Zum Hauptinhalt springen
LIVE
CVSS 7.4CVE-2026-138376 | AsyncSSH 1.13.1 before 2.24.2 contains an improper authentication vulnerability in SSHConnection._match_known_hosts that accumulates trusted client host keys across host-based authentication attempts on one connection. With trust_client_host enabled, attackers holding one known client host's private key can retry naming another known host and log in as users authorized only from that host.CVSS 7.6CVE-2026-138377 | AsyncSSH 1.13.1 before 2.24.2 contains an improper certificate validation vulnerability that allows remote clients to authenticate as users by abusing X.509 certificates matched in known_client_hosts. Attackers can make a failed host-based authentication attempt with any host key, adding host-only CA certificates to the trust anchors, then authenticate using user certificates issued under those CAs.CVSS 9.1CVE-2026-138378 | react-native-pure-jwt before 3.1.1 on Android contains a signature verification bypass vulnerability that allows unauthenticated attackers to forge tokens because RNPureJwtModule decode() calls JJWT parse() without algorithm pinning. Attackers can craft a token with header alg none and an empty signature to have arbitrary claims accepted as verified, forging identities or roles.CVSS 6.9CVE-2026-138379 | flare-redact before 1.13.1 contains a redaction bypass vulnerability that leaks secrets because the redact() object walker masks sensitive keys only when values are strings. Numbers, objects, arrays and binary data under keys such as password, cvv, pin, cookie or authorization pass through unchanged, exposing secrets in clear text to logger, Sentry, gateway and Fluent Bit sinks.CVSS 6.9CVE-2026-138380 | MediaInfoLib before 26.10 contains a heap-based buffer over-read vulnerability in File_Ogg::Data_Parse() that allows attackers to read beyond heap buffers via crafted Ogg segment sizes. Attackers can supply an Ogg file whose segment sizes exceed the page payload, wrapping the unsigned offset check and causing memcpy over-reads that crash the process or leak heap memory.CVSS 6.9CVE-2026-138381 | GNU LibreDWG 0.14 before 0.15 contains a heap use-after-free vulnerability in in_dxf.c new_object() where the OLE2FRAME oleclient pointer references freed memory after DXF import. Attackers can supply a DXF file with an OLE2FRAME entity to crash dxfwrite or similar applications and leak freed heap contents into exported output.CVSS 10.0CVE-2026-138227 | A vulnerability was found in D-Link R95 1.04B04Beta. This affects the function SetTimeSettings of the file /bin/ssi of the component DHMAPI. Performing a manipulation of the argument TZLocation results in os command injection. Remote exploitation of the attack is possible. The exploit has been made public and could be used.CVSS 10.0CVE-2026-138226 | A vulnerability has been found in D-Link R95 1.04B04Beta. Affected by this issue is the function SetSecureDNSSettings of the file /bin/ssi of the component DHMAPI SOAP interface. Such manipulation of the argument URI leads to os command injection. The attack may be launched remotely. The exploit has been disclosed to the public and may be used.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

Build a Notes App with ctrodb, Tailwind CSS, and Vanilla JavaScript

Let's build a notes app that runs entirely in the browser. Create, pin, search, and delete notes — all persisted to IndexedDB. No backend, no build step, no n…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 10 Min. Lesezeit
Quelle: dev.to
Rubrik: Secure Programming

Let's build a notes app that runs entirely in the browser. Create, pin, search, and delete notes — all persisted to IndexedDB. No backend, no build step, no npm install.



We'll use ctrodb for the database, Tailwind CSS for styling, and vanilla JavaScript for the glue.






What we're building



A single HTML file with:




  • Add notes with title, body, and tags

  • Pin important notes to the top

  • Search notes by title

  • Delete notes

  • Persistence across page reloads

  • Dark mode UI






Setting up






<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ctrodb Notes</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-900 text-gray-100 min-h-screen p-4 sm:p-6">






ctrodb ships as an IIFE that exposes a CtroDB global:




<script src="https://unpkg.com/ctrodb@1.0.1/dist/index.global.js"></script>
<script>
const { Database } = CtroDB






No bundler, no build step, no npm install.






Schema design






const schema = {
version: 1,
collections: {
notes: {
fields: {
title: { type: "string", required: true },
body: { type: "string", default: "" },
tags: { type: "array", items: { type: "string" }, default: [] },
pinned: { type: "boolean", default: false },
createdAt: { type: "string", default: () => new Date().toISOString() },
},
indexes: [
{ field: "createdAt" },
{ field: "pinned" },
],
},
},
}






