@tsed/oidc-provider 7.0.0-alpha.1 → 7.0.0-beta.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.
Files changed (174) hide show
  1. package/.nycrc +6 -5
  2. package/lib/{OidcModule.js → cjs/OidcModule.js} +21 -32
  3. package/lib/cjs/OidcModule.js.map +1 -0
  4. package/lib/{constants → cjs/constants}/index.js +0 -0
  5. package/lib/cjs/constants/index.js.map +1 -0
  6. package/lib/{decorators → cjs/decorators}/grantId.js +1 -1
  7. package/lib/cjs/decorators/grantId.js.map +1 -0
  8. package/lib/cjs/decorators/index.js +13 -0
  9. package/lib/cjs/decorators/index.js.map +1 -0
  10. package/lib/{decorators → cjs/decorators}/interaction.js +2 -2
  11. package/lib/cjs/decorators/interaction.js.map +1 -0
  12. package/lib/{decorators → cjs/decorators}/interactions.js +1 -1
  13. package/lib/cjs/decorators/interactions.js.map +1 -0
  14. package/lib/{decorators → cjs/decorators}/noCache.js +1 -1
  15. package/lib/cjs/decorators/noCache.js.map +1 -0
  16. package/lib/{decorators → cjs/decorators}/oidcCtx.js +1 -1
  17. package/lib/cjs/decorators/oidcCtx.js.map +1 -0
  18. package/lib/{decorators → cjs/decorators}/oidcSession.js +1 -1
  19. package/lib/cjs/decorators/oidcSession.js.map +1 -0
  20. package/lib/{decorators → cjs/decorators}/params.js +1 -1
  21. package/lib/cjs/decorators/params.js.map +1 -0
  22. package/lib/{decorators → cjs/decorators}/prompt.js +1 -1
  23. package/lib/cjs/decorators/prompt.js.map +1 -0
  24. package/lib/{decorators → cjs/decorators}/uid.js +1 -1
  25. package/lib/cjs/decorators/uid.js.map +1 -0
  26. package/lib/{domain → cjs/domain}/OidcAccountsMethods.js +0 -0
  27. package/lib/cjs/domain/OidcAccountsMethods.js.map +1 -0
  28. package/lib/{domain → cjs/domain}/OidcInteraction.js +0 -0
  29. package/lib/cjs/domain/OidcInteraction.js.map +1 -0
  30. package/lib/{domain → cjs/domain}/OidcInteractionMethods.js +0 -0
  31. package/lib/cjs/domain/OidcInteractionMethods.js.map +1 -0
  32. package/lib/{domain → cjs/domain}/OidcInteractionOptions.js +0 -0
  33. package/lib/cjs/domain/OidcInteractionOptions.js.map +1 -0
  34. package/lib/{domain → cjs/domain}/OidcSettings.js +0 -0
  35. package/lib/cjs/domain/OidcSettings.js.map +1 -0
  36. package/lib/cjs/domain/index.js +9 -0
  37. package/lib/cjs/domain/index.js.map +1 -0
  38. package/lib/cjs/index.js +15 -0
  39. package/lib/cjs/index.js.map +1 -0
  40. package/lib/{middlewares → cjs/middlewares}/OidcInteractionMiddleware.js +13 -13
  41. package/lib/cjs/middlewares/OidcInteractionMiddleware.js.map +1 -0
  42. package/lib/{middlewares → cjs/middlewares}/OidcNoCacheMiddleware.js +7 -7
  43. package/lib/cjs/middlewares/OidcNoCacheMiddleware.js.map +1 -0
  44. package/lib/{middlewares → cjs/middlewares}/OidcSecureMiddleware.js +8 -8
  45. package/lib/cjs/middlewares/OidcSecureMiddleware.js.map +1 -0
  46. package/lib/{services → cjs/services}/OidcAdapters.js +5 -5
  47. package/lib/cjs/services/OidcAdapters.js.map +1 -0
  48. package/lib/{services → cjs/services}/OidcInteractionContext.js +16 -16
  49. package/lib/cjs/services/OidcInteractionContext.js.map +1 -0
  50. package/lib/{services → cjs/services}/OidcInteractions.js +13 -12
  51. package/lib/cjs/services/OidcInteractions.js.map +1 -0
  52. package/lib/{services → cjs/services}/OidcJwks.js +9 -9
  53. package/lib/cjs/services/OidcJwks.js.map +1 -0
  54. package/lib/{services → cjs/services}/OidcProvider.js +42 -41
  55. package/lib/cjs/services/OidcProvider.js.map +1 -0
  56. package/lib/{utils → cjs/utils}/debug.js +3 -3
  57. package/lib/cjs/utils/debug.js.map +1 -0
  58. package/lib/esm/OidcModule.js +76 -0
  59. package/lib/esm/OidcModule.js.map +1 -0
  60. package/lib/esm/constants/index.js +11 -0
  61. package/lib/esm/constants/index.js.map +1 -0
  62. package/lib/esm/decorators/grantId.js +7 -0
  63. package/lib/esm/decorators/grantId.js.map +1 -0
  64. package/lib/esm/decorators/index.js +10 -0
  65. package/lib/esm/decorators/index.js.map +1 -0
  66. package/lib/esm/decorators/interaction.js +13 -0
  67. package/lib/esm/decorators/interaction.js.map +1 -0
  68. package/lib/esm/decorators/interactions.js +10 -0
  69. package/lib/esm/decorators/interactions.js.map +1 -0
  70. package/lib/esm/decorators/noCache.js +6 -0
  71. package/lib/esm/decorators/noCache.js.map +1 -0
  72. package/lib/esm/decorators/oidcCtx.js +7 -0
  73. package/lib/esm/decorators/oidcCtx.js.map +1 -0
  74. package/lib/esm/decorators/oidcSession.js +10 -0
  75. package/lib/esm/decorators/oidcSession.js.map +1 -0
  76. package/lib/esm/decorators/params.js +7 -0
  77. package/lib/esm/decorators/params.js.map +1 -0
  78. package/lib/esm/decorators/prompt.js +7 -0
  79. package/lib/esm/decorators/prompt.js.map +1 -0
  80. package/lib/esm/decorators/uid.js +7 -0
  81. package/lib/esm/decorators/uid.js.map +1 -0
  82. package/lib/esm/domain/OidcAccountsMethods.js +2 -0
  83. package/lib/esm/domain/OidcAccountsMethods.js.map +1 -0
  84. package/lib/esm/domain/OidcInteraction.js +2 -0
  85. package/lib/esm/domain/OidcInteraction.js.map +1 -0
  86. package/lib/esm/domain/OidcInteractionMethods.js +2 -0
  87. package/lib/esm/domain/OidcInteractionMethods.js.map +1 -0
  88. package/lib/esm/domain/OidcInteractionOptions.js +2 -0
  89. package/lib/esm/domain/OidcInteractionOptions.js.map +1 -0
  90. package/lib/esm/domain/OidcSettings.js +2 -0
  91. package/lib/esm/domain/OidcSettings.js.map +1 -0
  92. package/lib/esm/domain/index.js +6 -0
  93. package/lib/esm/domain/index.js.map +1 -0
  94. package/lib/esm/index.js +12 -0
  95. package/lib/esm/index.js.map +1 -0
  96. package/lib/esm/middlewares/OidcInteractionMiddleware.js +38 -0
  97. package/lib/esm/middlewares/OidcInteractionMiddleware.js.map +1 -0
  98. package/lib/esm/middlewares/OidcNoCacheMiddleware.js +19 -0
  99. package/lib/esm/middlewares/OidcNoCacheMiddleware.js.map +1 -0
  100. package/lib/esm/middlewares/OidcSecureMiddleware.js +35 -0
  101. package/lib/esm/middlewares/OidcSecureMiddleware.js.map +1 -0
  102. package/lib/esm/services/OidcAdapters.js +54 -0
  103. package/lib/esm/services/OidcAdapters.js.map +1 -0
  104. package/lib/esm/services/OidcInteractionContext.js +110 -0
  105. package/lib/esm/services/OidcInteractionContext.js.map +1 -0
  106. package/lib/esm/services/OidcInteractions.js +61 -0
  107. package/lib/esm/services/OidcInteractions.js.map +1 -0
  108. package/lib/esm/services/OidcJwks.js +28 -0
  109. package/lib/esm/services/OidcJwks.js.map +1 -0
  110. package/lib/esm/services/OidcProvider.js +173 -0
  111. package/lib/esm/services/OidcProvider.js.map +1 -0
  112. package/lib/esm/utils/debug.js +20 -0
  113. package/lib/esm/utils/debug.js.map +1 -0
  114. package/lib/{OidcModule.d.ts → types/OidcModule.d.ts} +0 -0
  115. package/lib/{constants → types/constants}/index.d.ts +0 -0
  116. package/lib/{decorators → types/decorators}/grantId.d.ts +0 -0
  117. package/lib/{decorators → types/decorators}/index.d.ts +0 -0
  118. package/lib/{decorators → types/decorators}/interaction.d.ts +0 -0
  119. package/lib/{decorators → types/decorators}/interactions.d.ts +0 -0
  120. package/lib/{decorators → types/decorators}/noCache.d.ts +0 -0
  121. package/lib/{decorators → types/decorators}/oidcCtx.d.ts +0 -0
  122. package/lib/{decorators → types/decorators}/oidcSession.d.ts +0 -0
  123. package/lib/{decorators → types/decorators}/params.d.ts +0 -0
  124. package/lib/{decorators → types/decorators}/prompt.d.ts +0 -0
  125. package/lib/{decorators → types/decorators}/uid.d.ts +0 -0
  126. package/lib/{domain → types/domain}/OidcAccountsMethods.d.ts +0 -0
  127. package/lib/{domain → types/domain}/OidcInteraction.d.ts +0 -0
  128. package/lib/{domain → types/domain}/OidcInteractionMethods.d.ts +0 -0
  129. package/lib/{domain → types/domain}/OidcInteractionOptions.d.ts +0 -0
  130. package/lib/{domain → types/domain}/OidcSettings.d.ts +0 -0
  131. package/lib/{domain → types/domain}/index.d.ts +0 -0
  132. package/lib/{index.d.ts → types/index.d.ts} +0 -0
  133. package/lib/{middlewares → types/middlewares}/OidcInteractionMiddleware.d.ts +0 -0
  134. package/lib/{middlewares → types/middlewares}/OidcNoCacheMiddleware.d.ts +0 -0
  135. package/lib/{middlewares → types/middlewares}/OidcSecureMiddleware.d.ts +0 -0
  136. package/lib/{services → types/services}/OidcAdapters.d.ts +0 -0
  137. package/lib/{services → types/services}/OidcInteractionContext.d.ts +0 -0
  138. package/lib/{services → types/services}/OidcInteractions.d.ts +0 -0
  139. package/lib/{services → types/services}/OidcJwks.d.ts +0 -0
  140. package/lib/{services → types/services}/OidcProvider.d.ts +0 -0
  141. package/lib/{utils → types/utils}/debug.d.ts +0 -0
  142. package/package.json +29 -21
  143. package/tsconfig.compile.esm.json +23 -0
  144. package/lib/OidcModule.js.map +0 -1
  145. package/lib/constants/index.js.map +0 -1
  146. package/lib/decorators/grantId.js.map +0 -1
  147. package/lib/decorators/index.js +0 -13
  148. package/lib/decorators/index.js.map +0 -1
  149. package/lib/decorators/interaction.js.map +0 -1
  150. package/lib/decorators/interactions.js.map +0 -1
  151. package/lib/decorators/noCache.js.map +0 -1
  152. package/lib/decorators/oidcCtx.js.map +0 -1
  153. package/lib/decorators/oidcSession.js.map +0 -1
  154. package/lib/decorators/params.js.map +0 -1
  155. package/lib/decorators/prompt.js.map +0 -1
  156. package/lib/decorators/uid.js.map +0 -1
  157. package/lib/domain/OidcAccountsMethods.js.map +0 -1
  158. package/lib/domain/OidcInteraction.js.map +0 -1
  159. package/lib/domain/OidcInteractionMethods.js.map +0 -1
  160. package/lib/domain/OidcInteractionOptions.js.map +0 -1
  161. package/lib/domain/OidcSettings.js.map +0 -1
  162. package/lib/domain/index.js +0 -9
  163. package/lib/domain/index.js.map +0 -1
  164. package/lib/index.js +0 -15
  165. package/lib/index.js.map +0 -1
  166. package/lib/middlewares/OidcInteractionMiddleware.js.map +0 -1
  167. package/lib/middlewares/OidcNoCacheMiddleware.js.map +0 -1
  168. package/lib/middlewares/OidcSecureMiddleware.js.map +0 -1
  169. package/lib/services/OidcAdapters.js.map +0 -1
  170. package/lib/services/OidcInteractionContext.js.map +0 -1
  171. package/lib/services/OidcInteractions.js.map +0 -1
  172. package/lib/services/OidcJwks.js.map +0 -1
  173. package/lib/services/OidcProvider.js.map +0 -1
  174. package/lib/utils/debug.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcInteractions.js","sourceRoot":"","sources":["../../../src/services/OidcInteractions.ts"],"names":[],"mappings":";;;;AAAA,yCAAmH;AACnH,qCAA+B;AAC/B,iCAA6D;AAC7D,4CAA4E;AAI5E,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IAA7B;QAUY,iBAAY,GAA0B,IAAI,GAAG,EAAE,CAAC;IA4C5D,CAAC;IA1CC,OAAO;QACL,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAkB,wBAAe,CAAE,CAAC;QAE7E,IAAI,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC,QAAkB,EAAE,EAAE;;YACpD,MAAM,EAAC,IAAI,EAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAyB,+BAAmB,CAAC,CAAC;YAC/E,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAEtC,IAAI,MAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,0CAAE,OAAO,EAAE;gBAC9C,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;aACzF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,eAAe;QACb,MAAM,oBAAoB,GAAG,IAAI,CAAC,Q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Metadata, PlatformContext, PlatformHandler, Provider, TokenProvider} from \"@tsed/common\";\nimport {Env} from \"@tsed/core\";\nimport {Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {INTERACTION, INTERACTION_OPTIONS, INTERACTIONS} from \"../constants\";\nimport {OidcInteractionOptions, OidcSettings} from \"../domain\";\n\n@Injectable()\nexport class OidcInteractions {\n @Inject()\n injector: InjectorService;\n\n @Constant(\"env\")\n env: Env;\n\n @Constant(\"oidc\")\n oidcSettings: OidcSettings;\n\n protected interactions: Map<string, Provider> = new Map();\n\n $onInit(): void {\n const platformHandler = this.injector.get<PlatformHandler>(PlatformHandler)!;\n\n this.getInteractions().forEach((provider: Provider) => {\n const {name} = provider.store.get<OidcInteractionOptions>(INTERACTION_OPTIONS);\n this.interactions.set(name, provider);\n\n if (this.injector.get(provider.token)?.$prompt) {\n provider.store.set(\"$prompt\", platformHandler.createCustomHandler(provider, \"$prompt\"));\n }\n });\n }\n\n getInteractions(): Provider[] {\n const interactionsProvider = this.injector.getProviders().find((provider) => provider.subType === INTERACTIONS);\n\n /* istanbul ignore next */\n if (!interactionsProvider) {\n return [];\n }\n\n return interactionsProvider.children\n .map((token: TokenProvider) => this.injector.getProvider(token)!)\n .filter((provider: Provider) => provider?.subType === INTERACTION);\n }\n\n getInteractionProvider(name: string): Provider | undefined {\n return this.interactions.get(name);\n }\n\n getInteractionHandler(name: string) {\n const interaction = this.getInteractionProvider(name);\n\n if (interaction) {\n return (ctx: PlatformContext) => {\n // Add current endpoint metadata to ctx\n ctx.endpoint = EndpointMetadata.get(interaction.useClass, \"$prompt\");\n\n return interaction.store.get(\"$prompt\")(ctx);\n };\n }\n }\n}\n"]}
