passkey-kit 0.12.1 → 0.14.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.
Files changed (172) hide show
  1. package/README.md +408 -227
  2. package/{types → dist}/base.d.ts +1 -0
  3. package/dist/base.d.ts.map +1 -0
  4. package/{src/base.ts → dist/base.js} +8 -10
  5. package/dist/base.js.map +1 -0
  6. package/dist/base64url.d.ts +18 -0
  7. package/dist/base64url.d.ts.map +1 -0
  8. package/dist/base64url.js +18 -0
  9. package/dist/base64url.js.map +1 -0
  10. package/dist/constants.d.ts +91 -0
  11. package/dist/constants.d.ts.map +1 -0
  12. package/dist/constants.js +115 -0
  13. package/dist/constants.js.map +1 -0
  14. package/dist/contract-errors.d.ts +69 -0
  15. package/dist/contract-errors.d.ts.map +1 -0
  16. package/dist/contract-errors.js +132 -0
  17. package/dist/contract-errors.js.map +1 -0
  18. package/dist/errors.d.ts +163 -0
  19. package/dist/errors.d.ts.map +1 -0
  20. package/dist/errors.js +244 -0
  21. package/dist/errors.js.map +1 -0
  22. package/dist/events.d.ts +94 -0
  23. package/dist/events.d.ts.map +1 -0
  24. package/dist/events.js +92 -0
  25. package/dist/events.js.map +1 -0
  26. package/dist/index.d.ts +22 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +36 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/indexer/codec.d.ts +18 -0
  31. package/dist/indexer/codec.d.ts.map +1 -0
  32. package/dist/indexer/codec.js +32 -0
  33. package/dist/indexer/codec.js.map +1 -0
  34. package/dist/indexer/index.d.ts +25 -0
  35. package/dist/indexer/index.d.ts.map +1 -0
  36. package/dist/indexer/index.js +34 -0
  37. package/dist/indexer/index.js.map +1 -0
  38. package/dist/indexer/mercury.d.ts +94 -0
  39. package/dist/indexer/mercury.d.ts.map +1 -0
  40. package/dist/indexer/mercury.js +245 -0
  41. package/dist/indexer/mercury.js.map +1 -0
  42. package/dist/indexer/stellar-indexer.d.ts +115 -0
  43. package/dist/indexer/stellar-indexer.d.ts.map +1 -0
  44. package/dist/indexer/stellar-indexer.js +279 -0
  45. package/dist/indexer/stellar-indexer.js.map +1 -0
  46. package/dist/indexer/types.d.ts +73 -0
  47. package/dist/indexer/types.d.ts.map +1 -0
  48. package/dist/indexer/types.js +9 -0
  49. package/dist/indexer/types.js.map +1 -0
  50. package/dist/kit/auth-payload.d.ts +106 -0
  51. package/dist/kit/auth-payload.d.ts.map +1 -0
  52. package/dist/kit/auth-payload.js +227 -0
  53. package/dist/kit/auth-payload.js.map +1 -0
  54. package/dist/kit/deploy-ops.d.ts +45 -0
  55. package/dist/kit/deploy-ops.d.ts.map +1 -0
  56. package/dist/kit/deploy-ops.js +69 -0
  57. package/dist/kit/deploy-ops.js.map +1 -0
  58. package/dist/kit/tx-ops.d.ts +95 -0
  59. package/dist/kit/tx-ops.d.ts.map +1 -0
  60. package/dist/kit/tx-ops.js +125 -0
  61. package/dist/kit/tx-ops.js.map +1 -0
  62. package/dist/kit/wallet-ops.d.ts +59 -0
  63. package/dist/kit/wallet-ops.d.ts.map +1 -0
  64. package/dist/kit/wallet-ops.js +122 -0
  65. package/dist/kit/wallet-ops.js.map +1 -0
  66. package/dist/kit/webauthn-ops.d.ts +55 -0
  67. package/dist/kit/webauthn-ops.d.ts.map +1 -0
  68. package/dist/kit/webauthn-ops.js +79 -0
  69. package/dist/kit/webauthn-ops.js.map +1 -0
  70. package/dist/kit.d.ts +132 -0
  71. package/dist/kit.d.ts.map +1 -0
  72. package/dist/kit.js +290 -0
  73. package/dist/kit.js.map +1 -0
  74. package/dist/managers/credential-manager.d.ts +39 -0
  75. package/dist/managers/credential-manager.d.ts.map +1 -0
  76. package/dist/managers/credential-manager.js +47 -0
  77. package/dist/managers/credential-manager.js.map +1 -0
  78. package/dist/managers/index.d.ts +7 -0
  79. package/dist/managers/index.d.ts.map +1 -0
  80. package/dist/managers/index.js +7 -0
  81. package/dist/managers/index.js.map +1 -0
  82. package/dist/managers/signer-manager.d.ts +62 -0
  83. package/dist/managers/signer-manager.d.ts.map +1 -0
  84. package/dist/managers/signer-manager.js +111 -0
  85. package/dist/managers/signer-manager.js.map +1 -0
  86. package/dist/managers/submission-manager.d.ts +52 -0
  87. package/dist/managers/submission-manager.d.ts.map +1 -0
  88. package/dist/managers/submission-manager.js +77 -0
  89. package/dist/managers/submission-manager.js.map +1 -0
  90. package/dist/relayer.d.ts +61 -0
  91. package/dist/relayer.d.ts.map +1 -0
  92. package/dist/relayer.js +122 -0
  93. package/dist/relayer.js.map +1 -0
  94. package/dist/rpc-data.d.ts +45 -0
  95. package/dist/rpc-data.d.ts.map +1 -0
  96. package/dist/rpc-data.js +61 -0
  97. package/dist/rpc-data.js.map +1 -0
  98. package/dist/sac.d.ts +31 -0
  99. package/dist/sac.d.ts.map +1 -0
  100. package/dist/sac.js +47 -0
  101. package/dist/sac.js.map +1 -0
  102. package/dist/server.d.ts +79 -0
  103. package/dist/server.d.ts.map +1 -0
  104. package/dist/server.js +152 -0
  105. package/dist/server.js.map +1 -0
  106. package/dist/signers.d.ts +83 -0
  107. package/dist/signers.d.ts.map +1 -0
  108. package/dist/signers.js +124 -0
  109. package/dist/signers.js.map +1 -0
  110. package/dist/storage/index.d.ts +13 -0
  111. package/dist/storage/index.d.ts.map +1 -0
  112. package/dist/storage/index.js +12 -0
  113. package/dist/storage/index.js.map +1 -0
  114. package/dist/storage/indexeddb.d.ts +26 -0
  115. package/dist/storage/indexeddb.d.ts.map +1 -0
  116. package/dist/storage/indexeddb.js +100 -0
  117. package/dist/storage/indexeddb.js.map +1 -0
  118. package/dist/storage/localStorage.d.ts +22 -0
  119. package/dist/storage/localStorage.d.ts.map +1 -0
  120. package/dist/storage/localStorage.js +86 -0
  121. package/dist/storage/localStorage.js.map +1 -0
  122. package/dist/storage/memory.d.ts +18 -0
  123. package/dist/storage/memory.d.ts.map +1 -0
  124. package/dist/storage/memory.js +41 -0
  125. package/dist/storage/memory.js.map +1 -0
  126. package/dist/types.d.ts +136 -0
  127. package/dist/types.d.ts.map +1 -0
  128. package/dist/types.js +39 -0
  129. package/dist/types.js.map +1 -0
  130. package/dist/utils.d.ts +72 -0
  131. package/dist/utils.d.ts.map +1 -0
  132. package/dist/utils.js +253 -0
  133. package/dist/utils.js.map +1 -0
  134. package/dist/validation.d.ts +42 -0
  135. package/dist/validation.d.ts.map +1 -0
  136. package/dist/validation.js +75 -0
  137. package/dist/validation.js.map +1 -0
  138. package/dist/version.d.ts +7 -0
  139. package/dist/version.d.ts.map +1 -0
  140. package/dist/version.js +9 -0
  141. package/dist/version.js.map +1 -0
  142. package/package.json +47 -20
  143. package/.claude/settings.local.json +0 -20
  144. package/.cursorrules +0 -170
  145. package/.gitattributes +0 -2
  146. package/.github/workflows/release.yml +0 -21
  147. package/.vscode/settings.json +0 -6
  148. package/PROPOSAL.md +0 -397
  149. package/cheatsheet.txt +0 -18
  150. package/clone-js-sdk.sh +0 -21
  151. package/packages/passkey-kit-sdk/README.md +0 -54
  152. package/packages/passkey-kit-sdk/package.json +0 -21
  153. package/packages/passkey-kit-sdk/src/index.ts +0 -171
  154. package/packages/passkey-kit-sdk/tsconfig.json +0 -98
  155. package/packages/passkey-kit-sdk/types/index.d.ts +0 -190
  156. package/packages/sac-sdk/README.md +0 -54
  157. package/packages/sac-sdk/package.json +0 -21
  158. package/packages/sac-sdk/src/index.ts +0 -586
  159. package/packages/sac-sdk/tsconfig.json +0 -98
  160. package/packages/sac-sdk/types/index.d.ts +0 -532
  161. package/pnpm-workspace.yaml +0 -2
  162. package/src/index.ts +0 -5
  163. package/src/kit.ts +0 -823
  164. package/src/sac.ts +0 -29
  165. package/src/server.ts +0 -179
  166. package/src/types.ts +0 -32
  167. package/tsconfig.json +0 -28
  168. package/types/index.d.ts +0 -5
  169. package/types/kit.d.ts +0 -95
  170. package/types/sac.d.ts +0 -13
  171. package/types/server.d.ts +0 -29
  172. package/types/types.d.ts +0 -22
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Wallet signer operations: build add/update/remove signer transactions, encode
3
+ * the SDK-side {@link SignerKey}/{@link SignerLimits} helpers into the contract's
4
+ * union types, and read a signer entry back from the ledger.
5
+ *
6
+ * `getSigner` reads the flat top-level `SignerKey → SignerVal` entry directly via
7
+ * RPC (temporary durability before persistent, per the contract's lookup
8
+ * invariant). This doubles as `connectWallet`'s ownership check (#601 F7): a
9
+ * keyId that resolves to a live signer entry proves the wallet actually knows
10
+ * that passkey. When the contract's `get_signer` view lands (A3) this can move
11
+ * onto the view; the ledger read is equivalent and works today.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ import { type Server } from "@stellar/stellar-sdk/rpc";
16
+ import type { AssembledTransaction, Result, Spec as ContractSpec } from "@stellar/stellar-sdk/contract";
17
+ import { Client as PasskeyClient, type SignerKey as SDKSignerKey, type SignerLimits as SDKSignerLimits, type SignerVal } from "passkey-kit-sdk";
18
+ import { SignerStore, type SignerKey, type SignerLimits } from "../types.js";
19
+ /**
20
+ * The result of a signer-write / upgrade transaction. The reworked contract's
21
+ * admin functions are typed `Result<void>` (they return `Ok(())` or a typed
22
+ * contract error), so the AssembledTransaction is generic over that.
23
+ */
24
+ export type WalletTx = AssembledTransaction<Result<void>>;
25
+ /** Which write the builder targets. */
26
+ type SignerFn = "add_signer" | "update_signer";
27
+ /** Encode a SDK-side {@link SignerKey} helper into the contract's union. */
28
+ export declare function toContractSignerKey({ key, value }: SignerKey): SDKSignerKey;
29
+ /** Encode SDK-side {@link SignerLimits} into the contract's `SignerLimits`. */
30
+ export declare function toContractSignerLimits(limits: SignerLimits): SDKSignerLimits;
31
+ /** Shared deps for building signer-write transactions. */
32
+ export interface WalletWriteDeps {
33
+ wallet: PasskeyClient;
34
+ timeoutInSeconds: number;
35
+ }
36
+ export declare function buildSecp256r1SignerTx(deps: WalletWriteDeps, fn: SignerFn, keyId: string | Uint8Array, publicKey: string | Uint8Array, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
37
+ export declare function buildEd25519SignerTx(deps: WalletWriteDeps, fn: SignerFn, publicKey: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
38
+ export declare function buildPolicySignerTx(deps: WalletWriteDeps, fn: SignerFn, policy: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
39
+ export declare function buildRemoveSignerTx(deps: WalletWriteDeps, signerKey: SignerKey): Promise<WalletTx>;
40
+ /** Build an `upgrade(new_wasm_hash)` transaction (renamed from update_contract_code). */
41
+ export declare function buildUpgradeTx(deps: WalletWriteDeps, newWasmHash: Buffer | Uint8Array): Promise<WalletTx>;
42
+ /**
43
+ * Read a signer entry from the ledger, or `null` if absent.
44
+ *
45
+ * Checks temporary durability before persistent (the contract's lookup order).
46
+ * A non-null result proves the wallet holds this signer — the basis of
47
+ * `connectWallet`'s ownership verification.
48
+ *
49
+ * `null` means a genuine not-found in BOTH durabilities. A transport error
50
+ * (RPC 429/5xx/timeout) is NOT swallowed — it propagates, so `connectWallet`
51
+ * never mistakes a flaky RPC for "the passkey is not a signer" and throws a
52
+ * misleading `WalletOwnershipError` for a valid credential.
53
+ */
54
+ export declare function getSigner(deps: {
55
+ rpc: Server;
56
+ spec: ContractSpec;
57
+ }, contractId: string, signerKey: SignerKey): Promise<SignerVal | null>;
58
+ export {};
59
+ //# sourceMappingURL=wallet-ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-ops.d.ts","sourceRoot":"","sources":["../../src/kit/wallet-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EACV,oBAAoB,EACpB,MAAM,EACN,IAAI,IAAI,YAAY,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,MAAM,IAAI,aAAa,EAGvB,KAAK,SAAS,IAAI,YAAY,EAC9B,KAAK,YAAY,IAAI,eAAe,EACpC,KAAK,SAAS,EACf,MA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AQ,CAAC,CAKnB;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,QAAQ,CAAC,CAKnB;AAED,yFAAyF;AACzF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,eAAe,EACrB,WAAW,EAAE,MAAM,GAAG,UAAU,GAC/B,OAAO,CAAC,QAAQ,CAAC,CAKnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,EACzC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAW3B"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Wallet signer operations: build add/update/remove signer transactions, encode
3
+ * the SDK-side {@link SignerKey}/{@link SignerLimits} helpers into the contract's
4
+ * union types, and read a signer entry back from the ledger.
5
+ *
6
+ * `getSigner` reads the flat top-level `SignerKey → SignerVal` entry directly via
7
+ * RPC (temporary durability before persistent, per the contract's lookup
8
+ * invariant). This doubles as `connectWallet`'s ownership check (#601 F7): a
9
+ * keyId that resolves to a live signer entry proves the wallet actually knows
10
+ * that passkey. When the contract's `get_signer` view lands (A3) this can move
11
+ * onto the view; the ledger read is equivalent and works today.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ import { Keypair } from "@stellar/stellar-sdk";
16
+ import { Durability } from "@stellar/stellar-sdk/rpc";
17
+ import base64url from "../base64url.js";
18
+ import { readContractData } from "../rpc-data.js";
19
+ import { signerKeyToScVal, SIGNER_VAL_UDT } from "./auth-payload.js";
20
+ /** Encode an optional expiration into the contract's `Option<u64>` timestamp. */
21
+ function toSignerExpiration(expiration) {
22
+ return [expiration == null ? undefined : BigInt(expiration)];
23
+ }
24
+ /** Encode a SDK-side {@link SignerKey} helper into the contract's union. */
25
+ export function toContractSignerKey({ key, value }) {
26
+ switch (key) {
27
+ case "Policy":
28
+ return { tag: "Policy", values: [value] };
29
+ case "Ed25519":
30
+ return { tag: "Ed25519", values: [Keypair.fromPublicKey(value).rawPublicKey()] };
31
+ case "Secp256r1":
32
+ return { tag: "Secp256r1", values: [base64url.toBuffer(value)] };
33
+ }
34
+ }
35
+ /** Encode SDK-side {@link SignerLimits} into the contract's `SignerLimits`. */
36
+ export function toContractSignerLimits(limits) {
37
+ if (!limits) {
38
+ return [undefined];
39
+ }
40
+ const map = new Map();
41
+ for (const [contract, signerKeys] of limits.entries()) {
42
+ map.set(contract, signerKeys?.length ? signerKeys.map(toContractSignerKey) : undefined);
43
+ }
44
+ return [map];
45
+ }
46
+ function buildSecp256r1Signer(keyId, publicKey, limits, store, expiration) {
47
+ const keyIdBuffer = typeof keyId === "string" ? base64url.toBuffer(keyId) : Buffer.from(keyId);
48
+ const publicKeyBuffer = typeof publicKey === "string"
49
+ ? base64url.toBuffer(publicKey)
50
+ : Buffer.from(publicKey);
51
+ return {
52
+ tag: "Secp256r1",
53
+ values: [
54
+ keyIdBuffer,
55
+ publicKeyBuffer,
56
+ toSignerExpiration(expiration),
57
+ toContractSignerLimits(limits),
58
+ { tag: store, values: undefined },
59
+ ],
60
+ };
61
+ }
62
+ function buildEd25519Signer(publicKey, limits, store, expiration) {
63
+ return {
64
+ tag: "Ed25519",
65
+ values: [
66
+ Keypair.fromPublicKey(publicKey).rawPublicKey(),
67
+ toSignerExpiration(expiration),
68
+ toContractSignerLimits(limits),
69
+ { tag: store, values: undefined },
70
+ ],
71
+ };
72
+ }
73
+ function buildPolicySigner(policy, limits, store, expiration) {
74
+ return {
75
+ tag: "Policy",
76
+ values: [
77
+ policy,
78
+ toSignerExpiration(expiration),
79
+ toContractSignerLimits(limits),
80
+ { tag: store, values: undefined },
81
+ ],
82
+ };
83
+ }
84
+ export function buildSecp256r1SignerTx(deps, fn, keyId, publicKey, limits, store, expiration) {
85
+ return deps.wallet[fn]({ signer: buildSecp256r1Signer(keyId, publicKey, limits, store, expiration) }, { timeoutInSeconds: deps.timeoutInSeconds });
86
+ }
87
+ export function buildEd25519SignerTx(deps, fn, publicKey, limits, store, expiration) {
88
+ return deps.wallet[fn]({ signer: buildEd25519Signer(publicKey, limits, store, expiration) }, { timeoutInSeconds: deps.timeoutInSeconds });
89
+ }
90
+ export function buildPolicySignerTx(deps, fn, policy, limits, store, expiration) {
91
+ return deps.wallet[fn]({ signer: buildPolicySigner(policy, limits, store, expiration) }, { timeoutInSeconds: deps.timeoutInSeconds });
92
+ }
93
+ export function buildRemoveSignerTx(deps, signerKey) {
94
+ return deps.wallet.remove_signer({ signer_key: toContractSignerKey(signerKey) }, { timeoutInSeconds: deps.timeoutInSeconds });
95
+ }
96
+ /** Build an `upgrade(new_wasm_hash)` transaction (renamed from update_contract_code). */
97
+ export function buildUpgradeTx(deps, newWasmHash) {
98
+ return deps.wallet.upgrade({ new_wasm_hash: Buffer.from(newWasmHash) }, { timeoutInSeconds: deps.timeoutInSeconds });
99
+ }
100
+ /**
101
+ * Read a signer entry from the ledger, or `null` if absent.
102
+ *
103
+ * Checks temporary durability before persistent (the contract's lookup order).
104
+ * A non-null result proves the wallet holds this signer — the basis of
105
+ * `connectWallet`'s ownership verification.
106
+ *
107
+ * `null` means a genuine not-found in BOTH durabilities. A transport error
108
+ * (RPC 429/5xx/timeout) is NOT swallowed — it propagates, so `connectWallet`
109
+ * never mistakes a flaky RPC for "the passkey is not a signer" and throws a
110
+ * misleading `WalletOwnershipError` for a valid credential.
111
+ */
112
+ export async function getSigner(deps, contractId, signerKey) {
113
+ const scKey = signerKeyToScVal(deps.spec, toContractSignerKey(signerKey));
114
+ for (const durability of [Durability.Temporary, Durability.Persistent]) {
115
+ const scVal = await readContractData(deps.rpc, contractId, scKey, durability);
116
+ if (scVal) {
117
+ return deps.spec.scValToNative(scVal, SIGNER_VAL_UDT);
118
+ }
119
+ }
120
+ return null;
121
+ }
122
+ //# sourceMappingURL=wallet-ops.js.map
@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@@
1
+ /**
2
+ * WebAuthn ceremony operations: passkey registration and authentication.
3
+ *
4
+ * Pure functions over an injected WebAuthn implementation and RP config, so the
5
+ * ceremonies are unit-testable with a fake authenticator. The old kit hard-coded
6
+ * a static challenge (`"stellaristhebetterblockchain"`) and read `rpId` per
7
+ * call; here the challenge is random (see {@link generateChallenge}) and the RP
8
+ * config comes from the kit constructor.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ import type { AuthenticationResponseJSON, RegistrationResponseJSON, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, AuthenticatorSelectionCriteria } from "@simplewebauthn/browser";
13
+ /** The WebAuthn ceremony surface the kit depends on (overridable for tests). */
14
+ export interface WebAuthnClient {
15
+ startRegistration(args: {
16
+ optionsJSON: PublicKeyCredentialCreationOptionsJSON;
17
+ }): Promise<RegistrationResponseJSON>;
18
+ startAuthentication(args: {
19
+ optionsJSON: PublicKeyCredentialRequestOptionsJSON;
20
+ }): Promise<AuthenticationResponseJSON>;
21
+ }
22
+ /** RP config + WebAuthn implementation for the ceremonies. */
23
+ export interface WebAuthnDeps {
24
+ rpId?: string;
25
+ webAuthn: WebAuthnClient;
26
+ }
27
+ /** A freshly registered passkey. */
28
+ export interface CreatedPasskey {
29
+ rawResponse: RegistrationResponseJSON;
30
+ /** Base64URL credential id. */
31
+ keyId: string;
32
+ /** Raw credential id bytes. */
33
+ keyIdBuffer: Buffer;
34
+ /** 65-byte uncompressed secp256r1 public key. */
35
+ publicKey: Uint8Array;
36
+ }
37
+ /**
38
+ * Run a WebAuthn registration ceremony and extract the passkey public key.
39
+ *
40
+ * `pubKeyCredParams` is ES256-only (the smart wallet verifies secp256r1).
41
+ */
42
+ export declare function createPasskey(deps: WebAuthnDeps, appName: string, userName: string, authenticatorSelection?: AuthenticatorSelectionCriteria): Promise<CreatedPasskey>;
43
+ /** A discoverable-credential authentication result. */
44
+ export interface AuthenticatedPasskey {
45
+ keyId: string;
46
+ keyIdBuffer: Buffer;
47
+ rawResponse: AuthenticationResponseJSON;
48
+ }
49
+ /**
50
+ * Run a WebAuthn authentication ceremony against a discoverable credential (no
51
+ * `allowCredentials`), returning the selected credential id. Used by
52
+ * `connectWallet` to discover which passkey the user picked.
53
+ */
54
+ export declare function authenticatePasskey(deps: WebAuthnDeps): Promise<AuthenticatedPasskey>;
55
+ //# sourceMappingURL=webauthn-ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthn-ops.d.ts","sourceRoot":"","sources":["../../src/kit/webauthn-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,sCAAsC,EACtC,qCAAqC,EACrC,8BAA8B,EAC/B,MAAM,yBAAyB,CAAC;AAMjC,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC7B,iBAAiB,CAAC,IAAI,EAAE;QACtB,WAAW,EAAE,sCAAsC,CAAC;KACrD,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACtC,mBAAmB,CAAC,IAAI,EAAE;QACxB,WAAW,EAAE,qCAAqC,CAAC;KACpD,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;CACzC;AAED,8DAA8D;AAC9D,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,oCAAoC;AACpC,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,wBAAwB,CAAC;IACtC,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,SAAS,EAAE,UAAU,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,sBAAsB,GAAE,8BAGvB,GACA,OAAO,CAAC,cAAc,CAAC,CAoCzB;AAED,uDAAuD;AACvD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,0BAA0B,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,oBAAoB,CAAC,CAwB/B"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * WebAuthn ceremony operations: passkey registration and authentication.
3
+ *
4
+ * Pure functions over an injected WebAuthn implementation and RP config, so the
5
+ * ceremonies are unit-testable with a fake authenticator. The old kit hard-coded
6
+ * a static challenge (`"stellaristhebetterblockchain"`) and read `rpId` per
7
+ * call; here the challenge is random (see {@link generateChallenge}) and the RP
8
+ * config comes from the kit constructor.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ import base64url from "../base64url.js";
13
+ import { extractPublicKeyFromAttestation, generateChallenge } from "../utils.js";
14
+ import { WEBAUTHN_TIMEOUT_MS } from "../constants.js";
15
+ import { WebAuthnError, PasskeyKitErrorCode } from "../errors.js";
16
+ /**
17
+ * Run a WebAuthn registration ceremony and extract the passkey public key.
18
+ *
19
+ * `pubKeyCredParams` is ES256-only (the smart wallet verifies secp256r1).
20
+ */
21
+ export async function createPasskey(deps, appName, userName, authenticatorSelection = {
22
+ residentKey: "preferred",
23
+ userVerification: "preferred",
24
+ }) {
25
+ const now = new Date();
26
+ const displayName = `${userName} — ${now.toLocaleString()}`;
27
+ const optionsJSON = {
28
+ challenge: generateChallenge(),
29
+ rp: { id: deps.rpId, name: appName },
30
+ user: {
31
+ id: generateChallenge(),
32
+ name: displayName,
33
+ displayName,
34
+ },
35
+ authenticatorSelection,
36
+ pubKeyCredParams: [{ alg: -7, type: "public-key" }],
37
+ timeout: WEBAUTHN_TIMEOUT_MS,
38
+ };
39
+ let rawResponse;
40
+ try {
41
+ rawResponse = await deps.webAuthn.startRegistration({ optionsJSON });
42
+ }
43
+ catch (err) {
44
+ throw new WebAuthnError("Passkey registration failed", PasskeyKitErrorCode.WEBAUTHN_REGISTRATION_FAILED, err instanceof Error ? err : undefined);
45
+ }
46
+ const publicKey = await extractPublicKeyFromAttestation(rawResponse.response);
47
+ return {
48
+ rawResponse,
49
+ keyId: rawResponse.id,
50
+ keyIdBuffer: base64url.toBuffer(rawResponse.id),
51
+ publicKey,
52
+ };
53
+ }
54
+ /**
55
+ * Run a WebAuthn authentication ceremony against a discoverable credential (no
56
+ * `allowCredentials`), returning the selected credential id. Used by
57
+ * `connectWallet` to discover which passkey the user picked.
58
+ */
59
+ export async function authenticatePasskey(deps) {
60
+ const optionsJSON = {
61
+ challenge: generateChallenge(),
62
+ rpId: deps.rpId,
63
+ userVerification: "preferred",
64
+ timeout: WEBAUTHN_TIMEOUT_MS,
65
+ };
66
+ let rawResponse;
67
+ try {
68
+ rawResponse = await deps.webAuthn.startAuthentication({ optionsJSON });
69
+ }
70
+ catch (err) {
71
+ throw new WebAuthnError("Passkey authentication failed", PasskeyKitErrorCode.WEBAUTHN_AUTHENTICATION_FAILED, err instanceof Error ? err : undefined);
72
+ }
73
+ return {
74
+ keyId: rawResponse.id,
75
+ keyIdBuffer: base64url.toBuffer(rawResponse.id),
76
+ rawResponse,
77
+ };
78
+ }
79
+ //# sourceMappingURL=webauthn-ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthn-ops.js","sourceRoot":"","sources":["../../src/kit/webauthn-ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA6BlE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACj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,UAAU,mBAAmB,CACvC,IAAkB;IAElB,MAAM,WAAW,GAA0C;QACzD,SAAS,EAAE,iBAAiB,EAAE;QAC9B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,gBAAgB,EAAE,WAAW;QAC7B,OAAO,EAAE,mBAAmB;KAC7B,CAAC;IAEF,IAAI,WAAuC,CAAC;IAC5C,IAAI,CAAC;QACH,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IACzE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,aAAa,CACrB,+BAA+B,EAC/B,mBAAmB,CAAC,8BAA8B,EAClD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CACvC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,KAAK,EAAE,WAAW,CAAC,EAAE;QACrB,WAAW,EAAE,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/C,WAAW;KACZ,CAAC;AACJ,CAAC"}
package/dist/kit.d.ts ADDED
@@ -0,0 +1,132 @@
1
+ /**
2
+ * `PasskeyKit` — the browser-side facade for creating and using smart-wallet
3
+ * accounts with WebAuthn passkeys.
4
+ *
5
+ * This is a ground-up rewrite of the old monolithic `kit.ts`. The signing
6
+ * pipeline, WebAuthn ceremonies, deploy path, and signer writes now live in
7
+ * dependency-injected managers ({@link CredentialManager}, {@link SignerManager},
8
+ * {@link SubmissionManager}) wired here with late-bound closures. All Protocol-27
9
+ * probe shims, dead commented experiments, and the legacy factory-address
10
+ * fallback are gone — the kit targets stellar-sdk >= 16 and the current wallet.
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ import { xdr } from "@stellar/stellar-sdk";
15
+ import { Server } from "@stellar/stellar-sdk/rpc";
16
+ import { type AuthenticatorSelectionCriteria } from "@simplewebauthn/browser";
17
+ import type { AssembledTransaction } from "@stellar/stellar-sdk/contract";
18
+ import { Client as PasskeyClient } from "passkey-kit-sdk";
19
+ import { SignerKey, SignerStore, type ConnectWalletResult, type CreateWalletResult, type SignerLimits, type StorageAdapter } from "./types.js";
20
+ import { PasskeyEventEmitter } from "./events.js";
21
+ import { type Signer } from "./signers.js";
22
+ import type { WebAuthnClient } from "./kit/webauthn-ops.js";
23
+ import type { CreatedPasskey } from "./kit/webauthn-ops.js";
24
+ import type { SignOptions } from "./kit/tx-ops.js";
25
+ import type { WalletTx } from "./kit/wallet-ops.js";
26
+ /** Configuration for a {@link PasskeyKit} client. */
27
+ export interface PasskeyKitConfig {
28
+ /** Stellar RPC URL. */
29
+ rpcUrl: string;
30
+ /** Network passphrase. */
31
+ networkPassphrase: string;
32
+ /** Smart-wallet WASM hash (hex) used to deploy new wallets. */
33
+ walletWasmHash: string;
34
+ /** WebAuthn Relying Party id (domain); defaults to the current origin. */
35
+ rpId?: string;
36
+ /**
37
+ * Secret key (`S…`) for the fee-paying deployer. Defaults to the canonical
38
+ * deterministic deployer (see {@link resolveDeployer}); overriding it changes
39
+ * derived wallet addresses.
40
+ */
41
+ deploySource?: string;
42
+ /** Transaction timeout, in seconds (default 30). */
43
+ timeoutInSeconds?: number;
44
+ /** Optional passkey-record storage adapter (see `passkey-kit/storage`). */
45
+ storage?: StorageAdapter;
46
+ /** Custom WebAuthn implementation (for testing). */
47
+ WebAuthn?: WebAuthnClient;
48
+ }
49
+ /** Options for {@link PasskeyKit.createKey}/{@link PasskeyKit.createWallet}. */
50
+ export interface CreateOptions {
51
+ authenticatorSelection?: AuthenticatorSelectionCriteria;
52
+ }
53
+ /** Options for {@link PasskeyKit.connectWallet}. */
54
+ export interface ConnectOptions {
55
+ /** A specific keyId to connect (skips the discovery ceremony). */
56
+ keyId?: string | Uint8Array;
57
+ /** Indexer-backed keyId → contract lookup, used when derivation misses. */
58
+ getContractId?: (keyId: string) => Promise<string | undefined>;
59
+ /**
60
+ * Also assert the wallet's on-chain WASM hash equals `walletWasmHash`.
61
+ * Off by default: an upgraded wallet legitimately runs a different hash.
62
+ */
63
+ verifyWasmHash?: boolean;
64
+ }
65
+ export declare class PasskeyKit {
66
+ readonly rpc: Server;
67
+ readonly rpcUrl: string;
68
+ readonly networkPassphrase: string;
69
+ readonly walletWasmHash: string;
70
+ readonly rpId?: string;
71
+ /** Lifecycle event emitter (walletCreated, walletConnected, …). */
72
+ readonly events: PasskeyEventEmitter;
73
+ private readonly timeoutInSeconds;
74
+ private readonly webAuthn;
75
+ private readonly credentialManager;
76
+ private readonly signerManager;
77
+ private readonly submissionManager;
78
+ /** The connected passkey's base64url keyId, if any. */
79
+ keyId: string | undefined;
80
+ /** The connected wallet client, if any. */
81
+ wallet: PasskeyClient | undefined;
82
+ constructor(config: PasskeyKitConfig);
83
+ /** The connected wallet's contract id, if any. */
84
+ get contractId(): string | undefined;
85
+ /** The fee-paying deployer's `G…` public key. */
86
+ get deployerPublicKey(): string;
87
+ private signerContext;
88
+ /** Run a passkey registration ceremony without deploying a wallet. */
89
+ createKey(appName: string, userName: string, options?: CreateOptions): Promise<CreatedPasskey>;
90
+ /**
91
+ * Register a passkey and deploy a smart wallet initialized with it as the
92
+ * first signer. Returns the signed deploy transaction (submit it via
93
+ * `PasskeyServer`).
94
+ */
95
+ createWallet(appName: string, userName: string, options?: CreateOptions): Promise<CreateWalletResult>;
96
+ /**
97
+ * Connect an existing wallet from a passkey.
98
+ *
99
+ * Resolves the wallet address by (1) deterministic derivation from the keyId,
100
+ * (2) local storage, then (3) an injected indexer lookup — and then VERIFIES
101
+ * ownership: the keyId must resolve to a live signer on the wallet (#601 F7).
102
+ * This closes the unverified reverse-lookup hole (#598 F3) at the SDK layer.
103
+ *
104
+ * @throws {WalletOwnershipError} If the keyId is not a signer on the wallet.
105
+ */
106
+ connectWallet(options?: ConnectOptions): Promise<ConnectWalletResult>;
107
+ private assertWalletWasmHash;
108
+ /** Disconnect the current wallet. */
109
+ disconnect(): void;
110
+ /** Sign a single auth entry (defaults to the connected passkey signer). */
111
+ signAuthEntry(entry: xdr.SorobanAuthorizationEntry, signer?: Signer, options?: SignOptions): Promise<xdr.SorobanAuthorizationEntry>;
112
+ /** Sign an assembled transaction's wallet auth entries. */
113
+ sign<T>(txn: AssembledTransaction<T>, signer?: Signer, options?: SignOptions): Promise<AssembledTransaction<T>>;
114
+ addSecp256r1(keyId: string | Uint8Array, publicKey: string | Uint8Array, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
115
+ /**
116
+ * Update a passkey signer's limits/storage/expiration. The public key is
117
+ * re-read from the ledger — never caller- or indexer-supplied.
118
+ */
119
+ updateSecp256r1(keyId: string | Uint8Array, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
120
+ addEd25519(publicKey: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
121
+ updateEd25519(publicKey: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
122
+ addPolicy(policy: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
123
+ updatePolicy(policy: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
124
+ remove(signerKey: SignerKey): Promise<WalletTx>;
125
+ /** Build an `upgrade(new_wasm_hash)` transaction for the connected wallet. */
126
+ upgrade(newWasmHash: Buffer | Uint8Array): Promise<WalletTx>;
127
+ /** Read a signer entry from the ledger (temporary before persistent). */
128
+ getSigner(signerKey: SignerKey): Promise<import("passkey-kit-sdk").SignerVal | null>;
129
+ /** Require a connected wallet, or throw. */
130
+ requireWallet(): PasskeyClient;
131
+ }
132
+ //# sourceMappingURL=kit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../src/kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;A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