@dismissible/nestjs-jwt-auth-hook 1.0.2 → 1.0.3-alpha.0b30e6d.0

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/README.md CHANGED
@@ -1,10 +1,25 @@
1
+ <p align="center">
2
+ <a href="https://dismissible.io" target="_blank"><img src="../../docs/images/dismissible_logo.png" width="120" alt="Dismissible" /></a>
3
+ </p>
4
+
5
+ <p align="center">Never Show The Same Thing Twice!</p>
6
+ <p align="center">
7
+ <a href="https://www.npmjs.com/package/@dismissible/nestjs-jwt-auth-hook" target="_blank"><img src="https://img.shields.io/npm/v/@dismissible/nestjs-jwt-auth-hook.svg" alt="NPM Version" /></a>
8
+ <a href="https://github.com/dismissibleio/dismissible-api/blob/main/LICENSE" target="_blank"><img src="https://img.shields.io/npm/l/@dismissible/nestjs-jwt-auth-hook.svg" alt="Package License" /></a>
9
+ <a href="https://www.npmjs.com/package/@dismissible/nestjs-jwt-auth-hook" target="_blank"><img src="https://img.shields.io/npm/dm/@dismissible/nestjs-jwt-auth-hook.svg" alt="NPM Downloads" /></a>
10
+ <a href="https://github.com/dismissibleio/dismissible-api" target="_blank"><img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/dismissibleio/dismissible-api/release.yml"></a>
11
+ <a href="https://paypal.me/joshstuartx" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
12
+ </p>
13
+
14
+ Dismissible manages the state of your UI elements across sessions, so your users see what matters, once! No more onboarding messages reappearing on every tab, no more notifications haunting users across devices. Dismissible syncs dismissal state everywhere, so every message is intentional, never repetitive.
15
+
1
16
  # @dismissible/nestjs-jwt-auth-hook
2
17
 
3
18
  JWT authentication hook for Dismissible applications using OpenID Connect (OIDC) well-known discovery.
4
19
 
5
20
  ## Overview
6
21
 
7
- This library provides a lifecycle hook that integrates with the `@dismissible/nestjs-dismissible` module to authenticate requests using JWT bearer tokens. It validates tokens using JWKS (JSON Web Key Set) fetched from an OIDC well-known endpoint.
22
+ This library provides a lifecycle hook that integrates with the `@dismissible/nestjs-core` module to authenticate requests using JWT bearer tokens. It validates tokens using JWKS (JSON Web Key Set) fetched from an OIDC well-known endpoint.
8
23
 
9
24
  ## Installation
10
25
 
@@ -18,7 +33,7 @@ npm install @dismissible/nestjs-jwt-auth-hook @nestjs/axios axios
18
33
 
19
34
  ```typescript
20
35
  import { Module } from '@nestjs/common';
21
- import { DismissibleModule } from '@dismissible/nestjs-dismissible';
36
+ import { DismissibleModule } from '@dismissible/nestjs-core';
22
37
  import { JwtAuthHookModule, JwtAuthHook } from '@dismissible/nestjs-jwt-auth-hook';
23
38
 
24
39
  @Module({
@@ -47,7 +62,7 @@ When configuration values come from environment variables or other async sources
47
62
  ```typescript
48
63
  import { Module } from '@nestjs/common';
49
64
  import { ConfigService } from '@nestjs/config';
50
- import { DismissibleModule } from '@dismissible/nestjs-dismissible';
65
+ import { DismissibleModule } from '@dismissible/nestjs-core';
51
66
  import { JwtAuthHookModule, JwtAuthHook } from '@dismissible/nestjs-jwt-auth-hook';
52
67
 
