@tsed/oidc-provider 6.87.2 → 6.90.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.
Files changed (201) hide show
  1. package/lib/{OidcModule.d.ts → cjs/OidcModule.d.ts} +0 -0
  2. package/lib/{OidcModule.js → cjs/OidcModule.js} +17 -17
  3. package/lib/cjs/OidcModule.js.map +1 -0
  4. package/lib/{constants → cjs/constants}/index.d.ts +0 -0
  5. package/lib/{constants → cjs/constants}/index.js +0 -0
  6. package/lib/cjs/constants/index.js.map +1 -0
  7. package/lib/{decorators → cjs/decorators}/grantId.d.ts +0 -0
  8. package/lib/{decorators → cjs/decorators}/grantId.js +1 -1
  9. package/lib/cjs/decorators/grantId.js.map +1 -0
  10. package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
  11. package/lib/cjs/decorators/index.js +13 -0
  12. package/lib/cjs/decorators/index.js.map +1 -0
  13. package/lib/{decorators → cjs/decorators}/interaction.d.ts +0 -0
  14. package/lib/{decorators → cjs/decorators}/interaction.js +2 -2
  15. package/lib/cjs/decorators/interaction.js.map +1 -0
  16. package/lib/{decorators → cjs/decorators}/interactions.d.ts +0 -0
  17. package/lib/{decorators → cjs/decorators}/interactions.js +1 -1
  18. package/lib/cjs/decorators/interactions.js.map +1 -0
  19. package/lib/{decorators → cjs/decorators}/noCache.d.ts +0 -0
  20. package/lib/{decorators → cjs/decorators}/noCache.js +1 -1
  21. package/lib/cjs/decorators/noCache.js.map +1 -0
  22. package/lib/{decorators → cjs/decorators}/oidcCtx.d.ts +0 -0
  23. package/lib/{decorators → cjs/decorators}/oidcCtx.js +1 -1
  24. package/lib/cjs/decorators/oidcCtx.js.map +1 -0
  25. package/lib/{decorators → cjs/decorators}/oidcSession.d.ts +0 -0
  26. package/lib/{decorators → cjs/decorators}/oidcSession.js +1 -1
  27. package/lib/cjs/decorators/oidcSession.js.map +1 -0
  28. package/lib/{decorators → cjs/decorators}/params.d.ts +0 -0
  29. package/lib/{decorators → cjs/decorators}/params.js +1 -1
  30. package/lib/cjs/decorators/params.js.map +1 -0
  31. package/lib/{decorators → cjs/decorators}/prompt.d.ts +0 -0
  32. package/lib/{decorators → cjs/decorators}/prompt.js +1 -1
  33. package/lib/cjs/decorators/prompt.js.map +1 -0
  34. package/lib/{decorators → cjs/decorators}/uid.d.ts +0 -0
  35. package/lib/{decorators → cjs/decorators}/uid.js +1 -1
  36. package/lib/cjs/decorators/uid.js.map +1 -0
  37. package/lib/{domain → cjs/domain}/OidcAccountsMethods.d.ts +0 -0
  38. package/lib/{domain → cjs/domain}/OidcAccountsMethods.js +0 -0
  39. package/lib/cjs/domain/OidcAccountsMethods.js.map +1 -0
  40. package/lib/{domain → cjs/domain}/OidcInteraction.d.ts +0 -0
  41. package/lib/{domain → cjs/domain}/OidcInteraction.js +0 -0
  42. package/lib/cjs/domain/OidcInteraction.js.map +1 -0
  43. package/lib/{domain → cjs/domain}/OidcInteractionMethods.d.ts +0 -0
  44. package/lib/{domain → cjs/domain}/OidcInteractionMethods.js +0 -0
  45. package/lib/cjs/domain/OidcInteractionMethods.js.map +1 -0
  46. package/lib/{domain → cjs/domain}/OidcInteractionOptions.d.ts +0 -0
  47. package/lib/{domain → cjs/domain}/OidcInteractionOptions.js +0 -0
  48. package/lib/cjs/domain/OidcInteractionOptions.js.map +1 -0
  49. package/lib/{domain → cjs/domain}/OidcSettings.d.ts +0 -0
  50. package/lib/{domain → cjs/domain}/OidcSettings.js +0 -0
  51. package/lib/cjs/domain/OidcSettings.js.map +1 -0
  52. package/lib/{domain → cjs/domain}/index.d.ts +0 -0
  53. package/lib/cjs/domain/index.js +9 -0
  54. package/lib/cjs/domain/index.js.map +1 -0
  55. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  56. package/lib/cjs/index.js +15 -0
  57. package/lib/cjs/index.js.map +1 -0
  58. package/lib/{middlewares → cjs/middlewares}/OidcInteractionMiddleware.d.ts +0 -0
  59. package/lib/{middlewares → cjs/middlewares}/OidcInteractionMiddleware.js +13 -13
  60. package/lib/cjs/middlewares/OidcInteractionMiddleware.js.map +1 -0
  61. package/lib/{middlewares → cjs/middlewares}/OidcNoCacheMiddleware.d.ts +0 -0
  62. package/lib/{middlewares → cjs/middlewares}/OidcNoCacheMiddleware.js +7 -7
  63. package/lib/cjs/middlewares/OidcNoCacheMiddleware.js.map +1 -0
  64. package/lib/{middlewares → cjs/middlewares}/OidcSecureMiddleware.d.ts +0 -0
  65. package/lib/{middlewares → cjs/middlewares}/OidcSecureMiddleware.js +8 -8
  66. package/lib/cjs/middlewares/OidcSecureMiddleware.js.map +1 -0
  67. package/lib/{services → cjs/services}/OidcAdapters.d.ts +0 -0
  68. package/lib/{services → cjs/services}/OidcAdapters.js +5 -5
  69. package/lib/cjs/services/OidcAdapters.js.map +1 -0
  70. package/lib/{services → cjs/services}/OidcInteractionContext.d.ts +0 -0
  71. package/lib/{services → cjs/services}/OidcInteractionContext.js +16 -16
  72. package/lib/cjs/services/OidcInteractionContext.js.map +1 -0
  73. package/lib/{services → cjs/services}/OidcInteractions.d.ts +0 -0
  74. package/lib/{services → cjs/services}/OidcInteractions.js +11 -11
  75. package/lib/cjs/services/OidcInteractions.js.map +1 -0
  76. package/lib/{services → cjs/services}/OidcJwks.d.ts +0 -0
  77. package/lib/{services → cjs/services}/OidcJwks.js +9 -9
  78. package/lib/cjs/services/OidcJwks.js.map +1 -0
  79. package/lib/{services → cjs/services}/OidcProvider.d.ts +0 -0
  80. package/lib/{services → cjs/services}/OidcProvider.js +39 -39
  81. package/lib/cjs/services/OidcProvider.js.map +1 -0
  82. package/lib/{utils → cjs/utils}/debug.d.ts +0 -0
  83. package/lib/{utils → cjs/utils}/debug.js +3 -3
  84. package/lib/cjs/utils/debug.js.map +1 -0
  85. package/lib/esm/OidcModule.js +87 -0
  86. package/lib/esm/OidcModule.js.map +1 -0
  87. package/lib/esm/constants/index.js +11 -0
  88. package/lib/esm/constants/index.js.map +1 -0
  89. package/lib/esm/decorators/grantId.js +7 -0
  90. package/lib/esm/decorators/grantId.js.map +1 -0
  91. package/lib/esm/decorators/index.js +10 -0
  92. package/lib/esm/decorators/index.js.map +1 -0
  93. package/lib/esm/decorators/interaction.js +13 -0
  94. package/lib/esm/decorators/interaction.js.map +1 -0
  95. package/lib/esm/decorators/interactions.js +10 -0
  96. package/lib/esm/decorators/interactions.js.map +1 -0
  97. package/lib/esm/decorators/noCache.js +6 -0
  98. package/lib/esm/decorators/noCache.js.map +1 -0
  99. package/lib/esm/decorators/oidcCtx.js +7 -0
  100. package/lib/esm/decorators/oidcCtx.js.map +1 -0
  101. package/lib/esm/decorators/oidcSession.js +10 -0
  102. package/lib/esm/decorators/oidcSession.js.map +1 -0
  103. package/lib/esm/decorators/params.js +7 -0
  104. package/lib/esm/decorators/params.js.map +1 -0
  105. package/lib/esm/decorators/prompt.js +7 -0
  106. package/lib/esm/decorators/prompt.js.map +1 -0
  107. package/lib/esm/decorators/uid.js +7 -0
  108. package/lib/esm/decorators/uid.js.map +1 -0
  109. package/lib/esm/domain/OidcAccountsMethods.js +2 -0
  110. package/lib/esm/domain/OidcAccountsMethods.js.map +1 -0
  111. package/lib/esm/domain/OidcInteraction.js +2 -0
  112. package/lib/esm/domain/OidcInteraction.js.map +1 -0
  113. package/lib/esm/domain/OidcInteractionMethods.js +2 -0
  114. package/lib/esm/domain/OidcInteractionMethods.js.map +1 -0
  115. package/lib/esm/domain/OidcInteractionOptions.js +2 -0
  116. package/lib/esm/domain/OidcInteractionOptions.js.map +1 -0
  117. package/lib/esm/domain/OidcSettings.js +2 -0
  118. package/lib/esm/domain/OidcSettings.js.map +1 -0
  119. package/lib/esm/domain/index.js +6 -0
  120. package/lib/esm/domain/index.js.map +1 -0
  121. package/lib/esm/index.js +12 -0
  122. package/lib/esm/index.js.map +1 -0
  123. package/lib/esm/middlewares/OidcInteractionMiddleware.js +38 -0
  124. package/lib/esm/middlewares/OidcInteractionMiddleware.js.map +1 -0
  125. package/lib/esm/middlewares/OidcNoCacheMiddleware.js +19 -0
  126. package/lib/esm/middlewares/OidcNoCacheMiddleware.js.map +1 -0
  127. package/lib/esm/middlewares/OidcSecureMiddleware.js +35 -0
  128. package/lib/esm/middlewares/OidcSecureMiddleware.js.map +1 -0
  129. package/lib/esm/services/OidcAdapters.js +54 -0
  130. package/lib/esm/services/OidcAdapters.js.map +1 -0
  131. package/lib/esm/services/OidcInteractionContext.js +110 -0
  132. package/lib/esm/services/OidcInteractionContext.js.map +1 -0
  133. package/lib/esm/services/OidcInteractions.js +61 -0
  134. package/lib/esm/services/OidcInteractions.js.map +1 -0
  135. package/lib/esm/services/OidcJwks.js +28 -0
  136. package/lib/esm/services/OidcJwks.js.map +1 -0
  137. package/lib/esm/services/OidcProvider.js +173 -0
  138. package/lib/esm/services/OidcProvider.js.map +1 -0
  139. package/lib/esm/utils/debug.js +20 -0
  140. package/lib/esm/utils/debug.js.map +1 -0
  141. package/lib/types/OidcModule.d.ts +14 -0
  142. package/lib/types/constants/index.d.ts +10 -0
  143. package/lib/types/decorators/grantId.d.ts +2 -0
  144. package/lib/types/decorators/index.d.ts +9 -0
  145. package/lib/types/decorators/interaction.d.ts +5 -0
  146. package/lib/types/decorators/interactions.d.ts +6 -0
  147. package/lib/types/decorators/noCache.d.ts +1 -0
  148. package/lib/types/decorators/oidcCtx.d.ts +3 -0
  149. package/lib/types/decorators/oidcSession.d.ts +6 -0
  150. package/lib/types/decorators/params.d.ts +2 -0
  151. package/lib/types/decorators/prompt.d.ts +3 -0
  152. package/lib/types/decorators/uid.d.ts +2 -0
  153. package/lib/types/domain/OidcAccountsMethods.d.ts +8 -0
  154. package/lib/types/domain/OidcInteraction.d.ts +2 -0
  155. package/lib/types/domain/OidcInteractionMethods.d.ts +3 -0
  156. package/lib/types/domain/OidcInteractionOptions.d.ts +5 -0
  157. package/lib/types/domain/OidcSettings.d.ts +41 -0
  158. package/lib/types/domain/index.d.ts +8 -0
  159. package/lib/types/index.d.ts +11 -0
  160. package/lib/types/middlewares/OidcInteractionMiddleware.d.ts +7 -0
  161. package/lib/types/middlewares/OidcNoCacheMiddleware.d.ts +4 -0
  162. package/lib/types/middlewares/OidcSecureMiddleware.d.ts +4 -0
  163. package/lib/types/services/OidcAdapters.d.ts +6 -0
  164. package/lib/types/services/OidcInteractionContext.d.ts +33 -0
  165. package/lib/types/services/OidcInteractions.d.ts +14 -0
  166. package/lib/types/services/OidcJwks.d.ts +8 -0
  167. package/lib/types/services/OidcProvider.d.ts +33 -0
  168. package/lib/types/utils/debug.d.ts +1 -0
  169. package/package.json +25 -17
  170. package/tsconfig.compile.esm.json +23 -0
  171. package/lib/OidcModule.js.map +0 -1
  172. package/lib/constants/index.js.map +0 -1
  173. package/lib/decorators/grantId.js.map +0 -1
  174. package/lib/decorators/index.js +0 -13
  175. package/lib/decorators/index.js.map +0 -1
  176. package/lib/decorators/interaction.js.map +0 -1
  177. package/lib/decorators/interactions.js.map +0 -1
  178. package/lib/decorators/noCache.js.map +0 -1
  179. package/lib/decorators/oidcCtx.js.map +0 -1
  180. package/lib/decorators/oidcSession.js.map +0 -1
  181. package/lib/decorators/params.js.map +0 -1
  182. package/lib/decorators/prompt.js.map +0 -1
  183. package/lib/decorators/uid.js.map +0 -1
  184. package/lib/domain/OidcAccountsMethods.js.map +0 -1
  185. package/lib/domain/OidcInteraction.js.map +0 -1
  186. package/lib/domain/OidcInteractionMethods.js.map +0 -1
  187. package/lib/domain/OidcInteractionOptions.js.map +0 -1
  188. package/lib/domain/OidcSettings.js.map +0 -1
  189. package/lib/domain/index.js +0 -9
  190. package/lib/domain/index.js.map +0 -1
  191. package/lib/index.js +0 -15
  192. package/lib/index.js.map +0 -1
  193. package/lib/middlewares/OidcInteractionMiddleware.js.map +0 -1
  194. package/lib/middlewares/OidcNoCacheMiddleware.js.map +0 -1
  195. package/lib/middlewares/OidcSecureMiddleware.js.map +0 -1
  196. package/lib/services/OidcAdapters.js.map +0 -1
  197. package/lib/services/OidcInteractionContext.js.map +0 -1
  198. package/lib/services/OidcInteractions.js.map +0 -1
  199. package/lib/services/OidcJwks.js.map +0 -1
  200. package/lib/services/OidcProvider.js.map +0 -1
  201. package/lib/utils/debug.js.map +0 -1
