@tsed/oidc-provider 8.0.0-alpha.4 → 8.0.0-alpha.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.
Files changed (101) hide show
  1. package/lib/esm/services/OidcInteractionContext.js +1 -1
  2. package/lib/esm/services/OidcInteractionContext.js.map +1 -1
  3. package/package.json +17 -18
  4. package/lib/cjs/OidcModule.js +0 -84
  5. package/lib/cjs/OidcModule.js.map +0 -1
  6. package/lib/cjs/constants/constants.js +0 -14
  7. package/lib/cjs/constants/constants.js.map +0 -1
  8. package/lib/cjs/decorators/grantId.js +0 -11
  9. package/lib/cjs/decorators/grantId.js.map +0 -1
  10. package/lib/cjs/decorators/interaction.js +0 -17
  11. package/lib/cjs/decorators/interaction.js.map +0 -1
  12. package/lib/cjs/decorators/interactions.js +0 -14
  13. package/lib/cjs/decorators/interactions.js.map +0 -1
  14. package/lib/cjs/decorators/noCache.js +0 -10
  15. package/lib/cjs/decorators/noCache.js.map +0 -1
  16. package/lib/cjs/decorators/oidcCtx.js +0 -11
  17. package/lib/cjs/decorators/oidcCtx.js.map +0 -1
  18. package/lib/cjs/decorators/oidcSession.js +0 -14
  19. package/lib/cjs/decorators/oidcSession.js.map +0 -1
  20. package/lib/cjs/decorators/params.js +0 -11
  21. package/lib/cjs/decorators/params.js.map +0 -1
  22. package/lib/cjs/decorators/prompt.js +0 -11
  23. package/lib/cjs/decorators/prompt.js.map +0 -1
  24. package/lib/cjs/decorators/uid.js +0 -11
  25. package/lib/cjs/decorators/uid.js.map +0 -1
  26. package/lib/cjs/domain/InteractionMethods.js +0 -3
  27. package/lib/cjs/domain/InteractionMethods.js.map +0 -1
  28. package/lib/cjs/domain/OidcAccountsMethods.js +0 -3
  29. package/lib/cjs/domain/OidcAccountsMethods.js.map +0 -1
  30. package/lib/cjs/domain/OidcBadInteractionName.js +0 -8
  31. package/lib/cjs/domain/OidcBadInteractionName.js.map +0 -1
  32. package/lib/cjs/domain/OidcInteractionMethods.js +0 -3
  33. package/lib/cjs/domain/OidcInteractionMethods.js.map +0 -1
  34. package/lib/cjs/domain/OidcInteractionOptions.js +0 -3
  35. package/lib/cjs/domain/OidcInteractionOptions.js.map +0 -1
  36. package/lib/cjs/domain/OidcInteractionPromptProps.js +0 -3
  37. package/lib/cjs/domain/OidcInteractionPromptProps.js.map +0 -1
  38. package/lib/cjs/domain/OidcSettings.js +0 -3
  39. package/lib/cjs/domain/OidcSettings.js.map +0 -1
  40. package/lib/cjs/domain/interfaces.js +0 -3
  41. package/lib/cjs/domain/interfaces.js.map +0 -1
  42. package/lib/cjs/index.js +0 -38
  43. package/lib/cjs/index.js.map +0 -1
  44. package/lib/cjs/middlewares/OidcInteractionMiddleware.js +0 -20
  45. package/lib/cjs/middlewares/OidcInteractionMiddleware.js.map +0 -1
  46. package/lib/cjs/middlewares/OidcNoCacheMiddleware.js +0 -22
  47. package/lib/cjs/middlewares/OidcNoCacheMiddleware.js.map +0 -1
  48. package/lib/cjs/middlewares/OidcSecureMiddleware.js +0 -38
  49. package/lib/cjs/middlewares/OidcSecureMiddleware.js.map +0 -1
  50. package/lib/cjs/package.json +0 -3
  51. package/lib/cjs/services/OidcAdapters.js +0 -85
  52. package/lib/cjs/services/OidcAdapters.js.map +0 -1
  53. package/lib/cjs/services/OidcInteractionContext.js +0 -165
  54. package/lib/cjs/services/OidcInteractionContext.js.map +0 -1
  55. package/lib/cjs/services/OidcInteractions.js +0 -64
  56. package/lib/cjs/services/OidcInteractions.js.map +0 -1
  57. package/lib/cjs/services/OidcJwks.js +0 -31
  58. package/lib/cjs/services/OidcJwks.js.map +0 -1
  59. package/lib/cjs/services/OidcPolicy.js +0 -78
  60. package/lib/cjs/services/OidcPolicy.js.map +0 -1
  61. package/lib/cjs/services/OidcProvider.js +0 -201
  62. package/lib/cjs/services/OidcProvider.js.map +0 -1
  63. package/lib/cjs/services/OidcProviderNodeModule.js +0 -16
  64. package/lib/cjs/services/OidcProviderNodeModule.js.map +0 -1
  65. package/lib/cjs/utils/debug.js +0 -25
  66. package/lib/cjs/utils/debug.js.map +0 -1
  67. package/lib/cjs/utils/events.js +0 -64
  68. package/lib/cjs/utils/events.js.map +0 -1
  69. package/lib/esm/package.json +0 -3
  70. package/lib/types-esm/OidcModule.d.ts +0 -14
  71. package/lib/types-esm/constants/constants.d.ts +0 -10
  72. package/lib/types-esm/decorators/grantId.d.ts +0 -2
  73. package/lib/types-esm/decorators/interaction.d.ts +0 -5
  74. package/lib/types-esm/decorators/interactions.d.ts +0 -6
  75. package/lib/types-esm/decorators/noCache.d.ts +0 -1
  76. package/lib/types-esm/decorators/oidcCtx.d.ts +0 -3
  77. package/lib/types-esm/decorators/oidcSession.d.ts +0 -6
  78. package/lib/types-esm/decorators/params.d.ts +0 -2
  79. package/lib/types-esm/decorators/prompt.d.ts +0 -3
  80. package/lib/types-esm/decorators/uid.d.ts +0 -2
  81. package/lib/types-esm/domain/InteractionMethods.d.ts +0 -10
  82. package/lib/types-esm/domain/OidcAccountsMethods.d.ts +0 -5
  83. package/lib/types-esm/domain/OidcBadInteractionName.d.ts +0 -3
  84. package/lib/types-esm/domain/OidcInteractionMethods.d.ts +0 -3
  85. package/lib/types-esm/domain/OidcInteractionOptions.d.ts +0 -8
  86. package/lib/types-esm/domain/OidcInteractionPromptProps.d.ts +0 -9
  87. package/lib/types-esm/domain/OidcSettings.d.ts +0 -67
  88. package/lib/types-esm/domain/interfaces.d.ts +0 -12
  89. package/lib/types-esm/index.d.ts +0 -34
  90. package/lib/types-esm/middlewares/OidcInteractionMiddleware.d.ts +0 -5
  91. package/lib/types-esm/middlewares/OidcNoCacheMiddleware.d.ts +0 -4
  92. package/lib/types-esm/middlewares/OidcSecureMiddleware.d.ts +0 -4
  93. package/lib/types-esm/services/OidcAdapters.d.ts +0 -9
  94. package/lib/types-esm/services/OidcInteractionContext.d.ts +0 -38
  95. package/lib/types-esm/services/OidcInteractions.d.ts +0 -14
  96. package/lib/types-esm/services/OidcJwks.d.ts +0 -8
  97. package/lib/types-esm/services/OidcPolicy.d.ts +0 -16
  98. package/lib/types-esm/services/OidcProvider.d.ts +0 -40
  99. package/lib/types-esm/services/OidcProviderNodeModule.d.ts +0 -7
  100. package/lib/types-esm/utils/debug.d.ts +0 -1
  101. package/lib/types-esm/utils/events.d.ts +0 -5
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OidcAdapters = void 0;
4
- const tslib_1 = require("tslib");
5
- const adapters_1 = require("@tsed/adapters");
6
- const di_1 = require("@tsed/di");
7
- let OidcAdapters = class OidcAdapters {
8
- createAdapterClass() {
9
- const self = this;
10
- const adapterBase = this.settings.get("oidc.Adapter", this.settings.get("adapters.Adapter"));
11
- const connectionName = this.settings.get("oidc.connectionName", "default");
12
- return class CustomAdapter {
13
- constructor(name) {
14
- this.adapter = self.adapters.invokeAdapter({
15
- adapter: adapterBase,
16
- collectionName: name,
17
- connectionName,
18
- model: Object
19
- });
20
- }
21
- async upsert(id, payload, expiresIn) {
22
- let expiresAt;
23
- if (expiresIn) {
24
- expiresAt = new Date(Date.now() + expiresIn * 1000);
25
- }
26
- await this.adapter.upsert(id, payload, expiresAt);
27
- }
28
- find(id) {
29
- return this.adapter.findById(id);
30
- }
31
- findByUserCode(userCode) {
32
- // istanbul ignore next
33
- if (this.adapter.findByUserCode) {
34
- return this.adapter.findByUserCode(userCode);
35
- }
36
- return this.adapter.findOne({
37
- userCode
38
- });
39
- }
40
- findByUid(uid) {
41
- // istanbul ignore next
42
- if (this.adapter.findByUid) {
43
- return this.adapter.findByUid(uid);
44
- }
45
- return this.adapter.findOne({
46
- uid
47
- });
48
- }
49
- async destroy(id) {
50
- // istanbul ignore next
51
- if (this.adapter.destroy) {
52
- return this.adapter.destroy(id);
53
- }
54
- await this.adapter.deleteById(id);
55
- }
56
- async revokeByGrantId(grantId) {
57
- // istanbul ignore next
58
- if (this.adapter.revokeByGrantId) {
59
- return this.adapter.revokeByGrantId(grantId);
60
- }
61
- await this.adapter.deleteMany({ grantId });
62
- }
63
- async consume(grantId) {
64
- // istanbul ignore next
65
- if (this.adapter.consume) {
66
- return this.adapter.consume(grantId);
67
- }
68
- await this.adapter.update(grantId, { consumed: Math.floor(Date.now() / 1000) });
69
- }
70
- };
71
- }
72
- };
73
- tslib_1.__decorate([
74
- (0, di_1.Inject)(),
75
- tslib_1.__metadata("design:type", adapters_1.Adapters)
76
- ], OidcAdapters.prototype, "adapters", void 0);
77
- tslib_1.__decorate([
78
- (0, di_1.Configuration)(),
79
- tslib_1.__metadata("design:type", Object)
80
- ], OidcAdapters.prototype, "settings", void 0);
81
- OidcAdapters = tslib_1.__decorate([
82
- (0, di_1.Injectable)()
83
- ], OidcAdapters);
84
- exports.OidcAdapters = OidcAdapters;
85
- //# sourceMappingURL=OidcAdapters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcAdapters.js","sourceRoot":"","sources":["../../../src/services/OidcAdapters.ts"],"names":[],"mappings":";;;;AAAA,6CAAiD;AACjD,iCAA2D;AAOpD,IAAM,YAAY,GAAlB,MAAM,YAAY;IAOvB,kBAAkB;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAC7F,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;QAE3E,OAAO,MAAM,aAAa;YAGxB,YAAY,IAAY;gBACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAM;oBAC9C,OAAO,EAAE,WAAW;oBACpB,cAAc,EAAE,IAAI;oBACpB,cAAc;oBACd,KAAK,EAAE,MAAM;iBACd,CAAuB,CAAC;YAC3B,CAAC;YAED,KAAK,CAAC,MAAM,CAAC,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AC,OAAO,CAAC,eAAe,EAAE;oBAChC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;iBAC9C;gBAED,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAC,OAAO,EAAC,CAAC,CAAC;YAC3C,CAAC;YAED,KAAK,CAAC,OAAO,CAAC,OAAe;gBAC3B,uBAAuB;gBACvB,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;oBACxB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;iBACtC;gBAED,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;AAvFC;IAAC,IAAA,WAAM,GAAE;sCACW,mBAAQ;8CAAC;AAE7B;IAAC,IAAA,kBAAa,GAAE;;8CACkB;AALvB,YAAY;IADxB,IAAA,eAAU,GAAE;GACA,YAAY,CAwFxB;AAxFY,oCAAY"}
@@ -1,165 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OidcInteractionContext = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const core_1 = require("@tsed/core");
7
- const di_1 = require("@tsed/di");
8
- const exceptions_1 = require("@tsed/exceptions");
9
- const constants_js_1 = require("../constants/constants.js");
10
- const OidcBadInteractionName_js_1 = require("../domain/OidcBadInteractionName.js");
11
- const debug_js_1 = require("../utils/debug.js");
12
- const OidcInteractions_js_1 = require("./OidcInteractions.js");
13
- const OidcProvider_js_1 = require("./OidcProvider.js");
14
- const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
15
- let OidcInteractionContext = class OidcInteractionContext {
16
- get raw() {
17
- return this.$ctx.get(constants_js_1.INTERACTION_DETAILS);
18
- }
19
- get session() {
20
- return this.raw.session;
21
- }
22
- get prompt() {
23
- return this.raw.prompt;
24
- }
25
- get params() {
26
- return this.raw.params;
27
- }
28
- get uid() {
29
- return this.raw.uid;
30
- }
31
- get grantId() {
32
- return this.raw.grantId;
33
- }
34
- async runInteraction(name) {
35
- name = name || this.prompt.name;
36
- const handler = this.oidcInteractions.getInteractionHandler(name);
37
- if (handler) {
38
- this.raw.prompt = {
39
- ...this.raw.prompt,
40
- name,
41
- reasons: [name]
42
- };
43
- await handler(this.$ctx);
44
- }
45
- }
46
- async interactionDetails() {
47
- const raw = await this.oidcProvider.get().interactionDetails(this.$ctx.getReq(), this.$ctx.getRes());
48
- const { uid, prompt, params, session, grantId } = raw;
49
- this.$ctx.set(constants_js_1.INTERACTION_CONTEXT, this);
50
- this.$ctx.set(constants_js_1.INTERACTION_DETAILS, raw);
51
- this.$ctx.set(constants_js_1.INTERACTION_UID, uid);
52
- this.$ctx.set(constants_js_1.INTERACTION_PROMPT, prompt);
53
- this.$ctx.set(constants_js_1.INTERACTION_PARAMS, params);
54
- this.$ctx.set(constants_js_1.INTERACTION_GRANT_ID, grantId);
55
- this.$ctx.set(constants_js_1.INTERACTION_SESSION, session);
56
- return raw;
57
- }
58
- interactionFinished(result, options = { mergeWithLastSubmission: false }) {
59
- return this.oidcProvider.get().interactionFinished(this.$ctx.getReq(), this.$ctx.getRes(), result, options);
60
- }
61
- interactionResult(result, options = { mergeWithLastSubmission: false }) {
62
- return this.oidcProvider.get().interactionResult(this.$ctx.getReq(), this.$ctx.getRes(), result, options);
63
- }
64
- async interactionPrompt({ client, ...options }) {
65
- client = client || (await this.findClient());
66
- return {
67
- client: (0, omit_1.default)(client, ["clientSecret", ...this.omitClientProps]),
68
- uid: this.uid,
69
- grantId: this.grantId,
70
- details: this.prompt.details,
71
- params: {
72
- ...this.params,
73
- ...options.params
74
- },
75
- ...options,
76
- ...this.debug()
77
- };
78
- }
79
- render(view, result) {
80
- return this.$ctx.response.render(view, result);
81
- }
82
- save(ttl) {
83
- return this.raw.save(ttl);
84
- }
85
- findClient(clientId = this.params.client_id) {
86
- const key = `$client:${clientId}`;
87
- return this.$ctx.cacheAsync(key, () => this.oidcProvider.get().Client.find(clientId));
88
- }
89
- findAccount(sub, token) {
90
- if (!sub && this.session) {
91
- sub = this.session?.accountId;
92
- }
93
- if (!sub) {
94
- return Promise.resolve(undefined);
95
- }
96
- const key = `$account:${sub}`;
97
- return this.$ctx.cacheAsync(key, (() => {
98
- return this.oidcProvider.get().Account.findAccount(undefined, sub, token);
99
- }));
100
- }
101
- getGrant() {
102
- const { Grant } = this.oidcProvider.get();
103
- if (this.grantId) {
104
- // we'll be modifying existing grant in existing session
105
- // @ts-ignore
106
- return Grant.find(this.grantId);
107
- }
108
- return Promise.resolve(new Grant({
109
- accountId: this.session?.accountId,
110
- clientId: this.params.client_id
111
- }));
112
- }
113
- checkInteractionName(name) {
114
- if (this.prompt.name !== name) {
115
- throw new OidcBadInteractionName_js_1.OidcBadInteractionName("Bad interaction name");
116
- }
117
- }
118
- async checkClientId(clientId = this.params.client_id) {
119
- const client = await this.findClient(clientId);
120
- if (!client) {
121
- throw new exceptions_1.Unauthorized(`Unknown client_id ${clientId}`);
122
- }
123
- }
124
- debug(obj) {
125
- /* istanbul ignore next */
126
- if (this.env === core_1.Env.PROD) {
127
- return { session: undefined, dbg: { params: undefined, prompt: undefined } };
128
- }
129
- if (obj) {
130
- return (0, debug_js_1.debug)(obj);
131
- }
132
- return {
133
- session: this.session ? this.debug(this.session) : undefined,
134
- dbg: {
135
- params: this.debug(this.params),
136
- prompt: this.debug(this.prompt)
137
- }
138
- };
139
- }
140
- };
141
- tslib_1.__decorate([
142
- (0, common_1.Constant)("env"),
143
- tslib_1.__metadata("design:type", String)
144
- ], OidcInteractionContext.prototype, "env", void 0);
145
- tslib_1.__decorate([
146
- (0, common_1.Constant)("oidc.render.omitClientProps", []),
147
- tslib_1.__metadata("design:type", Array)
148
- ], OidcInteractionContext.prototype, "omitClientProps", void 0);
149
- tslib_1.__decorate([
150
- (0, di_1.Inject)(),
151
- tslib_1.__metadata("design:type", OidcProvider_js_1.OidcProvider)
152
- ], OidcInteractionContext.prototype, "oidcProvider", void 0);
153
- tslib_1.__decorate([
154
- (0, di_1.Inject)(),
155
- tslib_1.__metadata("design:type", OidcInteractions_js_1.OidcInteractions)
156
- ], OidcInteractionContext.prototype, "oidcInteractions", void 0);
157
- tslib_1.__decorate([
158
- (0, common_1.InjectContext)(),
159
- tslib_1.__metadata("design:type", common_1.PlatformContext)
160
- ], OidcInteractionContext.prototype, "$ctx", void 0);
161
- OidcInteractionContext = tslib_1.__decorate([
162
- (0, di_1.Injectable)()
163
- ], OidcInteractionContext);
164
- exports.OidcInteractionContext = OidcInteractionContext;
165
- //# sourceMappingURL=OidcInteractionContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcInteractionContext.js","sourceRoot":"","sources":["../../../src/services/OidcInteractionContext.ts"],"names":[],"mappings":";;;;AAAA,yCAAsE;AACtE,qCAA+B;AAC/B,iCAA4C;AAC5C,iDAA8C;AAI9C,4DAQmC;AAGnC,mFAA2E;AAE3E,gDAAwC;AACxC,+DAAuD;AACvD,uDAA+C;AAC/C,+DAA+B;AAExB,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAgBjC,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,kCAAmB,CAAE,CAAC;IAC7C,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,OAAc,CAAC;IACjC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAA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SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAxLC;IAAC,IAAA,iBAAQ,EAAC,KAAK,CAAC;;mDACG;AAEnB;IAAC,IAAA,iBAAQ,EAAC,6BAA6B,EAAE,EAAE,CAAC;;+DACR;AAEpC;IAAC,IAAA,WAAM,GAAE;sCACe,8BAAY;4DAAC;AAErC;IAAC,IAAA,WAAM,GAAE;sCACmB,sCAAgB;gEAAC;AAE7C;IAAC,IAAA,sBAAa,GAAE;sCACA,wBAAe;oDAAC;AAdrB,sBAAsB;IADlC,IAAA,eAAU,GAAE;GACA,sBAAsB,CAyLlC;AAzLY,wDAAsB"}
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OidcInteractions = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const core_1 = require("@tsed/core");
7
- const di_1 = require("@tsed/di");
8
- const constants_js_1 = require("../constants/constants.js");
9
- let OidcInteractions = class OidcInteractions {
10
- constructor() {
11
- this.interactions = new Map();
12
- }
13
- $onInit() {
14
- const platformHandler = this.injector.get(common_1.PlatformHandler);
15
- this.getInteractions().forEach((provider) => {
16
- const { name } = provider.store.get(constants_js_1.INTERACTION_OPTIONS);
17
- this.interactions.set(name, provider);
18
- if (this.injector.get(provider.token)?.$prompt) {
19
- provider.store.set("$prompt", platformHandler.createCustomHandler(provider, "$prompt"));
20
- }
21
- });
22
- }
23
- getInteractions() {
24
- const interactionsProvider = this.injector.getProviders().find((provider) => provider.subType === constants_js_1.INTERACTIONS);
25
- /* istanbul ignore next */
26
- if (!interactionsProvider) {
27
- return [];
28
- }
29
- return interactionsProvider.children
30
- .map((token) => this.injector.getProvider(token))
31
- .filter((provider) => provider?.subType === constants_js_1.INTERACTION);
32
- }
33
- getInteractionProvider(name) {
34
- return this.interactions.get(name);
35
- }
36
- getInteractionHandler(name) {
37
- const interaction = this.getInteractionProvider(name);
38
- if (interaction) {
39
- const endpoint = common_1.EndpointMetadata.get(interaction.useClass, "$prompt");
40
- return (ctx) => {
41
- // Add current endpoint metadata to ctx
42
- ctx.endpoint = endpoint;
43
- return interaction.store.get("$prompt")(ctx);
44
- };
45
- }
46
- }
47
- };
48
- tslib_1.__decorate([
49
- (0, di_1.Inject)(),
50
- tslib_1.__metadata("design:type", di_1.InjectorService)
51
- ], OidcInteractions.prototype, "injector", void 0);
52
- tslib_1.__decorate([
53
- (0, common_1.Constant)("env"),
54
- tslib_1.__metadata("design:type", String)
55
- ], OidcInteractions.prototype, "env", void 0);
56
- tslib_1.__decorate([
57
- (0, common_1.Constant)("oidc"),
58
- tslib_1.__metadata("design:type", Object)
59
- ], OidcInteractions.prototype, "oidcSettings", void 0);
60
- OidcInteractions = tslib_1.__decorate([
61
- (0, di_1.Injectable)()
62
- ], OidcInteractions);
63
- exports.OidcInteractions = OidcInteractions;
64
- //# sourceMappingURL=OidcInteractions.js.map
@@ -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,4DAAyF;AAKlF,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAAtB;QAUK,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,kCAAmB,CAAC,CAAC;YAC/E,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAEtC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,C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AArDC;IAAC,IAAA,WAAM,GAAE;sCACW,oBAAe;kDAAC;AAEpC;IAAC,IAAA,iBAAQ,EAAC,KAAK,CAAC;;6CACG;AAEnB;IAAC,IAAA,iBAAQ,EAAC,MAAM,CAAC;;sDACoB;AAR1B,gBAAgB;IAD5B,IAAA,eAAU,GAAE;GACA,gBAAgB,CAsD5B;AAtDY,4CAAgB"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OidcJwks = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- const path_1 = require("path");
7
- const jwks_1 = require("@tsed/jwks");
8
- let OidcJwks = class OidcJwks {
9
- $onInit() {
10
- return this.getJwks();
11
- }
12
- getJwks() {
13
- return (0, jwks_1.getJwks)({
14
- path: this.jwksPath,
15
- certificates: this.certificates
16
- });
17
- }
18
- };
19
- tslib_1.__decorate([
20
- (0, di_1.Constant)("oidc.jwksPath", (0, path_1.join)(process.cwd(), "keys", "jwks.json")),
21
- tslib_1.__metadata("design:type", String)
22
- ], OidcJwks.prototype, "jwksPath", void 0);
23
- tslib_1.__decorate([
24
- (0, di_1.Constant)("oidc.certificates"),
25
- tslib_1.__metadata("design:type", Array)
26
- ], OidcJwks.prototype, "certificates", void 0);
27
- OidcJwks = tslib_1.__decorate([
28
- (0, di_1.Injectable)()
29
- ], OidcJwks);
30
- exports.OidcJwks = OidcJwks;
31
- //# sourceMappingURL=OidcJwks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcJwks.js","sourceRoot":"","sources":["../../../src/services/OidcJwks.ts"],"names":[],"mappings":";;;;AAAA,iCAA8C;AAC9C,+BAA0B;AAC1B,qCAAsD;AAG/C,IAAM,QAAQ,GAAd,MAAM,QAAQ;IASnB,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,OAAO;QACL,OAAO,IAAA,cAAO,EAAC;YACb,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAlBC;IAAC,IAAA,aAAQ,EAAC,eAAe,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;;0CACnD;AAEjB;IAAC,IAAA,aAAQ,EAAC,mBAAmB,CAAC;;8CACK;AALxB,QAAQ;IADpB,IAAA,eAAU,GAAE;GACA,QAAQ,CAmBpB;AAnBY,4BAAQ"}
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OidcPolicy = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- const OidcInteractions_js_1 = require("./OidcInteractions.js");
7
- const OidcProviderNodeModule_js_1 = require("./OidcProviderNodeModule.js");
8
- let OidcPolicy = class OidcPolicy {
9
- constructor(module) {
10
- this.module = module;
11
- }
12
- getPolicy() {
13
- let policy = this.module.interactionPolicy.base();
14
- const { usePriority, interactions } = this.getInteractions();
15
- if (interactions.size) {
16
- for (const { name, instance, options } of interactions.values()) {
17
- if (!policy.get(name)) {
18
- const prompt = this.createPrompt(instance, options);
19
- policy.add(prompt, options.priority);
20
- }
21
- if (instance.$onCreate) {
22
- instance.$onCreate(policy.get(name));
23
- }
24
- }
25
- // reordering interactions by interactions index
26
- if (!usePriority) {
27
- policy = policy.sort((a, b) => {
28
- const o1 = interactions.get(a.name)?.order || 0;
29
- const o2 = interactions.get(b.name)?.order || 0;
30
- return o1 < o2 ? -1 : 1;
31
- });
32
- }
33
- }
34
- return this.injector.alter("$alterOidcPolicy", policy);
35
- }
36
- createPrompt(instance, options) {
37
- const { checks: originalChecks = [], details, ...promptOptions } = options;
38
- const checks = [...(instance.checks ? instance.checks() : originalChecks)].filter(Boolean);
39
- return new this.module.interactionPolicy.Prompt(promptOptions, instance.details ? instance.details.bind(instance) : details, ...checks);
40
- }
41
- getInteractions() {
42
- let usePriority = false;
43
- const interactions = this.oidcInteractions.getInteractions();
44
- const map = interactions.reduce((map, provider, index) => {
45
- const instance = this.injector.get(provider.token);
46
- const options = provider.store.get("interactionOptions");
47
- if (options.priority !== undefined) {
48
- usePriority = true;
49
- }
50
- return map.set(options.name, {
51
- order: index,
52
- name: options.name,
53
- provider,
54
- instance,
55
- options
56
- });
57
- }, new Map());
58
- return {
59
- interactions: map,
60
- usePriority
61
- };
62
- }
63
- };
64
- tslib_1.__decorate([
65
- (0, di_1.Inject)(),
66
- tslib_1.__metadata("design:type", di_1.InjectorService)
67
- ], OidcPolicy.prototype, "injector", void 0);
68
- tslib_1.__decorate([
69
- (0, di_1.Inject)(),
70
- tslib_1.__metadata("design:type", OidcInteractions_js_1.OidcInteractions)
71
- ], OidcPolicy.prototype, "oidcInteractions", void 0);
72
- OidcPolicy = tslib_1.__decorate([
73
- (0, di_1.Injectable)(),
74
- tslib_1.__param(0, (0, di_1.Inject)(OidcProviderNodeModule_js_1.OIDC_PROVIDER_NODE_MODULE)),
75
- tslib_1.__metadata("design:paramtypes", [Object])
76
- ], OidcPolicy);
77
- exports.OidcPolicy = OidcPolicy;
78
- //# sourceMappingURL=OidcPolicy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OidcPolicy.js","sourceRoot":"","sources":["../../../src/services/OidcPolicy.ts"],"names":[],"mappings":";;;;AAAA,iCAAuE;AAKvE,+DAAuD;AACvD,2EAAsE;AAI/D,IAAM,UAAU,GAAhB,MAAM,UAAU;IAOrB,YAAyD,MAAiC;QAAjC,WAAM,GAAN,MAAM,CAA2B;IAAG,CAAC;IAEvF,SAAS;QACd,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;QAClD,MAAM,EAAC,WAAW,EAAE,YAAY,EAAC,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAE3D,IAAI,YAAY,CAAC,IAAI,EAAE;Y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AU;IADtB,IAAA,eAAU,GAAE;IAQE,mBAAA,IAAA,WAAM,EAAC,qDAAyB,CAAC,CAAA;;GAPnC,UAAU,CAuFtB;AAvFY,gCAAU"}
@@ -1,201 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OidcProvider = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const core_1 = require("@tsed/core");
7
- const di_1 = require("@tsed/di");
8
- const constants_js_1 = require("../constants/constants.js");
9
- const events_js_1 = require("../utils/events.js");
10
- const OidcAdapters_js_1 = require("./OidcAdapters.js");
11
- const OidcInteractions_js_1 = require("./OidcInteractions.js");
12
- const OidcJwks_js_1 = require("./OidcJwks.js");
13
- const OidcPolicy_js_1 = require("./OidcPolicy.js");
14
- const OidcProviderNodeModule_js_1 = require("./OidcProviderNodeModule.js");
15
- function mapError(error) {
16
- return Object.getOwnPropertyNames(error).reduce((obj, key) => {
17
- return {
18
- ...obj,
19
- [key]: error[key]
20
- };
21
- }, {});
22
- }
23
- let OidcProvider = class OidcProvider {
24
- constructor(module) {
25
- this.module = module;
26
- }
27
- get logger() {
28
- return this.$ctx?.logger || this.injector.logger;
29
- }
30
- hasConfiguration() {
31
- return !!this.oidc;
32
- }
33
- async getConfiguration() {
34
- const [jwks, adapter] = await Promise.all([this.oidcJwks.getJwks(), this.adapters.createAdapterClass()]);
35
- const { issuer, jwksPath, secureKey, proxy, Accounts, secureCookies = this.env == core_1.Env.PROD, Adapter, connectionName, render, ...options } = this.oidc;
36
- const configuration = {
37
- interactions: {
38
- /* istanbul ignore next */
39
- url: (ctx, interaction) => `interaction/${interaction.uid}`
40
- },
41
- ...options,
42
- adapter,
43
- jwks
44
- };
45
- if (Accounts) {
46
- configuration.findAccount = (ctx, id, token) => this.injector.get(Accounts).findAccount(id, token);
47
- }
48
- if (secureCookies) {
49
- (0, core_1.setValue)(configuration, "cookies.short.secure", true);
50
- (0, core_1.setValue)(configuration, "cookies.long.secure", true);
51
- }
52
- const policy = this.oidcPolicy.getPolicy();
53
- if (policy) {
54
- (0, core_1.setValue)(configuration, "interactions.policy", policy);
55
- }
56
- const url = this.getInteractionsUrl();
57
- if (url) {
58
- (0, core_1.setValue)(configuration, "interactions.url", url);
59
- }
60
- return configuration;
61
- }
62
- getIssuer() {
63
- if (this.issuer) {
64
- return this.issuer;
65
- }
66
- // istanbul ignore next
67
- if (this.httpsPort) {
68
- return `https://localhost:${this.httpsPort}`;
69
- }
70
- return `http://localhost:${this.httpPort}`;
71
- }
72
- get() {
73
- return this.raw;
74
- }
75
- /**
76
- * Create a new instance of OidcProvider
77
- */
78
- async create() {
79
- const { proxy = this.env === core_1.Env.PROD, secureKey, allowHttpLocalhost = this.env !== core_1.Env.PROD } = this.oidc;
80
- const configuration = await this.getConfiguration();
81
- await this.injector.alterAsync("$alterOidcConfiguration", configuration);
82
- const oidcProvider = new this.module.Provider(this.getIssuer(), configuration);
83
- if (proxy) {
84
- // istanbul ignore next
85
- switch (this.platformName) {
86
- default:
87
- case "express":
88
- oidcProvider.proxy = true;
89
- break;
90
- case "koa":
91
- this.app.rawApp.proxy = true;
92
- break;
93
- }
94
- }
95
- if (secureKey) {
96
- oidcProvider.app.keys = secureKey;
97
- }
98
- this.raw = oidcProvider;
99
- if (allowHttpLocalhost) {
100
- this.allowHttpLocalhost();
101
- }
102
- events_js_1.OIDC_ERROR_EVENTS.map((event) => {
103
- this.raw.on(event, this.createErrorHandler(event));
104
- });
105
- await this.injector.emit("$onCreateOIDC", this.raw);
106
- return this.raw;
107
- }
108
- createErrorHandler(event) {
109
- return (ctx, error, accountId, sid) => {
110
- this.logger.error({
111
- event: "OIDC_ERROR",
112
- type: event,
113
- error: mapError(error),
114
- account_id: accountId,
115
- params: ctx.oidc.params,
116
- headers: ctx.headers,
117
- sid
118
- });
119
- // TODO see if we need to call platformExceptions
120
- // this.platformExceptions.catch(error, ctx.request.$ctx);
121
- };
122
- }
123
- getInteractionsUrl() {
124
- const provider = this.injector.getProviders().find((provider) => provider.subType === constants_js_1.INTERACTIONS);
125
- if (provider) {
126
- return (ctx, interaction) => {
127
- // eslint-disable-line no-unused-vars
128
- return provider.path.replace(/:uid/, interaction.uid);
129
- };
130
- }
131
- }
132
- allowHttpLocalhost() {
133
- const { invalidate: orig } = this.raw.Client.Schema.prototype;
134
- this.raw.Client.Schema.prototype.invalidate = function invalidate(message, code) {
135
- if (code === "implicit-force-https" || code === "implicit-forbid-localhost") {
136
- return;
137
- }
138
- /* istanbul ignore next */
139
- return orig.call(this, message);
140
- };
141
- }
142
- };
143
- tslib_1.__decorate([
144
- (0, di_1.Constant)("env"),
145
- tslib_1.__metadata("design:type", String)
146
- ], OidcProvider.prototype, "env", void 0);
147
- tslib_1.__decorate([
148
- (0, di_1.Constant)("httpPort"),
149
- tslib_1.__metadata("design:type", Object)
150
- ], OidcProvider.prototype, "httpPort", void 0);
151
- tslib_1.__decorate([
152
- (0, di_1.Constant)("httpsPort"),
153
- tslib_1.__metadata("design:type", Object)
154
- ], OidcProvider.prototype, "httpsPort", void 0);
155
- tslib_1.__decorate([
156
- (0, di_1.Constant)("oidc.issuer", ""),
157
- tslib_1.__metadata("design:type", String)
158
- ], OidcProvider.prototype, "issuer", void 0);
159
- tslib_1.__decorate([
160
- (0, di_1.Constant)("oidc"),
161
- tslib_1.__metadata("design:type", Object)
162
- ], OidcProvider.prototype, "oidc", void 0);
163
- tslib_1.__decorate([
164
- (0, di_1.Constant)("PLATFORM_NAME"),
165
- tslib_1.__metadata("design:type", String)
166
- ], OidcProvider.prototype, "platformName", void 0);
167
- tslib_1.__decorate([
168
- (0, di_1.Inject)(),
169
- tslib_1.__metadata("design:type", OidcJwks_js_1.OidcJwks)
170
- ], OidcProvider.prototype, "oidcJwks", void 0);
171
- tslib_1.__decorate([
172
- (0, di_1.Inject)(),
173
- tslib_1.__metadata("design:type", OidcInteractions_js_1.OidcInteractions)
174
- ], OidcProvider.prototype, "oidcInteractions", void 0);
175
- tslib_1.__decorate([
176
- (0, di_1.Inject)(),
177
- tslib_1.__metadata("design:type", OidcPolicy_js_1.OidcPolicy)
178
- ], OidcProvider.prototype, "oidcPolicy", void 0);
179
- tslib_1.__decorate([
180
- (0, di_1.Inject)(),
181
- tslib_1.__metadata("design:type", OidcAdapters_js_1.OidcAdapters)
182
- ], OidcProvider.prototype, "adapters", void 0);
183
- tslib_1.__decorate([
184
- (0, di_1.Inject)(),
185
- tslib_1.__metadata("design:type", di_1.InjectorService)
186
- ], OidcProvider.prototype, "injector", void 0);
187
- tslib_1.__decorate([
188
- (0, di_1.Inject)(),
189
- tslib_1.__metadata("design:type", common_1.PlatformApplication)
190
- ], OidcProvider.prototype, "app", void 0);
191
- tslib_1.__decorate([
192
- (0, common_1.InjectContext)(),
193
- tslib_1.__metadata("design:type", common_1.PlatformContext)
194
- ], OidcProvider.prototype, "$ctx", void 0);
195
- OidcProvider = tslib_1.__decorate([
196
- (0, di_1.Injectable)(),
197
- tslib_1.__param(0, (0, di_1.Inject)(OidcProviderNodeModule_js_1.OIDC_PROVIDER_NODE_MODULE)),
198
- tslib_1.__metadata("design:paramtypes", [Object])
199
- ], OidcProvider);
200
- exports.OidcProvider = OidcProvider;
201
- //# sourceMappingURL=OidcProvider.js.map