@@ -10,22 +10,22 @@ let OidcJwks = class OidcJwks {
10
10
  return this.getJwks();
11
11
  }
12
12
  getJwks() {
13
- return jwks_1.getJwks({
13
+ return (0, jwks_1.getJwks)({
14
14
  path: this.jwksPath,
15
15
  certificates: this.certificates
16
16
  });
17
17
  }
18
18
  };
19
- tslib_1.__decorate([
20
- di_1.Constant("oidc.jwksPath", path_1.join(process.cwd(), "keys", "jwks.json")),
21
- tslib_1.__metadata("design:type", String)
19
+ (0, tslib_1.__decorate)([
20
+ (0, di_1.Constant)("oidc.jwksPath", (0, path_1.join)(process.cwd(), "keys", "jwks.json")),
21
+ (0, tslib_1.__metadata)("design:type", String)
22
22
  ], OidcJwks.prototype, "jwksPath", void 0);
23
- tslib_1.__decorate([
24
- di_1.Constant("oidc.certificates"),
25
- tslib_1.__metadata("design:type", Array)
23
+ (0, tslib_1.__decorate)([
24
+ (0, di_1.Constant)("oidc.certificates"),
25
+ (0, tslib_1.__metadata)("design:type", Array)
26
26
  ], OidcJwks.prototype, "certificates", void 0);
27
- OidcJwks = tslib_1.__decorate([
28
- di_1.Injectable()
27
+ OidcJwks = (0, tslib_1.__decorate)([
28
+ (0, di_1.Injectable)()
29
29
  ], OidcJwks);
30
30
  exports.OidcJwks = OidcJwks;
31
31
  //# sourceMappingURL=OidcJwks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcJwks.js","sourceRoot":"","sources":["../../../src/services/OidcJwks.ts"],"names":[],"mappings":";;;;AAAA,iCAA8C;AAC9C,+BAA0B;AAC1B,qCAAsD;AAGtD,IAAa,QAAQ,GAArB,MAAa,QAAQ;IASnB,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,OAAO;QACL,OAAO,IAAA,cAAO,EAAC;YACb,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjBC;IADC,IAAA,aAAQ,EAAC,eAAe,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;;0CACnD;AAGjB;IADC,IAAA,aAAQ,EAAC,mBAAmB,CAAC;;8CACK;AALxB,QAAQ;IADpB,IAAA,eAAU,GAAE;GACA,QAAQ,CAmBpB;AAnBY,4BAAQ","sourcesContent":["import {Constant, Injectable} from \"@tsed/di\";\nimport {join} from \"path\";\nimport {getJwks, JwksKeyParameters} from \"@tsed/jwks\";\n\n@Injectable()\nexport class OidcJwks {\n @Constant(\"oidc.jwksPath\", join(process.cwd(), \"keys\", \"jwks.json\"))\n jwksPath: string;\n\n @Constant(\"oidc.certificates\")\n certificates?: JwksKeyParameters[];\n\n keys: string;\n\n async $onInit() {\n return this.getJwks();\n }\n\n getJwks() {\n return getJwks({\n path: this.jwksPath,\n certificates: this.certificates\n });\n }\n}\n"]}
@@ -30,16 +30,16 @@ let OidcProvider = class OidcProvider {
30
30
  configuration.findAccount = (ctx, id, token) => this.injector.get(Accounts).findAccount(id, token, ctx.req.$ctx);
31
31
  }
32
32
  if (this.env === core_1.Env.PROD) {
33
- core_1.setValue(configuration, "cookies.short.secure", true);
34
- core_1.setValue(configuration, "cookies.long.secure", true);
33
+ (0, core_1.setValue)(configuration, "cookies.short.secure", true);
34
+ (0, core_1.setValue)(configuration, "cookies.long.secure", true);
35
35
  }
36
36
  const policy = this.getPolicy();
37
37
  if (policy) {
38
- core_1.setValue(configuration, "interactions.policy", policy);
38
+ (0, core_1.setValue)(configuration, "interactions.policy", policy);
39
39
  }
40
40
  const url = this.getInteractionsUrl();
41
41
  if (url) {
42
- core_1.setValue(configuration, "interactions.url", url);
42
+ (0, core_1.setValue)(configuration, "interactions.url", url);
43
43
  }
44
44
  return configuration;
45
45
  }
@@ -116,60 +116,61 @@ let OidcProvider = class OidcProvider {
116
116
  ...options
117
117
  }));
118
118
  }
119
- if (provider.instance.$onCreate) {
120
- provider.instance.$onCreate(policy.get(name));
119
+ const instance = this.injector.get(provider.token);
120
+ if (instance.$onCreate) {
121
+ instance.$onCreate(policy.get(name));
121
122
  }
122
123
  });
123
124
  }
124
125
  return this.injector.alter("$alterOidcPolicy", policy);
125
126
  }
