@newheap/platform-common 1.3.1 → 1.5.0

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as i20 from '@angular/common';
2
2
  import { KeyValue } from '@angular/common';
3
- import { HttpHeaders, HttpParams, HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpClient, HttpResponse } from '@angular/common/http';
3
+ import { HttpHeaders, HttpParams, HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpClient, HttpContextToken, HttpResponse } from '@angular/common/http';
4
4
  import * as i21 from '@ngx-translate/core';
5
5
  import { TranslateService, TranslateLoader } from '@ngx-translate/core';
6
6
  import * as rxjs from 'rxjs';
@@ -29,6 +29,32 @@ declare class EndpointsAuthenticationNhCommonModuleConfig {
29
29
  impersonate: string;
30
30
  revertImpersonate: string;
31
31
  accountInformation: string;
32
+ twoFactorVerify: string;
33
+ twoFactorStatus: string;
34
+ twoFactorAuthenticator: string;
35
+ twoFactorAuthenticatorConfirm: string;
36
+ twoFactorRecoveryCodes: string;
37
+ twoFactorDisable: string;
38
+ twoFactorForgetDevices: string;
39
+ twoFactorEmailSetup: string;
40
+ twoFactorEmailConfirm: string;
41
+ twoFactorEmail: string;
42
+ twoFactorPasskeyOptions: string;
43
+ twoFactorPasskey: string;
44
+ twoFactorEnrollmentAuthenticator: string;
45
+ twoFactorEnrollmentAuthenticatorConfirm: string;
46
+ twoFactorEnrollmentEmail: string;
47
+ twoFactorEnrollmentEmailConfirm: string;
48
+ twoFactorEnrollmentPasskeyOptions: string;
49
+ twoFactorEnrollmentPasskey: string;
50
+ /** Administration route; `{userId}` is replaced with the user ID. */
51
+ twoFactorUserReset: string;
52
+ twoFactorEnrollmentReminders: string;
53
+ twoFactorSessionRevocation: string;
54
+ passkeySignInOptions: string;
55
+ passkeySignIn: string;
56
+ passkeys: string;
57
+ passkeyRegistrationOptions: string;
32
58
  constructor(init?: Partial<EndpointsAuthenticationNhCommonModuleConfig>);
33
59
  }
