@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.d.mts CHANGED
@@ -268,6 +268,31 @@ interface PasskeySignupResponse {
268
268
  refresh_token?: string;
269
269
  expires_in?: number;
270
270
  }
271
+ /**
272
+ * Response returned by redeeming a recovery phrase (#784). A recovery account is
273
+ * email-less by construction, so `email` is null — same shape as
274
+ * {@link PasskeyLoginResponse}, kept as a distinct name for clarity. Redeeming
275
+ * installs the returned tokens into the SDK session, exactly like a passkey login.
276
+ */
277
+ interface RecoveryRedeemResponse {
278
+ user: {
279
+ id: string;
280
+ email: string | null;
281
+ roles: string[];
282
+ };
283
+ access_token: string;
284
+ refresh_token?: string;
285
+ expires_in?: number;
286
+ }
287
+ /**
288
+ * Whether the signed-in account has an active recovery-phrase binding (#784),
289
+ * and when it was last bound or rotated. Used to prompt the user to set or
290
+ * refresh their recovery phrase.
291
+ */
292
+ interface RecoveryStatusResponse {
293
+ hasBinding: boolean;
294
+ boundAt?: string;
295
+ }
271
296
  /** Result of verifying a passkey registration attestation. */
272
297
  interface PasskeyRegistrationResult {
273
298
  verified: boolean;
@@ -1147,6 +1172,29 @@ declare class AuthModule {
1147
1172
  deleted: true;
1148
1173
  }>;
1149
1174
  private storeTokensFromLogin;
1175
+ /**
1176
+ * Bind (or rotate) a recovery secret to the signed-in account, so it can be
1177
+ * redeemed later if every passkey is lost. Authenticated — the server rejects
1178
+ * a stale session (fresh-auth), so call this shortly after login/signup. Only
1179
+ * email-less accounts may bind. `secret` is a 43-char base64url string.
1180
+ */
1181
+ bindRecoveryPhrase(secret: string): Promise<{
1182
+ bound: true;
1183
+ }>;
1184
+ /**
1185
+ * Redeem a recovery secret to restore access to the SAME account without a
1186
+ * passkey/email/password. UNAUTHENTICATED (the caller has no session yet).
1187
+ * Single-use: after a successful redeem the client should bind a fresh phrase
1188
+ * and add a new passkey. Installs the returned tokens into the SDK session,
1189
+ * exactly like a passkey login.
1190
+ */
1191
+ redeemRecoveryPhrase(secret: string): Promise<RecoveryRedeemResponse>;
1192
+ /**
1193
+ * Whether the signed-in account has an active recovery binding, and when it
1194
+ * was last bound/rotated — so the app can prompt the user to set or refresh
1195
+ * their recovery phrase. Authenticated.
1196
+ */
1197
+ getRecoveryStatus(): Promise<RecoveryStatusResponse>;
1150
1198
  private storeTokensFromRegister;
1151
1199
  }
1152
1200
 
@@ -2175,4 +2223,4 @@ interface SpacelrClient {
2175
2223
  }
2176
2224
  declare function createClient(config: SpacelrClientConfig): SpacelrClient;
2177
2225
 
