passkey-kit 0.16.5 → 0.17.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 +70 -33
- package/dist/contract-errors.d.ts +1 -1
- package/dist/contract-errors.d.ts.map +1 -1
- package/dist/contract-errors.js +6 -2
- package/dist/contract-errors.js.map +1 -1
- package/dist/errors.d.ts +7 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/indexer/index.d.ts +1 -1
- package/dist/indexer/index.d.ts.map +1 -1
- package/dist/indexer/index.js.map +1 -1
- package/dist/indexer/mercury.d.ts +8 -12
- package/dist/indexer/mercury.d.ts.map +1 -1
- package/dist/indexer/mercury.js +110 -37
- package/dist/indexer/mercury.js.map +1 -1
- package/dist/indexer/types.d.ts +41 -5
- package/dist/indexer/types.d.ts.map +1 -1
- package/dist/kit/birth-verification.d.ts +45 -0
- package/dist/kit/birth-verification.d.ts.map +1 -0
- package/dist/kit/birth-verification.js +127 -0
- package/dist/kit/birth-verification.js.map +1 -0
- package/dist/kit/deploy-ops.d.ts +2 -2
- package/dist/kit/deploy-ops.d.ts.map +1 -1
- package/dist/kit/deploy-ops.js +2 -2
- package/dist/kit/deploy-ops.js.map +1 -1
- package/dist/kit/wallet-ops.d.ts +14 -2
- package/dist/kit/wallet-ops.d.ts.map +1 -1
- package/dist/kit/wallet-ops.js +50 -3
- package/dist/kit/wallet-ops.js.map +1 -1
- package/dist/kit/webauthn-ops.d.ts +3 -1
- package/dist/kit/webauthn-ops.d.ts.map +1 -1
- package/dist/kit/webauthn-ops.js +8 -2
- package/dist/kit/webauthn-ops.js.map +1 -1
- package/dist/kit/webauthn-verify.d.ts +166 -0
- package/dist/kit/webauthn-verify.d.ts.map +1 -0
- package/dist/kit/webauthn-verify.js +328 -0
- package/dist/kit/webauthn-verify.js.map +1 -0
- package/dist/kit.d.ts +60 -38
- package/dist/kit.d.ts.map +1 -1
- package/dist/kit.js +335 -108
- package/dist/kit.js.map +1 -1
- package/dist/managers/credential-manager.d.ts +2 -2
- package/dist/managers/credential-manager.d.ts.map +1 -1
- package/dist/managers/credential-manager.js +3 -3
- package/dist/managers/credential-manager.js.map +1 -1
- package/dist/managers/signer-manager.d.ts +10 -4
- package/dist/managers/signer-manager.d.ts.map +1 -1
- package/dist/managers/signer-manager.js +11 -5
- package/dist/managers/signer-manager.js.map +1 -1
- package/dist/managers/submission-manager.d.ts +2 -1
- package/dist/managers/submission-manager.d.ts.map +1 -1
- package/dist/managers/submission-manager.js +2 -2
- package/dist/managers/submission-manager.js.map +1 -1
- package/dist/server.d.ts +7 -5
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -5
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +8 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +4 -8
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -8
- package/dist/utils.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side cryptography for the Secp256r1 signer-binding protocol.
|
|
3
|
+
*
|
|
4
|
+
* Three things live here, all browser-safe (WebCrypto + stellar-sdk hashing,
|
|
5
|
+
* no Node-only modules):
|
|
6
|
+
*
|
|
7
|
+
* 1. **The binding challenge.** `sha256(XDR(Secp256r1BindingPayload))`, where
|
|
8
|
+
* the payload contains the network, wallet, purpose, and complete original
|
|
9
|
+
* signer. GENESIS and ADD use separate domains. The payload is encoded
|
|
10
|
+
* through the contract `Spec` and canonicalized to the host's map order.
|
|
11
|
+
* This is the exact value the wallet contract recomputes.
|
|
12
|
+
*
|
|
13
|
+
* 2. **WebAuthn assertion verification.** For a STORED proof (the contract's
|
|
14
|
+
* 64-byte compact `r||s` signature) and for a FRESH `AuthenticationResponseJSON`
|
|
15
|
+
* (DER signature straight from the authenticator). Checks: clientDataJSON
|
|
16
|
+
* `type`, `challenge`, optional origin allowlist, `rpIdHash`, User Presence,
|
|
17
|
+
* optional User Verification, the credential id where one is available, and
|
|
18
|
+
* the P-256 signature over `authenticatorData || sha256(clientDataJSON)`.
|
|
19
|
+
*
|
|
20
|
+
* 3. **Binding-record verification.** The record's immutable `keyId` and
|
|
21
|
+
* `publicKey` must equal the LIVE signer entry. The proof verifies
|
|
22
|
+
* against the ORIGINAL signer in the record. This permits authorized policy
|
|
23
|
+
* updates without changing the signed deployment or addition consent.
|
|
24
|
+
* The caller must also verify the wallet's accepted birth code. Custom birth
|
|
25
|
+
* code can copy a pending proof before it upgrades to accepted current code.
|
|
26
|
+
*
|
|
27
|
+
* Every verifier returns a result object rather than throwing, so a candidate
|
|
28
|
+
* filter can drop a wallet for a named reason without aborting the whole
|
|
29
|
+
* resolution. Only programmer errors (missing WebCrypto, malformed inputs to the
|
|
30
|
+
* challenge builder) throw.
|
|
31
|
+
*
|
|
32
|
+
* @packageDocumentation
|
|
33
|
+
*/
|
|
34
|
+
import { hash, xdr } from "@stellar/stellar-sdk";
|
|
35
|
+
import base64url from "../base64url.js";
|
|
36
|
+
import { compactSignature } from "../utils.js";
|
|
37
|
+
import { SECP256R1_PUBLIC_KEY_SIZE } from "../constants.js";
|
|
38
|
+
/** First byte of a SEC-1 uncompressed P-256 public key. */
|
|
39
|
+
const SECP256R1_PUBLIC_KEY_PREFIX = 0x04;
|
|
40
|
+
/**
|
|
41
|
+
* Copy bytes into a fresh, non-shared `ArrayBuffer`. WebCrypto's `BufferSource`
|
|
42
|
+
* parameters reject views over a `SharedArrayBuffer` at the type level, and a
|
|
43
|
+
* `Buffer` from the pool may alias a larger allocation, so every input handed
|
|
44
|
+
* to `crypto.subtle` goes through here.
|
|
45
|
+
*/
|
|
46
|
+
function toArrayBuffer(bytes) {
|
|
47
|
+
const copy = new Uint8Array(bytes.byteLength);
|
|
48
|
+
copy.set(bytes);
|
|
49
|
+
return copy.buffer;
|
|
50
|
+
}
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Binding challenge
|
|
53
|
+
// ============================================================================
|
|
54
|
+
/**
|
|
55
|
+
* Fixed domain separators. These values must equal the contract constants.
|
|
56
|
+
*/
|
|
57
|
+
export const SECP256R1_GENESIS_DOMAIN = "secp256r1_genesis_v1";
|
|
58
|
+
export const SECP256R1_ADD_DOMAIN = "secp256r1_add_v1";
|
|
59
|
+
/** The contract spec UDT name of the binding payload struct. */
|
|
60
|
+
export const SECP256R1_BINDING_PAYLOAD_TYPE = "Secp256r1BindingPayload";
|
|
61
|
+
/** Normalize a base64url string or raw bytes to bytes. */
|
|
62
|
+
export function toKeyIdBytes(keyId) {
|
|
63
|
+
return typeof keyId === "string"
|
|
64
|
+
? new Uint8Array(base64url.toBuffer(keyId))
|
|
65
|
+
: keyId;
|
|
66
|
+
}
|
|
67
|
+
function bytesEqual(a, b) {
|
|
68
|
+
if (a.length !== b.length)
|
|
69
|
+
return false;
|
|
70
|
+
let diff = 0;
|
|
71
|
+
for (let i = 0; i < a.length; i++)
|
|
72
|
+
diff |= a[i] ^ b[i];
|
|
73
|
+
return diff === 0;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Canonicalize an `ScVal` map into the host's storage order.
|
|
77
|
+
*
|
|
78
|
+
* The contract hashes `to_xdr(payload)`, and the host serializes a struct as
|
|
79
|
+
* an `ScMap` sorted by key. `Spec.nativeToScVal` emits struct fields in spec
|
|
80
|
+
* declaration order, which for the Rust struct is NOT sorted, so the map is
|
|
81
|
+
* re-sorted here by symbol key (bytewise, the host's order for symbols).
|
|
82
|
+
* Non-map values pass through unchanged.
|
|
83
|
+
*/
|
|
84
|
+
export function canonicalScVal(value) {
|
|
85
|
+
if (value.switch().name === "scvVec") {
|
|
86
|
+
const entries = value.vec();
|
|
87
|
+
return entries
|
|
88
|
+
? xdr.ScVal.scvVec(entries.map((entry) => canonicalScVal(entry)))
|
|
89
|
+
: value;
|
|
90
|
+
}
|
|
91
|
+
if (value.switch().name !== "scvMap")
|
|
92
|
+
return value;
|
|
93
|
+
const entries = value.map();
|
|
94
|
+
if (!entries)
|
|
95
|
+
return value;
|
|
96
|
+
const sorted = entries
|
|
97
|
+
.map((entry) => new xdr.ScMapEntry({
|
|
98
|
+
key: canonicalScVal(entry.key()),
|
|
99
|
+
val: canonicalScVal(entry.val()),
|
|
100
|
+
}))
|
|
101
|
+
.sort((a, b) => compareScValMapKeys(a.key(), b.key()));
|
|
102
|
+
return xdr.ScVal.scvMap(sorted);
|
|
103
|
+
}
|
|
104
|
+
/** Compare map keys as the Soroban host compares them. */
|
|
105
|
+
function compareScValMapKeys(a, b) {
|
|
106
|
+
if (a.switch().name === "scvSymbol" &&
|
|
107
|
+
b.switch().name === "scvSymbol") {
|
|
108
|
+
return Buffer.compare(Buffer.from(a.sym().toString(), "utf8"), Buffer.from(b.sym().toString(), "utf8"));
|
|
109
|
+
}
|
|
110
|
+
// The binding payload only uses fixed-width address keys outside structs.
|
|
111
|
+
// Their XDR byte order matches the host order for address type and payload.
|
|
112
|
+
return Buffer.compare(a.toXDR(), b.toXDR());
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The binding payload as a canonical `ScVal`, encoded through the contract
|
|
116
|
+
* `Spec` so field types are exactly the on-chain ones.
|
|
117
|
+
*/
|
|
118
|
+
export function bindingPayloadScVal(input) {
|
|
119
|
+
if (input.signer.tag !== "Secp256r1") {
|
|
120
|
+
throw new TypeError("binding signer must be Secp256r1");
|
|
121
|
+
}
|
|
122
|
+
const publicKey = input.signer.values[1];
|
|
123
|
+
if (publicKey.length !== SECP256R1_PUBLIC_KEY_SIZE) {
|
|
124
|
+
throw new TypeError(`publicKey must be ${SECP256R1_PUBLIC_KEY_SIZE} bytes (got ${publicKey.length})`);
|
|
125
|
+
}
|
|
126
|
+
const payload = {
|
|
127
|
+
domain: input.purpose === "Genesis"
|
|
128
|
+
? SECP256R1_GENESIS_DOMAIN
|
|
129
|
+
: SECP256R1_ADD_DOMAIN,
|
|
130
|
+
network_id: hash(Buffer.from(input.networkPassphrase)),
|
|
131
|
+
contract: input.contractId,
|
|
132
|
+
purpose: { tag: input.purpose, values: undefined },
|
|
133
|
+
signer: input.signer,
|
|
134
|
+
};
|
|
135
|
+
const scVal = input.spec.nativeToScVal(payload, xdr.ScSpecTypeDef.scSpecTypeUdt(new xdr.ScSpecTypeUdt({ name: SECP256R1_BINDING_PAYLOAD_TYPE })));
|
|
136
|
+
return canonicalScVal(scVal);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The 32-byte binding challenge: `sha256(XDR(payload))`. This is the value a
|
|
140
|
+
* WebAuthn ceremony must carry (base64url-encoded) as its `challenge`.
|
|
141
|
+
*/
|
|
142
|
+
export function bindingChallenge(input) {
|
|
143
|
+
return new Uint8Array(hash(bindingPayloadScVal(input).toXDR()));
|
|
144
|
+
}
|
|
145
|
+
/** The binding challenge as the base64url string WebAuthn puts in clientDataJSON. */
|
|
146
|
+
export function bindingChallengeBase64url(input) {
|
|
147
|
+
return base64url.encode(Buffer.from(bindingChallenge(input)));
|
|
148
|
+
}
|
|
149
|
+
/** WebAuthn authenticatorData layout. */
|
|
150
|
+
const AUTHENTICATOR_DATA_MIN_LEN = 37;
|
|
151
|
+
const RP_ID_HASH_LEN = 32;
|
|
152
|
+
const FLAGS_INDEX = 32;
|
|
153
|
+
const FLAG_USER_PRESENT = 0x01;
|
|
154
|
+
const FLAG_USER_VERIFIED = 0x04;
|
|
155
|
+
const WEBAUTHN_GET = "webauthn.get";
|
|
156
|
+
function fail(reason, detail) {
|
|
157
|
+
return { ok: false, reason, detail };
|
|
158
|
+
}
|
|
159
|
+
function subtle() {
|
|
160
|
+
const subtleCrypto = globalThis.crypto?.subtle;
|
|
161
|
+
if (!subtleCrypto) {
|
|
162
|
+
throw new Error("WebCrypto (crypto.subtle) is not available in this runtime");
|
|
163
|
+
}
|
|
164
|
+
return subtleCrypto;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Verify a P-256 ECDSA signature (compact `r||s`) over
|
|
168
|
+
* `authenticatorData || sha256(clientDataJSON)` — the WebAuthn signed message.
|
|
169
|
+
*/
|
|
170
|
+
async function verifyP256(publicKey, compactSig, authenticatorData, clientDataJSON) {
|
|
171
|
+
if (publicKey.length !== SECP256R1_PUBLIC_KEY_SIZE ||
|
|
172
|
+
publicKey[0] !== SECP256R1_PUBLIC_KEY_PREFIX) {
|
|
173
|
+
return fail("public_key", "public key must be a 65-byte 0x04-prefixed P-256 point");
|
|
174
|
+
}
|
|
175
|
+
if (compactSig.length !== 64) {
|
|
176
|
+
return fail("signature", `compact signature must be 64 bytes (got ${compactSig.length})`);
|
|
177
|
+
}
|
|
178
|
+
let key;
|
|
179
|
+
try {
|
|
180
|
+
key = await subtle().importKey("raw", toArrayBuffer(publicKey), { name: "ECDSA", namedCurve: "P-256" }, false, ["verify"]);
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
return fail("public_key", `public key rejected by WebCrypto: ${String(err)}`);
|
|
184
|
+
}
|
|
185
|
+
const signed = Buffer.concat([
|
|
186
|
+
Buffer.from(authenticatorData),
|
|
187
|
+
hash(Buffer.from(clientDataJSON)),
|
|
188
|
+
]);
|
|
189
|
+
let valid;
|
|
190
|
+
try {
|
|
191
|
+
valid = await subtle().verify({ name: "ECDSA", hash: "SHA-256" }, key, toArrayBuffer(compactSig), toArrayBuffer(signed));
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
return fail("signature", `WebCrypto verify threw: ${String(err)}`);
|
|
195
|
+
}
|
|
196
|
+
return valid ? { ok: true } : fail("signature", "P-256 signature does not verify");
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Verify one WebAuthn assertion with a compact signature against a policy.
|
|
200
|
+
* Every structural check runs before the signature, so a malformed assertion
|
|
201
|
+
* never costs a curve operation.
|
|
202
|
+
*/
|
|
203
|
+
export async function verifyAssertion(proof, policy, presentedKeyId) {
|
|
204
|
+
// Credential id, where the assertion carries one.
|
|
205
|
+
if (policy.expectedKeyId !== undefined && presentedKeyId !== undefined) {
|
|
206
|
+
const expected = base64url.encode(Buffer.from(toKeyIdBytes(policy.expectedKeyId)));
|
|
207
|
+
if (presentedKeyId !== expected) {
|
|
208
|
+
return fail("key_id", "assertion credential id does not match the expected keyId");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// clientDataJSON: type, challenge, origin.
|
|
212
|
+
let clientData;
|
|
213
|
+
try {
|
|
214
|
+
clientData = JSON.parse(Buffer.from(proof.clientDataJSON).toString("utf8"));
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
return fail("client_data", "clientDataJSON is not valid JSON");
|
|
218
|
+
}
|
|
219
|
+
if (typeof clientData !== "object" || clientData === null) {
|
|
220
|
+
return fail("client_data", "clientDataJSON is not an object");
|
|
221
|
+
}
|
|
222
|
+
if (clientData.type !== WEBAUTHN_GET) {
|
|
223
|
+
return fail("type", `clientDataJSON.type must be "${WEBAUTHN_GET}"`);
|
|
224
|
+
}
|
|
225
|
+
const expectedChallenge = base64url.encode(Buffer.from(policy.expectedChallenge));
|
|
226
|
+
if (clientData.challenge !== expectedChallenge) {
|
|
227
|
+
return fail("challenge", "clientDataJSON.challenge does not match the expected challenge");
|
|
228
|
+
}
|
|
229
|
+
if (policy.allowedOrigins && policy.allowedOrigins.length > 0) {
|
|
230
|
+
if (typeof clientData.origin !== "string" ||
|
|
231
|
+
!policy.allowedOrigins.includes(clientData.origin)) {
|
|
232
|
+
return fail("origin", "clientDataJSON.origin is not in the allowed origins");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// authenticatorData: length, rpIdHash, flags.
|
|
236
|
+
const authData = proof.authenticatorData;
|
|
237
|
+
if (authData.length < AUTHENTICATOR_DATA_MIN_LEN) {
|
|
238
|
+
return fail("authenticator_data", "authenticatorData is shorter than 37 bytes");
|
|
239
|
+
}
|
|
240
|
+
const rpIdHash = hash(Buffer.from(policy.rpId));
|
|
241
|
+
if (!bytesEqual(authData.subarray(0, RP_ID_HASH_LEN), new Uint8Array(rpIdHash))) {
|
|
242
|
+
return fail("rp_id", "authenticatorData.rpIdHash does not match the relying party id");
|
|
243
|
+
}
|
|
244
|
+
const flags = authData[FLAGS_INDEX];
|
|
245
|
+
if ((flags & FLAG_USER_PRESENT) === 0) {
|
|
246
|
+
return fail("user_presence", "User Present flag is not set");
|
|
247
|
+
}
|
|
248
|
+
if (policy.requireUserVerification && (flags & FLAG_USER_VERIFIED) === 0) {
|
|
249
|
+
return fail("user_verification", "User Verified flag is not set");
|
|
250
|
+
}
|
|
251
|
+
return verifyP256(policy.publicKey, proof.signature, authData, proof.clientDataJSON);
|
|
252
|
+
}
|
|
253
|
+
/** Verify a STORED binding proof (contract compact signature). */
|
|
254
|
+
export function verifyStoredProof(proof, policy) {
|
|
255
|
+
return verifyAssertion(proof, policy);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Verify a FRESH `AuthenticationResponseJSON` from `startAuthentication`. The
|
|
259
|
+
* DER signature is converted to compact form (with low-S) through the same
|
|
260
|
+
* `compactSignature` the signing pipeline uses, and `response.id` is checked
|
|
261
|
+
* against `policy.expectedKeyId` when that is set.
|
|
262
|
+
*/
|
|
263
|
+
export async function verifyFreshAssertion(response, policy) {
|
|
264
|
+
let signature;
|
|
265
|
+
try {
|
|
266
|
+
signature = compactSignature(base64url.toBuffer(response.response.signature));
|
|
267
|
+
}
|
|
268
|
+
catch (err) {
|
|
269
|
+
return fail("signature", `DER signature is malformed: ${String(err)}`);
|
|
270
|
+
}
|
|
271
|
+
return verifyAssertion({
|
|
272
|
+
authenticatorData: new Uint8Array(base64url.toBuffer(response.response.authenticatorData)),
|
|
273
|
+
clientDataJSON: new Uint8Array(base64url.toBuffer(response.response.clientDataJSON)),
|
|
274
|
+
signature,
|
|
275
|
+
}, policy, response.id);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Verify that `record` binds `liveSigner` to `policy.contractId`.
|
|
279
|
+
*
|
|
280
|
+
* 1. The record's signer keyId and public key equal the live signer.
|
|
281
|
+
* 2. The challenge uses the record's original full signer and purpose.
|
|
282
|
+
* 3. The stored proof must be a valid `webauthn.get` assertion over that
|
|
283
|
+
* challenge under that key, with the rpId/UP/UV/origin policy applied.
|
|
284
|
+
*/
|
|
285
|
+
export async function verifyBindingRecord(record, liveSigner, policy) {
|
|
286
|
+
if (record.signer.tag !== "Secp256r1") {
|
|
287
|
+
return {
|
|
288
|
+
ok: false,
|
|
289
|
+
reason: "signer_kind",
|
|
290
|
+
detail: "binding record does not contain a Secp256r1 signer",
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const [recordKeyId, recordPublicKey] = record.signer.values;
|
|
294
|
+
if (!bytesEqual(recordKeyId, toKeyIdBytes(liveSigner.keyId))) {
|
|
295
|
+
return {
|
|
296
|
+
ok: false,
|
|
297
|
+
reason: "key_id_mismatch",
|
|
298
|
+
detail: "binding record keyId does not equal the live signer keyId",
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
if (!bytesEqual(recordPublicKey, liveSigner.publicKey)) {
|
|
302
|
+
return {
|
|
303
|
+
ok: false,
|
|
304
|
+
reason: "public_key_mismatch",
|
|
305
|
+
detail: "binding record public key does not equal the live signer public key",
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const challenge = bindingChallenge({
|
|
309
|
+
spec: policy.spec,
|
|
310
|
+
networkPassphrase: policy.networkPassphrase,
|
|
311
|
+
contractId: policy.contractId,
|
|
312
|
+
purpose: record.purpose.tag,
|
|
313
|
+
signer: record.signer,
|
|
314
|
+
});
|
|
315
|
+
const result = await verifyStoredProof({
|
|
316
|
+
authenticatorData: record.proof.authenticator_data,
|
|
317
|
+
clientDataJSON: record.proof.client_data_json,
|
|
318
|
+
signature: record.proof.signature,
|
|
319
|
+
}, {
|
|
320
|
+
expectedChallenge: challenge,
|
|
321
|
+
rpId: policy.rpId,
|
|
322
|
+
publicKey: recordPublicKey,
|
|
323
|
+
allowedOrigins: policy.allowedOrigins,
|
|
324
|
+
requireUserVerification: policy.requireUserVerification,
|
|
325
|
+
});
|
|
326
|
+
return result.ok ? { ok: true, challenge } : result;
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=webauthn-verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webauthn-verify.js","sourceRoot":"","sources":["../../src/kit/webauthn-verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAQjD,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,2DAA2D;AAC3D,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEzC;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAiB;IACtC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC;AAED,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD,gEAAgE;AAChE,MAAM,CAAC,MAAM,8BAA8B,GAAG,yBAAyB,CAAC;AAgBxE,0DAA0D;AAC1D,MAAM,UAAU,YAAY,CAAC,KAA0B;IACrD,OAAO,O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AAC,OAAO,CAAC,GAAG;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,iBAAiB,CACpC;QACE,iBAAiB,EAAE,MAAM,CAAC,KAAK,CAAC,kBAAkB;QAClD,cAAc,EAAE,MAAM,CAAC,KAAK,CAAC,gBAAgB;QAC7C,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS;KAClC,EACD;QACE,iBAAiB,EAAE,SAAS;QAC5B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,eAAe;QAC1B,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;KACxD,CACF,CAAC;IAEF,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AACtD,CAAC"}
|
package/dist/kit.d.ts
CHANGED
|
@@ -6,23 +6,25 @@
|
|
|
6
6
|
* pipeline, WebAuthn ceremonies, deploy path, and signer writes now live in
|
|
7
7
|
* dependency-injected managers ({@link CredentialManager}, {@link SignerManager},
|
|
8
8
|
* {@link SubmissionManager}) wired here with late-bound closures. All Protocol-27
|
|
9
|
-
* probe shims
|
|
10
|
-
*
|
|
9
|
+
* probe shims and dead commented experiments are gone. The kit targets
|
|
10
|
+
* stellar-sdk >= 16 and the current wallet.
|
|
11
11
|
*
|
|
12
12
|
* @packageDocumentation
|
|
13
13
|
*/
|
|
14
|
-
import { xdr } from "@stellar/stellar-sdk";
|
|
14
|
+
import { Horizon, xdr } from "@stellar/stellar-sdk";
|
|
15
15
|
import { Server } from "@stellar/stellar-sdk/rpc";
|
|
16
16
|
import { type AuthenticatorSelectionCriteria } from "@simplewebauthn/browser";
|
|
17
17
|
import type { AssembledTransaction } from "@stellar/stellar-sdk/contract";
|
|
18
|
-
import { Client as PasskeyClient } from "passkey-kit-sdk";
|
|
18
|
+
import { Client as PasskeyClient, type SignerVal } from "passkey-kit-sdk";
|
|
19
19
|
import { SignerKey, SignerStore, type ConnectWalletResult, type CreateWalletResult, type SignerLimits, type StorageAdapter } from "./types.js";
|
|
20
20
|
import { PasskeyEventEmitter } from "./events.js";
|
|
21
21
|
import { type Signer } from "./signers.js";
|
|
22
22
|
import type { WebAuthnClient } from "./kit/webauthn-ops.js";
|
|
23
23
|
import type { CreatedPasskey } from "./kit/webauthn-ops.js";
|
|
24
24
|
import type { SignOptions } from "./kit/tx-ops.js";
|
|
25
|
-
import type
|
|
25
|
+
import { type PolicySignerTxOptions, type WalletTx } from "./kit/wallet-ops.js";
|
|
26
|
+
import type { WalletCandidateLookup } from "./indexer/types.js";
|
|
27
|
+
import { type VerifiedWalletBirth } from "./kit/birth-verification.js";
|
|
26
28
|
/** Configuration for a {@link PasskeyKit} client. */
|
|
27
29
|
export interface PasskeyKitConfig {
|
|
28
30
|
/** Stellar RPC URL. */
|
|
@@ -32,23 +34,31 @@ export interface PasskeyKitConfig {
|
|
|
32
34
|
/** Smart-wallet WASM hash (hex) used to deploy new wallets. */
|
|
33
35
|
walletWasmHash: string;
|
|
34
36
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* derivation. Defaults to `[walletWasmHash]`.
|
|
38
|
-
*
|
|
39
|
-
* Binding code identity is what makes a wallet's signer state meaningful: under
|
|
40
|
-
* accepted code, a signer entry can only have been produced by logic that
|
|
41
|
-
* required wallet authorization. Arbitrary code can write whatever signer entry
|
|
42
|
-
* a client expects, so without this check a reverse lookup proves nothing.
|
|
37
|
+
* Current code identities accepted during every wallet connection.
|
|
38
|
+
* Defaults to `[walletWasmHash]`.
|
|
43
39
|
*
|
|
44
40
|
* This is a list rather than a single value because a legitimately upgraded
|
|
45
|
-
* wallet runs different code. Add each accepted hash
|
|
46
|
-
*
|
|
47
|
-
* path. See `docs/security-deterministic-deployer.md`.
|
|
41
|
+
* wallet runs different code. Add each accepted hash during an upgrade.
|
|
42
|
+
* See `docs/security-deterministic-deployer.md`.
|
|
48
43
|
*/
|
|
49
44
|
acceptedWasmHashes?: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Immutable birth WASM hashes accepted during wallet discovery.
|
|
47
|
+
* Defaults to `[walletWasmHash]`. This list is separate from current code
|
|
48
|
+
* identities because a valid wallet can upgrade after its secure birth.
|
|
49
|
+
*/
|
|
50
|
+
acceptedBirthWasmHashes?: string[];
|
|
51
|
+
/**
|
|
52
|
+
* Full-history Horizon URL for creation transactions outside RPC retention.
|
|
53
|
+
* Public and test networks use the official Horizon endpoints by default.
|
|
54
|
+
*/
|
|
55
|
+
horizonUrl?: string;
|
|
50
56
|
/** WebAuthn Relying Party id (domain); defaults to the current origin. */
|
|
51
57
|
rpId?: string;
|
|
58
|
+
/** Accepted WebAuthn origins. Defaults to the browser origin. Required outside a browser. */
|
|
59
|
+
allowedOrigins?: readonly string[];
|
|
60
|
+
/** Require the WebAuthn User Verified flag. User Presence is always required. */
|
|
61
|
+
requireUserVerification?: boolean;
|
|
52
62
|
/**
|
|
53
63
|
* Secret key (`S…`) for the address-derivation deployer. Defaults to the
|
|
54
64
|
* canonical shared sign-only deployer (see {@link resolveDeployer});
|
|
@@ -70,23 +80,13 @@ export interface CreateOptions {
|
|
|
70
80
|
}
|
|
71
81
|
/** Options for {@link PasskeyKit.connectWallet}. */
|
|
72
82
|
export interface ConnectOptions {
|
|
73
|
-
/** A specific keyId to connect
|
|
83
|
+
/** A specific keyId to connect. Untrusted discovery still requires a proof ceremony. */
|
|
74
84
|
keyId?: string | Uint8Array;
|
|
75
|
-
/** Indexer-backed keyId → contract lookup, used when derivation misses. */
|
|
76
|
-
getContractId?: (keyId: string) => Promise<string | undefined>;
|
|
77
85
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* Defaults to ON whenever the address was resolved from an untrusted source
|
|
81
|
-
* (indexer lookup or derivation) and OFF when it came from trusted local
|
|
82
|
-
* storage, where a legitimately upgraded wallet would otherwise be locked out.
|
|
83
|
-
*
|
|
84
|
-
* Set `true` to check even a storage-resolved address; set `false` to skip the
|
|
85
|
-
* check entirely. Disabling it means a reverse lookup can resolve to a contract
|
|
86
|
-
* that merely claims this credential — only do so if you bind code identity
|
|
87
|
-
* yourself.
|
|
86
|
+
* Complete indexer-backed keyId lookup with immutable birth claims.
|
|
87
|
+
* The kit verifies every claim through Stellar RPC before use.
|
|
88
88
|
*/
|
|
89
|
-
|
|
89
|
+
getWalletCandidates?: (keyId: string) => Promise<WalletCandidateLookup>;
|
|
90
90
|
}
|
|
91
91
|
export declare class PasskeyKit {
|
|
92
92
|
readonly rpc: Server;
|
|
@@ -95,11 +95,17 @@ export declare class PasskeyKit {
|
|
|
95
95
|
readonly walletWasmHash: string;
|
|
96
96
|
/** Accepted code identities, lowercase hex. Never empty. */
|
|
97
97
|
readonly acceptedWasmHashes: readonly string[];
|
|
98
|
+
/** Accepted immutable birth code identities, lowercase hex. Never empty. */
|
|
99
|
+
readonly acceptedBirthWasmHashes: readonly string[];
|
|
100
|
+
/** Full-history source for immutable wallet-birth verification. */
|
|
101
|
+
readonly history?: Horizon.Server;
|
|
98
102
|
readonly rpId?: string;
|
|
99
103
|
/** Lifecycle event emitter (walletCreated, walletConnected, …). */
|
|
100
104
|
readonly events: PasskeyEventEmitter;
|
|
101
105
|
private readonly timeoutInSeconds;
|
|
102
106
|
private readonly webAuthn;
|
|
107
|
+
private readonly allowedOrigins?;
|
|
108
|
+
private readonly requireUserVerification;
|
|
103
109
|
private readonly credentialManager;
|
|
104
110
|
private readonly signerManager;
|
|
105
111
|
private readonly submissionManager;
|
|
@@ -121,20 +127,31 @@ export declare class PasskeyKit {
|
|
|
121
127
|
* submission and calls `connectWallet`.
|
|
122
128
|
*/
|
|
123
129
|
createWallet(appName: string, userName: string, options?: CreateOptions): Promise<CreateWalletResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Verify a successful wallet deployment and persist its immutable birth data.
|
|
132
|
+
* Call this only after the relayer returns a successful transaction hash.
|
|
133
|
+
*/
|
|
134
|
+
confirmWalletCreation(created: CreateWalletResult, creationTransactionHash: string): Promise<VerifiedWalletBirth>;
|
|
124
135
|
/**
|
|
125
136
|
* Connect an existing wallet from a passkey.
|
|
126
137
|
*
|
|
127
|
-
* Resolves
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* Derivation is deliberately last: it is only correct for a wallet's first
|
|
132
|
-
* credential and is the one path a squatted contract can hijack.
|
|
138
|
+
* Resolves wallet candidates from verified local storage or one complete
|
|
139
|
+
* indexer response. Every candidate must prove its immutable birth, current
|
|
140
|
+
* code, signer binding, and fresh passkey possession. The method connects
|
|
141
|
+
* only when one candidate passes every check.
|
|
133
142
|
*
|
|
134
143
|
* @throws {WalletOwnershipError} If the keyId is not a signer on the wallet.
|
|
135
144
|
*/
|
|
136
145
|
connectWallet(options?: ConnectOptions): Promise<ConnectWalletResult>;
|
|
137
146
|
private assertWalletWasmHash;
|
|
147
|
+
private contractWasmHash;
|
|
148
|
+
/** Create the address-bound proof required for a Secp256r1 signer write. */
|
|
149
|
+
private createBindingProof;
|
|
150
|
+
/** Verify stored address consent and fresh passkey possession. */
|
|
151
|
+
private assertSignerProvenance;
|
|
152
|
+
/** Verify one fresh WebAuthn assertion against the live signer key. */
|
|
153
|
+
private assertFreshAssertion;
|
|
154
|
+
private assertWebAuthnVerificationConfig;
|
|
138
155
|
/** Disconnect the current wallet. */
|
|
139
156
|
disconnect(): void;
|
|
140
157
|
/** Sign a single auth entry (defaults to the connected passkey signer). */
|
|
@@ -149,13 +166,18 @@ export declare class PasskeyKit {
|
|
|
149
166
|
updateSecp256r1(keyId: string | Uint8Array, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
|
|
150
167
|
addEd25519(publicKey: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
|
|
151
168
|
updateEd25519(publicKey: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
|
|
152
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Add a policy signer. Throws a `ValidationError` if the policy's `install`
|
|
171
|
+
* hook adds wallet-authorized sub-invocations to the auth entry, unless
|
|
172
|
+
* `options.allowInstallSubInvocations` is set.
|
|
173
|
+
*/
|
|
174
|
+
addPolicy(policy: string, limits: SignerLimits, store: SignerStore, expiration?: number, options?: PolicySignerTxOptions): Promise<WalletTx>;
|
|
153
175
|
updatePolicy(policy: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<WalletTx>;
|
|
154
176
|
remove(signerKey: SignerKey): Promise<WalletTx>;
|
|
155
177
|
/** Build an `upgrade(new_wasm_hash)` transaction for the connected wallet. */
|
|
156
178
|
upgrade(newWasmHash: Buffer | Uint8Array): Promise<WalletTx>;
|
|
157
179
|
/** Read a signer entry from the ledger (temporary before persistent). */
|
|
158
|
-
getSigner(signerKey: SignerKey): Promise<
|
|
180
|
+
getSigner(signerKey: SignerKey): Promise<SignerVal | null>;
|
|
159
181
|
/** Require a connected wallet, or throw. */
|
|
160
182
|
requireWallet(): PasskeyClient;
|
|
161
183
|
}
|
package/dist/kit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../src/kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../src/kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAqB,GAAG,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAO,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAIL,KAAK,8BAA8B,EACpC,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,MAAM,IAA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