@spacelr/sdk 0.19.3 → 0.19.4

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
@@ -469,8 +469,8 @@ interface UploadProgress {
469
469
  type RefreshCallback = (refreshToken: string) => Promise<StoredTokens>;
470
470
  /**
471
471
  * Reasons the SDK reports a **server-confirmed** auth loss via `onAuthLost`.
472
- * A transient refresh failure (network/transport OR a 5xx) is NOT reported
473
- * (#759/#762).
472
+ * A transient refresh failure (network/transport, a 5xx, a 429 or a 408) is NOT
473
+ * reported (#759/#762/#1080).
474
474
  * See the `onAuthLost` JSDoc in `client.ts` for the full contract.
475
475
  */
476
476
  type AuthLostReason = 'refresh-failed' | 'unauthorized';
@@ -541,9 +541,12 @@ declare class TokenManager {
541
541
  * gateway) surfaced as `SpacelrNetworkError`/`SpacelrTimeoutError` (#759);
542
542
  * - a 5xx server response — e.g. a 503 the gateway returns when oauth-service
543
543
  * is momentarily down (#760/#762) — which is retryable infrastructure, not
544
- * a token rejection.
545
- * A real auth rejection (401/invalid_grant) or any other non-5xx server error
546
- * is NOT transient and is treated as a server-confirmed loss.
544
+ * a token rejection;
545
+ * - a 429 or 408 (#1080) — the rate limit is per IP, so it is shared by
546
+ * everyone behind one NAT, and a 408 never completed. Neither judged the
547
+ * refresh token.
548
+ * A real auth rejection (401/invalid_grant) or any other 4xx server error is
549
+ * NOT transient and is treated as a server-confirmed loss.
547
550
  */
548
551
  private isTransientTransportError;
549
552
  private isTokenExpired;
@@ -2450,9 +2453,10 @@ interface SpacelrClient {
2450
2453
  * session and the next request retries. That covers a network/transport
2451
2454
  * failure (offline, tunnel, captive portal, unreachable gateway; #759) AND a
2452
2455
  * **5xx** server response, e.g. a `503` the gateway returns while
2453
- * oauth-service is momentarily down (#760/#762). This lets a local-first app
2456
+ * oauth-service is momentarily down (#760/#762). A **429** (rate limit, shared
2457
+ * per IP) and a **408** are transient too (#1080). This lets a local-first app
2454
2458
  * stay signed in through an outage instead of ejecting the user. Only a
2455
- * server-confirmed rejection (a 401/invalid_grant, or another non-5xx server
2459
+ * server-confirmed rejection (a 401/invalid_grant, or another 4xx server
2456
2460
  * error) fires.
2457
2461
  *
2458
2462
  * On a confirmed loss the SDK **clears the stored tokens itself**, so
package/dist/index.d.ts CHANGED
@@ -469,8 +469,8 @@ interface UploadProgress {
469
469
  type RefreshCallback = (refreshToken: string) => Promise<StoredTokens>;
470
470
  /**
471
471
  * Reasons the SDK reports a **server-confirmed** auth loss via `onAuthLost`.
472
- * A transient refresh failure (network/transport OR a 5xx) is NOT reported
473
- * (#759/#762).
472
+ * A transient refresh failure (network/transport, a 5xx, a 429 or a 408) is NOT
473
+ * reported (#759/#762/#1080).
474
474
  * See the `onAuthLost` JSDoc in `client.ts` for the full contract.
475
475
  */
476
476
  type AuthLostReason = 'refresh-failed' | 'unauthorized';
@@ -541,9 +541,12 @@ declare class TokenManager {
541
541
  * gateway) surfaced as `SpacelrNetworkError`/`SpacelrTimeoutError` (#759);
542
542
  * - a 5xx server response — e.g. a 503 the gateway returns when oauth-service
543
543
  * is momentarily down (#760/#762) — which is retryable infrastructure, not
544
- * a token rejection.
545
- * A real auth rejection (401/invalid_grant) or any other non-5xx server error
546
- * is NOT transient and is treated as a server-confirmed loss.
544
+ * a token rejection;
545
+ * - a 429 or 408 (#1080) — the rate limit is per IP, so it is shared by
546
+ * everyone behind one NAT, and a 408 never completed. Neither judged the
547
+ * refresh token.
548
+ * A real auth rejection (401/invalid_grant) or any other 4xx server error is
549
+ * NOT transient and is treated as a server-confirmed loss.
547
550
  */
548
551
  private isTransientTransportError;
549
552
  private isTokenExpired;
@@ -2450,9 +2453,10 @@ interface SpacelrClient {
2450
2453
  * session and the next request retries. That covers a network/transport
2451
2454
  * failure (offline, tunnel, captive portal, unreachable gateway; #759) AND a
2452
2455
  * **5xx** server response, e.g. a `503` the gateway returns while
2453
- * oauth-service is momentarily down (#760/#762). This lets a local-first app
2456
+ * oauth-service is momentarily down (#760/#762). A **429** (rate limit, shared
2457
+ * per IP) and a **408** are transient too (#1080). This lets a local-first app
2454
2458
  * stay signed in through an outage instead of ejecting the user. Only a
2455
- * server-confirmed rejection (a 401/invalid_grant, or another non-5xx server
2459
+ * server-confirmed rejection (a 401/invalid_grant, or another 4xx server
2456
2460
  * error) fires.
2457
2461
  *
2458
2462
  * On a confirmed loss the SDK **clears the stored tokens itself**, so
package/dist/index.js CHANGED
@@ -624,16 +624,20 @@ var TokenManager = class {
624
624
  * gateway) surfaced as `SpacelrNetworkError`/`SpacelrTimeoutError` (#759);
625
625
  * - a 5xx server response — e.g. a 503 the gateway returns when oauth-service
626
626
  * is momentarily down (#760/#762) — which is retryable infrastructure, not
627
- * a token rejection.
628
- * A real auth rejection (401/invalid_grant) or any other non-5xx server error
629
- * is NOT transient and is treated as a server-confirmed loss.
627
+ * a token rejection;
628
+ * - a 429 or 408 (#1080) — the rate limit is per IP, so it is shared by
629
+ * everyone behind one NAT, and a 408 never completed. Neither judged the
630
+ * refresh token.
631
+ * A real auth rejection (401/invalid_grant) or any other 4xx server error is
632
+ * NOT transient and is treated as a server-confirmed loss.
630
633
  */
631
634
  isTransientTransportError(error) {
632
635
  if (error instanceof SpacelrNetworkError || error instanceof SpacelrTimeoutError) {
633
636
  return true;
634
637
  }
635
638
  if (error instanceof SpacelrError && typeof error.statusCode === "number") {
636
- return error.statusCode >= 500 && error.statusCode <= 599;
639
+ const status = error.statusCode;
640
+ return status === 429 || status === 408 || status >= 500 && status <= 599;
637
641
  }
638
642
  return false;
639
643
  }