@nauth-toolkit/client 0.1.86 → 0.1.87

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.d.mts CHANGED
@@ -262,7 +262,7 @@ interface UpdateProfileRequest {
262
262
  * Change password request.
263
263
  */
264
264
  interface ChangePasswordRequest {
265
- currentPassword: string;
265
+ oldPassword: string;
266
266
  newPassword: string;
267
267
  }
268
268
  /**
@@ -296,12 +296,11 @@ interface ConfirmForgotPasswordResponse {
296
296
  mustChangePassword: boolean;
297
297
  }
298
298
  /**
299
- * Reset password with code/token request (generic for both admin-initiated and user-initiated resets).
299
+ * Reset password with code request (generic for both admin-initiated and user-initiated resets).
300
300
  */
301
301
  interface ResetPasswordWithCodeRequest {
302
302
  identifier: string;
303
- code?: string;
304
- token?: string;
303
+ code: string;
305
304
  newPassword: string;
306
305
  }
307
306
  /**
@@ -568,7 +567,6 @@ interface NAuthEndpoints {
568
567
  mfaRemove: string;
569
568
  mfaPreferred: string;
570
569
  mfaBackupCodes: string;
571
- mfaExemption: string;
572
570
  socialLinked: string;
573
571
  socialLink: string;
574
572
  socialUnlink: string;
@@ -1452,31 +1450,27 @@ declare class NAuthClient {
1452
1450
  */
1453
1451
  confirmForgotPassword(identifier: string, code: string, newPassword: string): Promise<ConfirmForgotPasswordResponse>;
1454
1452
  /**
1455
- * Reset password with code or token (works for both admin-initiated and user-initiated resets).
1453
+ * Reset password with verification code (works for both admin-initiated and user-initiated resets).
1456
1454
  *
1457
- * Accepts either:
1458
- * - code: Short numeric code from email/SMS (6-10 digits)
1459
- * - token: Long hex token from reset link (64 chars)
1455
+ * NOTE:
1456
+ * - Links (when provided by the backend email provider) include the same verification code as a query param
1457
+ * (e.g., `...?code=123456`) so consumer apps stay code-only and consistent.
1460
1458
  *
1461
1459
  * WHY: Generic method that works for both admin-initiated (adminResetPassword) and
1462
1460
  * user-initiated (forgotPassword) password resets. Uses same backend endpoint.
1463
1461
  *
1464
1462
  * @param identifier - User identifier (email, username, phone)
1465
- * @param codeOrToken - Verification code OR token from link (one required)
1463
+ * @param code - Verification code from email/SMS (6-10 digits)
1466
1464
  * @param newPassword - New password
1467
1465
  * @returns Success response
1468
1466
  * @throws {NAuthClientError} When reset fails
1469
1467
  *
1470
1468
  * @example
1471
1469
  * ```typescript
1472
- * // With code from email
1473
1470
  * await client.resetPasswordWithCode('user@example.com', '123456', 'NewPass123!');
1474
- *
1475
- * // With token from link
1476
- * await client.resetPasswordWithCode('user@example.com', '64-char-token', 'NewPass123!');
1477
1471
  * ```
1478
1472
  */
1479
- resetPasswordWithCode(identifier: string, codeOrToken: string, newPassword: string): Promise<ResetPasswordWithCodeResponse>;
1473
+ resetPasswordWithCode(identifier: string, code: string, newPassword: string): Promise<ResetPasswordWithCodeResponse>;
1480
1474
  /**
1481
1475
  * Request password change (must change on next login).
1482
1476
  */
@@ -1519,9 +1513,10 @@ declare class NAuthClient {
1519
1513
  */
1520
1514
  generateBackupCodes(): Promise<string[]>;
1521
1515
  /**
1522
- * Set MFA exemption (admin/test scenarios).
1516
+ * ============================================================================
1517
+ * Event System
1518
+ * ============================================================================
1523
1519
  */
1524
- setMfaExemption(exempt: boolean, reason?: string): Promise<void>;
1525
1520
  /**
1526
1521
  * Subscribe to authentication events.
1527
1522
  *
package/dist/index.d.ts CHANGED
@@ -262,7 +262,7 @@ interface UpdateProfileRequest {
262
262
  * Change password request.
263
263
  */
264
264
  interface ChangePasswordRequest {
265
- currentPassword: string;
265
+ oldPassword: string;
266
266
  newPassword: string;
267
267
  }
268
268
  /**
@@ -296,12 +296,11 @@ interface ConfirmForgotPasswordResponse {
296
296
  mustChangePassword: boolean;
297
297
  }
298
298
  /**
299
- * Reset password with code/token request (generic for both admin-initiated and user-initiated resets).
299
+ * Reset password with code request (generic for both admin-initiated and user-initiated resets).
300
300
  */
301
301
  interface ResetPasswordWithCodeRequest {
302
302
  identifier: string;
303
- code?: string;
304
- token?: string;
303
+ code: string;
305
304
  newPassword: string;
306
305
  }
307
306
  /**
@@ -568,7 +567,6 @@ interface NAuthEndpoints {
568
567
  mfaRemove: string;
569
568
  mfaPreferred: string;
570
569
  mfaBackupCodes: string;
571
- mfaExemption: string;
572
570
  socialLinked: string;
573
571
  socialLink: string;
574
572
  socialUnlink: string;
@@ -1452,31 +1450,27 @@ declare class NAuthClient {
1452
1450
  */
1453
1451
  confirmForgotPassword(identifier: string, code: string, newPassword: string): Promise<ConfirmForgotPasswordResponse>;
1454
1452
  /**
1455
- * Reset password with code or token (works for both admin-initiated and user-initiated resets).
1453
+ * Reset password with verification code (works for both admin-initiated and user-initiated resets).
1456
1454
  *
1457
- * Accepts either:
1458
- * - code: Short numeric code from email/SMS (6-10 digits)
1459
- * - token: Long hex token from reset link (64 chars)
1455
+ * NOTE:
1456
+ * - Links (when provided by the backend email provider) include the same verification code as a query param
1457
+ * (e.g., `...?code=123456`) so consumer apps stay code-only and consistent.
1460
1458
  *
1461
1459
  * WHY: Generic method that works for both admin-initiated (adminResetPassword) and
1462
1460
  * user-initiated (forgotPassword) password resets. Uses same backend endpoint.
1463
1461
  *
1464
1462
  * @param identifier - User identifier (email, username, phone)
1465
- * @param codeOrToken - Verification code OR token from link (one required)
1463
+ * @param code - Verification code from email/SMS (6-10 digits)
1466
1464
  * @param newPassword - New password
1467
1465
  * @returns Success response
1468
1466
  * @throws {NAuthClientError} When reset fails
1469
1467
  *
1470
1468
  * @example
1471
1469
  * ```typescript
1472
- * // With code from email
1473
1470
  * await client.resetPasswordWithCode('user@example.com', '123456', 'NewPass123!');
1474
- *
1475
- * // With token from link
1476
- * await client.resetPasswordWithCode('user@example.com', '64-char-token', 'NewPass123!');
1477
1471
  * ```
1478
1472
  */
1479
- resetPasswordWithCode(identifier: string, codeOrToken: string, newPassword: string): Promise<ResetPasswordWithCodeResponse>;
1473
+ resetPasswordWithCode(identifier: string, code: string, newPassword: string): Promise<ResetPasswordWithCodeResponse>;
1480
1474
  /**
1481
1475
  * Request password change (must change on next login).
1482
1476
  */
@@ -1519,9 +1513,10 @@ declare class NAuthClient {
1519
1513
  */
1520
1514
  generateBackupCodes(): Promise<string[]>;
1521
1515
  /**
1522
- * Set MFA exemption (admin/test scenarios).
1516
+ * ============================================================================
1517
+ * Event System
1518
+ * ============================================================================
1523
1519
  */
1524
- setMfaExemption(exempt: boolean, reason?: string): Promise<void>;
1525
1520
  /**
1526
1521
  * Subscribe to authentication events.
1527
1522
  *
package/dist/index.mjs CHANGED
@@ -126,7 +126,6 @@ var defaultEndpoints = {
126
126
  mfaRemove: "/mfa/method",
127
127
  mfaPreferred: "/mfa/preferred-method",
128
128
  mfaBackupCodes: "/mfa/backup-codes/generate",
129
- mfaExemption: "/mfa/exemption",
130
129
  socialLinked: "/social/linked",
131
130
  socialLink: "/social/link",
132
131
  socialUnlink: "/social/unlink",
@@ -1026,7 +1025,7 @@ var NAuthClient = class {
1026
1025
  * Change user password.
1027
1026
  */
1028
1027
  async changePassword(oldPassword, newPassword) {
1029
- const payload = { currentPassword: oldPassword, newPassword };
1028
+ const payload = { oldPassword, newPassword };
1030
1029
  await this.post(this.config.endpoints.changePassword, payload, true);
1031
1030
  }
1032
1031
  /**
@@ -1046,35 +1045,30 @@ var NAuthClient = class {
1046
1045
  return result;
1047
1046
  }
1048
1047
  /**
1049
- * Reset password with code or token (works for both admin-initiated and user-initiated resets).
1048
+ * Reset password with verification code (works for both admin-initiated and user-initiated resets).
1050
1049
  *
1051
- * Accepts either:
1052
- * - code: Short numeric code from email/SMS (6-10 digits)
1053
- * - token: Long hex token from reset link (64 chars)
1050
+ * NOTE:
1051
+ * - Links (when provided by the backend email provider) include the same verification code as a query param
1052
+ * (e.g., `...?code=123456`) so consumer apps stay code-only and consistent.
1054
1053
  *
1055
1054
  * WHY: Generic method that works for both admin-initiated (adminResetPassword) and
1056
1055
  * user-initiated (forgotPassword) password resets. Uses same backend endpoint.
1057
1056
  *
1058
1057
  * @param identifier - User identifier (email, username, phone)
1059
- * @param codeOrToken - Verification code OR token from link (one required)
1058
+ * @param code - Verification code from email/SMS (6-10 digits)
1060
1059
  * @param newPassword - New password
1061
1060
  * @returns Success response
1062
1061
  * @throws {NAuthClientError} When reset fails
1063
1062
  *
1064
1063
  * @example
1065
1064
  * ```typescript
1066
- * // With code from email
1067
1065
  * await client.resetPasswordWithCode('user@example.com', '123456', 'NewPass123!');
1068
- *
1069
- * // With token from link
1070
- * await client.resetPasswordWithCode('user@example.com', '64-char-token', 'NewPass123!');
1071
1066
  * ```
1072
1067
  */
1073
- async resetPasswordWithCode(identifier, codeOrToken, newPassword) {
1074
- const isToken = codeOrToken.length > 10;
1068
+ async resetPasswordWithCode(identifier, code, newPassword) {
1075
1069
  const payload = {
1076
1070
  identifier,
1077
- ...isToken ? { token: codeOrToken } : { code: codeOrToken },
1071
+ code,
1078
1072
  newPassword
1079
1073
  };
1080
1074
  const result = await this.post(
@@ -1144,14 +1138,10 @@ var NAuthClient = class {
1144
1138
  return result.codes;
1145
1139
  }
1146
1140
  /**
1147
- * Set MFA exemption (admin/test scenarios).
1141
+ * ============================================================================
1142
+ * Event System
1143
+ * ============================================================================
1148
1144
  */
1149
- async setMfaExemption(exempt, reason) {
1150
- await this.post(this.config.endpoints.mfaExemption, { exempt, reason }, true);
1151
- }
1152
- // ============================================================================
1153
- // Event System
1154
- // ============================================================================
1155
1145
  /**
1156
1146
  * Subscribe to authentication events.
1157
1147
  *