126
127
  };
127
- tslib_1.__decorate([
128
- di_1.Constant("env"),
129
- tslib_1.__metadata("design:type", String)
128
+ (0, tslib_1.__decorate)([
129
+ (0, di_1.Constant)("env"),
130
+ (0, tslib_1.__metadata)("design:type", String)
130
131
  ], OidcProvider.prototype, "env", void 0);
131
- tslib_1.__decorate([
132
- di_1.Constant("httpPort"),
133
- tslib_1.__metadata("design:type", Object)
132
+ (0, tslib_1.__decorate)([
133
+ (0, di_1.Constant)("httpPort"),
134
+ (0, tslib_1.__metadata)("design:type", Object)
134
135
  ], OidcProvider.prototype, "httpPort", void 0);
135
- tslib_1.__decorate([
136
- di_1.Constant("httpsPort"),
137
- tslib_1.__metadata("design:type", Object)
136
+ (0, tslib_1.__decorate)([
137
+ (0, di_1.Constant)("httpsPort"),
138
+ (0, tslib_1.__metadata)("design:type", Object)
138
139
  ], OidcProvider.prototype, "httpsPort", void 0);
139
- tslib_1.__decorate([
140
- di_1.Constant("oidc.issuer", ""),
141
- tslib_1.__metadata("design:type", String)
140
+ (0, tslib_1.__decorate)([
141
+ (0, di_1.Constant)("oidc.issuer", ""),
142
+ (0, tslib_1.__metadata)("design:type", String)
142
143
  ], OidcProvider.prototype, "issuer", void 0);
143
- tslib_1.__decorate([
144
- di_1.Constant("oidc"),
145
- tslib_1.__metadata("design:type", Object)
144
+ (0, tslib_1.__decorate)([
145
+ (0, di_1.Constant)("oidc"),
146
+ (0, tslib_1.__metadata)("design:type", Object)
146
147
  ], OidcProvider.prototype, "oidc", void 0);
147
- tslib_1.__decorate([
148
- di_1.Constant("PLATFORM_NAME"),
149
- tslib_1.__metadata("design:type", String)
148
+ (0, tslib_1.__decorate)([
149
+ (0, di_1.Constant)("PLATFORM_NAME"),
150
+ (0, tslib_1.__metadata)("design:type", String)
150
151
  ], OidcProvider.prototype, "platformName", void 0);
151
- tslib_1.__decorate([
152
- di_1.Inject(),
153
- tslib_1.__metadata("design:type", OidcJwks_1.OidcJwks)
152
+ (0, tslib_1.__decorate)([
153
+ (0, di_1.Inject)(),
154
+ (0, tslib_1.__metadata)("design:type", OidcJwks_1.OidcJwks)
154
155
  ], OidcProvider.prototype, "oidcJwks", void 0);
155
- tslib_1.__decorate([
156
- di_1.Inject(),
157
- tslib_1.__metadata("design:type", OidcInteractions_1.OidcInteractions)
156
+ (0, tslib_1.__decorate)([
157
+ (0, di_1.Inject)(),
158
+ (0, tslib_1.__metadata)("design:type", OidcInteractions_1.OidcInteractions)
158
159
  ], OidcProvider.prototype, "oidcInteractions", void 0);
159
- tslib_1.__decorate([
160
- di_1.Inject(),
161
- tslib_1.__metadata("design:type", OidcAdapters_1.OidcAdapters)
160
+ (0, tslib_1.__decorate)([
161
+ (0, di_1.Inject)(),
162
+ (0, tslib_1.__metadata)("design:type", OidcAdapters_1.OidcAdapters)
162
163
  ], OidcProvider.prototype, "adapters", void 0);
163
- tslib_1.__decorate([
164
- di_1.Inject(),
165
- tslib_1.__metadata("design:type", di_1.InjectorService)
164
+ (0, tslib_1.__decorate)([
165
+ (0, di_1.Inject)(),
166
+ (0, tslib_1.__metadata)("design:type", di_1.InjectorService)
166
167
  ], OidcProvider.prototype, "injector", void 0);
167
- tslib_1.__decorate([
168
- di_1.Inject(),
169
- tslib_1.__metadata("design:type", common_1.PlatformApplication)
168
+ (0, tslib_1.__decorate)([
169
+ (0, di_1.Inject)(),
170
+ (0, tslib_1.__metadata)("design:type", common_1.PlatformApplication)
170
171
  ], OidcProvider.prototype, "app", void 0);
171
- OidcProvider = tslib_1.__decorate([
172
- di_1.Injectable()
172
+ OidcProvider = (0, tslib_1.__decorate)([
173
+ (0, di_1.Injectable)()
173
174
  ], OidcProvider);
174
175
  exports.OidcProvider = OidcProvider;
175
176
  //# sourceMappingURL=OidcProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcProvider.js","sourceRoot":"","sources":["../../../src/services/OidcProvider.ts"],"names":[],"mappings":";;;;AAAA,qCAAyC;AACzC,iCAAuE;AACvE,iDAAyF;AACzF,4CAA0C;AAE1C,iDAA4C;AAC5C,yDAAo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CAAC;AAGjC;IADC,IAAA,WAAM,GAAE;2CACW,oBAAe;8CAAC;AAGpC;IADC,IAAA,WAAM,GAAE;2CACM,4BAAmB;yCAAC;AAlCxB,YAAY;IADxB,IAAA,eAAU,GAAE;GACA,YAAY,CAqLxB;AArLY,oCAAY","sourcesContent":["import {Env, setValue} from \"@tsed/core\";\nimport {Constant, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {Provider as OIDCProvider, Configuration, interactionPolicy} from \"oidc-provider\";\nimport {INTERACTIONS} from \"../constants\";\nimport {OidcAccountsMethods, OidcSettings} from \"../domain\";\nimport {OidcAdapters} from \"./OidcAdapters\";\nimport {OidcInteractions} from \"./OidcInteractions\";\nimport {OidcJwks} from \"./OidcJwks\";\nimport {PlatformApplication} from \"@tsed/common\";\n\n@Injectable()\nexport class OidcProvider {\n raw: OIDCProvider;\n\n @Constant(\"env\")\n protected env: Env;\n\n @Constant(\"httpPort\")\n protected httpPort: number | string;\n\n @Constant(\"httpsPort\")\n protected httpsPort: number | string;\n\n @Constant(\"oidc.issuer\", \"\")\n protected issuer: string;\n\n @Constant(\"oidc\")\n protected oidc: OidcSettings;\n\n @Constant(\"PLATFORM_NAME\")\n protected platformName: string;\n\n @Inject()\n protected oidcJwks: OidcJwks;\n\n @Inject()\n protected oidcInteractions: OidcInteractions;\n\n @Inject()\n protected adapters: OidcAdapters;\n\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected app: PlatformApplication;\n\n hasConfiguration() {\n return !!this.oidc;\n }\n\n async getConfiguration(): Promise<Configuration> {\n const [jwks, adapter] = await Promise.all([this.oidcJwks.getJwks(), this.adapters.createAdapterClass()]);\n const {issuer, jwksPath, secureKey, proxy, Accounts, ...options} = this.oidc;\n\n const configuration: Configuration = {\n interactions: {\n /* istanbul ignore next */\n url: (ctx, interaction) => `interaction/${interaction.uid}`\n },\n ...options,\n adapter,\n jwks\n };\n\n if (Accounts) {\n configuration.findAccount = (ctx, id, token) =>\n this.injector.get<OidcAccountsMethods>(Accounts)!.findAccount(id, token, (ctx.req as any).$ctx);\n }\n\n if (this.env === Env.PROD) {\n setValue(configuration, \"cookies.short.secure\", true);\n setValue(configuration, \"cookies.long.secure\", true);\n }\n\n const policy = this.getPolicy();\n if (policy) {\n setValue(configuration, \"interactions.policy\", policy);\n }\n\n const url = this.getInteractionsUrl();\n if (url) {\n setValue(configuration, \"interactions.url\", url);\n }\n\n return configuration;\n }\n\n getIssuer() {\n if (this.issuer) {\n return this.issuer;\n }\n\n // istanbul ignore next\n if (this.httpsPort) {\n return `https://localhost:${this.httpsPort}`;\n }\n\n return `http://localhost:${this.httpPort}`;\n }\n\n get(): OIDCProvider {\n return this.raw;\n }\n\n /**\n * Create a new instance of OidcProvider\n */\n async create(): Promise<void | OIDCProvider> {\n const {proxy, secureKey} = this.oidc;\n const configuration = await this.getConfiguration();\n const oidcProvider = new OIDCProvider(this.getIssuer(), configuration);\n\n if (proxy || this.env === Env.PROD) {\n // istanbul ignore next\n switch (this.platformName) {\n default:\n case \"express\":\n oidcProvider.proxy = true;\n break;\n case \"koa\":\n (this.app.rawApp as any).proxy = true;\n break;\n }\n }\n\n if (secureKey) {\n oidcProvider.app.keys = secureKey;\n }\n\n this.raw = oidcProvider;\n\n if (this.env !== Env.PROD) {\n this.allowHttpLocalhost();\n }\n\n await this.injector.emit(\"$onCreateOIDC\", this.raw);\n\n return this.raw;\n }\n\n private getInteractionsUrl() {\n const provider = this.injector.getProviders().find((provider) => provider.subType === INTERACTIONS);\n\n if (provider) {\n return (ctx: any, interaction: any) => {\n // eslint-disable-line no-unused-vars\n return provider.path.replace(/:uid/, interaction.uid);\n };\n }\n }\n\n private allowHttpLocalhost() {\n const {invalidate: orig} = (this.raw.Client as any).Schema.prototype;\n\n (this.raw.Client as any).Schema.prototype.invalidate = function invalidate(message: string, code: string) {\n if (code === \"implicit-force-https\" || code === \"implicit-forbid-localhost\") {\n return;\n }\n\n /* istanbul ignore next */\n return orig.call(this, message);\n };\n }\n\n private getPolicy() {\n const policy = interactionPolicy.base();\n const interactions = this.oidcInteractions.getInteractions();\n\n if (interactions.length) {\n interactions.forEach((provider) => {\n const {name, ...options} = provider.store.get(\"interactionOptions\");\n\n if (!policy.get(name)) {\n policy.add(\n new interactionPolicy.Prompt({\n name,\n ...options\n })\n );\n }\n\n const instance = this.injector.get(provider.token);\n\n if (instance.$onCreate) {\n instance.$onCreate(policy.get(name));\n }\n });\n }\n\n return this.injector.alter(\"$alterOidcPolicy\", policy);\n }\n}\n"]}
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.debug = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const core_1 = require("@tsed/core");
6
- const querystring_1 = tslib_1.__importDefault(require("querystring"));
6
+ const querystring_1 = (0, tslib_1.__importDefault)(require("querystring"));
7
7
  const util_1 = require("util");
8
8
  const keys = new Set();
9
9
  function serialize(obj) {
10
10
  return Object.entries(obj).reduce((acc, [key, value]) => {
11
11
  keys.add(key);
12
- if (core_1.isEmpty(value)) {
12
+ if ((0, core_1.isEmpty)(value)) {
13
13
  return acc;
14
14
  }
15
- acc[key] = util_1.inspect(value, { depth: null });
15
+ acc[key] = (0, util_1.inspect)(value, { depth: null });
16
16
  return acc;
17
17
  }, {});
18
18
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/utils/debug.ts"],"names":[],"mappings":";;;;AAAA,qCAAmC;AACnC,2EAA6B;AAC7B,+BAA6B;AAE7B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;AAEvB,SAAS,SAAS,CAAC,GAAQ;IACzB,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC3D,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEd,IAAI,IAAA,cAAO,EAAC,KAAK,CAAC,EAAE;YAClB,OAAO,GAAG,CAAC;SACZ;QAED,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,cAAO,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAEM,MAAM,KAAK,GAAG,CAAC,GAAQ,EAAE,EAAE,CAChC,qBAAE,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;IAC1C,kBAAkB,CAAC,KAAK;QACtB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/D,CAAC;CACF,CAAC,CAAC;AALQ,QAAA,KAAK,SAKb","sourcesContent":["import {isEmpty} from \"@tsed/core\";\nimport qs from \"querystring\";\nimport {inspect} from \"util\";\n\nconst keys = new Set();\n\nfunction serialize(obj: any) {\n return Object.entries(obj).reduce((acc: any, [key, value]) => {\n keys.add(key);\n\n if (isEmpty(value)) {\n return acc;\n }\n\n acc[key] = inspect(value, {depth: null});\n return acc;\n }, {});\n}\n\nexport const debug = (obj: any) =>\n qs.stringify(serialize(obj), \"<br/>\", \": \", {\n encodeURIComponent(value) {\n return keys.has(value) ? `<strong>${value}</strong>` : value;\n }\n });\n"]}
@@ -0,0 +1,76 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Inject, InjectorService, PlatformApplication } from "@tsed/common";
3
+ import { Constant, Module } from "@tsed/di";
4
+ import { OidcAdapters } from "./services/OidcAdapters";
5
+ import { OidcJwks } from "./services/OidcJwks";
6
+ import { OidcProvider } from "./services/OidcProvider";
7
+ let OidcModule = class OidcModule {
8
+ async $onInit() {
9
+ if (this.oidcProvider.hasConfiguration()) {
10
+ await this.oidcProvider.create();
11
+ }
12
+ }
13
+ async $onRoutesInit() {
14
+ if (this.basePath !== "/") {
15
+ this.app.use(this.getRewriteMiddleware());
16
+ }
17
+ }
18
+ async $afterRoutesInit() {
19
+ if (this.oidcProvider.hasConfiguration()) {
20
+ const provider = this.oidcProvider.get();
21
+ switch (this.platformName) {
22
+ default:
23
+ case "express":
24
+ this.app.use(this.basePath, provider.callback());
25
+ break;
26
+ case "koa":
27
+ this.app.use(require("koa-mount")(this.basePath, provider.app));
28
+ break;
29
+ }
30
+ }
31
+ }
32
+ $onReady() {
33
+ if (this.oidcProvider.hasConfiguration() && this.injector.settings.getBestHost) {
34
+ const { injector } = this;
35
+ const host = injector.settings.getBestHost();
36
+ const url = host.toString();
37
+ injector.logger.info(`WellKnown is available on ${url}/.well-known/openid-configuration`);
38
+ }
39
+ }
40
+ getRewriteMiddleware() {
41
+ switch (this.platformName) {
42
+ default:
43
+ case "express":
44
+ return require("express-urlrewrite")("/.well-known/*", `${this.basePath}/.well-known/$1`);
45
+ case "koa":
46
+ return require("koa-rewrite")("/.well-known/(.*)", `${this.basePath}/.well-known/$1`);
47
+ }
48
+ }
49
+ };
50
+ __decorate([
51
+ Inject(),
52
+ __metadata("design:type", PlatformApplication)
53
+ ], OidcModule.prototype, "app", void 0);
54
+ __decorate([
55
+ Constant("PLATFORM_NAME"),
56
+ __metadata("design:type", String)
57
+ ], OidcModule.prototype, "platformName", void 0);
58
+ __decorate([
59
+ Constant("oidc.path", "/"),
60
+ __metadata("design:type", String)
61
+ ], OidcModule.prototype, "basePath", void 0);
62
+ __decorate([
63
+ Inject(),
64
+ __metadata("design:type", OidcProvider)
65
+ ], OidcModule.prototype, "oidcProvider", void 0);
66
+ __decorate([
67
+ Inject(),
68
+ __metadata("design:type", InjectorService)
69
+ ], OidcModule.prototype, "injector", void 0);
70
+ OidcModule = __decorate([
71
+ Module({
72
+ imports: [OidcProvider, OidcAdapters, OidcJwks]
73
+ })
74
+ ], OidcModule);
75
+ export { OidcModule };
76
+ //# sourceMappingURL=OidcModule.js.map
@@ -0,0 +1 @@
1
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ACT;SACF;IACH,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE;YAC9E,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;YACxB,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAE5B,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,GAAG,mCAAmC,CAAC,CAAC;SAC3F;IACH,CAAC;IAEO,oBAAoB;QAC1B,QAAQ,IAAI,CAAC,YAAY,EAAE;YACzB,QAAQ;YACR,KAAK,SAAS;gBACZ,OAAO,OAAO,CAAC,oBAAoB,CAAC,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,QAAQ,iBAAiB,CAAC,CAAC;YAC5F,KAAK,KAAK;gBACR,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC,mBAAmB,EAAE,GAAG,IAAI,CAAC,QAAQ,iBAAiB,CAAC,CAAC;SACzF;IACH,CAAC;CACF,CAAA;AA7DC;IADC,MAAM,EAAE;8BACJ,mBAAmB;uCAAC;AAGzB;IADC,QAAQ,CAAC,eAAe,CAAC;;gDACL;AAGrB;IADC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC;;4CACV;AAGjB;IADC,MAAM,EAAE;8BACK,YAAY;gDAAC;AAG3B;IADC,MAAM,EAAE;8BACC,eAAe;4CAAC;AAdf,UAAU;IAHtB,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,CAAC;KAChD,CAAC;GACW,UAAU,CA+DtB;SA/DY,UAAU","sourcesContent":["import {Inject, InjectorService, PlatformApplication} from \"@tsed/common\";\nimport {Constant, Module} from \"@tsed/di\";\nimport {OidcAdapters} from \"./services/OidcAdapters\";\nimport {OidcJwks} from \"./services/OidcJwks\";\nimport {OidcProvider} from \"./services/OidcProvider\";\n\n@Module({\n imports: [OidcProvider, OidcAdapters, OidcJwks]\n})\nexport class OidcModule {\n @Inject()\n app: PlatformApplication;\n\n @Constant(\"PLATFORM_NAME\")\n platformName: string;\n\n @Constant(\"oidc.path\", \"/\")\n basePath: string;\n\n @Inject()\n oidcProvider: OidcProvider;\n\n @Inject()\n injector: InjectorService;\n\n async $onInit() {\n if (this.oidcProvider.hasConfiguration()) {\n await this.oidcProvider.create();\n }\n }\n\n async $onRoutesInit() {\n if (this.basePath !== \"/\") {\n this.app.use(this.getRewriteMiddleware());\n }\n }\n\n async $afterRoutesInit() {\n if (this.oidcProvider.hasConfiguration()) {\n const provider = this.oidcProvider.get();\n\n switch (this.platformName) {\n default:\n case \"express\":\n this.app.use(this.basePath, provider.callback());\n break;\n case \"koa\":\n this.app.use(require(\"koa-mount\")(this.basePath, provider.app));\n break;\n }\n }\n }\n\n $onReady() {\n if (this.oidcProvider.hasConfiguration() && this.injector.settings.getBestHost) {\n const {injector} = this;\n const host = injector.settings.getBestHost();\n const url = host.toString();\n\n injector.logger.info(`WellKnown is available on ${url}/.well-known/openid-configuration`);\n }\n }\n\n private getRewriteMiddleware() {\n switch (this.platformName) {\n default:\n case \"express\":\n return require(\"express-urlrewrite\")(\"/.well-known/*\", `${this.basePath}/.well-known/$1`);\n case \"koa\":\n return require(\"koa-rewrite\")(\"/.well-known/(.*)\", `${this.basePath}/.well-known/$1`);\n }\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ export const INTERACTION_CONTEXT = "interactionContext";
2
+ export const INTERACTION_PARAMS = "interactionParams";
3
+ export const INTERACTION_GRANT_ID = "interactionGrantId";
4
+ export const INTERACTION_PROMPT = "interactionPrompt";
5
+ export const INTERACTION_UID = "interactionUid";
6
+ export const INTERACTION_SESSION = "interactionSession";
7
+ export const INTERACTION_DETAILS = "interactionDetails";
8
+ export const INTERACTION_OPTIONS = "interactionOptions";
9
+ export const INTERACTION = "interaction";
10
+ export const INTERACTIONS = "interactions";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AACxD,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC","sourcesContent":["export const INTERACTION_CONTEXT = \"interactionContext\";\nexport const INTERACTION_PARAMS = \"interactionParams\";\nexport const INTERACTION_GRANT_ID = \"interactionGrantId\";\nexport const INTERACTION_PROMPT = \"interactionPrompt\";\nexport const INTERACTION_UID = \"interactionUid\";\nexport const INTERACTION_SESSION = \"interactionSession\";\nexport const INTERACTION_DETAILS = \"interactionDetails\";\nexport const INTERACTION_OPTIONS = \"interactionOptions\";\nexport const INTERACTION = \"interaction\";\nexport const INTERACTIONS = \"interactions\";\n"]}
@@ -0,0 +1,7 @@
1
+ import { Context } from "@tsed/common";
2
+ import { useDecorators } from "@tsed/core";
3
+ import { INTERACTION_GRANT_ID } from "../constants";
4
+ export function GrantId() {
5
+ return useDecorators(Context(INTERACTION_GRANT_ID));
6
+ }
7
+ //# sourceMappingURL=grantId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grantId.js","sourceRoot":"","sources":["../../../src/decorators/grantId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,oBAAoB,EAAqB,MAAM,cAAc,CAAC;AAEtE,MAAM,UAAU,OAAO;IACrB,OAAO,aAAa,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import {Context} from \"@tsed/common\";\nimport {useDecorators} from \"@tsed/core\";\nimport {INTERACTION_GRANT_ID, INTERACTION_PARAMS} from \"../constants\";\n\nexport function GrantId(): ParameterDecorator {\n return useDecorators(Context(INTERACTION_GRANT_ID));\n}\n\nexport type GrantId = string;\n"]}
@@ -0,0 +1,10 @@
1
+ export * from "./interactions";
2
+ export * from "./interaction";
3
+ export * from "./noCache";
4
+ export * from "./oidcCtx";
5
+ export * from "./oidcSession";
6
+ export * from "./params";
7
+ export * from "./prompt";
8
+ export * from "./uid";
9
+ export * from "./grantId";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC","sourcesContent":["export * from \"./interactions\";\nexport * from \"./interaction\";\nexport * from \"./noCache\";\nexport * from \"./oidcCtx\";\nexport * from \"./oidcSession\";\nexport * from \"./params\";\nexport * from \"./prompt\";\nexport * from \"./uid\";\nexport * from \"./grantId\";\n"]}
@@ -0,0 +1,13 @@
1
+ import { Controller } from "@tsed/common";
2
+ import { StoreMerge, useDecorators } from "@tsed/core";
3
+ import { INTERACTION, INTERACTION_OPTIONS } from "../constants";
4
+ /**
5
+ * @Oidc
6
+ */
7
+ export function Interaction(options) {
8
+ return useDecorators(Controller({
9
+ path: "/",
10
+ subType: INTERACTION
11
+ }), StoreMerge(INTERACTION_OPTIONS, options));
12
+ }
13
+ //# sourceMappingURL=interaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../../src/decorators/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACrD,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAG9D;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAA+B;IACzD,OAAO,aAAa,CAClB,UAAU,CAAC;QACT,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,WAAW;KACrB,CAAC,EACF,UAAU,CAAC,mBAAmB,EAAE,OAAO,CAAC,CACzC,CAAC;AACJ,CAAC","sourcesContent":["import {Controller} from \"@tsed/common\";\nimport {StoreMerge, useDecorators} from \"@tsed/core\";\nimport {INTERACTION, INTERACTION_OPTIONS} from \"../constants\";\nimport {OidcInteractionOptions} from \"../domain\";\n\n/**\n * @Oidc\n */\nexport function Interaction(options: OidcInteractionOptions): ClassDecorator {\n return useDecorators(\n Controller({\n path: \"/\",\n subType: INTERACTION\n }),\n StoreMerge(INTERACTION_OPTIONS, options)\n );\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { Controller, UseBefore } from "@tsed/common";
2
+ import { useDecorators } from "@tsed/core";
3
+ import { INTERACTIONS } from "../constants";
4
+ import { OidcInteractionMiddleware } from "../middlewares/OidcInteractionMiddleware";
5
+ import { NoCache } from "./noCache";
6
+ export function Interactions(options) {
7
+ const { path } = options;
8
+ return useDecorators(Controller({ path, children: options.children, subType: INTERACTIONS }), NoCache(), UseBefore(OidcInteractionMiddleware));
9
+ }
10
+ //# sourceMappingURL=interactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactions.js","sourceRoot":"","sources":["../../../src/decorators/interactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAO,aAAa,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAC,yBAAyB,EAAC,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAOlC,MAAM,UAAU,YAAY,CAAC,OAA4B;IACvD,MAAM,EAAC,IAAI,EAAC,GAAG,OAAO,CAAC;IACvB,OAAO,aAAa,CAClB,UAAU,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAC,CAAC,EACrE,OAAO,EAAE,EACT,SAAS,CAAC,yBAAyB,CAAC,CACrC,CAAC;AACJ,CAAC","sourcesContent":["import {Controller, UseBefore} from \"@tsed/common\";\nimport {Type, useDecorators} from \"@tsed/core\";\nimport {INTERACTIONS} from \"../constants\";\nimport {OidcInteractionMiddleware} from \"../middlewares/OidcInteractionMiddleware\";\nimport {NoCache} from \"./noCache\";\n\nexport interface InteractionsOptions {\n path: string;\n children: Type<any>[];\n}\n\nexport function Interactions(options: InteractionsOptions): ClassDecorator {\n const {path} = options;\n return useDecorators(\n Controller({path, children: options.children, subType: INTERACTIONS}),\n NoCache(),\n UseBefore(OidcInteractionMiddleware)\n );\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { UseBefore } from "@tsed/common";
2
+ import { OidcNoCacheMiddleware } from "../middlewares/OidcNoCacheMiddleware";
3
+ export function NoCache() {
4
+ return UseBefore(OidcNoCacheMiddleware);
5
+ }
6
+ //# sourceMappingURL=noCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noCache.js","sourceRoot":"","sources":["../../../src/decorators/noCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,qBAAqB,EAAC,MAAM,sCAAsC,CAAC;AAE3E,MAAM,UAAU,OAAO;IACrB,OAAO,SAAS,CAAC,qBAAqB,CAAmB,CAAC;AAC5D,CAAC","sourcesContent":["import {UseBefore} from \"@tsed/common\";\nimport {OidcNoCacheMiddleware} from \"../middlewares/OidcNoCacheMiddleware\";\n\nexport function NoCache(): ClassDecorator {\n return UseBefore(OidcNoCacheMiddleware) as ClassDecorator;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { Context } from "@tsed/common";
2
+ import { useDecorators } from "@tsed/core";
3
+ import { INTERACTION_CONTEXT } from "../constants";
4
+ export function OidcCtx() {
5
+ return useDecorators(Context(INTERACTION_CONTEXT));
6
+ }
7
+ //# sourceMappingURL=oidcCtx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidcCtx.js","sourceRoot":"","sources":["../../../src/decorators/oidcCtx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAGjD,MAAM,UAAU,OAAO;IACrB,OAAO,aAAa,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import {Context} from \"@tsed/common\";\nimport {useDecorators} from \"@tsed/core\";\nimport {INTERACTION_CONTEXT} from \"../constants\";\nimport {OidcInteractionContext} from \"../services/OidcInteractionContext\";\n\nexport function OidcCtx(): ParameterDecorator {\n return useDecorators(Context(INTERACTION_CONTEXT));\n}\n\nexport type OidcCtx = OidcInteractionContext;\n"]}
@@ -0,0 +1,10 @@
1
+ import { Context } from "@tsed/common";
2
+ import { useDecorators } from "@tsed/core";
3
+ import { INTERACTION_SESSION } from "../constants";
4
+ /**
5
+ * @decorator
6
+ */
7
+ export function OidcSession(expression) {
8
+ return useDecorators(Context([INTERACTION_SESSION, expression].filter(Boolean).join(".")));
9
+ }
10
+ //# sourceMappingURL=oidcSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidcSession.js","sourceRoot":"","sources":["../../../src/decorators/oidcSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAEjD;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,UAAmB;IAC7C,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7F,CAAC","sourcesContent":["import {Context} from \"@tsed/common\";\nimport {useDecorators} from \"@tsed/core\";\nimport {Provider} from \"oidc-provider\";\nimport {INTERACTION_SESSION} from \"../constants\";\n\n/**\n * @decorator\n */\nexport function OidcSession(expression?: string): ParameterDecorator {\n return useDecorators(Context([INTERACTION_SESSION, expression].filter(Boolean).join(\".\")));\n}\n\nexport type OidcSession = InstanceType<Provider[\"Session\"]>;\n"]}
@@ -0,0 +1,7 @@
1
+ import { Context } from "@tsed/common";
2
+ import { useDecorators } from "@tsed/core";
3
+ import { INTERACTION_PARAMS } from "../constants";
4
+ export function Params(expression) {
5
+ return useDecorators(Context([INTERACTION_PARAMS, expression].filter(Boolean).join(".")));
6
+ }
7
+ //# sourceMappingURL=params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.js","sourceRoot":"","sources":["../../../src/decorators/params.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAEhD,MAAM,UAAU,MAAM,CAAC,UAAmB;IACxC,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["import {Context} from \"@tsed/common\";\nimport {useDecorators} from \"@tsed/core\";\nimport {INTERACTION_PARAMS} from \"../constants\";\n\nexport function Params(expression?: string): ParameterDecorator {\n return useDecorators(Context([INTERACTION_PARAMS, expression].filter(Boolean).join(\".\")));\n}\n\nexport type Params = Record<string, any>;\n"]}
@@ -0,0 +1,7 @@
1
+ import { Context } from "@tsed/common";
2
+ import { useDecorators } from "@tsed/core";
3
+ import { INTERACTION_PROMPT } from "../constants";
4
+ export function Prompt() {
5
+ return useDecorators(Context(INTERACTION_PROMPT));
6
+ }
7
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/decorators/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAEhD,MAAM,UAAU,MAAM;IACpB,OAAO,aAAa,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import {Context} from \"@tsed/common\";\nimport {useDecorators} from \"@tsed/core\";\nimport {PromptDetail as P} from \"oidc-provider\";\nimport {INTERACTION_PROMPT} from \"../constants\";\n\nexport function Prompt(): ParameterDecorator {\n return useDecorators(Context(INTERACTION_PROMPT));\n}\n\nexport type Prompt = P;\n"]}
@@ -0,0 +1,7 @@
1
+ import { Context } from "@tsed/common";
2
+ import { useDecorators } from "@tsed/core";
3
+ import { INTERACTION_UID } from "../constants";
4
+ export function Uid() {
5
+ return useDecorators(Context(INTERACTION_UID));
6
+ }
7
+ //# sourceMappingURL=uid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uid.js","sourceRoot":"","sources":["../../../src/decorators/uid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAE7C,MAAM,UAAU,GAAG;IACjB,OAAO,aAAa,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import {Context} from \"@tsed/common\";\nimport {useDecorators} from \"@tsed/core\";\nimport {INTERACTION_UID} from \"../constants\";\n\nexport function Uid(): ParameterDecorator {\n return useDecorators(Context(INTERACTION_UID));\n}\n\nexport type Uid = string;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OidcAccountsMethods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcAccountsMethods.js","sourceRoot":"","sources":["../../../src/domain/OidcAccountsMethods.ts"],"names":[],"mappings":"","sourcesContent":["import {PlatformContext} from \"@tsed/common\";\nimport {Provider, Account} from \"oidc-provider\";\n\nexport type AuthorizationCode = InstanceType<Provider[\"AuthorizationCode\"]>;\nexport type AccessToken = InstanceType<Provider[\"AccessToken\"]>;\nexport type DeviceCode = InstanceType<Provider[\"DeviceCode\"]>;\n\nexport interface OidcAccountsMethods {\n findAccount(\n id: string,\n token: AuthorizationCode | AccessToken | DeviceCode | undefined,\n ctx: PlatformContext\n ): Promise<Account | undefined>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OidcInteraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcInteraction.js","sourceRoot":"","sources":["../../../src/domain/OidcInteraction.ts"],"names":[],"mappings":"","sourcesContent":["import {Provider as OidcProvider} from \"oidc-provider\";\n\nexport type OidcInteraction = InstanceType<OidcProvider[\"Interaction\"]>;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OidcInteractionMethods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcInteractionMethods.js","sourceRoot":"","sources":["../../../src/domain/OidcInteractionMethods.ts"],"names":[],"mappings":"","sourcesContent":["export interface OidcInteractionMethods {\n $prompts?(...args: unknown[]): void | unknown | Promise<unknown>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OidcInteractionOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcInteractionOptions.js","sourceRoot":"","sources":["../../../src/domain/OidcInteractionOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface OidcInteractionOptions {\n name: string;\n requestable?: boolean;\n priority?: number;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OidcSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcSettings.js","sourceRoot":"","sources":["../../../src/domain/OidcSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JwksKeyParameters} from \"@tsed/jwks\";\nimport {Configuration} from \"oidc-provider\";\nimport {OidcAccountsMethods} from \"./OidcAccountsMethods\";\n\nexport interface OidcSettings extends Configuration {\n /**\n * Path on which the oidc-provider instance is mounted.\n */\n path?: string;\n /**\n * Issuer URI. By default Ts.ED create issuer with http://localhost:${httpPort}\n */\n issuer?: string;\n /**\n * Path to store jwks keys.\n */\n jwksPath?: string;\n /**\n * Generate jwks from given certificates\n */\n certificates?: JwksKeyParameters[];\n /**\n * Secure keys.\n */\n secureKey?: string[];\n /**\n * Enable proxy.\n */\n proxy?: boolean;\n /**\n * Injectable service to manage accounts.\n */\n Accounts?: Type<OidcAccountsMethods>;\n /**\n * Injectable service to manage clients.\n */\n // Clients?: Type<OidcClientsMethods>;\n}\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n oidc: OidcSettings;\n }\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export * from "./OidcAccountsMethods";
2
+ export * from "./OidcInteraction";
3
+ export * from "./OidcInteractionMethods";
4
+ export * from "./OidcInteractionOptions";
5
+ export * from "./OidcSettings";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/index.ts"],"names":[],"mappings":"AAEA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC","sourcesContent":["import {Provider, interactionPolicy} from \"oidc-provider\";\n\nexport * from \"./OidcAccountsMethods\";\nexport * from \"./OidcInteraction\";\nexport * from \"./OidcInteractionMethods\";\nexport * from \"./OidcInteractionOptions\";\nexport * from \"./OidcSettings\";\n\nexport type OidcClient = InstanceType<Provider[\"Client\"]>;\nexport type DefaultPolicy = interactionPolicy.DefaultPolicy;\n"]}
@@ -0,0 +1,12 @@
1
+ export * from "./decorators";
2
+ export * from "./domain";
3
+ export * from "./middlewares/OidcInteractionMiddleware";
4
+ export * from "./middlewares/OidcNoCacheMiddleware";
5
+ export * from "./middlewares/OidcSecureMiddleware";
6
+ export * from "./services/OidcAdapters";
7
+ export * from "./services/OidcInteractions";
8
+ export * from "./services/OidcInteractionContext";
9
+ export * from "./services/OidcJwks";
10
+ export * from "./services/OidcProvider";
11
+ export * from "./OidcModule";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,cAAc,UAAU,CAAC;AAEzB,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AAExC,cAAc,cAAc,CAAC","sourcesContent":["export * from \"./decorators\";\n\nexport * from \"./domain\";\n\nexport * from \"./middlewares/OidcInteractionMiddleware\";\nexport * from \"./middlewares/OidcNoCacheMiddleware\";\nexport * from \"./middlewares/OidcSecureMiddleware\";\n\nexport * from \"./services/OidcAdapters\";\nexport * from \"./services/OidcInteractions\";\nexport * from \"./services/OidcInteractionContext\";\nexport * from \"./services/OidcJwks\";\nexport * from \"./services/OidcProvider\";\n\nexport * from \"./OidcModule\";\n"]}
@@ -0,0 +1,38 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Context, Inject, InjectorService, Middleware } from "@tsed/common";
3
+ import { INTERACTION_CONTEXT, INTERACTION_DETAILS, INTERACTION_PARAMS, INTERACTION_GRANT_ID, INTERACTION_PROMPT, INTERACTION_SESSION, INTERACTION_UID } from "../constants";
4
+ import { OidcInteractionContext } from "../services/OidcInteractionContext";
5
+ import { OidcInteractions } from "../services/OidcInteractions";
6
+ let OidcInteractionMiddleware = class OidcInteractionMiddleware {
7
+ async use(context) {
8
+ const oidcInteraction = this.injector.invoke(OidcInteractionContext, context.container);
9
+ const interactionDetails = await oidcInteraction.interactionDetails();
10
+ const { uid, prompt, params, session, grantId } = interactionDetails;
11
+ context.set(INTERACTION_CONTEXT, oidcInteraction);
12
+ context.set(INTERACTION_DETAILS, interactionDetails);
13
+ context.set(INTERACTION_UID, uid);
14
+ context.set(INTERACTION_PROMPT, prompt);
15
+ context.set(INTERACTION_PARAMS, params);
16
+ context.set(INTERACTION_GRANT_ID, grantId);
17
+ context.set(INTERACTION_SESSION, session);
18
+ }
19
+ };
20
+ __decorate([
21
+ Inject(),
22
+ __metadata("design:type", OidcInteractions)
23
+ ], OidcInteractionMiddleware.prototype, "oidcInteractions", void 0);
24
+ __decorate([
25
+ Inject(),
26
+ __metadata("design:type", InjectorService)
27
+ ], OidcInteractionMiddleware.prototype, "injector", void 0);
28
+ __decorate([
29
+ __param(0, Context()),
30
+ __metadata("design:type", Function),
31
+ __metadata("design:paramtypes", [Object]),
32
+ __metadata("design:returntype", Promise)
33
+ ], OidcInteractionMiddleware.prototype, "use", null);
34
+ OidcInteractionMiddleware = __decorate([
35
+ Middleware()
36
+ ], OidcInteractionMiddleware);
37
+ export { OidcInteractionMiddleware };
38
+ //# sourceMappingURL=OidcInteractionMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcInteractionMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/OidcInteractionMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,sBAAsB,EAAC,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAG9D,IAAa,yBAAyB,GAAtC,MAAa,yBAAyB;IAOpC,KAAK,CAAC,GAAG,CAAY,OAAgB;QACnC,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAyB,sBAAsB,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAChH,MAAM,kBAAkB,GAAG,MAAM,eAAe,CAAC,kBAAkB,EAAE,CAAC;QACtE,MAAM,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAC,GAAG,kBAAyB,CAAC;QAE1E,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF,CAAA;AAlBC;IADC,MAAM,EAAE;8BACmB,gBAAgB;mEAAC;AAG7C;IADC,MAAM,EAAE;8BACW,eAAe;2DAAC;AAEpC;IAAW,WAAA,OAAO,EAAE,CAAA;;;;oDAYnB;AAnBU,yBAAyB;IADrC,UAAU,EAAE;GACA,yBAAyB,CAoBrC;SApBY,yBAAyB","sourcesContent":["import {Context, Inject, InjectorService, Middleware} from \"@tsed/common\";\nimport {\n INTERACTION_CONTEXT,\n INTERACTION_DETAILS,\n INTERACTION_PARAMS,\n INTERACTION_GRANT_ID,\n INTERACTION_PROMPT,\n INTERACTION_SESSION,\n INTERACTION_UID\n} from \"../constants\";\nimport {OidcInteractionContext} from \"../services/OidcInteractionContext\";\nimport {OidcInteractions} from \"../services/OidcInteractions\";\n\n@Middleware()\nexport class OidcInteractionMiddleware {\n @Inject()\n protected oidcInteractions: OidcInteractions;\n\n @Inject()\n protected injector: InjectorService;\n\n async use(@Context() context: Context) {\n const oidcInteraction = this.injector.invoke<OidcInteractionContext>(OidcInteractionContext, context.container);\n const interactionDetails = await oidcInteraction.interactionDetails();\n const {uid, prompt, params, session, grantId} = interactionDetails as any;\n\n context.set(INTERACTION_CONTEXT, oidcInteraction);\n context.set(INTERACTION_DETAILS, interactionDetails);\n context.set(INTERACTION_UID, uid);\n context.set(INTERACTION_PROMPT, prompt);\n context.set(INTERACTION_PARAMS, params);\n context.set(INTERACTION_GRANT_ID, grantId);\n context.set(INTERACTION_SESSION, session);\n }\n}\n"]}