@rdlabo/ionic-angular-kit 21.5.18 → 21.5.19

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.18",
3
+ "version": "21.5.19",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rdlabo-team/ionic-angular-library.git"
@@ -1403,6 +1403,31 @@ interface KitHttpConfig {
1403
1403
  * @returns `true` when shared remote access should be cleared.
1404
1404
  */
1405
1405
  isAuthAccessDenial?(request: HttpRequest<unknown>, error: unknown): boolean;
1406
+ /**
1407
+ * Attempt to recover credentials after an explicit HTTP `401` / `403` before denial hooks run.
1408
+ *
1409
+ * @remarks
1410
+ * Invoked at most once per original request — only on the first explicit auth denial from the
1411
+ * server, and never on a recovery replay (which carries {@link KIT_AUTH_RECOVERY_REPLAY}). When
1412
+ * this hook resolves `true`, {@link KitHttpConfig.getAuthHeaders} is called again and the
1413
+ * original request is sent exactly once more with fresh auth and extra headers. A second denial
1414
+ * follows the normal revocation / status-hook path with no further recovery.
1415
+ *
1416
+ * Unlike transient transport retries, this replay is allowed for writes (`POST` / `PATCH` /
1417
+ * `DELETE`) because the server returned an explicit auth denial — the request was rejected
1418
+ * before (or without) being processed, not lost after a successful write. Apps must still ensure
1419
+ * {@link KitHttpConfig.recoverAuthAccess} only returns `true` when credentials were refreshed
1420
+ * and a single replay is safe for the endpoint.
1421
+ *
1422
+ * When the hook is absent, resolves `false`, or throws, the original {@link HttpErrorResponse}
1423
+ * is preserved and the existing denial / fallback pipeline runs unchanged; hook failures do not
1424
+ * replace the server error.
1425
+ *
1426
+ * @param request - The outgoing request that received the denial (before header merge).
1427
+ * @param error - The explicit `401` / `403` response.
1428
+ * @returns `true` to replay once with regenerated headers; `false` to proceed with normal denial handling.
1429
+ */
1430
+ recoverAuthAccess?(request: HttpRequest<unknown>, error: HttpErrorResponse): Promise<boolean>;
1406
1431
  }
1407
1432
  /**
1408
1433
  * Injection token that carries the {@link KitHttpConfig} to {@link kitAuthInterceptor}.
@@ -1454,7 +1479,9 @@ declare const provideKitHttp: (configFactory: () => KitHttpConfig) => Environmen
1454
1479
  * `Idempotency-Key`), and the status is a {@link RETRYABLE_STATUSES | transient status}. The
1455
1480
  * backoff is `retryCount * 500ms` plus up to 250ms of jitter, or the server's `Retry-After`.
1456
1481
  * When the device is offline it stops retrying immediately.
1457
- * 5. On the final error, enforced 401/403 revokes shared access and is rejected before fallback.
1482
+ * 5. On the first explicit HTTP `401`/`403`, {@link KitHttpConfig.recoverAuthAccess} may replay the
1483
+ * request once with regenerated headers before denial hooks run; recovery replays never recurse.
1484
+ * 6. On the final error, enforced 401/403 revokes shared access and is rejected before fallback.
1458
1485
  * For every other error, `offlineFallback` is consulted first; otherwise the error is classified by
1459
1486
  * status (see {@link dispatchError}): `401`→`onUnauthorized`, `403`→`onForbidden`, `0`→
1460
1487
  * `onNetworkError` (when connected), `429`→`onRateLimited`, maintenance `503`→`onMaintenance`,