53
68
  @Module({
@@ -81,9 +96,15 @@ export class AppModule {}
81
96
  | `jwksCacheDuration` | `number` | No | `600000` | JWKS cache duration in milliseconds (10 minutes) |
82
97
  | `requestTimeout` | `number` | No | `30000` | Request timeout in milliseconds (30 seconds) |
83
98
  | `priority` | `number` | No | `-100` | Hook priority (lower numbers run first) |
99
+ | `matchUserId` | `boolean` | No | `true` | Enable user ID matching against JWT claim |
100
+ | `userIdClaim` | `string` | No | `'sub'` | The JWT claim key to use for user ID matching |
101
+ | `userIdMatchType` | `string` | No | `'exact'` | Match method: `exact`, `substring`, or `regex` |
102
+ | `userIdMatchRegex` | `string` | No\*\* | - | Regex pattern for user ID matching (required when type is `regex`) |
84
103
 
85
104
  \* `wellKnownUrl` is only required when `enabled` is `true`.
86
105
 
106
+ \*\* `userIdMatchRegex` is required when `userIdMatchType` is `regex`.
107
+
87
108
  ## Environment Variables
88
109
 
89
110
  When using the Dismissible API Docker image or the standalone API, these environment variables configure JWT authentication:
@@ -98,13 +119,17 @@ When using the Dismissible API Docker image or the standalone API, these environ
98
119
  | `DISMISSIBLE_JWT_AUTH_JWKS_CACHE_DURATION` | JWKS cache duration in ms | `600000` |
99
120
  | `DISMISSIBLE_JWT_AUTH_REQUEST_TIMEOUT` | Request timeout in ms | `30000` |
100
121
  | `DISMISSIBLE_JWT_AUTH_PRIORITY` | Hook priority (lower runs first) | `-100` |
122
+ | `DISMISSIBLE_JWT_AUTH_MATCH_USER_ID` | Enable user ID matching | `true` |
123
+ | `DISMISSIBLE_JWT_AUTH_USER_ID_CLAIM` | JWT claim key for user ID matching | `sub` |
124
+ | `DISMISSIBLE_JWT_AUTH_USER_ID_MATCH_TYPE` | User ID match method | `exact` |
125
+ | `DISMISSIBLE_JWT_AUTH_USER_ID_MATCH_REGEX` | Regex pattern for user ID matching | `""` |
101
126
 
102
127
  ### Example: Disabling JWT Auth for Development
103
128
 
104
129
  ```bash
105
130
  docker run -p 3001:3001 \
106
131
  -e DISMISSIBLE_JWT_AUTH_ENABLED=false \
107
- -e DISMISSIBLE_POSTGRES_STORAGE_CONNECTION_STRING="postgresql://..." \
132
+ -e DISMISSIBLE_STORAGE_POSTGRES_CONNECTION_STRING="postgresql://..." \
108
133
  dismissibleio/dismissible-api:latest
109
134
  ```
110
135
 
@@ -116,7 +141,7 @@ docker run -p 3001:3001 \
116
141
  -e DISMISSIBLE_JWT_AUTH_WELL_KNOWN_URL="https://your-tenant.auth0.com/.well-known/openid-configuration" \
117
142
  -e DISMISSIBLE_JWT_AUTH_ISSUER="https://your-tenant.auth0.com/" \
118
143
  -e DISMISSIBLE_JWT_AUTH_AUDIENCE="your-api-identifier" \
119
- -e DISMISSIBLE_POSTGRES_STORAGE_CONNECTION_STRING="postgresql://..." \
144
+ -e DISMISSIBLE_STORAGE_POSTGRES_CONNECTION_STRING="postgresql://..." \
120
145
  dismissibleio/dismissible-api:latest
121
146
  ```
122
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dismissible/nestjs-jwt-auth-hook",
3
- "version": "1.0.2",
3
+ "version": "1.0.3-alpha.0b30e6d.0",
4
4
  "description": "JWT authentication hook for Dismissible applications using OIDC well-known discovery",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -13,26 +13,27 @@
13
13
  },
14
14
  "files": [
15
15
  "src",
16
- "README.md"
16
+ "README.md",
17
+ "LICENSE.md"
17
18
  ],
18
19
  "dependencies": {
19
- "@nestjs/axios": "^4.0.1",
20
- "@dismissible/nestjs-dismissible-hooks": "^1.0.2",
21
- "@dismissible/nestjs-dismissible-request": "^1.0.2",
22
- "@dismissible/nestjs-logger": "^1.0.2",
23
- "@dismissible/nestjs-validation": "^1.0.2",
24
- "jwks-rsa": "^3.2.0",
25
- "jsonwebtoken": "^9.0.3"
20
+ "@nestjs/axios": "4.0.1",
21
+ "@dismissible/nestjs-hooks": "1.0.3-alpha.0b30e6d.0",
22
+ "@dismissible/nestjs-request": "1.0.3-alpha.0b30e6d.0",
23
+ "@dismissible/nestjs-logger": "1.0.3-alpha.0b30e6d.0",
24
+ "@dismissible/nestjs-validation": "1.0.3-alpha.0b30e6d.0",
25
+ "jwks-rsa": "3.2.0",
26
+ "jsonwebtoken": "9.0.3"
26
27
  },
27
28
  "devDependencies": {
28
- "@types/jsonwebtoken": "^9.0.10"
29
+ "@types/jsonwebtoken": "9.0.10"
29
30
  },
30
31
  "peerDependencies": {
31
- "@nestjs/common": "^10.0.0 || ^11.0.0",
32
- "@nestjs/core": "^10.0.0 || ^11.0.0",
33
- "class-validator": "^0.14.3",
34
- "class-transformer": "^0.5.1",
35
- "rxjs": "^7.8.2"
32
+ "@nestjs/common": "10.0.0 || ^11.0.0",
33
+ "@nestjs/core": "10.0.0 || ^11.0.0",
34
+ "class-validator": "0.14.3",
35
+ "class-transformer": "0.5.1",
36
+ "rxjs": "7.8.2"
36
37
  },
37
38
  "peerDependenciesMeta": {
38
39
  "@nestjs/common": {
@@ -70,4 +71,4 @@
70
71
  "access": "public"
71
72
  },
72
73
  "type": "commonjs"
73
- }
74
+ }
@@ -2,6 +2,17 @@
2
2
  * Injection token for JWT auth hook configuration.
3
3
  */
4
4
  export declare const JWT_AUTH_HOOK_CONFIG: unique symbol;
5
+ /**
6
+ * User ID match type for comparing JWT claim against request userId.
7
+ */
8
+ export declare enum UserIdMatchType {
9
+ /** Exact string match (default) */
10
+ EXACT = "exact",
11
+ /** Substring match - either value contains the other */
12
+ SUBSTRING = "substring",
13
+ /** Regex match - tokenUserId is tested against a regex pattern */
14
+ REGEX = "regex"
15
+ }
5
16
  /**
6
17
  * Configuration options for JWT authentication hook.
7
18
  */
@@ -14,9 +25,11 @@ export declare class JwtAuthHookConfig {
14
25
  readonly wellKnownUrl: string;
15
26
  /**
16
27
  * Optional: Expected issuer claim (iss) to validate.
28
+ * Can be a comma-separated string or array of issuers.
17
29
  * If not provided, issuer validation is skipped.
30
+ * The token's issuer must match at least one of the provided issuers.
18
31
  */
19
- readonly issuer?: string;
32
+ readonly issuer?: string[];
20
33
  /**
21
34
  * Optional: Expected audience claim (aud) to validate.
22
35
  * If not provided, audience validation is skipped.
@@ -24,6 +37,7 @@ export declare class JwtAuthHookConfig {
24
37
  readonly audience?: string;
25
38
  /**
26
39
  * Optional: Allowed algorithms for JWT verification.
40
+ * Can be a comma-separated string or array of algorithms.
27
41
  * Defaults to ['RS256'].
28
42
  */
29
43
  readonly algorithms?: string[];
@@ -43,8 +57,24 @@ export declare class JwtAuthHookConfig {
43
57
  */
44
58
  readonly priority?: number;
45
59
  /**
46
- * Optional: Verify that the userId parameter matches the JWT subject (sub) claim.
60
+ * Optional: Match the userId parameter against the JWT claim set in userIdClaim.
47
61
  * Defaults to true for security. Set to false for service-to-service scenarios.
48
62
  */
49
- readonly verifyUserIdMatch?: boolean;
63
+ readonly matchUserId?: boolean;
64
+ /**
65
+ * Optional: The JWT claim key to use for user ID matching.
66
+ * Defaults to 'sub' (the standard JWT subject claim).
67
+ */
68
+ readonly userIdClaim?: string;
69
+ /**
70
+ * Optional: The type of matching to use for user ID comparison.
71
+ * Defaults to 'exact' for strict equality matching.
72
+ */
73
+ readonly userIdMatchType?: UserIdMatchType;
74
+ /**
75
+ * Optional: Regex pattern for user ID matching.
76
+ * Required when userIdMatchType is 'regex'.
77
+ * The pattern is tested against the tokenUserId from the JWT claim.
78
+ */
79
+ readonly userIdMatchRegex?: string;
50
80
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JwtAuthHookConfig = exports.JWT_AUTH_HOOK_CONFIG = void 0;
3
+ exports.JwtAuthHookConfig = exports.UserIdMatchType = exports.JWT_AUTH_HOOK_CONFIG = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const class_validator_1 = require("class-validator");
6
6
  const class_transformer_1 = require("class-transformer");
@@ -9,6 +9,18 @@ const nestjs_validation_1 = require("@dismissible/nestjs-validation");
9
9
  * Injection token for JWT auth hook configuration.
10
10
  */
11
11
  exports.JWT_AUTH_HOOK_CONFIG = Symbol('JWT_AUTH_HOOK_CONFIG');
12
+ /**
13
+ * User ID match type for comparing JWT claim against request userId.
14
+ */
15
+ var UserIdMatchType;
16
+ (function (UserIdMatchType) {
17
+ /** Exact string match (default) */
18
+ UserIdMatchType["EXACT"] = "exact";
19
+ /** Substring match - either value contains the other */
20
+ UserIdMatchType["SUBSTRING"] = "substring";
21
+ /** Regex match - tokenUserId is tested against a regex pattern */
22
+ UserIdMatchType["REGEX"] = "regex";
23
+ })(UserIdMatchType || (exports.UserIdMatchType = UserIdMatchType = {}));
12
24
  /**
13
25
  * Configuration options for JWT authentication hook.
14
26
  */
@@ -27,8 +39,10 @@ tslib_1.__decorate([
27
39
  ], JwtAuthHookConfig.prototype, "wellKnownUrl", void 0);
28
40
  tslib_1.__decorate([
29
41
  (0, class_validator_1.IsOptional)(),
30
- (0, class_validator_1.IsString)(),
31
- tslib_1.__metadata("design:type", String)
42
+ (0, class_validator_1.IsArray)(),
43
+ (0, class_validator_1.IsString)({ each: true }),
44
+ (0, nestjs_validation_1.TransformCommaSeparated)(),
45
+ tslib_1.__metadata("design:type", Array)
32
46
  ], JwtAuthHookConfig.prototype, "issuer", void 0);
33
47
  tslib_1.__decorate([
34
48
  (0, class_validator_1.IsOptional)(),
@@ -39,6 +53,7 @@ tslib_1.__decorate([
39
53
  (0, class_validator_1.IsOptional)(),
40
54
  (0, class_validator_1.IsArray)(),
41
55
  (0, class_validator_1.IsString)({ each: true }),
56
+ (0, nestjs_validation_1.TransformCommaSeparated)(),
42
57
  tslib_1.__metadata("design:type", Array)
43
58
  ], JwtAuthHookConfig.prototype, "algorithms", void 0);
44
59
  tslib_1.__decorate([
@@ -65,5 +80,20 @@ tslib_1.__decorate([
65
80
  (0, nestjs_validation_1.TransformBoolean)(true) // Default to true if not provided
66
81
  ,
67
82
  tslib_1.__metadata("design:type", Boolean)
68
- ], JwtAuthHookConfig.prototype, "verifyUserIdMatch", void 0);
83
+ ], JwtAuthHookConfig.prototype, "matchUserId", void 0);
84
+ tslib_1.__decorate([
85
+ (0, class_validator_1.IsOptional)(),
86
+ (0, class_validator_1.IsString)(),
87
+ tslib_1.__metadata("design:type", String)
88
+ ], JwtAuthHookConfig.prototype, "userIdClaim", void 0);
89
+ tslib_1.__decorate([
90
+ (0, class_validator_1.IsOptional)(),
91
+ (0, class_validator_1.IsEnum)(UserIdMatchType),
92
+ tslib_1.__metadata("design:type", String)
93
+ ], JwtAuthHookConfig.prototype, "userIdMatchType", void 0);
94
+ tslib_1.__decorate([
95
+ (0, class_validator_1.ValidateIf)((o) => o.userIdMatchType === UserIdMatchType.REGEX),
96
+ (0, class_validator_1.IsString)(),
97
+ tslib_1.__metadata("design:type", String)
98
+ ], JwtAuthHookConfig.prototype, "userIdMatchRegex", void 0);
69
99
  //# sourceMappingURL=jwt-auth-hook.config.js.map
@@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,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;yDACqB;AASxB;IAHf,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;mDACe;AASlB;IAHf,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;IACX,IAAA,oCAAgB,EAAC,IAAI,CAAC,CAAC,kCAAkC;;;sDACpB;AAQtB;IAFf,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;sDAC0B;AAQrB;IAFf,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,eAAe,CAAC;;0DAC0B;AASlC;IAFf,IAAA,4BAAU,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,KAAK,eAAe,CAAC,KAAK,CAAC;IAC9D,IAAA,0BAAQ,GAAE;;2DAC+B"}
@@ -12,7 +12,7 @@ export interface IJwtAuthHookModuleAsyncOptions {
12
12
  *
13
13
  * @example
14
14
  * ```typescript
15
- * import { DismissibleModule } from '@dismissible/nestjs-dismissible';
15
+ * import { DismissibleModule } from '@dismissible/nestjs-core';
16
16
  * import { JwtAuthHookModule, JwtAuthHook } from '@dismissible/nestjs-jwt-auth-hook';
17
17
  *
18
18
  * @Module({
@@ -13,7 +13,7 @@ const jwt_auth_hook_config_1 = require("./jwt-auth-hook.config");
13
13
  *
14
14
  * @example
15
15
  * ```typescript
16
- * import { DismissibleModule } from '@dismissible/nestjs-dismissible';
16
+ * import { DismissibleModule } from '@dismissible/nestjs-core';
17
17
  * import { JwtAuthHookModule, JwtAuthHook } from '@dismissible/nestjs-jwt-auth-hook';
18
18
  *
19
19
  * @Module({
@@ -1,5 +1,5 @@
1
- import { IDismissibleLifecycleHook, IHookResult } from '@dismissible/nestjs-dismissible-hooks';
2
- import { IRequestContext } from '@dismissible/nestjs-dismissible-request';
1
+ import { IDismissibleLifecycleHook, IHookResult } from '@dismissible/nestjs-hooks';
2
+ import { IRequestContext } from '@dismissible/nestjs-request';
3
3
  import { IDismissibleLogger } from '@dismissible/nestjs-logger';
4
4
  import { JwtAuthService } from './jwt-auth.service';
5
5
  import { JwtAuthHookConfig } from './jwt-auth-hook.config';
@@ -18,4 +18,8 @@ export declare class JwtAuthHook implements IDismissibleLifecycleHook {
18
18
  * Runs before any dismissible operation.
19
19
  */
20
20
  onBeforeRequest(itemId: string, userId: string, context?: IRequestContext): Promise<IHookResult>;
21
+ /**
22
+ * Matches the token user ID against the request user ID based on the configured match type.
23
+ */
24
+ private matchUserIdValue;
21
25
  }
@@ -45,14 +45,16 @@ let JwtAuthHook = class JwtAuthHook {
45
45
  });
46
46
  throw new common_1.UnauthorizedException(result.error);
47
47
  }
48
- const verifyUserIdMatch = this.config.verifyUserIdMatch ?? true;
49
- if (verifyUserIdMatch && result.payload?.sub) {
50
- if (result.payload.sub !== userId) {
48
+ const matchUserId = this.config.matchUserId ?? true;
49
+ const userIdClaim = this.config.userIdClaim ?? 'sub';
50
+ const tokenUserId = result.payload?.[userIdClaim];
51
+ if (matchUserId && tokenUserId) {
52
+ if (!this.matchUserIdValue(tokenUserId, userId)) {
51
53
  this.logger.debug('JWT auth hook: User ID mismatch', {
52
54
  itemId,
53
55
  userId,
54
56
  requestId: context?.requestId,
55
- tokenSubject: result.payload.sub,
57
+ tokenSubject: tokenUserId,
56
58
  });
57
59
  throw new common_1.ForbiddenException('User ID in request does not match authenticated user');
58
60
  }
@@ -61,12 +63,28 @@ let JwtAuthHook = class JwtAuthHook {
61
63
  itemId,
62
64
  userId,
63
65
  requestId: context?.requestId,
64
- subject: result.payload?.sub,
66
+ subject: tokenUserId,
65
67
  });
66
68
  return {
67
69
  proceed: true,
68
70
  };
69
71
  }
72
+ /**
73
+ * Matches the token user ID against the request user ID based on the configured match type.
74
+ */
75
+ matchUserIdValue(tokenUserId, userId) {
76
+ const matchType = this.config.userIdMatchType ?? jwt_auth_hook_config_1.UserIdMatchType.EXACT;
77
+ switch (matchType) {
78
+ case jwt_auth_hook_config_1.UserIdMatchType.EXACT:
79
+ return tokenUserId === userId;
80
+ case jwt_auth_hook_config_1.UserIdMatchType.SUBSTRING:
81
+ return tokenUserId.includes(userId) || userId.includes(tokenUserId);
82
+ case jwt_auth_hook_config_1.UserIdMatchType.REGEX: {
83
+ const regex = new RegExp(this.config.userIdMatchRegex);
84
+ return regex.test(tokenUserId);
85
+ }
86
+ }
87
+ }
70
88
  };
71
89
  exports.JwtAuthHook = JwtAuthHook;
72
90
  exports.JwtAuthHook = JwtAuthHook = tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"jwt-auth.hook.js","sourceRoot":"","sources":["../../../../libs/jwt-auth-hook/src/jwt-auth.hook.ts"],"names":[],"mappings":";;;;AAAA,2CAA+F;AAG/F,8DAAoF;AACpF,yDAAoD;AACpD,iEAAiF;AAEjF;;;GAGG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IAGtB,YACmB,cAA8B,EAE9B,MAAyB,EAEzB,MAA0B;QAJ1B,mBAAc,GAAd,cAAc,CAAgB;QAE9B,WAAM,GAAN,MAAM,CAAmB;QAEzB,WAAM,GAAN,MAAM,CAAoB;QAE3C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,eAAe,CACnB,MAAc,EACd,MAAc,EACd,OAAyB;QAEzB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;QAED,MAAM,mBAAmB,GAAG,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;QAE9D,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;QAE1E,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,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,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,WAAmB,EAAE,MAAc;QAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,IAAI,sCAAe,CAAC,KAAK,CAAC;QAEvE,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,sCAAe,CAAC,KAAK;gBACxB,OAAO,WAAW,KAAK,MAAM,CAAC;YAChC,KAAK,sCAAe,CAAC,SAAS;gBAC5B,OAAO,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACtE,KAAK,sCAAe,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC3B,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,gBAA0B,CAAC,CAAC;gBACjE,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAlGY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;IAMR,mBAAA,IAAA,eAAM,EAAC,2CAAoB,CAAC,CAAA;IAE5B,mBAAA,IAAA,eAAM,EAAC,kCAAkB,CAAC,CAAA;6CAHM,iCAAc;QAEtB,wCAAiB;GANjC,WAAW,CAkGvB"}
@@ -108,8 +108,11 @@ let JwtAuthService = class JwtAuthService {
108
108
  const verifyOptions = {
109
109
  algorithms: this.config.algorithms ?? ['RS256'],
110
110
  };
111
- if (this.config.issuer) {
112
- verifyOptions.issuer = this.config.issuer;
111
+ if (this.config.issuer && this.config.issuer.length > 0) {
112
+ verifyOptions.issuer =
113
+ this.config.issuer.length === 1
114
+ ? this.config.issuer[0]
115
+ : this.config.issuer;
113
116
  }
114
117
  if (this.config.audience) {
115
118
  verifyOptions.audience = this.config.audience;
@@ -1 +1 @@
1
- {"version":3,"file":"jwt-auth.service.js","sourceRoot":"","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