@tsed/oidc-provider 8.0.1 → 8.0.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 (49) hide show
  1. package/package.json +16 -15
  2. package/src/OidcModule.spec.ts +116 -0
  3. package/src/OidcModule.ts +70 -0
  4. package/src/constants/constants.ts +10 -0
  5. package/src/decorators/grantId.spec.ts +17 -0
  6. package/src/decorators/grantId.ts +10 -0
  7. package/src/decorators/interaction.spec.ts +27 -0
  8. package/src/decorators/interaction.ts +18 -0
  9. package/src/decorators/interactions.spec.ts +23 -0
  10. package/src/decorators/interactions.ts +21 -0
  11. package/src/decorators/noCache.ts +7 -0
  12. package/src/decorators/oidcCtx.spec.ts +17 -0
  13. package/src/decorators/oidcCtx.ts +11 -0
  14. package/src/decorators/oidcSession.spec.ts +17 -0
  15. package/src/decorators/oidcSession.ts +14 -0
  16. package/src/decorators/params.spec.ts +17 -0
  17. package/src/decorators/params.ts +10 -0
  18. package/src/decorators/prompt.spec.ts +17 -0
  19. package/src/decorators/prompt.ts +11 -0
  20. package/src/decorators/uid.spec.ts +17 -0
  21. package/src/decorators/uid.ts +10 -0
  22. package/src/domain/InteractionMethods.ts +11 -0
  23. package/src/domain/OidcAccountsMethods.ts +10 -0
  24. package/src/domain/OidcBadInteractionName.ts +3 -0
  25. package/src/domain/OidcInteractionMethods.ts +3 -0
  26. package/src/domain/OidcInteractionOptions.ts +8 -0
  27. package/src/domain/OidcInteractionPromptProps.ts +11 -0
  28. package/src/domain/OidcSettings.ts +72 -0
  29. package/src/domain/interfaces.ts +13 -0
  30. package/src/index.ts +33 -0
  31. package/src/middlewares/OidcInteractionMiddleware.spec.ts +40 -0
  32. package/src/middlewares/OidcInteractionMiddleware.ts +14 -0
  33. package/src/middlewares/OidcNoCacheMiddleware.spec.ts +18 -0
  34. package/src/middlewares/OidcNoCacheMiddleware.ts +10 -0
  35. package/src/middlewares/OidcSecureMiddleware.spec.ts +106 -0
  36. package/src/middlewares/OidcSecureMiddleware.ts +29 -0
  37. package/src/services/OidcAdapters.spec.ts +100 -0
  38. package/src/services/OidcAdapters.ts +92 -0
  39. package/src/services/OidcInteractionContext.spec.ts +304 -0
  40. package/src/services/OidcInteractionContext.ts +206 -0
  41. package/src/services/OidcInteractions.ts +57 -0
  42. package/src/services/OidcJwks.ts +21 -0
  43. package/src/services/OidcPolicy.spec.ts +156 -0
  44. package/src/services/OidcPolicy.ts +92 -0
  45. package/src/services/OidcProvider.spec.ts +116 -0
  46. package/src/services/OidcProvider.ts +198 -0
  47. package/src/utils/debug.spec.ts +12 -0
  48. package/src/utils/debug.ts +25 -0
  49. package/src/utils/events.ts +61 -0
package/package.json CHANGED
@@ -2,13 +2,14 @@
2
2
  "name": "@tsed/oidc-provider",
3
3
  "description": "OIDC provider package for Ts.ED framework",
4
4
  "type": "module",
5
- "version": "8.0.1",
5
+ "version": "8.0.3",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
9
9
  "typings": "./lib/types/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
+ "@tsed/source": "./src/index.ts",
12
13
  "types": "./lib/types/index.d.ts",
13
14
  "import": "./lib/esm/index.js",
14
15
  "default": "./lib/esm/index.js"
@@ -23,7 +24,7 @@
23
24
  "test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
24
25
  },
