decane-connect-kit 2.15.0 → 2.16.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/dist/index.js CHANGED
@@ -3783,8 +3783,19 @@ async function createDecaneConnect(config) {
3783
3783
  rpName,
3784
3784
  prfSalt
3785
3785
  });
3786
- if (!prfOutput) throw new WebAuthnNotSupportedError();
3787
- const wrappingKey = await importAesKey(prfOutput);
3786
+ let key = prfOutput;
3787
+ if (!key) {
3788
+ try {
3789
+ key = await getPrfOutput({ rpId, credentialId, prfSalt });
3790
+ } catch (e) {
3791
+ console.warn(
3792
+ "decane-connect-kit: the new credential did not return a PRF output; it cannot wrap the share.",
3793
+ e
3794
+ );
3795
+ }
3796
+ }
3797
+ if (!key) throw new WebAuthnNotSupportedError();
3798
+ const wrappingKey = await importAesKey(key);
3788
3799
  const iv = generateRandomBytes(12);
3789
3800
  const wrappedDeviceShare = await aesGcmEncrypt(wrappingKey, deviceShare, iv);
3790
3801
  const existing = await storage.getShare(userId);
@@ -4495,8 +4506,19 @@ async function createDecaneConnect(config) {
4495
4506
  if (!auth) throw new ReconnectRequiredError();
4496
4507
  if (!isPasskeySupported()) throw new WebAuthnNotSupportedError();
4497
4508
  const stored = await storage.getShare(auth.userId);
4498
- if (!stored) throw new NewDeviceError();
4499
- if (stored.unlockMethod === "passkey") return;
4509
+ if (stored?.unlockMethod === "passkey") return;
4510
+ if (!stored) {
4511
+ if (!serverAssistedRecovery) throw new NewDeviceError();
4512
+ const tee = new TeeClient(teeUrl);
4513
+ const provisioned = await tee.provisionDeviceShare(auth.jwt);
4514
+ if (!provisioned) throw new NewDeviceError();
4515
+ try {
4516
+ await registerPasskeyForDevice(auth.userId, auth.jwt, provisioned);
4517
+ } finally {
4518
+ zeroize(provisioned);
4519
+ }
4520
+ return;
4521
+ }
4500
4522
  let deviceShare;
4501
4523
  try {
4502
4524
  deviceShare = await aesGcmDecrypt(