@rdlabo/ionic-angular-kit 21.5.1 → 21.5.3

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/README.md CHANGED
@@ -633,7 +633,7 @@ fields and ignored server fields are never persisted.
633
633
  ```typescript
634
634
  // app.config.ts
635
635
  import { provideHttpClient, withInterceptors } from '@angular/common/http';
636
- import { kitAuthInterceptor, provideKitHttp, KitReloadAlertController } from '@rdlabo/ionic-angular-kit';
636
+ import { isIdentityAuthFailure, kitAuthInterceptor, provideKitHttp, KitReloadAlertController } from '@rdlabo/ionic-angular-kit';
637
637
 
638
638
  export const appConfig: ApplicationConfig = {
639
639
  providers: [
@@ -645,13 +645,17 @@ export const appConfig: ApplicationConfig = {
645
645
  // Required for the new offline auth boundary. Kept opt-in so existing applications retain
646
646
  // their current interceptor behavior until they wire KitAuthAccessService.
647
647
  enforceAuthAccessMode: true,
648
- // Optional. Use this only when the API distinguishes invalid identity (401) from
649
- // authenticated resource permission (403). Omission keeps the legacy 401/403 revoke policy.
650
- isAuthAccessDenial: (_req, error) => error.status === 401,
648
+ // Only an explicitly tagged global identity failure may revoke shared access.
649
+ // Omission keeps the legacy 401/403 revoke policy for existing applications.
650
+ isAuthAccessDenial: (_req, error) => isIdentityAuthFailure(error),
651
651
  getAuthHeaders: async (req) => ({
652
652
  Authorization: `Bearer ${await auth.getToken()}`,
653
653
  }),
654
- onUnauthorized: (req) => auth.signOut(),
654
+ // Status-independent: handles both new identity 401 and tagged historical identity 403.
655
+ onAuthAccessDenial: () => auth.signOut(),
656
+ onUnauthorized: (_req, error) => {
657
+ // Feature UX for reauthentication/credential failures may inspect the error here.
658
+ },
655
659
  // Fleet-canonical "network error → offer reload" (see KitReloadAlertController).
656
660
  onNetworkError: (status) =>
657
661
  reload.present({
@@ -698,6 +702,36 @@ because that also skips authentication headers and error handling, and do not gl
698
702
 
699
703
  Plus: a `getAuthHeaders` rejection → `onAuthError(request, error)` (the request is never sent).
700
704
 
705
+ The shared `401` body carries `authFailureScope`:
706
+
707
+ - `identity`: the Firebase/global identity cannot be established; global session and replica/outbox
708
+ invalidation is allowed.
709
+ - `reauthentication`: the identity remains valid, but a recent sign-in/step-up is required.
710
+ - `credential`: only a feature-owned delegated credential is invalid.
711
+
712
+ `getAuthFailureScope(error)` reads this explicit field and returns `null` for untagged legacy
713
+ responses. It also accepts an explicitly tagged historical `403` identity failure for products
714
+ whose installed clients still require that status; new APIs use `401`.
715
+ `isIdentityAuthFailure(error)` is therefore intentionally strict. Put destructive global cleanup in
716
+ `onAuthAccessDenial`; it runs for a classified identity failure independently of whether a compatible
717
+ server returned 401 or 403. `onUnauthorized` receives the complete `HttpErrorResponse` for status-specific UX.
718
+ An untagged `403` remains a resource/scope/business permission failure and never implies global
719
+ identity loss. Existing callbacks that accept only the request remain source-compatible, and applications
720
+ that omit `isAuthAccessDenial` retain the historical 401/403 revocation behavior.
721
+
722
+ Deploy the API contract before enabling the strict client classifier:
723
+
724
+ | Combination | Result |
725
+ | ---------------------------- | ----------------------------------------------------------------------------------------------------------- |
726
+ | Tagged API + legacy client | The extra body fields are ignored and the client's existing status behavior is preserved. |
727
+ | Untagged API + strict client | Global identity loss cannot be identified safely, so the client retains local identity state. |
728
+ | Tagged API + strict client | Only `identity` with `AUTH_IDENTITY_INVALID` revokes global access; narrower failures remain feature-owned. |
729
+
730
+ For products whose installed clients historically require auth failure as `403`, deploy an explicitly
731
+ tagged legacy `403` identity response first. The strict classifier accepts it only with the matching
732
+ `statusCode`, scope, and `AUTH_IDENTITY_INVALID` code. Do not infer identity from an untagged legacy
733
+ 401/403: that would collapse `credential` and `reauthentication` back into destructive global logout.
734
+
701
735
  **Note (0.0.9):** `onNetworkError` is now narrowed to genuine network failures (status `0`); `502/503/429` moved to `onServerBusy`/`onRateLimited`. Existing configs stay valid — they just fire less often — so adopt the new hooks only if you want to distinguish server-busy / rate-limit from a connection loss.
702
736
 
703
737
  ### KitReloadAlertController
@@ -1534,7 +1534,8 @@ class OfflineSyncService {
1534
1534
  return commands.length > 0 ? 'pending' : 'idle';
1535
1535
  }, ...(ngDevMode ? [{ debugName: "syncState" }] : /* istanbul ignore next */ []));
1536
1536
  effect(() => {
1537
- if (this.#initialized && this.#network.connected())
1537
+ const connected = this.#network.connected();
1538
+ if (this.#initialized && connected)
1538
1539
  this.#flushInBackground();
1539
1540
  });
1540
1541
  }