@tsed/oidc-provider 7.0.0-beta.3 → 7.0.0-beta.6
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 +2 -2
- package/lib/cjs/OidcModule.js +20 -16
- package/lib/cjs/OidcModule.js.map +1 -1
- package/lib/cjs/constants/{index.js → constants.js} +1 -1
- package/lib/cjs/constants/constants.js.map +1 -0
- package/lib/cjs/decorators/grantId.js +1 -1
- package/lib/cjs/decorators/grantId.js.map +1 -1
- package/lib/cjs/decorators/interaction.js +1 -1
- package/lib/cjs/decorators/interaction.js.map +1 -1
- package/lib/cjs/decorators/interactions.js +1 -1
- package/lib/cjs/decorators/interactions.js.map +1 -1
- package/lib/cjs/decorators/oidcCtx.js +1 -1
- package/lib/cjs/decorators/oidcCtx.js.map +1 -1
- package/lib/cjs/decorators/oidcSession.js +1 -1
- package/lib/cjs/decorators/oidcSession.js.map +1 -1
- package/lib/cjs/decorators/params.js +1 -1
- package/lib/cjs/decorators/params.js.map +1 -1
- package/lib/cjs/decorators/prompt.js +1 -1
- package/lib/cjs/decorators/prompt.js.map +1 -1
- package/lib/cjs/decorators/uid.js +1 -1
- package/lib/cjs/decorators/uid.js.map +1 -1
- package/lib/cjs/domain/OidcAccountsMethods.js.map +1 -1
- package/lib/cjs/domain/interfaces.js +3 -0
- package/lib/cjs/domain/interfaces.js.map +1 -0
- package/lib/cjs/index.js +29 -11
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/middlewares/OidcInteractionMiddleware.js +11 -11
- package/lib/cjs/middlewares/OidcInteractionMiddleware.js.map +1 -1
- package/lib/cjs/middlewares/OidcNoCacheMiddleware.js +6 -6
- package/lib/cjs/middlewares/OidcNoCacheMiddleware.js.map +1 -1
- package/lib/cjs/middlewares/OidcSecureMiddleware.js +7 -7
- package/lib/cjs/middlewares/OidcSecureMiddleware.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/OidcAdapters.js +3 -3
- package/lib/cjs/services/OidcAdapters.js.map +1 -1
- package/lib/cjs/services/OidcInteractionContext.js +9 -9
- package/lib/cjs/services/OidcInteractionContext.js.map +1 -1
- package/lib/cjs/services/OidcInteractions.js +8 -8
- package/lib/cjs/services/OidcInteractions.js.map +1 -1
- package/lib/cjs/services/OidcJwks.js +5 -5
- package/lib/cjs/services/OidcProvider.js +24 -24
- package/lib/cjs/services/OidcProvider.js.map +1 -1
- package/lib/cjs/utils/debug.js +1 -1
- package/lib/cjs/utils/debug.js.map +1 -1
- package/lib/esm/OidcModule.js +12 -8
- package/lib/esm/OidcModule.js.map +1 -1
- package/lib/esm/constants/{index.js → constants.js} +1 -1
- package/lib/esm/constants/constants.js.map +1 -0
- package/lib/esm/decorators/grantId.js +1 -1
- package/lib/esm/decorators/grantId.js.map +1 -1
- package/lib/esm/decorators/interaction.js +1 -1
- package/lib/esm/decorators/interaction.js.map +1 -1
- package/lib/esm/decorators/interactions.js +3 -3
- package/lib/esm/decorators/interactions.js.map +1 -1
- package/lib/esm/decorators/noCache.js +1 -1
- package/lib/esm/decorators/oidcCtx.js +1 -1
- package/lib/esm/decorators/oidcCtx.js.map +1 -1
- package/lib/esm/decorators/oidcSession.js +1 -1
- package/lib/esm/decorators/oidcSession.js.map +1 -1
- package/lib/esm/decorators/params.js +1 -1
- package/lib/esm/decorators/params.js.map +1 -1
- package/lib/esm/decorators/prompt.js +1 -1
- package/lib/esm/decorators/prompt.js.map +1 -1
- package/lib/esm/decorators/uid.js +1 -1
- package/lib/esm/decorators/uid.js.map +1 -1
- package/lib/esm/domain/OidcAccountsMethods.js.map +1 -1
- package/lib/esm/domain/interfaces.js +2 -0
- package/lib/esm/domain/interfaces.js.map +1 -0
- package/lib/esm/index.js +29 -11
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/middlewares/OidcInteractionMiddleware.js +3 -3
- package/lib/esm/middlewares/OidcInteractionMiddleware.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/OidcInteractionContext.js +3 -3
- package/lib/esm/services/OidcInteractionContext.js.map +1 -1
- package/lib/esm/services/OidcInteractions.js +1 -1
- package/lib/esm/services/OidcInteractions.js.map +1 -1
- package/lib/esm/services/OidcProvider.js +4 -4
- package/lib/esm/services/OidcProvider.js.map +1 -1
- package/lib/types/constants/{index.d.ts → constants.d.ts} +0 -0
- package/lib/types/decorators/interaction.d.ts +1 -1
- package/lib/types/domain/OidcAccountsMethods.d.ts +2 -1
- package/lib/types/domain/interfaces.d.ts +3 -0
- package/lib/types/index.d.ts +22 -4
- package/lib/types/services/OidcInteractionContext.d.ts +3 -2
- package/lib/types/services/OidcInteractions.d.ts +1 -1
- package/lib/types/services/OidcProvider.d.ts +1 -1
- package/package.json +21 -21
- package/readme.md +27 -33
- package/tsconfig.compile.esm.json +1 -12
- package/lib/cjs/constants/index.js.map +0 -1
- package/lib/cjs/decorators/index.js +0 -13
- package/lib/cjs/decorators/index.js.map +0 -1
- package/lib/cjs/domain/index.js +0 -9
- package/lib/cjs/domain/index.js.map +0 -1
- package/lib/esm/constants/index.js.map +0 -1
- package/lib/esm/decorators/index.js +0 -10
- package/lib/esm/decorators/index.js.map +0 -1
- package/lib/esm/domain/index.js +0 -6
- package/lib/esm/domain/index.js.map +0 -1
- package/lib/types/decorators/index.d.ts +0 -9
- package/lib/types/domain/index.d.ts +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcInteractionContext.js","sourceRoot":"","sources":["../../../src/services/OidcInteractionContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"OidcInteractionContext.js","sourceRoot":"","sources":["../../../src/services/OidcInteractionContext.ts"],"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;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhHC;IADC,QAAQ,CAAC,KAAK,CAAC;;mDACP;AAGT;IADC,MAAM,EAAE;8BACe,YAAY;4DAAC;AAGrC;IADC,MAAM,EAAE;8BACmB,gBAAgB;gEAAC;AAG7C;IADC,MAAM,EAAE;8BACU,eAAe;uDAAC;AAXxB,sBAAsB;IAFlC,UAAU,EAAE;IACZ,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;GAChB,sBAAsB,CAkHlC;SAlHY,sBAAsB","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/oidcSession\";\nimport {OidcClient} from \"../domain/interfaces\";\nimport {OidcInteraction} from \"../domain/OidcInteraction\";\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"]}
|
|
@@ -2,7 +2,7 @@ import { __decorate, __metadata } from "tslib";
|
|
|
2
2
|
import { Constant, EndpointMetadata, PlatformHandler } from "@tsed/common";
|
|
3
3
|
import { Env } from "@tsed/core";
|
|
4
4
|
import { Inject, Injectable, InjectorService } from "@tsed/di";
|
|
5
|
-
import { INTERACTION, INTERACTION_OPTIONS, INTERACTIONS } from "../constants";
|
|
5
|
+
import { INTERACTION, INTERACTION_OPTIONS, INTERACTIONS } from "../constants/constants.js";
|
|
6
6
|
let OidcInteractions = class OidcInteractions {
|
|
7
7
|
constructor() {
|
|
8
8
|
this.interactions = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcInteractions.js","sourceRoot":"","sources":["../../../src/services/OidcInteractions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAmB,eAAe,EAA0B,MAAM,cAAc,CAAC;AACnH,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAE,YAAY,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"OidcInteractions.js","sourceRoot":"","sources":["../../../src/services/OidcInteractions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAmB,eAAe,EAA0B,MAAM,cAAc,CAAC;AACnH,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAE,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAKtF,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,eAAe,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,mBAAmB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AS,CAAC,CAAC;gBAErE,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC;YAC/C,CAAC,CAAC;SACH;IACH,CAAC;CACF,CAAA;AApDC;IADC,MAAM,EAAE;8BACC,eAAe;kDAAC;AAG1B;IADC,QAAQ,CAAC,KAAK,CAAC;;6CACP;AAGT;IADC,QAAQ,CAAC,MAAM,CAAC;;sDACU;AARhB,gBAAgB;IAD5B,UAAU,EAAE;GACA,gBAAgB,CAsD5B;SAtDY,gBAAgB","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/constants\";\nimport {OidcInteractionOptions} from \"../domain/OidcInteractionOptions\";\nimport {OidcSettings} from \"../domain/OidcSettings\";\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"]}
|
|
@@ -2,10 +2,10 @@ import { __decorate, __metadata } from "tslib";
|
|
|
2
2
|
import { Env, setValue } from "@tsed/core";
|
|
3
3
|
import { Constant, Inject, Injectable, InjectorService } from "@tsed/di";
|
|
4
4
|
import { Provider as OIDCProvider, interactionPolicy } from "oidc-provider";
|
|
5
|
-
import { INTERACTIONS } from "../constants";
|
|
6
|
-
import { OidcAdapters } from "./OidcAdapters";
|
|
7
|
-
import { OidcInteractions } from "./OidcInteractions";
|
|
8
|
-
import { OidcJwks } from "./OidcJwks";
|
|
5
|
+
import { INTERACTIONS } from "../constants/constants.js";
|
|
6
|
+
import { OidcAdapters } from "./OidcAdapters.js";
|
|
7
|
+
import { OidcInteractions } from "./OidcInteractions.js";
|
|
8
|
+
import { OidcJwks } from "./OidcJwks.js";
|
|
9
9
|
import { PlatformApplication } from "@tsed/common";
|
|
10
10
|
let OidcProvider = class OidcProvider {
|
|
11
11
|
hasConfiguration() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcProvider.js","sourceRoot":"","sources":["../../../src/services/OidcProvider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,UAAU,CAAC;AACvE,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAiB,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACzF,OAAO,EAAC,YAAY,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"OidcProvider.js","sourceRoot":"","sources":["../../../src/services/Oid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CAAC,KAAK,CAAC;;yCACG;AAGnB;IADC,QAAQ,CAAC,UAAU,CAAC;;8CACe;AAGpC;IADC,QAAQ,CAAC,WAAW,CAAC;;+CACe;AAGrC;IADC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;;4CACH;AAGzB;IADC,QAAQ,CAAC,MAAM,CAAC;;0CACY;AAG7B;IADC,QAAQ,CAAC,eAAe,CAAC;;kDACK;AAG/B;IADC,MAAM,EAAE;8BACW,QAAQ;8CAAC;AAG7B;IADC,MAAM,EAAE;8BACmB,gBAAgB;sDAAC;AAG7C;IADC,MAAM,EAAE;8BACW,YAAY;8CAAC;AAGjC;IADC,MAAM,EAAE;8BACW,eAAe;8CAAC;AAGpC;IADC,MAAM,EAAE;8BACM,mBAAmB;yCAAC;AAlCxB,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CAqLxB;SArLY,YAAY","sourcesContent":["import {Env, setValue} from \"@tsed/core\";\nimport {Constant, Inject, Injectable, InjectorService} from \"@tsed/di\";\nimport {Provider as OIDCProvider, Configuration, interactionPolicy} from \"oidc-provider\";\nimport {INTERACTIONS} from \"../constants/constants\";\nimport {OidcAdapters} from \"./OidcAdapters\";\nimport {OidcInteractions} from \"./OidcInteractions\";\nimport {OidcJwks} from \"./OidcJwks\";\nimport {PlatformApplication} from \"@tsed/common\";\nimport {OidcSettings} from \"../domain/OidcSettings\";\nimport {OidcAccountsMethods} from \"../domain/OidcAccountsMethods\";\n\n@Injectable()\nexport class OidcProvider {\n raw: OIDCProvider;\n\n @Constant(\"env\")\n protected env: Env;\n\n @Constant(\"httpPort\")\n protected httpPort: number | string;\n\n @Constant(\"httpsPort\")\n protected httpsPort: number | string;\n\n @Constant(\"oidc.issuer\", \"\")\n protected issuer: string;\n\n @Constant(\"oidc\")\n protected oidc: OidcSettings;\n\n @Constant(\"PLATFORM_NAME\")\n protected platformName: string;\n\n @Inject()\n protected oidcJwks: OidcJwks;\n\n @Inject()\n protected oidcInteractions: OidcInteractions;\n\n @Inject()\n protected adapters: OidcAdapters;\n\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected app: PlatformApplication;\n\n hasConfiguration() {\n return !!this.oidc;\n }\n\n async getConfiguration(): Promise<Configuration> {\n const [jwks, adapter] = await Promise.all([this.oidcJwks.getJwks(), this.adapters.createAdapterClass()]);\n const {issuer, jwksPath, secureKey, proxy, Accounts, ...options} = this.oidc;\n\n const configuration: Configuration = {\n interactions: {\n /* istanbul ignore next */\n url: (ctx, interaction) => `interaction/${interaction.uid}`\n },\n ...options,\n adapter,\n jwks\n };\n\n if (Accounts) {\n configuration.findAccount = (ctx, id, token) =>\n this.injector.get<OidcAccountsMethods>(Accounts)!.findAccount(id, token, (ctx.req as any).$ctx);\n }\n\n if (this.env === Env.PROD) {\n setValue(configuration, \"cookies.short.secure\", true);\n setValue(configuration, \"cookies.long.secure\", true);\n }\n\n const policy = this.getPolicy();\n if (policy) {\n setValue(configuration, \"interactions.policy\", policy);\n }\n\n const url = this.getInteractionsUrl();\n if (url) {\n setValue(configuration, \"interactions.url\", url);\n }\n\n return configuration;\n }\n\n getIssuer() {\n if (this.issuer) {\n return this.issuer;\n }\n\n // istanbul ignore next\n if (this.httpsPort) {\n return `https://localhost:${this.httpsPort}`;\n }\n\n return `http://localhost:${this.httpPort}`;\n }\n\n get(): OIDCProvider {\n return this.raw;\n }\n\n /**\n * Create a new instance of OidcProvider\n */\n async create(): Promise<void | OIDCProvider> {\n const {proxy, secureKey} = this.oidc;\n const configuration = await this.getConfiguration();\n const oidcProvider = new OIDCProvider(this.getIssuer(), configuration);\n\n if (proxy || this.env === Env.PROD) {\n // istanbul ignore next\n switch (this.platformName) {\n default:\n case \"express\":\n oidcProvider.proxy = true;\n break;\n case \"koa\":\n (this.app.rawApp as any).proxy = true;\n break;\n }\n }\n\n if (secureKey) {\n oidcProvider.app.keys = secureKey;\n }\n\n this.raw = oidcProvider;\n\n if (this.env !== Env.PROD) {\n this.allowHttpLocalhost();\n }\n\n await this.injector.emit(\"$onCreateOIDC\", this.raw);\n\n return this.raw;\n }\n\n private getInteractionsUrl() {\n const provider = this.injector.getProviders().find((provider) => provider.subType === INTERACTIONS);\n\n if (provider) {\n return (ctx: any, interaction: any) => {\n // eslint-disable-line no-unused-vars\n return provider.path.replace(/:uid/, interaction.uid);\n };\n }\n }\n\n private allowHttpLocalhost() {\n const {invalidate: orig} = (this.raw.Client as any).Schema.prototype;\n\n (this.raw.Client as any).Schema.prototype.invalidate = function invalidate(message: string, code: string) {\n if (code === \"implicit-force-https\" || code === \"implicit-forbid-localhost\") {\n return;\n }\n\n /* istanbul ignore next */\n return orig.call(this, message);\n };\n }\n\n private getPolicy() {\n const policy = interactionPolicy.base();\n const interactions = this.oidcInteractions.getInteractions();\n\n if (interactions.length) {\n interactions.forEach((provider) => {\n const {name, ...options} = provider.store.get(\"interactionOptions\");\n\n if (!policy.get(name)) {\n policy.add(\n new interactionPolicy.Prompt({\n name,\n ...options\n })\n );\n }\n\n const instance = this.injector.get(provider.token);\n\n if (instance.$onCreate) {\n instance.$onCreate(policy.get(name));\n }\n });\n }\n\n return this.injector.alter(\"$alterOidcPolicy\", policy);\n }\n}\n"]}
|
|
File without changes
|
|
@@ -3,6 +3,7 @@ import { Provider, Account } from "oidc-provider";
|
|
|
3
3
|
export declare type AuthorizationCode = InstanceType<Provider["AuthorizationCode"]>;
|
|
4
4
|
export declare type AccessToken = InstanceType<Provider["AccessToken"]>;
|
|
5
5
|
export declare type DeviceCode = InstanceType<Provider["DeviceCode"]>;
|
|
6
|
+
export declare type BackchannelAuthenticationRequest = InstanceType<Provider["BackchannelAuthenticationRequest"]>;
|
|
6
7
|
export interface OidcAccountsMethods {
|
|
7
|
-
findAccount(id: string, token: AuthorizationCode | AccessToken | DeviceCode | undefined, ctx: PlatformContext): Promise<Account | undefined>;
|
|
8
|
+
findAccount(id: string, token: AuthorizationCode | AccessToken | DeviceCode | BackchannelAuthenticationRequest | undefined, ctx: PlatformContext): Promise<Account | undefined>;
|
|
8
9
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./OidcModule";
|
|
5
|
+
export * from "./constants/constants";
|
|
6
|
+
export * from "./decorators/grantId";
|
|
7
|
+
export * from "./decorators/interaction";
|
|
8
|
+
export * from "./decorators/interactions";
|
|
9
|
+
export * from "./decorators/noCache";
|
|
10
|
+
export * from "./decorators/oidcCtx";
|
|
11
|
+
export * from "./decorators/oidcSession";
|
|
12
|
+
export * from "./decorators/params";
|
|
13
|
+
export * from "./decorators/prompt";
|
|
14
|
+
export * from "./decorators/uid";
|
|
15
|
+
export * from "./domain/OidcAccountsMethods";
|
|
16
|
+
export * from "./domain/OidcInteraction";
|
|
17
|
+
export * from "./domain/OidcInteractionMethods";
|
|
18
|
+
export * from "./domain/OidcInteractionOptions";
|
|
19
|
+
export * from "./domain/OidcSettings";
|
|
20
|
+
export * from "./domain/interfaces";
|
|
3
21
|
export * from "./middlewares/OidcInteractionMiddleware";
|
|
4
22
|
export * from "./middlewares/OidcNoCacheMiddleware";
|
|
5
23
|
export * from "./middlewares/OidcSecureMiddleware";
|
|
6
24
|
export * from "./services/OidcAdapters";
|
|
7
|
-
export * from "./services/OidcInteractions";
|
|
8
25
|
export * from "./services/OidcInteractionContext";
|
|
26
|
+
export * from "./services/OidcInteractions";
|
|
9
27
|
export * from "./services/OidcJwks";
|
|
10
28
|
export * from "./services/OidcProvider";
|
|
11
|
-
export * from "./
|
|
29
|
+
export * from "./utils/debug";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { PlatformContext } from "@tsed/common";
|
|
2
2
|
import { Env } from "@tsed/core";
|
|
3
3
|
import { Account, InteractionResults, PromptDetail, Provider } from "oidc-provider";
|
|
4
|
-
import { OidcSession } from "../decorators";
|
|
5
|
-
import { OidcClient
|
|
4
|
+
import { OidcSession } from "../decorators/oidcSession";
|
|
5
|
+
import { OidcClient } from "../domain/interfaces";
|
|
6
|
+
import { OidcInteraction } from "../domain/OidcInteraction";
|
|
6
7
|
import { OidcInteractions } from "./OidcInteractions";
|
|
7
8
|
import { OidcProvider } from "./OidcProvider";
|
|
8
9
|
export declare class OidcInteractionContext {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlatformContext, Provider } from "@tsed/common";
|
|
2
2
|
import { Env } from "@tsed/core";
|
|
3
3
|
import { InjectorService } from "@tsed/di";
|
|
4
|
-
import { OidcSettings } from "../domain";
|
|
4
|
+
import { OidcSettings } from "../domain/OidcSettings";
|
|
5
5
|
export declare class OidcInteractions {
|
|
6
6
|
injector: InjectorService;
|
|
7
7
|
env: Env;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Env } from "@tsed/core";
|
|
2
2
|
import { InjectorService } from "@tsed/di";
|
|
3
3
|
import { Provider as OIDCProvider, Configuration } from "oidc-provider";
|
|
4
|
-
import { OidcSettings } from "../domain";
|
|
5
4
|
import { OidcAdapters } from "./OidcAdapters";
|
|
6
5
|
import { OidcInteractions } from "./OidcInteractions";
|
|
7
6
|
import { OidcJwks } from "./OidcJwks";
|
|
8
7
|
import { PlatformApplication } from "@tsed/common";
|
|
8
|
+
import { OidcSettings } from "../domain/OidcSettings";
|
|
9
9
|
export declare class OidcProvider {
|
|
10
10
|
raw: OIDCProvider;
|
|
11
11
|
protected env: Env;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/oidc-provider",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.6",
|
|
4
4
|
"description": "OIDC provider package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/cjs/index.js",
|
|
8
|
+
"module": "./lib/esm/index.js",
|
|
8
9
|
"typings": "./lib/types/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
11
|
"types": "./lib/types/index.d.ts",
|
|
@@ -13,48 +14,47 @@
|
|
|
13
14
|
"default": "./lib/esm/index.js"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
|
-
"build": "yarn run build:esm && yarn run build:cjs",
|
|
17
|
+
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
17
18
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
18
19
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
19
20
|
"start": "ts-node -r tsconfig-paths/register test/app/index.ts",
|
|
21
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
20
22
|
"test": "cross-env NODE_ENV=test nyc mocha"
|
|
21
23
|
},
|
|
22
24
|
"dependencies": {
|
|
23
|
-
"@tsed/adapters": "7.0.0-beta.
|
|
25
|
+
"@tsed/adapters": "7.0.0-beta.6",
|
|
24
26
|
"express-urlrewrite": "^1.4.0",
|
|
25
27
|
"jose2": "npm:jose@^2.0.4",
|
|
26
28
|
"koa-mount": "^4.0.0",
|
|
27
29
|
"koa-rewrite": "^3.0.1",
|
|
28
|
-
"lowdb": "
|
|
29
|
-
"tslib": "2.
|
|
30
|
+
"lowdb": "3.0.0",
|
|
31
|
+
"tslib": "2.3.1",
|
|
30
32
|
"uuid": "8.3.2"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@tsed/common": "7.0.0-beta.
|
|
34
|
-
"@tsed/core": "7.0.0-beta.
|
|
35
|
-
"@tsed/di": "7.0.0-beta.
|
|
36
|
-
"@tsed/exceptions": "7.0.0-beta.
|
|
37
|
-
"@types/lowdb": "1.0.
|
|
35
|
+
"@tsed/common": "7.0.0-beta.6",
|
|
36
|
+
"@tsed/core": "7.0.0-beta.6",
|
|
37
|
+
"@tsed/di": "7.0.0-beta.6",
|
|
38
|
+
"@tsed/exceptions": "7.0.0-beta.6",
|
|
39
|
+
"@types/lowdb": "1.0.11",
|
|
38
40
|
"@types/oidc-provider": "^7.1.1",
|
|
39
|
-
"@types/uuid": "8.3.
|
|
40
|
-
"oidc-provider": "7.10.
|
|
41
|
+
"@types/uuid": "8.3.4",
|
|
42
|
+
"oidc-provider": "7.10.6"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
|
-
"@tsed/common": "^7.0.0-beta.
|
|
44
|
-
"@tsed/core": "^7.0.0-beta.3",
|
|
45
|
-
"@tsed/di": "^7.0.0-beta.3",
|
|
46
|
-
"@tsed/exceptions": "^7.0.0-beta.3",
|
|
47
|
-
"@tsed/json-mapper": "^7.0.0-beta.3",
|
|
48
|
-
"@tsed/logger": ">=6.0.0",
|
|
49
|
-
"@tsed/openspec": "^7.0.0-beta.3",
|
|
50
|
-
"@tsed/schema": "^7.0.0-beta.3",
|
|
45
|
+
"@tsed/common": "^7.0.0-beta.6",
|
|
51
46
|
"oidc-provider": ">=7.3.0"
|
|
52
47
|
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"@tsed/common": {
|
|
50
|
+
"optional": false
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
53
|
"repository": "https://github.com/tsedio/tsed",
|
|
54
54
|
"bugs": {
|
|
55
55
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
56
56
|
},
|
|
57
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
57
|
+
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/security/oidc-provider",
|
|
58
58
|
"author": "Romain Lenzotti",
|
|
59
59
|
"license": "MIT"
|
|
60
60
|
}
|
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
|
|
@@ -55,38 +56,33 @@ import "@tsed/oidc-provider"; // import typeorm ts.ed module
|
|
|
55
56
|
import {Accounts} from "../services/Accounts";
|
|
56
57
|
import {MemoryAdapter} from "../adapters/MemoryAdapter";
|
|
57
58
|
|
|
58
|
-
export const rootDir = __dirname;
|
|
59
|
-
|
|
60
59
|
@Configuration({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
60
|
+
oidc: {
|
|
61
|
+
jwksPath: `./../keys/jwks.json`, // don't forget add this path to .gitignore
|
|
62
|
+
Adapter: MemoryAdapter,
|
|
63
|
+
Accounts: Accounts,
|
|
64
|
+
// Clients: Clients,
|
|
65
|
+
clients: [
|
|
66
|
+
{
|
|
67
|
+
client_id: "client_id",
|
|
68
|
+
client_secret: "client_secret",
|
|
69
|
+
redirect_uris: ["https://host.fr/"]
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
options: {
|
|
73
|
+
// Oidc-provider options See https://github.com/panva/node-oidc-provider/blob/master/docs/README.md
|
|
74
|
+
formats: {
|
|
75
|
+
AccessToken: "jwt"
|
|
76
|
+
},
|
|
77
|
+
features: {
|
|
78
|
+
encryption: {enabled: true},
|
|
79
|
+
introspection: {enabled: true},
|
|
80
|
+
revocation: {enabled: true}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
86
84
|
})
|
|
87
|
-
export class Server {
|
|
88
|
-
|
|
89
|
-
}
|
|
85
|
+
export class Server {}
|
|
90
86
|
```
|
|
91
87
|
|
|
92
88
|
## Contributors
|
|
@@ -95,14 +91,12 @@ Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
|
|
|
95
91
|
|
|
96
92
|
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
|
|
97
93
|
|
|
98
|
-
|
|
99
94
|
## Backers
|
|
100
95
|
|
|
101
96
|
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
|
|
102
97
|
|
|
103
98
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
|
|
104
99
|
|
|
105
|
-
|
|
106
100
|
## Sponsors
|
|
107
101
|
|
|
108
102
|
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
|
}
|
|
@@ -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,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
(0, tslib_1.__exportStar)(require("./interactions"), exports);
|
|
5
|
-
(0, tslib_1.__exportStar)(require("./interaction"), exports);
|
|
6
|
-
(0, tslib_1.__exportStar)(require("./noCache"), exports);
|
|
7
|
-
(0, tslib_1.__exportStar)(require("./oidcCtx"), exports);
|
|
8
|
-
(0, tslib_1.__exportStar)(require("./oidcSession"), exports);
|
|
9
|
-
(0, tslib_1.__exportStar)(require("./params"), exports);
|
|
10
|
-
(0, tslib_1.__exportStar)(require("./prompt"), exports);
|
|
11
|
-
(0, tslib_1.__exportStar)(require("./uid"), exports);
|
|
12
|
-
(0, 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,8DAA+B;AAC/B,6DAA8B;AAC9B,yDAA0B;AAC1B,yDAA0B;AAC1B,6DAA8B;AAC9B,wDAAyB;AACzB,wDAAyB;AACzB,qDAAsB;AACtB,yDAA0B","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"]}
|
package/lib/cjs/domain/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
(0, tslib_1.__exportStar)(require("./OidcAccountsMethods"), exports);
|
|
5
|
-
(0, tslib_1.__exportStar)(require("./OidcInteraction"), exports);
|
|
6
|
-
(0, tslib_1.__exportStar)(require("./OidcInteractionMethods"), exports);
|
|
7
|
-
(0, tslib_1.__exportStar)(require("./OidcInteractionOptions"), exports);
|
|
8
|
-
(0, 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,qEAAsC;AACtC,iEAAkC;AAClC,wEAAyC;AACzC,wEAAyC;AACzC,8DAA+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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AACxD,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC","sourcesContent":["export const INTERACTION_CONTEXT = \"interactionContext\";\nexport const INTERACTION_PARAMS = \"interactionParams\";\nexport const INTERACTION_GRANT_ID = \"interactionGrantId\";\nexport const INTERACTION_PROMPT = \"interactionPrompt\";\nexport const INTERACTION_UID = \"interactionUid\";\nexport const INTERACTION_SESSION = \"interactionSession\";\nexport const INTERACTION_DETAILS = \"interactionDetails\";\nexport const INTERACTION_OPTIONS = \"interactionOptions\";\nexport const INTERACTION = \"interaction\";\nexport const INTERACTIONS = \"interactions\";\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./interactions";
|
|
2
|
-
export * from "./interaction";
|
|
3
|
-
export * from "./noCache";
|
|
4
|
-
export * from "./oidcCtx";
|
|
5
|
-
export * from "./oidcSession";
|
|
6
|
-
export * from "./params";
|
|
7
|
-
export * from "./prompt";
|
|
8
|
-
export * from "./uid";
|
|
9
|
-
export * from "./grantId";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC","sourcesContent":["export * from \"./interactions\";\nexport * from \"./interaction\";\nexport * from \"./noCache\";\nexport * from \"./oidcCtx\";\nexport * from \"./oidcSession\";\nexport * from \"./params\";\nexport * from \"./prompt\";\nexport * from \"./uid\";\nexport * from \"./grantId\";\n"]}
|
package/lib/esm/domain/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/index.ts"],"names":[],"mappings":"AAEA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC","sourcesContent":["import {Provider, interactionPolicy} from \"oidc-provider\";\n\nexport * from \"./OidcAccountsMethods\";\nexport * from \"./OidcInteraction\";\nexport * from \"./OidcInteractionMethods\";\nexport * from \"./OidcInteractionOptions\";\nexport * from \"./OidcSettings\";\n\nexport type OidcClient = InstanceType<Provider[\"Client\"]>;\nexport type DefaultPolicy = interactionPolicy.DefaultPolicy;\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
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";
|
|
@@ -1,8 +0,0 @@
|
|
|
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;
|