@tstdl/base 0.85.20 → 0.85.21
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.
|
@@ -51,6 +51,10 @@ export type TokenResult<AdditionalTokenPayload extends Record = Record<never>> =
|
|
|
51
51
|
jsonToken: Token<AdditionalTokenPayload>;
|
|
52
52
|
refreshToken: string;
|
|
53
53
|
};
|
|
54
|
+
export type SetCredentialsOptions = {
|
|
55
|
+
/** skip validation for password strength */
|
|
56
|
+
skipValidation?: boolean;
|
|
57
|
+
};
|
|
54
58
|
type CreateTokenResult<AdditionalTokenPayload extends Record> = {
|
|
55
59
|
token: string;
|
|
56
60
|
jsonToken: Token<AdditionalTokenPayload>;
|
|
@@ -80,7 +84,7 @@ export declare class AuthenticationService<AdditionalTokenPayload extends Record
|
|
|
80
84
|
constructor(credentialsRepository: AuthenticationCredentialsRepository, sessionRepository: AuthenticationSessionRepository, authenticationSecretRequirementsValidator: AuthenticationSecretRequirementsValidator, subjectResolver: AuthenticationSubjectResolver | undefined, tokenPayloadProvider: AuthenticationTokenPayloadProvider<AdditionalTokenPayload, AuthenticationData> | undefined, authenticationResetSecretHandler: AuthenticationSecretResetHandler | undefined, options: AuthenticationServiceOptions);
|
|
81
85
|
[afterResolve](): Promise<void>;
|
|
82
86
|
initialize(): Promise<void>;
|
|
83
|
-
setCredentials(subject: string, secret: string): Promise<void>;
|
|
87
|
+
setCredentials(subject: string, secret: string, options?: SetCredentialsOptions): Promise<void>;
|
|
84
88
|
authenticate(subject: string, secret: string): Promise<AuthenticationResult>;
|
|
85
89
|
getToken(subject: string, authenticationData: AuthenticationData): Promise<TokenResult<AdditionalTokenPayload>>;
|
|
86
90
|
endSession(sessionId: string): Promise<void>;
|
|
@@ -116,9 +116,11 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
116
116
|
this.derivedSecretResetTokenSigningSecret = this.options.secret.secretResetTokenSigningSecret;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
async setCredentials(subject, secret) {
|
|
119
|
+
async setCredentials(subject, secret, options) {
|
|
120
120
|
const actualSubject = await this.resolveSubject(subject);
|
|
121
|
-
|
|
121
|
+
if (options?.skipValidation != true) {
|
|
122
|
+
await this.authenticationSecretRequirementsValidator.validateSecretRequirements(secret);
|
|
123
|
+
}
|
|
122
124
|
const salt = (0, import_random.getRandomBytes)(32);
|
|
123
125
|
const hash = await this.getHash(secret, salt);
|
|
124
126
|
const credentials = {
|