@rdlabo/ionic-angular-kit 21.5.0 → 21.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdlabo/ionic-angular-kit",
3
- "version": "21.5.0",
3
+ "version": "21.5.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rdlabo-team/ionic-angular-library.git"
@@ -1288,8 +1288,9 @@ interface KitHttpConfig {
1288
1288
  * Optional; defaults to a no-op.
1289
1289
  *
1290
1290
  * @param request - The request that received the `401`.
1291
+ * @param error - The complete response, including any explicit authentication failure scope.
1291
1292
  */
1292
- onUnauthorized?(request: HttpRequest<unknown>): void;
1293
+ onUnauthorized?(request: HttpRequest<unknown>, error: HttpErrorResponse): void;
1293
1294
  /**
1294
1295
  * Side effect to run on a `403` response (a permission error).
1295
1296
  *
@@ -1297,8 +1298,9 @@ interface KitHttpConfig {
1297
1298
  * Optional; defaults to a no-op.
1298
1299
  *
1299
1300
  * @param request - The request that received the `403`.
1301
+ * @param error - The complete permission-error response.
1300
1302
  */
1301
- onForbidden?(request: HttpRequest<unknown>): void;
1303
+ onForbidden?(request: HttpRequest<unknown>, error: HttpErrorResponse): void;
1302
1304
  /**
1303
1305
  * UX hook for a genuine network / transport failure (status `0`) while the device reports itself
1304
1306
  * connected — i.e. the server is unreachable rather than the phone being offline.
@@ -1368,6 +1370,39 @@ interface KitHttpConfig {
1368
1370
  * @param error - The error thrown by `getAuthHeaders`.
1369
1371
  */
1370
1372
  onAuthError?(request: HttpRequest<unknown>, error: unknown): void;
1373
+ /**
1374
+ * Called when {@link KitHttpConfig.isAuthAccessDenial} classifies a failure as
1375
+ * global identity loss and shared remote access is revoked.
1376
+ *
1377
+ * @remarks
1378
+ * This hook is status-independent so an explicitly tagged historical 403
1379
+ * identity response reaches the same cleanup as a new 401 identity response.
1380
+ * Status hooks still run afterward for response-specific UX. Optional and
1381
+ * backward compatible.
1382
+ */
1383
+ onAuthAccessDenial?(request: HttpRequest<unknown>, error: unknown): void;
1384
+ /**
1385
+ * Classify whether an auth-related failure should revoke shared remote access.
1386
+ *
1387
+ * @remarks
1388
+ * Consulted only when {@link KitHttpConfig.enforceAuthAccessMode} is enabled and the failure is
1389
+ * an explicit authentication denial ({@link isExplicitAuthDenial | HTTP 401/403} or the same
1390
+ * status shape from {@link KitHttpConfig.getAuthHeaders}). Return `true` to call
1391
+ * {@link KitAuthAccessService.clear}; return `false` to keep the current access mode (for example
1392
+ * when a `403` is a resource permission error rather than a lost session). When omitted, both
1393
+ * `401` and `403` revoke access — the historical default.
1394
+ *
1395
+ * Regardless of the return value, explicit `401`/`403` responses never reach
1396
+ * {@link KitHttpConfig.offlineFallback}; the matching response hook
1397
+ * ({@link KitHttpConfig.onUnauthorized} / {@link KitHttpConfig.onForbidden}) still runs and the
1398
+ * error is rethrown. A rejection from `getAuthHeaders` has no response, so it calls only
1399
+ * {@link KitHttpConfig.onAuthError}.
1400
+ *
1401
+ * @param request - The outgoing request that failed (or whose headers could not be produced).
1402
+ * @param error - The `HttpErrorResponse` or header-production rejection.
1403
+ * @returns `true` when shared remote access should be cleared.
1404
+ */
1405
+ isAuthAccessDenial?(request: HttpRequest<unknown>, error: unknown): boolean;
1371
1406
  }
1372
1407
  /**
1373
1408
  * Injection token that carries the {@link KitHttpConfig} to {@link kitAuthInterceptor}.
@@ -1436,6 +1471,35 @@ declare const provideKitHttp: (configFactory: () => KitHttpConfig) => Environmen
1436
1471
  */
