@tstdl/base 0.83.4 → 0.83.6

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 = 512;
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 / 8);
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,16 +1,17 @@
1
- import type { Type } from '../../types.js';
1
+ import type { InjectionToken, Provider } from '../../container/index.js';
2
2
  import { AuthenticationCredentialsRepository } from './authentication-credentials.repository.js';
3
3
  import { AuthenticationSessionRepository } from './authentication-session.repository.js';
4
4
  import { AuthenticationSubjectResolver } from './authentication-subject.resolver.js';
5
5
  import { AuthenticationTokenPayloadProvider } from './authentication-token-payload.provider.js';
6
6
  import { AuthenticationService, AuthenticationServiceOptions } from './authentication.service.js';
7
7
  export type AuthenticationModuleConfig = {
8
- serviceOptions: AuthenticationServiceOptions;
9
- credentialsRepository: Type<AuthenticationCredentialsRepository>;
10
- sessionRepository: Type<AuthenticationSessionRepository>;
8
+ serviceOptions?: AuthenticationServiceOptions | Provider<AuthenticationServiceOptions>;
9
+ serviceOptionsProvider?: Provider<AuthenticationServiceOptions>;
10
+ credentialsRepository: InjectionToken<AuthenticationCredentialsRepository>;
11
+ sessionRepository: InjectionToken<AuthenticationSessionRepository>;
11
12
  /** override default AuthenticationService */
12
- authenticationService?: Type<AuthenticationService<any, any>>;
13
- tokenPayloadProvider?: Type<AuthenticationTokenPayloadProvider<any, any>>;
14
- subjectResolver?: Type<AuthenticationSubjectResolver>;
13
+ authenticationService?: InjectionToken<AuthenticationService<any, any>>;
14
+ tokenPayloadProvider?: InjectionToken<AuthenticationTokenPayloadProvider<any, any>>;
15
+ subjectResolver?: InjectionToken<AuthenticationSubjectResolver>;
15
16
  };
16
17
  export declare function configureAuthenticationServer(config: AuthenticationModuleConfig): void;
@@ -29,7 +29,13 @@ 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
+ if ((0, import_type_guards.isDefined)(config.serviceOptions)) {
33
+ import_container.container.register(import_authentication_service.AuthenticationServiceOptions, { useValue: config.serviceOptions });
34
+ } else if ((0, import_type_guards.isDefined)(config.serviceOptionsProvider)) {
35
+ import_container.container.register(import_authentication_service.AuthenticationServiceOptions, config.serviceOptionsProvider);
36
+ } else {
37
+ throw new Error("Either serviceOptions or serviceOptionsToken must be provided.");
38
+ }
33
39
  import_container.container.registerSingleton(import_authentication_credentials_repository.AuthenticationCredentialsRepository, { useToken: config.credentialsRepository });
34
40
  import_container.container.registerSingleton(import_authentication_session_repository.AuthenticationSessionRepository, { useToken: config.sessionRepository });
35
41
  if ((0, import_type_guards.isDefined)(config.authenticationService)) {
@@ -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>(provider: Provider<T>): provider is ClassProvider<T>;
32
- export declare function isValueProvider<T>(provider: Provider<T>): provider is ValueProvider<T>;
33
- export declare function isTokenProvider<T>(provider: Provider<T>): provider is TokenProvider<T>;
34
- export declare function isFactoryProvider<T, A>(provider: Provider<T, A>): provider is FactoryProvider<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>;
@@ -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(provider) {
45
- return (0, import_object.hasOwnProperty)(provider, "useClass");
46
+ function isClassProvider(value) {
47
+ return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useClass");
46
48
  }
47
- function isValueProvider(provider) {
48
- return (0, import_object.hasOwnProperty)(provider, "useValue");
49
+ function isValueProvider(value) {
50
+ return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useValue");
49
51
  }
50
- function isTokenProvider(provider) {
51
- return (0, import_object.hasOwnProperty)(provider, "useToken") || (0, import_object.hasOwnProperty)(provider, "useTokenProvider");
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(provider) {
54
- return (0, import_object.hasOwnProperty)(provider, "useFactory");
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.83.4",
3
+ "version": "0.83.6",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"