@waaskey/sdk 0.4.0 → 0.4.2
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/dist/index.cjs +53 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +53 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -486,6 +486,54 @@ var Onramp = class {
|
|
|
486
486
|
}
|
|
487
487
|
};
|
|
488
488
|
|
|
489
|
+
// src/passkey/assertion.ts
|
|
490
|
+
function isPasskeyAssertionSupported() {
|
|
491
|
+
return typeof globalThis.navigator !== "undefined" && typeof globalThis.navigator.credentials !== "undefined";
|
|
492
|
+
}
|
|
493
|
+
async function defaultAssertionCeremony() {
|
|
494
|
+
let mod;
|
|
495
|
+
try {
|
|
496
|
+
mod = await import('@simplewebauthn/browser');
|
|
497
|
+
} catch {
|
|
498
|
+
throw new WaaskeyError('Passkey step-up requires "@simplewebauthn/browser" installed, or pass a custom ceremony.', "unsupported");
|
|
499
|
+
}
|
|
500
|
+
return {
|
|
501
|
+
get: (options) => mod.startAuthentication({ optionsJSON: options })
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
async function getSigningAssertion(challenge, options = {}) {
|
|
505
|
+
if (options.ceremony === void 0 && !isPasskeyAssertionSupported()) {
|
|
506
|
+
throw new WaaskeyError("Passkey step-up is not available in this runtime (no WebAuthn API).", "unsupported");
|
|
507
|
+
}
|
|
508
|
+
const ceremony = options.ceremony ?? await defaultAssertionCeremony();
|
|
509
|
+
const rpId = options.rpId ?? (typeof location === "undefined" ? void 0 : location.hostname);
|
|
510
|
+
const requestOptions = {
|
|
511
|
+
challenge,
|
|
512
|
+
userVerification: "required",
|
|
513
|
+
...rpId ? { rpId } : {},
|
|
514
|
+
...options.credentialId ? { allowCredentials: [{ id: options.credentialId, type: "public-key" }] } : {}
|
|
515
|
+
};
|
|
516
|
+
try {
|
|
517
|
+
return await ceremony.get(requestOptions);
|
|
518
|
+
} catch (cause) {
|
|
519
|
+
if (cause instanceof WaaskeyError) throw cause;
|
|
520
|
+
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
521
|
+
if (/cancel|abort|not allowed|user gesture/i.test(msg)) {
|
|
522
|
+
throw new WaaskeyError("Passkey authentication was cancelled by the user.", "aborted", { cause });
|
|
523
|
+
}
|
|
524
|
+
throw new WaaskeyError("Passkey step-up assertion failed.", "unsupported", { cause });
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// src/passkey/recovery-factor.ts
|
|
529
|
+
function passkeyFactorEnrollment(credentialId) {
|
|
530
|
+
return { type: "passkey", credential: credentialId };
|
|
531
|
+
}
|
|
532
|
+
async function passkeyFactorVerification(challenge, options = {}) {
|
|
533
|
+
const assertion = await getSigningAssertion(challenge, options);
|
|
534
|
+
return { type: "passkey", token: JSON.stringify(assertion) };
|
|
535
|
+
}
|
|
536
|
+
|
|
489
537
|
// src/storage/crypto.ts
|
|
490
538
|
var PBKDF2_ITERATIONS = 21e4;
|
|
491
539
|
var PBKDF2_HASH = "SHA-256";
|
|
@@ -687,8 +735,12 @@ var Recovery = class {
|
|
|
687
735
|
async function buildRecoveryRegistration(params) {
|
|
688
736
|
const recoveryCode = params.recoveryCode ?? generateRecoveryCode();
|
|
689
737
|
const backup = params.passkey ? await sealRecoveryBackup(params.share, recoveryCode, params.passkey) : { ciphertext: await sealWithPassword(recoveryCode, params.share), keyWraps: void 0 };
|
|
738
|
+
if (params.passkeyFactor && !params.passkey) {
|
|
739
|
+
throw new WaaskeyError("passkeyFactor requires `passkey` \u2014 a factor for a credential this backup cannot open would be a lock-out.", "validation");
|
|
740
|
+
}
|
|
741
|
+
const strongFactor = params.passkeyFactor ? passkeyFactorEnrollment(params.passkey.credentialId) : { type: "recovery_code", credential: await sha256Hex(recoveryCode) };
|
|
690
742
|
const factors = [
|
|
691
|
-
|
|
743
|
+
strongFactor,
|
|
692
744
|
{ type: "totp", credential: params.totpSecret },
|
|
693
745
|
{ type: "email_otp", credential: params.email },
|
|
694
746
|
...params.extraFactors ?? []
|
|
@@ -1171,45 +1223,6 @@ function deserializeShare(blob) {
|
|
|
1171
1223
|
};
|
|
1172
1224
|
}
|
|
1173
1225
|
|
|
1174
|
-
// src/passkey/assertion.ts
|
|
1175
|
-
function isPasskeyAssertionSupported() {
|
|
1176
|
-
return typeof globalThis.navigator !== "undefined" && typeof globalThis.navigator.credentials !== "undefined";
|
|
1177
|
-
}
|
|
1178
|
-
async function defaultAssertionCeremony() {
|
|
1179
|
-
let mod;
|
|
1180
|
-
try {
|
|
1181
|
-
mod = await import('@simplewebauthn/browser');
|
|
1182
|
-
} catch {
|
|
1183
|
-
throw new WaaskeyError('Passkey step-up requires "@simplewebauthn/browser" installed, or pass a custom ceremony.', "unsupported");
|
|
1184
|
-
}
|
|
1185
|
-
return {
|
|
1186
|
-
get: (options) => mod.startAuthentication({ optionsJSON: options })
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
|
-
async function getSigningAssertion(challenge, options = {}) {
|
|
1190
|
-
if (options.ceremony === void 0 && !isPasskeyAssertionSupported()) {
|
|
1191
|
-
throw new WaaskeyError("Passkey step-up is not available in this runtime (no WebAuthn API).", "unsupported");
|
|
1192
|
-
}
|
|
1193
|
-
const ceremony = options.ceremony ?? await defaultAssertionCeremony();
|
|
1194
|
-
const rpId = options.rpId ?? (typeof location === "undefined" ? void 0 : location.hostname);
|
|
1195
|
-
const requestOptions = {
|
|
1196
|
-
challenge,
|
|
1197
|
-
userVerification: "required",
|
|
1198
|
-
...rpId ? { rpId } : {},
|
|
1199
|
-
...options.credentialId ? { allowCredentials: [{ id: options.credentialId, type: "public-key" }] } : {}
|
|
1200
|
-
};
|
|
1201
|
-
try {
|
|
1202
|
-
return await ceremony.get(requestOptions);
|
|
1203
|
-
} catch (cause) {
|
|
1204
|
-
if (cause instanceof WaaskeyError) throw cause;
|
|
1205
|
-
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
1206
|
-
if (/cancel|abort|not allowed|user gesture/i.test(msg)) {
|
|
1207
|
-
throw new WaaskeyError("Passkey authentication was cancelled by the user.", "aborted", { cause });
|
|
1208
|
-
}
|
|
1209
|
-
throw new WaaskeyError("Passkey step-up assertion failed.", "unsupported", { cause });
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
1226
|
// src/wallet.ts
|
|
1214
1227
|
var DEVICE_ROLE = "device";
|
|
1215
1228
|
var Wallet = class {
|
|
@@ -2361,15 +2374,6 @@ function resolveSink(analytics, http) {
|
|
|
2361
2374
|
return analytics ?? new HttpAnalyticsSink(http);
|
|
2362
2375
|
}
|
|
2363
2376
|
|
|
2364
|
-
// src/passkey/recovery-factor.ts
|
|
2365
|
-
function passkeyFactorEnrollment(credentialId) {
|
|
2366
|
-
return { type: "passkey", credential: credentialId };
|
|
2367
|
-
}
|
|
2368
|
-
async function passkeyFactorVerification(challenge, options = {}) {
|
|
2369
|
-
const assertion = await getSigningAssertion(challenge, options);
|
|
2370
|
-
return { type: "passkey", token: JSON.stringify(assertion) };
|
|
2371
|
-
}
|
|
2372
|
-
|
|
2373
2377
|
// src/mpc/wasm-core.ts
|
|
2374
2378
|
var WasmMpcCore = class {
|
|
2375
2379
|
constructor(load) {
|