[Frontend] Edge Intelligence — browser model + silent Nostr identity signing #65
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & Why
Move the cheapest cognitive work to the browser GPU so it never touches the server. A Transformers.js Web Worker runs a small classification model locally to pre-screen requests before submission. Simultaneously,
nostr-tools(3kb) lets the browser sign Nostr challenge nonces to prove identity — enabling free-tier access — without any private key ever leaving the device. Combined effect: Timmy's free-tier users identify themselves and get filtered responses at zero upstream cost.Done looks like
Out of scope
Tasks
public/edge-worker.js: import Transformers.js, loadXenova/distilbert-base-uncased-finetuned-sst-2-english(lightest useful model), exposeclassify(text)→{label, score}. Post status events back to main thread.nostr_nsec, silently callGET /api/identity/challenge+ sign nonce withnostr-tools signEvent+ callPOST /api/identity/verify→ store returned token. Ifwindow.nostr(nos2x) available, usewindow.nostr.signEventinstead.Relevant files
the-matrix/index.htmlthe-matrix/js/ui.jsthe-matrix/js/websocket.jsthe-matrix/js/session.jsartifacts/api-server/src/routes/identity.ts