@@ -0,0 +1,10 @@
1
+ export declare const INTERACTION_CONTEXT = "interactionContext";
2
+ export declare const INTERACTION_PARAMS = "interactionParams";
3
+ export declare const INTERACTION_GRANT_ID = "interactionGrantId";
4
+ export declare const INTERACTION_PROMPT = "interactionPrompt";
5
+ export declare const INTERACTION_UID = "interactionUid";
6
+ export declare const INTERACTION_SESSION = "interactionSession";
7
+ export declare const INTERACTION_DETAILS = "interactionDetails";
8
+ export declare const INTERACTION_OPTIONS = "interactionOptions";
9
+ export declare const INTERACTION = "interaction";
10
+ export declare const INTERACTIONS = "interactions";
@@ -0,0 +1,2 @@
1
+ export declare function GrantId(): ParameterDecorator;
2
+ export declare type GrantId = string;
@@ -0,0 +1,9 @@
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";
@@ -0,0 +1,5 @@
1
+ import { OidcInteractionOptions } from "../domain";
2
+ /**
3
+ * @Oidc
4
+ */
5
+ export declare function Interaction(options: OidcInteractionOptions): ClassDecorator;
@@ -0,0 +1,6 @@
1
+ import { Type } from "@tsed/core";
2
+ export interface InteractionsOptions {
3
+ path: string;
4
+ children: Type<any>[];
5
+ }
6
+ export declare function Interactions(options: InteractionsOptions): ClassDecorator;
@@ -0,0 +1 @@
1
+ export declare function NoCache(): ClassDecorator;
@@ -0,0 +1,3 @@
1
+ import { OidcInteractionContext } from "../services/OidcInteractionContext";
2
+ export declare function OidcCtx(): ParameterDecorator;
3
+ export declare type OidcCtx = OidcInteractionContext;
@@ -0,0 +1,6 @@
1
+ import { Provider } from "oidc-provider";
2
+ /**
3
+ * @decorator
4
+ */
5
+ export declare function OidcSession(expression?: string): ParameterDecorator;
6
+ export declare type OidcSession = InstanceType<Provider["Session"]>;
@@ -0,0 +1,2 @@
1
+ export declare function Params(expression?: string): ParameterDecorator;
2
+ export declare type Params = Record<string, any>;
@@ -0,0 +1,3 @@
1
+ import { PromptDetail as P } from "oidc-provider";
2
+ export declare function Prompt(): ParameterDecorator;
3
+ export declare type Prompt = P;
@@ -0,0 +1,2 @@
1
+ export declare function Uid(): ParameterDecorator;
2
+ export declare type Uid = string;
@@ -0,0 +1,8 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ import { Provider, Account } from "oidc-provider";
3
+ export declare type AuthorizationCode = InstanceType<Provider["AuthorizationCode"]>;
4
+ export declare type AccessToken = InstanceType<Provider["AccessToken"]>;
5
+ export declare type DeviceCode = InstanceType<Provider["DeviceCode"]>;
6
+ export interface OidcAccountsMethods {
7
+ findAccount(id: string, token: AuthorizationCode | AccessToken | DeviceCode | undefined, ctx: PlatformContext): Promise<Account | undefined>;
8
+ }
@@ -0,0 +1,2 @@
1
+ import { Provider as OidcProvider } from "oidc-provider";
2
+ export declare type OidcInteraction = InstanceType<OidcProvider["Interaction"]>;
@@ -0,0 +1,3 @@
1
+ export interface OidcInteractionMethods {
2
+ $prompts?(...args: unknown[]): void | unknown | Promise<unknown>;
3
+ }
@@ -0,0 +1,5 @@
1
+ export interface OidcInteractionOptions {
2
+ name: string;
3
+ requestable?: boolean;
4
+ priority?: number;
5
+ }
@@ -0,0 +1,41 @@
1
+ import { Type } from "@tsed/core";
2
+ import { JwksKeyParameters } from "@tsed/jwks";
3
+ import { Configuration } from "oidc-provider";
4
+ import { OidcAccountsMethods } from "./OidcAccountsMethods";
5
+ export interface OidcSettings extends Configuration {
6
+ /**
7
+ * Path on which the oidc-provider instance is mounted.
8
+ */
9
+ path?: string;
10
+ /**
11
+ * Issuer URI. By default Ts.ED create issuer with http://localhost:${httpPort}
12
+ */
13
+ issuer?: string;
14
+ /**
15
+ * Path to store jwks keys.
16
+ */
17
+ jwksPath?: string;
18
+ /**
19
+ * Generate jwks from given certificates
20
+ */
21
+ certificates?: JwksKeyParameters[];
22
+ /**
23
+ * Secure keys.
24
+ */
25
+ secureKey?: string[];
26
+ /**
27
+ * Enable proxy.
28
+ */
29
+ proxy?: boolean;
30
+ /**
31
+ * Injectable service to manage accounts.
32
+ */
33
+ Accounts?: Type<OidcAccountsMethods>;
34
+ }
35
+ declare global {
36
+ namespace TsED {
37
+ interface Configuration {
38
+ oidc: OidcSettings;
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,8 @@
1
+ import { Provider, interactionPolicy } from "oidc-provider";
2
+ export * from "./OidcAccountsMethods";
3
+ export * from "./OidcInteraction";
4
+ export * from "./OidcInteractionMethods";
5
+ export * from "./OidcInteractionOptions";
6
+ export * from "./OidcSettings";
7
+ export declare type OidcClient = InstanceType<Provider["Client"]>;
8
+ export declare type DefaultPolicy = interactionPolicy.DefaultPolicy;
@@ -0,0 +1,11 @@
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";
@@ -0,0 +1,7 @@
1
+ import { Context, InjectorService } from "@tsed/common";
2
+ import { OidcInteractions } from "../services/OidcInteractions";
3
+ export declare class OidcInteractionMiddleware {
4
+ protected oidcInteractions: OidcInteractions;
5
+ protected injector: InjectorService;
6
+ use(context: Context): Promise<void>;
7
+ }
@@ -0,0 +1,4 @@
1
+ import { Context, MiddlewareMethods } from "@tsed/common";
2
+ export declare class OidcNoCacheMiddleware implements MiddlewareMethods {
3
+ use(ctx: Context): void;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Context, MiddlewareMethods } from "@tsed/common";
2
+ export declare class OidcSecureMiddleware implements MiddlewareMethods {
3
+ use(ctx: Context): void;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { Adapters } from "@tsed/adapters";
2
+ import { AdapterConstructor } from "oidc-provider";
3
+ export declare class OidcAdapters {
4
+ protected adapters: Adapters;
5
+ createAdapterClass(): AdapterConstructor;
6
+ }
@@ -0,0 +1,33 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ import { Env } from "@tsed/core";
3
+ import { Account, InteractionResults, PromptDetail, Provider } from "oidc-provider";
4
+ import { OidcSession } from "../decorators";
5
+ import { OidcClient, OidcInteraction } from "../domain";
6
+ import { OidcInteractions } from "./OidcInteractions";
7
+ import { OidcProvider } from "./OidcProvider";
8
+ export declare class OidcInteractionContext {
9
+ env: Env;
10
+ protected oidcProvider: OidcProvider;
11
+ protected oidcInteractions: OidcInteractions;
12
+ protected context: PlatformContext;
13
+ protected raw: OidcInteraction;
14
+ get session(): OidcSession | undefined;
15
+ get prompt(): PromptDetail;
16
+ get params(): Record<string, any>;
17
+ get uid(): string;
18
+ get grantId(): string;
19
+ runInteraction(name?: string): Promise<void>;
20
+ interactionDetails(): Promise<OidcInteraction>;
21
+ interactionFinished(result: InteractionResults, options?: {
22
+ mergeWithLastSubmission?: boolean;
23
+ }): Promise<void>;
24
+ interactionResult(result: InteractionResults, options?: {
25
+ mergeWithLastSubmission?: boolean;
26
+ }): Promise<string>;
27
+ render(view: string, result: any): Promise<string>;
28
+ save(ttl: number): Promise<string>;
29
+ findClient(clientId?: string): Promise<OidcClient | undefined>;
30
+ findAccount(sub?: string, token?: any): Promise<Account | undefined>;
31
+ getGrant(): Promise<InstanceType<Provider["Grant"]>>;
32
+ debug(obj?: any): any;
33
+ }
@@ -0,0 +1,14 @@
1
+ import { PlatformContext, Provider } from "@tsed/common";
2
+ import { Env } from "@tsed/core";
3
+ import { InjectorService } from "@tsed/di";
4
+ import { OidcSettings } from "../domain";
5
+ export declare class OidcInteractions {
6
+ injector: InjectorService;
7
+ env: Env;
8
+ oidcSettings: OidcSettings;
9
+ protected interactions: Map<string, Provider>;
10
+ $onInit(): void;
11
+ getInteractions(): Provider[];
12
+ getInteractionProvider(name: string): Provider | undefined;
13
+ getInteractionHandler(name: string): ((ctx: PlatformContext) => any) | undefined;
14
+ }
@@ -0,0 +1,8 @@
1
+ import { JwksKeyParameters } from "@tsed/jwks";
2
+ export declare class OidcJwks {
3
+ jwksPath: string;
4
+ certificates?: JwksKeyParameters[];
5
+ keys: string;
6
+ $onInit(): Promise<any>;
7
+ getJwks(): any;
8
+ }
@@ -0,0 +1,33 @@
1
+ import { Env } from "@tsed/core";
2
+ import { InjectorService } from "@tsed/di";
3
+ import { Provider as OIDCProvider, Configuration } from "oidc-provider";
4
+ import { OidcSettings } from "../domain";
5
+ import { OidcAdapters } from "./OidcAdapters";
6
+ import { OidcInteractions } from "./OidcInteractions";
7
+ import { OidcJwks } from "./OidcJwks";
8
+ import { PlatformApplication } from "@tsed/common";
9
+ export declare class OidcProvider {
10
+ raw: OIDCProvider;
11
+ protected env: Env;
12
+ protected httpPort: number | string;
13
+ protected httpsPort: number | string;
14
+ protected issuer: string;
15
+ protected oidc: OidcSettings;
16
+ protected platformName: string;
17
+ protected oidcJwks: OidcJwks;
18
+ protected oidcInteractions: OidcInteractions;
19
+ protected adapters: OidcAdapters;
20
+ protected injector: InjectorService;
21
+ protected app: PlatformApplication;
22
+ hasConfiguration(): boolean;
23
+ getConfiguration(): Promise<Configuration>;
24
+ getIssuer(): string;
25
+ get(): OIDCProvider;
26
+ /**
27
+ * Create a new instance of OidcProvider
28
+ */
29
+ create(): Promise<void | OIDCProvider>;
30
+ private getInteractionsUrl;
31
+ private allowHttpLocalhost;
32
+ private getPolicy;
33
+ }
@@ -0,0 +1 @@
1
+ export declare const debug: (obj: any) => string;
package/package.json CHANGED
@@ -1,18 +1,26 @@
1
1
  {
2
2
  "name": "@tsed/oidc-provider",
3
- "version": "6.87.2",
3
+ "version": "6.90.0",
4
4
  "description": "OIDC provider package for Ts.ED framework",
5
- "source": "./src/index.ts",
6
- "main": "./lib/index.js",
7
- "typings": "./lib/index.d.ts",
8
5
  "private": false,
6
+ "source": "./src/index.ts",
7
+ "main": "./lib/cjs/index.js",
8
+ "typings": "./lib/types/index.d.ts",
9
+ "exports": {
10
+ "types": "./lib/types/index.d.ts",
11
+ "import": "./lib/esm/index.js",
12
+ "require": "./lib/cjs/index.js",
13
+ "default": "./lib/esm/index.js"
14
+ },
9
15
  "scripts": {
10
- "build": "tsc --build tsconfig.compile.json",
16
+ "build": "yarn run build:esm && yarn run build:cjs",
17
+ "build:cjs": "tsc --build tsconfig.compile.json",
18
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
11
19
  "start": "ts-node -r tsconfig-paths/register test/app/index.ts",
12
20
  "test": "cross-env NODE_ENV=test nyc mocha"
13
21
  },
14
22
  "dependencies": {
15
- "@tsed/adapters": "6.87.2",
23
+ "@tsed/adapters": "6.90.0",
16
24
  "express-urlrewrite": "^1.4.0",
17
25
  "jose2": "npm:jose@^2.0.4",
18
26
  "koa-mount": "^4.0.0",
@@ -22,24 +30,24 @@
22
30
  "uuid": "8.3.2"
23
31
  },
24
32
  "devDependencies": {
25
- "@tsed/common": "6.87.2",
26
- "@tsed/core": "6.87.2",
27
- "@tsed/di": "6.87.2",
28
- "@tsed/exceptions": "6.87.2",
33
+ "@tsed/common": "6.90.0",
34
+ "@tsed/core": "6.90.0",
35
+ "@tsed/di": "6.90.0",
36
+ "@tsed/exceptions": "6.90.0",
29
37
  "@types/lowdb": "1.0.9",
30
38
  "@types/oidc-provider": "^7.1.1",
31
39
  "@types/uuid": "8.3.0",
32
40
  "oidc-provider": "7.10.1"
33
41
  },
34
42
  "peerDependencies": {
35
- "@tsed/common": "^6.87.2",
36
- "@tsed/core": "^6.87.2",
37
- "@tsed/di": "^6.87.2",
38
- "@tsed/exceptions": "^6.87.2",
39
- "@tsed/json-mapper": "^6.87.2",
43
+ "@tsed/common": "^6.90.0",
44
+ "@tsed/core": "^6.90.0",
45
+ "@tsed/di": "^6.90.0",
46
+ "@tsed/exceptions": "^6.90.0",
47
+ "@tsed/json-mapper": "^6.90.0",
40
48
  "@tsed/logger": ">=6.0.0",
41
- "@tsed/openspec": "^6.87.2",
42
- "@tsed/schema": "^6.87.2",
49
+ "@tsed/openspec": "^6.90.0",
50
+ "@tsed/schema": "^6.90.0",
43
51
  "oidc-provider": ">=7.3.0"
44
52
  },
45
53
  "repository": "https://github.com/tsedio/tsed",
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "./tsconfig.compile.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types"
10
+ },
11
+ "exclude": [
12
+ "node_modules",
13
+ "test",
14
+ "lib",
15
+ "benchmark",
16
+ "coverage",
17
+ "spec",
18
+ "**/*.benchmark.ts",
19
+ "**/*.spec.ts",
20
+ "keys",
21
+ "jest.config.js"
22
+ ]
23
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcModule.js","sourceRoot":"","sources":["../src/OidcModule.ts"],"names":[],"mappings":";;;;AAAA,yCAA0E;AAC1E,iCAA0C;AAC1C,0DAAqD;AACrD,kDAA6C;AAC7C,0DAAqD;AAKrD,IAAa,UAAU,GAAvB,MAAa,UAAU;IAgBrB,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,EAAE;YACxC,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;SAClC;IACH,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,IAAI,CAAC,QAAQ,KAAK,GAAG,EAAE;YACzB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;SAC3C;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,IAAI,IAAI,CAAC,YAAY,CAAC,g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BAAM,IAAI,QAAQ,EAAE;gBACnB,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;gBAC7C,UAAU,CAAC,EAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,EAAC,CAAC,CAAC;aACzC;SACF;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;AAzEC;IADC,eAAM,EAAE;sCACJ,4BAAmB;uCAAC;AAGzB;IADC,aAAQ,CAAC,eAAe,CAAC;;gDACL;AAGrB;IADC,aAAQ,CAAC,WAAW,EAAE,GAAG,CAAC;;4CACV;AAGjB;IADC,eAAM,EAAE;sCACK,2BAAY;gDAAC;AAG3B;IADC,eAAM,EAAE;sCACC,wBAAe;4CAAC;AAdf,UAAU;IAHtB,WAAM,CAAC;QACN,OAAO,EAAE,CAAC,2BAAY,EAAE,2BAAY,EAAE,mBAAQ,CAAC;KAChD,CAAC;GACW,UAAU,CA2EtB;AA3EY,gCAAU","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()) {\n const {injector} = this;\n const {httpsPort, httpPort} = injector.settings;\n\n const displayLog = (host: any) => {\n const url = [`${host.protocol}://${host.address}`, typeof host.port === \"number\" && host.port].filter(Boolean).join(\":\");\n\n injector.logger.info(`WellKnown is available on ${url}/.well-known/openid-configuration`);\n };\n\n /* istanbul ignore next */\n if (httpsPort) {\n const host = injector.settings.getHttpsPort();\n displayLog({protocol: \"https\", ...host});\n } else if (httpPort) {\n const host = injector.settings.getHttpPort();\n displayLog({protocol: \"http\", ...host});\n }\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAC3C,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AACzC,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAC5C,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AACzC,QAAA,eAAe,GAAG,gBAAgB,CAAC;AACnC,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAC3C,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAC3C,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAC3C,QAAA,WAAW,GAAG,aAAa,CAAC;AAC5B,QAAA,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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"grantId.js","sourceRoot":"","sources":["../../src/decorators/grantId.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qCAAyC;AACzC,4CAAsE;AAEtE,SAAgB,OAAO;IACrB,OAAO,oBAAa,CAAC,gBAAO,CAAC,gCAAoB,CAAC,CAAC,CAAC;AACtD,CAAC;AAFD,0BAEC","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"]}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./interactions"), exports);
5
- tslib_1.__exportStar(require("./interaction"), exports);
6
- tslib_1.__exportStar(require("./noCache"), exports);
7
- tslib_1.__exportStar(require("./oidcCtx"), exports);
8
- tslib_1.__exportStar(require("./oidcSession"), exports);
9
- tslib_1.__exportStar(require("./params"), exports);
10
- tslib_1.__exportStar(require("./prompt"), exports);
11
- tslib_1.__exportStar(require("./uid"), exports);
12
- tslib_1.__exportStar(require("./grantId"), exports);
13
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,wDAA8B;AAC9B,oDAA0B;AAC1B,oDAA0B;AAC1B,wDAA8B;AAC9B,mDAAyB;AACzB,mDAAyB;AACzB,gDAAsB;AACtB,oDAA0B","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../src/decorators/interaction.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AACxC,qCAAqD;AACrD,4CAA8D;AAG9D;;GAEG;AACH,SAAgB,WAAW,CAAC,OAA+B;IACzD,OAAO,oBAAa,CAClB,mBAAU,CAAC;QACT,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,uBAAW;KACrB,CAAC,EACF,iBAAU,CAAC,+BAAmB,EAAE,OAAO,CAAC,CACzC,CAAC;AACJ,CAAC;AARD,kCAQC","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactions.js","sourceRoot":"","sources":["../../src/decorators/interactions.ts"],"names":[],"mappings":";;;AAAA,yCAAmD;AACnD,qCAA+C;AAC/C,4CAA0C;AAC1C,wFAAmF;AACnF,uCAAkC;AAOlC,SAAgB,YAAY,CAAC,OAA4B;IACvD,MAAM,EAAC,IAAI,EAAC,GAAG,OAAO,CAAC;IACvB,OAAO,oBAAa,CAClB,mBAAU,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,wBAAY,EAAC,CAAC,EACrE,iBAAO,EAAE,EACT,kBAAS,CAAC,qDAAyB,CAAC,CACrC,CAAC;AACJ,CAAC;AAPD,oCAOC","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"noCache.js","sourceRoot":"","sources":["../../src/decorators/noCache.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AACvC,gFAA2E;AAE3E,SAAgB,OAAO;IACrB,OAAO,kBAAS,CAAC,6CAAqB,CAAmB,CAAC;AAC5D,CAAC;AAFD,0BAEC","sourcesContent":["import {UseBefore} from \"@tsed/common\";\nimport {OidcNoCacheMiddleware} from \"../middlewares/OidcNoCacheMiddleware\";\n\nexport function NoCache(): ClassDecorator {\n return UseBefore(OidcNoCacheMiddleware) as ClassDecorator;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"oidcCtx.js","sourceRoot":"","sources":["../../src/decorators/oidcCtx.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qCAAyC;AACzC,4CAAiD;AAGjD,SAAgB,OAAO;IACrB,OAAO,oBAAa,CAAC,gBAAO,CAAC,+BAAmB,CAAC,CAAC,CAAC;AACrD,CAAC;AAFD,0BAEC","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"oidcSession.js","sourceRoot":"","sources":["../../src/decorators/oidcSession.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qCAAyC;AAEzC,4CAAiD;AAEjD;;GAEG;AACH,SAAgB,WAAW,CAAC,UAAmB;IAC7C,OAAO,oBAAa,CAAC,gBAAO,CAAC,CAAC,+BAAmB,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7F,CAAC;AAFD,kCAEC","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"params.js","sourceRoot":"","sources":["../../src/decorators/params.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qCAAyC;AACzC,4CAAgD;AAEhD,SAAgB,MAAM,CAAC,UAAmB;IACxC,OAAO,oBAAa,CAAC,gBAAO,CAAC,CAAC,8BAAkB,EAAE,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5F,CAAC;AAFD,wBAEC","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/decorators/prompt.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qCAAyC;AAEzC,4CAAgD;AAEhD,SAAgB,MAAM;IACpB,OAAO,oBAAa,CAAC,gBAAO,CAAC,8BAAkB,CAAC,CAAC,CAAC;AACpD,CAAC;AAFD,wBAEC","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"uid.js","sourceRoot":"","sources":["../../src/decorators/uid.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qCAAyC;AACzC,4CAA6C;AAE7C,SAAgB,GAAG;IACjB,OAAO,oBAAa,CAAC,gBAAO,CAAC,2BAAe,CAAC,CAAC,CAAC;AACjD,CAAC;AAFD,kBAEC","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"]}
@@ -1 +0,0 @@
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"]}
@@ -1 +0,0 @@
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"]}
@@ -1 +0,0 @@
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"]}
@@ -1 +0,0 @@
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"]}
@@ -1 +0,0 @@
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"]}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./OidcAccountsMethods"), exports);
5
- tslib_1.__exportStar(require("./OidcInteraction"), exports);
6
- tslib_1.__exportStar(require("./OidcInteractionMethods"), exports);
7
- tslib_1.__exportStar(require("./OidcInteractionOptions"), exports);
8
- tslib_1.__exportStar(require("./OidcSettings"), exports);
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":";;;AAEA,gEAAsC;AACtC,4DAAkC;AAClC,mEAAyC;AACzC,mEAAyC;AACzC,yDAA+B","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"]}
package/lib/index.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./decorators"), exports);
5
- tslib_1.__exportStar(require("./domain"), exports);
6
- tslib_1.__exportStar(require("./middlewares/OidcInteractionMiddleware"), exports);
7
- tslib_1.__exportStar(require("./middlewares/OidcNoCacheMiddleware"), exports);
8
- tslib_1.__exportStar(require("./middlewares/OidcSecureMiddleware"), exports);
9
- tslib_1.__exportStar(require("./services/OidcAdapters"), exports);
10
- tslib_1.__exportStar(require("./services/OidcInteractions"), exports);
11
- tslib_1.__exportStar(require("./services/OidcInteractionContext"), exports);
12
- tslib_1.__exportStar(require("./services/OidcJwks"), exports);
13
- tslib_1.__exportStar(require("./services/OidcProvider"), exports);
14
- tslib_1.__exportStar(require("./OidcModule"), exports);
15
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAE7B,mDAAyB;AAEzB,kFAAwD;AACxD,8EAAoD;AACpD,6EAAmD;AAEnD,kEAAwC;AACxC,sEAA4C;AAC5C,4EAAkD;AAClD,8DAAoC;AACpC,kEAAwC;AAExC,uDAA6B","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcInteractionMiddleware.js","sourceRoot":"","sources":["../../src/middlewares/OidcInteractionMiddleware.ts"],"names":[],"mappings":";;;;AAAA,yCAA0E;AAC1E,4CAQsB;AACtB,+EAA0E;AAC1E,mEAA8D;AAG9D,IAAa,yBAAyB,GAAtC,MAAa,yBAAyB;IAOpC,KAAK,CAAC,GAAG,CAAY,OAAgB;QACnC,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAyB,+CAAsB,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,+BAAmB,EAAE,eAAe,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,+BAAmB,EAAE,kBAAkB,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,2BAAe,EAAE,GAAG,CAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,8BAAkB,EAAE,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,8BAAkB,EAAE,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,gCAAoB,EAAE,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,+BAAmB,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF,CAAA;AAlBC;IADC,eAAM,EAAE;sCACmB,mCAAgB;mEAAC;AAG7C;IADC,eAAM,EAAE;sCACW,wBAAe;2DAAC;AAEpC;IAAW,mBAAA,gBAAO,EAAE,CAAA;;;;oDAYnB;AAnBU,yBAAyB;IADrC,mBAAU,EAAE;GACA,yBAAyB,CAoBrC;AApBY,8DAAyB","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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcNoCacheMiddleware.js","sourceRoot":"","sources":["../../src/middlewares/OidcNoCacheMiddleware.ts"],"names":[],"mappings":";;;;AAAA,yCAAoE;AAGpE,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAChC,GAAG,CAAY,GAAY;QACzB,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC7C,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC;IAChE,CAAC;CACF,CAAA;AAJC;IAAK,mBAAA,gBAAO,EAAE,CAAA;;;;gDAGb;AAJU,qBAAqB;IADjC,mBAAU,EAAE;GACA,qBAAqB,CAKjC;AALY,sDAAqB","sourcesContent":["import {Context, Middleware, MiddlewareMethods} from \"@tsed/common\";\n\n@Middleware()\nexport class OidcNoCacheMiddleware implements MiddlewareMethods {\n use(@Context() ctx: Context) {\n ctx.response.setHeader(\"Pragma\", \"no-cache\");\n ctx.response.setHeader(\"Cache-Control\", \"no-cache, no-store\");\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcSecureMiddleware.js","sourceRoot":"","sources":["../../src/middlewares/OidcSecureMiddleware.ts"],"names":[],"mappings":";;;;AAAA,yCAAoE;AACpE,iDAA4C;AAC5C,sDAAsB;AAGtB,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAC/B,GAAG,CAAY,GAAY;QACzB,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC;QAExB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;YACf,IAAI,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE;gBACjD,GAAG,CAAC,QAAQ,CAAC,QAAQ,CACnB,GAAG,EACH,aAAG,CAAC,MAAM,CAAC;oBACT,QAAQ,EAAE,OAAO;oBACjB,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC;oBACrB,QAAQ,EAAE,GAAG,CAAC,GAAG;iBAClB,CAAC,CACH,CAAC;aACH;iBAAM;gBACL,MAAM,IAAI,uBAAU,CAAC,gBAAgB,EAAE;oBACrC,KAAK,EAAE,iBAAiB;oBACxB,iBAAiB,EAAE,wCAAwC;iBAC5D,CAAC,CAAC;aACJ;SACF;IACH,CAAC;CACF,CAAA;AArBC;IAAK,mBAAA,gBAAO,EAAE,CAAA;;;;+CAoBb;AArBU,oBAAoB;IADhC,mBAAU,EAAE;GACA,oBAAoB,CAsBhC;AAtBY,oDAAoB","sourcesContent":["import {Context, Middleware, MiddlewareMethods} from \"@tsed/common\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport url from \"url\";\n\n@Middleware()\nexport class OidcSecureMiddleware implements MiddlewareMethods {\n use(@Context() ctx: Context) {\n const req = ctx.request;\n\n if (!req.secure) {\n if (req.method === \"GET\" || req.method === \"HEAD\") {\n ctx.response.redirect(\n 302,\n url.format({\n protocol: \"https\",\n host: req.get(\"host\"),\n pathname: req.url\n })\n );\n } else {\n throw new BadRequest(\"InvalidRequest\", {\n error: \"invalid_request\",\n error_description: \"Do yourself a favor and only use https\"\n });\n }\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcAdapters.js","sourceRoot":"","sources":["../../src/services/OidcAdapters.ts"],"names":[],"mappings":";;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;YAC3C,CAAC;YAED,KAAK,CAAC,OAAO,CAAC,OAAe;gBAC3B,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,EAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,EAAC,CAAC,CAAC;YAChF,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAtDC;IADC,WAAM,EAAE;sCACW,mBAAQ;8CAAC;AAFlB,YAAY;IADxB,eAAU,EAAE;GACA,YAAY,CAwDxB;AAxDY,oCAAY","sourcesContent":["import {Adapter, Adapters} from \"@tsed/adapters\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {Adapter as OidcAdapter, AdapterConstructor} from \"oidc-provider\";\n\n@Injectable()\nexport class OidcAdapters {\n @Inject()\n protected adapters: Adapters;\n\n createAdapterClass(): AdapterConstructor {\n const self = this;\n\n return class CustomAdapter implements OidcAdapter {\n adapter: Adapter<any>;\n\n constructor(name: string) {\n this.adapter = self.adapters.invokeAdapter<any>({\n collectionName: name,\n model: Object\n });\n }\n\n async upsert(id: string, payload: any, expiresIn: number): Promise<void> {\n let expiresAt;\n\n if (expiresIn) {\n expiresAt = new Date(Date.now() + expiresIn * 1000);\n }\n\n await this.adapter.upsert(id, payload, expiresAt);\n }\n\n async find(id: string) {\n return this.adapter.findById(id);\n }\n\n async findByUserCode(userCode: string) {\n return this.adapter.findOne({\n userCode\n });\n }\n\n async findByUid(uid: string) {\n return this.adapter.findOne({\n uid\n });\n }\n\n async destroy(id: string) {\n await this.adapter.deleteById(id);\n }\n\n async revokeByGrantId(grantId: string) {\n await this.adapter.deleteMany({grantId});\n }\n\n async consume(grantId: string) {\n await this.adapter.update(grantId, {consumed: Math.floor(Date.now() / 1000)});\n }\n };\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcInteractionContext.js","sourceRoot":"","sources":["../../src/services/OidcInteractionContext.ts"],"names":[],"m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AC,sBAAa,CAAC,OAAO,CAAC;GAChB,sBAAsB,CAkHlC;AAlHY,wDAAsB","sourcesContent":["import {Constant, PlatformContext, ProviderScope, Scope} from \"@tsed/common\";\nimport {Env} from \"@tsed/core\";\nimport {Inject, Injectable} from \"@tsed/di\";\nimport {Account, InteractionResults, PromptDetail, Provider} from \"oidc-provider\";\nimport {OidcSession} from \"../decorators\";\nimport {OidcClient, OidcInteraction} from \"../domain\";\nimport {debug} from \"../utils/debug\";\nimport {OidcInteractions} from \"./OidcInteractions\";\nimport {OidcProvider} from \"./OidcProvider\";\n\n@Injectable()\n@Scope(ProviderScope.REQUEST)\nexport class OidcInteractionContext {\n @Constant(\"env\")\n env: Env;\n\n @Inject()\n protected oidcProvider: OidcProvider;\n\n @Inject()\n protected oidcInteractions: OidcInteractions;\n\n @Inject()\n protected context: PlatformContext;\n\n protected raw: OidcInteraction;\n\n get session(): OidcSession | undefined {\n return this.raw.session as any;\n }\n\n get prompt(): PromptDetail {\n return this.raw.prompt;\n }\n\n get params(): Record<string, any> {\n return this.raw.params;\n }\n\n get uid(): string {\n return this.raw.uid;\n }\n\n get grantId(): string {\n return (this.raw as any).grantId;\n }\n\n async runInteraction(name: string = this.prompt.name) {\n const handler = this.oidcInteractions.getInteractionHandler(name);\n\n if (handler) {\n await handler(this.context);\n }\n }\n\n async interactionDetails(): Promise<OidcInteraction> {\n this.raw = await this.oidcProvider.get().interactionDetails(this.context.getReq(), this.context.getRes());\n\n return this.raw;\n }\n\n async interactionFinished(result: InteractionResults, options: {mergeWithLastSubmission?: boolean} = {mergeWithLastSubmission: false}) {\n return this.oidcProvider.get().interactionFinished(this.context.getReq(), this.context.getRes(), result, options);\n }\n\n async interactionResult(result: InteractionResults, options: {mergeWithLastSubmission?: boolean} = {mergeWithLastSubmission: false}) {\n return this.oidcProvider.get().interactionResult(this.context.getReq(), this.context.getRes(), result, options);\n }\n\n async render(view: string, result: any): Promise<string> {\n return this.context.response.render(view, result);\n }\n\n async save(ttl: number): Promise<string> {\n return this.raw.save(ttl);\n }\n\n async findClient(clientId: string = this.params.client_id): Promise<OidcClient | undefined> {\n return this.oidcProvider.get().Client.find(clientId);\n }\n\n async findAccount(sub?: string, token?: any): Promise<Account | undefined> {\n if (!sub && this.session) {\n sub = this.session?.accountId as any;\n }\n\n if (!sub) {\n return;\n }\n\n return this.oidcProvider.get().Account.findAccount(undefined as any, sub!, token);\n }\n\n async getGrant(): Promise<InstanceType<Provider[\"Grant\"]>> {\n const {Grant} = this.oidcProvider.get() as any;\n\n if (this.grantId) {\n // we'll be modifying existing grant in existing session\n // @ts-ignore\n return await (this.oidcProvider.get().find || Grant.find)(this.grantId);\n }\n\n return new Grant({\n accountId: this.session?.accountId,\n clientId: this.params.client_id\n });\n }\n\n debug(obj?: any): any {\n /* istanbul ignore next */\n if (this.env === Env.PROD) {\n return {session: undefined, dbg: {params: undefined, prompt: undefined}};\n }\n\n if (obj) {\n return debug(obj);\n }\n\n return {\n session: this.session ? this.debug(this.session) : undefined,\n dbg: {\n params: this.debug(this.params),\n prompt: this.debug(this.prompt)\n }\n };\n }\n}\n"]}
@@ -1 +0,0 @@
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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OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC;YAC/C,CAAC,CAAC;SACH;IACH,CAAC;CACF,CAAA;AApDC;IADC,WAAM,EAAE;sCACC,oBAAe;kDAAC;AAG1B;IADC,iBAAQ,CAAC,KAAK,CAAC;;6CACP;AAGT;IADC,iBAAQ,CAAC,MAAM,CAAC;;sDACU;AARhB,gBAAgB;IAD5B,eAAU,EAAE;GACA,gBAAgB,CAsD5B;AAtDY,4CAAgB","sourcesContent":["import {Constant, EndpointMetadata, 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"]}
@@ -1 +0,0 @@
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,cAAO,CAAC;YACb,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjBC;IADC,aAAQ,CAAC,eAAe,EAAE,WAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;;0CACnD;AAGjB;IADC,aAAQ,CAAC,mBAAmB,CAAC;;8CACK;AALxB,QAAQ;IADpB,eAAU,EAAE;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"]}