@nauth-toolkit/client 0.1.59 → 0.1.60
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 +40 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +43 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.mjs +40 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -295,6 +295,21 @@ interface ConfirmForgotPasswordResponse {
|
|
|
295
295
|
success: boolean;
|
|
296
296
|
mustChangePassword: boolean;
|
|
297
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Reset password with code/token request (generic for both admin-initiated and user-initiated resets).
|
|
300
|
+
*/
|
|
301
|
+
interface ResetPasswordWithCodeRequest {
|
|
302
|
+
identifier: string;
|
|
303
|
+
code?: string;
|
|
304
|
+
token?: string;
|
|
305
|
+
newPassword: string;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Reset password with code response.
|
|
309
|
+
*/
|
|
310
|
+
interface ResetPasswordWithCodeResponse {
|
|
311
|
+
success: boolean;
|
|
312
|
+
}
|
|
298
313
|
|
|
299
314
|
/**
|
|
300
315
|
* Social provider identifiers.
|
|
@@ -545,6 +560,7 @@ interface NAuthEndpoints {
|
|
|
545
560
|
requestPasswordChange: string;
|
|
546
561
|
forgotPassword: string;
|
|
547
562
|
confirmForgotPassword: string;
|
|
563
|
+
confirmAdminResetPassword: string;
|
|
548
564
|
mfaStatus: string;
|
|
549
565
|
mfaDevices: string;
|
|
550
566
|
mfaSetupData: string;
|
|
@@ -1363,6 +1379,32 @@ declare class NAuthClient {
|
|
|
1363
1379
|
* Confirm a password reset code and set a new password.
|
|
1364
1380
|
*/
|
|
1365
1381
|
confirmForgotPassword(identifier: string, code: string, newPassword: string): Promise<ConfirmForgotPasswordResponse>;
|
|
1382
|
+
/**
|
|
1383
|
+
* Reset password with code or token (works for both admin-initiated and user-initiated resets).
|
|
1384
|
+
*
|
|
1385
|
+
* Accepts either:
|
|
1386
|
+
* - code: Short numeric code from email/SMS (6-10 digits)
|
|
1387
|
+
* - token: Long hex token from reset link (64 chars)
|
|
1388
|
+
*
|
|
1389
|
+
* WHY: Generic method that works for both admin-initiated (adminResetPassword) and
|
|
1390
|
+
* user-initiated (forgotPassword) password resets. Uses same backend endpoint.
|
|
1391
|
+
*
|
|
1392
|
+
* @param identifier - User identifier (email, username, phone)
|
|
1393
|
+
* @param codeOrToken - Verification code OR token from link (one required)
|
|
1394
|
+
* @param newPassword - New password
|
|
1395
|
+
* @returns Success response
|
|
1396
|
+
* @throws {NAuthClientError} When reset fails
|
|
1397
|
+
*
|
|
1398
|
+
* @example
|
|
1399
|
+
* ```typescript
|
|
1400
|
+
* // With code from email
|
|
1401
|
+
* await client.resetPasswordWithCode('user@example.com', '123456', 'NewPass123!');
|
|
1402
|
+
*
|
|
1403
|
+
* // With token from link
|
|
1404
|
+
* await client.resetPasswordWithCode('user@example.com', '64-char-token', 'NewPass123!');
|
|
1405
|
+
* ```
|
|
1406
|
+
*/
|
|
1407
|
+
resetPasswordWithCode(identifier: string, codeOrToken: string, newPassword: string): Promise<ResetPasswordWithCodeResponse>;
|
|
1366
1408
|
/**
|
|
1367
1409
|
* Request password change (must change on next login).
|
|
1368
1410
|
*/
|
|
@@ -1803,4 +1845,4 @@ declare class FetchAdapter implements HttpAdapter {
|
|
|
1803
1845
|
request<T>(config: HttpRequest): Promise<HttpResponse<T>>;
|
|
1804
1846
|
}
|
|
1805
1847
|
|
|
1806
|
-
export { type AuditHistoryResponse, type AuthAuditEvent, type AuthAuditEventStatus, AuthAuditEventType, AuthChallenge, type AuthChallengeEvent, type AuthErrorEvent, type AuthEvent, type AuthEventListener, type AuthEventType, type AuthLoginEvent, type AuthLogoutEvent, type AuthRefreshEvent, type AuthResponse, type AuthResponseContext, type AuthSignupEvent, type AuthSuccessEvent, type AuthUser, type AuthUserSummary, type BackupCodesResponse, type BaseChallengeResponse, BrowserStorage, type ChallengeResponse, ChallengeRouter, type ChangePasswordRequest, type ConfirmForgotPasswordRequest, type ConfirmForgotPasswordResponse, EventEmitter, FetchAdapter, type ForceChangePasswordResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetChallengeDataRequest, type GetChallengeDataResponse, type GetSetupDataRequest, type GetSetupDataResponse, type HttpAdapter, type HttpRequest, type HttpResponse, InMemoryStorage, type LinkedAccountsResponse, type LoginRequest, type LogoutAllRequest, type LogoutRequest, type MFAChallengeMethod, type MFACodeResponse, type MFADevice, type MFADeviceMethod, type MFAMethod, type MFAPasskeyResponse, type MFASetupData, type MFASetupResponse, type MFAStatus, type MfaRoutesConfig, NAuthClient, type NAuthClientConfig, NAuthClientError, type NAuthEndpoints, type NAuthError, NAuthErrorCode, type NAuthRedirectsConfig, type NAuthStorageAdapter, type OAuthCallbackEvent, type OAuthCompletedEvent, type OAuthErrorEvent, type OAuthStartedEvent, type ResendCodeRequest, type ResolvedNAuthClientConfig, type SignupRequest, type SocialLoginOptions, type SocialProvider, type SocialVerifyRequest, type TokenDeliveryMode, type TokenResponse, type UpdateProfileRequest, type VerifyEmailResponse, type VerifyPhoneCodeResponse, type VerifyPhoneCollectResponse, defaultEndpoints, getChallengeInstructions, getMFAMethod, getMaskedDestination, isOTPChallenge, requiresPhoneCollection, resolveConfig };
|
|
1848
|
+
export { type AuditHistoryResponse, type AuthAuditEvent, type AuthAuditEventStatus, AuthAuditEventType, AuthChallenge, type AuthChallengeEvent, type AuthErrorEvent, type AuthEvent, type AuthEventListener, type AuthEventType, type AuthLoginEvent, type AuthLogoutEvent, type AuthRefreshEvent, type AuthResponse, type AuthResponseContext, type AuthSignupEvent, type AuthSuccessEvent, type AuthUser, type AuthUserSummary, type BackupCodesResponse, type BaseChallengeResponse, BrowserStorage, type ChallengeResponse, ChallengeRouter, type ChangePasswordRequest, type ConfirmForgotPasswordRequest, type ConfirmForgotPasswordResponse, EventEmitter, FetchAdapter, type ForceChangePasswordResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetChallengeDataRequest, type GetChallengeDataResponse, type GetSetupDataRequest, type GetSetupDataResponse, type HttpAdapter, type HttpRequest, type HttpResponse, InMemoryStorage, type LinkedAccountsResponse, type LoginRequest, type LogoutAllRequest, type LogoutRequest, type MFAChallengeMethod, type MFACodeResponse, type MFADevice, type MFADeviceMethod, type MFAMethod, type MFAPasskeyResponse, type MFASetupData, type MFASetupResponse, type MFAStatus, type MfaRoutesConfig, NAuthClient, type NAuthClientConfig, NAuthClientError, type NAuthEndpoints, type NAuthError, NAuthErrorCode, type NAuthRedirectsConfig, type NAuthStorageAdapter, type OAuthCallbackEvent, type OAuthCompletedEvent, type OAuthErrorEvent, type OAuthStartedEvent, type ResendCodeRequest, type ResetPasswordWithCodeRequest, type ResetPasswordWithCodeResponse, type ResolvedNAuthClientConfig, type SignupRequest, type SocialLoginOptions, type SocialProvider, type SocialVerifyRequest, type TokenDeliveryMode, type TokenResponse, type UpdateProfileRequest, type VerifyEmailResponse, type VerifyPhoneCodeResponse, type VerifyPhoneCollectResponse, defaultEndpoints, getChallengeInstructions, getMFAMethod, getMaskedDestination, isOTPChallenge, requiresPhoneCollection, resolveConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -295,6 +295,21 @@ interface ConfirmForgotPasswordResponse {
|
|
|
295
295
|
success: boolean;
|
|
296
296
|
mustChangePassword: boolean;
|
|
297
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Reset password with code/token request (generic for both admin-initiated and user-initiated resets).
|
|
300
|
+
*/
|
|
301
|
+
interface ResetPasswordWithCodeRequest {
|
|
302
|
+
identifier: string;
|
|
303
|
+
code?: string;
|
|
304
|
+
token?: string;
|
|
305
|
+
newPassword: string;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Reset password with code response.
|
|
309
|
+
*/
|
|
310
|
+
interface ResetPasswordWithCodeResponse {
|
|
311
|
+
success: boolean;
|
|
312
|
+
}
|
|
298
313
|
|
|
299
314
|
/**
|
|
300
315
|
* Social provider identifiers.
|
|
@@ -545,6 +560,7 @@ interface NAuthEndpoints {
|
|
|
545
560
|
requestPasswordChange: string;
|
|
546
561
|
forgotPassword: string;
|
|
547
562
|
confirmForgotPassword: string;
|
|
563
|
+
confirmAdminResetPassword: string;
|
|
548
564
|
mfaStatus: string;
|
|
549
565
|
mfaDevices: string;
|
|
550
566
|
mfaSetupData: string;
|
|
@@ -1363,6 +1379,32 @@ declare class NAuthClient {
|
|
|
1363
1379
|
* Confirm a password reset code and set a new password.
|
|
1364
1380
|
*/
|
|
1365
1381
|
confirmForgotPassword(identifier: string, code: string, newPassword: string): Promise<ConfirmForgotPasswordResponse>;
|
|
1382
|
+
/**
|
|
1383
|
+
* Reset password with code or token (works for both admin-initiated and user-initiated resets).
|
|
1384
|
+
*
|
|
1385
|
+
* Accepts either:
|
|
1386
|
+
* - code: Short numeric code from email/SMS (6-10 digits)
|
|
1387
|
+
* - token: Long hex token from reset link (64 chars)
|
|
1388
|
+
*
|
|
1389
|
+
* WHY: Generic method that works for both admin-initiated (adminResetPassword) and
|
|
1390
|
+
* user-initiated (forgotPassword) password resets. Uses same backend endpoint.
|
|
1391
|
+
*
|
|
1392
|
+
* @param identifier - User identifier (email, username, phone)
|
|
1393
|
+
* @param codeOrToken - Verification code OR token from link (one required)
|
|
1394
|
+
* @param newPassword - New password
|
|
1395
|
+
* @returns Success response
|
|
1396
|
+
* @throws {NAuthClientError} When reset fails
|
|
1397
|
+
*
|
|
1398
|
+
* @example
|
|
1399
|
+
* ```typescript
|
|
1400
|
+
* // With code from email
|
|
1401
|
+
* await client.resetPasswordWithCode('user@example.com', '123456', 'NewPass123!');
|
|
1402
|
+
*
|
|
1403
|
+
* // With token from link
|
|
1404
|
+
* await client.resetPasswordWithCode('user@example.com', '64-char-token', 'NewPass123!');
|
|
1405
|
+
* ```
|
|
1406
|
+
*/
|
|
1407
|
+
resetPasswordWithCode(identifier: string, codeOrToken: string, newPassword: string): Promise<ResetPasswordWithCodeResponse>;
|
|
1366
1408
|
/**
|
|
1367
1409
|
* Request password change (must change on next login).
|
|
1368
1410
|
*/
|
|
@@ -1803,4 +1845,4 @@ declare class FetchAdapter implements HttpAdapter {
|
|
|
1803
1845
|
request<T>(config: HttpRequest): Promise<HttpResponse<T>>;
|
|
1804
1846
|
}
|
|
1805
1847
|
|
|
1806
|
-
export { type AuditHistoryResponse, type AuthAuditEvent, type AuthAuditEventStatus, AuthAuditEventType, AuthChallenge, type AuthChallengeEvent, type AuthErrorEvent, type AuthEvent, type AuthEventListener, type AuthEventType, type AuthLoginEvent, type AuthLogoutEvent, type AuthRefreshEvent, type AuthResponse, type AuthResponseContext, type AuthSignupEvent, type AuthSuccessEvent, type AuthUser, type AuthUserSummary, type BackupCodesResponse, type BaseChallengeResponse, BrowserStorage, type ChallengeResponse, ChallengeRouter, type ChangePasswordRequest, type ConfirmForgotPasswordRequest, type ConfirmForgotPasswordResponse, EventEmitter, FetchAdapter, type ForceChangePasswordResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetChallengeDataRequest, type GetChallengeDataResponse, type GetSetupDataRequest, type GetSetupDataResponse, type HttpAdapter, type HttpRequest, type HttpResponse, InMemoryStorage, type LinkedAccountsResponse, type LoginRequest, type LogoutAllRequest, type LogoutRequest, type MFAChallengeMethod, type MFACodeResponse, type MFADevice, type MFADeviceMethod, type MFAMethod, type MFAPasskeyResponse, type MFASetupData, type MFASetupResponse, type MFAStatus, type MfaRoutesConfig, NAuthClient, type NAuthClientConfig, NAuthClientError, type NAuthEndpoints, type NAuthError, NAuthErrorCode, type NAuthRedirectsConfig, type NAuthStorageAdapter, type OAuthCallbackEvent, type OAuthCompletedEvent, type OAuthErrorEvent, type OAuthStartedEvent, type ResendCodeRequest, type ResolvedNAuthClientConfig, type SignupRequest, type SocialLoginOptions, type SocialProvider, type SocialVerifyRequest, type TokenDeliveryMode, type TokenResponse, type UpdateProfileRequest, type VerifyEmailResponse, type VerifyPhoneCodeResponse, type VerifyPhoneCollectResponse, defaultEndpoints, getChallengeInstructions, getMFAMethod, getMaskedDestination, isOTPChallenge, requiresPhoneCollection, resolveConfig };
|
|
1848
|
+
export { type AuditHistoryResponse, type AuthAuditEvent, type AuthAuditEventStatus, AuthAuditEventType, AuthChallenge, type AuthChallengeEvent, type AuthErrorEvent, type AuthEvent, type AuthEventListener, type AuthEventType, type AuthLoginEvent, type AuthLogoutEvent, type AuthRefreshEvent, type AuthResponse, type AuthResponseContext, type AuthSignupEvent, type AuthSuccessEvent, type AuthUser, type AuthUserSummary, type BackupCodesResponse, type BaseChallengeResponse, BrowserStorage, type ChallengeResponse, ChallengeRouter, type ChangePasswordRequest, type ConfirmForgotPasswordRequest, type ConfirmForgotPasswordResponse, EventEmitter, FetchAdapter, type ForceChangePasswordResponse, type ForgotPasswordRequest, type ForgotPasswordResponse, type GetChallengeDataRequest, type GetChallengeDataResponse, type GetSetupDataRequest, type GetSetupDataResponse, type HttpAdapter, type HttpRequest, type HttpResponse, InMemoryStorage, type LinkedAccountsResponse, type LoginRequest, type LogoutAllRequest, type LogoutRequest, type MFAChallengeMethod, type MFACodeResponse, type MFADevice, type MFADeviceMethod, type MFAMethod, type MFAPasskeyResponse, type MFASetupData, type MFASetupResponse, type MFAStatus, type MfaRoutesConfig, NAuthClient, type NAuthClientConfig, NAuthClientError, type NAuthEndpoints, type NAuthError, NAuthErrorCode, type NAuthRedirectsConfig, type NAuthStorageAdapter, type OAuthCallbackEvent, type OAuthCompletedEvent, type OAuthErrorEvent, type OAuthStartedEvent, type ResendCodeRequest, type ResetPasswordWithCodeRequest, type ResetPasswordWithCodeResponse, type ResolvedNAuthClientConfig, type SignupRequest, type SocialLoginOptions, type SocialProvider, type SocialVerifyRequest, type TokenDeliveryMode, type TokenResponse, type UpdateProfileRequest, type VerifyEmailResponse, type VerifyPhoneCodeResponse, type VerifyPhoneCollectResponse, defaultEndpoints, getChallengeInstructions, getMFAMethod, getMaskedDestination, isOTPChallenge, requiresPhoneCollection, resolveConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -118,6 +118,7 @@ var defaultEndpoints = {
|
|
|
118
118
|
requestPasswordChange: "/request-password-change",
|
|
119
119
|
forgotPassword: "/forgot-password",
|
|
120
120
|
confirmForgotPassword: "/forgot-password/confirm",
|
|
121
|
+
confirmAdminResetPassword: "/admin/reset-password/confirm",
|
|
121
122
|
mfaStatus: "/mfa/status",
|
|
122
123
|
mfaDevices: "/mfa/devices",
|
|
123
124
|
mfaSetupData: "/mfa/setup-data",
|
|
@@ -981,6 +982,45 @@ var NAuthClient = class {
|
|
|
981
982
|
await this.clearAuthState(false);
|
|
982
983
|
return result;
|
|
983
984
|
}
|
|
985
|
+
/**
|
|
986
|
+
* Reset password with code or token (works for both admin-initiated and user-initiated resets).
|
|
987
|
+
*
|
|
988
|
+
* Accepts either:
|
|
989
|
+
* - code: Short numeric code from email/SMS (6-10 digits)
|
|
990
|
+
* - token: Long hex token from reset link (64 chars)
|
|
991
|
+
*
|
|
992
|
+
* WHY: Generic method that works for both admin-initiated (adminResetPassword) and
|
|
993
|
+
* user-initiated (forgotPassword) password resets. Uses same backend endpoint.
|
|
994
|
+
*
|
|
995
|
+
* @param identifier - User identifier (email, username, phone)
|
|
996
|
+
* @param codeOrToken - Verification code OR token from link (one required)
|
|
997
|
+
* @param newPassword - New password
|
|
998
|
+
* @returns Success response
|
|
999
|
+
* @throws {NAuthClientError} When reset fails
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```typescript
|
|
1003
|
+
* // With code from email
|
|
1004
|
+
* await client.resetPasswordWithCode('user@example.com', '123456', 'NewPass123!');
|
|
1005
|
+
*
|
|
1006
|
+
* // With token from link
|
|
1007
|
+
* await client.resetPasswordWithCode('user@example.com', '64-char-token', 'NewPass123!');
|
|
1008
|
+
* ```
|
|
1009
|
+
*/
|
|
1010
|
+
async resetPasswordWithCode(identifier, codeOrToken, newPassword) {
|
|
1011
|
+
const isToken = codeOrToken.length > 10;
|
|
1012
|
+
const payload = {
|
|
1013
|
+
identifier,
|
|
1014
|
+
...isToken ? { token: codeOrToken } : { code: codeOrToken },
|
|
1015
|
+
newPassword
|
|
1016
|
+
};
|
|
1017
|
+
const result = await this.post(
|
|
1018
|
+
this.config.endpoints.confirmAdminResetPassword,
|
|
1019
|
+
payload
|
|
1020
|
+
);
|
|
1021
|
+
await this.clearAuthState(false);
|
|
1022
|
+
return result;
|
|
1023
|
+
}
|
|
984
1024
|
/**
|
|
985
1025
|
* Request password change (must change on next login).
|
|
986
1026
|
*/
|