@spacelr/sdk 0.18.0 → 0.18.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.d.mts CHANGED
@@ -1116,8 +1116,18 @@ declare class AuthModule {
1116
1116
  refresh(refreshToken: string): Promise<TokenResponse>;
1117
1117
  getProfile(): Promise<UserProfile>;
1118
1118
  logout(): Promise<void>;
1119
+ /**
1120
+ * Verify an email address with the token from the verification email.
1121
+ *
1122
+ * The token is sent in the request BODY, never the URL (#941): a query
1123
+ * string reaches server, proxy and CDN logs. When the project mints one, the
1124
+ * response carries a one-time `loginCode`; pass it to `exchangeCode` to sign
1125
+ * the user in.
1126
+ */
1119
1127
  verifyEmail(token: string): Promise<{
1120
1128
  message: string;
1129
+ valid: boolean;
1130
+ loginCode?: string;
1121
1131
  }>;
1122
1132
  resendVerification(email: string): Promise<{
1123
1133
  message: string;
@@ -1212,6 +1222,11 @@ declare class AuthModule {
1212
1222
  /**
1213
1223
  * Fetch WebAuthn attestation options to register a new passkey for the
1214
1224
  * currently authenticated user.
1225
+ *
1226
+ * Requires a recent interactive login (within 5 minutes). Otherwise the
1227
+ * server answers 401 `STALE_SESSION` and this throws
1228
+ * {@link SpacelrStepUpRequiredError}: sign the user in again, then retry.
1229
+ * A token refresh does not help.
1215
1230
  */
1216
1231
  beginPasskeyRegistration(): Promise<PasskeyRegistrationOptionsJSON>;
1217
1232
  /**
@@ -1219,6 +1234,11 @@ declare class AuthModule {
1219
1234
  * against the options returned by `beginPasskeyRegistration()`, saving the
1220
1235
  * new credential under the current user. This does not issue tokens or
1221
1236
  * change auth state — the caller is already authenticated.
1237
+ *
1238
+ * Requires a recent interactive login (within 5 minutes). Otherwise the
1239
+ * server answers 401 `STALE_SESSION` and this throws
1240
+ * {@link SpacelrStepUpRequiredError}: sign the user in again, then retry.
1241
+ * A token refresh does not help.
1222
1242
  */
1223
1243
  verifyPasskeyRegistration(response: PasskeyRegistrationResponseJSON, label?: string): Promise<PasskeyRegistrationResult>;
1224
1244
  /**
@@ -1347,6 +1367,11 @@ declare class AuthModule {
1347
1367
  /**
1348
1368
  * Approve the pending device link (signed-in device A). Authenticated.
1349
1369
  * Ownership/identity are derived server-side from the JWT.
1370
+ *
1371
+ * Requires a recent interactive login (within 5 minutes). Otherwise the
1372
+ * server answers 401 `STALE_SESSION` and this throws
1373
+ * {@link SpacelrStepUpRequiredError}: sign the user in again, then retry.
1374
+ * A token refresh does not help.
1350
1375
  */
1351
1376
  approveDeviceLink(code: string): Promise<{
1352
1377
  approved: true;
@@ -2389,4 +2414,4 @@ interface SpacelrClient {
2389
2414
  }
2390
2415
  declare function createClient(config: SpacelrClientConfig): SpacelrClient;
2391
2416
 
2392
- 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, SpacelrStepUpRequiredError, 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 };
2417
+ 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 DeviceLinkCompleteResponse, type DeviceLinkInit, type DeviceLinkStatus, 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 PasskeySignupResponse, type PushSubscriptionInfo, type QuotaInfo, type RecoveryRedeemResponse, type RecoveryStatusResponse, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type SessionSummary, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrScanLimitExceededError, SpacelrSearchFilterRequiredError, SpacelrStepUpRequiredError, 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
@@ -1116,8 +1116,18 @@ declare class AuthModule {
1116
1116
  refresh(refreshToken: string): Promise<TokenResponse>;
1117
1117
  getProfile(): Promise<UserProfile>;
1118
1118
  logout(): Promise<void>;
1119
+ /**
1120
+ * Verify an email address with the token from the verification email.
1121
+ *
1122
+ * The token is sent in the request BODY, never the URL (#941): a query
1123
+ * string reaches server, proxy and CDN logs. When the project mints one, the
1124
+ * response carries a one-time `loginCode`; pass it to `exchangeCode` to sign
1125
+ * the user in.
1126
+ */
1119
1127
  verifyEmail(token: string): Promise<{
1120
1128
  message: string;
1129
+ valid: boolean;
1130
+ loginCode?: string;
1121
1131
  }>;
1122
1132
  resendVerification(email: string): Promise<{
1123
1133
  message: string;
@@ -1212,6 +1222,11 @@ declare class AuthModule {
1212
1222
  /**
1213
1223
  * Fetch WebAuthn attestation options to register a new passkey for the
1214
1224
  * currently authenticated user.
1225
+ *
1226
+ * Requires a recent interactive login (within 5 minutes). Otherwise the
1227
+ * server answers 401 `STALE_SESSION` and this throws
1228
+ * {@link SpacelrStepUpRequiredError}: sign the user in again, then retry.
1229
+ * A token refresh does not help.
1215
1230
  */
1216
1231
  beginPasskeyRegistration(): Promise<PasskeyRegistrationOptionsJSON>;
1217
1232
  /**
@@ -1219,6 +1234,11 @@ declare class AuthModule {
1219
1234
  * against the options returned by `beginPasskeyRegistration()`, saving the
1220
1235
  * new credential under the current user. This does not issue tokens or
1221
1236
  * change auth state — the caller is already authenticated.
1237
+ *
1238
+ * Requires a recent interactive login (within 5 minutes). Otherwise the
1239
+ * server answers 401 `STALE_SESSION` and this throws
1240
+ * {@link SpacelrStepUpRequiredError}: sign the user in again, then retry.
1241
+ * A token refresh does not help.
1222
1242
  */
1223
1243
  verifyPasskeyRegistration(response: PasskeyRegistrationResponseJSON, label?: string): Promise<PasskeyRegistrationResult>;
1224
1244
  /**
@@ -1347,6 +1367,11 @@ declare class AuthModule {
1347
1367
  /**
1348
1368
  * Approve the pending device link (signed-in device A). Authenticated.
1349
1369
  * Ownership/identity are derived server-side from the JWT.
1370
+ *
1371
+ * Requires a recent interactive login (within 5 minutes). Otherwise the
1372
+ * server answers 401 `STALE_SESSION` and this throws
1373
+ * {@link SpacelrStepUpRequiredError}: sign the user in again, then retry.
1374
+ * A token refresh does not help.
1350
1375
  */
1351
1376
  approveDeviceLink(code: string): Promise<{
1352
1377
  approved: true;
@@ -2389,4 +2414,4 @@ interface SpacelrClient {
2389
2414
  }
2390
2415
  declare function createClient(config: SpacelrClientConfig): SpacelrClient;
2391
2416
 
2392
- 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, SpacelrStepUpRequiredError, 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 };
2417
+ 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 DeviceLinkCompleteResponse, type DeviceLinkInit, type DeviceLinkStatus, 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 PasskeySignupResponse, type PushSubscriptionInfo, type QuotaInfo, type RecoveryRedeemResponse, type RecoveryStatusResponse, type RegisterParams, type RegisterResponse, type Schedule, type ScheduleInvokeOptions, type ScheduleListOptions, type ScheduleStatus, type SearchOptions, ServerConfigError, type SessionSummary, type ShareFileParams, SharePermission, SpacelrAuthError, type SpacelrClient, type SpacelrClientConfig, SpacelrEmailVerificationRequiredError, SpacelrError, SpacelrNetworkError, SpacelrScanLimitExceededError, SpacelrSearchFilterRequiredError, SpacelrStepUpRequiredError, 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
@@ -1639,6 +1639,7 @@ var RealtimeClient = class {
1639
1639
  captureDurableHandshake(state, ack) {
1640
1640
  if (ack.generation !== void 0) state.generation = ack.generation;
1641
1641
  if (ack.session !== void 0) state.session = ack.session;
1642
+ this.scheduleDurableAck(state);
1642
1643
  }
1643
1644
  /**
1644
1645
  * #768 — schedule a coalesced durable ack. Only durable subscriptions (a
@@ -1761,6 +1762,10 @@ var RealtimeClient = class {
1761
1762
  }
1762
1763
  }
1763
1764
  async resubscribeOne(primary, set) {
1765
+ for (const s of set) {
1766
+ s.generation = void 0;
1767
+ s.session = void 0;
1768
+ }
1764
1769
  try {
1765
1770
  const ack = await this.emitSubscribeEvents(primary);
1766
1771
  if (ack.error) {
@@ -1773,12 +1778,9 @@ var RealtimeClient = class {
1773
1778
  }
1774
1779
  return;
1775
1780
  }
1776
- for (const s of set) {
1777
- s.generation = void 0;
1778
- s.session = void 0;
1779
- }
1780
- this.captureDurableHandshake(primary, ack);
1781
- if (!this.streamSubscriptions.has(primary.subscriptionKey)) {
1781
+ if (this.streamSubscriptions.has(primary.subscriptionKey)) {
1782
+ this.captureDurableHandshake(primary, ack);
1783
+ } else {
1782
1784
  const payload = {
1783
1785
  projectId: primary.options.projectId,
1784
1786
  collectionName: primary.options.collectionName
@@ -2046,11 +2048,19 @@ var AuthModule = class _AuthModule {
2046
2048
  await this.tokenManager.clearTokens();
2047
2049
  this.emitState("unauthenticated");
2048
2050
  }
2051
+ /**
2052
+ * Verify an email address with the token from the verification email.
2053
+ *
2054
+ * The token is sent in the request BODY, never the URL (#941): a query
2055
+ * string reaches server, proxy and CDN logs. When the project mints one, the
2056
+ * response carries a one-time `loginCode`; pass it to `exchangeCode` to sign
2057
+ * the user in.
2058
+ */
2049
2059
  async verifyEmail(token) {
2050
2060
  return this.http.request({
2051
- method: "GET",
2061
+ method: "POST",
2052
2062
  path: "/auth/verify-email",
2053
- query: { token }
2063
+ body: { token }
2054
2064
  });
2055
2065
  }
2056
2066
  async resendVerification(email) {
@@ -2295,6 +2305,11 @@ var AuthModule = class _AuthModule {
2295
2305
  /**
2296
2306
  * Fetch WebAuthn attestation options to register a new passkey for the
2297
2307
  * currently authenticated user.
2308
+ *
2309
+ * Requires a recent interactive login (within 5 minutes). Otherwise the
2310
+ * server answers 401 `STALE_SESSION` and this throws
2311
+ * {@link SpacelrStepUpRequiredError}: sign the user in again, then retry.
2312
+ * A token refresh does not help.
2298
2313
  */
2299
2314
  async beginPasskeyRegistration() {
2300
2315
  return this.http.request({
@@ -2309,6 +2324,11 @@ var AuthModule = class _AuthModule {
2309
2324
  * against the options returned by `beginPasskeyRegistration()`, saving the
2310
2325
  * new credential under the current user. This does not issue tokens or
2311
2326
  * change auth state — the caller is already authenticated.
2327
+ *
2328
+ * Requires a recent interactive login (within 5 minutes). Otherwise the
2329
+ * server answers 401 `STALE_SESSION` and this throws
2330
+ * {@link SpacelrStepUpRequiredError}: sign the user in again, then retry.
2331
+ * A token refresh does not help.
2312
2332
  */
2313
2333
  async verifyPasskeyRegistration(response, label) {
2314
2334
  return this.http.request({
@@ -2558,6 +2578,11 @@ var AuthModule = class _AuthModule {
2558
2578
  /**
2559
2579
  * Approve the pending device link (signed-in device A). Authenticated.
2560
2580
  * Ownership/identity are derived server-side from the JWT.
2581
+ *
2582
+ * Requires a recent interactive login (within 5 minutes). Otherwise the
2583
+ * server answers 401 `STALE_SESSION` and this throws
2584
+ * {@link SpacelrStepUpRequiredError}: sign the user in again, then retry.
2585
+ * A token refresh does not help.
2561
2586
  */
2562
2587
  async approveDeviceLink(code) {
2563
2588
  return this.http.request({