@tstdl/base 0.83.4 → 0.83.5
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.
|
@@ -74,7 +74,7 @@ class AuthenticationServiceOptions {
|
|
|
74
74
|
/** How long a secret reset token is valid. */
|
|
75
75
|
secretResetTokenTimeToLive;
|
|
76
76
|
}
|
|
77
|
-
const SIGNING_SECRETS_LENGTH =
|
|
77
|
+
const SIGNING_SECRETS_LENGTH = 64;
|
|
78
78
|
let AuthenticationService = class AuthenticationService2 {
|
|
79
79
|
credentialsRepository;
|
|
80
80
|
sessionRepository;
|
|
@@ -282,7 +282,7 @@ let AuthenticationService = class AuthenticationService2 {
|
|
|
282
282
|
async deriveSigningSecrets(secret) {
|
|
283
283
|
const key = await (0, import_cryptography.importPbkdf2Key)(secret);
|
|
284
284
|
const algorithm = { name: "PBKDF2", hash: "SHA-512", iterations: 5e5, salt: new Uint8Array() };
|
|
285
|
-
const [derivedTokenSigningSecret, derivedRefreshTokenSigningSecret, derivedSecretResetTokenSigningSecret] = await (0, import_cryptography.deriveBytesMultiple)(algorithm, key, 3, SIGNING_SECRETS_LENGTH
|
|
285
|
+
const [derivedTokenSigningSecret, derivedRefreshTokenSigningSecret, derivedSecretResetTokenSigningSecret] = await (0, import_cryptography.deriveBytesMultiple)(algorithm, key, 3, SIGNING_SECRETS_LENGTH);
|
|
286
286
|
this.derivedTokenSigningSecret = derivedTokenSigningSecret;
|
|
287
287
|
this.derivedRefreshTokenSigningSecret = derivedRefreshTokenSigningSecret;
|
|
288
288
|
this.derivedSecretResetTokenSigningSecret = derivedSecretResetTokenSigningSecret;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Provider } from '../../container/index.js';
|
|
1
2
|
import type { Type } from '../../types.js';
|
|
2
3
|
import { AuthenticationCredentialsRepository } from './authentication-credentials.repository.js';
|
|
3
4
|
import { AuthenticationSessionRepository } from './authentication-session.repository.js';
|
|
@@ -5,7 +6,7 @@ import { AuthenticationSubjectResolver } from './authentication-subject.resolver
|
|
|
5
6
|
import { AuthenticationTokenPayloadProvider } from './authentication-token-payload.provider.js';
|
|
6
7
|
import { AuthenticationService, AuthenticationServiceOptions } from './authentication.service.js';
|
|
7
8
|
export type AuthenticationModuleConfig = {
|
|
8
|
-
serviceOptions: AuthenticationServiceOptions
|
|
9
|
+
serviceOptions: AuthenticationServiceOptions | Provider<AuthenticationServiceOptions>;
|
|
9
10
|
credentialsRepository: Type<AuthenticationCredentialsRepository>;
|
|
10
11
|
sessionRepository: Type<AuthenticationSessionRepository>;
|
|
11
12
|
/** override default AuthenticationService */
|
|
@@ -29,7 +29,7 @@ var import_authentication_subject_resolver = require("./authentication-subject.r
|
|
|
29
29
|
var import_authentication_token_payload_provider = require("./authentication-token-payload.provider.js");
|
|
30
30
|
var import_authentication_service = require("./authentication.service.js");
|
|
31
31
|
function configureAuthenticationServer(config) {
|
|
32
|
-
import_container.container.register(import_authentication_service.AuthenticationServiceOptions, { useValue: config.serviceOptions });
|
|
32
|
+
import_container.container.register(import_authentication_service.AuthenticationServiceOptions, (0, import_container.isProvider)(config.serviceOptions) ? config.serviceOptions : { useValue: config.serviceOptions });
|
|
33
33
|
import_container.container.registerSingleton(import_authentication_credentials_repository.AuthenticationCredentialsRepository, { useToken: config.credentialsRepository });
|
|
34
34
|
import_container.container.registerSingleton(import_authentication_session_repository.AuthenticationSessionRepository, { useToken: config.sessionRepository });
|
|
35
35
|
if ((0, import_type_guards.isDefined)(config.authenticationService)) {
|
package/container/provider.d.ts
CHANGED
|
@@ -28,7 +28,8 @@ export declare function classProvider<T>(constructor: Constructor<T>): ClassProv
|
|
|
28
28
|
export declare function valueProvider<T>(value: T): ValueProvider<T>;
|
|
29
29
|
export declare function tokenProvider<T, A>(token: InjectionToken<T, A>, argument?: InjectableArgument<T, A>): TokenProvider<T>;
|
|
30
30
|
export declare function factoryProvider<T, A>(factory: Factory<T, A>): FactoryProvider<T, A>;
|
|
31
|
-
export declare function isClassProvider<T>(
|
|
32
|
-
export declare function isValueProvider<T>(
|
|
33
|
-
export declare function isTokenProvider<T>(
|
|
34
|
-
export declare function isFactoryProvider<T, A>(
|
|
31
|
+
export declare function isClassProvider<T>(value: unknown): value is ClassProvider<T>;
|
|
32
|
+
export declare function isValueProvider<T>(value: unknown): value is ValueProvider<T>;
|
|
33
|
+
export declare function isTokenProvider<T>(value: unknown): value is TokenProvider<T>;
|
|
34
|
+
export declare function isFactoryProvider<T, A>(value: unknown): value is FactoryProvider<T, A>;
|
|
35
|
+
export declare function isProvider<T, A>(value: unknown): value is Provider<T, A>;
|
package/container/provider.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(provider_exports, {
|
|
|
22
22
|
factoryProvider: () => factoryProvider,
|
|
23
23
|
isClassProvider: () => isClassProvider,
|
|
24
24
|
isFactoryProvider: () => isFactoryProvider,
|
|
25
|
+
isProvider: () => isProvider,
|
|
25
26
|
isTokenProvider: () => isTokenProvider,
|
|
26
27
|
isValueProvider: () => isValueProvider,
|
|
27
28
|
tokenProvider: () => tokenProvider,
|
|
@@ -29,6 +30,7 @@ __export(provider_exports, {
|
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(provider_exports);
|
|
31
32
|
var import_object = require("../utils/object/object.js");
|
|
33
|
+
var import_type_guards = require("../utils/type-guards.js");
|
|
32
34
|
function classProvider(constructor) {
|
|
33
35
|
return { useClass: constructor };
|
|
34
36
|
}
|
|
@@ -41,15 +43,18 @@ function tokenProvider(token, argument) {
|
|
|
41
43
|
function factoryProvider(factory) {
|
|
42
44
|
return { useFactory: factory };
|
|
43
45
|
}
|
|
44
|
-
function isClassProvider(
|
|
45
|
-
return (0, import_object.hasOwnProperty)(
|
|
46
|
+
function isClassProvider(value) {
|
|
47
|
+
return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useClass");
|
|
46
48
|
}
|
|
47
|
-
function isValueProvider(
|
|
48
|
-
return (0, import_object.hasOwnProperty)(
|
|
49
|
+
function isValueProvider(value) {
|
|
50
|
+
return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useValue");
|
|
49
51
|
}
|
|
50
|
-
function isTokenProvider(
|
|
51
|
-
return (0, import_object.hasOwnProperty)(
|
|
52
|
+
function isTokenProvider(value) {
|
|
53
|
+
return (0, import_type_guards.isObject)(value) && ((0, import_object.hasOwnProperty)(value, "useToken") || (0, import_object.hasOwnProperty)(value, "useTokenProvider"));
|
|
52
54
|
}
|
|
53
|
-
function isFactoryProvider(
|
|
54
|
-
return (0, import_object.hasOwnProperty)(
|
|
55
|
+
function isFactoryProvider(value) {
|
|
56
|
+
return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useFactory");
|
|
57
|
+
}
|
|
58
|
+
function isProvider(value) {
|
|
59
|
+
return (0, import_type_guards.isObject)(value) && (isClassProvider(value) || isValueProvider(value) || isTokenProvider(value) || isFactoryProvider(value));
|
|
55
60
|
}
|