2178
- export { type ApiResponse, type AuthLostReason, type AuthState, type AuthStateListener, type AuthorizationUrlParams, BrowserTokenStorage, CONSUMER_ID_STORAGE_KEY, CodeChallengeMethod, type ConnectionState, CursorInvalidError, type CursorStorage, type DatabaseChangeEvent, type DownloadUrlResponse, type ExchangeCodeParams, type FileInfo, type FileListResponse, FileVisibility, ForbiddenError, type FunctionInvokeOptions, type FunctionInvokeResult, type GapReason, GrantType, type InitMultipartUploadParams, type InitMultipartUploadResponse, type JWK, type JWKSResponse, type ListFilesParams, type LoginParams, type LoginResponse, MemoryTokenStorage, NotFoundError, type OpenIDConfiguration, type PKCEChallenge, type PartEtag, type PasskeyAuthenticationOptionsJSON, type PasskeyAuthenticationResponseJSON, type PasskeyCredential, type PasskeyCredentialDescriptorJSON, type PasskeyLoginResponse, type PasskeyRegistrationOptionsJSON, type PasskeyRegistrationResponseJSON, type PasskeyRegistrationResult, type PushSubscriptionInfo, type QuotaInfo, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrScanLimitExceededError, SpacelrSearchFilterRequiredError, SpacelrTimeoutError, SpacelrTwoFactorRequiredError, type StoredTokens, type StreamGapInfo, type StreamSubscription, type SubscribeEventsHandlers, type SubscribeHandlers, type SubscribeWithSnapshotOptions, type TimelineAndFilter, TimelineError, type TimelineFieldFilter, type TimelineFilter, type TimelineLeafFilter, TimelineModule, type TimelineOrderBy, type TimelineQueryOptions, type TimelineQueryResponse, type TimelineScalar, type TimelineSourceStats, TimeoutError, type TokenResponse, type TokenStorage, type TwoFactorResponse, type TwoFactorVerifyParams, type UnshareFileParams, type UploadFileParams, type UploadLargeFileParams, type UploadProgress, type UserInfo, type UserProfile, ValidationError, type VapidKeyResponse, type WhereFilter, type WhereOperator, type WhereScalar, type WhereValue, createClient, generatePKCEChallenge, localStorageCursorStorage, memoryCursorStorage, resolveConsumerId };
2226
+ export { type ApiResponse, type AuthLostReason, type AuthState, type AuthStateListener, type AuthorizationUrlParams, BrowserTokenStorage, CONSUMER_ID_STORAGE_KEY, CodeChallengeMethod, type ConnectionState, CursorInvalidError, type CursorStorage, type DatabaseChangeEvent, type DownloadUrlResponse, type ExchangeCodeParams, type FileInfo, type FileListResponse, FileVisibility, ForbiddenError, type FunctionInvokeOptions, type FunctionInvokeResult, type GapReason, GrantType, type InitMultipartUploadParams, type InitMultipartUploadResponse, type JWK, type JWKSResponse, type ListFilesParams, type LoginParams, type LoginResponse, MemoryTokenStorage, NotFoundError, type OpenIDConfiguration, type PKCEChallenge, type PartEtag, type PasskeyAuthenticationOptionsJSON, type PasskeyAuthenticationResponseJSON, type PasskeyCredential, type PasskeyCredentialDescriptorJSON, type PasskeyLoginResponse, type PasskeyRegistrationOptionsJSON, type PasskeyRegistrationResponseJSON, type PasskeyRegistrationResult, type PushSubscriptionInfo, type QuotaInfo, type RecoveryRedeemResponse, type RecoveryStatusResponse, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrScanLimitExceededError, SpacelrSearchFilterRequiredError, SpacelrTimeoutError, SpacelrTwoFactorRequiredError, type StoredTokens, type StreamGapInfo, type StreamSubscription, type SubscribeEventsHandlers, type SubscribeHandlers, type SubscribeWithSnapshotOptions, type TimelineAndFilter, TimelineError, type TimelineFieldFilter, type TimelineFilter, type TimelineLeafFilter, TimelineModule, type TimelineOrderBy, type TimelineQueryOptions, type TimelineQueryResponse, type TimelineScalar, type TimelineSourceStats, TimeoutError, type TokenResponse, type TokenStorage, type TwoFactorResponse, type TwoFactorVerifyParams, type UnshareFileParams, type UploadFileParams, type UploadLargeFileParams, type UploadProgress, type UserInfo, type UserProfile, ValidationError, type VapidKeyResponse, type WhereFilter, type WhereOperator, type WhereScalar, type WhereValue, createClient, generatePKCEChallenge, localStorageCursorStorage, memoryCursorStorage, resolveConsumerId };
package/dist/index.d.ts CHANGED
@@ -268,6 +268,31 @@ interface PasskeySignupResponse {
268
268
  refresh_token?: string;
269
269
  expires_in?: number;
270
270
  }
271
+ /**
272
+ * Response returned by redeeming a recovery phrase (#784). A recovery account is
273
+ * email-less by construction, so `email` is null — same shape as
274
+ * {@link PasskeyLoginResponse}, kept as a distinct name for clarity. Redeeming
275
+ * installs the returned tokens into the SDK session, exactly like a passkey login.
276
+ */
277
+ interface RecoveryRedeemResponse {
278
+ user: {
279
+ id: string;
280
+ email: string | null;
281
+ roles: string[];
282
+ };
283
+ access_token: string;
284
+ refresh_token?: string;
285
+ expires_in?: number;
286
+ }
287
+ /**
288
+ * Whether the signed-in account has an active recovery-phrase binding (#784),
289
+ * and when it was last bound or rotated. Used to prompt the user to set or
290
+ * refresh their recovery phrase.
291
+ */
292
+ interface RecoveryStatusResponse {
293
+ hasBinding: boolean;
294
+ boundAt?: string;
295
+ }
271
296
  /** Result of verifying a passkey registration attestation. */
