@nauth-toolkit/client 0.8.0 → 0.8.2

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/index.cjs CHANGED
@@ -2639,20 +2639,31 @@ var NAuthClient = class {
2639
2639
  return this.post(this.config.endpoints.resendCode, payload);
2640
2640
  }
2641
2641
  /**
2642
- * Get setup data for MFA.
2642
+ * Get setup data for MFA during an `MFA_SETUP_REQUIRED` challenge.
2643
2643
  *
2644
2644
  * Returns method-specific setup information:
2645
2645
  * - TOTP: { secret, qrCode, manualEntryKey }
2646
- * - SMS: { maskedPhone }
2647
- * - Email: { maskedEmail }
2646
+ * - SMS: { maskedPhone } (code sent) or { deviceId, autoCompleted: true }
2647
+ * - Email: { maskedEmail } or { deviceId, autoCompleted: true }
2648
2648
  * - Passkey: WebAuthn registration options
2649
2649
  *
2650
+ * For SMS, pass `{ phoneNumber }` (E.164) when the challenge has `requiresPhoneCollection: 'true'`
2651
+ * (see `requiresPhoneCollection()`): the number is saved to the account and verified by the code.
2652
+ * Call again with a different `phoneNumber` to change it, or without `setupData` to resend.
2653
+ *
2650
2654
  * @param session - Challenge session token
2651
2655
  * @param method - MFA method to set up
2656
+ * @param setupData - Optional method-specific input (SMS: `{ phoneNumber?, deviceName? }`)
2652
2657
  * @returns Setup data wrapped in GetSetupDataResponse
2658
+ *
2659
+ * @example
2660
+ * ```typescript
2661
+ * const { setupData } = await client.getSetupData(session, 'sms', { phoneNumber: '+14155552671' });
2662
+ * // setupData: { maskedPhone: '+1***2671' }
2663
+ * ```
2653
2664
  */
2654
- async getSetupData(session, method) {
2655
- const payload = { session, method };
2665
+ async getSetupData(session, method, setupData) {
2666
+ const payload = setupData ? { session, method, setupData } : { session, method };
2656
2667
  return this.post(this.config.endpoints.getSetupData, payload);
2657
2668
  }
2658
2669
  /**
@@ -3580,7 +3591,7 @@ var NAuthClient = class {
3580
3591
 
3581
3592
  // src/core/challenge-helpers.ts
3582
3593
  function requiresPhoneCollection(challenge) {
3583
- if (challenge.challengeName !== "VERIFY_PHONE" /* VERIFY_PHONE */) {
3594
+ if (challenge.challengeName !== "VERIFY_PHONE" /* VERIFY_PHONE */ && challenge.challengeName !== "MFA_SETUP_REQUIRED" /* MFA_SETUP_REQUIRED */) {
3584
3595
  return false;
3585
3596
  }
3586
3597
  const params = challenge.challengeParameters;