@nauth-toolkit/client 0.1.45 → 0.1.48
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 +327 -189
- package/dist/angular/index.cjs.map +1 -1
- package/dist/angular/index.d.mts +263 -106
- package/dist/angular/index.d.ts +263 -106
- package/dist/angular/index.mjs +325 -187
- package/dist/angular/index.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/angular/index.d.mts
CHANGED
|
@@ -1303,11 +1303,11 @@ declare class NAuthClient {
|
|
|
1303
1303
|
}
|
|
1304
1304
|
|
|
1305
1305
|
/**
|
|
1306
|
-
* Angular wrapper around NAuthClient that
|
|
1306
|
+
* Angular wrapper around NAuthClient that provides promise-based auth methods and reactive state.
|
|
1307
1307
|
*
|
|
1308
1308
|
* This service provides:
|
|
1309
1309
|
* - Reactive state (currentUser$, isAuthenticated$, challenge$)
|
|
1310
|
-
* - All core auth methods as
|
|
1310
|
+
* - All core auth methods as Promises (login, signup, logout, refresh)
|
|
1311
1311
|
* - Profile management (getProfile, updateProfile, changePassword)
|
|
1312
1312
|
* - Challenge flow methods (respondToChallenge, resendCode)
|
|
1313
1313
|
* - MFA management (getMfaStatus, setupMfaDevice, etc.)
|
|
@@ -1323,15 +1323,15 @@ declare class NAuthClient {
|
|
|
1323
1323
|
* this.auth.currentUser$.subscribe(user => ...);
|
|
1324
1324
|
* this.auth.isAuthenticated$.subscribe(isAuth => ...);
|
|
1325
1325
|
*
|
|
1326
|
-
* // Auth operations
|
|
1327
|
-
* this.auth.login(email, password)
|
|
1326
|
+
* // Auth operations with async/await
|
|
1327
|
+
* const response = await this.auth.login(email, password);
|
|
1328
1328
|
*
|
|
1329
1329
|
* // Profile management
|
|
1330
|
-
* this.auth.changePassword(oldPassword, newPassword)
|
|
1331
|
-
* this.auth.updateProfile({ firstName: 'John' })
|
|
1330
|
+
* await this.auth.changePassword(oldPassword, newPassword);
|
|
1331
|
+
* const user = await this.auth.updateProfile({ firstName: 'John' });
|
|
1332
1332
|
*
|
|
1333
1333
|
* // MFA operations
|
|
1334
|
-
* this.auth.getMfaStatus()
|
|
1334
|
+
* const status = await this.auth.getMfaStatus();
|
|
1335
1335
|
* ```
|
|
1336
1336
|
*/
|
|
1337
1337
|
declare class AuthService {
|
|
@@ -1390,16 +1390,49 @@ declare class AuthService {
|
|
|
1390
1390
|
getCurrentChallenge(): AuthResponse | null;
|
|
1391
1391
|
/**
|
|
1392
1392
|
* Login with identifier and password.
|
|
1393
|
+
*
|
|
1394
|
+
* @param identifier - User email or username
|
|
1395
|
+
* @param password - User password
|
|
1396
|
+
* @returns Promise with auth response or challenge
|
|
1397
|
+
*
|
|
1398
|
+
* @example
|
|
1399
|
+
* ```typescript
|
|
1400
|
+
* const response = await this.auth.login('user@example.com', 'password');
|
|
1401
|
+
* if (response.challengeName) {
|
|
1402
|
+
* // Handle challenge
|
|
1403
|
+
* } else {
|
|
1404
|
+
* // Login successful
|
|
1405
|
+
* }
|
|
1406
|
+
* ```
|
|
1393
1407
|
*/
|
|
1394
|
-
login(identifier: string, password: string):
|
|
1408
|
+
login(identifier: string, password: string): Promise<AuthResponse>;
|
|
1395
1409
|
/**
|
|
1396
1410
|
* Signup with credentials.
|
|
1411
|
+
*
|
|
1412
|
+
* @param payload - Signup request payload
|
|
1413
|
+
* @returns Promise with auth response or challenge
|
|
1414
|
+
*
|
|
1415
|
+
* @example
|
|
1416
|
+
* ```typescript
|
|
1417
|
+
* const response = await this.auth.signup({
|
|
1418
|
+
* email: 'new@example.com',
|
|
1419
|
+
* password: 'SecurePass123!',
|
|
1420
|
+
* firstName: 'John',
|
|
1421
|
+
* });
|
|
1422
|
+
* ```
|
|
1397
1423
|
*/
|
|
1398
|
-
signup(payload: Parameters<NAuthClient['signup']>[0]):
|
|
1424
|
+
signup(payload: Parameters<NAuthClient['signup']>[0]): Promise<AuthResponse>;
|
|
1399
1425
|
/**
|
|
1400
1426
|
* Logout current session.
|
|
1427
|
+
*
|
|
1428
|
+
* @param forgetDevice - If true, removes device trust
|
|
1429
|
+
*
|
|
1430
|
+
* @example
|
|
1431
|
+
* ```typescript
|
|
1432
|
+
* await this.auth.logout();
|
|
1433
|
+
* ```
|
|
1401
1434
|
*/
|
|
1402
|
-
logout(forgetDevice?: boolean):
|
|
1435
|
+
logout(forgetDevice?: boolean): Promise<void>;
|
|
1403
1436
|
/**
|
|
1404
1437
|
* Logout all sessions.
|
|
1405
1438
|
*
|
|
@@ -1407,108 +1440,132 @@ declare class AuthService {
|
|
|
1407
1440
|
* Optionally revokes all trusted devices if forgetDevices is true.
|
|
1408
1441
|
*
|
|
1409
1442
|
* @param forgetDevices - If true, also revokes all trusted devices (default: false)
|
|
1410
|
-
* @returns
|
|
1443
|
+
* @returns Promise with number of sessions revoked
|
|
1444
|
+
*
|
|
1445
|
+
* @example
|
|
1446
|
+
* ```typescript
|
|
1447
|
+
* const result = await this.auth.logoutAll();
|
|
1448
|
+
* console.log(`Revoked ${result.revokedCount} sessions`);
|
|
1449
|
+
* ```
|
|
1411
1450
|
*/
|
|
1412
|
-
logoutAll(forgetDevices?: boolean):
|
|
1451
|
+
logoutAll(forgetDevices?: boolean): Promise<{
|
|
1413
1452
|
revokedCount: number;
|
|
1414
1453
|
}>;
|
|
1415
1454
|
/**
|
|
1416
1455
|
* Refresh tokens.
|
|
1417
|
-
*/
|
|
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
1456
|
*
|
|
1425
|
-
* @returns Promise
|
|
1457
|
+
* @returns Promise with new tokens
|
|
1426
1458
|
*
|
|
1427
1459
|
* @example
|
|
1428
1460
|
* ```typescript
|
|
1429
|
-
* const tokens = await auth.
|
|
1461
|
+
* const tokens = await this.auth.refresh();
|
|
1430
1462
|
* ```
|
|
1431
1463
|
*/
|
|
1432
|
-
|
|
1464
|
+
refresh(): Promise<TokenResponse>;
|
|
1433
1465
|
/**
|
|
1434
1466
|
* Request a password reset code (forgot password).
|
|
1467
|
+
*
|
|
1468
|
+
* @param identifier - User email, username, or phone
|
|
1469
|
+
* @returns Promise with password reset response
|
|
1470
|
+
*
|
|
1471
|
+
* @example
|
|
1472
|
+
* ```typescript
|
|
1473
|
+
* await this.auth.forgotPassword('user@example.com');
|
|
1474
|
+
* ```
|
|
1435
1475
|
*/
|
|
1436
|
-
forgotPassword(identifier: string):
|
|
1476
|
+
forgotPassword(identifier: string): Promise<ForgotPasswordResponse>;
|
|
1437
1477
|
/**
|
|
1438
1478
|
* Confirm a password reset code and set a new password.
|
|
1479
|
+
*
|
|
1480
|
+
* @param identifier - User email, username, or phone
|
|
1481
|
+
* @param code - One-time reset code
|
|
1482
|
+
* @param newPassword - New password
|
|
1483
|
+
* @returns Promise with confirmation response
|
|
1484
|
+
*
|
|
1485
|
+
* @example
|
|
1486
|
+
* ```typescript
|
|
1487
|
+
* await this.auth.confirmForgotPassword('user@example.com', '123456', 'NewPass123!');
|
|
1488
|
+
* ```
|
|
1439
1489
|
*/
|
|
1440
|
-
confirmForgotPassword(identifier: string, code: string, newPassword: string):
|
|
1490
|
+
confirmForgotPassword(identifier: string, code: string, newPassword: string): Promise<ConfirmForgotPasswordResponse>;
|
|
1441
1491
|
/**
|
|
1442
1492
|
* Change user password (requires current password).
|
|
1443
1493
|
*
|
|
1444
1494
|
* @param oldPassword - Current password
|
|
1445
1495
|
* @param newPassword - New password (must meet requirements)
|
|
1446
|
-
* @returns
|
|
1496
|
+
* @returns Promise that resolves when password is changed
|
|
1447
1497
|
*
|
|
1448
1498
|
* @example
|
|
1449
1499
|
* ```typescript
|
|
1450
|
-
* this.auth.changePassword('oldPassword123', 'newSecurePassword456!')
|
|
1451
|
-
* next: () => console.log('Password changed successfully'),
|
|
1452
|
-
* error: (err) => console.error('Failed to change password:', err)
|
|
1453
|
-
* });
|
|
1500
|
+
* await this.auth.changePassword('oldPassword123', 'newSecurePassword456!');
|
|
1454
1501
|
* ```
|
|
1455
1502
|
*/
|
|
1456
|
-
changePassword(oldPassword: string, newPassword: string):
|
|
1503
|
+
changePassword(oldPassword: string, newPassword: string): Promise<void>;
|
|
1457
1504
|
/**
|
|
1458
1505
|
* Request password change (must change on next login).
|
|
1459
1506
|
*
|
|
1460
|
-
* @returns
|
|
1461
|
-
*/
|
|
1462
|
-
requestPasswordChange(): Observable<void>;
|
|
1463
|
-
/**
|
|
1464
|
-
* Get current user profile.
|
|
1465
|
-
*
|
|
1466
|
-
* @returns Observable of current user profile
|
|
1507
|
+
* @returns Promise that resolves when request is sent
|
|
1467
1508
|
*
|
|
1468
1509
|
* @example
|
|
1469
1510
|
* ```typescript
|
|
1470
|
-
* this.auth.
|
|
1471
|
-
* console.log('User profile:', user);
|
|
1472
|
-
* });
|
|
1511
|
+
* await this.auth.requestPasswordChange();
|
|
1473
1512
|
* ```
|
|
1474
1513
|
*/
|
|
1475
|
-
|
|
1514
|
+
requestPasswordChange(): Promise<void>;
|
|
1476
1515
|
/**
|
|
1477
|
-
* Get current user profile
|
|
1478
|
-
*
|
|
1479
|
-
* Returns a promise instead of an Observable, matching the core NAuthClient API.
|
|
1480
|
-
* Useful for async/await patterns in guards and interceptors.
|
|
1516
|
+
* Get current user profile.
|
|
1481
1517
|
*
|
|
1482
1518
|
* @returns Promise of current user profile
|
|
1483
1519
|
*
|
|
1484
1520
|
* @example
|
|
1485
1521
|
* ```typescript
|
|
1486
|
-
* const user = await auth.
|
|
1522
|
+
* const user = await this.auth.getProfile();
|
|
1523
|
+
* console.log('User profile:', user);
|
|
1487
1524
|
* ```
|
|
1488
1525
|
*/
|
|
1489
|
-
|
|
1526
|
+
getProfile(): Promise<AuthUser>;
|
|
1490
1527
|
/**
|
|
1491
1528
|
* Update user profile.
|
|
1492
1529
|
*
|
|
1493
1530
|
* @param updates - Profile fields to update
|
|
1494
|
-
* @returns
|
|
1531
|
+
* @returns Promise of updated user profile
|
|
1495
1532
|
*
|
|
1496
1533
|
* @example
|
|
1497
1534
|
* ```typescript
|
|
1498
|
-
* this.auth.updateProfile({ firstName: 'John', lastName: 'Doe' })
|
|
1499
|
-
*
|
|
1500
|
-
* });
|
|
1535
|
+
* const user = await this.auth.updateProfile({ firstName: 'John', lastName: 'Doe' });
|
|
1536
|
+
* console.log('Profile updated:', user);
|
|
1501
1537
|
* ```
|
|
1502
1538
|
*/
|
|
1503
|
-
updateProfile(updates: UpdateProfileRequest):
|
|
1539
|
+
updateProfile(updates: UpdateProfileRequest): Promise<AuthUser>;
|
|
1504
1540
|
/**
|
|
1505
1541
|
* Respond to a challenge (VERIFY_EMAIL, VERIFY_PHONE, MFA_REQUIRED, etc.).
|
|
1542
|
+
*
|
|
1543
|
+
* @param response - Challenge response data
|
|
1544
|
+
* @returns Promise with auth response or next challenge
|
|
1545
|
+
*
|
|
1546
|
+
* @example
|
|
1547
|
+
* ```typescript
|
|
1548
|
+
* const result = await this.auth.respondToChallenge({
|
|
1549
|
+
* session: challengeSession,
|
|
1550
|
+
* type: 'VERIFY_EMAIL',
|
|
1551
|
+
* code: '123456',
|
|
1552
|
+
* });
|
|
1553
|
+
* ```
|
|
1506
1554
|
*/
|
|
1507
|
-
respondToChallenge(response: ChallengeResponse):
|
|
1555
|
+
respondToChallenge(response: ChallengeResponse): Promise<AuthResponse>;
|
|
1508
1556
|
/**
|
|
1509
1557
|
* Resend challenge code.
|
|
1558
|
+
*
|
|
1559
|
+
* @param session - Challenge session token
|
|
1560
|
+
* @returns Promise with destination information
|
|
1561
|
+
*
|
|
1562
|
+
* @example
|
|
1563
|
+
* ```typescript
|
|
1564
|
+
* const result = await this.auth.resendCode(session);
|
|
1565
|
+
* console.log('Code sent to:', result.destination);
|
|
1566
|
+
* ```
|
|
1510
1567
|
*/
|
|
1511
|
-
resendCode(session: string):
|
|
1568
|
+
resendCode(session: string): Promise<{
|
|
1512
1569
|
destination: string;
|
|
1513
1570
|
}>;
|
|
1514
1571
|
/**
|
|
@@ -1522,24 +1579,51 @@ declare class AuthService {
|
|
|
1522
1579
|
*
|
|
1523
1580
|
* @param session - Challenge session token
|
|
1524
1581
|
* @param method - MFA method to set up
|
|
1525
|
-
* @returns
|
|
1582
|
+
* @returns Promise of setup data response
|
|
1583
|
+
*
|
|
1584
|
+
* @example
|
|
1585
|
+
* ```typescript
|
|
1586
|
+
* const setupData = await this.auth.getSetupData(session, 'totp');
|
|
1587
|
+
* console.log('QR Code:', setupData.setupData.qrCode);
|
|
1588
|
+
* ```
|
|
1526
1589
|
*/
|
|
1527
|
-
getSetupData(session: string, method: string):
|
|
1590
|
+
getSetupData(session: string, method: string): Promise<GetSetupDataResponse>;
|
|
1528
1591
|
/**
|
|
1529
1592
|
* Get MFA challenge data (for MFA_REQUIRED challenge - e.g., passkey options).
|
|
1530
1593
|
*
|
|
1531
1594
|
* @param session - Challenge session token
|
|
1532
1595
|
* @param method - Challenge method
|
|
1533
|
-
* @returns
|
|
1596
|
+
* @returns Promise of challenge data response
|
|
1597
|
+
*
|
|
1598
|
+
* @example
|
|
1599
|
+
* ```typescript
|
|
1600
|
+
* const challengeData = await this.auth.getChallengeData(session, 'passkey');
|
|
1601
|
+
* ```
|
|
1534
1602
|
*/
|
|
1535
|
-
getChallengeData(session: string, method: string):
|
|
1603
|
+
getChallengeData(session: string, method: string): Promise<GetChallengeDataResponse>;
|
|
1536
1604
|
/**
|
|
1537
1605
|
* Clear stored challenge (when navigating away from challenge flow).
|
|
1606
|
+
*
|
|
1607
|
+
* @returns Promise that resolves when challenge is cleared
|
|
1608
|
+
*
|
|
1609
|
+
* @example
|
|
1610
|
+
* ```typescript
|
|
1611
|
+
* await this.auth.clearChallenge();
|
|
1612
|
+
* ```
|
|
1538
1613
|
*/
|
|
1539
|
-
clearChallenge():
|
|
1614
|
+
clearChallenge(): Promise<void>;
|
|
1540
1615
|
/**
|
|
1541
1616
|
* Initiate social OAuth login flow.
|
|
1542
1617
|
* Redirects the browser to backend `/auth/social/:provider/redirect`.
|
|
1618
|
+
*
|
|
1619
|
+
* @param provider - Social provider ('google', 'apple', 'facebook')
|
|
1620
|
+
* @param options - Optional redirect options
|
|
1621
|
+
* @returns Promise that resolves when redirect starts
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* ```typescript
|
|
1625
|
+
* await this.auth.loginWithSocial('google', { returnTo: '/auth/callback' });
|
|
1626
|
+
* ```
|
|
1543
1627
|
*/
|
|
1544
1628
|
loginWithSocial(provider: SocialProvider, options?: SocialLoginOptions): Promise<void>;
|
|
1545
1629
|
/**
|
|
@@ -1549,153 +1633,226 @@ declare class AuthService {
|
|
|
1549
1633
|
* with `exchangeToken` instead of setting cookies.
|
|
1550
1634
|
*
|
|
1551
1635
|
* @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
1636
|
* @returns Promise of AuthResponse
|
|
1563
1637
|
*
|
|
1564
1638
|
* @example
|
|
1565
1639
|
* ```typescript
|
|
1566
|
-
* const response = await auth.
|
|
1640
|
+
* const response = await this.auth.exchangeSocialRedirect(exchangeToken);
|
|
1567
1641
|
* ```
|
|
1568
1642
|
*/
|
|
1569
|
-
|
|
1643
|
+
exchangeSocialRedirect(exchangeToken: string): Promise<AuthResponse>;
|
|
1570
1644
|
/**
|
|
1571
1645
|
* Verify native social token (mobile).
|
|
1572
1646
|
*
|
|
1573
1647
|
* @param request - Social verification request with provider and token
|
|
1574
|
-
* @returns
|
|
1648
|
+
* @returns Promise of AuthResponse
|
|
1649
|
+
*
|
|
1650
|
+
* @example
|
|
1651
|
+
* ```typescript
|
|
1652
|
+
* const result = await this.auth.verifyNativeSocial({
|
|
1653
|
+
* provider: 'google',
|
|
1654
|
+
* idToken: nativeIdToken,
|
|
1655
|
+
* });
|
|
1656
|
+
* ```
|
|
1575
1657
|
*/
|
|
1576
|
-
verifyNativeSocial(request: SocialVerifyRequest):
|
|
1658
|
+
verifyNativeSocial(request: SocialVerifyRequest): Promise<AuthResponse>;
|
|
1577
1659
|
/**
|
|
1578
1660
|
* Get linked social accounts.
|
|
1579
1661
|
*
|
|
1580
|
-
* @returns
|
|
1662
|
+
* @returns Promise of linked accounts response
|
|
1663
|
+
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* ```typescript
|
|
1666
|
+
* const accounts = await this.auth.getLinkedAccounts();
|
|
1667
|
+
* console.log('Linked providers:', accounts.providers);
|
|
1668
|
+
* ```
|
|
1581
1669
|
*/
|
|
1582
|
-
getLinkedAccounts():
|
|
1670
|
+
getLinkedAccounts(): Promise<LinkedAccountsResponse>;
|
|
1583
1671
|
/**
|
|
1584
1672
|
* Link social account.
|
|
1585
1673
|
*
|
|
1586
1674
|
* @param provider - Social provider to link
|
|
1587
1675
|
* @param code - OAuth authorization code
|
|
1588
1676
|
* @param state - OAuth state parameter
|
|
1589
|
-
* @returns
|
|
1677
|
+
* @returns Promise with success message
|
|
1678
|
+
*
|
|
1679
|
+
* @example
|
|
1680
|
+
* ```typescript
|
|
1681
|
+
* await this.auth.linkSocialAccount('google', code, state);
|
|
1682
|
+
* ```
|
|
1590
1683
|
*/
|
|
1591
|
-
linkSocialAccount(provider: string, code: string, state: string):
|
|
1684
|
+
linkSocialAccount(provider: string, code: string, state: string): Promise<{
|
|
1592
1685
|
message: string;
|
|
1593
1686
|
}>;
|
|
1594
1687
|
/**
|
|
1595
1688
|
* Unlink social account.
|
|
1596
1689
|
*
|
|
1597
1690
|
* @param provider - Social provider to unlink
|
|
1598
|
-
* @returns
|
|
1691
|
+
* @returns Promise with success message
|
|
1692
|
+
*
|
|
1693
|
+
* @example
|
|
1694
|
+
* ```typescript
|
|
1695
|
+
* await this.auth.unlinkSocialAccount('google');
|
|
1696
|
+
* ```
|
|
1599
1697
|
*/
|
|
1600
|
-
unlinkSocialAccount(provider: string):
|
|
1698
|
+
unlinkSocialAccount(provider: string): Promise<{
|
|
1601
1699
|
message: string;
|
|
1602
1700
|
}>;
|
|
1603
1701
|
/**
|
|
1604
1702
|
* Get MFA status for the current user.
|
|
1605
1703
|
*
|
|
1606
|
-
* @returns
|
|
1704
|
+
* @returns Promise of MFA status
|
|
1705
|
+
*
|
|
1706
|
+
* @example
|
|
1707
|
+
* ```typescript
|
|
1708
|
+
* const status = await this.auth.getMfaStatus();
|
|
1709
|
+
* console.log('MFA enabled:', status.enabled);
|
|
1710
|
+
* ```
|
|
1607
1711
|
*/
|
|
1608
|
-
getMfaStatus():
|
|
1712
|
+
getMfaStatus(): Promise<MFAStatus>;
|
|
1609
1713
|
/**
|
|
1610
1714
|
* Get MFA devices for the current user.
|
|
1611
1715
|
*
|
|
1612
|
-
* @returns
|
|
1716
|
+
* @returns Promise of MFA devices array
|
|
1717
|
+
*
|
|
1718
|
+
* @example
|
|
1719
|
+
* ```typescript
|
|
1720
|
+
* const devices = await this.auth.getMfaDevices();
|
|
1721
|
+
* ```
|
|
1613
1722
|
*/
|
|
1614
|
-
getMfaDevices():
|
|
1723
|
+
getMfaDevices(): Promise<MFADevice[]>;
|
|
1615
1724
|
/**
|
|
1616
1725
|
* Setup MFA device (authenticated user).
|
|
1617
1726
|
*
|
|
1618
1727
|
* @param method - MFA method to set up
|
|
1619
|
-
* @returns
|
|
1728
|
+
* @returns Promise of setup data
|
|
1729
|
+
*
|
|
1730
|
+
* @example
|
|
1731
|
+
* ```typescript
|
|
1732
|
+
* const setupData = await this.auth.setupMfaDevice('totp');
|
|
1733
|
+
* ```
|
|
1620
1734
|
*/
|
|
1621
|
-
setupMfaDevice(method: string):
|
|
1735
|
+
setupMfaDevice(method: string): Promise<unknown>;
|
|
1622
1736
|
/**
|
|
1623
1737
|
* Verify MFA setup (authenticated user).
|
|
1624
1738
|
*
|
|
1625
1739
|
* @param method - MFA method
|
|
1626
1740
|
* @param setupData - Setup data from setupMfaDevice
|
|
1627
1741
|
* @param deviceName - Optional device name
|
|
1628
|
-
* @returns
|
|
1742
|
+
* @returns Promise with device ID
|
|
1743
|
+
*
|
|
1744
|
+
* @example
|
|
1745
|
+
* ```typescript
|
|
1746
|
+
* const result = await this.auth.verifyMfaSetup('totp', { code: '123456' }, 'My Phone');
|
|
1747
|
+
* ```
|
|
1629
1748
|
*/
|
|
1630
|
-
verifyMfaSetup(method: string, setupData: Record<string, unknown>, deviceName?: string):
|
|
1749
|
+
verifyMfaSetup(method: string, setupData: Record<string, unknown>, deviceName?: string): Promise<{
|
|
1631
1750
|
deviceId: number;
|
|
1632
1751
|
}>;
|
|
1633
1752
|
/**
|
|
1634
1753
|
* Remove MFA device.
|
|
1635
1754
|
*
|
|
1636
1755
|
* @param method - MFA method to remove
|
|
1637
|
-
* @returns
|
|
1756
|
+
* @returns Promise with success message
|
|
1757
|
+
*
|
|
1758
|
+
* @example
|
|
1759
|
+
* ```typescript
|
|
1760
|
+
* await this.auth.removeMfaDevice('sms');
|
|
1761
|
+
* ```
|
|
1638
1762
|
*/
|
|
1639
|
-
removeMfaDevice(method: string):
|
|
1763
|
+
removeMfaDevice(method: string): Promise<{
|
|
1640
1764
|
message: string;
|
|
1641
1765
|
}>;
|
|
1642
1766
|
/**
|
|
1643
1767
|
* Set preferred MFA method.
|
|
1644
1768
|
*
|
|
1645
1769
|
* @param method - Device method to set as preferred ('totp', 'sms', 'email', or 'passkey')
|
|
1646
|
-
* @returns
|
|
1770
|
+
* @returns Promise with success message
|
|
1771
|
+
*
|
|
1772
|
+
* @example
|
|
1773
|
+
* ```typescript
|
|
1774
|
+
* await this.auth.setPreferredMfaMethod('totp');
|
|
1775
|
+
* ```
|
|
1647
1776
|
*/
|
|
1648
|
-
setPreferredMfaMethod(method: 'totp' | 'sms' | 'email' | 'passkey'):
|
|
1777
|
+
setPreferredMfaMethod(method: 'totp' | 'sms' | 'email' | 'passkey'): Promise<{
|
|
1649
1778
|
message: string;
|
|
1650
1779
|
}>;
|
|
1651
1780
|
/**
|
|
1652
1781
|
* Generate backup codes.
|
|
1653
1782
|
*
|
|
1654
|
-
* @returns
|
|
1783
|
+
* @returns Promise of backup codes array
|
|
1784
|
+
*
|
|
1785
|
+
* @example
|
|
1786
|
+
* ```typescript
|
|
1787
|
+
* const codes = await this.auth.generateBackupCodes();
|
|
1788
|
+
* console.log('Backup codes:', codes);
|
|
1789
|
+
* ```
|
|
1655
1790
|
*/
|
|
1656
|
-
generateBackupCodes():
|
|
1791
|
+
generateBackupCodes(): Promise<string[]>;
|
|
1657
1792
|
/**
|
|
1658
1793
|
* Set MFA exemption (admin/test scenarios).
|
|
1659
1794
|
*
|
|
1660
1795
|
* @param exempt - Whether to exempt user from MFA
|
|
1661
1796
|
* @param reason - Optional reason for exemption
|
|
1662
|
-
* @returns
|
|
1797
|
+
* @returns Promise that resolves when exemption is set
|
|
1798
|
+
*
|
|
1799
|
+
* @example
|
|
1800
|
+
* ```typescript
|
|
1801
|
+
* await this.auth.setMfaExemption(true, 'Test account');
|
|
1802
|
+
* ```
|
|
1663
1803
|
*/
|
|
1664
|
-
setMfaExemption(exempt: boolean, reason?: string):
|
|
1804
|
+
setMfaExemption(exempt: boolean, reason?: string): Promise<void>;
|
|
1665
1805
|
/**
|
|
1666
1806
|
* Trust current device.
|
|
1667
1807
|
*
|
|
1668
|
-
* @returns
|
|
1808
|
+
* @returns Promise with device token
|
|
1809
|
+
*
|
|
1810
|
+
* @example
|
|
1811
|
+
* ```typescript
|
|
1812
|
+
* const result = await this.auth.trustDevice();
|
|
1813
|
+
* console.log('Device trusted:', result.deviceToken);
|
|
1814
|
+
* ```
|
|
1669
1815
|
*/
|
|
1670
|
-
trustDevice():
|
|
1816
|
+
trustDevice(): Promise<{
|
|
1671
1817
|
deviceToken: string;
|
|
1672
1818
|
}>;
|
|
1673
1819
|
/**
|
|
1674
1820
|
* Check if the current device is trusted.
|
|
1675
1821
|
*
|
|
1676
|
-
* @returns
|
|
1822
|
+
* @returns Promise with trusted status
|
|
1823
|
+
*
|
|
1824
|
+
* @example
|
|
1825
|
+
* ```typescript
|
|
1826
|
+
* const result = await this.auth.isTrustedDevice();
|
|
1827
|
+
* if (result.trusted) {
|
|
1828
|
+
* console.log('This device is trusted');
|
|
1829
|
+
* }
|
|
1830
|
+
* ```
|
|
1677
1831
|
*/
|
|
1678
|
-
isTrustedDevice():
|
|
1832
|
+
isTrustedDevice(): Promise<{
|
|
1679
1833
|
trusted: boolean;
|
|
1680
1834
|
}>;
|
|
1681
1835
|
/**
|
|
1682
1836
|
* Get paginated audit history for the current user.
|
|
1683
1837
|
*
|
|
1684
1838
|
* @param params - Query parameters for filtering and pagination
|
|
1685
|
-
* @returns
|
|
1839
|
+
* @returns Promise of audit history response
|
|
1686
1840
|
*
|
|
1687
1841
|
* @example
|
|
1688
1842
|
* ```typescript
|
|
1689
|
-
* this.auth.getAuditHistory({
|
|
1690
|
-
*
|
|
1843
|
+
* const history = await this.auth.getAuditHistory({
|
|
1844
|
+
* page: 1,
|
|
1845
|
+
* limit: 20,
|
|
1846
|
+
* eventType: 'LOGIN_SUCCESS'
|
|
1691
1847
|
* });
|
|
1848
|
+
* console.log('Audit history:', history);
|
|
1692
1849
|
* ```
|
|
1693
1850
|
*/
|
|
1694
|
-
getAuditHistory(params?: Record<string, string | number | boolean>):
|
|
1851
|
+
getAuditHistory(params?: Record<string, string | number | boolean>): Promise<AuditHistoryResponse>;
|
|
1695
1852
|
/**
|
|
1696
1853
|
* Expose underlying NAuthClient for advanced scenarios.
|
|
1697
1854
|
*
|
|
1698
|
-
* @deprecated All core functionality is now exposed directly on AuthService as
|
|
1855
|
+
* @deprecated All core functionality is now exposed directly on AuthService as Promises.
|
|
1699
1856
|
* Use the direct methods on AuthService instead (e.g., `auth.changePassword()` instead of `auth.getClient().changePassword()`).
|
|
1700
1857
|
* This method is kept for backward compatibility only and may be removed in a future version.
|
|
1701
1858
|
*
|
|
@@ -1706,8 +1863,8 @@ declare class AuthService {
|
|
|
1706
1863
|
* // Deprecated - use direct methods instead
|
|
1707
1864
|
* const status = await this.auth.getClient().getMfaStatus();
|
|
1708
1865
|
*
|
|
1709
|
-
* // Preferred - use
|
|
1710
|
-
* this.auth.getMfaStatus()
|
|
1866
|
+
* // Preferred - use direct methods
|
|
1867
|
+
* const status = await this.auth.getMfaStatus();
|
|
1711
1868
|
* ```
|
|
1712
1869
|
*/
|
|
1713
1870
|
getClient(): NAuthClient;
|