@tstdl/base 0.83.5 → 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.
@@ -1,17 +1,17 @@
1
- import type { Provider } from '../../container/index.js';
2
- import type { Type } from '../../types.js';
1
+ import type { InjectionToken, Provider } from '../../container/index.js';
3
2
  import { AuthenticationCredentialsRepository } from './authentication-credentials.repository.js';
4
3
  import { AuthenticationSessionRepository } from './authentication-session.repository.js';
5
4
  import { AuthenticationSubjectResolver } from './authentication-subject.resolver.js';
6
5
  import { AuthenticationTokenPayloadProvider } from './authentication-token-payload.provider.js';
7
6
  import { AuthenticationService, AuthenticationServiceOptions } from './authentication.service.js';
8
7
  export type AuthenticationModuleConfig = {
9
- serviceOptions: AuthenticationServiceOptions | Provider<AuthenticationServiceOptions>;
10
- credentialsRepository: Type<AuthenticationCredentialsRepository>;
11
- sessionRepository: Type<AuthenticationSessionRepository>;
8
+ serviceOptions?: AuthenticationServiceOptions | Provider<AuthenticationServiceOptions>;
9
+ serviceOptionsProvider?: Provider<AuthenticationServiceOptions>;
10
+ credentialsRepository: InjectionToken<AuthenticationCredentialsRepository>;
11
+ sessionRepository: InjectionToken<AuthenticationSessionRepository>;
12
12
  /** override default AuthenticationService */
13
- authenticationService?: Type<AuthenticationService<any, any>>;
14
- tokenPayloadProvider?: Type<AuthenticationTokenPayloadProvider<any, any>>;
15
- subjectResolver?: Type<AuthenticationSubjectResolver>;
13
+ authenticationService?: InjectionToken<AuthenticationService<any, any>>;
14
+ tokenPayloadProvider?: InjectionToken<AuthenticationTokenPayloadProvider<any, any>>;
15
+ subjectResolver?: InjectionToken<AuthenticationSubjectResolver>;
16
16
  };
17
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, (0, import_container.isProvider)(config.serviceOptions) ? config.serviceOptions : { 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)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.83.5",
3
+ "version": "0.83.6",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"