The schema validates every write. A note without a title throws a ValidationError. Defaults fill in missing fields.






Connecting






const db = new Database({ name: "notes-app", schema })
await db.connect()
const notes = db.collection("notes")









Rendering notes



Each note card carries its own id directly in the markup via a data-id attribute:




function noteCard(note) {
const isPinned = note.pinned
return `
<div class="bg-gray-800 rounded-lg p-4 border ..." data-id="
${note.id}">
<h3>
${escapeHtml(note.title)}</h3>
<button class="pin-btn ...">
${isPinned ? "\u2605" : "\u2606"}</button>
<button class="delete-btn ...">\u2715</button>
</div>
`

}

async function render(message) {
const query = document.getElementById("search").value.trim()
const list = query
? await notes.query().search("title", query).fetch()
: await notes.query().sort({ pinned: "desc", createdAt: "desc" }).fetch()

if (list.length === 0) {
container.innerHTML = `<p>${message || "No notes yet."}</p>`
return
}

container.innerHTML = list.map(noteCard).join("")
}






Notice render() only builds HTML — it doesn't attach any click handlers. That's deliberate, and it's the key to the next section.






Wiring up pin and delete with event delegation



A common first instinct is to attach a click listener to every .pin-btn and .delete-btn right after rendering, capturing the note from the list array by index:




// Don't do this — see below for why
container.querySelectorAll(".pin-btn").forEach((btn, i) => {
btn.addEventListener("click", async () => {
const note = list[i]
await note.update({ pinned: !note.pinned })
await render()
})
})






This works at first glance, but it has two real problems. Every call to render() re-attaches a fresh batch of listeners on top of whatever's still pending from the previous render, and the handler closes over the list array by position — so if a search or sort ever reorders things between render and click, the index can point at the wrong note.



The more robust pattern is event delegation: attach a single listener to the container once, and read the note's id off the clicked card's data-id attribute at click time.




container.addEventListener("click", async (e) => {
const card = e.target.closest("[data-id]")
if (!card) return
const id = Number(card.dataset.id)

if (e.target.closest(".pin-btn")) {
const note = await notes.get(id)
if (note) {
await note.update({ pinned: !note.pinned })
await render()
}
return
}

if (e.target.closest(".delete-btn")) {
await notes.delete(id)
await render()
}
})






One listener, attached once in init(), handles every note — present and future — since clicks bubble up to container regardless of how many times innerHTML gets replaced.






The one gotcha: dataset.id is always a string



This is the part that trips people up, so it's worth calling out explicitly. element.dataset.id always returns a string — "1", "2", and so on — because HTML attributes are text. But ctrodb's default browser adapter is IndexedDB, and with keyPath: "id", autoIncrement: true, the ids it actually stores are numbers.



IndexedDB key lookups are type-sensitive: the string "1" and the number 1 are different keys. So notes.get(card.dataset.id) silently fails to find anything — no error, no thrown exception, just an undefined result that your if (note) guard quietly swallows. From the UI, it just looks like the pin and delete buttons don't do anything.



The fix is the Number(...) call above:




const id = Number(card.dataset.id)






Easy to miss, easy to fix, and a good reminder that anything pulled from dataset needs to be coerced back to its real type before you use it as a database key.






Adding notes






document.getElementById("add-note-btn").addEventListener("click", async () => {
const title = document.getElementById("title").value.trim()
const body = document.getElementById("body").value.trim()
const tags = document.getElementById("tags").value
.split(",").map(t => t.trim()).filter(Boolean)

if (!title) { alert("Title is required."); return }

await notes.create({ title, body, tags })
clearForm()
await render()
})








A 200ms debounce avoids excessive queries:




let searchTimer
document.getElementById("search").addEventListener("input", () => {
clearTimeout(searchTimer)
searchTimer = setTimeout(() => render(), 200)
})






query().search("title", query) does case-insensitive substring matching.






Complete code



Here's the full HTML file:




<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ctrodb Notes</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = { darkMode: "class" }
</script>
</head>
<body class="bg-gray-900 text-gray-100 min-h-screen p-4 sm:p-6">
<div class="max-w-2xl mx-auto">

<h1 class="text-3xl font-bold mb-8 flex items-center gap-3">
<span class="text-blue-400">◆</span>
ctrodb Notes
</h1>

