@tsed/oidc-provider 6.102.0 → 6.102.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.mocharc.js CHANGED
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- ...require('@tsed/mocha-config')(),
2
+ ...require("@tsed/mocha-config")(),
3
3
  spec: ["{src,test}/**/*.spec.ts"],
4
- exclude: [],
4
+ exclude: []
5
5
  };
@@ -4,6 +4,7 @@ exports.OidcModule = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@tsed/common");
6
6
  const di_1 = require("@tsed/di");
7
+ const koa_mount_1 = (0, tslib_1.__importDefault)(require("koa-mount"));
7
8
  const OidcAdapters_1 = require("./services/OidcAdapters");
8
9
  const OidcJwks_1 = require("./services/OidcJwks");
9
10
  const OidcProvider_1 = require("./services/OidcProvider");
@@ -15,7 +16,7 @@ let OidcModule = class OidcModule {
15
16
  }
16
17
  async $onRoutesInit() {
17
18
  if (this.basePath !== "/") {
18
- this.app.use(this.getRewriteMiddleware());
19
+ this.app.use(await this.getRewriteMiddleware());
19
20
  }
20
21
  }
21
22
  async $afterRoutesInit() {
@@ -27,7 +28,7 @@ let OidcModule = class OidcModule {
27
28
  this.app.use(this.basePath, provider.callback());
28
29
  break;
29
30
  case "koa":
30
- this.app.use(require("koa-mount")(this.basePath, provider.app));
31
+ this.app.use((0, koa_mount_1.default)(this.basePath, provider.app));
31
32
  break;
32
33
  }
33
34
  }
@@ -40,13 +41,16 @@ let OidcModule = class OidcModule {
40
41
  injector.logger.info(`WellKnown is available on ${url}/.well-known/openid-configuration`);
41
42
  }
42
43
  }
43
- getRewriteMiddleware() {
44
+ async getRewriteMiddleware() {
44
45
  switch (this.platformName) {
45
46
  default:
46
47
  case "express":
47
- return require("express-urlrewrite")("/.well-known/*", `${this.basePath}/.well-known/$1`);
48
+ const { default: expressUrlRewrite } = await Promise.resolve().then(() => (0, tslib_1.__importStar)(require("express-urlrewrite")));
49
+ return expressUrlRewrite("/.well-known/*", `${this.basePath}/.well-known/$1`);
48
50
  case "koa":
49
- return require("koa-rewrite")("/.well-known/(.*)", `${this.basePath}/.well-known/$1`);
51
+ // @ts-ignore
52
+ const { default: koaUrlRewrite } = await Promise.resolve().then(() => (0, tslib_1.__importStar)(require("koa-rewrite")));
53
+ return koaUrlRewrite("/.well-known/(.*)", `${this.basePath}/.well-known/$1`);
50
54
  }
51
55
  }
52
56
  };
