passkey-kit 0.12.0 → 0.13.1
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 +399 -227
- package/{types → dist}/base.d.ts +2 -1
- 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 +87 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +111 -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 +129 -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 +88 -0
- package/dist/indexer/mercury.d.ts.map +1 -0
- package/dist/indexer/mercury.js +237 -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 +89 -0
- package/dist/kit/auth-payload.d.ts.map +1 -0
- package/dist/kit/auth-payload.js +203 -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 +92 -0
- package/dist/kit/tx-ops.d.ts.map +1 -0
- package/dist/kit/tx-ops.js +113 -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 +128 -0
- package/dist/kit.d.ts.map +1 -0
- package/dist/kit.js +276 -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 +51 -0
- package/dist/managers/signer-manager.d.ts.map +1 -0
- package/dist/managers/signer-manager.js +92 -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 +119 -0
- package/dist/relayer.js.map +1 -0
- package/dist/rpc-data.d.ts +35 -0
- package/dist/rpc-data.d.ts.map +1 -0
- package/dist/rpc-data.js +49 -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 +52 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +153 -0
- package/dist/utils.js.map +1 -0
- package/dist/validation.d.ts +40 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +73 -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 +48 -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 -18
- 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 -18
- 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 -698
- 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 -89
- 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,52 @@
|
|
|
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
|
+
* Extract the 65-byte uncompressed secp256r1 public key from a WebAuthn
|
|
25
|
+
* registration (attestation) response.
|
|
26
|
+
*
|
|
27
|
+
* Tries, in order:
|
|
28
|
+
* 1. `response.publicKey` when it is already a raw uncompressed EC point.
|
|
29
|
+
* 2. `response.publicKey` decoded from SPKI via WebCrypto (`crypto.subtle`),
|
|
30
|
+
* which is the correct, non-magic-offset way to normalize the DER-encoded
|
|
31
|
+
* SubjectPublicKeyInfo most authenticators return.
|
|
32
|
+
* 3. Parsing the COSE key out of `authenticatorData` / `attestationObject`.
|
|
33
|
+
*
|
|
34
|
+
* @throws {WebAuthnError} If the public key cannot be extracted.
|
|
35
|
+
*/
|
|
36
|
+
export declare function extractPublicKeyFromAttestation(response: RegistrationResponseJSON["response"]): Promise<Uint8Array>;
|
|
37
|
+
/**
|
|
38
|
+
* Convert a DER-encoded ECDSA signature to Stellar's compact `r || s` form with
|
|
39
|
+
* a low-S value (S <= n/2), as required by the secp256r1 host function.
|
|
40
|
+
*
|
|
41
|
+
* @param derSignature - The DER-encoded signature
|
|
42
|
+
* @returns 64-byte compact signature (`r || s`)
|
|
43
|
+
*/
|
|
44
|
+
export declare function compactSignature(derSignature: Buffer): Uint8Array;
|
|
45
|
+
/**
|
|
46
|
+
* Generate a cryptographically-random base64url challenge for a WebAuthn
|
|
47
|
+
* ceremony.
|
|
48
|
+
*
|
|
49
|
+
* Replaces the old hard-coded `"stellaristhebetterblockchain"` challenge.
|
|
50
|
+
*/
|
|
51
|
+
export declare function generateChallenge(): string;
|
|
52
|
+
//# 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;AAcxE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,MAAM,EACzB,iBAAiB,EAAE,MAAM,GACxB,MAAM,CAcR;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,wBAAwB,CAAC,UAAU,CAAC,GAC7C,OAAO,CAAC,UAAU,CAAC,CAsFrB;AAMD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CAyBjE;AAMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAI1C"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic and derivation helpers for the Passkey Kit SDK.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import { StrKey, hash, xdr, Address } from "@stellar/stellar-sdk";
|
|
7
|
+
import base64url from "./base64url.js";
|
|
8
|
+
import { SECP256R1_PUBLIC_KEY_SIZE, SECP256R1_CURVE_ORDER, UNCOMPRESSED_PUBKEY_PREFIX, WEBAUTHN_CHALLENGE_SIZE, } from "./constants.js";
|
|
9
|
+
import { WebAuthnError, PasskeyKitErrorCode } from "./errors.js";
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Deterministic contract-address derivation
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Derive a smart-wallet contract address from a passkey credential id.
|
|
15
|
+
*
|
|
16
|
+
* The wallet's contract id is deterministic: `salt = sha256(keyId)` and the
|
|
17
|
+
* deployer address salts a `ContractIdPreimageFromAddress`. This determinism is
|
|
18
|
+
* load-bearing — the indexer reverse-lookup (keyId → wallet) re-derives the
|
|
19
|
+
* address the same way — so this function is pinned with golden vectors in
|
|
20
|
+
* `utils.test.ts`. Any change to the derivation breaks the tests instead of
|
|
21
|
+
* silently shifting deployed addresses.
|
|
22
|
+
*
|
|
23
|
+
* @param keyId - The raw credential id bytes
|
|
24
|
+
* @param deployerPublicKey - The deployer's `G…` public key
|
|
25
|
+
* @param networkPassphrase - The network passphrase
|
|
26
|
+
* @returns The derived contract address (`C…`)
|
|
27
|
+
*/
|
|
28
|
+
export function deriveContractAddress(keyId, deployerPublicKey, networkPassphrase) {
|
|
29
|
+
const preimage = xdr.HashIdPreimage.envelopeTypeContractId(new xdr.HashIdPreimageContractId({
|
|
30
|
+
networkId: hash(Buffer.from(networkPassphrase)),
|
|
31
|
+
contractIdPreimage: xdr.ContractIdPreimage.contractIdPreimageFromAddress(new xdr.ContractIdPreimageFromAddress({
|
|
32
|
+
address: Address.fromString(deployerPublicKey).toScAddress(),
|
|
33
|
+
salt: hash(keyId),
|
|
34
|
+
})),
|
|
35
|
+
}));
|
|
36
|
+
return StrKey.encodeContract(hash(preimage.toXDR()));
|
|
37
|
+
}
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// WebAuthn public-key extraction
|
|
40
|
+
// ============================================================================
|
|
41
|
+
/**
|
|
42
|
+
* Extract the 65-byte uncompressed secp256r1 public key from a WebAuthn
|
|
43
|
+
* registration (attestation) response.
|
|
44
|
+
*
|
|
45
|
+
* Tries, in order:
|
|
46
|
+
* 1. `response.publicKey` when it is already a raw uncompressed EC point.
|
|
47
|
+
* 2. `response.publicKey` decoded from SPKI via WebCrypto (`crypto.subtle`),
|
|
48
|
+
* which is the correct, non-magic-offset way to normalize the DER-encoded
|
|
49
|
+
* SubjectPublicKeyInfo most authenticators return.
|
|
50
|
+
* 3. Parsing the COSE key out of `authenticatorData` / `attestationObject`.
|
|
51
|
+
*
|
|
52
|
+
* @throws {WebAuthnError} If the public key cannot be extracted.
|
|
53
|
+
*/
|
|
54
|
+
export async function extractPublicKeyFromAttestation(response) {
|
|
55
|
+
let publicKey;
|
|
56
|
+
if (response.publicKey) {
|
|
57
|
+
const encodedPublicKey = base64url.toBuffer(response.publicKey);
|
|
58
|
+
if (encodedPublicKey.length === SECP256R1_PUBLIC_KEY_SIZE &&
|
|
59
|
+
encodedPublicKey[0] === UNCOMPRESSED_PUBKEY_PREFIX) {
|
|
60
|
+
publicKey = encodedPublicKey;
|
|
61
|
+
}
|
|
62
|
+
else if (typeof crypto?.subtle !== "undefined") {
|
|
63
|
+
try {
|
|
64
|
+
const imported = await crypto.subtle.importKey("spki", new Uint8Array(encodedPublicKey), { name: "ECDSA", namedCurve: "P-256" }, true, []);
|
|
65
|
+
const rawKey = await crypto.subtle.exportKey("raw", imported);
|
|
66
|
+
publicKey = Buffer.from(new Uint8Array(rawKey));
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
publicKey = encodedPublicKey.subarray(encodedPublicKey.length - SECP256R1_PUBLIC_KEY_SIZE);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
publicKey = encodedPublicKey.subarray(encodedPublicKey.length - SECP256R1_PUBLIC_KEY_SIZE);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Validate it is a proper uncompressed EC point; otherwise fall back to the
|
|
77
|
+
// COSE key embedded in authenticatorData / attestationObject.
|
|
78
|
+
if (!publicKey ||
|
|
79
|
+
publicKey[0] !== UNCOMPRESSED_PUBKEY_PREFIX ||
|
|
80
|
+
publicKey.length !== SECP256R1_PUBLIC_KEY_SIZE) {
|
|
81
|
+
let x;
|
|
82
|
+
let y;
|
|
83
|
+
if (response.authenticatorData) {
|
|
84
|
+
const authenticatorData = base64url.toBuffer(response.authenticatorData);
|
|
85
|
+
const credentialIdLength = (authenticatorData[53] << 8) | authenticatorData[54];
|
|
86
|
+
x = authenticatorData.subarray(65 + credentialIdLength, 97 + credentialIdLength);
|
|
87
|
+
y = authenticatorData.subarray(100 + credentialIdLength, 132 + credentialIdLength);
|
|
88
|
+
}
|
|
89
|
+
else if (response.attestationObject) {
|
|
90
|
+
const attestationObject = base64url.toBuffer(response.attestationObject);
|
|
91
|
+
// COSE key structure prefix for an ES256 (P-256) key.
|
|
92
|
+
const publicKeyPrefixSlice = Buffer.from([
|
|
93
|
+
0xa5, 0x01, 0x02, 0x03, 0x26, 0x20, 0x01, 0x21, 0x58, 0x20,
|
|
94
|
+
]);
|
|
95
|
+
let startIndex = attestationObject.indexOf(publicKeyPrefixSlice);
|
|
96
|
+
if (startIndex === -1) {
|
|
97
|
+
throw new WebAuthnError("Could not locate the COSE public key in the attestation object", PasskeyKitErrorCode.PUBLIC_KEY_EXTRACTION_FAILED);
|
|
98
|
+
}
|
|
99
|
+
startIndex = startIndex + publicKeyPrefixSlice.length;
|
|
100
|
+
x = attestationObject.subarray(startIndex, 32 + startIndex);
|
|
101
|
+
y = attestationObject.subarray(35 + startIndex, 67 + startIndex);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw new WebAuthnError("Could not extract a public key from the attestation response", PasskeyKitErrorCode.PUBLIC_KEY_EXTRACTION_FAILED);
|
|
105
|
+
}
|
|
106
|
+
publicKey = Buffer.from([UNCOMPRESSED_PUBKEY_PREFIX, ...x, ...y]);
|
|
107
|
+
}
|
|
108
|
+
return new Uint8Array(publicKey);
|
|
109
|
+
}
|
|
110
|
+
// ============================================================================
|
|
111
|
+
// Signature encoding
|
|
112
|
+
// ============================================================================
|
|
113
|
+
/**
|
|
114
|
+
* Convert a DER-encoded ECDSA signature to Stellar's compact `r || s` form with
|
|
115
|
+
* a low-S value (S <= n/2), as required by the secp256r1 host function.
|
|
116
|
+
*
|
|
117
|
+
* @param derSignature - The DER-encoded signature
|
|
118
|
+
* @returns 64-byte compact signature (`r || s`)
|
|
119
|
+
*/
|
|
120
|
+
export function compactSignature(derSignature) {
|
|
121
|
+
// DER: 0x30 [total-len] 0x02 [r-len] [r] 0x02 [s-len] [s]
|
|
122
|
+
let offset = 2; // skip 0x30 and the total length
|
|
123
|
+
const rLength = derSignature[offset + 1];
|
|
124
|
+
const r = derSignature.subarray(offset + 2, offset + 2 + rLength);
|
|
125
|
+
offset += 2 + rLength;
|
|
126
|
+
const sLength = derSignature[offset + 1];
|
|
127
|
+
const s = derSignature.subarray(offset + 2, offset + 2 + sLength);
|
|
128
|
+
const rBigInt = BigInt("0x" + r.toString("hex"));
|
|
129
|
+
let sBigInt = BigInt("0x" + s.toString("hex"));
|
|
130
|
+
// Enforce low-S.
|
|
131
|
+
const halfN = SECP256R1_CURVE_ORDER / 2n;
|
|
132
|
+
if (sBigInt > halfN) {
|
|
133
|
+
sBigInt = SECP256R1_CURVE_ORDER - sBigInt;
|
|
134
|
+
}
|
|
135
|
+
const rPadded = Buffer.from(rBigInt.toString(16).padStart(64, "0"), "hex");
|
|
136
|
+
const sLowS = Buffer.from(sBigInt.toString(16).padStart(64, "0"), "hex");
|
|
137
|
+
return new Uint8Array(Buffer.concat([rPadded, sLowS]));
|
|
138
|
+
}
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// WebAuthn challenge
|
|
141
|
+
// ============================================================================
|
|
142
|
+
/**
|
|
143
|
+
* Generate a cryptographically-random base64url challenge for a WebAuthn
|
|
144
|
+
* ceremony.
|
|
145
|
+
*
|
|
146
|
+
* Replaces the old hard-coded `"stellaristhebetterblockchain"` challenge.
|
|
147
|
+
*/
|
|
148
|
+
export function generateChallenge() {
|
|
149
|
+
const bytes = new Uint8Array(WEBAUTHN_CHALLENGE_SIZE);
|
|
150
|
+
crypto.getRandomValues(bytes);
|
|
151
|
+
return base64url.encode(Buffer.from(bytes));
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,IAA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C;IAC3E,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAEzE,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACtD,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side input validation.
|
|
3
|
+
*
|
|
4
|
+
* Produces clear {@link ValidationError}s before submission instead of opaque
|
|
5
|
+
* on-chain or WebCrypto failures. The smart wallet imposes no signer-count caps
|
|
6
|
+
* (unlike a policy-based account), so validation here is about shapes and
|
|
7
|
+
* ranges: addresses, amounts, expirations, and secp256r1 public keys.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Validate that a string is a Stellar account (`G…`) or contract (`C…`) address.
|
|
13
|
+
*
|
|
14
|
+
* @throws {ValidationError} If the address is missing or malformed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateAddress(address: string, fieldName?: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Validate that an amount is a positive, finite number.
|
|
19
|
+
*
|
|
20
|
+
* @throws {ValidationError} If the amount is not a positive number.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateAmount(amount: number, fieldName?: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Validate a signer expiration.
|
|
25
|
+
*
|
|
26
|
+
* Must be a non-negative integer within `u32` bounds when provided; `undefined`
|
|
27
|
+
* means "no expiration". (Unix-second timestamps fit in `u32` through the year
|
|
28
|
+
* 2106, so this bound holds whether the contract interprets the value as a
|
|
29
|
+
* ledger sequence or a UNIX timestamp.)
|
|
30
|
+
*
|
|
31
|
+
* @throws {ValidationError} If the expiration is out of range.
|
|
32
|
+
*/
|
|
33
|
+
export declare function validateExpiration(expiration: number | undefined, fieldName?: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Validate a secp256r1 public key: 65 bytes, uncompressed (`0x04`) prefix.
|
|
36
|
+
*
|
|
37
|
+
* @throws {ValidationError} If the key is not a valid uncompressed EC point.
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateSecp256r1PublicKey(publicKey: Uint8Array, fieldName?: string): void;
|
|
40
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,SAAY,GACpB,IAAI,CAmBN;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,SAAW,GAAG,IAAI,CAezE;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,SAAS,SAAe,GACvB,IAAI,CAaN;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,UAAU,EACrB,SAAS,SAAc,GACtB,IAAI,CAeN"}
|