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.
- package/README.md +408 -227
- package/{types → dist}/base.d.ts +1 -0
- package/dist/base.d.ts.map +1 -0
- package/{src/base.ts → dist/base.js} +8 -10
- package/dist/base.js.map +1 -0
- package/dist/base64url.d.ts +18 -0
- package/dist/base64url.d.ts.map +1 -0
- package/dist/base64url.js +18 -0
- package/dist/base64url.js.map +1 -0
- package/dist/constants.d.ts +91 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +115 -0
- package/dist/constants.js.map +1 -0
- package/dist/contract-errors.d.ts +69 -0
- package/dist/contract-errors.d.ts.map +1 -0
- package/dist/contract-errors.js +132 -0
- package/dist/contract-errors.js.map +1 -0
- package/dist/errors.d.ts +163 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +244 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +94 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +92 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer/codec.d.ts +18 -0
- package/dist/indexer/codec.d.ts.map +1 -0
- package/dist/indexer/codec.js +32 -0
- package/dist/indexer/codec.js.map +1 -0
- package/dist/indexer/index.d.ts +25 -0
- package/dist/indexer/index.d.ts.map +1 -0
- package/dist/indexer/index.js +34 -0
- package/dist/indexer/index.js.map +1 -0
- package/dist/indexer/mercury.d.ts +94 -0
- package/dist/indexer/mercury.d.ts.map +1 -0
- package/dist/indexer/mercury.js +245 -0
- package/dist/indexer/mercury.js.map +1 -0
- package/dist/indexer/stellar-indexer.d.ts +115 -0
- package/dist/indexer/stellar-indexer.d.ts.map +1 -0
- package/dist/indexer/stellar-indexer.js +279 -0
- package/dist/indexer/stellar-indexer.js.map +1 -0
- package/dist/indexer/types.d.ts +73 -0
- package/dist/indexer/types.d.ts.map +1 -0
- package/dist/indexer/types.js +9 -0
- package/dist/indexer/types.js.map +1 -0
- package/dist/kit/auth-payload.d.ts +106 -0
- package/dist/kit/auth-payload.d.ts.map +1 -0
- package/dist/kit/auth-payload.js +227 -0
- package/dist/kit/auth-payload.js.map +1 -0
- package/dist/kit/deploy-ops.d.ts +45 -0
- package/dist/kit/deploy-ops.d.ts.map +1 -0
- package/dist/kit/deploy-ops.js +69 -0
- package/dist/kit/deploy-ops.js.map +1 -0
- package/dist/kit/tx-ops.d.ts +95 -0
- package/dist/kit/tx-ops.d.ts.map +1 -0
- package/dist/kit/tx-ops.js +125 -0
- package/dist/kit/tx-ops.js.map +1 -0
- package/dist/kit/wallet-ops.d.ts +59 -0
- package/dist/kit/wallet-ops.d.ts.map +1 -0
- package/dist/kit/wallet-ops.js +122 -0
- package/dist/kit/wallet-ops.js.map +1 -0
- package/dist/kit/webauthn-ops.d.ts +55 -0
- package/dist/kit/webauthn-ops.d.ts.map +1 -0
- package/dist/kit/webauthn-ops.js +79 -0
- package/dist/kit/webauthn-ops.js.map +1 -0
- package/dist/kit.d.ts +132 -0
- package/dist/kit.d.ts.map +1 -0
- package/dist/kit.js +290 -0
- package/dist/kit.js.map +1 -0
- package/dist/managers/credential-manager.d.ts +39 -0
- package/dist/managers/credential-manager.d.ts.map +1 -0
- package/dist/managers/credential-manager.js +47 -0
- package/dist/managers/credential-manager.js.map +1 -0
- package/dist/managers/index.d.ts +7 -0
- package/dist/managers/index.d.ts.map +1 -0
- package/dist/managers/index.js +7 -0
- package/dist/managers/index.js.map +1 -0
- package/dist/managers/signer-manager.d.ts +62 -0
- package/dist/managers/signer-manager.d.ts.map +1 -0
- package/dist/managers/signer-manager.js +111 -0
- package/dist/managers/signer-manager.js.map +1 -0
- package/dist/managers/submission-manager.d.ts +52 -0
- package/dist/managers/submission-manager.d.ts.map +1 -0
- package/dist/managers/submission-manager.js +77 -0
- package/dist/managers/submission-manager.js.map +1 -0
- package/dist/relayer.d.ts +61 -0
- package/dist/relayer.d.ts.map +1 -0
- package/dist/relayer.js +122 -0
- package/dist/relayer.js.map +1 -0
- package/dist/rpc-data.d.ts +45 -0
- package/dist/rpc-data.d.ts.map +1 -0
- package/dist/rpc-data.js +61 -0
- package/dist/rpc-data.js.map +1 -0
- package/dist/sac.d.ts +31 -0
- package/dist/sac.d.ts.map +1 -0
- package/dist/sac.js +47 -0
- package/dist/sac.js.map +1 -0
- package/dist/server.d.ts +79 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +152 -0
- package/dist/server.js.map +1 -0
- package/dist/signers.d.ts +83 -0
- package/dist/signers.d.ts.map +1 -0
- package/dist/signers.js +124 -0
- package/dist/signers.js.map +1 -0
- package/dist/storage/index.d.ts +13 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +12 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/indexeddb.d.ts +26 -0
- package/dist/storage/indexeddb.d.ts.map +1 -0
- package/dist/storage/indexeddb.js +100 -0
- package/dist/storage/indexeddb.js.map +1 -0
- package/dist/storage/localStorage.d.ts +22 -0
- package/dist/storage/localStorage.d.ts.map +1 -0
- package/dist/storage/localStorage.js +86 -0
- package/dist/storage/localStorage.js.map +1 -0
- package/dist/storage/memory.d.ts +18 -0
- package/dist/storage/memory.d.ts.map +1 -0
- package/dist/storage/memory.js +41 -0
- package/dist/storage/memory.js.map +1 -0
- package/dist/types.d.ts +136 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +39 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +72 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +253 -0
- package/dist/utils.js.map +1 -0
- package/dist/validation.d.ts +42 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +75 -0
- package/dist/validation.js.map +1 -0
- package/dist/version.d.ts +7 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +9 -0
- package/dist/version.js.map +1 -0
- package/package.json +47 -20
- package/.claude/settings.local.json +0 -20
- package/.cursorrules +0 -170
- package/.gitattributes +0 -2
- package/.github/workflows/release.yml +0 -21
- package/.vscode/settings.json +0 -6
- package/PROPOSAL.md +0 -397
- package/cheatsheet.txt +0 -18
- package/clone-js-sdk.sh +0 -21
- package/packages/passkey-kit-sdk/README.md +0 -54
- package/packages/passkey-kit-sdk/package.json +0 -21
- package/packages/passkey-kit-sdk/src/index.ts +0 -171
- package/packages/passkey-kit-sdk/tsconfig.json +0 -98
- package/packages/passkey-kit-sdk/types/index.d.ts +0 -190
- package/packages/sac-sdk/README.md +0 -54
- package/packages/sac-sdk/package.json +0 -21
- package/packages/sac-sdk/src/index.ts +0 -586
- package/packages/sac-sdk/tsconfig.json +0 -98
- package/packages/sac-sdk/types/index.d.ts +0 -532
- package/pnpm-workspace.yaml +0 -2
- package/src/index.ts +0 -5
- package/src/kit.ts +0 -823
- package/src/sac.ts +0 -29
- package/src/server.ts +0 -179
- package/src/types.ts +0 -32
- package/tsconfig.json +0 -28
- package/types/index.d.ts +0 -5
- package/types/kit.d.ts +0 -95
- package/types/sac.d.ts +0 -13
- package/types/server.d.ts +0 -29
- package/types/types.d.ts +0 -22
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `localStorage` passkey storage adapter.
|
|
3
|
+
*
|
|
4
|
+
* Persists passkey records across page reloads in the browser. `localStorage`
|
|
5
|
+
* has a ~5MB limit and stores data unencrypted; for larger or more structured
|
|
6
|
+
* needs prefer {@link import("./indexeddb.js").IndexedDBStorage}.
|
|
7
|
+
*/
|
|
8
|
+
import { LOCALSTORAGE_CREDENTIALS_KEY } from "../constants.js";
|
|
9
|
+
function serialize(passkey) {
|
|
10
|
+
return { ...passkey, publicKey: Array.from(passkey.publicKey) };
|
|
11
|
+
}
|
|
12
|
+
function deserialize(data) {
|
|
13
|
+
return { ...data, publicKey: new Uint8Array(data.publicKey) };
|
|
14
|
+
}
|
|
15
|
+
export class LocalStorageAdapter {
|
|
16
|
+
storageKey;
|
|
17
|
+
constructor(storageKey = LOCALSTORAGE_CREDENTIALS_KEY) {
|
|
18
|
+
this.storageKey = storageKey;
|
|
19
|
+
}
|
|
20
|
+
read() {
|
|
21
|
+
if (typeof localStorage === "undefined") {
|
|
22
|
+
throw new Error("localStorage is not available in this environment");
|
|
23
|
+
}
|
|
24
|
+
const data = localStorage.getItem(this.storageKey);
|
|
25
|
+
if (!data)
|
|
26
|
+
return new Map();
|
|
27
|
+
try {
|
|
28
|
+
const parsed = JSON.parse(data);
|
|
29
|
+
const map = new Map();
|
|
30
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
31
|
+
map.set(key, deserialize(value));
|
|
32
|
+
}
|
|
33
|
+
return map;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
// Corrupt storage: warn loudly rather than silently dropping the user's
|
|
37
|
+
// passkeys. Return empty so the app keeps working; do not overwrite.
|
|
38
|
+
console.error(`[PasskeyKit] Failed to parse stored passkeys at "${this.storageKey}"; treating storage as empty.`, error);
|
|
39
|
+
return new Map();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
write(passkeys) {
|
|
43
|
+
const obj = {};
|
|
44
|
+
for (const [key, value] of passkeys.entries()) {
|
|
45
|
+
obj[key] = serialize(value);
|
|
46
|
+
}
|
|
47
|
+
localStorage.setItem(this.storageKey, JSON.stringify(obj));
|
|
48
|
+
}
|
|
49
|
+
async save(passkey) {
|
|
50
|
+
const passkeys = this.read();
|
|
51
|
+
passkeys.set(passkey.keyId, passkey);
|
|
52
|
+
this.write(passkeys);
|
|
53
|
+
}
|
|
54
|
+
async get(keyId) {
|
|
55
|
+
return this.read().get(keyId) ?? null;
|
|
56
|
+
}
|
|
57
|
+
async getByContract(contractId) {
|
|
58
|
+
const results = [];
|
|
59
|
+
for (const passkey of this.read().values()) {
|
|
60
|
+
if (passkey.contractId === contractId) {
|
|
61
|
+
results.push(passkey);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return results;
|
|
65
|
+
}
|
|
66
|
+
async getAll() {
|
|
67
|
+
return Array.from(this.read().values());
|
|
68
|
+
}
|
|
69
|
+
async delete(keyId) {
|
|
70
|
+
const passkeys = this.read();
|
|
71
|
+
passkeys.delete(keyId);
|
|
72
|
+
this.write(passkeys);
|
|
73
|
+
}
|
|
74
|
+
async update(keyId, updates) {
|
|
75
|
+
const passkeys = this.read();
|
|
76
|
+
const passkey = passkeys.get(keyId);
|
|
77
|
+
if (passkey) {
|
|
78
|
+
passkeys.set(keyId, { ...passkey, ...updates });
|
|
79
|
+
this.write(passkeys);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async clear() {
|
|
83
|
+
localStorage.removeItem(this.storageKey);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=localStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localStorage.js","sourceRoot":"","sources":["../../src/storage/localStorage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAU/D,SAAS,SAAS,CAAC,OAAsB;IACvC,OAAO,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;AAClE,CAAC;AAED,SAAS,WAAW,CAAC,IAAuB;IAC1C,OAAO,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,OAAO,mBAAmB;IACtB,UAAU,CAAS;IAE3B,YAAY,aAAqB,4BAA4B;QAC3D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEO,IAAI;QACV,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;YACxC,MAAM,IA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C;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory passkey storage adapter.
|
|
3
|
+
*
|
|
4
|
+
* Useful for tests and server-side environments. Data is lost when the process
|
|
5
|
+
* restarts.
|
|
6
|
+
*/
|
|
7
|
+
import type { StorageAdapter, StoredPasskey } from "../types.js";
|
|
8
|
+
export declare class MemoryStorage implements StorageAdapter {
|
|
9
|
+
private passkeys;
|
|
10
|
+
save(passkey: StoredPasskey): Promise<void>;
|
|
11
|
+
get(keyId: string): Promise<StoredPasskey | null>;
|
|
12
|
+
getByContract(contractId: string): Promise<StoredPasskey[]>;
|
|
13
|
+
getAll(): Promise<StoredPasskey[]>;
|
|
14
|
+
delete(keyId: string): Promise<void>;
|
|
15
|
+
update(keyId: string, updates: Partial<Omit<StoredPasskey, "keyId" | "publicKey">>): Promise<void>;
|
|
16
|
+
clear(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/storage/memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjE,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,QAAQ,CAAyC;IAEnD,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAKjD,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAU3D,MAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAIlC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,WAAW,CAAC,CAAC,GAC3D,OAAO,CAAC,IAAI,CAAC;IAOV,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory passkey storage adapter.
|
|
3
|
+
*
|
|
4
|
+
* Useful for tests and server-side environments. Data is lost when the process
|
|
5
|
+
* restarts.
|
|
6
|
+
*/
|
|
7
|
+
export class MemoryStorage {
|
|
8
|
+
passkeys = new Map();
|
|
9
|
+
async save(passkey) {
|
|
10
|
+
this.passkeys.set(passkey.keyId, { ...passkey });
|
|
11
|
+
}
|
|
12
|
+
async get(keyId) {
|
|
13
|
+
const passkey = this.passkeys.get(keyId);
|
|
14
|
+
return passkey ? { ...passkey } : null;
|
|
15
|
+
}
|
|
16
|
+
async getByContract(contractId) {
|
|
17
|
+
const results = [];
|
|
18
|
+
for (const passkey of this.passkeys.values()) {
|
|
19
|
+
if (passkey.contractId === contractId) {
|
|
20
|
+
results.push({ ...passkey });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return results;
|
|
24
|
+
}
|
|
25
|
+
async getAll() {
|
|
26
|
+
return Array.from(this.passkeys.values()).map((p) => ({ ...p }));
|
|
27
|
+
}
|
|
28
|
+
async delete(keyId) {
|
|
29
|
+
this.passkeys.delete(keyId);
|
|
30
|
+
}
|
|
31
|
+
async update(keyId, updates) {
|
|
32
|
+
const passkey = this.passkeys.get(keyId);
|
|
33
|
+
if (passkey) {
|
|
34
|
+
this.passkeys.set(keyId, { ...passkey, ...updates });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async clear() {
|
|
38
|
+
this.passkeys.clear();
|
|
39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AC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,MAAM,CACV,KAAa,EACb,OAA4D;QAE5D,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for the Passkey Kit SDK.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { AuthenticationResponseJSON, RegistrationResponseJSON } from "@simplewebauthn/browser";
|
|
7
|
+
import type { PasskeyKitError } from "./errors.js";
|
|
8
|
+
/**
|
|
9
|
+
* The three signer kinds the smart wallet understands.
|
|
10
|
+
*/
|
|
11
|
+
export type SignerKeyTag = "Policy" | "Ed25519" | "Secp256r1";
|
|
12
|
+
/**
|
|
13
|
+
* A convenience wrapper describing which signer a key/limits entry refers to.
|
|
14
|
+
*
|
|
15
|
+
* The `value` is the string form the caller works with: a `C…`/`G…` address for
|
|
16
|
+
* `Policy`, a `G…` public key for `Ed25519`, or a base64url credential id for
|
|
17
|
+
* `Secp256r1`. The signing pipeline converts these into the contract's
|
|
18
|
+
* `SignerKey` ScVals.
|
|
19
|
+
*/
|
|
20
|
+
export declare class SignerKey {
|
|
21
|
+
key: SignerKeyTag;
|
|
22
|
+
value: string;
|
|
23
|
+
private constructor();
|
|
24
|
+
static Policy(policy: string): SignerKey;
|
|
25
|
+
static Ed25519(publicKey: string): SignerKey;
|
|
26
|
+
static Secp256r1(keyId: string): SignerKey;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Per-signer limits: a map of contract address → the signer keys that signer may
|
|
30
|
+
* co-authorize on that contract (`undefined` value = unrestricted on that
|
|
31
|
+
* contract). `undefined` for the whole map = a fully unlimited signer.
|
|
32
|
+
*/
|
|
33
|
+
export type SignerLimits = Map<string, SignerKey[] | undefined> | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Storage durability for a signer entry.
|
|
36
|
+
*/
|
|
37
|
+
export declare enum SignerStore {
|
|
38
|
+
Persistent = "Persistent",
|
|
39
|
+
Temporary = "Temporary"
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A persisted passkey → smart-wallet association.
|
|
43
|
+
*
|
|
44
|
+
* The `keyId` (base64url credential id) is essential for re-authenticating the
|
|
45
|
+
* passkey later; the `contractId` lets the kit reconnect a wallet from a keyId
|
|
46
|
+
* without an indexer round-trip.
|
|
47
|
+
*/
|
|
48
|
+
export interface StoredPasskey {
|
|
49
|
+
/** Base64URL-encoded credential id (the passkey keyId) — the unique key. */
|
|
50
|
+
keyId: string;
|
|
51
|
+
/** 65-byte uncompressed secp256r1 public key (0x04 prefix + x + y). */
|
|
52
|
+
publicKey: Uint8Array;
|
|
53
|
+
/** Smart-wallet contract address this passkey controls. */
|
|
54
|
+
contractId: string;
|
|
55
|
+
/** User-friendly label for this passkey. */
|
|
56
|
+
nickname?: string;
|
|
57
|
+
/** Unix-ms timestamp when the passkey was created. */
|
|
58
|
+
createdAt: number;
|
|
59
|
+
/** Unix-ms timestamp when the passkey was last used. */
|
|
60
|
+
lastUsedAt?: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Interface for passkey storage adapters.
|
|
64
|
+
*
|
|
65
|
+
* Implementations persist the passkey → wallet association in various backends
|
|
66
|
+
* (IndexedDB, localStorage, memory). See `./storage`.
|
|
67
|
+
*/
|
|
68
|
+
export interface StorageAdapter {
|
|
69
|
+
/** Save a new passkey record or overwrite an existing one (keyed by keyId). */
|
|
70
|
+
save(passkey: StoredPasskey): Promise<void>;
|
|
71
|
+
/** Get a passkey record by its keyId. */
|
|
72
|
+
get(keyId: string): Promise<StoredPasskey | null>;
|
|
73
|
+
/** Get all passkey records associated with a contract. */
|
|
74
|
+
getByContract(contractId: string): Promise<StoredPasskey[]>;
|
|
75
|
+
/** Get every stored passkey record. */
|
|
76
|
+
getAll(): Promise<StoredPasskey[]>;
|
|
77
|
+
/** Delete a passkey record by its keyId. */
|
|
78
|
+
delete(keyId: string): Promise<void>;
|
|
79
|
+
/** Update mutable metadata on a stored passkey record. */
|
|
80
|
+
update(keyId: string, updates: Partial<Omit<StoredPasskey, "keyId" | "publicKey">>): Promise<void>;
|
|
81
|
+
/** Remove every stored passkey record. */
|
|
82
|
+
clear(): Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
/** Result of creating (deploying) a new smart wallet. */
|
|
85
|
+
export interface CreateWalletResult {
|
|
86
|
+
/** The raw WebAuthn registration response. */
|
|
87
|
+
rawResponse: RegistrationResponseJSON;
|
|
88
|
+
/** Raw credential id bytes. */
|
|
89
|
+
keyId: Uint8Array;
|
|
90
|
+
/** Base64URL-encoded credential id. */
|
|
91
|
+
keyIdBase64: string;
|
|
92
|
+
/** Deployed smart-wallet contract address. */
|
|
93
|
+
contractId: string;
|
|
94
|
+
/** Signed deployment transaction, ready to submit (base64 XDR). */
|
|
95
|
+
signedTx: string;
|
|
96
|
+
}
|
|
97
|
+
/** Result of connecting to an existing smart wallet. */
|
|
98
|
+
export interface ConnectWalletResult {
|
|
99
|
+
/** Raw WebAuthn authentication response, when a ceremony was performed. */
|
|
100
|
+
rawResponse?: AuthenticationResponseJSON;
|
|
101
|
+
/** Raw credential id bytes. */
|
|
102
|
+
keyId: Uint8Array;
|
|
103
|
+
/** Base64URL-encoded credential id. */
|
|
104
|
+
keyIdBase64: string;
|
|
105
|
+
/** Connected smart-wallet contract address. */
|
|
106
|
+
contractId: string;
|
|
107
|
+
}
|
|
108
|
+
/** Successful result of a submission operation. */
|
|
109
|
+
export interface TransactionSuccess {
|
|
110
|
+
success: true;
|
|
111
|
+
/** Transaction hash (may be empty for a `skipWait` submission not yet polled). */
|
|
112
|
+
hash: string;
|
|
113
|
+
/** Ledger the transaction was included in, when known. */
|
|
114
|
+
ledger?: number;
|
|
115
|
+
/** Relayer transaction id, for polling a `skipWait` submission. */
|
|
116
|
+
transactionId?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Failed result of a submission operation.
|
|
120
|
+
*
|
|
121
|
+
* Submission methods never throw for expected on-chain/relayer failures; they
|
|
122
|
+
* return this shape with a typed {@link PasskeyKitError} (a `ContractError` when
|
|
123
|
+
* an on-chain contract code was decoded). All other SDK methods throw.
|
|
124
|
+
*/
|
|
125
|
+
export interface TransactionFailure {
|
|
126
|
+
success: false;
|
|
127
|
+
/** The typed error describing the failure. Branch on `error.code`. */
|
|
128
|
+
error: PasskeyKitError;
|
|
129
|
+
/** Transaction hash, when one was assigned before the failure. */
|
|
130
|
+
hash?: string;
|
|
131
|
+
}
|
|
132
|
+
/** Result of a submission operation: a discriminated union on `success`. */
|
|
133
|
+
export type TransactionResult = TransactionSuccess | TransactionFailure;
|
|
134
|
+
/** How a transaction is submitted to the network. */
|
|
135
|
+
export type SubmissionMethod = "relayer" | "rpc";
|
|
136
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAMnD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;AAE9D;;;;;;;GAOG;AACH,qBAAa,SAAS;IAEX,GAA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AkB,CAAC;AAExE,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,KAAK,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for the Passkey Kit SDK.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A convenience wrapper describing which signer a key/limits entry refers to.
|
|
8
|
+
*
|
|
9
|
+
* The `value` is the string form the caller works with: a `C…`/`G…` address for
|
|
10
|
+
* `Policy`, a `G…` public key for `Ed25519`, or a base64url credential id for
|
|
11
|
+
* `Secp256r1`. The signing pipeline converts these into the contract's
|
|
12
|
+
* `SignerKey` ScVals.
|
|
13
|
+
*/
|
|
14
|
+
export class SignerKey {
|
|
15
|
+
key;
|
|
16
|
+
value;
|
|
17
|
+
constructor(key, value) {
|
|
18
|
+
this.key = key;
|
|
19
|
+
this.value = value;
|
|
20
|
+
}
|
|
21
|
+
static Policy(policy) {
|
|
22
|
+
return new SignerKey("Policy", policy);
|
|
23
|
+
}
|
|
24
|
+
static Ed25519(publicKey) {
|
|
25
|
+
return new SignerKey("Ed25519", publicKey);
|
|
26
|
+
}
|
|
27
|
+
static Secp256r1(keyId) {
|
|
28
|
+
return new SignerKey("Secp256r1", keyId);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Storage durability for a signer entry.
|
|
33
|
+
*/
|
|
34
|
+
export var SignerStore;
|
|
35
|
+
(function (SignerStore) {
|
|
36
|
+
SignerStore["Persistent"] = "Persistent";
|
|
37
|
+
SignerStore["Temporary"] = "Temporary";
|
|
38
|
+
})(SignerStore || (SignerStore = {}));
|
|
39
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH;;;;;;;GAOG;AACH,MAAM,OAAO,SAAS;IAEX;IACA;IAFT,YACS,GAAiB,EACjB,KAAa;QADb,QAAG,GAAH,GAAG,CAAc;QACjB,UAAK,GAAL,KAAK,CAAQ;IACnB,CAAC;IAEJ,MAAM,CAAC,MAAM,CAAC,MAAc;QAC1B,OAAO,IAAI,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,SAAiB;QAC9B,OAAO,IAAI,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,KAAa;QAC5B,OAAO,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AASD;;GAEG;AACH,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,sCAAuB,CAAA;AACzB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic and derivation helpers for the Passkey Kit SDK.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { RegistrationResponseJSON } from "@simplewebauthn/browser";
|
|
7
|
+
/**
|
|
8
|
+
* Derive a smart-wallet contract address from a passkey credential id.
|
|
9
|
+
*
|
|
10
|
+
* The wallet's contract id is deterministic: `salt = sha256(keyId)` and the
|
|
11
|
+
* deployer address salts a `ContractIdPreimageFromAddress`. This determinism is
|
|
12
|
+
* load-bearing — the indexer reverse-lookup (keyId → wallet) re-derives the
|
|
13
|
+
* address the same way — so this function is pinned with golden vectors in
|
|
14
|
+
* `utils.test.ts`. Any change to the derivation breaks the tests instead of
|
|
15
|
+
* silently shifting deployed addresses.
|
|
16
|
+
*
|
|
17
|
+
* @param keyId - The raw credential id bytes
|
|
18
|
+
* @param deployerPublicKey - The deployer's `G…` public key
|
|
19
|
+
* @param networkPassphrase - The network passphrase
|
|
20
|
+
* @returns The derived contract address (`C…`)
|
|
21
|
+
*/
|
|
22
|
+
export declare function deriveContractAddress(keyId: Buffer, deployerPublicKey: string, networkPassphrase: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether an uncompressed `0x04 || x || y` key is a point on the P-256 curve
|
|
25
|
+
* (`y² ≡ x³ − 3x + b (mod p)`, coordinates in-field). A structurally valid but
|
|
26
|
+
* off-curve key would register fine and deploy a wallet no signature can ever
|
|
27
|
+
* satisfy, so extraction rejects it up front.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isOnP256Curve(publicKey: Uint8Array): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Extract the 65-byte uncompressed secp256r1 public key from a WebAuthn
|
|
32
|
+
* registration (attestation) response.
|
|
33
|
+
*
|
|
34
|
+
* Tries, in order:
|
|
35
|
+
* 1. `response.publicKey` when it is already a raw uncompressed EC point.
|
|
36
|
+
* 2. `response.publicKey` decoded from SPKI via WebCrypto (`crypto.subtle`),
|
|
37
|
+
* which is the correct, non-magic-offset way to normalize the DER-encoded
|
|
38
|
+
* SubjectPublicKeyInfo most authenticators return.
|
|
39
|
+
* 3. Parsing the COSE key out of `authenticatorData`, then
|
|
40
|
+
* `attestationObject` — with the COSE structure verified in place, never
|
|
41
|
+
* trusted fixed offsets.
|
|
42
|
+
*
|
|
43
|
+
* Whatever the source, the result must be a valid point ON the P-256 curve;
|
|
44
|
+
* a mangled key is rejected here rather than deployed as an unusable wallet
|
|
45
|
+
* signer.
|
|
46
|
+
*
|
|
47
|
+
* @throws {WebAuthnError} If no valid public key can be extracted.
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractPublicKeyFromAttestation(response: RegistrationResponseJSON["response"]): Promise<Uint8Array>;
|
|
50
|
+
/**
|
|
51
|
+
* Convert a DER-encoded ECDSA signature to Stellar's compact `r || s` form with
|
|
52
|
+
* a low-S value (S <= n/2), as required by the secp256r1 host function.
|
|
53
|
+
*
|
|
54
|
+
* The DER structure is validated before any offset is dereferenced:
|
|
55
|
+
* sequence/integer tags, short-form lengths that exactly span the buffer, and
|
|
56
|
+
* `r`/`s` values in `[1, n-1]`. A WebAuthn P-256 signature always fits
|
|
57
|
+
* short-form DER (total length < 128 bytes), so long-form lengths are rejected.
|
|
58
|
+
*
|
|
59
|
+
* @param derSignature - The DER-encoded signature
|
|
60
|
+
* @returns 64-byte compact signature (`r || s`)
|
|
61
|
+
* @throws {ValidationError} If the signature is not structurally valid DER or
|
|
62
|
+
* `r`/`s` are out of range for P-256.
|
|
63
|
+
*/
|
|
64
|
+
export declare function compactSignature(derSignature: Buffer): Uint8Array;
|
|
65
|
+
/**
|
|
66
|
+
* Generate a cryptographically-random base64url challenge for a WebAuthn
|
|
67
|
+
* ceremony.
|
|
68
|
+
*
|
|
69
|
+
* Replaces the old hard-coded `"stellaristhebetterblockchain"` challenge.
|
|
70
|
+
*/
|
|
71
|
+
export declare function generateChallenge(): string;
|
|
72
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAoBxE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,MAAM,EACzB,iBAAiB,EAAE,MAAM,GACxB,MAAM,CAcR;AAcD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAe5D;AAgDD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,wBAAwB,CAAC,UAAU,CAAC,GAC7C,OAAO,CAAC,UAAU,CAAC,CAoDrB;AAaD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CAmDjE;AAMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAI1C"}
|