25
26
  "dependencies": {
26
- "@tsed/adapters": "8.0.1",
27
+ "@tsed/adapters": "8.0.3",
27
28
  "express-urlrewrite": "^2.0.3",
28
29
  "jose2": "npm:jose@^2.0.4",
29
30
  "koa-mount": "^4.0.0",
@@ -33,13 +34,13 @@
33
34
  "uuid": "^10.0.0"
34
35
  },
35
36
  "devDependencies": {
36
- "@tsed/barrels": "8.0.1",
37
- "@tsed/core": "8.0.1",
38
- "@tsed/di": "8.0.1",
39
- "@tsed/exceptions": "8.0.1",
40
- "@tsed/jwks": "8.0.1",
41
- "@tsed/platform-http": "8.0.1",
42
- "@tsed/typescript": "8.0.1",
37
+ "@tsed/barrels": "8.0.3",
38
+ "@tsed/core": "8.0.3",
39
+ "@tsed/di": "8.0.3",
40
+ "@tsed/exceptions": "8.0.3",
41
+ "@tsed/jwks": "8.0.3",
42
+ "@tsed/platform-http": "8.0.3",
43
+ "@tsed/typescript": "8.0.3",
43
44
  "@types/lowdb": "1.0.15",
44
45
  "@types/oidc-provider": "8.5.2",
45
46
  "@types/uuid": "10.0.0",
@@ -51,12 +52,12 @@
51
52
  "vitest": "2.1.2"
52
53
  },
53
54
  "peerDependencies": {
54
- "@tsed/ajv": "8.0.1",
55
- "@tsed/core": "8.0.1",
56
- "@tsed/di": "8.0.1",
57
- "@tsed/json-mapper": "8.0.1",
58
- "@tsed/platform-http": "8.0.1",
59
- "@tsed/schema": "8.0.1",
55
+ "@tsed/ajv": "8.0.3",
56
+ "@tsed/core": "8.0.3",
57
+ "@tsed/di": "8.0.3",
58
+ "@tsed/json-mapper": "8.0.3",
59
+ "@tsed/platform-http": "8.0.3",
60
+ "@tsed/schema": "8.0.3",
60
61
  "oidc-provider": ">=8.0.0"
61
62
  },
