@qntx/wallet 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -4
- package/dist/{protocol-D9_0sY_Y.mjs → core-QJ66nLLG.mjs} +91 -228
- package/dist/core-QJ66nLLG.mjs.map +1 -0
- package/dist/host.d.mts +19 -3
- package/dist/host.mjs +101 -11
- package/dist/host.mjs.map +1 -1
- package/dist/index-Dhf6wGjQ.d.mts +668 -0
- package/dist/index.d.mts +18 -2
- package/dist/index.mjs +35 -1
- package/dist/index.mjs.map +1 -0
- package/dist/internal-LBHal13j.mjs +25 -0
- package/dist/internal-LBHal13j.mjs.map +1 -0
- package/dist/nostr.d.mts +2 -2
- package/dist/nostr.mjs +13 -5
- package/dist/nostr.mjs.map +1 -1
- package/dist/protocol-D9xBuMzq.mjs +697 -0
- package/dist/protocol-D9xBuMzq.mjs.map +1 -0
- package/dist/protocol.d.mts +3 -3
- package/dist/protocol.mjs +3 -2
- package/dist/{secret-B-P3QOym.mjs → secret-IcTjjaX0.mjs} +113 -31
- package/dist/secret-IcTjjaX0.mjs.map +1 -0
- package/dist/spark.d.mts +30 -0
- package/dist/spark.mjs +303 -0
- package/dist/spark.mjs.map +1 -0
- package/dist/{types-CEy7At1l.d.mts → types-D4OUjGVS.d.mts} +62 -8
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs.map +1 -1
- package/package.json +16 -5
- package/dist/index-BJfyIwOZ.d.mts +0 -286
- package/dist/protocol-D9_0sY_Y.mjs.map +0 -1
- package/dist/secret-B-P3QOym.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,36 @@
|
|
|
1
|
+
import { D as validate } from "./core-QJ66nLLG.mjs";
|
|
2
|
+
import { d as backupEnvelope, m as backupHeader } from "./protocol-D9xBuMzq.mjs";
|
|
1
3
|
import { WalletError } from "./types.mjs";
|
|
2
|
-
|
|
4
|
+
//#region src/backup.ts
|
|
5
|
+
function integrity(msg) {
|
|
6
|
+
throw new WalletError("integrity", `backup: ${msg}`);
|
|
7
|
+
}
|
|
8
|
+
function json(text, what) {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(text);
|
|
11
|
+
} catch {
|
|
12
|
+
return integrity(`${what} is not JSON`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Strictly validates the envelope and returns the header fields — no secrets, no writes. */
|
|
16
|
+
function parseBackupHeader(envelope) {
|
|
17
|
+
if (envelope.length > 4e6) integrity("envelope too large");
|
|
18
|
+
const parsed = validate(backupEnvelope, json(envelope, "envelope"));
|
|
19
|
+
if (parsed === void 0) integrity("malformed envelope");
|
|
20
|
+
const header = validate(backupHeader, json(parsed.header, "header"));
|
|
21
|
+
if (header === void 0) integrity("malformed header");
|
|
22
|
+
const factorKinds = parsed.factors.map((f) => f.kind);
|
|
23
|
+
if (factorKinds.filter((k) => k === "password").length > 1) integrity("at most one password factor");
|
|
24
|
+
return {
|
|
25
|
+
version: 1,
|
|
26
|
+
createdAt: parsed.createdAt,
|
|
27
|
+
wallets: header.wallets,
|
|
28
|
+
importedNostrKeyCount: header.importedNostrKeyCount,
|
|
29
|
+
importedChainKeyCount: header.importedChainKeyCount,
|
|
30
|
+
factorKinds
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { WalletError, parseBackupHeader };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/backup.ts"],"sourcesContent":["// Read-only envelope inspection for the host: lists what a backup restores before the factor\n// ceremony runs. `header` is authenticated by the payload tag at restore time — this parser only\n// validates structure (bounded lengths, unknown fields rejected via the shared validators), so\n// nothing garbage reaches the kernel.\n\nimport type { BackupHeaderWire } from \"./protocol/index.ts\";\nimport { backupEnvelope, backupHeader, validate } from \"./protocol/index.ts\";\nimport { WalletError } from \"./types.ts\";\n\nexport type BackupHeaderWallet = BackupHeaderWire[\"wallets\"][number];\n\nexport type BackupHeader = {\n readonly version: 1;\n readonly createdAt: number;\n readonly wallets: ReadonlyArray<BackupHeaderWallet>;\n readonly importedNostrKeyCount: number;\n readonly importedChainKeyCount: number;\n /** The factor kinds the envelope can be unwrapped with. */\n readonly factorKinds: ReadonlyArray<\"passkey\" | \"password\">;\n};\n\nfunction integrity(msg: string): never {\n throw new WalletError(\"integrity\", `backup: ${msg}`);\n}\n\nfunction json(text: string, what: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return integrity(`${what} is not JSON`);\n }\n}\n\n/** Strictly validates the envelope and returns the header fields — no secrets, no writes. */\nexport function parseBackupHeader(envelope: string): BackupHeader {\n if (envelope.length > 4_000_000) {\n integrity(\"envelope too large\");\n }\n const parsed = validate(backupEnvelope, json(envelope, \"envelope\"));\n if (parsed === undefined) {\n integrity(\"malformed envelope\");\n }\n const header = validate(backupHeader, json(parsed.header, \"header\"));\n if (header === undefined) {\n integrity(\"malformed header\");\n }\n const factorKinds = parsed.factors.map((f) => f.kind);\n if (factorKinds.filter((k) => k === \"password\").length > 1) {\n integrity(\"at most one password factor\");\n }\n return {\n version: 1,\n createdAt: parsed.createdAt,\n wallets: header.wallets,\n importedNostrKeyCount: header.importedNostrKeyCount,\n importedChainKeyCount: header.importedChainKeyCount,\n factorKinds,\n };\n}\n"],"mappings":";;;;AAqBA,SAAS,UAAU,KAAoB;CACrC,MAAM,IAAI,YAAY,aAAa,WAAW,KAAK;AACrD;AAEA,SAAS,KAAK,MAAc,MAAuB;CACjD,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,QAAQ;EACN,OAAO,UAAU,GAAG,KAAK,aAAa;CACxC;AACF;;AAGA,SAAgB,kBAAkB,UAAgC;CAChE,IAAI,SAAS,SAAS,KACpB,UAAU,oBAAoB;CAEhC,MAAM,SAAS,SAAS,gBAAgB,KAAK,UAAU,UAAU,CAAC;CAClE,IAAI,WAAW,KAAA,GACb,UAAU,oBAAoB;CAEhC,MAAM,SAAS,SAAS,cAAc,KAAK,OAAO,QAAQ,QAAQ,CAAC;CACnE,IAAI,WAAW,KAAA,GACb,UAAU,kBAAkB;CAE9B,MAAM,cAAc,OAAO,QAAQ,KAAK,MAAM,EAAE,IAAI;CACpD,IAAI,YAAY,QAAQ,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GACvD,UAAU,6BAA6B;CAEzC,OAAO;EACL,SAAS;EACT,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,uBAAuB,OAAO;EAC9B,uBAAuB,OAAO;EAC9B;CACF;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WalletError } from "./types.mjs";
|
|
2
|
+
//#region src/internal.ts
|
|
3
|
+
/**
|
|
4
|
+
* Channel internals shared between the core Wallet and the protocol subpath modules
|
|
5
|
+
* (@qntx/wallet/nostr, later spark/chains). This file is NOT a package subpath — modules look a
|
|
6
|
+
* Wallet up in the WeakMap, so a foreign object has no channel to reach.
|
|
7
|
+
*/
|
|
8
|
+
const internals = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
function registerInternals(wallet, value) {
|
|
10
|
+
internals.set(wallet, value);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The internals behind a Wallet from this package — or `invalid-input` for anything else. A foreign
|
|
14
|
+
* object can imitate the Wallet shape but can never hold the channel: modules that look it up here
|
|
15
|
+
* get a closed failure, not a crafted kernel.
|
|
16
|
+
*/
|
|
17
|
+
function internalsOf(wallet) {
|
|
18
|
+
const found = internals.get(wallet);
|
|
19
|
+
if (found === void 0) throw new WalletError("invalid-input", "not a Wallet from @qntx/wallet");
|
|
20
|
+
return found;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { registerInternals as n, internalsOf as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=internal-LBHal13j.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-LBHal13j.mjs","names":[],"sources":["../src/internal.ts"],"sourcesContent":["import type { Factor, MethodName, ParamsOf, ResultOf } from \"./protocol/index.ts\";\n/**\n * Channel internals shared between the core Wallet and the protocol subpath modules\n * (@qntx/wallet/nostr, later spark/chains). This file is NOT a package subpath — modules look a\n * Wallet up in the WeakMap, so a foreign object has no channel to reach.\n */\nimport { WalletError } from \"./types.ts\";\nimport type { InitialFactor, UnlockFactor, Wallet, WalletSnapshot } from \"./types.ts\";\n\nexport type WalletInternals = {\n /** One validated request on the kernel channel (awaits the live port's first status). */\n readonly call: <M extends MethodName>(\n method: M,\n params: ParamsOf<M>,\n transfer?: ArrayBuffer[],\n ) => Promise<ResultOf<M>>;\n /** The live kernel port's first-status gate — re-read per call (a respawn replaces it). */\n readonly ready: () => Promise<void>;\n readonly snapshot: () => WalletSnapshot;\n /** Marks a user verification in flight on the snapshot (`verifying`). */\n readonly withVerifying: <T>(fn: () => Promise<T>) => Promise<T>;\n /** Public UnlockFactor → wire factor material (the passkey ceremony runs here). */\n readonly resolveFactor: (factor: UnlockFactor, transfer: ArrayBuffer[]) => Promise<Factor>;\n /** The create/import factor gate: required on an uninitialized vault, forbidden after. */\n readonly createFactorParam: (\n factor: InitialFactor | undefined,\n transfer: ArrayBuffer[],\n ) => Promise<Factor | undefined>;\n /** Adopts the session a create/import result opened onto the channel. */\n readonly sessionOf: (result: { readonly session: string }) => void;\n};\n\nconst internals = new WeakMap<Wallet, WalletInternals>();\n\nexport function registerInternals(wallet: Wallet, value: WalletInternals): void {\n internals.set(wallet, value);\n}\n\n/**\n * The internals behind a Wallet from this package — or `invalid-input` for anything else. A foreign\n * object can imitate the Wallet shape but can never hold the channel: modules that look it up here\n * get a closed failure, not a crafted kernel.\n */\nexport function internalsOf(wallet: Wallet): WalletInternals {\n const found = internals.get(wallet);\n if (found === undefined) {\n throw new WalletError(\"invalid-input\", \"not a Wallet from @qntx/wallet\");\n }\n return found;\n}\n"],"mappings":";;;;;;;AAgCA,MAAM,4BAAY,IAAI,QAAiC;AAEvD,SAAgB,kBAAkB,QAAgB,OAA8B;CAC9E,UAAU,IAAI,QAAQ,KAAK;AAC7B;;;;;;AAOA,SAAgB,YAAY,QAAiC;CAC3D,MAAM,QAAQ,UAAU,IAAI,MAAM;CAClC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,YAAY,iBAAiB,gCAAgC;CAEzE,OAAO;AACT"}
|
package/dist/nostr.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as DerivedNostrKey, b as WalletErrorCode, c as InitialFactor, d as NostrKeyInfo, f as NostrKeyRef, h as UnlockFactor, o as ExportedSecret, v as Wallet } from "./types-D4OUjGVS.mjs";
|
|
2
2
|
import { Event, NostrSigner } from "@qntx/nostr";
|
|
3
3
|
import { Rumor } from "@qntx/nostr/nips/nip59";
|
|
4
4
|
//#region src/nostr/types.d.ts
|
|
@@ -9,7 +9,7 @@ type NostrUnwrapResult = {
|
|
|
9
9
|
};
|
|
10
10
|
/** A proxy NostrSigner: the kernel key is resolved per call, so it survives lock/unlock cycles. */
|
|
11
11
|
type WalletSigner = {
|
|
12
|
-
readonly unwrapGiftWraps: (events: ReadonlyArray<Event>) => Promise<ReadonlyArray<
|
|
12
|
+
readonly unwrapGiftWraps: (events: ReadonlyArray<Event>) => Promise<ReadonlyArray<Rumor | Error>>;
|
|
13
13
|
} & NostrSigner;
|
|
14
14
|
type NostrImportKeyInput = {
|
|
15
15
|
readonly nsec: string;
|
package/dist/nostr.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WalletError } from "./types.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { f as wireSecretText, m as integrity, t as SingleUseSecret } from "./secret-IcTjjaX0.mjs";
|
|
3
|
+
import { t as internalsOf } from "./internal-LBHal13j.mjs";
|
|
3
4
|
import { signedMatchesUnsigned, verifyEvent } from "@qntx/nostr";
|
|
4
5
|
//#region src/nostr/signer.ts
|
|
5
6
|
/**
|
|
@@ -73,10 +74,17 @@ function proxySigner(ref, internals) {
|
|
|
73
74
|
text: payload
|
|
74
75
|
}),
|
|
75
76
|
unwrapGiftWraps: async (events) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
if (events.length === 0) return [];
|
|
78
|
+
const publicKey = resolvePublicKey();
|
|
79
|
+
const results = [];
|
|
80
|
+
for (let start = 0; start < events.length; start += 64) {
|
|
81
|
+
const batch = await internals.call("nostr.unwrapGiftWraps", {
|
|
82
|
+
publicKey,
|
|
83
|
+
events: events.slice(start, start + 64)
|
|
84
|
+
});
|
|
85
|
+
for (const r of batch.results) results.push("ok" in r ? r.ok : new Error(r.err));
|
|
86
|
+
}
|
|
87
|
+
return results;
|
|
80
88
|
}
|
|
81
89
|
};
|
|
82
90
|
}
|
package/dist/nostr.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nostr.mjs","names":[],"sources":["../src/nostr/signer.ts","../src/nostr/index.ts"],"sourcesContent":["/**\n * The proxy NostrSigner: the ref resolves against the CURRENT snapshot at every call, so the same\n * signer object keeps working across lock/unlock and worker respawns. Returned events are checked\n * against the request — a compromised kernel cannot make a valid signature over different content\n * pass as the requested event.\n */\nimport { signedMatchesUnsigned, verifyEvent } from \"@qntx/nostr\";\nimport type { UnsignedEvent } from \"@qntx/nostr\";\n\nimport { integrity } from \"../channel.ts\";\nimport type { WalletInternals } from \"../internal.ts\";\nimport type { UnsignedEventInput } from \"../protocol/index.ts\";\nimport { WalletError } from \"../types.ts\";\nimport type { NostrKeyInfo, NostrKeyRef } from \"../types.ts\";\nimport type { NostrUnwrapResult, WalletSigner } from \"./types.ts\";\n\n/** Resolves a public ref to its stored key record; missing refs are `not-found`. */\nexport function keyInfoOf(internals: WalletInternals, ref: NostrKeyRef): NostrKeyInfo {\n const info = internals.snapshot().nostr.keys.find((key) => {\n const k = key.ref;\n return (\n (ref.kind === \"derived\" &&\n k.kind === \"derived\" &&\n k.walletId === ref.walletId &&\n k.groupIndex === ref.groupIndex) ||\n (ref.kind === \"nip46-client\" && k.kind === \"nip46-client\" && k.id === ref.id) ||\n (ref.kind === \"standalone\" && k.kind === \"standalone\" && k.id === ref.id)\n );\n });\n if (info === undefined) {\n throw new WalletError(\"not-found\", \"no such nostr key\");\n }\n return info;\n}\n\nexport function proxySigner(ref: NostrKeyRef, internals: WalletInternals): WalletSigner {\n const resolvePublicKey = (): string => keyInfoOf(internals, ref).publicKey;\n return {\n getPublicKey: async () => {\n await internals.ready();\n return resolvePublicKey();\n },\n signEvent: async (unsigned) => {\n const publicKey = resolvePublicKey();\n // An absent pubkey must stay absent: `pubkey: undefined` is not a ProtocolValue and the\n // kernel would reject the params outright.\n const event: UnsignedEventInput =\n unsigned.pubkey === undefined\n ? {\n kind: unsigned.kind,\n created_at: unsigned.created_at,\n tags: unsigned.tags,\n content: unsigned.content,\n }\n : {\n kind: unsigned.kind,\n created_at: unsigned.created_at,\n tags: unsigned.tags,\n content: unsigned.content,\n pubkey: unsigned.pubkey,\n };\n const signed = await internals.call(\"nostr.signEvent\", { publicKey, event });\n // The kernel output must be the requested event, signed by the expected key.\n const requested: UnsignedEvent = {\n kind: unsigned.kind,\n created_at: unsigned.created_at,\n tags: unsigned.tags,\n content: unsigned.content,\n pubkey: publicKey,\n };\n if (\n signed.pubkey !== publicKey ||\n !signedMatchesUnsigned(signed, requested) ||\n !verifyEvent(signed)\n ) {\n throw integrity(\"the kernel returned a forged event\");\n }\n return signed;\n },\n nip04Encrypt: async (peer, plaintext) =>\n internals.call(\"nostr.nip04Encrypt\", {\n publicKey: resolvePublicKey(),\n peer,\n text: plaintext,\n }),\n nip04Decrypt: async (peer, ciphertext) =>\n internals.call(\"nostr.nip04Decrypt\", {\n publicKey: resolvePublicKey(),\n peer,\n text: ciphertext,\n }),\n nip44Encrypt: async (peer, plaintext) =>\n internals.call(\"nostr.nip44Encrypt\", {\n publicKey: resolvePublicKey(),\n peer,\n text: plaintext,\n }),\n nip44Decrypt: async (peer, payload) =>\n internals.call(\"nostr.nip44Decrypt\", {\n publicKey: resolvePublicKey(),\n peer,\n text: payload,\n }),\n unwrapGiftWraps: async (events): Promise<ReadonlyArray<NostrUnwrapResult>> => {\n const result = await internals.call(\"nostr.unwrapGiftWraps\", {\n publicKey: resolvePublicKey(),\n events: [...events],\n });\n return result.results;\n },\n };\n}\n","/**\n * The nostr module of @qntx/wallet: `nostr(wallet)` returns the wallet's Nostr API — signer\n * proxies, key discovery/derivation/import/generation, guarded export and removal. The API is\n * memoized per wallet so repeated calls return the same object (stable React identity); a foreign\n * object is rejected because only a Wallet from this package holds a registered channel.\n */\nimport { wireSecretText } from \"../factors.ts\";\nimport { internalsOf } from \"../internal.ts\";\nimport type { WalletInternals } from \"../internal.ts\";\nimport { SingleUseSecret } from \"../secret.ts\";\nimport { WalletError } from \"../types.ts\";\nimport type {\n DerivedNostrKey,\n ExportedSecret,\n InitialFactor,\n NostrKeyInfo,\n NostrKeyRef,\n UnlockFactor,\n Wallet,\n} from \"../types.ts\";\nimport { keyInfoOf, proxySigner } from \"./signer.ts\";\nimport type { NostrApi, NostrExportKeyFormat, NostrImportKeyInput, WalletSigner } from \"./types.ts\";\n\nexport type {\n DerivedNostrKey,\n NostrApi,\n NostrExportKeyFormat,\n NostrImportKeyInput,\n NostrKeyInfo,\n NostrKeyRef,\n NostrUnwrapResult,\n WalletSigner,\n} from \"./types.ts\";\n\nfunction createNostrApi(internals: WalletInternals): NostrApi {\n return {\n signer: (ref: NostrKeyRef): WalletSigner => proxySigner(ref, internals),\n\n discover: async (\n walletId: string,\n from: number,\n count: number,\n ): Promise<ReadonlyArray<DerivedNostrKey>> => {\n const result = await internals.call(\"nostr.discover\", { walletId, from, count });\n return result.keys;\n },\n\n deriveKey: async (walletId: string, groupIndex: number): Promise<NostrKeyInfo> =>\n internals.call(\"nostr.deriveKey\", { walletId, groupIndex }),\n\n importKey: async (\n input: NostrImportKeyInput,\n options?: { readonly factor?: InitialFactor },\n ): Promise<NostrKeyInfo> => {\n const transfer: ArrayBuffer[] = [];\n const factor = await internals.createFactorParam(options?.factor, transfer);\n const wireInput =\n \"nsec\" in input\n ? { kind: \"nsec\" as const, nsec: wireSecretText(input.nsec, transfer) }\n : {\n kind: \"ncryptsec\" as const,\n ncryptsec: input.ncryptsec,\n password: wireSecretText(input.password, transfer),\n };\n const result = await internals.call(\n \"nostr.importKey\",\n { input: wireInput, ...(factor === undefined ? {} : { factor }) },\n transfer,\n );\n internals.sessionOf(result);\n return result.key;\n },\n\n generateKey: async (options?: { readonly factor?: InitialFactor }): Promise<NostrKeyInfo> => {\n const transfer: ArrayBuffer[] = [];\n const factor = await internals.createFactorParam(options?.factor, transfer);\n const result = await internals.call(\n \"nostr.generateKey\",\n factor === undefined ? {} : { factor },\n transfer,\n );\n internals.sessionOf(result);\n return result.key;\n },\n\n createNip46ClientKey: async (): Promise<NostrKeyInfo> =>\n internals.call(\"nostr.createNip46ClientKey\", null),\n\n removeKey: async (ref: NostrKeyRef, verify?: UnlockFactor): Promise<void> =>\n internals.withVerifying(async () => {\n const info = keyInfoOf(internals, ref); // resolves ref → publicKey + origin\n const transfer: ArrayBuffer[] = [];\n let wireVerify;\n if (info.origin !== \"nip46-client\") {\n if (verify === undefined) {\n throw new WalletError(\"invalid-input\", \"factor verification is required\");\n }\n wireVerify = await internals.resolveFactor(verify, transfer);\n }\n await internals.call(\n \"nostr.removeKey\",\n {\n publicKey: info.publicKey,\n ...(wireVerify === undefined ? {} : { verify: wireVerify }),\n },\n transfer,\n );\n }),\n\n exportKey: async (\n ref: NostrKeyRef,\n format: NostrExportKeyFormat,\n verify: UnlockFactor,\n ): Promise<ExportedSecret> =>\n internals.withVerifying(async () => {\n const { publicKey } = keyInfoOf(internals, ref);\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await internals.resolveFactor(verify, transfer);\n const wireFormat =\n format.kind === \"nsec\"\n ? { kind: \"nsec\" as const }\n : {\n kind: \"ncryptsec\" as const,\n password: wireSecretText(format.password, transfer),\n };\n const bytes = await internals.call(\n \"nostr.exportKey\",\n { verify: wireVerify, publicKey, format: wireFormat },\n transfer,\n );\n return new SingleUseSecret(bytes);\n }),\n };\n}\n\nconst apis = new WeakMap<Wallet, NostrApi>();\n\nexport function nostr(wallet: Wallet): NostrApi {\n const internals = internalsOf(wallet);\n let api = apis.get(wallet);\n if (api === undefined) {\n api = createNostrApi(internals);\n apis.set(wallet, api);\n }\n return api;\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,UAAU,WAA4B,KAAgC;CACpF,MAAM,OAAO,UAAU,SAAS,CAAC,CAAC,MAAM,KAAK,MAAM,QAAQ;EACzD,MAAM,IAAI,IAAI;EACd,OACG,IAAI,SAAS,aACZ,EAAE,SAAS,aACX,EAAE,aAAa,IAAI,YACnB,EAAE,eAAe,IAAI,cACtB,IAAI,SAAS,kBAAkB,EAAE,SAAS,kBAAkB,EAAE,OAAO,IAAI,MACzE,IAAI,SAAS,gBAAgB,EAAE,SAAS,gBAAgB,EAAE,OAAO,IAAI;CAE1E,CAAC;CACD,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,YAAY,aAAa,mBAAmB;CAExD,OAAO;AACT;AAEA,SAAgB,YAAY,KAAkB,WAA0C;CACtF,MAAM,yBAAiC,UAAU,WAAW,GAAG,CAAC,CAAC;CACjE,OAAO;EACL,cAAc,YAAY;GACxB,MAAM,UAAU,MAAM;GACtB,OAAO,iBAAiB;EAC1B;EACA,WAAW,OAAO,aAAa;GAC7B,MAAM,YAAY,iBAAiB;GAGnC,MAAM,QACJ,SAAS,WAAW,KAAA,IAChB;IACE,MAAM,SAAS;IACf,YAAY,SAAS;IACrB,MAAM,SAAS;IACf,SAAS,SAAS;GACpB,IACA;IACE,MAAM,SAAS;IACf,YAAY,SAAS;IACrB,MAAM,SAAS;IACf,SAAS,SAAS;IAClB,QAAQ,SAAS;GACnB;GACN,MAAM,SAAS,MAAM,U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OAAO,SAAS,SACZ,EAAE,MAAM,OAAgB,IACxB;IACE,MAAM;IACN,UAAU,eAAe,OAAO,UAAU,QAAQ;GACpD;GACN,MAAM,QAAQ,MAAM,UAAU,KAC5B,mBACA;IAAE,QAAQ;IAAY;IAAW,QAAQ;GAAW,GACpD,QACF;GACA,OAAO,IAAI,gBAAgB,KAAK;EAClC,CAAC;CACL;AACF;AAEA,MAAM,uBAAO,IAAI,QAA0B;AAE3C,SAAgB,MAAM,QAA0B;CAC9C,MAAM,YAAY,YAAY,MAAM;CACpC,IAAI,MAAM,KAAK,IAAI,MAAM;CACzB,IAAI,QAAQ,KAAA,GAAW;EACrB,MAAM,eAAe,SAAS;EAC9B,KAAK,IAAI,QAAQ,GAAG;CACtB;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"nostr.mjs","names":[],"sources":["../src/nostr/signer.ts","../src/nostr/index.ts"],"sourcesContent":["/**\n * The proxy NostrSigner: the ref resolves against the CURRENT snapshot at every call, so the same\n * signer object keeps working across lock/unlock and worker respawns. Returned events are checked\n * against the request — a compromised kernel cannot make a valid signature over different content\n * pass as the requested event.\n */\nimport { signedMatchesUnsigned, verifyEvent } from \"@qntx/nostr\";\nimport type { UnsignedEvent } from \"@qntx/nostr\";\nimport type { Rumor } from \"@qntx/nostr/nips/nip59\";\n\nimport { integrity } from \"../channel.ts\";\nimport type { WalletInternals } from \"../internal.ts\";\nimport { MAX_BATCH } from \"../protocol/core.ts\";\nimport type { UnsignedEventInput } from \"../protocol/index.ts\";\nimport { WalletError } from \"../types.ts\";\nimport type { NostrKeyInfo, NostrKeyRef } from \"../types.ts\";\nimport type { WalletSigner } from \"./types.ts\";\n\n/** Resolves a public ref to its stored key record; missing refs are `not-found`. */\nexport function keyInfoOf(internals: WalletInternals, ref: NostrKeyRef): NostrKeyInfo {\n const info = internals.snapshot().nostr.keys.find((key) => {\n const k = key.ref;\n return (\n (ref.kind === \"derived\" &&\n k.kind === \"derived\" &&\n k.walletId === ref.walletId &&\n k.groupIndex === ref.groupIndex) ||\n (ref.kind === \"nip46-client\" && k.kind === \"nip46-client\" && k.id === ref.id) ||\n (ref.kind === \"standalone\" && k.kind === \"standalone\" && k.id === ref.id)\n );\n });\n if (info === undefined) {\n throw new WalletError(\"not-found\", \"no such nostr key\");\n }\n return info;\n}\n\nexport function proxySigner(ref: NostrKeyRef, internals: WalletInternals): WalletSigner {\n const resolvePublicKey = (): string => keyInfoOf(internals, ref).publicKey;\n return {\n getPublicKey: async () => {\n await internals.ready();\n return resolvePublicKey();\n },\n signEvent: async (unsigned) => {\n const publicKey = resolvePublicKey();\n // An absent pubkey must stay absent: `pubkey: undefined` is not a ProtocolValue and the\n // kernel would reject the params outright.\n const event: UnsignedEventInput =\n unsigned.pubkey === undefined\n ? {\n kind: unsigned.kind,\n created_at: unsigned.created_at,\n tags: unsigned.tags,\n content: unsigned.content,\n }\n : {\n kind: unsigned.kind,\n created_at: unsigned.created_at,\n tags: unsigned.tags,\n content: unsigned.content,\n pubkey: unsigned.pubkey,\n };\n const signed = await internals.call(\"nostr.signEvent\", { publicKey, event });\n // The kernel output must be the requested event, signed by the expected key.\n const requested: UnsignedEvent = {\n kind: unsigned.kind,\n created_at: unsigned.created_at,\n tags: unsigned.tags,\n content: unsigned.content,\n pubkey: publicKey,\n };\n if (\n signed.pubkey !== publicKey ||\n !signedMatchesUnsigned(signed, requested) ||\n !verifyEvent(signed)\n ) {\n throw integrity(\"the kernel returned a forged event\");\n }\n return signed;\n },\n nip04Encrypt: async (peer, plaintext) =>\n internals.call(\"nostr.nip04Encrypt\", {\n publicKey: resolvePublicKey(),\n peer,\n text: plaintext,\n }),\n nip04Decrypt: async (peer, ciphertext) =>\n internals.call(\"nostr.nip04Decrypt\", {\n publicKey: resolvePublicKey(),\n peer,\n text: ciphertext,\n }),\n nip44Encrypt: async (peer, plaintext) =>\n internals.call(\"nostr.nip44Encrypt\", {\n publicKey: resolvePublicKey(),\n peer,\n text: plaintext,\n }),\n nip44Decrypt: async (peer, payload) =>\n internals.call(\"nostr.nip44Decrypt\", {\n publicKey: resolvePublicKey(),\n peer,\n text: payload,\n }),\n unwrapGiftWraps: async (events) => {\n if (events.length === 0) {\n return [];\n }\n const publicKey = resolvePublicKey();\n const results: Array<Rumor | Error> = [];\n // The wire caps one batch at MAX_BATCH; chunk sequentially and concatenate in order —\n // other requests can interleave between chunks.\n for (let start = 0; start < events.length; start += MAX_BATCH) {\n // oxlint-disable-next-line eslint/no-await-in-loop -- sequential on purpose: chunks round-trip in order\n const batch = await internals.call(\"nostr.unwrapGiftWraps\", {\n publicKey,\n events: events.slice(start, start + MAX_BATCH),\n });\n for (const r of batch.results) {\n results.push(\"ok\" in r ? r.ok : new Error(r.err));\n }\n }\n return results;\n },\n };\n}\n","/**\n * The nostr module of @qntx/wallet: `nostr(wallet)` returns the wallet's Nostr API — signer\n * proxies, key discovery/derivation/import/generation, guarded export and removal. The API is\n * memoized per wallet so repeated calls return the same object (stable React identity); a foreign\n * object is rejected because only a Wallet from this package holds a registered channel.\n */\nimport { wireSecretText } from \"../factors.ts\";\nimport { internalsOf } from \"../internal.ts\";\nimport type { WalletInternals } from \"../internal.ts\";\nimport { SingleUseSecret } from \"../secret.ts\";\nimport { WalletError } from \"../types.ts\";\nimport type {\n DerivedNostrKey,\n ExportedSecret,\n InitialFactor,\n NostrKeyInfo,\n NostrKeyRef,\n UnlockFactor,\n Wallet,\n} from \"../types.ts\";\nimport { keyInfoOf, proxySigner } from \"./signer.ts\";\nimport type { NostrApi, NostrExportKeyFormat, NostrImportKeyInput, WalletSigner } from \"./types.ts\";\n\nexport type {\n DerivedNostrKey,\n NostrApi,\n NostrExportKeyFormat,\n NostrImportKeyInput,\n NostrKeyInfo,\n NostrKeyRef,\n NostrUnwrapResult,\n WalletSigner,\n} from \"./types.ts\";\n\nfunction createNostrApi(internals: WalletInternals): NostrApi {\n return {\n signer: (ref: NostrKeyRef): WalletSigner => proxySigner(ref, internals),\n\n discover: async (\n walletId: string,\n from: number,\n count: number,\n ): Promise<ReadonlyArray<DerivedNostrKey>> => {\n const result = await internals.call(\"nostr.discover\", { walletId, from, count });\n return result.keys;\n },\n\n deriveKey: async (walletId: string, groupIndex: number): Promise<NostrKeyInfo> =>\n internals.call(\"nostr.deriveKey\", { walletId, groupIndex }),\n\n importKey: async (\n input: NostrImportKeyInput,\n options?: { readonly factor?: InitialFactor },\n ): Promise<NostrKeyInfo> => {\n const transfer: ArrayBuffer[] = [];\n const factor = await internals.createFactorParam(options?.factor, transfer);\n const wireInput =\n \"nsec\" in input\n ? { kind: \"nsec\" as const, nsec: wireSecretText(input.nsec, transfer) }\n : {\n kind: \"ncryptsec\" as const,\n ncryptsec: input.ncryptsec,\n password: wireSecretText(input.password, transfer),\n };\n const result = await internals.call(\n \"nostr.importKey\",\n { input: wireInput, ...(factor === undefined ? {} : { factor }) },\n transfer,\n );\n internals.sessionOf(result);\n return result.key;\n },\n\n generateKey: async (options?: { readonly factor?: InitialFactor }): Promise<NostrKeyInfo> => {\n const transfer: ArrayBuffer[] = [];\n const factor = await internals.createFactorParam(options?.factor, transfer);\n const result = await internals.call(\n \"nostr.generateKey\",\n factor === undefined ? {} : { factor },\n transfer,\n );\n internals.sessionOf(result);\n return result.key;\n },\n\n createNip46ClientKey: async (): Promise<NostrKeyInfo> =>\n internals.call(\"nostr.createNip46ClientKey\", null),\n\n removeKey: async (ref: NostrKeyRef, verify?: UnlockFactor): Promise<void> =>\n internals.withVerifying(async () => {\n const info = keyInfoOf(internals, ref); // resolves ref → publicKey + origin\n const transfer: ArrayBuffer[] = [];\n let wireVerify;\n if (info.origin !== \"nip46-client\") {\n if (verify === undefined) {\n throw new WalletError(\"invalid-input\", \"factor verification is required\");\n }\n wireVerify = await internals.resolveFactor(verify, transfer);\n }\n await internals.call(\n \"nostr.removeKey\",\n {\n publicKey: info.publicKey,\n ...(wireVerify === undefined ? {} : { verify: wireVerify }),\n },\n transfer,\n );\n }),\n\n exportKey: async (\n ref: NostrKeyRef,\n format: NostrExportKeyFormat,\n verify: UnlockFactor,\n ): Promise<ExportedSecret> =>\n internals.withVerifying(async () => {\n const { publicKey } = keyInfoOf(internals, ref);\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await internals.resolveFactor(verify, transfer);\n const wireFormat =\n format.kind === \"nsec\"\n ? { kind: \"nsec\" as const }\n : {\n kind: \"ncryptsec\" as const,\n password: wireSecretText(format.password, transfer),\n };\n const bytes = await internals.call(\n \"nostr.exportKey\",\n { verify: wireVerify, publicKey, format: wireFormat },\n transfer,\n );\n return new SingleUseSecret(bytes);\n }),\n };\n}\n\nconst apis = new WeakMap<Wallet, NostrApi>();\n\nexport function nostr(wallet: Wallet): NostrApi {\n const internals = internalsOf(wallet);\n let api = apis.get(wallet);\n if (api === undefined) {\n api = createNostrApi(internals);\n apis.set(wallet, api);\n }\n return api;\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,SAAgB,UAAU,WAA4B,KAAgC;CACpF,MAAM,OAAO,UAAU,SAAS,CAAC,CAAC,MAAM,KAAK,MAAM,QAAQ;EACzD,MAAM,IAAI,IAAI;EACd,OACG,IAAI,SAAS,aACZ,EAAE,SAAS,aACX,EAAE,aAAa,IAAI,YACnB,EAAE,eAAe,IAAI,cACtB,IAAI,SAAS,kBAAkB,EAAE,SAAS,kBAAkB,EAAE,OAAO,IAAI,MACzE,IAAI,SAAS,gBAAgB,EAAE,SAAS,gBAAgB,EAAE,OAAO,IAAI;CAE1E,CAAC;CACD,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,YAAY,aAAa,mBAAmB;CAExD,OAAO;AACT;AAEA,SAAgB,YAAY,KAAkB,WAA0C;CACtF,MAAM,yBAAiC,UAAU,WAAW,GAAG,CAAC,CAAC;CACjE,OAAO;EACL,cAAc,YAAY;GACxB,MAAM,UAAU,MAAM;GACtB,OAAO,iBAAiB;EAC1B;EACA,WAAW,OAAO,aAAa;GAC7B,MAAM,YAAY,iBAAiB;GAGnC,MAAM,QACJ,SAAS,WAAW,KAA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