<!-- Search -->
<div class="bg-gray-800 rounded-lg p-4 mb-6 border border-gray-700">
<input
id="search"
type="text"
placeholder="Search notes by title..."
class="w-full bg-gray-700 rounded px-3 py-2 text-gray-100 placeholder-gray-400 border border-gray-600 focus:outline-none focus:border-blue-500 transition-colors"
/>
</div>

<!-- New Note Form -->
<div class="bg-gray-800 rounded-lg p-4 mb-6 border border-gray-700">
<h2 class="font-semibold mb-3 text-gray-300">New Note</h2>
<input
id="title"
type="text"
placeholder="Title (required)"
required
class="w-full bg-gray-700 rounded px-3 py-2 mb-3 text-gray-100 placeholder-gray-400 border border-gray-600 focus:outline-none focus:border-blue-500 transition-colors"
/>
<textarea
id="body"
placeholder="Body (optional)"
rows="3"
class="w-full bg-gray-700 rounded px-3 py-2 mb-3 text-gray-100 placeholder-gray-400 border border-gray-600 focus:outline-none focus:border-blue-500 transition-colors resize-none"
></textarea>
<input
id="tags"
type="text"
placeholder="Tags (comma-separated)"
class="w-full bg-gray-700 rounded px-3 py-2 mb-3 text-gray-100 placeholder-gray-400 border border-gray-600 focus:outline-none focus:border-blue-500 transition-colors"
/>
<button
id="add-note-btn"
class="bg-blue-600 hover:bg-blue-500 text-white px-4 py-2 rounded font-medium transition-colors"
>
+ Add Note
</button>
</div>

<!-- Notes List -->
<div id="notes-container" class="space-y-3"></div>

</div>

<script src="https://unpkg.com/ctrodb@1.0.1/dist/index.global.js"></script>
<script>
const { Database } = CtroDB

const schema = {
version: 1,
collections: {
notes: {
fields: {
title: { type: "string", required: true },
body: { type: "string", default: "" },
tags: { type: "array", items: { type: "string" }, default: [] },
pinned: { type: "boolean", default: false },
createdAt: { type: "string", default: () => new Date().toISOString() },
},
indexes: [
{ field: "createdAt" },
{ field: "pinned" },
],
},
},
}

let db, notes, container

function escapeHtml(str) {
const div = document.createElement("div")
div.textContent = str
return div.innerHTML
}

function noteCard(note) {
const isPinned = note.pinned
return `
<div class="bg-gray-800 rounded-lg p-4 border transition-colors
${isPinned ? "border-yellow-500/60" : "border-gray-700"}" data-id="${note.id}">
<div class="flex items-start justify-between gap-4">
<div class="flex-1 min-w-0">
<h3 class="font-semibold text-lg truncate">
${escapeHtml(note.title)}</h3>
${note.body ? `<p class="text-gray-400 mt-1 line-clamp-3">${escapeHtml(note.body)}</p>` : ""}
${note.tags.length ? `
<div class="flex flex-wrap gap-2 mt-3">
${note.tags.map(t => `<span class="text-xs bg-gray-700 text-gray-300 px-2 py-0.5 rounded-full">${escapeHtml(t)}</span>`).join("")}
</div>
`
: ""}
<p class="text-xs text-gray-500 mt-3">
${new Date(note.createdAt).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" })}</p>
</div>
<div class="flex gap-1 shrink-0">
<button class="pin-btn p-1.5 rounded hover:bg-gray-700 transition-colors
${isPinned ? "text-yellow-400" : "text-gray-500 hover:text-yellow-400"}" title="${isPinned ? "Unpin" : "Pin"}">
${isPinned ? "\u2605" : "\u2606"}
</button>
<button class="delete-btn p-1.5 rounded hover:bg-gray-700 text-gray-500 hover:text-red-400 transition-colors" title="Delete">\u2715</button>
</div>
</div>
</div>
`

}

function clearForm() {
document.getElementById("title").value = ""
document.getElementById("body").value = ""
document.getElementById("tags").value = ""
}

async function render(message) {
const query = document.getElementById("search").value.trim()
const list = query
? await notes.query().search("title", query).fetch()
: await notes.query().sort({ pinned: "desc", createdAt: "desc" }).fetch()

if (list.length === 0) {
container.innerHTML = `<p class="text-gray-500 text-center py-8">${message || (query ? "No notes match your search." : "No notes yet. Create one above!")}</p>`
return
}

container.innerHTML = list.map(noteCard).join("")
}