62
63
  "peerDependenciesMeta": {
@@ -0,0 +1,116 @@
1
+ import {PlatformTest} from "@tsed/platform-http/testing";
2
+ import expressRewrite from "express-urlrewrite";
3
+ import koaMount from "koa-mount";
4
+ // @ts-ignore
5
+ import koaRewrite from "koa-rewrite";
6
+
7
+ import {OidcModule} from "./OidcModule.js";
8
+ import {OidcProvider} from "./services/OidcProvider.js";
9
+
10
+ vi.mock("express-urlrewrite", () => {
11
+ return {default: vi.fn().mockReturnValue(vi.fn())};
12
+ });
13
+ vi.mock("koa-rewrite", () => {
14
+ return {default: vi.fn().mockReturnValue(vi.fn())};
15
+ });
16
+ vi.mock("koa-mount", () => {
17
+ return {default: vi.fn().mockReturnValue(vi.fn())};
18
+ });
19
+
20
+ describe("OidcModule", () => {
21
+ describe("with express", () => {
22
+ beforeEach(() =>
23
+ PlatformTest.create({
24
+ PLATFORM_NAME: "express",
25
+ oidc: {
26
+ path: "/oidc"
27
+ }
28
+ })
29
+ );
30
+
31
+ afterEach(() => PlatformTest.reset());
32
+ describe('when path "/oidc"', () => {
33
+ it("should register the appropriate rewrite middleware", async () => {
34
+ const mdl = await PlatformTest.invoke<any>(OidcModule);
35
+
36
+ vi.spyOn(mdl.app, "use").mockReturnValue(undefined);
37
+
38
+ await mdl.$onRoutesInit();
39
+
40
+ expect(expressRewrite).toHaveBeenCalledWith("/.well-known/*", "/oidc/.well-known/$1");
41
+ expect(mdl.app.use).toHaveBeenCalledWith(expect.any(Function));
42
+ });
43
+ it("should mount the oidc provider server to application", async () => {
44
+ const provider = {
45
+ app: "app",
46
+ callback: vi.fn().mockReturnValue("callback")
47
+ };
48
+ const oidcProvider = {
49
+ hasConfiguration: vi.fn().mockReturnValue(true),
50
+ get: vi.fn().mockReturnValue(provider),
51
+ create: vi.fn()
52
+ };
53
+ const mdl = await PlatformTest.invoke<any>(OidcModule, [
54
+ {
55
+ token: OidcProvider,
56
+ use: oidcProvider
57
+ }
58
+ ]);
59
+
60
+ vi.spyOn(mdl.app, "use").mockReturnValue(undefined);
61
+
62
+ await mdl.$afterRoutesInit();
63
+
64
+ expect(mdl.app.use).toHaveBeenCalledWith("/oidc", "callback");
65
+ });
66
+ });
67
+ });
68
+ describe("with koa", () => {
69
+ beforeEach(() =>
70
+ PlatformTest.create({
71
+ PLATFORM_NAME: "koa",
72
+ oidc: {
73
+ path: "/oidc"
74
+ }
75
+ })
76
+ );
77
+
78
+ afterEach(() => PlatformTest.reset());
79
+ describe('when path "/oidc"', () => {
80
+ it("should register the appropriate rewrite middleware", async () => {
81
+ const mdl = await PlatformTest.invoke<any>(OidcModule);
82
+
83
+ vi.spyOn(mdl.app, "use").mockReturnValue(undefined);
84
+
85
+ await mdl.$onRoutesInit();
86
+
87
+ expect(koaRewrite).toHaveBeenCalledWith("/.well-known/(.*)", "/oidc/.well-known/$1");
88
+ expect(mdl.app.use).toHaveBeenCalledWith(expect.any(Function));
89
+ });
90
+ it("should mount the oidc provider server to application", async () => {
91
+ const provider = {
92
+ app: "app",
93
+ callback: vi.fn().mockReturnValue("callback")
94
+ };
95
+ const oidcProvider = {
96
+ hasConfiguration: vi.fn().mockReturnValue(true),
97
+ get: vi.fn().mockReturnValue(provider),
98
+ create: vi.fn()
99
+ };
100
+ const mdl = await PlatformTest.invoke<any>(OidcModule, [
101
+ {
102
+ token: OidcProvider,
103
+ use: oidcProvider
104
+ }
105
+ ]);
106
+
107
+ vi.spyOn(mdl.app, "use").mockReturnValue(undefined);
108
+
109
+ await mdl.$afterRoutesInit();
110
+
111
+ expect(koaMount).toHaveBeenCalledWith("/oidc", "app");
112
+ expect(mdl.app.use).toHaveBeenCalledWith(expect.any(Function));
113
+ });
114
+ });
115
+ });
116
+ });
@@ -0,0 +1,70 @@
1
+ import {constant, inject, injector, Module} from "@tsed/di";
2
+ import {PlatformApplication} from "@tsed/platform-http";
3
+ import koaMount from "koa-mount";
4
+
5
+ import {OidcAdapters} from "./services/OidcAdapters.js";
6
+ import {OidcJwks} from "./services/OidcJwks.js";
7
+ import {OidcProvider} from "./services/OidcProvider.js";
8
+
9
+ @Module({
10
+ imports: [OidcProvider, OidcAdapters, OidcJwks]
11
+ })
12
+ export class OidcModule {
13
+ protected app: PlatformApplication = inject(PlatformApplication);
14
+ protected platformName = constant<string>("PLATFORM_NAME");
15
+ protected basePath = constant("oidc.path", "/oidc");
16
+ protected oidcProvider = inject(OidcProvider);
17
+
18
+ async $onInit() {
19
+ if (this.oidcProvider.hasConfiguration()) {
20
+ await this.oidcProvider.create();
21
+ }
22
+ }
23
+
24
+ async $onRoutesInit() {
25
+ if (this.basePath !== "/") {
26
+ this.app.use(await this.getRewriteMiddleware());
27
+ }
28
+ }
29
+
30
+ $afterRoutesInit() {
31
+ if (this.oidcProvider.hasConfiguration()) {
32
+ const provider = this.oidcProvider.get();
33
+
34
+ switch (this.platformName) {
35
+ default:
36
+ case "express":
37
+ this.app.use(this.basePath, provider.callback());
38
+ break;
39
+ case "koa":
40
+ this.app.use(koaMount(this.basePath, provider.app));
41
+ break;
42
+ }
43
+ }
44
+ }
45
+
46
+ $onReady() {
47
+ const inj = injector();
48
+
49
+ if (this.oidcProvider.hasConfiguration() && "getBestHost" in inj.settings) {
50
+ // @ts-ignore
51
+ const host = inj.settings.getBestHost();
52
+ const url = host.toString();
53
+
54
+ inj.logger.info(`WellKnown is available on ${url}/.well-known/openid-configuration`);
55
+ }
56
+ }
57
+
58
+ private async getRewriteMiddleware() {
59
+ switch (this.platformName) {
60
+ default:
61
+ case "express":
62
+ const {default: expressUrlRewrite} = await import("express-urlrewrite");
63
+ return expressUrlRewrite("/.well-known/*", `${this.basePath}/.well-known/$1`);
64
+ case "koa":
65
+ // @ts-ignore
66
+ const {default: koaUrlRewrite} = await import("koa-rewrite");
67
+ return koaUrlRewrite("/.well-known/(.*)", `${this.basePath}/.well-known/$1`);
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,10 @@
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";
@@ -0,0 +1,17 @@
1
+ import {JsonParameterStore} from "@tsed/schema";
2
+
3
+ import {INTERACTION_GRANT_ID} from "../constants/constants.js";
4
+ import {GrantId} from "./grantId.js";
5
+
6
+ describe("@GrandId", () => {
7
+ it("should inject grantId", () => {
8
+ class MyInteraction {
9
+ $prompt(@GrantId() grandId: string) {}
10
+ }
11
+
12
+ const entity = JsonParameterStore.get(MyInteraction, "$prompt", 0);
13
+
14
+ expect(entity.paramType).toEqual("$CTX");
15
+ expect(entity.expression).toEqual(INTERACTION_GRANT_ID);
16
+ });
17
+ });
@@ -0,0 +1,10 @@
1
+ import {useDecorators} from "@tsed/core";
2
+ import {Context} from "@tsed/platform-params";
3
+
4
+ import {INTERACTION_GRANT_ID, INTERACTION_PARAMS} from "../constants/constants.js";
5
+
6
+ export function GrantId(): ParameterDecorator {
7
+ return useDecorators(Context(INTERACTION_GRANT_ID));
8
+ }
9
+
10
+ export type GrantId = string;
@@ -0,0 +1,27 @@
1
+ import {Store} from "@tsed/core";
2
+ import {GlobalProviders} from "@tsed/di";
3
+
4
+ import {INTERACTION_OPTIONS} from "../constants/constants.js";
5
+ import {OidcInteractionMethods} from "../domain/OidcInteractionMethods.js";
6
+ import {Interaction} from "./interaction.js";
7
+
8
+ describe("@Interaction", () => {
9
+ it("should create an interaction", () => {
10
+ @Interaction({
11
+ name: "login",
12
+ requestable: true,
13
+ priority: 0
14
+ })
15
+ class CustomInteraction implements OidcInteractionMethods {}
16
+
17
+ const store = Store.from(CustomInteraction);
18
+ const provider = GlobalProviders.get(CustomInteraction)!;
19
+
20
+ expect(provider.subType).toEqual("interaction");
21
+ expect(store.get(INTERACTION_OPTIONS)).toEqual({
22
+ name: "login",
23
+ requestable: true,
24
+ priority: 0
25
+ });
26
+ });
27
+ });
@@ -0,0 +1,18 @@
1
+ import {StoreMerge, useDecorators} from "@tsed/core";
2
+ import {Controller} from "@tsed/di";
3
+
4
+ import {INTERACTION, INTERACTION_OPTIONS} from "../constants/constants.js";
5
+ import {OidcInteractionOptions} from "../domain/OidcInteractionOptions.js";
6
+
7
+ /**
8
+ * @Oidc
9
+ */
10
+ export function Interaction(options: OidcInteractionOptions): ClassDecorator {
11
+ return useDecorators(
12
+ Controller({
13
+ path: "/",
14
+ subType: INTERACTION
15
+ }),
16
+ StoreMerge(INTERACTION_OPTIONS, options)
17
+ );
18
+ }
@@ -0,0 +1,23 @@
1
+ import "../../test/app/controllers/oidc/InteractionsCtrl.js";
2
+
3
+ import {PlatformTest} from "@tsed/platform-http/testing";
4
+
5
+ describe("@Interactions", () => {
6
+ beforeEach(() =>
7
+ PlatformTest.create({
8
+ oidc: {
9
+ options: {
10
+ claims: {}
11
+ }
12
+ } as any
13
+ })
14
+ );
15
+ afterEach(() => PlatformTest.create());
16
+ it("should create interactions", () => {
17
+ PlatformTest.injector.resolveConfiguration();
18
+
19
+ const oidc = PlatformTest.injector.settings.get("oidc");
20
+
21
+ expect(oidc.options.claims).toEqual({});
22
+ });
23
+ });
@@ -0,0 +1,21 @@
1
+ import {Type, useDecorators} from "@tsed/core";
2
+ import {Controller} from "@tsed/di";
3
+ import {UseBefore} from "@tsed/platform-middlewares";
4
+
5
+ import {INTERACTIONS} from "../constants/constants.js";
6
+ import {OidcInteractionMiddleware} from "../middlewares/OidcInteractionMiddleware.js";
7
+ import {NoCache} from "./noCache.js";
8
+
9
+ export interface InteractionsOptions {
10
+ path: string;
11
+ children: Type<any>[];
12
+ }
13
+
14
+ export function Interactions(options: InteractionsOptions): ClassDecorator {
15
+ const {path} = options;
16
+ return useDecorators(
17
+ Controller({path, children: options.children, subType: INTERACTIONS}),
18
+ NoCache(),
19
+ UseBefore(OidcInteractionMiddleware)
20
+ );
21
+ }
@@ -0,0 +1,7 @@
1
+ import {UseBefore} from "@tsed/platform-middlewares";
2
+
3
+ import {OidcNoCacheMiddleware} from "../middlewares/OidcNoCacheMiddleware.js";
4
+
5
+ export function NoCache(): ClassDecorator {
6
+ return UseBefore(OidcNoCacheMiddleware) as ClassDecorator;
7
+ }
@@ -0,0 +1,17 @@
1
+ import {JsonParameterStore} from "@tsed/schema";
2
+
3
+ import {INTERACTION_CONTEXT} from "../constants/constants.js";
4
+ import {OidcCtx} from "./oidcCtx.js";
5
+
6
+ describe("@OidcCtx", () => {
7
+ it("should inject uid", () => {
8
+ class MyInteraction {
9
+ $prompt(@OidcCtx() oidcCtx: OidcCtx) {}
10
+ }
11
+
12
+ const entity = JsonParameterStore.get(MyInteraction, "$prompt", 0);
13
+
14
+ expect(entity.paramType).toEqual("$CTX");
15
+ expect(entity.expression).toEqual(INTERACTION_CONTEXT);
16
+ });
17
+ });
@@ -0,0 +1,11 @@
1
+ import {useDecorators} from "@tsed/core";
2
+ import {Context} from "@tsed/platform-params";
3
+
4
+ import {INTERACTION_CONTEXT} from "../constants/constants.js";
5
+ import {OidcInteractionContext} from "../services/OidcInteractionContext.js";
6
+
7
+ export function OidcCtx(): ParameterDecorator {
8
+ return useDecorators(Context(INTERACTION_CONTEXT));
9
+ }
10
+
11
+ export type OidcCtx = OidcInteractionContext;
@@ -0,0 +1,17 @@
1
+ import {JsonParameterStore} from "@tsed/schema";
2
+
3
+ import {INTERACTION_SESSION} from "../constants/constants.js";
4
+ import {OidcSession} from "./oidcSession.js";
5
+
6
+ describe("@OidcSession", () => {
7
+ it("should inject uid", () => {
8
+ class MyInteraction {
9
+ $prompt(@OidcSession() session: OidcSession) {}
10
+ }
11
+
12
+ const entity = JsonParameterStore.get(MyInteraction, "$prompt", 0);
13
+
14
+ expect(entity.paramType).toEqual("$CTX");
15
+ expect(entity.expression).toEqual(INTERACTION_SESSION);
16
+ });
17
+ });
@@ -0,0 +1,14 @@
1
+ import {useDecorators} from "@tsed/core";
2
+ import {Context} from "@tsed/platform-params";
3
+ import type {default as Provider} from "oidc-provider";
4
+
5
+ import {INTERACTION_SESSION} from "../constants/constants.js";
6
+
7
+ /**
8
+ * @decorator
9
+ */
10
+ export function OidcSession(expression?: string): ParameterDecorator {
11
+ return useDecorators(Context([INTERACTION_SESSION, expression].filter(Boolean).join(".")));
12
+ }
13
+
14
+ export type OidcSession = InstanceType<Provider["Session"]>;
@@ -0,0 +1,17 @@
1
+ import {JsonParameterStore} from "@tsed/schema";
2
+
3
+ import {INTERACTION_PARAMS} from "../constants/constants.js";
4
+ import {Params} from "./params.js";
5
+
6
+ describe("@Params", () => {
7
+ it("should inject uid", () => {
8
+ class MyInteraction {
9
+ $prompt(@Params() params: Params) {}
10
+ }
11
+
12
+ const entity = JsonParameterStore.get(MyInteraction, "$prompt", 0);
13
+
14
+ expect(entity.paramType).toEqual("$CTX");
15
+ expect(entity.expression).toEqual(INTERACTION_PARAMS);
16
+ });
17
+ });
@@ -0,0 +1,10 @@
1
+ import {useDecorators} from "@tsed/core";
2
+ import {Context} from "@tsed/platform-params";
3
+
4
+ import {INTERACTION_PARAMS} from "../constants/constants.js";
5
+
6
+ export function Params(expression?: string): ParameterDecorator {
7
+ return useDecorators(Context([INTERACTION_PARAMS, expression].filter(Boolean).join(".")));
8
+ }
9
+
10
+ export type Params = Record<string, any>;
@@ -0,0 +1,17 @@
1
+ import {JsonParameterStore} from "@tsed/schema";
2
+
3
+ import {INTERACTION_PROMPT} from "../constants/constants.js";
4
+ import {Prompt} from "./prompt.js";
5
+
6
+ describe("@Prompt", () => {
7
+ it("should inject uid", () => {
8
+ class MyInteraction {
9
+ $prompt(@Prompt() uid: Prompt) {}
10
+ }
11
+
12
+ const entity = JsonParameterStore.get(MyInteraction, "$prompt", 0);
13
+
14
+ expect(entity.paramType).toEqual("$CTX");
15
+ expect(entity.expression).toEqual(INTERACTION_PROMPT);
16
+ });
17
+ });
@@ -0,0 +1,11 @@
1
+ import {useDecorators} from "@tsed/core";
2
+ import {Context} from "@tsed/platform-params";
3
+ import type {PromptDetail as P} from "oidc-provider";
4
+
5
+ import {INTERACTION_PROMPT} from "../constants/constants.js";
6
+
7
+ export function Prompt(): ParameterDecorator {
8
+ return useDecorators(Context(INTERACTION_PROMPT));
9
+ }
10
+
11
+ export type Prompt = P;
@@ -0,0 +1,17 @@
1
+ import {JsonParameterStore} from "@tsed/schema";
2
+
3
+ import {INTERACTION_UID} from "../constants/constants.js";
4
+ import {Uid} from "./uid.js";
5
+
6
+ describe("@Uid", () => {
7
+ it("should inject uid", () => {
8
+ class MyInteraction {
9
+ $prompt(@Uid() uid: string) {}
10
+ }
11
+
12
+ const entity = JsonParameterStore.get(MyInteraction, "$prompt", 0);
13
+
14
+ expect(entity.paramType).toEqual("$CTX");
15
+ expect(entity.expression).toEqual(INTERACTION_UID);
16
+ });
17
+ });
@@ -0,0 +1,10 @@
1
+ import {useDecorators} from "@tsed/core";
2
+ import {Context} from "@tsed/platform-params";
3
+
4
+ import {INTERACTION_UID} from "../constants/constants.js";
5
+
6
+ export function Uid(): ParameterDecorator {
7
+ return useDecorators(Context(INTERACTION_UID));
8
+ }
9
+
10
+ export type Uid = string;
@@ -0,0 +1,11 @@
1
+ import type {CanBePromise, interactionPolicy, KoaContextWithOIDC, UnknownObject} from "oidc-provider";
2
+
3
+ export interface InteractionMethods {
4
+ details?: (ctx: KoaContextWithOIDC) => CanBePromise<UnknownObject>;
5
+ checks?: () => interactionPolicy.Check[];
6
+ $onCreate?: (prompt: interactionPolicy.Prompt) => void | Promise<void>;
7
+ /**
8
+ * @param args Injectable parameters
9
+ */
10
+ $prompt?: (...args: any[]) => any | Promise<any>;
11
+ }
@@ -0,0 +1,10 @@
1
+ import type {Account, default as Provider} from "oidc-provider";
2
+
3
+ import {AccessToken, AuthorizationCode, BackchannelAuthenticationRequest, DeviceCode} from "./interfaces.js";
4
+
5
+ export interface OidcAccountsMethods {
6
+ findAccount(
7
+ id: string,
8
+ token: AuthorizationCode | AccessToken | DeviceCode | BackchannelAuthenticationRequest | undefined
9
+ ): Promise<Account | undefined>;
10
+ }
@@ -0,0 +1,3 @@
1
+ import {BadRequest} from "@tsed/exceptions";
2
+
3
+ export class OidcBadInteractionName extends BadRequest {}
@@ -0,0 +1,3 @@
1
+ export interface OidcInteractionMethods {
2
+ $prompts?(...args: unknown[]): void | unknown | Promise<unknown>;
3
+ }
@@ -0,0 +1,8 @@
1
+ import type {CanBePromise, interactionPolicy, KoaContextWithOIDC, UnknownObject} from "oidc-provider";
2
+ export interface OidcInteractionOptions {
3
+ name: string;
4
+ requestable?: boolean | undefined;
5
+ priority?: number;
6
+ details?: (ctx: KoaContextWithOIDC) => CanBePromise<UnknownObject>;
7
+ checks?: interactionPolicy.Check[];
8
+ }
@@ -0,0 +1,11 @@
1
+ import type {UnknownObject} from "oidc-provider";
2
+
3
+ import {OidcClient} from "./interfaces.js";
4
+
5
+ export type OidcInteractionPromptProps<Props = Record<string, any>> = {
6
+ client: OidcClient;
7
+ uid: string;
8
+ grantId: string;
9
+ details: UnknownObject;
10
+ params: Record<string, any>;
11
+ } & Props;