@rdlabo/ionic-angular-kit 22.0.8 → 22.0.10

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.
@@ -1826,11 +1826,16 @@ const DEFAULT_TIMEOUT_MS = 60_000;
1826
1826
  * @returns Whether this is a maintenance response.
1827
1827
  */
1828
1828
  const isMaintenanceError = (error) => error.status === 503 && error.error?.code === 'MAINTENANCE';
1829
+ /** A write may have committed during this attempt or an earlier attempt with the same key. */
1830
+ function isWriteOutcomeUnknown(error) {
1831
+ if (!error || typeof error !== 'object')
1832
+ return false;
1833
+ const { status, serverCommitUnknown } = error;
1834
+ return serverCommitUnknown === true || status === 0 || status === 408 || (typeof status === 'number' && status >= 500);
1835
+ }
1829
1836
  /**
1830
1837
  * Parse a `Retry-After` header (delta-seconds or an HTTP-date) into milliseconds, or `null` when it
1831
1838
  * is absent or unparseable.
1832
- *
1833
- * @internal
1834
1839
  */
1835
1840
  const parseRetryAfterMs = (error) => {
1836
1841
  const header = error.headers?.get('Retry-After');
@@ -2022,6 +2027,12 @@ const kitAuthInterceptor = (request, next) => {
2022
2027
  }
2023
2028
  return throwError(() => error);
2024
2029
  }
2030
+ let uncertainAttempt;
2031
+ const preserveWriteOutcome = (error) => {
2032
+ if (!uncertainAttempt || isWriteOutcomeUnknown(error))
2033
+ return error;
2034
+ return Object.assign(new HttpErrorResponse({ ...error, url: error.url ?? undefined }), { serverCommitUnknown: true });
2035
+ };
2025
2036
  const sendAuthenticated = (outgoing, allowAuthRecovery) => from(config.getAuthHeaders(outgoing)).pipe(catchError((headerError) => {
2026
2037
  // getAuthHeaders failed → the request is never sent; classify it instead of failing silently.
2027
2038
  if (config.enforceAuthAccessMode && isExplicitAuthDenial(headerError) && shouldRevokeAuthAccess(config, outgoing, headerError)) {
@@ -2029,7 +2040,7 @@ const kitAuthInterceptor = (request, next) => {
2029
2040
  config.onAuthAccessDenial?.(outgoing, headerError);
2030
2041
  }
2031
2042
  config.onAuthError?.(outgoing, headerError);
2032
- return throwError(() => headerError);
2043
+ return throwError(() => headerError instanceof HttpErrorResponse ? preserveWriteOutcome(headerError) : (uncertainAttempt ?? headerError));
2033
2044
  }), mergeMap((authHeaders) => {
2034
2045
  const req = outgoing.clone({ setHeaders: { ...authHeaders, ...config.buildExtraHeaders?.(outgoing) } });
2035
2046
  const retryable = RETRYABLE_METHODS.includes(req.method) || req.headers.has('Idempotency-Key');
@@ -2045,7 +2056,7 @@ const kitAuthInterceptor = (request, next) => {
2045
2056
  return event;
2046
2057
  }), retry({
2047
2058
  count: MAX_RETRIES,
2048
- delay: (error, retryCount) => from(Network.getStatus()).pipe(mergeMap((network) => {
2059
+ delay: (error, retryCount) => from(Network.getStatus()).pipe(catchError(() => throwError(() => error)), mergeMap((network) => {
2049
2060
  // Offline → don't wait out the retries; fail fast so offlineFallback can take over.
2050
2061
  if (!network.connected) {
2051
2062
  return throwError(() => error);
@@ -2058,13 +2069,19 @@ const kitAuthInterceptor = (request, next) => {
2058
2069
  // Short linear backoff (500ms, 1000ms, …) plus jitter to de-correlate a fleet of
2059
2070
  // clients reconnecting at once; the server's Retry-After wins when present.
2060
2071
  const backoff = parseRetryAfterMs(error) ?? retryCount * 500 + Math.random() * 250;
2072
+ // A native timer cannot honor a longer delay. Surface the response so a durable queue can.
2073
+ if (backoff > 2_147_483_647)
2074
+ return throwError(() => error);
2075
+ if (!RETRYABLE_METHODS.includes(req.method) && isWriteOutcomeUnknown(error))
2076
+ uncertainAttempt = error;
2061
2077
  return timer(backoff);
2062
2078
  })),
2063
2079
  }), tap((event) => {
2064
2080
  if (event instanceof HttpResponse) {
2065
2081
  config.onResponse?.(event);
2066
2082
  }
2067
- }), catchError((error) => {
2083
+ }), catchError((failure) => {
2084
+ const error = preserveWriteOutcome(failure);
2068
2085
  const mayRecover = allowAuthRecovery &&
2069
2086
  isExplicitAuthDenial(error) &&
2070
2087
  !outgoing.context.get(KIT_AUTH_RECOVERY_REPLAY) &&
@@ -2843,5 +2860,5 @@ function mountViewModel(host, onMount) {
2843
2860
  * Generated bundle index. Do not edit.
2844
2861
  */
2845
2862
 
2846
- export { AUTH_FAILURE_SCOPES, AUTH_IDENTITY_INVALID_CODE, KIT_AUTH_BOOTSTRAP_REQUEST, KIT_AUTH_CONFIG, KIT_AUTH_RECOVERY_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KIT_REALTIME_CLIENT_ID, KIT_SKIP_ERROR_NOTIFICATIONS, KIT_THEME_STORAGE_KEY, KitAuthAccessService, KitAuthInputDirective, KitAuthLoginExchange, KitAuthRecoveryService, KitLoadingController, KitMaintenanceController, KitOverlayController, KitRealtimeConnection, KitRealtimeLivenessWatchdog, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, getAuthFailureScope, isExplicitAuthDenial, isIdentityAuthFailure, isMaintenanceError, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPreloadAuthLoginForNavigation, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRealtimeProtocols, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, mountViewModel, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay, toKitWebSocketUrl };
2863
+ export { AUTH_FAILURE_SCOPES, AUTH_IDENTITY_INVALID_CODE, KIT_AUTH_BOOTSTRAP_REQUEST, KIT_AUTH_CONFIG, KIT_AUTH_RECOVERY_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KIT_REALTIME_CLIENT_ID, KIT_SKIP_ERROR_NOTIFICATIONS, KIT_THEME_STORAGE_KEY, KitAuthAccessService, KitAuthInputDirective, KitAuthLoginExchange, KitAuthRecoveryService, KitLoadingController, KitMaintenanceController, KitOverlayController, KitRealtimeConnection, KitRealtimeLivenessWatchdog, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, getAuthFailureScope, isExplicitAuthDenial, isIdentityAuthFailure, isMaintenanceError, isWriteOutcomeUnknown, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPreloadAuthLoginForNavigation, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRealtimeProtocols, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, mountViewModel, objectEqual, parseRetryAfterMs, provideKitAuth, provideKitHttp, provideKitOverlay, toKitWebSocketUrl };
2847
2864
  //# sourceMappingURL=rdlabo-ionic-angular-kit.mjs.map