async function init() {
db = new Database({ name: "notes-app", schema })
await db.connect()
notes = db.collection("notes")
container = document.getElementById("notes-container")

// Add note
document.getElementById("add-note-btn").addEventListener("click", async () => {
const title = document.getElementById("title").value.trim()
const body = document.getElementById("body").value.trim()
const rawTags = document.getElementById("tags").value

if (!title) { alert("Title is required."); return }

const tags = rawTags.split(",").map(t => t.trim()).filter(Boolean)
await notes.create({ title, body, tags })
clearForm()
await render()
})

// Search with debounce
let searchTimer
document.getElementById("search").addEventListener("input", () => {
clearTimeout(searchTimer)
searchTimer = setTimeout(() => render(), 200)
})

// Event delegation for pin and delete
container.addEventListener("click", async (e) => {
const card = e.target.closest("[data-id]")
if (!card) return
const id = Number(card.dataset.id)

if (e.target.closest(".pin-btn")) {
const note = await notes.get(id)
if (note) {
await note.update({ pinned: !note.pinned })
await render()
}
return
}

if (e.target.closest(".delete-btn")) {
await notes.delete(id)
await render()
}
})

await render()
}

init()
</script>
</body>
</html>






Save it as notes.html and open it in any browser. Add notes, pin them, search, delete — all operations work with full IndexedDB persistence.






What's happening




  • ctrodb connects to IndexedDB, creates the notes-app database

  • The schema validates every write — wrong types or missing required fields throw


  • query().search("title", query) does case-insensitive substring matching

  • A single delegated click listener on #notes-container handles pin and delete for every note, current and future — no listeners to re-attach on each render

  • Ids read from data-id are coerced with Number(...) before being passed back to ctrodb, since IndexedDB's autoincrement keys are numeric but dataset values are always strings

  • Everything runs in-process — no network requests, no server



Try the browser playground at https://ctrodb.vercel.app/playground.






ctrodb is open source. GitHub: https://github.com/ctrotech-tutor/ctrodb. Docs: https://ctrodb.vercel.app/docs/getting-started/quick-start.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Community discussion & comments

🌐 Join the main chat

Start the discussion in the Social Chat broadcast stream or submit an expert contribution via the supplement form above.

Community Rating &amp; Social Proof
⭐ Reader Rating
–
Ø / 5.0
No reader ratings yet
Was this article helpful?
0
Submit your rating
Detailed rating (optional)
Content & Quality
Source & Credibility
Freshness
Security Briefing Free · 1-Click Unsubscribe

Intelligence Digest — free

The top security news daily · unsubscribe anytime

Related story clusters & sources (vector AI)

