decane-connect-kit 2.7.1 → 2.7.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.js CHANGED
@@ -2400,7 +2400,12 @@ var TeeClient = class {
2400
2400
  headers: { Authorization: `Bearer ${jwt}`, "Content-Type": "application/json" },
2401
2401
  body: JSON.stringify({ share: bytesToBase64(recoveryShare) })
2402
2402
  });
2403
- if (!res.ok) throw new Error("auth share enrolment failed");
2403
+ if (!res.ok) {
2404
+ const detail = await res.text().catch(() => "");
2405
+ throw new Error(
2406
+ `auth share enrolment failed (HTTP ${res.status})${detail ? `: ${detail.slice(0, 200)}` : ""}`
2407
+ );
2408
+ }
2404
2409
  }
2405
2410
  /**
2406
2411
  * Ask the enclave for a fresh device share for this authenticated user.
@@ -2418,7 +2423,12 @@ var TeeClient = class {
2418
2423
  headers: { Authorization: `Bearer ${jwt}`, "Content-Type": "application/json" }
2419
2424
  });
2420
2425
  if (res.status === 409) return null;
2421
- if (!res.ok) throw new Error("device share provisioning failed");
2426
+ if (!res.ok) {
2427
+ const detail = await res.text().catch(() => "");
2428
+ throw new Error(
2429
+ `device share provisioning failed (HTTP ${res.status})${detail ? `: ${detail.slice(0, 200)}` : ""}`
2430
+ );
2431
+ }
2422
2432
  const body = await res.json();
2423
2433
  return base64ToBytes(body.deviceShare);
2424
2434
  }
@@ -3621,6 +3631,22 @@ async function createDecaneConnect(config) {
3621
3631
  addresses.evm = evmAddress = confirmed.evm;
3622
3632
  addresses.solana = solanaAddress = confirmed.solana;
3623
3633
  addresses.tron = tronAddress = confirmed.tron ?? evmToTronAddress2(confirmed.evm);
3634
+ if (serverAssistedRecovery) {
3635
+ for (let attempt = 1; attempt <= 2; attempt++) {
3636
+ try {
3637
+ const tee = new TeeClient(teeUrl);
3638
+ await tee.enrolAuthShare(jwt, shareSet.recovery);
3639
+ break;
3640
+ } catch (e) {
3641
+ if (attempt === 2) {
3642
+ console.warn(
3643
+ "decane-connect-kit: could not enrol this wallet for server-assisted recovery; a recovery file will be required on a new device. This wallet will get a 409 not_enrolled from /signer/provision until it is re-enrolled.",
3644
+ e
3645
+ );
3646
+ }
3647
+ }
3648
+ }
3649
+ }
3624
3650
  if (config.offerRecoveryAtSignup !== false && config.onRecoveryShareOffer) {
3625
3651
  try {
3626
3652
  const choice = await config.onRecoveryShareOffer({ evmAddress, solanaAddress });
@@ -3639,17 +3665,6 @@ async function createDecaneConnect(config) {
3639
3665
  console.warn("decane-connect-kit: recovery share offer failed or was skipped.", e);
3640
3666
  }
3641
3667
  }
3642
- if (serverAssistedRecovery) {
3643
- try {
3644
- const tee = new TeeClient(teeUrl);
3645
- await tee.enrolAuthShare(jwt, shareSet.recovery);
3646
- } catch (e) {
3647
- console.warn(
3648
- "decane-connect-kit: could not enrol this wallet for server-assisted recovery; a recovery file will be required on a new device.",
3649
- e
3650
- );
3651
- }
3652
- }
3653
3668
  zeroize(shareSet.recovery);
3654
3669
  return addresses;
3655
3670
  }
@@ -3675,6 +3690,9 @@ async function createDecaneConnect(config) {
3675
3690
  }
3676
3691
  return addrs;
3677
3692
  }
3693
+ console.warn(
3694
+ "decane-connect-kit: this wallet is not enrolled for server-assisted provisioning (/signer/provision returned 409 not_enrolled), so a device share cannot be issued from the JWT alone. Falling back to passkey sync, then the recovery file."
3695
+ );
3678
3696
  } catch (e) {
3679
3697
  console.warn(
3680
3698
  "decane-connect-kit: server-assisted provisioning unavailable; falling back to passkey/recovery-file recovery.",