@nauth-toolkit/client-angular 0.1.112 → 0.1.115

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.
@@ -2,7 +2,7 @@ import { Router } from '@angular/router';
2
2
  import { Observable } from 'rxjs';
3
3
  import { AngularHttpAdapter } from './http-adapter';
4
4
  import { RecaptchaService } from '../lib/recaptcha.service';
5
- import { NAuthClient, NAuthClientConfig, ChallengeResponse, AuthResponse, TokenResponse, AuthUser, ConfirmForgotPasswordResponse, ForgotPasswordResponse, ResetPasswordWithCodeResponse, UpdateProfileRequest, GetChallengeDataResponse, GetSetupDataResponse, MFAStatus, MFADevice, AuthEvent, SocialProvider, SocialLoginOptions, LinkedAccountsResponse, SocialVerifyRequest, AuditHistoryResponse, AdminOperations } from '@nauth-toolkit/client';
5
+ import { NAuthClient, NAuthClientConfig, ChallengeResponse, AuthResponse, TokenResponse, AuthUser, ConfirmForgotPasswordResponse, ForgotPasswordResponse, ResetPasswordWithCodeResponse, UpdateProfileRequest, GetChallengeDataResponse, GetSetupDataResponse, GetMFADevicesResponse, MFAStatus, RemoveMFADeviceResponse, AuthEvent, SocialProvider, SocialLoginOptions, LinkedAccountsResponse, SocialVerifyRequest, AuditHistoryResponse, AdminOperations } from '@nauth-toolkit/client';
6
6
  import * as i0 from "@angular/core";
7
7
  /**
8
8
  * Angular wrapper around NAuthClient that provides promise-based auth methods and reactive state.
@@ -492,37 +492,94 @@ export declare class AuthService {
492
492
  /**
493
493
  * Get MFA devices for the current user.
494
494
  *
495
- * @returns Promise of MFA devices array
495
+ * @returns Promise of MFA devices response
496
496
  *
497
497
  * @example
498
498
  * ```typescript
499
- * const devices = await this.auth.getMfaDevices();
499
+ * const result = await this.auth.getMfaDevices();
500
+ * console.log('Devices:', result.devices);
500
501
  * ```
501
502
  */
502
- getMfaDevices(): Promise<MFADevice[]>;
503
+ getMfaDevices(): Promise<GetMFADevicesResponse>;
503
504
  /**
504
505
  * Setup MFA device (authenticated user).
505
506
  *
507
+ * Returns method-specific setup information:
508
+ * - TOTP: { secret, qrCode, manualEntryKey }
509
+ * - SMS: { maskedPhone } or { deviceId, autoCompleted: true }
510
+ * - Email: { maskedEmail } or { deviceId, autoCompleted: true }
511
+ * - Passkey: WebAuthn registration options
512
+ *
506
513
  * @param method - MFA method to set up
507
- * @returns Promise of setup data
514
+ * @returns Promise of setup data response
508
515
  *
509
516
  * @example
510
517
  * ```typescript
511
- * const setupData = await this.auth.setupMfaDevice('totp');
518
+ * const result = await this.auth.setupMfaDevice('totp');
519
+ * console.log('QR Code:', result.setupData.qrCode);
512
520
  * ```
513
521
  */