34
60
  declare class AuthenticationNhCommonModuleConfig {
@@ -37,6 +63,11 @@ declare class AuthenticationNhCommonModuleConfig {
37
63
  additionalDivisionClaimPermissionTypes: string[];
38
64
  endpoints: EndpointsAuthenticationNhCommonModuleConfig;
39
65
  loginPath: string;
66
+ /**
67
+ * Ends the local session when the API answers 401 and the account endpoint confirms that the
68
+ * server no longer accepts the session, for example after a password change on another device.
69
+ */
70
+ endSessionRejectedByServer: boolean;
40
71
  constructor(init?: Partial<AuthenticationNhCommonModuleConfig>);
41
72
  }
42
73
  declare class UserNotificationNhCommonModuleConfig {
@@ -419,6 +450,8 @@ declare class AuthSessionExpirationInformation {
419
450
  isAuthenticated: boolean;
420
451
  expiresWithin15MinutesOrExpired: boolean;
421
452
  displayMinutesSecondsUntilExpiration: string;
453
+ /** The server rejected the session before it expired; it stays set until the next sign-in. */
454
+ rejectedByServer: boolean;
422
455
  constructor(init?: Partial<AuthSessionExpirationInformation>);
423
456
  }
424
457
  declare class RefreshTokenLoginAccountMutateModel {
@@ -475,6 +508,8 @@ declare class AuthenticateModel {
475
508
  realm: string;
476
509
  username: string;
477
510
  password: string | undefined;
511
+ /** Remember-device token for header authentication; cookie clients send it as a cookie. */
512
+ rememberDeviceToken?: string;
478
513
  constructor(init?: Partial<AuthenticateModel>);
479
514
  }
480
515
  declare class ImpersonateAuthenticateModel {
@@ -485,6 +520,178 @@ declare class RevertImpersonateAuthenticateModel {
485
520
  constructor(init?: Partial<RevertImpersonateAuthenticateModel>);
486
521
  }
487
522
  type AuthenticationFlow = 'password' | 'microsoft-oauth' | string;
523
+ /**
524
+ * Second-factor methods a user can present after the first factor succeeded.
525
+ */
526
+ declare const NhTwoFactorMethods: {
527
+ readonly authenticator: "authenticator";
528
+ readonly recoveryCode: "recovery-code";
529
+ readonly email: "email";
530
+ readonly passkey: "passkey";
531
+ };
532
+ type NhTwoFactorMethod = typeof NhTwoFactorMethods[keyof typeof NhTwoFactorMethods] | string;
533
+ /**
534
+ * Safe failure codes returned by the two-factor endpoints. Each error item uses the code as
535
+ * its name and `nh-two-factor.<suffix>` as its translation key.
536
+ */
537
+ declare enum NhTwoFactorFailureCodes {
538
+ Required = "two-factor-required",
539
+ EnrollmentRequired = "two-factor-enrollment-required",
540
+ InvalidCode = "two-factor-invalid-code",
541
+ ChallengeExpired = "two-factor-challenge-expired",
542
+ LockedOut = "two-factor-locked-out",
543
+ MethodNotAllowed = "two-factor-method-not-allowed",
544
+ NotEnabled = "two-factor-not-enabled",
545
+ AlreadyEnabled = "two-factor-already-enabled",
546
+ SetupNotStarted = "two-factor-setup-not-started",
547
+ ReauthenticationRequired = "two-factor-reauthentication-required",
548
+ ReauthenticationFailed = "two-factor-reauthentication-failed",
549
+ RequiredByPolicy = "two-factor-required-by-policy",
550
+ NotAllowedWhileImpersonating = "two-factor-not-allowed-while-impersonating",
551
+ ConfigurationInvalid = "two-factor-configuration-invalid",
552
+ EmailCooldown = "two-factor-email-cooldown",
553
+ EmailUnavailable = "two-factor-email-unavailable",
554
+ UserNotFound = "two-factor-user-not-found",
555
+ PasskeyInvalid = "two-factor-passkey-invalid",
556
+ PasskeyNotFound = "two-factor-passkey-not-found",
557
+ /** The browser does not support passkeys or the user cancelled the passkey prompt. */
558
+ PasskeyUnavailable = "two-factor-passkey-unavailable"
559
+ }
560
+ /**
561
+ * Status values of a pending authentication step.
562
+ */
563
+ declare const NhAuthenticationStepStatuses: {
564
+ readonly twoFactorRequired: "two-factor-required";
565
+ readonly enrollmentRequired: "enrollment-required";
566
+ };
567
+ /**
568
+ * A pending sign-in step. With status `two-factor-required` the user presents a second
569
+ * factor; with `enrollment-required` the policy requires the user to enroll one first, and
570
+ * `challengeToken` is the enrollment token.
571
+ */
572
+ declare class NhTwoFactorChallenge {
573
+ status: string;
574
+ challengeToken: string;
575
+ expiresAt: string;
576
+ methods: NhTwoFactorMethod[];
577
+ /** Whether completing the challenge can remember this device for later sign-ins. */
578
+ rememberDeviceAvailable: boolean;
579
+ constructor(init?: Partial<NhTwoFactorChallenge>);
580
+ }
581
+ /**
582
+ * Login response when two-factor authentication is enabled on the server. A complete
583
+ * session has the token fields; a pending sign-in only has `twoFactor`.
584
+ */
585
+ interface NhLoginResponse {
586
+ token?: string | null;
587
+ validTo?: string | null;
588
+ refreshToken?: string | null;
589
+ refreshValidTo?: string | null;
590
+ issuer?: string | null;
591
+ twoFactor?: NhTwoFactorChallenge | null;
592
+ /** Remember-device token for header authentication, returned when the user chose to remember the device. */
593
+ rememberDeviceToken?: string | null;
594
+ }
595
+ type NhAuthenticationStepStatus = 'authenticated' | 'two-factor-required' | 'enrollment-required';
596
+ /**
597
+ * Outcome of an interactive sign-in step: the stored authorization, a second-factor
598
+ * challenge or a required enrollment.
599
+ */
600
+ declare class NhAuthenticationStep<TAuthorization extends INhAuthorization = INhAuthorization> {
601
+ status: NhAuthenticationStepStatus;
602
+ authorization?: TAuthorization;
603
+ challenge?: NhTwoFactorChallenge;
604
+ constructor(init?: Partial<NhAuthenticationStep<TAuthorization>>);
605
+ }
606
+ declare class NhTwoFactorVerifyModel {
607
+ challengeToken: string;
608
+ method: NhTwoFactorMethod;
609
+ code: string;
610
+ /** Skip the second factor on this device for later sign-ins, when the server allows it. */
611
+ rememberDevice?: boolean;
612
+ constructor(init?: Partial<NhTwoFactorVerifyModel>);
613
+ }
614
+ /**
615
+ * Proof that the signed-in user is present before a sensitive change: the current password
616
+ * or a valid second-factor code.
617
+ */
618
+ declare class NhTwoFactorReauthentication {
619
+ password?: string;
620
+ method?: NhTwoFactorMethod;
621
+ code?: string;
622
+ constructor(init?: Partial<NhTwoFactorReauthentication>);
623
+ }
624
+ declare class NhTwoFactorStatus {
625
+ enabled: boolean;
626
+ required: boolean;
627
+ methods: NhTwoFactorMethod[];
628
+ availableMethods: NhTwoFactorMethod[];
629
+ recoveryCodesLeft: number;
630
+ authenticatorSetupPending: boolean;
631
+ emailSetupPending: boolean;
632
+ rememberDeviceAvailable: boolean;
633
+ passkeyCount: number;
634
+ constructor(init?: Partial<NhTwoFactorStatus>);
635
+ }
636
+ /**
637
+ * Pending authenticator enrollment. `qrCodeDataUri` is a PNG data URI rendered by the server.
638
+ */
639
+ declare class NhAuthenticatorSetup {
640
+ sharedKey: string;
641
+ authenticatorUri: string;
642
+ qrCodeDataUri?: string;
643
+ constructor(init?: Partial<NhAuthenticatorSetup>);
644
+ }
645
+ /**
646
+ * Result of a two-factor change. Recovery codes are returned once. When the change ended
647
+ * every session, the service has already stored the renewed session for this device.
648
+ */
649
+ declare class NhTwoFactorChange {
650
+ recoveryCodes?: string[];
651
+ sessionRenewed: boolean;
652
+ constructor(init?: Partial<NhTwoFactorChange>);
653
+ }
654
+ /**
655
+ * Confirmation that the server e-mailed a code.
656
+ */
657
+ declare class NhTwoFactorEmailCodeSent {
658
+ expiresAt: string;
659
+ /** When another code can be requested. */
660
+ resendAvailableAt: string;
661
+ constructor(init?: Partial<NhTwoFactorEmailCodeSent>);
662
+ }
663
+ /**
664
+ * Result of an enrollment that the policy required during sign-in. The session is already
665
+ * stored; the recovery codes are returned once.
666
+ */
667
+ declare class NhTwoFactorEnrollmentResult<TAuthorization extends INhAuthorization = INhAuthorization> {
668
+ authorization?: TAuthorization;
669
+ recoveryCodes?: string[];
670
+ constructor(init?: Partial<NhTwoFactorEnrollmentResult<TAuthorization>>);
671
+ }
672
+ /**
673
+ * WebAuthn options from the server for one passkey ceremony. `options` is the JSON form of
674
+ * the creation or request options; `ceremonyToken` goes back with the credential.
675
+ */
676
+ declare class NhPasskeyOptions {
677
+ options: any;
678
+ ceremonyToken: string;
679
+ expiresAt: string;
680
+ constructor(init?: Partial<NhPasskeyOptions>);
681
+ }
682
+ /**
683
+ * A registered passkey. The public key is never returned.
684
+ */
685
+ declare class NhPasskey {
686
+ /** Credential ID, base64url encoded. */
687
+ id: string;
688
+ name: string;
689
+ createdAt: string;
690
+ /** Whether a passkey provider, such as a password manager, syncs the passkey. */
691
+ isBackedUp: boolean;
692
+ transports: string[];
693
+ constructor(init?: Partial<NhPasskey>);
694
+ }
488
695
 
489
696
  declare class NhUserNotificationCollectionHttpRequestOptions extends CollectionHttpRequestOptions {
490
697
  constructor(init?: Partial<NhUserNotificationCollectionHttpRequestOptions>);
@@ -1072,20 +1279,63 @@ declare class NhCookieService {
1072
1279
  static ɵprov: i0.ɵɵInjectableDeclaration<NhCookieService>;
1073
1280
  }
1074
1281
 
1282
+ /**
1283
+ * Runs WebAuthn ceremonies in the browser. The server returns the options in their JSON form
1284
+ * and expects the credential in its JSON form; this client converts both, with a fallback for
1285
+ * browsers without `PublicKeyCredential.parseCreationOptionsFromJSON` and `toJSON()`.
1286
+ */
1287
+ declare class NhPasskeyClient {
1288
+ private readonly platformId;
1289
+ /**
1290
+ * Whether the browser supports passkeys. Always false during server-side rendering.
1291
+ */
1292
+ isSupported(): boolean;
1293
+ /**
1294
+ * Creates a passkey for WebAuthn creation options and returns the credential JSON.
1295
+ * Rejects when the user cancels the prompt or the browser refuses the request.
1296
+ */
1297
+ create(options: any): Promise<object>;
1298
+ /**
1299
+ * Signs WebAuthn request options with a passkey and returns the credential JSON.
1300
+ * Rejects when the user cancels the prompt or the browser refuses the request.
1301
+ */
1302
+ get(options: any): Promise<object>;
1303
+ private ensureSupported;
1304
+ private requireCredential;
1305
+ private creationOptionsFromJSON;
1306
+ private requestOptionsFromJSON;
1307
+ private credentialToJSON;
1308
+ private static fromBase64Url;
1309
+ private static toBase64Url;
1310
+ static ɵfac: i0.ɵɵFactoryDeclaration<NhPasskeyClient, never>;
1311
+ static ɵprov: i0.ɵɵInjectableDeclaration<NhPasskeyClient>;
1312
+ }
1313
+
1314
+ /** Marks a request whose 401 must not start a server session check, such as the check itself. */
1315
+ declare const NH_SKIP_SERVER_SESSION_CHECK: HttpContextToken<boolean>;
1075
1316
  declare abstract class BaseNhAuthService<TAuthorization extends INhAuthorization> implements OnDestroy {
1317
+ protected static readonly pendingTwoFactorChallengeStorageKey = "nh-two-factor-challenge";
1318
+ protected static readonly externalTwoFactorChallengePrefix = "nh-two-factor=";
1319
+ protected static readonly rememberDeviceStorageKey = "nh-two-factor-device";
1320
+ protected static readonly serverSessionConfirmationMilliseconds = 30000;
1076
1321
  protected authorization: TAuthorization | undefined;
1322
+ protected pendingTwoFactorChallenge: NhTwoFactorChallenge | undefined;
1077
1323
  protected authSession: AuthenticationSessionCreateResponse | undefined;
1078
1324
  readonly authSubject: BehaviorSubject<TAuthorization | undefined>;
1079
1325
  protected onReady: ((value: (PromiseLike<unknown> | unknown)) => void) | undefined;
1080
1326
  readonly authReady: Promise<unknown>;
1081
1327
  protected _sessionExpirationInformation: BehaviorSubject<AuthSessionExpirationInformation>;
1082
- sessionExpirationInformationChanged: rxjs.Observable<AuthSessionExpirationInformation>;
1328
+ sessionExpirationInformationChanged: Observable<AuthSessionExpirationInformation>;
1083
1329
  protected intervalHandle: any;
1330
+ private serverSessionCheck;
1331
+ private serverSessionConfirmedAt;
1332
+ private sessionRejectedByServer;
1084
1333
  protected zone: NgZone;
1085
1334
  protected moduleConfig: NhCommonModuleConfig;
1086
1335
  protected httpClient: HttpClient;
1087
1336
  protected platformId: Object;
1088
1337
  protected requestContext: any;
1338
+ protected passkeyClient: NhPasskeyClient;
1089
1339
  constructor();
1090
1340
  dispatchSessionExpirationInformationChanged(): void;
1091
1341
  ngOnDestroy(): void;
@@ -1117,8 +1367,178 @@ declare abstract class BaseNhAuthService<TAuthorization extends INhAuthorization
1117
1367
  getAuthenticationFlow(username: string): Promise<TaskResult<AuthenticationFlow>>;
1118
1368
  getMicrosoftRedirectUrl(callbackUrl: string, username: string): Promise<TaskResult<string>>;
1119
1369
  authorizeMicrosoft(code: string, state: string): Promise<TaskResult<TAuthorization>>;
1370
+ /**
1371
+ * Signs in with username and password and stores the complete session.
1372
+ *
1373
+ * When the server requires a second factor this method fails with
1374
+ * `NhTwoFactorFailureCodes.Required` and stores nothing. Use `authenticateInteractive`
1375
+ * to receive the challenge, or read it with `getPendingTwoFactorChallenge()`.
1376
+ */
1120
1377
  authenticate(model: AuthenticateModel, loginAsUser?: boolean): Promise<TaskResult<TAuthorization>>;
1378
+ /**
1379
+ * Signs in with username and password. Returns the stored authorization, the
1380
+ * second-factor challenge or the required enrollment. A pending step is never stored as
1381
+ * an authorization.
1382
+ */
1383
+ authenticateInteractive(model: AuthenticateModel): Promise<TaskResult<NhAuthenticationStep<TAuthorization>>>;
1384
+ /**
1385
+ * Completes a second-factor challenge and stores the session.
1386
+ */
1387
+ verifyTwoFactor(model: NhTwoFactorVerifyModel): Promise<TaskResult<TAuthorization>>;
1388
+ /**
1389
+ * E-mails a sign-in code for the pending challenge when the user enrolled the e-mail factor.
1390
+ */
1391
+ sendTwoFactorEmailCode(challengeToken: string): Promise<TaskResult<NhTwoFactorEmailCodeSent>>;
1392
+ /**
1393
+ * Whether this browser can use passkeys.
1394
+ */
1395
+ isPasskeySupported(): boolean;
1396
+ /**
1397
+ * Completes the pending challenge with a passkey and stores the session.
1398
+ */
1399
+ verifyTwoFactorWithPasskey(challengeToken: string, rememberDevice?: boolean): Promise<TaskResult<TAuthorization>>;
1400
+ /**
1401
+ * Signs in with a discoverable passkey, without a username or password. Returns the
1402
+ * stored authorization, or a pending step when the server's policy asks for more.
1403
+ */
1404
+ signInWithPasskey(): Promise<TaskResult<NhAuthenticationStep<TAuthorization>>>;
1405
+ /**
1406
+ * Starts authenticator enrollment for a user whom the policy requires to enroll during
1407
+ * sign-in. `enrollmentToken` is the `challengeToken` of the enrollment step.
1408
+ */
1409
+ beginEnrollmentAuthenticatorSetup(enrollmentToken: string): Promise<TaskResult<NhAuthenticatorSetup>>;
1410
+ /**
1411
+ * Confirms the authenticator during a required enrollment and stores the session.
1412
+ */
1413
+ confirmEnrollmentAuthenticator(enrollmentToken: string, code: string): Promise<TaskResult<NhTwoFactorEnrollmentResult<TAuthorization>>>;
1414
+ /**
1415
+ * E-mails a confirmation code during a required enrollment.
1416
+ */
1417
+ sendEnrollmentEmailCode(enrollmentToken: string): Promise<TaskResult<NhTwoFactorEmailCodeSent>>;
1418
+ /**
1419
+ * Confirms the e-mail factor during a required enrollment and stores the session.
1420
+ */
1421
+ confirmEnrollmentEmail(enrollmentToken: string, code: string): Promise<TaskResult<NhTwoFactorEnrollmentResult<TAuthorization>>>;
1422
+ /**
1423
+ * Registers a passkey during a required enrollment and stores the session.
1424
+ */
1425
+ enrollPasskey(enrollmentToken: string, name?: string): Promise<TaskResult<NhTwoFactorEnrollmentResult<TAuthorization>>>;
1426
+ /**
1427
+ * Returns the pending second-factor challenge of this browser tab, if it has not expired.
1428
+ */
1429
+ getPendingTwoFactorChallenge(): NhTwoFactorChallenge | undefined;
1430
+ clearPendingTwoFactorChallenge(): void;
1431
+ /**
1432
+ * Reads a challenge that an external sign-in (Microsoft OAuth) passed back in the URL
1433
+ * fragment, stores it as the pending challenge and removes it from the address bar.
1434
+ */
1435
+ consumeExternalTwoFactorChallenge(fragment?: string): NhTwoFactorChallenge | undefined;
1436
+ getTwoFactorStatus(): Promise<TaskResult<NhTwoFactorStatus>>;
1437
+ /**
1438
+ * Starts authenticator enrollment. Restarting enrollment while two-factor authentication
1439
+ * is enabled requires reauthentication.
1440
+ */
1441
+ beginAuthenticatorSetup(reauthentication?: NhTwoFactorReauthentication): Promise<TaskResult<NhAuthenticatorSetup>>;
1442
+ /**
1443
+ * Confirms authenticator enrollment. The server ends every other session; the renewed
1444
+ * session for this device is stored before the promise resolves.
1445
+ */
1446
+ confirmAuthenticator(code: string): Promise<TaskResult<NhTwoFactorChange>>;
1447
+ regenerateRecoveryCodes(reauthentication: NhTwoFactorReauthentication): Promise<TaskResult<NhTwoFactorChange>>;
1448
+ disableTwoFactor(reauthentication: NhTwoFactorReauthentication): Promise<TaskResult<NhTwoFactorChange>>;
1449
+ /**
1450
+ * E-mails a code that confirms the user's e-mail address as a second factor. Requires
1451
+ * reauthentication while two-factor authentication is enabled.
1452
+ */
1453
+ beginEmailSetup(reauthentication?: NhTwoFactorReauthentication): Promise<TaskResult<NhTwoFactorEmailCodeSent>>;
1454
+ confirmEmailSetup(code: string): Promise<TaskResult<NhTwoFactorChange>>;
1455
+ /**
1456
+ * Forgets every remembered device, including this one, and ends every other session.
1457
+ */
1458
+ forgetTwoFactorDevices(reauthentication: NhTwoFactorReauthentication): Promise<TaskResult<NhTwoFactorChange>>;
1459
+ getPasskeys(): Promise<TaskResult<NhPasskey[]>>;
1460
+ /**
1461
+ * Registers a passkey on this device. Adding a passkey while two-factor authentication is
1462
+ * enabled requires reauthentication. The server ends every other session; the renewed
1463
+ * session for this device is stored before the promise resolves.
1464
+ */
1465
+ registerPasskey(name?: string, reauthentication?: NhTwoFactorReauthentication): Promise<TaskResult<NhTwoFactorChange>>;
1466
+ renamePasskey(passkeyId: string, name: string): Promise<TaskResult<void>>;
1467
+ /**
1468
+ * Removes a passkey. Removing the last second factor disables two-factor authentication,
1469
+ * which fails when the policy requires it.
1470
+ */
1471
+ removePasskey(passkeyId: string, reauthentication: NhTwoFactorReauthentication): Promise<TaskResult<NhTwoFactorChange>>;
1472
+ /**
1473
+ * Removes every second factor of another user who lost access to them. Requires the
1474
+ * server's two-factor administration policy.
1475
+ */
1476
+ resetUserTwoFactor(userId: string): Promise<TaskResult<void>>;
1477
+ /**
1478
+ * Starts a background operation that reminds every user whom the policy requires to
1479
+ * enroll. A repeated idempotency key returns the operation that was already started.
1480
+ */
1481
+ startTwoFactorEnrollmentReminders(idempotencyKey: string): Promise<TaskResult<NhBackgroundOperation>>;
1482
+ /**
1483
+ * Starts a background operation that ends the sessions of every user whom the policy
1484
+ * requires to enroll, so their next sign-in enrolls them.
1485
+ */
1486
+ startTwoFactorSessionRevocation(idempotencyKey: string): Promise<TaskResult<NhBackgroundOperation>>;
1487
+ protected sendTwoFactorChange(endpoint: string, body: object): Promise<TaskResult<NhTwoFactorChange>>;
1488
+ /**
1489
+ * Stores the session that the server issued for this device after a change that ended
1490
+ * every session. The user, claims and divisions of the current authorization are kept.
1491
+ */
1492
+ protected applyRenewedSession(session: NhLoginResponse | null | undefined): boolean;
1493
+ protected toAuthorization(response: NhLoginResponse): TAuthorization;
1494
+ /**
1495
+ * Stores a complete session, or keeps a second-factor challenge or enrollment as the
1496
+ * pending step of this browser tab.
1497
+ */
1498
+ protected completeAuthenticationStep(response: NhLoginResponse): NhAuthenticationStep<TAuthorization>;
1499
+ /**
1500
+ * Converts a failed challenge or enrollment request and forgets the pending step when the
1501
+ * server ended it.
1502
+ */
1503
+ protected pendingStepFailed(ex: unknown): TaskResult<unknown>;
1504
+ protected sendEnrollmentCompletion(endpoint: string, body: object): Promise<TaskResult<NhTwoFactorEnrollmentResult<TAuthorization>>>;
1505
+ protected sendTwoFactorRequest<TResponse, TResult>(request$: Observable<TResponse>, map: (response: TResponse) => TResult): Promise<TaskResult<TResult>>;
1506
+ /**
1507
+ * Runs a WebAuthn prompt. A cancelled prompt or an unsupported browser becomes a failed
1508
+ * result with `NhTwoFactorFailureCodes.PasskeyUnavailable`.
1509
+ */
1510
+ protected runPasskeyCeremony(ceremony: () => Promise<object>): Promise<TaskResult<object>>;
1511
+ /**
1512
+ * Returns the remember-device token of header clients. Cookie clients receive it as an
1513
+ * HttpOnly cookie, so nothing is stored in the browser.
1514
+ */
1515
+ protected getRememberDeviceToken(): string | undefined;
1516
+ protected storeRememberDeviceToken(token: string | undefined): void;
1517
+ protected rememberDeviceStorageKey(): string;
1518
+ protected setPendingTwoFactorChallenge(challenge: NhTwoFactorChallenge): void;
1519
+ protected readStoredTwoFactorChallenge(): NhTwoFactorChallenge | undefined;
1520
+ protected twoFactorEndpoints(): EndpointsAuthenticationNhCommonModuleConfig;
1521
+ protected twoFactorUrl(endpoint: string): string;
1522
+ protected twoFactorStepRequestOptions(): {
1523
+ params: HttpParams;
1524
+ withCredentials: boolean;
1525
+ };
1526
+ protected twoFactorAccountRequestOptions(): {
1527
+ params: HttpParams;
1528
+ headers: HttpHeaders;
1529
+ withCredentials: boolean;
1530
+ };
1531
+ protected languageParams(): HttpParams;
1121
1532
  reloadAuthorizationProfile(): Promise<TaskResult<TAuthorization>>;
1533
+ /**
1534
+ * Asks the account information endpoint whether the server still accepts the current session.
1535
+ * When the server answers 401, for example after a password change on another device, the local
1536
+ * session ends and the session expiration information reports `rejectedByServer`. Concurrent
1537
+ * checks share one request, and a confirmed session is not checked again for 30 seconds.
1538
+ * @returns `false` only when there is no session or the server rejected it.
1539
+ */
1540
+ verifyServerSession(): Promise<boolean>;
1541
+ protected checkServerSession(): Promise<boolean>;
1122
1542
  logout(): Promise<TaskResult<void>>;
1123
1543
  authenticateRefreshToken(model: RefreshTokenLoginAccountMutateModel): Promise<TaskResult<TAuthorization>>;
1124
1544
  impersonate(model: ImpersonateAuthenticateModel): Promise<TaskResult<TAuthorization>>;
@@ -1165,6 +1585,23 @@ declare class NhDeduplicateGetRequestsInterceptor implements HttpInterceptor {
1165
1585
  static ɵprov: i0.ɵɵInjectableDeclaration<NhDeduplicateGetRequestsInterceptor>;
1166
1586
  }
1167
1587
 
1588
+ /**
1589
+ * Ends a session that the NewHeap API no longer accepts. A 401 from the API while the browser
1590
+ * still holds a session asks the auth service to check that session with the server. Only a 401
1591
+ * from the account endpoint ends it, so an endpoint that answers 401 for another reason never
1592
+ * signs the user out. The original error still reaches the caller.
1593
+ */
1594
+ declare class NhSessionRejectionInterceptor implements HttpInterceptor {
1595
+ private moduleConfig;
1596
+ private authService;
1597
+ constructor(moduleConfig: NhCommonModuleConfig, authService: NhAuthService);
1598
+ intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
1599
+ private appliesTo;
1600
+ private isUnder;
1601
+ static ɵfac: i0.ɵɵFactoryDeclaration<NhSessionRejectionInterceptor, never>;
1602
+ static ɵprov: i0.ɵɵInjectableDeclaration<NhSessionRejectionInterceptor>;
1603
+ }
1604
+
1168
1605
  declare abstract class AbstractValueAccessor implements ControlValueAccessor {
1169
1606
  _value: any;
1170
1607
  get value(): any;
@@ -2635,5 +3072,5 @@ declare class NhTranslateBrowserLoader implements TranslateLoader {
2635
3072
  }
2636
3073
  declare function nhTranslateBrowserLoaderFactory(httpClient: HttpClient, transferState: TransferState): NhTranslateBrowserLoader;
2637
3074
 
2638
- export { AbstractValueAccessor, AspMvcFormServerSideFormValidator, AuthSessionExpirationInformation, AuthenticateModel, AuthenticationNhCommonModuleConfig, AuthenticationSessionCreateResponse, BackgroundOperationsNhCommonModuleConfig, BaseNhAuthService, CheckAuthenticateSessionModel, Claim, ClaimAuthenticateSessionAccountMutateModel, ClaimAuthenticateSessionAccountViewModel, ClaimTypes, CollectionHttpRequestOptions, CollectionHttpResponse, DefaultMultiSelectSettings, DefaultMultiSelectTexts, EndpointsAuthenticationNhCommonModuleConfig, FilterRequestOptions, FormError, FormValidationResult, HttpDownloadRequestOptions, HttpRequestOptions, HttpRequestOptionsArrayBuffer, HttpRequestOptionsText, ImpersonateAuthenticateModel, IsAllPermissionsGrantedPipe, IsAuthenticatedPipe, IsClaimGrantedPipe, IsDefined, IsGrantedRolePipe, IsOneActiveDivisionPermissionGrantedGuard, IsOneActiveDivisionPermissionGrantedPipe, IsOneActiveDivisionRoleGrantedGuard, IsOneActiveDivisionRoleGrantedPipe, IsOneClaimGrantedPipe, IsOneDivisionPermissionGrantedPipe, IsOneDivisionRoleGrantedPipe, IsOnePermissionGrantedPipe, IsOneRoleGrantedPipe, JsonLdDataChanged, ListSortDirection, MakeProvider, MutationType, NH_ERROR_HANDLERS, NH_ROUTER_LANGUAGE_CHANGE_METHOD, NH_ROUTER_ROOT_ROUTES, NhAccountInformationResponse, NhAngularUtil, NhApiService, NhApiUtil, NhAppService, NhAsyncLock, NhAuthService, NhAuthorization, NhBackgroundOperationAdministrationCollectionHttpRequestOptions, NhBackgroundOperationAdministrationService, NhBackgroundOperationCollectionHttpRequestOptions, NhBackgroundOperationLiveUpdateService, NhBackgroundOperationProgressComponent, NhBackgroundOperationService, NhBackgroundOperationStore, NhBaseApiService, NhBooleanToStringPipe, NhBreadCrumb, NhBreadCrumbItem, NhButtonDebounceDirective, NhCanCancelNavigationGuard, NhCollectionBaseComponent, NhCollectionTypeBaseComponent, NhCommonConfig, NhCommonConfigChanged, NhCommonModule, NhCommonModuleConfig, NhConfigCommonService, NhContextMenu, NhContextMenuItem, NhContextMenuService, NhContextMenuServiceConfig, NhCookieService, NhDatePipe, NhDateTimePipe, NhDateUtcPipe, NhDebounceDirective, NhDeduplicateGetRequestsInterceptor, NhDivision, NhDivisionRole, NhDivisionUser, NhEncodeHttpParamsInterceptor, NhEncodingUtil, NhErrorComponent, NhErrorHandlerService, NhFormDropDownComponent, NhFormDropDownNhCommonModuleConfig, NhFormDropDownSettings, NhFormErrorMessageComponent, NhFormHelper, NhHeadService, NhHttpNhCommonModuleConfig, NhHttpUtil, NhInternetConnectionService, NhIsAllPermissionsGrantedGuard, NhIsAuthenticatedGuard, NhIsOneClaimGrantedGuard, NhIsOnePermissionGrantedGuard, NhIsOneRoleGrantedGuard, NhJsonLdComponent, NhJsonLdData, NhJsonLdDataItem, NhJsonLdService, NhLoaderComponent, NhMetaService, NhModalComponent, NhModalComponentClosed, NhModalComponentImpl, NhModalComponentRef, NhModalConfirmComponent, NhModalContentDirective, NhModalLoadingComponent, NhModalMutateBaseComponent, NhModalMutateBaseTypeComponent, NhModalOptions, NhModalService, NhMutateBaseComponent, NhMutateBaseTypeComponent, NhMutex, NhPageBaseComponent, NhPageService, NhPageSettings, NhPageSizeComponent, NhPageTypeBaseComponent, NhRegisterRoute, NhRequestScopedServerHttpInterceptorService, NhRoute, NhRouteInfo, NhRouteNavigationItem, NhRouterLinkDirective, NhRouterService, NhRouterSetupService, NhSearchInputComponent, NhServerHttpInterceptor, NhServerService, NhServerSideFormValidationService, NhSitemap, NhSitemapEntry, NhSitemapEntryItem, NhStringUtil, NhTaskResultFormValidationService, NhTitleService, NhToHeadDirective, NhTranslateBrowserLoader, NhTranslationNhCommonModuleConfig, NhTypedPageBaseComponent, NhTypedPageTypeBaseComponent, NhUrlEncodePipe, NhUser, NhUserNotification, NhUserNotificationCollectionHttpRequestOptions, NhUserNotificationData, NhUserNotificationMessage, NhUserNotificationOverview, NhUserNotificationService, NhUserNotificationState, NhUserNotificationsAbstractComponent, OrderByRequestOptions, PreConnectUrlItem, PreLoadUrlItem, REVIEW_AGGREGATE_RATING_KEY, REVIEW_KEY, RefreshTokenLoginAccountMutateModel, RevertImpersonateAuthenticateModel, SafeHtmlPipe, SafeResourceUrlPipe, SafeUrlPipe, SearchableCollectionHttpRequestOptions, SimpleCollectionHttpRequestOptions, SimpleCollectionHttpResponse, TaskResult, TaskResultItem, TypedNhPageSettings, UserNotificationNhCommonModuleConfig, enumIntValuesToArray, enumKeysToArray, enumStringValuesToArray, enumValuesToArray, getEmptyGuid, getRandomIdentifier, groupBy, languageToCultureMap, nameof, nhBackgroundOperationStatusName, nhBackgroundOperationStepStatusName, nhBackgroundOperationTranslationSegment, nhTranslateBrowserLoaderFactory, nhUserNotificationSeverityName, uppercaseFirst };
2639
- export type { AuthenticationFlow, ErrorResult, ICancelNavigationComponent, IClaimAuthenticateSessionAccountViewModel, ICollectionHttpRequestOptions, ICollectionHttpResponse, IFormError, IFormValidationResult, IHttpDownloadRequestOptions, IHttpRequestOptions, INhAccountInformationResponse, INhAuthorization, INhDivision, INhDivisionRole, INhDivisionUser, INhModalComponent, INhUser, ISearchableCollectionHttpRequestOptions, IServerSideFormValidationService, IServerSideFormValidator, ISimpleCollectionHttpRequestOptions, ISimpleCollectionHttpResponse, NhBackgroundOperation, NhBackgroundOperationAdministration, NhBackgroundOperationAggregationMode, NhBackgroundOperationAttempt, NhBackgroundOperationAttemptStatus, NhBackgroundOperationChanged, NhBackgroundOperationChild, NhBackgroundOperationConnectionState, NhBackgroundOperationEvent, NhBackgroundOperationEventType, NhBackgroundOperationMessageSeverity, NhBackgroundOperationStatus, NhBackgroundOperationStep, NhBackgroundOperationStepStatus, NhContextEventWithCoordinates, NhEnumDropDownItem, NhRouterLink, NhUserNotificationSeverity, SuccessResult, TypedResult };
3075
+ export { AbstractValueAccessor, AspMvcFormServerSideFormValidator, AuthSessionExpirationInformation, AuthenticateModel, AuthenticationNhCommonModuleConfig, AuthenticationSessionCreateResponse, BackgroundOperationsNhCommonModuleConfig, BaseNhAuthService, CheckAuthenticateSessionModel, Claim, ClaimAuthenticateSessionAccountMutateModel, ClaimAuthenticateSessionAccountViewModel, ClaimTypes, CollectionHttpRequestOptions, CollectionHttpResponse, DefaultMultiSelectSettings, DefaultMultiSelectTexts, EndpointsAuthenticationNhCommonModuleConfig, FilterRequestOptions, FormError, FormValidationResult, HttpDownloadRequestOptions, HttpRequestOptions, HttpRequestOptionsArrayBuffer, HttpRequestOptionsText, ImpersonateAuthenticateModel, IsAllPermissionsGrantedPipe, IsAuthenticatedPipe, IsClaimGrantedPipe, IsDefined, IsGrantedRolePipe, IsOneActiveDivisionPermissionGrantedGuard, IsOneActiveDivisionPermissionGrantedPipe, IsOneActiveDivisionRoleGrantedGuard, IsOneActiveDivisionRoleGrantedPipe, IsOneClaimGrantedPipe, IsOneDivisionPermissionGrantedPipe, IsOneDivisionRoleGrantedPipe, IsOnePermissionGrantedPipe, IsOneRoleGrantedPipe, JsonLdDataChanged, ListSortDirection, MakeProvider, MutationType, NH_ERROR_HANDLERS, NH_ROUTER_LANGUAGE_CHANGE_METHOD, NH_ROUTER_ROOT_ROUTES, NH_SKIP_SERVER_SESSION_CHECK, NhAccountInformationResponse, NhAngularUtil, NhApiService, NhApiUtil, NhAppService, NhAsyncLock, NhAuthService, NhAuthenticationStep, NhAuthenticationStepStatuses, NhAuthenticatorSetup, NhAuthorization, NhBackgroundOperationAdministrationCollectionHttpRequestOptions, NhBackgroundOperationAdministrationService, NhBackgroundOperationCollectionHttpRequestOptions, NhBackgroundOperationLiveUpdateService, NhBackgroundOperationProgressComponent, NhBackgroundOperationService, NhBackgroundOperationStore, NhBaseApiService, NhBooleanToStringPipe, NhBreadCrumb, NhBreadCrumbItem, NhButtonDebounceDirective, NhCanCancelNavigationGuard, NhCollectionBaseComponent, NhCollectionTypeBaseComponent, NhCommonConfig, NhCommonConfigChanged, NhCommonModule, NhCommonModuleConfig, NhConfigCommonService, NhContextMenu, NhContextMenuItem, NhContextMenuService, NhContextMenuServiceConfig, NhCookieService, NhDatePipe, NhDateTimePipe, NhDateUtcPipe, NhDebounceDirective, NhDeduplicateGetRequestsInterceptor, NhDivision, NhDivisionRole, NhDivisionUser, NhEncodeHttpParamsInterceptor, NhEncodingUtil, NhErrorComponent, NhErrorHandlerService, NhFormDropDownComponent, NhFormDropDownNhCommonModuleConfig, NhFormDropDownSettings, NhFormErrorMessageComponent, NhFormHelper, NhHeadService, NhHttpNhCommonModuleConfig, NhHttpUtil, NhInternetConnectionService, NhIsAllPermissionsGrantedGuard, NhIsAuthenticatedGuard, NhIsOneClaimGrantedGuard, NhIsOnePermissionGrantedGuard, NhIsOneRoleGrantedGuard, NhJsonLdComponent, NhJsonLdData, NhJsonLdDataItem, NhJsonLdService, NhLoaderComponent, NhMetaService, NhModalComponent, NhModalComponentClosed, NhModalComponentImpl, NhModalComponentRef, NhModalConfirmComponent, NhModalContentDirective, NhModalLoadingComponent, NhModalMutateBaseComponent, NhModalMutateBaseTypeComponent, NhModalOptions, NhModalService, NhMutateBaseComponent, NhMutateBaseTypeComponent, NhMutex, NhPageBaseComponent, NhPageService, NhPageSettings, NhPageSizeComponent, NhPageTypeBaseComponent, NhPasskey, NhPasskeyClient, NhPasskeyOptions, NhRegisterRoute, NhRequestScopedServerHttpInterceptorService, NhRoute, NhRouteInfo, NhRouteNavigationItem, NhRouterLinkDirective, NhRouterService, NhRouterSetupService, NhSearchInputComponent, NhServerHttpInterceptor, NhServerService, NhServerSideFormValidationService, NhSessionRejectionInterceptor, NhSitemap, NhSitemapEntry, NhSitemapEntryItem, NhStringUtil, NhTaskResultFormValidationService, NhTitleService, NhToHeadDirective, NhTranslateBrowserLoader, NhTranslationNhCommonModuleConfig, NhTwoFactorChallenge, NhTwoFactorChange, NhTwoFactorEmailCodeSent, NhTwoFactorEnrollmentResult, NhTwoFactorFailureCodes, NhTwoFactorMethods, NhTwoFactorReauthentication, NhTwoFactorStatus, NhTwoFactorVerifyModel, NhTypedPageBaseComponent, NhTypedPageTypeBaseComponent, NhUrlEncodePipe, NhUser, NhUserNotification, NhUserNotificationCollectionHttpRequestOptions, NhUserNotificationData, NhUserNotificationMessage, NhUserNotificationOverview, NhUserNotificationService, NhUserNotificationState, NhUserNotificationsAbstractComponent, OrderByRequestOptions, PreConnectUrlItem, PreLoadUrlItem, REVIEW_AGGREGATE_RATING_KEY, REVIEW_KEY, RefreshTokenLoginAccountMutateModel, RevertImpersonateAuthenticateModel, SafeHtmlPipe, SafeResourceUrlPipe, SafeUrlPipe, SearchableCollectionHttpRequestOptions, SimpleCollectionHttpRequestOptions, SimpleCollectionHttpResponse, TaskResult, TaskResultItem, TypedNhPageSettings, UserNotificationNhCommonModuleConfig, enumIntValuesToArray, enumKeysToArray, enumStringValuesToArray, enumValuesToArray, getEmptyGuid, getRandomIdentifier, groupBy, languageToCultureMap, nameof, nhBackgroundOperationStatusName, nhBackgroundOperationStepStatusName, nhBackgroundOperationTranslationSegment, nhTranslateBrowserLoaderFactory, nhUserNotificationSeverityName, uppercaseFirst };
3076
+ export type { AuthenticationFlow, ErrorResult, ICancelNavigationComponent, IClaimAuthenticateSessionAccountViewModel, ICollectionHttpRequestOptions, ICollectionHttpResponse, IFormError, IFormValidationResult, IHttpDownloadRequestOptions, IHttpRequestOptions, INhAccountInformationResponse, INhAuthorization, INhDivision, INhDivisionRole, INhDivisionUser, INhModalComponent, INhUser, ISearchableCollectionHttpRequestOptions, IServerSideFormValidationService, IServerSideFormValidator, ISimpleCollectionHttpRequestOptions, ISimpleCollectionHttpResponse, NhAuthenticationStepStatus, NhBackgroundOperation, NhBackgroundOperationAdministration, NhBackgroundOperationAggregationMode, NhBackgroundOperationAttempt, NhBackgroundOperationAttemptStatus, NhBackgroundOperationChanged, NhBackgroundOperationChild, NhBackgroundOperationConnectionState, NhBackgroundOperationEvent, NhBackgroundOperationEventType, NhBackgroundOperationMessageSeverity, NhBackgroundOperationStatus, NhBackgroundOperationStep, NhBackgroundOperationStepStatus, NhContextEventWithCoordinates, NhEnumDropDownItem, NhLoginResponse, NhRouterLink, NhTwoFactorMethod, NhUserNotificationSeverity, SuccessResult, TypedResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newheap/platform-common",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20.3.28",
6
6
  "@angular/core": "^20.3.28",
@@ -22,6 +22,22 @@
22
22
  "tslib": "^2.3.0"
23
23
  },
24
24
  "sideEffects": true,
25
+ "exports": {
26
+ "./two-factor/i18n/*.json": {
27
+ "default": "./two-factor/i18n/*.json"
28
+ },
29
+ "./package.json": {
30
+ "default": "./package.json"
31
+ },
32
+ ".": {
33
+ "types": "./index.d.ts",
34
+ "default": "./fesm2022/newheap-platform-common.mjs"
35
+ },
36
+ "./two-factor": {
37
+ "types": "./two-factor/index.d.ts",
38
+ "default": "./fesm2022/newheap-platform-common-two-factor.mjs"
39
+ }
40
+ },
25
41
  "license": "Apache-2.0",
26
42
  "description": "Shared Angular components, services and application infrastructure for NewHeap applications.",
27
43
  "repository": {
@@ -37,14 +53,5 @@
37
53
  "access": "public"
38
54
  },
39
55
  "module": "fesm2022/newheap-platform-common.mjs",
40
- "typings": "index.d.ts",
41
- "exports": {
42
- "./package.json": {
43
- "default": "./package.json"
44
- },
45
- ".": {
46
- "types": "./index.d.ts",
47
- "default": "./fesm2022/newheap-platform-common.mjs"
48
- }
49
- }
56
+ "typings": "index.d.ts"
50
57
  }