6 Cluster
25 sources
CVE-2026-135550 | Mozilla Firefox Web Codecs memory corruption (Nessus ID 388625)
VulDB Updates 1 hour ago
24 more sources
VulDB Updates1 hour agoCVE-2026-135551 | Mozilla Firefox up to 153.7/160 Layout use after free (Nessus ID 388625) VulDB Updates1 hour agoCVE-2026-135552 | Mozilla Firefox up to 115.45/153.7/160 Canvas2D use after free (Nessus ID 388625) VulDB Updates1 hour agoCVE-2026-135554 | Mozilla Firefox up to 115.45/153.7/160 Navigation use after free (Nessus ID 388625) VulDB Updates1 hour agoCVE-2026-135556 | Mozilla Firefox up to 115.45/153.7/160 JIT memory corruption (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135540 | Mozilla Firefox up to 115.45/153.7/160 JIT memory corruption (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135539 | Mozilla Firefox up to 115.45/153.7/160 CSS Object Model use after free (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135542 | Mozilla Firefox up to 115.45/153.7/160 Layout buffer overflow (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135541 | Mozilla Firefox up to 115.45/153.7/160 XSLT use after free (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135544 | Mozilla Firefox up to 115.45/153.7/160 Navigation memory corruption (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135545 | Mozilla Firefox up to 153.7/160 Editor memory corruption (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135543 | Mozilla Firefox up to 115.45/153.7/160 Networking memory corruption (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135547 | Mozilla Firefox up to 115.45/153.7/160 Networking sandbox (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135549 | Mozilla Firefox up to 115.45/153.7/160 XSLT use after free (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135548 | Mozilla Firefox up to 115.45/153.7/160 Layout use after free (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135533 | Mozilla Firefox up to 115.45/153.7/160 Layout Tables off-by-one (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135536 | Mozilla Firefox up to 115.45/153.7/160 DOM Editor uninitialized pointer (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135535 | Mozilla Firefox up to 115.45/153.7/160 Skia input validation (Nessus ID 388625) VulDB Updates4 hours agoCVE-2026-135537 | Mozilla Firefox up to 115.45/153.7/160 Layout Text/Fonts out-of-bounds (Nessus ID 388625) VulDB Updates5 hours agoCVE-2026-135525 | Mozilla Firefox up to 115.45/153.7/160 WebRender use after free (Nessus ID 388625) VulDB Updates5 hours agoCVE-2026-135526 | Mozilla Firefox up to 115.45/153.7/160 Networking use after free (Nessus ID 388625) VulDB Updates5 hours agoCVE-2026-135527 | Mozilla Firefox up to 115.45/153.7/160 DOM/HTML use after free (Nessus ID 388625) VulDB Updates5 hours agoCVE-2026-135528 | Mozilla Firefox up to 153.7/160 HTTP race condition (Nessus ID 388625) VulDB Updates5 hours agoCVE-2026-135530 | Mozilla Firefox up to 115.45/153.7/160 HTTP sandbox (Nessus ID 388625) VulDB Updates5 hours agoCVE-2026-135529 | Mozilla Firefox up to 153.7/160 Text sandbox (Nessus ID 388625)
17 sources
Apple Cyber Monday Deals (2026): AirPods, iPads, MacBooks, and More
WIRED 23 min. ago
16 more sources
The Mac Observer31 min. agoAqara W200 thermostat is $119.99 for Cyber Monday, $40 off and Apple Home ready Latest from TechRadar50 min. agoCyber Monday mini PC deals 2026 live — top tiny desktops from GMKtec, Geekom, Minisforum, and more as the Black Friday sale continues The Mac Observer56 min. agoSonos Beam Gen 2 is $339 for Cyber Monday, $160 off and $359 under two HomePods The Mac Observer1 hour agoMagic Mouse in black drops to $79.99 for Cyber Monday, $19 under Apple’s $99 The Mac Observer1 hour agoGarmin fenix 8 47mm drops $250 to $749.99 for Cyber Monday, $49 under Ultra 4 Latest from TechRadar2 hours agoI've been waiting for a better deal on the Philips LatteGo 4400 — and Amazon has delivered a record-low price for Cyber Monday Latest from TechRadar2 hours agoLooking to get a last-minute gaming gift before Cyber Monday is over? WIRED3 hours agoLast Call for Black Friday iPad Deals (2026): Save Up to $100 Latest from Windows Central3 hours agoWhy I bought a handheld over a gaming laptop on Cyber Monday Latest from TechRadar3 hours agoI found the most capable PC under $300 for Cyber Monday — Origimagic's C7 Windows 11 Pro machine packs dual Thunderbolt 4, 2.5Gb LAN, a Core 3 100U, 16GB of RAM, and a 512GB SSD OS X Daily3 hours agoCyber Monday Deals: $300 Off 16″ PROLED MacBook Pro, $100 Off AirPods Pro 3, $100 Off iPad Air, & More Latest from TechRadar4 hours agoCyber Monday home office deals 2026 live — our top workspace picks from FlexiSpot, Dell, Anker, Logitech and more as Black Friday sale rolls on Latest from TechRadar4 hours agoThe best Cyber Monday deals in the UK in 2026: top picks from Amazon, Argos, Ninja, Lego and more Latest from TechRadar4 hours agoBlack Friday laptop deals 2026: the huge savings on MacBooks, Chromebooks and Windows 11 laptops still available from Apple, Dell, HP and many more Latest from TechRadar4 hours agoCyber Monday Australia laptop deals for 2026: score up to 52% off Lenovo, Apple, Dell, HP and more Latest from TechRadar4 hours agoAmazon Australia Cyber Monday deals
12 sources
CVE-2026-116159 | ImageMagick up to 6.9.13-57/7.1.2-32 CDL Option memory leak (Nessus ID 388637)
VulDB Updates 1 hour ago
11 more sources
Similar posts
🔍 Verwandte News

Auch interessante Nachrichten Build a Notes App with ctrodb, Tailwind CSS, and Vanilla JavaScript

Thematisch verwandte Begriffe: Build, Notes, with, ctrodb · 6 Treffer

Laden...

Loading posts ...

Laden...

Loading videos ...

Laden...

Loading posts ...

Laden...

Loading videos ...

Laden...

Loading posts ...

Laden...

Loading videos ...

Laden...

Loading posts ...

Laden...

Loading videos ...

💬 Loading comments…
Pull to refresh
Widgets & topics
Loading widgets…
Next post