@@ -1 +1 @@
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,gBAAgB,EAAE,EAAE;YACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;YAEzC,QAAQ,IAAI,CAAC,YAAY,EAAE;gBACzB,QAAQ;gBACR,KAAK,SAAS;oBACZ,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;oBACjD,MAAM;gBACR,KAAK,KAAK;oBACR,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,WA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CA+DtB;AA/DY,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() && 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"]}
1
+ {"version":3,"file":"OidcModule.js","sourceRoot":"","sources":["../../src/OidcModule.ts"],"names":[],"mappings":";;;;AAAA,yCAA0E;AAC1E,iCAA0C;AAC1C,uEAAiC;AACjC,0DAAqD;AACrD,kDAA6C;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CAAC,6BAA6B,GAAG,mCAAmC,CAAC,CAAC;SAC3F;IACH,CAAC;IAEO,KAAK,CAAC,oBAAoB;QAChC,QAAQ,IAAI,CAAC,YAAY,EAAE;YACzB,QAAQ;YACR,KAAK,SAAS;gBACZ,MAAM,EAAC,OAAO,EAAE,iBAAiB,EAAC,GAAG,qEAAa,oBAAoB,GAAC,CAAC;gBACxE,OAAO,iBAAiB,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,QAAQ,iBAAiB,CAAC,CAAC;YAChF,KAAK,KAAK;gBACR,aAAa;gBACb,MAAM,EAAC,OAAO,EAAE,aAAa,EAAC,GAAG,qEAAa,aAAa,GAAC,CAAC;gBAC7D,OAAO,aAAa,CAAC,mBAAmB,EAAE,GAAG,IAAI,CAAC,QAAQ,iBAAiB,CAAC,CAAC;SAChF;IACH,CAAC;CACF,CAAA;AAhEC;IADC,IAAA,eAAM,GAAE;2CACJ,4BAAmB;uCAAC;AAGzB;IADC,IAAA,aAAQ,EAAC,eAAe,CAAC;;gDACL;AAGrB;IADC,IAAA,aAAQ,EAAC,WAAW,EAAE,GAAG,CAAC;;4CACV;AAGjB;IADC,IAAA,eAAM,GAAE;2CACK,2BAAY;gDAAC;AAG3B;IADC,IAAA,eAAM,GAAE;2CACC,wBAAe;4CAAC;AAdf,UAAU;IAHtB,IAAA,WAAM,EAAC;QACN,OAAO,EAAE,CAAC,2BAAY,EAAE,2BAAY,EAAE,mBAAQ,CAAC;KAChD,CAAC;GACW,UAAU,CAkEtB;AAlEY,gCAAU","sourcesContent":["import {Inject, InjectorService, PlatformApplication} from \"@tsed/common\";\nimport {Constant, Module} from \"@tsed/di\";\nimport koaMount from \"koa-mount\";\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(await 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(koaMount(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 async getRewriteMiddleware() {\n switch (this.platformName) {\n default:\n case \"express\":\n const {default: expressUrlRewrite} = await import(\"express-urlrewrite\");\n return expressUrlRewrite(\"/.well-known/*\", `${this.basePath}/.well-known/$1`);\n case \"koa\":\n // @ts-ignore\n const {default: koaUrlRewrite} = await import(\"koa-rewrite\");\n return koaUrlRewrite(\"/.well-known/(.*)\", `${this.basePath}/.well-known/$1`);\n }\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { Inject, InjectorService, PlatformApplication } from "@tsed/common";
3
3
  import { Constant, Module } from "@tsed/di";
4
+ import koaMount from "koa-mount";
4
5
  import { OidcAdapters } from "./services/OidcAdapters";
5
6
  import { OidcJwks } from "./services/OidcJwks";
6
7
  import { OidcProvider } from "./services/OidcProvider";
@@ -12,7 +13,7 @@ let OidcModule = class OidcModule {
12
13
  }
13
14
  async $onRoutesInit() {
14
15
  if (this.basePath !== "/") {
15
- this.app.use(this.getRewriteMiddleware());
16
+ this.app.use(await this.getRewriteMiddleware());
16
17
  }
17
18
  }
18
19
  async $afterRoutesInit() {
@@ -24,7 +25,7 @@ let OidcModule = class OidcModule {
24
25
  this.app.use(this.basePath, provider.callback());
25
26
  break;
26
27
  case "koa":
27
- this.app.use(require("koa-mount")(this.basePath, provider.app));
28
+ this.app.use(koaMount(this.basePath, provider.app));
28
29
  break;
29
30
  }
30
31
  }
@@ -37,13 +38,16 @@ let OidcModule = class OidcModule {
37
38
  injector.logger.info(`WellKnown is available on ${url}/.well-known/openid-configuration`);
38
39
  }
39
40
  }
40
- getRewriteMiddleware() {
41
+ async getRewriteMiddleware() {
41
42
  switch (this.platformName) {
42
43
  default:
43
44
  case "express":
44
- return require("express-urlrewrite")("/.well-known/*", `${this.basePath}/.well-known/$1`);
45
+ const { default: expressUrlRewrite } = await import("express-urlrewrite");
46
+ return expressUrlRewrite("/.well-known/*", `${this.basePath}/.well-known/$1`);
45
47
  case "koa":
46
- return require("koa-rewrite")("/.well-known/(.*)", `${this.basePath}/.well-known/$1`);
48
+ // @ts-ignore
49
+ const { default: koaUrlRewrite } = await import("koa-rewrite");
50
+ return koaUrlRewrite("/.well-known/(.*)", `${this.basePath}/.well-known/$1`);
47
51
  }
48
52
  }
49
53
  };
@@ -1 +1 @@
1
- {"version":3,"file":"OidcModule.js","sourceRoot":"","sources":["../../src/OidcModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,eAAe,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAKrD,IAAa,UAAU,GAAvB,MAAa,UAAU;IAgBrB,KAAK,CAAC,OAAO;QACX,IAAI,IAA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AI,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"]}
1
+ {"version":3,"file":"OidcModule.js","sourceRoot":"","sources":["../../src/OidcModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,eAAe,EAAE,mBAAmB,EAAC,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;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,MAAM,IAAI,CAAC,oB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gBACR,aAAa;gBACb,MAAM,EAAC,OAAO,EAAE,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC7D,OAAO,aAAa,CAAC,mBAAmB,EAAE,GAAG,IAAI,CAAC,QAAQ,iBAAiB,CAAC,CAAC;SAChF;IACH,CAAC;CACF,CAAA;AAhEC;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,CAkEtB;SAlEY,UAAU","sourcesContent":["import {Inject, InjectorService, PlatformApplication} from \"@tsed/common\";\nimport {Constant, Module} from \"@tsed/di\";\nimport koaMount from \"koa-mount\";\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(await 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(koaMount(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 async getRewriteMiddleware() {\n switch (this.platformName) {\n default:\n case \"express\":\n const {default: expressUrlRewrite} = await import(\"express-urlrewrite\");\n return expressUrlRewrite(\"/.well-known/*\", `${this.basePath}/.well-known/$1`);\n case \"koa\":\n // @ts-ignore\n const {default: koaUrlRewrite} = await import(\"koa-rewrite\");\n return koaUrlRewrite(\"/.well-known/(.*)\", `${this.basePath}/.well-known/$1`);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/oidc-provider",
3
- "version": "6.102.0",
3
+ "version": "6.102.4",
4
4
  "description": "OIDC provider package for Ts.ED framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -20,7 +20,7 @@
20
20
  "test": "cross-env NODE_ENV=test nyc mocha"
21
21
  },
22
22
  "dependencies": {
23
- "@tsed/adapters": "6.102.0",
23
+ "@tsed/adapters": "6.102.4",
24
24
  "express-urlrewrite": "^1.4.0",
25
25
  "jose2": "npm:jose@^2.0.4",
26
26
  "koa-mount": "^4.0.0",
@@ -30,24 +30,16 @@
30
30
  "uuid": "8.3.2"
31
31
  },
32
32
  "devDependencies": {
33
- "@tsed/common": "6.102.0",
34
- "@tsed/core": "6.102.0",
35
- "@tsed/di": "6.102.0",
36
- "@tsed/exceptions": "6.102.0",
33
+ "@tsed/common": "6.102.4",
34
+ "@tsed/core": "6.102.4",
35
+ "@tsed/di": "6.102.4",
36
+ "@tsed/exceptions": "6.102.4",
37
37
  "@types/lowdb": "1.0.9",
38
38
  "@types/oidc-provider": "^7.1.1",
39
39
  "@types/uuid": "8.3.0",
40
40
  "oidc-provider": "7.10.1"
41
41
  },
42
42
  "peerDependencies": {
43
- "@tsed/common": "^6.102.0",
44
- "@tsed/core": "^6.102.0",
45
- "@tsed/di": "^6.102.0",
46
- "@tsed/exceptions": "^6.102.0",
47
- "@tsed/json-mapper": "^6.102.0",
48
- "@tsed/logger": ">=6.0.0",
49
- "@tsed/openspec": "^6.102.0",
50
- "@tsed/schema": "^6.102.0",
51
43
  "oidc-provider": ">=7.3.0"
52
44
  },
53
45
  "repository": "https://github.com/tsedio/tsed",
package/readme.md CHANGED
@@ -32,7 +32,7 @@ A package of Ts.ED framework. See website: https://tsed.io/tutorials/oidc-provid
32
32
  ## Feature
33
33
 
34
34
  Currently, `@tsed/oidc-provider` allows you:
35
-
35
+
36
36
  - Configure the server with [oidc-provider](https://github.com/panva/node-oidc-provider)
37
37
  - Configure Clients and Accounts classes to manage clients and accounts
38
38
  - Configure an adapter to connect your oidc to any database
@@ -42,6 +42,7 @@ Currently, `@tsed/oidc-provider` allows you:
42
42
  ## Installation
43
43
 
44
44
  To begin, install the oidc-provider module for TS.ED:
45
+
45
46
  ```bash
46
47
  npm install --save @tsed/oidc-provider
47
48
  npm install --save oidc-provider
@@ -58,35 +59,32 @@ import {MemoryAdapter} from "../adapters/MemoryAdapter";
58
59
  export const rootDir = __dirname;
59
60
 
60
61
  @Configuration({
61
- oidc: {
62
- jwksPath: `${rootDir}/../keys/jwks.json`, // don't forget add this path to .gitignore
63
- Adapter: MemoryAdapter,
64
- Accounts: Accounts,
65
- // Clients: Clients,
66
- clients: [
67
- {
68
- client_id: "client_id",
69
- client_secret: "client_secret",
70
- redirect_uris: [
71
- "https://host.fr/"
72
- ]
73
- }
74
- ],
75
- options: { // Oidc-provider options See https://github.com/panva/node-oidc-provider/blob/master/docs/README.md
76
- formats: {
77
- AccessToken: "jwt"
78
- },
79
- features: {
80
- encryption: {enabled: true},
81
- introspection: {enabled: true},
82
- revocation: {enabled: true}
83
- }
84
- }
85
- }
62
+ oidc: {
63
+ jwksPath: `${rootDir}/../keys/jwks.json`, // don't forget add this path to .gitignore
64
+ Adapter: MemoryAdapter,
65
+ Accounts: Accounts,
66
+ // Clients: Clients,
67
+ clients: [
68
+ {
69
+ client_id: "client_id",
70
+ client_secret: "client_secret",
71
+ redirect_uris: ["https://host.fr/"]
72
+ }
73
+ ],
74
+ options: {
75
+ // Oidc-provider options See https://github.com/panva/node-oidc-provider/blob/master/docs/README.md
76
+ formats: {
77
+ AccessToken: "jwt"
78
+ },
79
+ features: {
80
+ encryption: {enabled: true},
81
+ introspection: {enabled: true},
82
+ revocation: {enabled: true}
83
+ }
84
+ }
85
+ }
86
86
  })
87
- export class Server {
88
-
89
- }
87
+ export class Server {}
90
88
  ```
91
89
 
92
90
  ## Contributors
@@ -95,14 +93,12 @@ Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
95
93
 
96
94
  <a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
97
95
 
98
-
99
96
  ## Backers
100
97
 
101
98
  Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
102
99
 
103
100
  <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
104
101
 
105
-
106
102
  ## Sponsors
107
103
 
108
104
  Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
@@ -8,16 +8,5 @@
8
8
  "declaration": true,
9
9
  "declarationDir": "./lib/types"
10
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
- ]
11
+ "exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
23
12
  }