514
- setupMfaDevice(method: string): Promise<unknown>;
522
+ setupMfaDevice(method: string): Promise<GetSetupDataResponse>;
515
523
  /**
516
524
  * Verify MFA setup (authenticated user).
517
525
  *
518
- * @param method - MFA method
519
- * @param setupData - Setup data from setupMfaDevice
520
- * @param deviceName - Optional device name
521
- * @returns Promise with device ID
526
+ * Completes MFA device setup by verifying the setup data. The structure of `setupData` varies by method:
522
527
  *
523
- * @example
528
+ * **TOTP:**
529
+ * - Requires both `secret` (from `getSetupData()` response) and `code` (from authenticator app)
530
+ * - Example: `{ secret: 'JBSWY3DPEHPK3PXP', code: '123456' }`
531
+ *
532
+ * **SMS:**
533
+ * - Requires `phoneNumber` and `code` (verification code sent to phone)
534
+ * - Example: `{ phoneNumber: '+1234567890', code: '123456' }`
535
+ *
536
+ * **Email:**
537
+ * - Requires `code` (verification code sent to email)
538
+ * - Example: `{ code: '123456' }`
539
+ *
540
+ * **Passkey:**
541
+ * - Requires `credential` (WebAuthn credential from registration) and `expectedChallenge`
542
+ * - Example: `{ credential: {...}, expectedChallenge: '...' }`
543
+ *
544
+ * @param method - MFA method ('totp', 'sms', 'email', 'passkey')
545
+ * @param setupData - Method-specific setup verification data
546
+ * @param deviceName - Optional device name (can also be included in setupData for some methods)
547
+ * @returns Promise with device ID of the created MFA device
548
+ *
549
+ * @example TOTP Setup
524
550
  * ```typescript
525
- * const result = await this.auth.verifyMfaSetup('totp', { code: '123456' }, 'My Phone');
551
+ * // Step 1: Get setup data
552
+ * const setupData = await this.auth.setupMfaDevice('totp');
553
+ * // Returns: { setupData: { secret: 'JBSWY3DPEHPK3PXP', qrCode: '...', ... } }
554
+ *
555
+ * // Step 2: User scans QR code and enters code from authenticator app
556
+ * const code = '123456'; // From authenticator app
557
+ *
558
+ * // Step 3: Verify setup (requires both secret and code)
559
+ * const result = await this.auth.verifyMfaSetup('totp', {
560
+ * secret: setupData.setupData.secret,
561
+ * code: code,
562
+ * }, 'Google Authenticator');
563
+ * // Returns: { deviceId: 123 }
564
+ * ```
565
+ *
566
+ * @example SMS Setup
567
+ * ```typescript
568
+ * const result = await this.auth.verifyMfaSetup('sms', {
569
+ * phoneNumber: '+1234567890', // Phone number receiving the code
570
+ * code: '123456', // Code sent to phone
571
+ * }, 'My iPhone');
572
+ * ```
573
+ *
574
+ * @example Passkey Setup
575
+ * ```typescript
576
+ * const credential = await navigator.credentials.create({
577
+ * publicKey: setupData.setupData.options
578
+ * });
579
+ * const result = await this.auth.verifyMfaSetup('passkey', {
580
+ * credential: credential,
581
+ * expectedChallenge: setupData.setupData.challenge,
582
+ * }, 'MacBook Pro');
526
583
  * ```
527
584
  */
528
585
  verifyMfaSetup(method: string, setupData: Record<string, unknown>, deviceName?: string): Promise<{
@@ -542,7 +599,7 @@ export declare class AuthService {
542
599
  * await this.auth.removeMfaDeviceById(devices[0].id);
543
600
  * ```
544
601
  */
545
- removeMfaDeviceById(deviceId: number): Promise<import('@nauth-toolkit/client').RemoveMFADeviceResponse>;
602
+ removeMfaDeviceById(deviceId: number): Promise<RemoveMFADeviceResponse>;
546
603
  /**
547
604
 
548
605
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nauth-toolkit/client-angular",
3
- "version": "0.1.112",
3
+ "version": "0.1.115",
4
4
  "description": "Angular adapter for nauth-toolkit client SDK",
5
5
  "keywords": [
6
6
  "nauth",
@@ -24,7 +24,7 @@
24
24
  "peerDependencies": {
25
25
  "@angular/common": ">=17.0.0",
26
26
  "@angular/core": ">=17.0.0",
27
- "@nauth-toolkit/client": "^0.1.112",
27
+ "@nauth-toolkit/client": "^0.1.115",
28
28
  "rxjs": "^7.0.0 || ^8.0.0"
29
29
  },
30
30
  "dependencies": {