@rxap/nest-auth0 10.1.0-dev.1 → 10.1.0-dev.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.1.0-dev.3](https://gitlab.com/rxap/packages/compare/@rxap/nest-auth0@10.1.0-dev.2...@rxap/nest-auth0@10.1.0-dev.3) (2025-03-27)
7
+
8
+ ### Features
9
+
10
+ - **auth0:** add support for optional Auth0 disable feature ([a3cef89](https://gitlab.com/rxap/packages/commit/a3cef895c6acc348097fb0a3c8df97df48a7d5dd))
11
+
12
+ # [10.1.0-dev.2](https://gitlab.com/rxap/packages/compare/@rxap/nest-auth0@10.1.0-dev.1...@rxap/nest-auth0@10.1.0-dev.2) (2025-03-17)
13
+
14
+ ### Features
15
+
16
+ - add management and authentication services ([b3acc35](https://gitlab.com/rxap/packages/commit/b3acc35117e77c6ac80b2b4d9e13d66c510ccda6))
17
+
6
18
  # [10.1.0-dev.1](https://gitlab.com/rxap/packages/compare/@rxap/nest-auth0@10.1.0-dev.0...@rxap/nest-auth0@10.1.0-dev.1) (2025-03-14)
7
19
 
8
20
  ### Features
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "10.1.0-dev.1",
2
+ "version": "10.1.0-dev.3",
3
3
  "name": "@rxap/nest-auth0",
4
4
  "description": "This package provides an Auth0 module for NestJS applications, simplifying integration with Auth0 for authentication and authorization. It includes a configurable module, JWT strategy, and service for interacting with the Auth0 Authentication API. The module also offers validation schemas for environment variables related to Auth0 configuration.\n",
5
5
  "license": "GPL-3.0-or-later",
@@ -39,5 +39,5 @@
39
39
  "schematics": "./generators.json",
40
40
  "type": "commonjs",
41
41
  "types": "./src/index.d.ts",
42
- "gitHead": "70c885dac01229b385d60bdeaf77140f0fc6bc8f"
42
+ "gitHead": "381da5268a631106fb62b6f2858d6e6f488115ae"
43
43
  }
package/src/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
+ export * from './lib/auth0-authentication.service';
2
+ export * from './lib/auth0-management.service';
1
3
  export * from './lib/auth0-module-options.factory';
4
+ export * from './lib/auth0-options';
2
5
  export * from './lib/auth0-validation-schema';
3
6
  export * from './lib/auth0.guard';
4
7
  export * from './lib/auth0.module';
package/src/index.js CHANGED
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  // region
5
+ tslib_1.__exportStar(require("./lib/auth0-authentication.service"), exports);
6
+ tslib_1.__exportStar(require("./lib/auth0-management.service"), exports);
5
7
  tslib_1.__exportStar(require("./lib/auth0-module-options.factory"), exports);
8
+ tslib_1.__exportStar(require("./lib/auth0-options"), exports);
6
9
  tslib_1.__exportStar(require("./lib/auth0-validation-schema"), exports);
7
10
  tslib_1.__exportStar(require("./lib/auth0.guard"), exports);
8
11
  tslib_1.__exportStar(require("./lib/auth0.module"), exports);
@@ -0,0 +1,65 @@
1
+ import { AuthenticationClient, AuthenticationClientOptions } from 'auth0';
2
+ /**
3
+ * A service that extends Auth0's AuthenticationClient to provide authentication capabilities in NestJS applications.
4
+ *
5
+ * @summary
6
+ * Provides Auth0 authentication services with additional token management functionality.
7
+ *
8
+ * @typeParam T - The type of authentication client options used to configure the Auth0 service.
9
+ *
10
+ * @param options - The configuration options for the Auth0 client including domain, clientId, and clientSecret.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * @Injectable()
15
+ * class AppService {
16
+ * constructor(private readonly auth0Service: Auth0AuthenticationService) {}
17
+ *
18
+ * async getToken() {
19
+ * return this.auth0Service.requestToken('https://api.example.com');
20
+ * }
21
+ * }
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Manual instantiation (not recommended in NestJS)
27
+ * const auth0Service = new Auth0AuthenticationService({
28
+ * domain: 'your-domain.auth0.com',
29
+ * clientId: 'your-client-id',
30
+ * clientSecret: 'your-client-secret'
31
+ * });
32
+ * ```
33
+ *
34
+ * @throws {@link Error} If the Auth0 client initialization fails due to invalid configuration options.
35
+ *
36
+ * @property requestToken - Method to obtain an access token for a specific audience using client credentials flow.
37
+ */
38
+ export declare class Auth0AuthenticationService extends AuthenticationClient {
39
+ constructor(options: AuthenticationClientOptions);
40
+ /**
41
+ * Requests an access token from Auth0 using the client credentials grant flow.
42
+ *
43
+ * @summary
44
+ * This method obtains an access token for a specific API audience using the OAuth 2.0 client credentials flow.
45
+ *
46
+ * @param audience - The unique identifier of the API for which the access token is being requested. This is typically the API's URL or identifier registered in Auth0.
47
+ *
48
+ * @returns A Promise that resolves to a string containing the JWT access token that can be used to authenticate requests to the specified API audience.
49
+ *
50
+ * @throws {@link Error} If the token request fails due to invalid credentials, network issues, or other Auth0 API errors.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const auth0Service = new Auth0AuthenticationService(options);
55
+ * try {
56
+ * const token = await auth0Service.requestToken('https://api.example.com');
57
+ * // Use the token for API requests
58
+ * console.log(token);
59
+ * } catch (error) {
60
+ * console.error('Failed to obtain access token:', error);
61
+ * }
62
+ * ```
63
+ */
64
+ requestToken(audience: string): Promise<string>;
65
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Auth0AuthenticationService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const auth0_1 = require("auth0");
7
+ const tokens_1 = require("./tokens");
8
+ /**
9
+ * A service that extends Auth0's AuthenticationClient to provide authentication capabilities in NestJS applications.
10
+ *
11
+ * @summary
12
+ * Provides Auth0 authentication services with additional token management functionality.
13
+ *
14
+ * @typeParam T - The type of authentication client options used to configure the Auth0 service.
15
+ *
16
+ * @param options - The configuration options for the Auth0 client including domain, clientId, and clientSecret.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * @Injectable()
21
+ * class AppService {
22
+ * constructor(private readonly auth0Service: Auth0AuthenticationService) {}
23
+ *
24
+ * async getToken() {
25
+ * return this.auth0Service.requestToken('https://api.example.com');
26
+ * }
27
+ * }
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // Manual instantiation (not recommended in NestJS)
33
+ * const auth0Service = new Auth0AuthenticationService({
34
+ * domain: 'your-domain.auth0.com',
35
+ * clientId: 'your-client-id',
36
+ * clientSecret: 'your-client-secret'
37
+ * });
38
+ * ```
39
+ *
40
+ * @throws {@link Error} If the Auth0 client initialization fails due to invalid configuration options.
41
+ *
42
+ * @property requestToken - Method to obtain an access token for a specific audience using client credentials flow.
43
+ */
44
+ let Auth0AuthenticationService = class Auth0AuthenticationService extends auth0_1.AuthenticationClient {
45
+ constructor(options) {
46
+ super(options);
47
+ }
48
+ /**
49
+ * Requests an access token from Auth0 using the client credentials grant flow.
50
+ *
51
+ * @summary
52
+ * This method obtains an access token for a specific API audience using the OAuth 2.0 client credentials flow.
53
+ *
54
+ * @param audience - The unique identifier of the API for which the access token is being requested. This is typically the API's URL or identifier registered in Auth0.
55
+ *
56
+ * @returns A Promise that resolves to a string containing the JWT access token that can be used to authenticate requests to the specified API audience.
57
+ *
58
+ * @throws {@link Error} If the token request fails due to invalid credentials, network issues, or other Auth0 API errors.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const auth0Service = new Auth0AuthenticationService(options);
63
+ * try {
64
+ * const token = await auth0Service.requestToken('https://api.example.com');
65
+ * // Use the token for API requests
66
+ * console.log(token);
67
+ * } catch (error) {
68
+ * console.error('Failed to obtain access token:', error);
69
+ * }
70
+ * ```
71
+ */
72
+ async requestToken(audience) {
73
+ const { data: { access_token }, } = await this.oauth.clientCredentialsGrant({ audience });
74
+ return access_token;
75
+ }
76
+ };
77
+ exports.Auth0AuthenticationService = Auth0AuthenticationService;
78
+ exports.Auth0AuthenticationService = Auth0AuthenticationService = tslib_1.__decorate([
79
+ (0, common_1.Injectable)(),
80
+ tslib_1.__param(0, (0, common_1.Inject)(tokens_1.AUTH0_AUTHENTICATION_OPTIONS)),
81
+ tslib_1.__metadata("design:paramtypes", [Object])
82
+ ], Auth0AuthenticationService);
@@ -0,0 +1,4 @@
1
+ import { ManagementClient, ManagementClientOptionsWithClientCredentials, ManagementClientOptionsWithToken } from 'auth0';
2
+ export declare class Auth0ManagementService extends ManagementClient {
3
+ constructor(options: ManagementClientOptionsWithToken | ManagementClientOptionsWithClientCredentials);
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Auth0ManagementService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const auth0_1 = require("auth0");
7
+ const tokens_1 = require("./tokens");
8
+ let Auth0ManagementService = class Auth0ManagementService extends auth0_1.ManagementClient {
9
+ constructor(options) {
10
+ // @ts-expect-error - constructor signature is not compatible with the base class
11
+ super(options);
12
+ }
13
+ };
14
+ exports.Auth0ManagementService = Auth0ManagementService;
15
+ exports.Auth0ManagementService = Auth0ManagementService = tslib_1.__decorate([
16
+ (0, common_1.Injectable)(),
17
+ tslib_1.__param(0, (0, common_1.Inject)(tokens_1.AUTH0_MANAGEMENT_OPTIONS)),
18
+ tslib_1.__metadata("design:paramtypes", [Object])
19
+ ], Auth0ManagementService);
@@ -1,6 +1,6 @@
1
1
  import { ConfigurableModuleOptionsFactory, Logger } from '@nestjs/common';
2
2
  import { ConfigService } from '@nestjs/config';
3
- import { AuthenticationClientOptions } from 'auth0';
3
+ import { Auth0Options } from './auth0-options';
4
4
  /**
5
5
  * Creates an instance of `AuthenticationClientOptions` for Auth0 configuration.
6
6
  *
@@ -31,7 +31,7 @@ import { AuthenticationClientOptions } from 'auth0';
31
31
  * const options = await auth0ModuleOptionsFactory.create();
32
32
  * ```
33
33
  */
34
- export declare class Auth0ModuleOptionsFactory implements ConfigurableModuleOptionsFactory<AuthenticationClientOptions, 'create'> {
34
+ export declare class Auth0ModuleOptionsFactory implements ConfigurableModuleOptionsFactory<Auth0Options, 'create'> {
35
35
  protected readonly config: ConfigService;
36
36
  protected readonly logger: Logger;
37
37
  /**
@@ -49,5 +49,5 @@ export declare class Auth0ModuleOptionsFactory implements ConfigurableModuleOpti
49
49
  * const options = await auth0ModuleOptionsFactory.create();
50
50
  * ```
51
51
  */
52
- create(): Promise<AuthenticationClientOptions>;
52
+ create(): Promise<Auth0Options>;
53
53
  }
@@ -52,11 +52,24 @@ let Auth0ModuleOptionsFactory = class Auth0ModuleOptionsFactory {
52
52
  */
53
53
  async create() {
54
54
  this.logger.verbose('Create auth0 client options', 'Auth0ClientModuleOptionsFactory');
55
- return {
55
+ const authentication = {
56
+ domain: this.config.get('AUTH0_DOMAIN'),
57
+ clientId: this.config.get('AUTH0_CLIENT_ID'),
58
+ clientSecret: this.config.get('AUTH0_CLIENT_SECRET'),
59
+ };
60
+ const management = this.config.get('AUTH0_MANAGEMENT_TOKEN') ? {
61
+ domain: this.config.get('AUTH0_DOMAIN'),
62
+ token: this.config.get('AUTH0_MANAGEMENT_TOKEN'),
63
+ } : {
56
64
  domain: this.config.get('AUTH0_DOMAIN'),
57
65
  clientId: this.config.get('AUTH0_CLIENT_ID'),
58
66
  clientSecret: this.config.get('AUTH0_CLIENT_SECRET'),
59
67
  };
68
+ return {
69
+ authentication,
70
+ management,
71
+ disabled: this.config.get('AUTH0_DISABLED', false),
72
+ };
60
73
  }
61
74
  };
62
75
  exports.Auth0ModuleOptionsFactory = Auth0ModuleOptionsFactory;
@@ -0,0 +1,6 @@
1
+ import { AuthenticationClientOptions, ManagementClientOptionsWithToken, ManagementClientOptionsWithClientCredentials } from 'auth0';
2
+ export interface Auth0Options {
3
+ authentication: AuthenticationClientOptions;
4
+ management: ManagementClientOptionsWithToken | ManagementClientOptionsWithClientCredentials;
5
+ disabled?: boolean;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -25,6 +25,8 @@ export interface Auth0ValidationSchema {
25
25
  AUTH0_DOMAIN: string;
26
26
  AUTH0_CLIENT_ID: string;
27
27
  AUTH0_CLIENT_SECRET: string;
28
+ AUTH0_MANAGEMENT_TOKEN: string;
29
+ AUTH0_DISABLED: boolean;
28
30
  }
29
31
  /**
30
32
  * Generates a validation schema for Auth0 configuration settings using Joi.
@@ -34,4 +36,4 @@ export interface Auth0ValidationSchema {
34
36
  * @param {Partial<Auth0ValidationSchema>} [defaults={}] - An optional object with default values for the schema keys.
35
37
  * @return {Record<string, StringSchema>} The Joi validation schema object for Auth0 configuration.
36
38
  */
37
- export declare function auth0ValidationSchema(environment: Environment, defaults?: Partial<Auth0ValidationSchema>): Record<string, Joi.StringSchema<string>>;
39
+ export declare function auth0ValidationSchema(environment: Environment, defaults?: Partial<Auth0ValidationSchema>): Record<string, Joi.AnySchema<any>>;
@@ -17,8 +17,12 @@ function auth0ValidationSchema(environment, defaults = {}) {
17
17
  schema['AUTH0_DOMAIN'] = Joi.string().domain();
18
18
  schema['AUTH0_CLIENT_ID'] = Joi.string();
19
19
  schema['AUTH0_CLIENT_SECRET'] = Joi.string();
20
+ schema['AUTH0_MANAGEMENT_TOKEN'] = Joi.string();
21
+ schema['AUTH0_DISABLED'] = Joi.boolean();
20
22
  for (const [key, value] of Object.keys(defaults)) {
21
- schema[key] = schema[key].default(value);
23
+ if (value) {
24
+ schema[key] = schema[key].default(value);
25
+ }
22
26
  }
23
27
  return schema;
24
28
  }
@@ -4,5 +4,6 @@ export declare class Auth0Guard implements CanActivate {
4
4
  private readonly jwtService;
5
5
  private readonly logger;
6
6
  protected readonly reflector: Reflector;
7
+ private readonly options;
7
8
  canActivate(context: ExecutionContext): Promise<boolean>;
8
9
  }
@@ -7,6 +7,7 @@ const core_1 = require("@nestjs/core");
7
7
  const jwt_1 = require("@nestjs/jwt");
8
8
  const nest_utilities_1 = require("@rxap/nest-utilities");
9
9
  const passport_jwt_1 = require("passport-jwt");
10
+ const tokens_1 = require("./tokens");
10
11
  let Auth0Guard = class Auth0Guard {
11
12
  async canActivate(context) {
12
13
  const isPublic = this.reflector.getAllAndOverride(nest_utilities_1.IS_PUBLIC_KEY, [
@@ -17,6 +18,29 @@ let Auth0Guard = class Auth0Guard {
17
18
  return true;
18
19
  }
19
20
  const request = context.switchToHttp().getRequest();
21
+ if (this.options.disabled) {
22
+ this.logger.warn('Auth0 is disabled', 'Auth0Guard');
23
+ const user = request.user = {};
24
+ if (request.headers['x-user-id']) {
25
+ user.sub = request.headers['x-user-id'];
26
+ }
27
+ if (request.headers['x-user-sub']) {
28
+ user.sub = request.headers['x-user-sub'];
29
+ }
30
+ user.aud = request.headers['x-user-aud'];
31
+ user.roles = request.headers['x-user-roles'];
32
+ user.displayName = request.headers['x-user-display-name'];
33
+ user.email = request.headers['x-user-email'];
34
+ user.usernane = request.headers['x-user-username'];
35
+ user.name = request.headers['x-user-name'];
36
+ user.nickname = request.headers['x-user-nickname'];
37
+ if (request.user && 'sub' in request.user) {
38
+ return true;
39
+ }
40
+ else {
41
+ this.logger.warn('Request is not authenticated. Please check the authorization header. Ensure the header x-user-id or x-user-sub is set. Fallback to bearer token authentication.', 'Auth0Guard');
42
+ }
43
+ }
20
44
  const jwt = passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken()(request);
21
45
  if (!jwt) {
22
46
  this.logger.debug('No Bearer token found in authorization header', 'Auth0Guard');
@@ -45,6 +69,10 @@ tslib_1.__decorate([
45
69
  (0, common_1.Inject)(core_1.Reflector),
46
70
  tslib_1.__metadata("design:type", core_1.Reflector)
47
71
  ], Auth0Guard.prototype, "reflector", void 0);
72
+ tslib_1.__decorate([
73
+ (0, common_1.Inject)(tokens_1.AUTH0_OPTIONS),
74
+ tslib_1.__metadata("design:type", Object)
75
+ ], Auth0Guard.prototype, "options", void 0);
48
76
  exports.Auth0Guard = Auth0Guard = tslib_1.__decorate([
49
77
  (0, common_1.Injectable)()
50
78
  ], Auth0Guard);
@@ -1,6 +1,12 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
- import { AuthenticationClientOptions } from 'auth0';
3
- export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<AuthenticationClientOptions, "register", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: AuthenticationClientOptions & Partial<{}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<AuthenticationClientOptions, "create"> & Partial<{}>;
2
+ import { Auth0Options } from './auth0-options';
3
+ export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<Auth0Options, "register", "create", {
4
+ global: boolean;
5
+ }>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: Auth0Options & Partial<{
6
+ global: boolean;
7
+ }>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<Auth0Options, "create"> & Partial<{
8
+ global: boolean;
9
+ }>;
4
10
  /**
5
11
  * A configurable module that provides Auth0 authentication services for NestJS applications.
6
12
  *
@@ -48,7 +54,7 @@ export declare const ConfigurableModuleClass: import("@nestjs/common").Configura
48
54
  * @property registerAsync - Static method to configure the module with asynchronous options
49
55
  * @property updateProviders - Private static method to update the module's providers and exports
50
56
  *
51
- * @returns A dynamic module configured with Auth0 authentication capabilities, including the Auth0Service and JWT strategy.
57
+ * @returns A dynamic module configured with Auth0 authentication capabilities, including the Auth0AuthenticationService and JWT strategy.
52
58
  *
53
59
  * @throws {@link Error} If the required Auth0 configuration options are invalid or missing.
54
60
  */
@@ -7,11 +7,11 @@ const common_1 = require("@nestjs/common");
7
7
  const config_1 = require("@nestjs/config");
8
8
  const jwt_1 = require("@nestjs/jwt");
9
9
  const jwks_rsa_1 = require("jwks-rsa");
10
+ const auth0_management_service_1 = require("./auth0-management.service");
11
+ const auth0_authentication_service_1 = require("./auth0-authentication.service");
10
12
  const auth0_guard_1 = require("./auth0.guard");
11
- const auth0_service_1 = require("./auth0.service");
12
13
  const tokens_1 = require("./tokens");
13
- _a = new common_1.ConfigurableModuleBuilder()
14
- .build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE, exports.ASYNC_OPTIONS_TYPE = _a.ASYNC_OPTIONS_TYPE;
14
+ _a = new common_1.ConfigurableModuleBuilder().setExtras({ global: true }).build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE, exports.ASYNC_OPTIONS_TYPE = _a.ASYNC_OPTIONS_TYPE;
15
15
  /**
16
16
  * A configurable module that provides Auth0 authentication services for NestJS applications.
17
17
  *
@@ -59,7 +59,7 @@ _a = new common_1.ConfigurableModuleBuilder()
59
59
  * @property registerAsync - Static method to configure the module with asynchronous options
60
60
  * @property updateProviders - Private static method to update the module's providers and exports
61
61
  *
62
- * @returns A dynamic module configured with Auth0 authentication capabilities, including the Auth0Service and JWT strategy.
62
+ * @returns A dynamic module configured with Auth0 authentication capabilities, including the Auth0AuthenticationService and JWT strategy.
63
63
  *
64
64
  * @throws {@link Error} If the required Auth0 configuration options are invalid or missing.
65
65
  */
@@ -125,18 +125,39 @@ let Auth0Module = class Auth0Module extends exports.ConfigurableModuleClass {
125
125
  }
126
126
  static updateProviders(module) {
127
127
  module.providers ??= [];
128
- module.providers.push(auth0_service_1.Auth0Service);
129
- module.exports ??= [];
130
- module.exports.push(auth0_service_1.Auth0Service);
131
128
  module.providers.push({
132
129
  provide: tokens_1.AUTH0_OPTIONS,
133
130
  useExisting: exports.MODULE_OPTIONS_TOKEN
134
131
  });
132
+ module.providers.push({
133
+ provide: tokens_1.AUTH0_AUTHENTICATION_OPTIONS,
134
+ useFactory: (options) => options.authentication ?? null,
135
+ inject: [tokens_1.AUTH0_OPTIONS]
136
+ });
137
+ module.providers.push({
138
+ provide: tokens_1.AUTH0_MANAGEMENT_OPTIONS,
139
+ useFactory: (options) => options.management ?? null,
140
+ inject: [tokens_1.AUTH0_OPTIONS]
141
+ });
142
+ module.providers.push({
143
+ provide: auth0_authentication_service_1.Auth0AuthenticationService,
144
+ useFactory: (options) => options ? new auth0_authentication_service_1.Auth0AuthenticationService(options) : null,
145
+ inject: [tokens_1.AUTH0_AUTHENTICATION_OPTIONS]
146
+ });
147
+ module.providers.push({
148
+ provide: auth0_management_service_1.Auth0ManagementService,
149
+ useFactory: (options) => options ? new auth0_management_service_1.Auth0ManagementService(options) : null,
150
+ inject: [tokens_1.AUTH0_MANAGEMENT_OPTIONS]
151
+ });
152
+ module.exports ??= [];
153
+ module.exports.push(auth0_authentication_service_1.Auth0AuthenticationService);
154
+ module.exports.push(auth0_management_service_1.Auth0ManagementService);
135
155
  return module;
136
156
  }
137
157
  };
138
158
  exports.Auth0Module = Auth0Module;
139
159
  exports.Auth0Module = Auth0Module = tslib_1.__decorate([
160
+ (0, common_1.Global)(),
140
161
  (0, common_1.Module)({
141
162
  imports: [
142
163
  jwt_1.JwtModule.registerAsync({
@@ -1 +1,3 @@
1
1
  export declare const AUTH0_OPTIONS: unique symbol;
2
+ export declare const AUTH0_AUTHENTICATION_OPTIONS: unique symbol;
3
+ export declare const AUTH0_MANAGEMENT_OPTIONS: unique symbol;
package/src/lib/tokens.js CHANGED
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AUTH0_OPTIONS = void 0;
3
+ exports.AUTH0_MANAGEMENT_OPTIONS = exports.AUTH0_AUTHENTICATION_OPTIONS = exports.AUTH0_OPTIONS = void 0;
4
4
  exports.AUTH0_OPTIONS = Symbol('AUTH0_OPTIONS');
5
+ exports.AUTH0_AUTHENTICATION_OPTIONS = Symbol('AUTH0_AUTHENTICATION_OPTIONS');
6
+ exports.AUTH0_MANAGEMENT_OPTIONS = Symbol('AUTH0_MANAGEMENT_OPTIONS');