@nauth-toolkit/client 0.1.18 → 0.1.22
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/dist/angular/index.cjs +381 -166
- package/dist/angular/index.cjs.map +1 -1
- package/dist/angular/index.d.mts +331 -127
- package/dist/angular/index.d.ts +331 -127
- package/dist/angular/index.mjs +380 -165
- package/dist/angular/index.mjs.map +1 -1
- package/dist/index.cjs +60 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +65 -72
- package/dist/index.d.ts +65 -72
- package/dist/index.mjs +60 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/angular/index.d.mts
CHANGED
|
@@ -21,6 +21,13 @@ interface AuthUser {
|
|
|
21
21
|
mfaEnabled?: boolean;
|
|
22
22
|
socialProviders?: string[] | null;
|
|
23
23
|
hasPasswordHash: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Authentication method used to create the current session.
|
|
26
|
+
*
|
|
27
|
+
* This is session-scoped (how the user logged in this time), not an account capability.
|
|
28
|
+
* Use `hasPasswordHash` and `socialProviders` to determine what login methods the account supports.
|
|
29
|
+
*/
|
|
30
|
+
sessionAuthMethod?: string | null;
|
|
24
31
|
createdAt?: string | Date;
|
|
25
32
|
updatedAt?: string | Date;
|
|
26
33
|
}
|
|
@@ -137,6 +144,10 @@ interface NAuthStorageAdapter {
|
|
|
137
144
|
* Remove a stored value.
|
|
138
145
|
*/
|
|
139
146
|
removeItem(key: string): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Clear all stored values.
|
|
149
|
+
*/
|
|
150
|
+
clear(): Promise<void>;
|
|
140
151
|
}
|
|
141
152
|
|
|
142
153
|
/**
|
|
@@ -259,12 +270,12 @@ interface NAuthEndpoints {
|
|
|
259
270
|
mfaPreferred: string;
|
|
260
271
|
mfaBackupCodes: string;
|
|
261
272
|
mfaExemption: string;
|
|
262
|
-
socialAuthUrl: string;
|
|
263
|
-
socialCallback: string;
|
|
264
273
|
socialLinked: string;
|
|
265
274
|
socialLink: string;
|
|
266
275
|
socialUnlink: string;
|
|
267
276
|
socialVerify: string;
|
|
277
|
+
socialRedirectStart: string;
|
|
278
|
+
socialExchange: string;
|
|
268
279
|
trustDevice: string;
|
|
269
280
|
isTrustedDevice: string;
|
|
270
281
|
auditHistory: string;
|
|
@@ -409,6 +420,17 @@ interface MFAStatus {
|
|
|
409
420
|
mfaExemptReason: string | null;
|
|
410
421
|
mfaExemptGrantedAt: string | Date | null;
|
|
411
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* MFA device information.
|
|
425
|
+
*/
|
|
426
|
+
interface MFADevice {
|
|
427
|
+
id: number;
|
|
428
|
+
type: MFADeviceMethod;
|
|
429
|
+
name: string;
|
|
430
|
+
isPrimary: boolean;
|
|
431
|
+
isActive: boolean;
|
|
432
|
+
createdAt: string | Date;
|
|
433
|
+
}
|
|
412
434
|
/**
|
|
413
435
|
* Response from getSetupData API call.
|
|
414
436
|
* Contains provider-specific MFA setup information.
|
|
@@ -441,6 +463,16 @@ interface AuthResponse {
|
|
|
441
463
|
refreshToken?: string;
|
|
442
464
|
accessTokenExpiresAt?: number;
|
|
443
465
|
refreshTokenExpiresAt?: number;
|
|
466
|
+
/**
|
|
467
|
+
* Authentication method used to create the current session.
|
|
468
|
+
*
|
|
469
|
+
* Examples:
|
|
470
|
+
* - `password`
|
|
471
|
+
* - `google`
|
|
472
|
+
* - `apple`
|
|
473
|
+
* - `facebook`
|
|
474
|
+
*/
|
|
475
|
+
authMethod?: string;
|
|
444
476
|
trusted?: boolean;
|
|
445
477
|
deviceToken?: string;
|
|
446
478
|
challengeName?: AuthChallenge;
|
|
@@ -759,19 +791,28 @@ type AuthEventListener = (event: AuthEvent) => void;
|
|
|
759
791
|
*/
|
|
760
792
|
type SocialProvider = 'google' | 'apple' | 'facebook';
|
|
761
793
|
/**
|
|
762
|
-
*
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
}
|
|
768
|
-
/**
|
|
769
|
-
* Social callback parameters.
|
|
794
|
+
* Options for starting a redirect-first social login flow.
|
|
795
|
+
*
|
|
796
|
+
* This is a web-first API:
|
|
797
|
+
* - Browser navigates to backend `/auth/social/:provider/redirect`
|
|
798
|
+
* - Backend completes OAuth, sets cookies (or returns exchange token), and redirects back
|
|
770
799
|
*/
|
|
771
|
-
interface
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
800
|
+
interface SocialLoginOptions {
|
|
801
|
+
/**
|
|
802
|
+
* Frontend route (recommended) or URL to redirect to after the backend callback completes.
|
|
803
|
+
* Default: config.redirects.success || '/'
|
|
804
|
+
*/
|
|
805
|
+
returnTo?: string;
|
|
806
|
+
/**
|
|
807
|
+
* Optional application state to round-trip back to the frontend.
|
|
808
|
+
* Must be treated as non-secret.
|
|
809
|
+
*/
|
|
810
|
+
appState?: string;
|
|
811
|
+
/**
|
|
812
|
+
* Optional flow action.
|
|
813
|
+
* Default: 'login'
|
|
814
|
+
*/
|
|
815
|
+
action?: 'login' | 'link';
|
|
775
816
|
}
|
|
776
817
|
/**
|
|
777
818
|
* Linked social accounts response.
|
|
@@ -1056,69 +1097,36 @@ declare class NAuthClient {
|
|
|
1056
1097
|
*/
|
|
1057
1098
|
off(event: AuthEventType | '*', listener: AuthEventListener): void;
|
|
1058
1099
|
/**
|
|
1059
|
-
* Start social OAuth flow
|
|
1100
|
+
* Start redirect-first social OAuth flow (web).
|
|
1060
1101
|
*
|
|
1061
|
-
*
|
|
1062
|
-
*
|
|
1102
|
+
* This performs a browser navigation to:
|
|
1103
|
+
* `GET {baseUrl}/social/:provider/redirect?returnTo=...&appState=...`
|
|
1104
|
+
*
|
|
1105
|
+
* The backend:
|
|
1106
|
+
* - generates and stores CSRF state (cluster-safe)
|
|
1107
|
+
* - redirects the user to the provider
|
|
1108
|
+
* - completes OAuth on callback and sets cookies (or issues an exchange token)
|
|
1109
|
+
* - redirects back to `returnTo` with `appState` (and `exchangeToken` for json/hybrid)
|
|
1063
1110
|
*
|
|
1064
1111
|
* @param provider - OAuth provider ('google', 'apple', 'facebook')
|
|
1065
|
-
* @param options - Optional
|
|
1112
|
+
* @param options - Optional redirect options
|
|
1066
1113
|
*
|
|
1067
1114
|
* @example
|
|
1068
1115
|
* ```typescript
|
|
1069
|
-
*
|
|
1070
|
-
* await client.loginWithSocial('google');
|
|
1071
|
-
*
|
|
1072
|
-
* // With custom redirect URI
|
|
1073
|
-
* await client.loginWithSocial('apple', {
|
|
1074
|
-
* redirectUri: 'https://example.com/auth/callback'
|
|
1075
|
-
* });
|
|
1116
|
+
* await client.loginWithSocial('google', { returnTo: '/auth/callback', appState: '12345' });
|
|
1076
1117
|
* ```
|
|
1077
1118
|
*/
|
|
1078
|
-
loginWithSocial(provider: SocialProvider,
|
|
1079
|
-
redirectUri?: string;
|
|
1080
|
-
}): Promise<void>;
|
|
1119
|
+
loginWithSocial(provider: SocialProvider, options?: SocialLoginOptions): Promise<void>;
|
|
1081
1120
|
/**
|
|
1082
|
-
*
|
|
1121
|
+
* Exchange an `exchangeToken` (from redirect callback URL) into an AuthResponse.
|
|
1083
1122
|
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
* The SDK validates the state token, completes authentication via backend,
|
|
1088
|
-
* and emits appropriate events.
|
|
1089
|
-
*
|
|
1090
|
-
* @param urlOrParams - Optional URL string or URLSearchParams (auto-detects from window.location if not provided)
|
|
1091
|
-
* @returns AuthResponse if OAuth callback detected, null otherwise
|
|
1092
|
-
*
|
|
1093
|
-
* @example
|
|
1094
|
-
* ```typescript
|
|
1095
|
-
* // Auto-detect on app init
|
|
1096
|
-
* const response = await client.handleOAuthCallback();
|
|
1097
|
-
* if (response) {
|
|
1098
|
-
* if (response.challengeName) {
|
|
1099
|
-
* router.navigate(['/challenge', response.challengeName]);
|
|
1100
|
-
* } else {
|
|
1101
|
-
* router.navigate(['/']); // Navigate to your app's home route
|
|
1102
|
-
* }
|
|
1103
|
-
* }
|
|
1123
|
+
* Used for `tokenDelivery: 'json'` or hybrid flows where the backend redirects back
|
|
1124
|
+
* with `exchangeToken` instead of setting cookies.
|
|
1104
1125
|
*
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1107
|
-
* ```
|
|
1108
|
-
*/
|
|
1109
|
-
handleOAuthCallback(urlOrParams?: string | URLSearchParams): Promise<AuthResponse | null>;
|
|
1110
|
-
/**
|
|
1111
|
-
* Get social auth URL (low-level API).
|
|
1112
|
-
*
|
|
1113
|
-
* For most cases, use `loginWithSocial()` which handles state management automatically.
|
|
1126
|
+
* @param exchangeToken - One-time exchange token from the callback URL
|
|
1127
|
+
* @returns AuthResponse
|
|
1114
1128
|
*/
|
|
1115
|
-
|
|
1116
|
-
url: string;
|
|
1117
|
-
}>;
|
|
1118
|
-
/**
|
|
1119
|
-
* Handle social callback.
|
|
1120
|
-
*/
|
|
1121
|
-
handleSocialCallback(request: SocialCallbackRequest): Promise<AuthResponse>;
|
|
1129
|
+
exchangeSocialRedirect(exchangeToken: string): Promise<AuthResponse>;
|
|
1122
1130
|
/**
|
|
1123
1131
|
* Verify native social token (mobile).
|
|
1124
1132
|
*/
|
|
@@ -1297,12 +1305,15 @@ declare class NAuthClient {
|
|
|
1297
1305
|
/**
|
|
1298
1306
|
* Angular wrapper around NAuthClient that exposes Observables for auth state.
|
|
1299
1307
|
*
|
|
1300
|
-
* Design philosophy: Keep lean, use getClient() for full API access.
|
|
1301
1308
|
* This service provides:
|
|
1302
1309
|
* - Reactive state (currentUser$, isAuthenticated$, challenge$)
|
|
1303
|
-
* -
|
|
1310
|
+
* - All core auth methods as Observables (login, signup, logout, refresh)
|
|
1311
|
+
* - Profile management (getProfile, updateProfile, changePassword)
|
|
1304
1312
|
* - Challenge flow methods (respondToChallenge, resendCode)
|
|
1305
|
-
* -
|
|
1313
|
+
* - MFA management (getMfaStatus, setupMfaDevice, etc.)
|
|
1314
|
+
* - Social authentication and account linking
|
|
1315
|
+
* - Device trust management
|
|
1316
|
+
* - Audit history
|
|
1306
1317
|
*
|
|
1307
1318
|
* @example
|
|
1308
1319
|
* ```typescript
|
|
@@ -1315,8 +1326,12 @@ declare class NAuthClient {
|
|
|
1315
1326
|
* // Auth operations
|
|
1316
1327
|
* this.auth.login(email, password).subscribe(response => ...);
|
|
1317
1328
|
*
|
|
1318
|
-
* //
|
|
1319
|
-
* this.auth.
|
|
1329
|
+
* // Profile management
|
|
1330
|
+
* this.auth.changePassword(oldPassword, newPassword).subscribe(() => ...);
|
|
1331
|
+
* this.auth.updateProfile({ firstName: 'John' }).subscribe(user => ...);
|
|
1332
|
+
*
|
|
1333
|
+
* // MFA operations
|
|
1334
|
+
* this.auth.getMfaStatus().subscribe(status => ...);
|
|
1320
1335
|
* ```
|
|
1321
1336
|
*/
|
|
1322
1337
|
declare class AuthService {
|
|
@@ -1401,6 +1416,20 @@ declare class AuthService {
|
|
|
1401
1416
|
* Refresh tokens.
|
|
1402
1417
|
*/
|
|
1403
1418
|
refresh(): Observable<TokenResponse>;
|
|
1419
|
+
/**
|
|
1420
|
+
* Refresh tokens (promise-based).
|
|
1421
|
+
*
|
|
1422
|
+
* Returns a promise instead of an Observable, matching the core NAuthClient API.
|
|
1423
|
+
* Useful for async/await patterns in guards and interceptors.
|
|
1424
|
+
*
|
|
1425
|
+
* @returns Promise of TokenResponse
|
|
1426
|
+
*
|
|
1427
|
+
* @example
|
|
1428
|
+
* ```typescript
|
|
1429
|
+
* const tokens = await auth.refreshTokensPromise();
|
|
1430
|
+
* ```
|
|
1431
|
+
*/
|
|
1432
|
+
refreshTokensPromise(): Promise<TokenResponse>;
|
|
1404
1433
|
/**
|
|
1405
1434
|
* Request a password reset code (forgot password).
|
|
1406
1435
|
*/
|
|
@@ -1409,6 +1438,69 @@ declare class AuthService {
|
|
|
1409
1438
|
* Confirm a password reset code and set a new password.
|
|
1410
1439
|
*/
|
|
1411
1440
|
confirmForgotPassword(identifier: string, code: string, newPassword: string): Observable<ConfirmForgotPasswordResponse>;
|
|
1441
|
+
/**
|
|
1442
|
+
* Change user password (requires current password).
|
|
1443
|
+
*
|
|
1444
|
+
* @param oldPassword - Current password
|
|
1445
|
+
* @param newPassword - New password (must meet requirements)
|
|
1446
|
+
* @returns Observable that completes when password is changed
|
|
1447
|
+
*
|
|
1448
|
+
* @example
|
|
1449
|
+
* ```typescript
|
|
1450
|
+
* this.auth.changePassword('oldPassword123', 'newSecurePassword456!').subscribe({
|
|
1451
|
+
* next: () => console.log('Password changed successfully'),
|
|
1452
|
+
* error: (err) => console.error('Failed to change password:', err)
|
|
1453
|
+
* });
|
|
1454
|
+
* ```
|
|
1455
|
+
*/
|
|
1456
|
+
changePassword(oldPassword: string, newPassword: string): Observable<void>;
|
|
1457
|
+
/**
|
|
1458
|
+
* Request password change (must change on next login).
|
|
1459
|
+
*
|
|
1460
|
+
* @returns Observable that completes when request is sent
|
|
1461
|
+
*/
|
|
1462
|
+
requestPasswordChange(): Observable<void>;
|
|
1463
|
+
/**
|
|
1464
|
+
* Get current user profile.
|
|
1465
|
+
*
|
|
1466
|
+
* @returns Observable of current user profile
|
|
1467
|
+
*
|
|
1468
|
+
* @example
|
|
1469
|
+
* ```typescript
|
|
1470
|
+
* this.auth.getProfile().subscribe(user => {
|
|
1471
|
+
* console.log('User profile:', user);
|
|
1472
|
+
* });
|
|
1473
|
+
* ```
|
|
1474
|
+
*/
|
|
1475
|
+
getProfile(): Observable<AuthUser>;
|
|
1476
|
+
/**
|
|
1477
|
+
* Get current user profile (promise-based).
|
|
1478
|
+
*
|
|
1479
|
+
* Returns a promise instead of an Observable, matching the core NAuthClient API.
|
|
1480
|
+
* Useful for async/await patterns in guards and interceptors.
|
|
1481
|
+
*
|
|
1482
|
+
* @returns Promise of current user profile
|
|
1483
|
+
*
|
|
1484
|
+
* @example
|
|
1485
|
+
* ```typescript
|
|
1486
|
+
* const user = await auth.getProfilePromise();
|
|
1487
|
+
* ```
|
|
1488
|
+
*/
|
|
1489
|
+
getProfilePromise(): Promise<AuthUser>;
|
|
1490
|
+
/**
|
|
1491
|
+
* Update user profile.
|
|
1492
|
+
*
|
|
1493
|
+
* @param updates - Profile fields to update
|
|
1494
|
+
* @returns Observable of updated user profile
|
|
1495
|
+
*
|
|
1496
|
+
* @example
|
|
1497
|
+
* ```typescript
|
|
1498
|
+
* this.auth.updateProfile({ firstName: 'John', lastName: 'Doe' }).subscribe(user => {
|
|
1499
|
+
* console.log('Profile updated:', user);
|
|
1500
|
+
* });
|
|
1501
|
+
* ```
|
|
1502
|
+
*/
|
|
1503
|
+
updateProfile(updates: UpdateProfileRequest): Observable<AuthUser>;
|
|
1412
1504
|
/**
|
|
1413
1505
|
* Respond to a challenge (VERIFY_EMAIL, VERIFY_PHONE, MFA_REQUIRED, etc.).
|
|
1414
1506
|
*/
|
|
@@ -1447,38 +1539,175 @@ declare class AuthService {
|
|
|
1447
1539
|
clearChallenge(): Observable<void>;
|
|
1448
1540
|
/**
|
|
1449
1541
|
* Initiate social OAuth login flow.
|
|
1450
|
-
* Redirects to
|
|
1542
|
+
* Redirects the browser to backend `/auth/social/:provider/redirect`.
|
|
1543
|
+
*/
|
|
1544
|
+
loginWithSocial(provider: SocialProvider, options?: SocialLoginOptions): Promise<void>;
|
|
1545
|
+
/**
|
|
1546
|
+
* Exchange an exchangeToken (from redirect callback URL) into an AuthResponse.
|
|
1547
|
+
*
|
|
1548
|
+
* Used for `tokenDelivery: 'json'` or hybrid flows where the backend redirects back
|
|
1549
|
+
* with `exchangeToken` instead of setting cookies.
|
|
1550
|
+
*
|
|
1551
|
+
* @param exchangeToken - One-time exchange token from the callback URL
|
|
1552
|
+
* @returns Observable of AuthResponse
|
|
1553
|
+
*/
|
|
1554
|
+
exchangeSocialRedirect(exchangeToken: string): Observable<AuthResponse>;
|
|
1555
|
+
/**
|
|
1556
|
+
* Exchange an exchangeToken (from redirect callback URL) into an AuthResponse (promise-based).
|
|
1557
|
+
*
|
|
1558
|
+
* Returns a promise instead of an Observable, matching the core NAuthClient API.
|
|
1559
|
+
* Useful for async/await patterns in guards and interceptors.
|
|
1560
|
+
*
|
|
1561
|
+
* @param exchangeToken - One-time exchange token from the callback URL
|
|
1562
|
+
* @returns Promise of AuthResponse
|
|
1563
|
+
*
|
|
1564
|
+
* @example
|
|
1565
|
+
* ```typescript
|
|
1566
|
+
* const response = await auth.exchangeSocialRedirectPromise(exchangeToken);
|
|
1567
|
+
* ```
|
|
1568
|
+
*/
|
|
1569
|
+
exchangeSocialRedirectPromise(exchangeToken: string): Promise<AuthResponse>;
|
|
1570
|
+
/**
|
|
1571
|
+
* Verify native social token (mobile).
|
|
1572
|
+
*
|
|
1573
|
+
* @param request - Social verification request with provider and token
|
|
1574
|
+
* @returns Observable of AuthResponse
|
|
1575
|
+
*/
|
|
1576
|
+
verifyNativeSocial(request: SocialVerifyRequest): Observable<AuthResponse>;
|
|
1577
|
+
/**
|
|
1578
|
+
* Get linked social accounts.
|
|
1579
|
+
*
|
|
1580
|
+
* @returns Observable of linked accounts response
|
|
1581
|
+
*/
|
|
1582
|
+
getLinkedAccounts(): Observable<LinkedAccountsResponse>;
|
|
1583
|
+
/**
|
|
1584
|
+
* Link social account.
|
|
1585
|
+
*
|
|
1586
|
+
* @param provider - Social provider to link
|
|
1587
|
+
* @param code - OAuth authorization code
|
|
1588
|
+
* @param state - OAuth state parameter
|
|
1589
|
+
* @returns Observable with success message
|
|
1590
|
+
*/
|
|
1591
|
+
linkSocialAccount(provider: string, code: string, state: string): Observable<{
|
|
1592
|
+
message: string;
|
|
1593
|
+
}>;
|
|
1594
|
+
/**
|
|
1595
|
+
* Unlink social account.
|
|
1596
|
+
*
|
|
1597
|
+
* @param provider - Social provider to unlink
|
|
1598
|
+
* @returns Observable with success message
|
|
1599
|
+
*/
|
|
1600
|
+
unlinkSocialAccount(provider: string): Observable<{
|
|
1601
|
+
message: string;
|
|
1602
|
+
}>;
|
|
1603
|
+
/**
|
|
1604
|
+
* Get MFA status for the current user.
|
|
1605
|
+
*
|
|
1606
|
+
* @returns Observable of MFA status
|
|
1607
|
+
*/
|
|
1608
|
+
getMfaStatus(): Observable<MFAStatus>;
|
|
1609
|
+
/**
|
|
1610
|
+
* Get MFA devices for the current user.
|
|
1611
|
+
*
|
|
1612
|
+
* @returns Observable of MFA devices array
|
|
1613
|
+
*/
|
|
1614
|
+
getMfaDevices(): Observable<MFADevice[]>;
|
|
1615
|
+
/**
|
|
1616
|
+
* Setup MFA device (authenticated user).
|
|
1617
|
+
*
|
|
1618
|
+
* @param method - MFA method to set up
|
|
1619
|
+
* @returns Observable of setup data
|
|
1620
|
+
*/
|
|
1621
|
+
setupMfaDevice(method: string): Observable<unknown>;
|
|
1622
|
+
/**
|
|
1623
|
+
* Verify MFA setup (authenticated user).
|
|
1624
|
+
*
|
|
1625
|
+
* @param method - MFA method
|
|
1626
|
+
* @param setupData - Setup data from setupMfaDevice
|
|
1627
|
+
* @param deviceName - Optional device name
|
|
1628
|
+
* @returns Observable with device ID
|
|
1629
|
+
*/
|
|
1630
|
+
verifyMfaSetup(method: string, setupData: Record<string, unknown>, deviceName?: string): Observable<{
|
|
1631
|
+
deviceId: number;
|
|
1632
|
+
}>;
|
|
1633
|
+
/**
|
|
1634
|
+
* Remove MFA device.
|
|
1635
|
+
*
|
|
1636
|
+
* @param method - MFA method to remove
|
|
1637
|
+
* @returns Observable with success message
|
|
1638
|
+
*/
|
|
1639
|
+
removeMfaDevice(method: string): Observable<{
|
|
1640
|
+
message: string;
|
|
1641
|
+
}>;
|
|
1642
|
+
/**
|
|
1643
|
+
* Set preferred MFA method.
|
|
1644
|
+
*
|
|
1645
|
+
* @param method - Device method to set as preferred ('totp', 'sms', 'email', or 'passkey')
|
|
1646
|
+
* @returns Observable with success message
|
|
1451
1647
|
*/
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
}
|
|
1648
|
+
setPreferredMfaMethod(method: 'totp' | 'sms' | 'email' | 'passkey'): Observable<{
|
|
1649
|
+
message: string;
|
|
1650
|
+
}>;
|
|
1651
|
+
/**
|
|
1652
|
+
* Generate backup codes.
|
|
1653
|
+
*
|
|
1654
|
+
* @returns Observable of backup codes array
|
|
1655
|
+
*/
|
|
1656
|
+
generateBackupCodes(): Observable<string[]>;
|
|
1657
|
+
/**
|
|
1658
|
+
* Set MFA exemption (admin/test scenarios).
|
|
1659
|
+
*
|
|
1660
|
+
* @param exempt - Whether to exempt user from MFA
|
|
1661
|
+
* @param reason - Optional reason for exemption
|
|
1662
|
+
* @returns Observable that completes when exemption is set
|
|
1663
|
+
*/
|
|
1664
|
+
setMfaExemption(exempt: boolean, reason?: string): Observable<void>;
|
|
1665
|
+
/**
|
|
1666
|
+
* Trust current device.
|
|
1667
|
+
*
|
|
1668
|
+
* @returns Observable with device token
|
|
1669
|
+
*/
|
|
1670
|
+
trustDevice(): Observable<{
|
|
1671
|
+
deviceToken: string;
|
|
1672
|
+
}>;
|
|
1455
1673
|
/**
|
|
1456
|
-
*
|
|
1674
|
+
* Check if the current device is trusted.
|
|
1675
|
+
*
|
|
1676
|
+
* @returns Observable with trusted status
|
|
1457
1677
|
*/
|
|
1458
|
-
|
|
1459
|
-
|
|
1678
|
+
isTrustedDevice(): Observable<{
|
|
1679
|
+
trusted: boolean;
|
|
1460
1680
|
}>;
|
|
1461
1681
|
/**
|
|
1462
|
-
*
|
|
1682
|
+
* Get paginated audit history for the current user.
|
|
1683
|
+
*
|
|
1684
|
+
* @param params - Query parameters for filtering and pagination
|
|
1685
|
+
* @returns Observable of audit history response
|
|
1686
|
+
*
|
|
1687
|
+
* @example
|
|
1688
|
+
* ```typescript
|
|
1689
|
+
* this.auth.getAuditHistory({ page: 1, limit: 20, eventType: 'LOGIN_SUCCESS' }).subscribe(history => {
|
|
1690
|
+
* console.log('Audit history:', history);
|
|
1691
|
+
* });
|
|
1692
|
+
* ```
|
|
1463
1693
|
*/
|
|
1464
|
-
|
|
1694
|
+
getAuditHistory(params?: Record<string, string | number | boolean>): Observable<AuditHistoryResponse>;
|
|
1465
1695
|
/**
|
|
1466
1696
|
* Expose underlying NAuthClient for advanced scenarios.
|
|
1467
1697
|
*
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
* - Device trust (trustDevice)
|
|
1698
|
+
* @deprecated All core functionality is now exposed directly on AuthService as Observables.
|
|
1699
|
+
* Use the direct methods on AuthService instead (e.g., `auth.changePassword()` instead of `auth.getClient().changePassword()`).
|
|
1700
|
+
* This method is kept for backward compatibility only and may be removed in a future version.
|
|
1701
|
+
*
|
|
1702
|
+
* @returns The underlying NAuthClient instance
|
|
1474
1703
|
*
|
|
1475
1704
|
* @example
|
|
1476
1705
|
* ```typescript
|
|
1477
|
-
* //
|
|
1706
|
+
* // Deprecated - use direct methods instead
|
|
1478
1707
|
* const status = await this.auth.getClient().getMfaStatus();
|
|
1479
1708
|
*
|
|
1480
|
-
* //
|
|
1481
|
-
*
|
|
1709
|
+
* // Preferred - use Observable-based methods
|
|
1710
|
+
* this.auth.getMfaStatus().subscribe(status => ...);
|
|
1482
1711
|
* ```
|
|
1483
1712
|
*/
|
|
1484
1713
|
getClient(): NAuthClient;
|
|
@@ -1572,54 +1801,29 @@ declare class AuthGuard {
|
|
|
1572
1801
|
}
|
|
1573
1802
|
|
|
1574
1803
|
/**
|
|
1575
|
-
*
|
|
1576
|
-
*
|
|
1577
|
-
* Drop-in guard that automatically processes OAuth callbacks and redirects appropriately.
|
|
1578
|
-
* Place this guard on your `/auth/callback` route to handle social authentication.
|
|
1804
|
+
* Social redirect callback route guard.
|
|
1579
1805
|
*
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1582
|
-
* -
|
|
1583
|
-
* -
|
|
1806
|
+
* This guard supports the redirect-first social flow where the backend redirects
|
|
1807
|
+
* back to the frontend with:
|
|
1808
|
+
* - `appState` (always optional)
|
|
1809
|
+
* - `exchangeToken` (present for json/hybrid flows, and for cookie flows that return a challenge)
|
|
1810
|
+
* - `error` / `error_description` (provider errors)
|
|
1584
1811
|
*
|
|
1585
|
-
*
|
|
1812
|
+
* Behavior:
|
|
1813
|
+
* - If `exchangeToken` exists: exchanges it via backend and redirects to success or challenge routes.
|
|
1814
|
+
* - If no `exchangeToken`: treat as cookie-success path and redirect to success route.
|
|
1815
|
+
* - If `error` exists: redirects to oauthError route.
|
|
1586
1816
|
*
|
|
1587
1817
|
* @example
|
|
1588
1818
|
* ```typescript
|
|
1589
|
-
*
|
|
1590
|
-
* import { oauthCallbackGuard } from '@nauth-toolkit/client/angular';
|
|
1819
|
+
* import { socialRedirectCallbackGuard } from '@nauth-toolkit/client/angular';
|
|
1591
1820
|
*
|
|
1592
1821
|
* export const routes: Routes = [
|
|
1593
|
-
* {
|
|
1594
|
-
* path: 'auth/callback',
|
|
1595
|
-
* canActivate: [oauthCallbackGuard],
|
|
1596
|
-
* redirectTo: '/', // Fallback - guard handles redirect
|
|
1597
|
-
* },
|
|
1822
|
+
* { path: 'auth/callback', canActivate: [socialRedirectCallbackGuard], component: CallbackComponent },
|
|
1598
1823
|
* ];
|
|
1599
1824
|
* ```
|
|
1600
|
-
*
|
|
1601
|
-
* @example
|
|
1602
|
-
* ```typescript
|
|
1603
|
-
* // app.config.ts - Configure redirect URLs
|
|
1604
|
-
* import { NAUTH_CLIENT_CONFIG } from '@nauth-toolkit/client/angular';
|
|
1605
|
-
*
|
|
1606
|
-
* providers: [
|
|
1607
|
-
* {
|
|
1608
|
-
* provide: NAUTH_CLIENT_CONFIG,
|
|
1609
|
-
* useValue: {
|
|
1610
|
-
* baseUrl: 'https://api.example.com/auth',
|
|
1611
|
-
* tokenDelivery: 'cookies',
|
|
1612
|
-
* redirects: {
|
|
1613
|
-
* success: '/home', // Common redirect for all successful auth
|
|
1614
|
-
* oauthError: '/login',
|
|
1615
|
-
* challengeBase: '/auth/challenge',
|
|
1616
|
-
* },
|
|
1617
|
-
* },
|
|
1618
|
-
* }
|
|
1619
|
-
* ]
|
|
1620
|
-
* ```
|
|
1621
1825
|
*/
|
|
1622
|
-
declare const
|
|
1826
|
+
declare const socialRedirectCallbackGuard: CanActivateFn;
|
|
1623
1827
|
|
|
1624
1828
|
/**
|
|
1625
1829
|
* NgModule wrapper to provide configuration and interceptor.
|
|
@@ -1665,4 +1869,4 @@ declare class AngularHttpAdapter implements HttpAdapter {
|
|
|
1665
1869
|
request<T>(config: HttpRequest): Promise<HttpResponse<T>>;
|
|
1666
1870
|
}
|
|
1667
1871
|
|
|
1668
|
-
export { AngularHttpAdapter, AuthChallenge, type AuthEvent, type AuthEventListener, type AuthEventType, AuthGuard, AuthInterceptor, type AuthResponse, AuthService, type AuthUser, type ChallengeResponse, type HttpAdapter, type MFADeviceMethod, type MFAMethod, type MFAStatus, NAUTH_CLIENT_CONFIG, type NAuthClientConfig, NAuthModule, type SocialProvider, type TokenDeliveryMode, type TokenResponse, authGuard, authInterceptor,
|
|
1872
|
+
export { AngularHttpAdapter, AuthChallenge, type AuthEvent, type AuthEventListener, type AuthEventType, AuthGuard, AuthInterceptor, type AuthResponse, AuthService, type AuthUser, type ChallengeResponse, type HttpAdapter, type MFADeviceMethod, type MFAMethod, type MFAStatus, NAUTH_CLIENT_CONFIG, type NAuthClientConfig, NAuthModule, type SocialProvider, type TokenDeliveryMode, type TokenResponse, authGuard, authInterceptor, socialRedirectCallbackGuard };
|