272
297
  interface PasskeyRegistrationResult {
273
298
  verified: boolean;
@@ -1147,6 +1172,29 @@ declare class AuthModule {
1147
1172
  deleted: true;
1148
1173
  }>;
1149
1174
  private storeTokensFromLogin;
1175
+ /**
1176
+ * Bind (or rotate) a recovery secret to the signed-in account, so it can be
1177
+ * redeemed later if every passkey is lost. Authenticated — the server rejects
1178
+ * a stale session (fresh-auth), so call this shortly after login/signup. Only
1179
+ * email-less accounts may bind. `secret` is a 43-char base64url string.
1180
+ */
1181
+ bindRecoveryPhrase(secret: string): Promise<{
1182
+ bound: true;
1183
+ }>;
1184
+ /**
1185
+ * Redeem a recovery secret to restore access to the SAME account without a
1186
+ * passkey/email/password. UNAUTHENTICATED (the caller has no session yet).
1187
+ * Single-use: after a successful redeem the client should bind a fresh phrase
1188
+ * and add a new passkey. Installs the returned tokens into the SDK session,
1189
+ * exactly like a passkey login.
1190
+ */
1191
+ redeemRecoveryPhrase(secret: string): Promise<RecoveryRedeemResponse>;
1192
+ /**
1193
+ * Whether the signed-in account has an active recovery binding, and when it
1194
+ * was last bound/rotated — so the app can prompt the user to set or refresh
1195
+ * their recovery phrase. Authenticated.
1196
+ */
1197
+ getRecoveryStatus(): Promise<RecoveryStatusResponse>;
1150
1198
  private storeTokensFromRegister;
1151
1199
  }
1152
1200
 
@@ -2175,4 +2223,4 @@ interface SpacelrClient {
2175
2223
  }
2176
2224
  declare function createClient(config: SpacelrClientConfig): SpacelrClient;
2177
2225
 
2178
- export { type ApiResponse, type AuthLostReason, type AuthState, type AuthStateListener, type AuthorizationUrlParams, BrowserTokenStorage, CONSUMER_ID_STORAGE_KEY, CodeChallengeMethod, type ConnectionState, CursorInvalidError, type CursorStorage, type DatabaseChangeEvent, type DownloadUrlResponse, type ExchangeCodeParams, type FileInfo, type FileListResponse, FileVisibility, ForbiddenError, type FunctionInvokeOptions, type FunctionInvokeResult, type GapReason, GrantType, type InitMultipartUploadParams, type InitMultipartUploadResponse, type JWK, type JWKSResponse, type ListFilesParams, type LoginParams, type LoginResponse, MemoryTokenStorage, NotFoundError, type OpenIDConfiguration, type PKCEChallenge, type PartEtag, type PasskeyAuthenticationOptionsJSON, type PasskeyAuthenticationResponseJSON, type PasskeyCredential, type PasskeyCredentialDescriptorJSON, type PasskeyLoginResponse, type PasskeyRegistrationOptionsJSON, type PasskeyRegistrationResponseJSON, type PasskeyRegistrationResult, type PushSubscriptionInfo, type QuotaInfo, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrScanLimitExceededError, SpacelrSearchFilterRequiredError, SpacelrTimeoutError, SpacelrTwoFactorRequiredError, type StoredTokens, type StreamGapInfo, type StreamSubscription, type SubscribeEventsHandlers, type SubscribeHandlers, type SubscribeWithSnapshotOptions, type TimelineAndFilter, TimelineError, type TimelineFieldFilter, type TimelineFilter, type TimelineLeafFilter, TimelineModule, type TimelineOrderBy, type TimelineQueryOptions, type TimelineQueryResponse, type TimelineScalar, type TimelineSourceStats, TimeoutError, type TokenResponse, type TokenStorage, type TwoFactorResponse, type TwoFactorVerifyParams, type UnshareFileParams, type UploadFileParams, type UploadLargeFileParams, type UploadProgress, type UserInfo, type UserProfile, ValidationError, type VapidKeyResponse, type WhereFilter, type WhereOperator, type WhereScalar, type WhereValue, createClient, generatePKCEChallenge, localStorageCursorStorage, memoryCursorStorage, resolveConsumerId };
2226
+ export { type ApiResponse, type AuthLostReason, type AuthState, type AuthStateListener, type AuthorizationUrlParams, BrowserTokenStorage, CONSUMER_ID_STORAGE_KEY, CodeChallengeMethod, type ConnectionState, CursorInvalidError, type CursorStorage, type DatabaseChangeEvent, type DownloadUrlResponse, type ExchangeCodeParams, type FileInfo, type FileListResponse, FileVisibility, ForbiddenError, type FunctionInvokeOptions, type FunctionInvokeResult, type GapReason, GrantType, type InitMultipartUploadParams, type InitMultipartUploadResponse, type JWK, type JWKSResponse, type ListFilesParams, type LoginParams, type LoginResponse, MemoryTokenStorage, NotFoundError, type OpenIDConfiguration, type PKCEChallenge, type PartEtag, type PasskeyAuthenticationOptionsJSON, type PasskeyAuthenticationResponseJSON, type PasskeyCredential, type PasskeyCredentialDescriptorJSON, type PasskeyLoginResponse, type PasskeyRegistrationOptionsJSON, type PasskeyRegistrationResponseJSON, type PasskeyRegistrationResult, type PushSubscriptionInfo, type QuotaInfo, type RecoveryRedeemResponse, type RecoveryStatusResponse, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrScanLimitExceededError, SpacelrSearchFilterRequiredError, SpacelrTimeoutError, SpacelrTwoFactorRequiredError, type StoredTokens, type StreamGapInfo, type StreamSubscription, type SubscribeEventsHandlers, type SubscribeHandlers, type SubscribeWithSnapshotOptions, type TimelineAndFilter, TimelineError, type TimelineFieldFilter, type TimelineFilter, type TimelineLeafFilter, TimelineModule, type TimelineOrderBy, type TimelineQueryOptions, type TimelineQueryResponse, type TimelineScalar, type TimelineSourceStats, TimeoutError, type TokenResponse, type TokenStorage, type TwoFactorResponse, type TwoFactorVerifyParams, type UnshareFileParams, type UploadFileParams, type UploadLargeFileParams, type UploadProgress, type UserInfo, type UserProfile, ValidationError, type VapidKeyResponse, type WhereFilter, type WhereOperator, type WhereScalar, type WhereValue, createClient, generatePKCEChallenge, localStorageCursorStorage, memoryCursorStorage, resolveConsumerId };
package/dist/index.js CHANGED
@@ -2335,6 +2335,53 @@ var AuthModule = class _AuthModule {
2335
2335
  });