1437
1472
  declare const kitAuthInterceptor: HttpInterceptorFn;
1438
1473
 
1474
+ /**
1475
+ * Shared lifecycle boundary carried by an authentication failure response.
1476
+ *
1477
+ * Only `identity` invalidates the application's global authenticated identity.
1478
+ * The other scopes retain it and let the owning feature handle recovery.
1479
+ */
1480
+ declare const AUTH_FAILURE_SCOPES: {
1481
+ readonly identity: "identity";
1482
+ readonly reauthentication: "reauthentication";
1483
+ readonly credential: "credential";
1484
+ };
1485
+ type AuthFailureScope = (typeof AUTH_FAILURE_SCOPES)[keyof typeof AUTH_FAILURE_SCOPES];
1486
+ declare const AUTH_IDENTITY_INVALID_CODE = "AUTH_IDENTITY_INVALID";
1487
+ interface AuthFailureBody {
1488
+ statusCode: 401 | 403;
1489
+ message: string;
1490
+ code: string;
1491
+ authFailureScope: AuthFailureScope;
1492
+ }
1493
+ /**
1494
+ * Reads the explicit auth-failure scope from an Angular `HttpErrorResponse` or
1495
+ * from a body-like value. Tagged historical 403 identity responses are
1496
+ * supported for installed-client compatibility. Untagged 401/403 responses
1497
+ * intentionally return `null`.
1498
+ */
1499
+ declare const getAuthFailureScope: (error: unknown) => AuthFailureScope | null;
1500
+ /** True only for an explicitly tagged global identity failure. */
1501
+ declare const isIdentityAuthFailure: (error: unknown) => boolean;
1502
+
1439
1503
  /** One WebSocket endpoint and its ordered subprotocol list. URLs must be unique within a target set. */
1440
1504
  interface KitRealtimeSocketTarget {
1441
1505
  url: string;
@@ -1742,5 +1806,5 @@ type ComponentPropsType<T> = {
1742
1806
  [K in keyof T]: InputSignal<T[K]> | InputSignalWithTransform<T[K], any>;
1743
1807
  };
1744
1808
 
1745
- export { 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_THEME_STORAGE_KEY, KitAuthAccessService, KitAuthInputDirective, KitAuthRecoveryService, KitLoadingController, KitMaintenanceController, KitOverlayController, KitRealtimeConnection, KitRealtimeLivenessWatchdog, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, isExplicitAuthDenial, isMaintenanceError, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRealtimeProtocols, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, mountViewModel, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay, toKitWebSocketUrl };
1746
- export type { ComponentPropsType, KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthAccessLease, KitAuthAccessMode, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthGuardState, KitAuthInputMode, KitAuthRecoveryConfig, KitAuthRedirects, KitAuthState, KitClearableStore, KitClientRealtimeEvent, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitMaintenanceOptions, KitModalPresentOptions, KitOverlayConfig, KitRealtimeConnectionOptions, KitRealtimeEvent, KitRealtimeSocketTarget, KitReloadAlertOptions, KitRemoteAccessRecovery, ModalMetadata, ReactiveHost, ViewModelHost };
1809
+ 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_THEME_STORAGE_KEY, KitAuthAccessService, KitAuthInputDirective, KitAuthRecoveryService, KitLoadingController, KitMaintenanceController, KitOverlayController, KitRealtimeConnection, KitRealtimeLivenessWatchdog, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, getAuthFailureScope, isExplicitAuthDenial, isIdentityAuthFailure, isMaintenanceError, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRealtimeProtocols, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, mountViewModel, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay, toKitWebSocketUrl };
1810
+ export type { AuthFailureBody, AuthFailureScope, ComponentPropsType, KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthAccessLease, KitAuthAccessMode, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthGuardState, KitAuthInputMode, KitAuthRecoveryConfig, KitAuthRedirects, KitAuthState, KitClearableStore, KitClientRealtimeEvent, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitMaintenanceOptions, KitModalPresentOptions, KitOverlayConfig, KitRealtimeConnectionOptions, KitRealtimeEvent, KitRealtimeSocketTarget, KitReloadAlertOptions, KitRemoteAccessRecovery, ModalMetadata, ReactiveHost, ViewModelHost };