@spacelr/sdk 0.13.0 → 0.14.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.mjs CHANGED
@@ -2289,6 +2289,53 @@ var AuthModule = class _AuthModule {
2289
2289
  });
2290
2290
  this.emitState("authenticated");
2291
2291
  }
2292
+ // ─── Recover-with-phrase (#784) ───
2293
+ // For an email-less passkey account (#780) that has lost every passkey. The
2294
+ // caller derives an opaque 32-byte base64url secret from a BIP39 phrase and
2295
+ // passes it here — the SDK is transport-only and never sees or generates the
2296
+ // phrase (no wordlist in the bundle).
2297
+ /**
2298
+ * Bind (or rotate) a recovery secret to the signed-in account, so it can be
2299
+ * redeemed later if every passkey is lost. Authenticated — the server rejects
2300
+ * a stale session (fresh-auth), so call this shortly after login/signup. Only
2301
+ * email-less accounts may bind. `secret` is a 43-char base64url string.
2302
+ */
2303
+ async bindRecoveryPhrase(secret) {
2304
+ return this.http.request({
2305
+ method: "POST",
2306
+ path: "/auth/recovery/bind",
2307
+ body: { secret },
2308
+ authenticated: true
2309
+ });
2310
+ }
2311
+ /**
2312
+ * Redeem a recovery secret to restore access to the SAME account without a
2313
+ * passkey/email/password. UNAUTHENTICATED (the caller has no session yet).
2314
+ * Single-use: after a successful redeem the client should bind a fresh phrase
2315
+ * and add a new passkey. Installs the returned tokens into the SDK session,
2316
+ * exactly like a passkey login.
2317
+ */
2318
+ async redeemRecoveryPhrase(secret) {
2319
+ const result = await this.http.request({
2320
+ method: "POST",
2321
+ path: "/auth/recovery/redeem",
2322
+ body: { secret }
2323
+ });
2324
+ await this.storeTokensFromLogin(result);
2325
+ return result;
2326
+ }
2327
+ /**
2328
+ * Whether the signed-in account has an active recovery binding, and when it
2329
+ * was last bound/rotated — so the app can prompt the user to set or refresh
2330
+ * their recovery phrase. Authenticated.
2331
+ */
2332
+ async getRecoveryStatus() {
2333
+ return this.http.request({
2334
+ method: "GET",
2335
+ path: "/auth/recovery/status",
2336
+ authenticated: true
2337
+ });
2338
+ }
2292
2339
  async storeTokensFromRegister(response) {
2293
2340
  if (!response.access_token) return;
2294
2341
  const expiresAt = response.expires_in ? Math.floor(Date.now() / 1e3) + response.expires_in : void 0;