2336
2336
  this.emitState("authenticated");
2337
2337
  }
2338
+ // ─── Recover-with-phrase (#784) ───
2339
+ // For an email-less passkey account (#780) that has lost every passkey. The
2340
+ // caller derives an opaque 32-byte base64url secret from a BIP39 phrase and
2341
+ // passes it here — the SDK is transport-only and never sees or generates the
2342
+ // phrase (no wordlist in the bundle).
2343
+ /**
2344
+ * Bind (or rotate) a recovery secret to the signed-in account, so it can be
2345
+ * redeemed later if every passkey is lost. Authenticated — the server rejects
2346
+ * a stale session (fresh-auth), so call this shortly after login/signup. Only
2347
+ * email-less accounts may bind. `secret` is a 43-char base64url string.
2348
+ */
2349
+ async bindRecoveryPhrase(secret) {
2350
+ return this.http.request({
2351
+ method: "POST",
2352
+ path: "/auth/recovery/bind",
2353
+ body: { secret },
2354
+ authenticated: true
2355
+ });
2356
+ }
2357
+ /**
2358
+ * Redeem a recovery secret to restore access to the SAME account without a
2359
+ * passkey/email/password. UNAUTHENTICATED (the caller has no session yet).
2360
+ * Single-use: after a successful redeem the client should bind a fresh phrase
2361
+ * and add a new passkey. Installs the returned tokens into the SDK session,
2362
+ * exactly like a passkey login.
2363
+ */
2364
+ async redeemRecoveryPhrase(secret) {
2365
+ const result = await this.http.request({
2366
+ method: "POST",
2367
+ path: "/auth/recovery/redeem",
2368
+ body: { secret }
2369
+ });
2370
+ await this.storeTokensFromLogin(result);
2371
+ return result;
2372
+ }
2373
+ /**
2374
+ * Whether the signed-in account has an active recovery binding, and when it
2375
+ * was last bound/rotated — so the app can prompt the user to set or refresh
2376
+ * their recovery phrase. Authenticated.
2377
+ */
2378
+ async getRecoveryStatus() {
2379
+ return this.http.request({
2380
+ method: "GET",
2381
+ path: "/auth/recovery/status",
2382
+ authenticated: true
2383
+ });
2384
+ }
2338
2385
  async storeTokensFromRegister(response) {
2339
2386
  if (!response.access_token) return;
2340
2387
  const expiresAt = response.expires_in ? Math.floor(Date.now() / 1e3) + response.expires_in : void 0;