@rdlabo/ionic-angular-kit 22.0.7 → 22.0.9
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/docs/auth-http.md +2 -0
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs +14 -5
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit.mjs +20 -4
- package/fesm2022/rdlabo-ionic-angular-kit.mjs.map +1 -1
- package/package.json +1 -1
- package/types/rdlabo-ionic-angular-kit.d.ts +3 -1
|
@@ -1826,6 +1826,13 @@ 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.
|
|
@@ -2022,6 +2029,12 @@ const kitAuthInterceptor = (request, next) => {
|
|
|
2022
2029
|
}
|
|
2023
2030
|
return throwError(() => error);
|
|
2024
2031
|
}
|
|
2032
|
+
let uncertainAttempt;
|
|
2033
|
+
const preserveWriteOutcome = (error) => {
|
|
2034
|
+
if (!uncertainAttempt || isWriteOutcomeUnknown(error))
|
|
2035
|
+
return error;
|
|
2036
|
+
return Object.assign(new HttpErrorResponse({ ...error, url: error.url ?? undefined }), { serverCommitUnknown: true });
|
|
2037
|
+
};
|
|
2025
2038
|
const sendAuthenticated = (outgoing, allowAuthRecovery) => from(config.getAuthHeaders(outgoing)).pipe(catchError((headerError) => {
|
|
2026
2039
|
// getAuthHeaders failed → the request is never sent; classify it instead of failing silently.
|
|
2027
2040
|
if (config.enforceAuthAccessMode && isExplicitAuthDenial(headerError) && shouldRevokeAuthAccess(config, outgoing, headerError)) {
|
|
@@ -2029,7 +2042,7 @@ const kitAuthInterceptor = (request, next) => {
|
|
|
2029
2042
|
config.onAuthAccessDenial?.(outgoing, headerError);
|
|
2030
2043
|
}
|
|
2031
2044
|
config.onAuthError?.(outgoing, headerError);
|
|
2032
|
-
return throwError(() => headerError);
|
|
2045
|
+
return throwError(() => headerError instanceof HttpErrorResponse ? preserveWriteOutcome(headerError) : (uncertainAttempt ?? headerError));
|
|
2033
2046
|
}), mergeMap((authHeaders) => {
|
|
2034
2047
|
const req = outgoing.clone({ setHeaders: { ...authHeaders, ...config.buildExtraHeaders?.(outgoing) } });
|
|
2035
2048
|
const retryable = RETRYABLE_METHODS.includes(req.method) || req.headers.has('Idempotency-Key');
|
|
@@ -2045,7 +2058,7 @@ const kitAuthInterceptor = (request, next) => {
|
|
|
2045
2058
|
return event;
|
|
2046
2059
|
}), retry({
|
|
2047
2060
|
count: MAX_RETRIES,
|
|
2048
|
-
delay: (error, retryCount) => from(Network.getStatus()).pipe(mergeMap((network) => {
|
|
2061
|
+
delay: (error, retryCount) => from(Network.getStatus()).pipe(catchError(() => throwError(() => error)), mergeMap((network) => {
|
|
2049
2062
|
// Offline → don't wait out the retries; fail fast so offlineFallback can take over.
|
|
2050
2063
|
if (!network.connected) {
|
|
2051
2064
|
return throwError(() => error);
|
|
@@ -2058,13 +2071,16 @@ const kitAuthInterceptor = (request, next) => {
|
|
|
2058
2071
|
// Short linear backoff (500ms, 1000ms, …) plus jitter to de-correlate a fleet of
|
|
2059
2072
|
// clients reconnecting at once; the server's Retry-After wins when present.
|
|
2060
2073
|
const backoff = parseRetryAfterMs(error) ?? retryCount * 500 + Math.random() * 250;
|
|
2074
|
+
if (!RETRYABLE_METHODS.includes(req.method) && isWriteOutcomeUnknown(error))
|
|
2075
|
+
uncertainAttempt = error;
|
|
2061
2076
|
return timer(backoff);
|
|
2062
2077
|
})),
|
|
2063
2078
|
}), tap((event) => {
|
|
2064
2079
|
if (event instanceof HttpResponse) {
|
|
2065
2080
|
config.onResponse?.(event);
|
|
2066
2081
|
}
|
|
2067
|
-
}), catchError((
|
|
2082
|
+
}), catchError((failure) => {
|
|
2083
|
+
const error = preserveWriteOutcome(failure);
|
|
2068
2084
|
const mayRecover = allowAuthRecovery &&
|
|
2069
2085
|
isExplicitAuthDenial(error) &&
|
|
2070
2086
|
!outgoing.context.get(KIT_AUTH_RECOVERY_REPLAY) &&
|
|
@@ -2843,5 +2859,5 @@ function mountViewModel(host, onMount) {
|
|
|
2843
2859
|
* Generated bundle index. Do not edit.
|
|
2844
2860
|
*/
|
|
2845
2861
|
|
|
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 };
|
|
2862
|
+
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, provideKitAuth, provideKitHttp, provideKitOverlay, toKitWebSocketUrl };
|
|
2847
2863
|
//# sourceMappingURL=rdlabo-ionic-angular-kit.mjs.map
|