@nauth-toolkit/client 0.1.85 → 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.cjs +11 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +12 -17
- package/dist/index.d.ts +12 -17
- package/dist/index.mjs +11 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -166,7 +166,6 @@ var defaultEndpoints = {
|
|
|
166
166
|
mfaRemove: "/mfa/method",
|
|
167
167
|
mfaPreferred: "/mfa/preferred-method",
|
|
168
168
|
mfaBackupCodes: "/mfa/backup-codes/generate",
|
|
169
|
-
mfaExemption: "/mfa/exemption",
|
|
170
169
|
socialLinked: "/social/linked",
|
|
171
170
|
socialLink: "/social/link",
|
|
172
171
|
socialUnlink: "/social/unlink",
|
|
@@ -1066,7 +1065,7 @@ var NAuthClient = class {
|
|
|
1066
1065
|
* Change user password.
|
|
1067
1066
|
*/
|
|
1068
1067
|
async changePassword(oldPassword, newPassword) {
|
|
1069
|
-
const payload = {
|
|
1068
|
+
const payload = { oldPassword, newPassword };
|
|
1070
1069
|
await this.post(this.config.endpoints.changePassword, payload, true);
|
|
1071
1070
|
}
|
|
1072
1071
|
/**
|
|
@@ -1086,35 +1085,30 @@ var NAuthClient = class {
|
|
|
1086
1085
|
return result;
|
|
1087
1086
|
}
|
|
1088
1087
|
/**
|
|
1089
|
-
* Reset password with code
|
|
1088
|
+
* Reset password with verification code (works for both admin-initiated and user-initiated resets).
|
|
1090
1089
|
*
|
|
1091
|
-
*
|
|
1092
|
-
* -
|
|
1093
|
-
*
|
|
1090
|
+
* NOTE:
|
|
1091
|
+
* - Links (when provided by the backend email provider) include the same verification code as a query param
|
|
1092
|
+
* (e.g., `...?code=123456`) so consumer apps stay code-only and consistent.
|
|
1094
1093
|
*
|
|
1095
1094
|
* WHY: Generic method that works for both admin-initiated (adminResetPassword) and
|
|
1096
1095
|
* user-initiated (forgotPassword) password resets. Uses same backend endpoint.
|
|
1097
1096
|
*
|
|
1098
1097
|
* @param identifier - User identifier (email, username, phone)
|
|
1099
|
-
* @param
|
|
1098
|
+
* @param code - Verification code from email/SMS (6-10 digits)
|
|
1100
1099
|
* @param newPassword - New password
|
|
1101
1100
|
* @returns Success response
|
|
1102
1101
|
* @throws {NAuthClientError} When reset fails
|
|
1103
1102
|
*
|
|
1104
1103
|
* @example
|
|
1105
1104
|
* ```typescript
|
|
1106
|
-
* // With code from email
|
|
1107
1105
|
* await client.resetPasswordWithCode('user@example.com', '123456', 'NewPass123!');
|
|
1108
|
-
*
|
|
1109
|
-
* // With token from link
|
|
1110
|
-
* await client.resetPasswordWithCode('user@example.com', '64-char-token', 'NewPass123!');
|
|
1111
1106
|
* ```
|
|
1112
1107
|
*/
|
|
1113
|
-
async resetPasswordWithCode(identifier,
|
|
1114
|
-
const isToken = codeOrToken.length > 10;
|
|
1108
|
+
async resetPasswordWithCode(identifier, code, newPassword) {
|
|
1115
1109
|
const payload = {
|
|
1116
1110
|
identifier,
|
|
1117
|
-
|
|
1111
|
+
code,
|
|
1118
1112
|
newPassword
|
|
1119
1113
|
};
|
|
1120
1114
|
const result = await this.post(
|
|
@@ -1184,14 +1178,10 @@ var NAuthClient = class {
|
|
|
1184
1178
|
return result.codes;
|
|
1185
1179
|
}
|
|
1186
1180
|
/**
|
|
1187
|
-
*
|
|
1181
|
+
* ============================================================================
|
|
1182
|
+
* Event System
|
|
1183
|
+
* ============================================================================
|
|
1188
1184
|
*/
|
|
1189
|
-
async setMfaExemption(exempt, reason) {
|
|
1190
|
-
await this.post(this.config.endpoints.mfaExemption, { exempt, reason }, true);
|
|
1191
|
-
}
|
|
1192
|
-
// ============================================================================
|
|
1193
|
-
// Event System
|
|
1194
|
-
// ============================================================================
|
|
1195
1185
|
/**
|
|
1196
1186
|
* Subscribe to authentication events.
|
|
1197
1187
|
*
|