@celljs/oauth2-client 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/cell.yml +57 -0
  4. package/lib/node/authentication/authentication-protocol.d.ts +25 -0
  5. package/lib/node/authentication/authentication-protocol.d.ts.map +1 -0
  6. package/lib/node/authentication/authentication-protocol.js +11 -0
  7. package/lib/node/authentication/authentication-protocol.js.map +1 -0
  8. package/lib/node/authentication/index.d.ts +4 -0
  9. package/lib/node/authentication/index.d.ts.map +1 -0
  10. package/lib/node/authentication/index.js +20 -0
  11. package/lib/node/authentication/index.js.map +1 -0
  12. package/lib/node/authentication/oauth2-authentication-provider.d.ts +30 -0
  13. package/lib/node/authentication/oauth2-authentication-provider.d.ts.map +1 -0
  14. package/lib/node/authentication/oauth2-authentication-provider.js +170 -0
  15. package/lib/node/authentication/oauth2-authentication-provider.js.map +1 -0
  16. package/lib/node/authentication/oidc-authentication-provider.d.ts +18 -0
  17. package/lib/node/authentication/oidc-authentication-provider.d.ts.map +1 -0
  18. package/lib/node/authentication/oidc-authentication-provider.js +74 -0
  19. package/lib/node/authentication/oidc-authentication-provider.js.map +1 -0
  20. package/lib/node/authorization/authorization-code-authorized-client-provider.d.ts +5 -0
  21. package/lib/node/authorization/authorization-code-authorized-client-provider.d.ts.map +1 -0
  22. package/lib/node/authorization/authorization-code-authorized-client-provider.js +27 -0
  23. package/lib/node/authorization/authorization-code-authorized-client-provider.js.map +1 -0
  24. package/lib/node/authorization/authorization-code-grant-middleware.d.ts +26 -0
  25. package/lib/node/authorization/authorization-code-grant-middleware.d.ts.map +1 -0
  26. package/lib/node/authorization/authorization-code-grant-middleware.js +129 -0
  27. package/lib/node/authorization/authorization-code-grant-middleware.js.map +1 -0
  28. package/lib/node/authorization/authorization-failure-handler.d.ts +10 -0
  29. package/lib/node/authorization/authorization-failure-handler.d.ts.map +1 -0
  30. package/lib/node/authorization/authorization-failure-handler.js +35 -0
  31. package/lib/node/authorization/authorization-failure-handler.js.map +1 -0
  32. package/lib/node/authorization/authorization-protocol.d.ts +78 -0
  33. package/lib/node/authorization/authorization-protocol.d.ts.map +1 -0
  34. package/lib/node/authorization/authorization-protocol.js +34 -0
  35. package/lib/node/authorization/authorization-protocol.js.map +1 -0
  36. package/lib/node/authorization/authorization-request-manager.d.ts +13 -0
  37. package/lib/node/authorization/authorization-request-manager.d.ts.map +1 -0
  38. package/lib/node/authorization/authorization-request-manager.js +64 -0
  39. package/lib/node/authorization/authorization-request-manager.js.map +1 -0
  40. package/lib/node/authorization/authorization-request-redirect-middleware.d.ts +20 -0
  41. package/lib/node/authorization/authorization-request-redirect-middleware.d.ts.map +1 -0
  42. package/lib/node/authorization/authorization-request-redirect-middleware.js +113 -0
  43. package/lib/node/authorization/authorization-request-redirect-middleware.js.map +1 -0
  44. package/lib/node/authorization/authorization-request-resolver.d.ts +38 -0
  45. package/lib/node/authorization/authorization-request-resolver.d.ts.map +1 -0
  46. package/lib/node/authorization/authorization-request-resolver.js +155 -0
  47. package/lib/node/authorization/authorization-request-resolver.js.map +1 -0
  48. package/lib/node/authorization/authorization-success-handler.d.ts +7 -0
  49. package/lib/node/authorization/authorization-success-handler.d.ts.map +1 -0
  50. package/lib/node/authorization/authorization-success-handler.js +28 -0
  51. package/lib/node/authorization/authorization-success-handler.js.map +1 -0
  52. package/lib/node/authorization/authorized-client-manager.d.ts +11 -0
  53. package/lib/node/authorization/authorized-client-manager.d.ts.map +1 -0
  54. package/lib/node/authorization/authorized-client-manager.js +48 -0
  55. package/lib/node/authorization/authorized-client-manager.js.map +1 -0
  56. package/lib/node/authorization/authorized-client-service.d.ts +12 -0
  57. package/lib/node/authorization/authorized-client-service.d.ts.map +1 -0
  58. package/lib/node/authorization/authorized-client-service.js +87 -0
  59. package/lib/node/authorization/authorized-client-service.js.map +1 -0
  60. package/lib/node/authorization/client-credentials-authorized-client-provider.d.ts +12 -0
  61. package/lib/node/authorization/client-credentials-authorized-client-provider.d.ts.map +1 -0
  62. package/lib/node/authorization/client-credentials-authorized-client-provider.js +72 -0
  63. package/lib/node/authorization/client-credentials-authorized-client-provider.js.map +1 -0
  64. package/lib/node/authorization/context-attributes-mapper.d.ts +5 -0
  65. package/lib/node/authorization/context-attributes-mapper.d.ts.map +1 -0
  66. package/lib/node/authorization/context-attributes-mapper.js +28 -0
  67. package/lib/node/authorization/context-attributes-mapper.js.map +1 -0
  68. package/lib/node/authorization/index.d.ts +14 -0
  69. package/lib/node/authorization/index.d.ts.map +1 -0
  70. package/lib/node/authorization/index.js +30 -0
  71. package/lib/node/authorization/index.js.map +1 -0
  72. package/lib/node/authorization/password-authorized-client-provider.d.ts +12 -0
  73. package/lib/node/authorization/password-authorized-client-provider.d.ts.map +1 -0
  74. package/lib/node/authorization/password-authorized-client-provider.js +85 -0
  75. package/lib/node/authorization/password-authorized-client-provider.js.map +1 -0
  76. package/lib/node/authorization/refresh-token-authorized-client-provider.d.ts +12 -0
  77. package/lib/node/authorization/refresh-token-authorized-client-provider.d.ts.map +1 -0
  78. package/lib/node/authorization/refresh-token-authorized-client-provider.js +68 -0
  79. package/lib/node/authorization/refresh-token-authorized-client-provider.js.map +1 -0
  80. package/lib/node/constants.d.ts +5 -0
  81. package/lib/node/constants.d.ts.map +1 -0
  82. package/lib/node/constants.js +8 -0
  83. package/lib/node/constants.js.map +1 -0
  84. package/lib/node/endpoint/authorization-code-token-response-client.d.ts +12 -0
  85. package/lib/node/endpoint/authorization-code-token-response-client.d.ts.map +1 -0
  86. package/lib/node/endpoint/authorization-code-token-response-client.js +83 -0
  87. package/lib/node/endpoint/authorization-code-token-response-client.js.map +1 -0
  88. package/lib/node/endpoint/client-credentials-token-response-client.d.ts +12 -0
  89. package/lib/node/endpoint/client-credentials-token-response-client.d.ts.map +1 -0
  90. package/lib/node/endpoint/client-credentials-token-response-client.js +80 -0
  91. package/lib/node/endpoint/client-credentials-token-response-client.js.map +1 -0
  92. package/lib/node/endpoint/endpoint-protocol.d.ts +48 -0
  93. package/lib/node/endpoint/endpoint-protocol.d.ts.map +1 -0
  94. package/lib/node/endpoint/endpoint-protocol.js +9 -0
  95. package/lib/node/endpoint/endpoint-protocol.js.map +1 -0
  96. package/lib/node/endpoint/index.d.ts +7 -0
  97. package/lib/node/endpoint/index.d.ts.map +1 -0
  98. package/lib/node/endpoint/index.js +23 -0
  99. package/lib/node/endpoint/index.js.map +1 -0
  100. package/lib/node/endpoint/password-token-response-client.d.ts +12 -0
  101. package/lib/node/endpoint/password-token-response-client.d.ts.map +1 -0
  102. package/lib/node/endpoint/password-token-response-client.js +82 -0
  103. package/lib/node/endpoint/password-token-response-client.js.map +1 -0
  104. package/lib/node/endpoint/refresh-token-token-response-client.d.ts +12 -0
  105. package/lib/node/endpoint/refresh-token-token-response-client.d.ts.map +1 -0
  106. package/lib/node/endpoint/refresh-token-token-response-client.js +87 -0
  107. package/lib/node/endpoint/refresh-token-token-response-client.js.map +1 -0
  108. package/lib/node/endpoint/user-response-client.d.ts +9 -0
  109. package/lib/node/endpoint/user-response-client.d.ts.map +1 -0
  110. package/lib/node/endpoint/user-response-client.js +84 -0
  111. package/lib/node/endpoint/user-response-client.js.map +1 -0
  112. package/lib/node/error/error-hander.d.ts +11 -0
  113. package/lib/node/error/error-hander.d.ts.map +1 -0
  114. package/lib/node/error/error-hander.js +52 -0
  115. package/lib/node/error/error-hander.js.map +1 -0
  116. package/lib/node/error/error-protocol.d.ts +3 -0
  117. package/lib/node/error/error-protocol.d.ts.map +1 -0
  118. package/lib/node/error/error-protocol.js +7 -0
  119. package/lib/node/error/error-protocol.js.map +1 -0
  120. package/lib/node/error/error.d.ts +10 -0
  121. package/lib/node/error/error.d.ts.map +1 -0
  122. package/lib/node/error/error.js +23 -0
  123. package/lib/node/error/error.js.map +1 -0
  124. package/lib/node/error/index.d.ts +4 -0
  125. package/lib/node/error/index.d.ts.map +1 -0
  126. package/lib/node/error/index.js +20 -0
  127. package/lib/node/error/index.js.map +1 -0
  128. package/lib/node/index.d.ts +8 -0
  129. package/lib/node/index.d.ts.map +1 -0
  130. package/lib/node/index.js +24 -0
  131. package/lib/node/index.js.map +1 -0
  132. package/lib/node/module.d.ts +4 -0
  133. package/lib/node/module.d.ts.map +1 -0
  134. package/lib/node/module.js +6 -0
  135. package/lib/node/module.js.map +1 -0
  136. package/lib/node/provider/index.d.ts +3 -0
  137. package/lib/node/provider/index.d.ts.map +1 -0
  138. package/lib/node/provider/index.js +19 -0
  139. package/lib/node/provider/index.js.map +1 -0
  140. package/lib/node/provider/provider-details-manager.d.ts +12 -0
  141. package/lib/node/provider/provider-details-manager.d.ts.map +1 -0
  142. package/lib/node/provider/provider-details-manager.js +50 -0
  143. package/lib/node/provider/provider-details-manager.js.map +1 -0
  144. package/lib/node/provider/provider-protocol.d.ts +21 -0
  145. package/lib/node/provider/provider-protocol.d.ts.map +1 -0
  146. package/lib/node/provider/provider-protocol.js +5 -0
  147. package/lib/node/provider/provider-protocol.js.map +1 -0
  148. package/lib/node/registration/id-token-jwt-decoder-facatory.d.ts +15 -0
  149. package/lib/node/registration/id-token-jwt-decoder-facatory.d.ts.map +1 -0
  150. package/lib/node/registration/id-token-jwt-decoder-facatory.js +89 -0
  151. package/lib/node/registration/id-token-jwt-decoder-facatory.js.map +1 -0
  152. package/lib/node/registration/index.d.ts +5 -0
  153. package/lib/node/registration/index.d.ts.map +1 -0
  154. package/lib/node/registration/index.js +21 -0
  155. package/lib/node/registration/index.js.map +1 -0
  156. package/lib/node/registration/jws-algorithm-resolver.d.ts +5 -0
  157. package/lib/node/registration/jws-algorithm-resolver.d.ts.map +1 -0
  158. package/lib/node/registration/jws-algorithm-resolver.js +22 -0
  159. package/lib/node/registration/jws-algorithm-resolver.js.map +1 -0
  160. package/lib/node/registration/registration-manager.d.ts +15 -0
  161. package/lib/node/registration/registration-manager.d.ts.map +1 -0
  162. package/lib/node/registration/registration-manager.js +64 -0
  163. package/lib/node/registration/registration-manager.js.map +1 -0
  164. package/lib/node/registration/registration-protocol.d.ts +22 -0
  165. package/lib/node/registration/registration-protocol.d.ts.map +1 -0
  166. package/lib/node/registration/registration-protocol.js +7 -0
  167. package/lib/node/registration/registration-protocol.js.map +1 -0
  168. package/lib/node/user/index.d.ts +4 -0
  169. package/lib/node/user/index.d.ts.map +1 -0
  170. package/lib/node/user/index.js +20 -0
  171. package/lib/node/user/index.js.map +1 -0
  172. package/lib/node/user/oauth2-user-service.d.ts +10 -0
  173. package/lib/node/user/oauth2-user-service.d.ts.map +1 -0
  174. package/lib/node/user/oauth2-user-service.js +61 -0
  175. package/lib/node/user/oauth2-user-service.js.map +1 -0
  176. package/lib/node/user/oidc-user-service.d.ts +13 -0
  177. package/lib/node/user/oidc-user-service.d.ts.map +1 -0
  178. package/lib/node/user/oidc-user-service.js +98 -0
  179. package/lib/node/user/oidc-user-service.js.map +1 -0
  180. package/lib/node/user/user-protocol.d.ts +6 -0
  181. package/lib/node/user/user-protocol.d.ts.map +1 -0
  182. package/lib/node/user/user-protocol.js +3 -0
  183. package/lib/node/user/user-protocol.js.map +1 -0
  184. package/lib/node/utils/authorization-grant-request-entity-util.d.ts +10 -0
  185. package/lib/node/utils/authorization-grant-request-entity-util.d.ts.map +1 -0
  186. package/lib/node/utils/authorization-grant-request-entity-util.js +28 -0
  187. package/lib/node/utils/authorization-grant-request-entity-util.js.map +1 -0
  188. package/lib/node/utils/authorization-response-util.d.ts +8 -0
  189. package/lib/node/utils/authorization-response-util.d.ts.map +1 -0
  190. package/lib/node/utils/authorization-response-util.js +53 -0
  191. package/lib/node/utils/authorization-response-util.js.map +1 -0
  192. package/lib/node/utils/index.d.ts +3 -0
  193. package/lib/node/utils/index.d.ts.map +1 -0
  194. package/lib/node/utils/index.js +19 -0
  195. package/lib/node/utils/index.js.map +1 -0
  196. package/lib/package.spec.d.ts +1 -0
  197. package/lib/package.spec.d.ts.map +1 -0
  198. package/lib/package.spec.js +4 -0
  199. package/lib/package.spec.js.map +1 -0
  200. package/package.json +51 -0
  201. package/src/node/authentication/authentication-protocol.ts +26 -0
  202. package/src/node/authentication/index.ts +3 -0
  203. package/src/node/authentication/oauth2-authentication-provider.ts +163 -0
  204. package/src/node/authentication/oidc-authentication-provider.ts +60 -0
  205. package/src/node/authorization/authorization-code-authorized-client-provider.ts +16 -0
  206. package/src/node/authorization/authorization-code-grant-middleware.ts +110 -0
  207. package/src/node/authorization/authorization-failure-handler.ts +23 -0
  208. package/src/node/authorization/authorization-protocol.ts +104 -0
  209. package/src/node/authorization/authorization-request-manager.ts +54 -0
  210. package/src/node/authorization/authorization-request-redirect-middleware.ts +91 -0
  211. package/src/node/authorization/authorization-request-resolver.ts +149 -0
  212. package/src/node/authorization/authorization-success-handler.ts +15 -0
  213. package/src/node/authorization/authorized-client-manager.ts +35 -0
  214. package/src/node/authorization/authorized-client-service.ts +73 -0
  215. package/src/node/authorization/client-credentials-authorized-client-provider.ts +61 -0
  216. package/src/node/authorization/context-attributes-mapper.ts +18 -0
  217. package/src/node/authorization/index.ts +13 -0
  218. package/src/node/authorization/password-authorized-client-provider.ts +78 -0
  219. package/src/node/authorization/refresh-token-authorized-client-provider.ts +58 -0
  220. package/src/node/constants.ts +4 -0
  221. package/src/node/endpoint/authorization-code-token-response-client.ts +73 -0
  222. package/src/node/endpoint/client-credentials-token-response-client.ts +69 -0
  223. package/src/node/endpoint/endpoint-protocol.ts +55 -0
  224. package/src/node/endpoint/index.ts +6 -0
  225. package/src/node/endpoint/password-token-response-client.ts +71 -0
  226. package/src/node/endpoint/refresh-token-token-response-client.ts +77 -0
  227. package/src/node/endpoint/user-response-client.ts +72 -0
  228. package/src/node/error/error-hander.ts +39 -0
  229. package/src/node/error/error-protocol.ts +6 -0
  230. package/src/node/error/error.ts +19 -0
  231. package/src/node/error/index.ts +3 -0
  232. package/src/node/index.ts +7 -0
  233. package/src/node/module.ts +4 -0
  234. package/src/node/provider/index.ts +2 -0
  235. package/src/node/provider/provider-details-manager.ts +33 -0
  236. package/src/node/provider/provider-protocol.ts +24 -0
  237. package/src/node/registration/id-token-jwt-decoder-facatory.ts +71 -0
  238. package/src/node/registration/index.ts +4 -0
  239. package/src/node/registration/jws-algorithm-resolver.ts +12 -0
  240. package/src/node/registration/registration-manager.ts +47 -0
  241. package/src/node/registration/registration-protocol.ts +27 -0
  242. package/src/node/user/index.ts +3 -0
  243. package/src/node/user/oauth2-user-service.ts +50 -0
  244. package/src/node/user/oidc-user-service.ts +92 -0
  245. package/src/node/user/user-protocol.ts +6 -0
  246. package/src/node/utils/authorization-grant-request-entity-util.ts +26 -0
  247. package/src/node/utils/authorization-response-util.ts +50 -0
  248. package/src/node/utils/index.ts +2 -0
  249. package/src/package.spec.ts +4 -0
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.InMemoryProviderDetailsManager = void 0;
13
+ const provider_protocol_1 = require("./provider-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ let InMemoryProviderDetailsManager = class InMemoryProviderDetailsManager {
16
+ constructor() {
17
+ this.providers = {};
18
+ this.providerTemplates = {};
19
+ this.initialized = false;
20
+ }
21
+ async get(providerId) {
22
+ if (!this.initialized) {
23
+ for (const id in this.providers) {
24
+ if (Object.prototype.hasOwnProperty.call(this.providers, id)) {
25
+ const template = this.providerTemplates[id];
26
+ const provider = Object.assign(Object.assign({}, template), this.providers[id]);
27
+ provider.userInfoEndpoint = Object.assign(Object.assign({}, template === null || template === void 0 ? void 0 : template.userInfoEndpoint), provider.userInfoEndpoint);
28
+ provider.configurationMetadata = Object.assign(Object.assign({}, template === null || template === void 0 ? void 0 : template.configurationMetadata), provider.configurationMetadata);
29
+ this.providers[id] = provider;
30
+ }
31
+ }
32
+ this.providers = this.providers || {};
33
+ this.initialized = true;
34
+ }
35
+ return this.providers[providerId] || this.providerTemplates[providerId];
36
+ }
37
+ };
38
+ __decorate([
39
+ (0, core_1.Value)('cell.oauth2.client.providers'),
40
+ __metadata("design:type", Object)
41
+ ], InMemoryProviderDetailsManager.prototype, "providers", void 0);
42
+ __decorate([
43
+ (0, core_1.Value)('cell.oauth2.client.providerTemplates'),
44
+ __metadata("design:type", Object)
45
+ ], InMemoryProviderDetailsManager.prototype, "providerTemplates", void 0);
46
+ InMemoryProviderDetailsManager = __decorate([
47
+ (0, core_1.Component)(provider_protocol_1.ProviderDetailsManager)
48
+ ], InMemoryProviderDetailsManager);
49
+ exports.InMemoryProviderDetailsManager = InMemoryProviderDetailsManager;
50
+ //# sourceMappingURL=provider-details-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-details-manager.js","sourceRoot":"","sources":["../../../src/node/provider/provider-details-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAA8E;AAC9E,uCAAgD;AAGzC,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAApC;QAGO,cAAS,GAAsC,EAAE,CAAC;QAGzC,sBAAiB,GAAsC,EAAE,CAAC;QAEnE,gBAAW,GAAG,KAAK,CAAC;IAoBlC,CAAC;IAlBG,KAAK,CAAC,GAAG,CAAC,UAAkB;QACxB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,EAAE;gBAC7B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE;oBAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;oBAC5C,MAAM,QAAQ,mCAAQ,QAAQ,GAAK,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAE,CAAC;oBACxD,QAAQ,CAAC,gBAAgB,mCAAQ,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,GAAK,QAAQ,CAAC,gBAAgB,CAAE,CAAC;oBAC5F,QAAQ,CAAC,qBAAqB,mCAAQ,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,qBAAqB,GAAK,QAAQ,CAAC,qBAAqB,CAAE,CAAC;oBAC3G,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC;iBACjC;aACJ;YACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;YACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SAC3B;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC5E,CAAC;CAEJ,CAAA;AA1BG;IAAC,IAAA,YAAK,EAAC,8BAA8B,CAAC;;iEACsB;AAE5D;IAAC,IAAA,YAAK,EAAC,sCAAsC,CAAC;;yEAC+B;AANpE,8BAA8B;IAD1C,IAAA,gBAAS,EAAC,0CAAsB,CAAC;GACrB,8BAA8B,CA4B1C;AA5BY,wEAA8B"}
@@ -0,0 +1,21 @@
1
+ import { AuthenticationMethod } from '@celljs/oauth2-core';
2
+ export declare const ProviderDetailsManager: unique symbol;
3
+ export interface ProviderDetails {
4
+ authorizationUri: string;
5
+ tokenUri: string;
6
+ userInfoEndpoint: UserInfoEndpoint;
7
+ jwkSetUri: string;
8
+ issuerUri: string;
9
+ configurationMetadata: {
10
+ [key: string]: any;
11
+ };
12
+ }
13
+ export interface UserInfoEndpoint {
14
+ uri: string;
15
+ authenticationMethod: AuthenticationMethod;
16
+ userNameAttributeName: string;
17
+ }
18
+ export interface ProviderDetailsManager {
19
+ get(providerId: string): Promise<ProviderDetails | undefined>;
20
+ }
21
+ //# sourceMappingURL=provider-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/provider/provider-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AAEvE,MAAM,WAAW,eAAe;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACjD;AAED,MAAM,WAAW,gBAAgB;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,qBAAqB,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,sBAAsB;IAEnC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;CAEjE"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProviderDetailsManager = void 0;
4
+ exports.ProviderDetailsManager = Symbol('ProviderDetailsManager');
5
+ //# sourceMappingURL=provider-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-protocol.js","sourceRoot":"","sources":["../../../src/node/provider/provider-protocol.ts"],"names":[],"mappings":";;;AAEa,QAAA,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { JwtDecoderFactory, JwtDecoder, JwkSetManager } from '@celljs/oauth2-jose';
2
+ import { ClientRegistration, JwsAlgorithmResolver } from './registration-protocol';
3
+ import { ProviderDetailsManager } from '../provider';
4
+ import { KeyLike } from 'jose';
5
+ import { AuthorizationRequest } from '@celljs/oauth2-core';
6
+ import { AuthorizationRequestManager } from '../authorization';
7
+ export declare class IdTokenJwtDecoderFactory implements JwtDecoderFactory<ClientRegistration> {
8
+ protected readonly jwsAlgorithmResolver: JwsAlgorithmResolver;
9
+ protected readonly authorizationRequestManager: AuthorizationRequestManager<AuthorizationRequest>;
10
+ protected readonly jwkSetManager: JwkSetManager<KeyLike | Uint8Array>;
11
+ protected readonly providerDetailsManager: ProviderDetailsManager;
12
+ protected readonly jwtDecoders: Map<string, JwtDecoder>;
13
+ create(clientRegistration: ClientRegistration): Promise<JwtDecoder>;
14
+ }
15
+ //# sourceMappingURL=id-token-jwt-decoder-facatory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-token-jwt-decoder-facatory.d.ts","sourceRoot":"","sources":["../../../src/node/registration/id-token-jwt-decoder-facatory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,aAAa,EAAiB,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAyC,MAAM,yBAAyB,CAAC;AAE1H,OAAO,EAAE,sBAAsB,EAAmB,MAAM,aAAa,CAAC;AACtE,OAAO,EAAa,OAAO,EAAkB,MAAM,MAAM,CAAC;AAC1D,OAAO,EAA6B,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D,qBACa,wBAAyB,YAAW,iBAAiB,CAAC,kBAAkB,CAAC;IAGlF,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAG9D,SAAS,CAAC,QAAQ,CAAC,2BAA2B,EAAE,2BAA2B,CAAC,oBAAoB,CAAC,CAAC;IAGlG,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,OAAO,GAAG,UAAU,CAAC,CAAC;IAGtE,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAElE,SAAS,CAAC,QAAQ,CAAC,WAAW,0BAAiC;IAEzD,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;CA6C5E"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.IdTokenJwtDecoderFactory = void 0;
13
+ const oauth2_jose_1 = require("@celljs/oauth2-jose");
14
+ const registration_protocol_1 = require("./registration-protocol");
15
+ const core_1 = require("@celljs/core");
16
+ const provider_1 = require("../provider");
17
+ const jose_1 = require("jose");
18
+ const oauth2_core_1 = require("@celljs/oauth2-core");
19
+ const authorization_1 = require("../authorization");
20
+ let IdTokenJwtDecoderFactory = class IdTokenJwtDecoderFactory {
21
+ constructor() {
22
+ this.jwtDecoders = new Map();
23
+ }
24
+ async create(clientRegistration) {
25
+ const { registrationId } = clientRegistration;
26
+ let jwtDecoder = this.jwtDecoders.get(registrationId);
27
+ if (!jwtDecoder) {
28
+ const jwsAlgorithm = await this.jwsAlgorithmResolver.reolve(clientRegistration);
29
+ const { jwkSetUri, issuerUri } = await this.providerDetailsManager.get(registrationId);
30
+ let key;
31
+ if (jwsAlgorithm === oauth2_jose_1.JwsAlgorithms.RS256) {
32
+ if (!jwkSetUri) {
33
+ throw new oauth2_core_1.OAuth2AuthenticationError({
34
+ errorCode: registration_protocol_1.MISSING_SIGNATURE_VERIFIER_ERROR_CODE,
35
+ description: `Failed to find a Signature Verifier for Client Registration: '${registrationId}'. Check to ensure you have configured the JwkSet URI.`
36
+ });
37
+ }
38
+ key = await this.jwkSetManager.get(jwkSetUri);
39
+ }
40
+ else {
41
+ const { clientSecret } = clientRegistration;
42
+ if (!clientSecret) {
43
+ throw new oauth2_core_1.OAuth2AuthenticationError({
44
+ errorCode: registration_protocol_1.MISSING_SIGNATURE_VERIFIER_ERROR_CODE,
45
+ description: `Failed to find a Signature Verifier for Client Registration: '${registrationId}'. Check to ensure you have configured the client secret.`
46
+ });
47
+ }
48
+ key = await (0, jose_1.generateSecret)(clientRegistration.clientSecret);
49
+ }
50
+ jwtDecoder = {
51
+ decode: async (token) => {
52
+ const { payload, protectedHeader } = await (0, jose_1.jwtVerify)(token, key, {
53
+ issuer: issuerUri,
54
+ audience: clientRegistration.clientId,
55
+ algorithms: [jwsAlgorithm]
56
+ });
57
+ return {
58
+ header: protectedHeader,
59
+ payload,
60
+ token
61
+ };
62
+ }
63
+ };
64
+ this.jwtDecoders.set(registrationId, jwtDecoder);
65
+ }
66
+ return jwtDecoder;
67
+ }
68
+ };
69
+ __decorate([
70
+ (0, core_1.Autowired)(registration_protocol_1.JwsAlgorithmResolver),
71
+ __metadata("design:type", Object)
72
+ ], IdTokenJwtDecoderFactory.prototype, "jwsAlgorithmResolver", void 0);
73
+ __decorate([
74
+ (0, core_1.Autowired)(authorization_1.AuthorizationRequestManager),
75
+ __metadata("design:type", Object)
76
+ ], IdTokenJwtDecoderFactory.prototype, "authorizationRequestManager", void 0);
77
+ __decorate([
78
+ (0, core_1.Autowired)(oauth2_jose_1.JwkSetManager),
79
+ __metadata("design:type", Object)
80
+ ], IdTokenJwtDecoderFactory.prototype, "jwkSetManager", void 0);
81
+ __decorate([
82
+ (0, core_1.Autowired)(provider_1.ProviderDetailsManager),
83
+ __metadata("design:type", Object)
84
+ ], IdTokenJwtDecoderFactory.prototype, "providerDetailsManager", void 0);
85
+ IdTokenJwtDecoderFactory = __decorate([
86
+ (0, core_1.Component)()
87
+ ], IdTokenJwtDecoderFactory);
88
+ exports.IdTokenJwtDecoderFactory = IdTokenJwtDecoderFactory;
89
+ //# sourceMappingURL=id-token-jwt-decoder-facatory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-token-jwt-decoder-facatory.js","sourceRoot":"","sources":["../../../src/node/registration/id-token-jwt-decoder-facatory.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAkG;AAClG,mEAA0H;AAC1H,uCAAoD;AACpD,0CAAsE;AACtE,+BAA0D;AAC1D,qDAAsF;AACtF,oDAA+D;AAGxD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAA9B;QAcgB,gBAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IA+CnE,CAAC;IA7CG,KAAK,CAAC,MAAM,CAAC,kBAAsC;QAC/C,MAAM,EAAE,cAAc,EAAE,GAAG,kBAAkB,CAAC;QAC9C,IAAI,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACtD,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;YAChF,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAqB,MAAM,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAEzG,IAAI,GAAyB,CAAC;YAC9B,IAAI,YAAY,KAAK,2BAAa,CAAC,KAAK,EAAE;gBACtC,IAAI,CAAC,SAAS,EAAE;oBACZ,MAAM,IAAI,uCAAyB,CAAC;wBAChC,SAAS,EAAE,6DAAqC;wBAChD,WAAW,EAAE,iEAAiE,cAAc,wDAAwD;qBACvJ,CAAC,CAAC;iBACN;gBACD,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;aACjD;iBAAM;gBACH,MAAM,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAAC;gBAC5C,IAAI,CAAC,YAAY,EAAE;oBACf,MAAM,IAAI,uCAAyB,CAAC;wBAChC,SAAS,EAAE,6DAAqC;wBAChD,WAAW,EAAE,iEAAiE,cAAc,2DAA2D;qBAC1J,CAAC,CAAC;iBACN;gBACD,GAAG,GAAG,MAAM,IAAA,qBAAc,EAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;aAC/D;YACD,UAAU,GAAG;gBACT,MAAM,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;oBAClB,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,IAAA,gBAAS,EAAC,KAAK,EAAE,GAAG,EAAE;wBAC7D,MAAM,EAAE,SAAS;wBACjB,QAAQ,EAAE,kBAAkB,CAAC,QAAQ;wBACrC,UAAU,EAAE,CAAE,YAAY,CAAE;qBAC/B,CAAC,CAAC;oBACH,OAAO;wBACH,MAAM,EAAE,eAAe;wBACvB,OAAO;wBACP,KAAK;qBACR,CAAC;gBACN,CAAC;aACJ,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;SACpD;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;CAEJ,CAAA;AA3DG;IAAC,IAAA,gBAAS,EAAC,4CAAoB,CAAC;;sEAC8B;AAE9D;IAAC,IAAA,gBAAS,EAAC,2CAA2B,CAAC;;6EAC2D;AAElG;IAAC,IAAA,gBAAS,EAAC,2BAAa,CAAC;;+DAC6C;AAEtE;IAAC,IAAA,gBAAS,EAAC,iCAAsB,CAAC;;wEACgC;AAZzD,wBAAwB;IADpC,IAAA,gBAAS,GAAE;GACC,wBAAwB,CA6DpC;AA7DY,4DAAwB"}
@@ -0,0 +1,5 @@
1
+ export * from './registration-protocol';
2
+ export * from './registration-manager';
3
+ export * from './id-token-jwt-decoder-facatory';
4
+ export * from './jws-algorithm-resolver';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/registration/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./registration-protocol"), exports);
18
+ __exportStar(require("./registration-manager"), exports);
19
+ __exportStar(require("./id-token-jwt-decoder-facatory"), exports);
20
+ __exportStar(require("./jws-algorithm-resolver"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/registration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,yDAAuC;AACvC,kEAAgD;AAChD,2DAAyC"}
@@ -0,0 +1,5 @@
1
+ import { ClientRegistration, JwsAlgorithmResolver } from './registration-protocol';
2
+ export declare class DefaultJwsAlgorithmResolver implements JwsAlgorithmResolver {
3
+ reolve(clientRegistration: ClientRegistration): Promise<string>;
4
+ }
5
+ //# sourceMappingURL=jws-algorithm-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jws-algorithm-resolver.d.ts","sourceRoot":"","sources":["../../../src/node/registration/jws-algorithm-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAGnF,qBACa,2BAA4B,YAAW,oBAAoB;IAE9D,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;CAIxE"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DefaultJwsAlgorithmResolver = void 0;
10
+ const oauth2_jose_1 = require("@celljs/oauth2-jose");
11
+ const registration_protocol_1 = require("./registration-protocol");
12
+ const core_1 = require("@celljs/core");
13
+ let DefaultJwsAlgorithmResolver = class DefaultJwsAlgorithmResolver {
14
+ async reolve(clientRegistration) {
15
+ return oauth2_jose_1.JwsAlgorithms.RS256;
16
+ }
17
+ };
18
+ DefaultJwsAlgorithmResolver = __decorate([
19
+ (0, core_1.Component)(registration_protocol_1.JwsAlgorithmResolver)
20
+ ], DefaultJwsAlgorithmResolver);
21
+ exports.DefaultJwsAlgorithmResolver = DefaultJwsAlgorithmResolver;
22
+ //# sourceMappingURL=jws-algorithm-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jws-algorithm-resolver.js","sourceRoot":"","sources":["../../../src/node/registration/jws-algorithm-resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qDAAoD;AACpD,mEAAmF;AACnF,uCAAyC;AAGlC,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAEpC,KAAK,CAAC,MAAM,CAAC,kBAAsC;QAC/C,OAAO,2BAAa,CAAC,KAAK,CAAC;IAC/B,CAAC;CAEJ,CAAA;AANY,2BAA2B;IADvC,IAAA,gBAAS,EAAC,4CAAoB,CAAC;GACnB,2BAA2B,CAMvC;AANY,kEAA2B"}
@@ -0,0 +1,15 @@
1
+ import { ClientRegistrationManager, ClientRegistration } from './registration-protocol';
2
+ import { ClientAuthenticationMethod } from '@celljs/oauth2-core';
3
+ export declare class InMemoryClientRegistrationManager implements ClientRegistrationManager {
4
+ protected readonly registrations: {
5
+ [id: string]: ClientRegistration;
6
+ };
7
+ protected readonly registrationTemplates: {
8
+ [id: string]: ClientRegistration;
9
+ };
10
+ protected readonly defaultRedirectUri: string;
11
+ protected initialized: boolean;
12
+ get(registrationId: string): Promise<ClientRegistration | undefined>;
13
+ protected deduceClientAuthenticationMethod(clientRegistration: ClientRegistration): ClientAuthenticationMethod.Basic | ClientAuthenticationMethod.None;
14
+ }
15
+ //# sourceMappingURL=registration-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-manager.d.ts","sourceRoot":"","sources":["../../../src/node/registration/registration-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAExF,OAAO,EAA0B,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEzF,qBACa,iCAAkC,YAAW,yBAAyB;IAG/E,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,CAAA;KAAE,CAAM;IAG5E,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,CAAA;KAAE,CAAM;IAGpF,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAE9C,SAAS,CAAC,WAAW,UAAS;IAExB,GAAG,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;IAoB1E,SAAS,CAAC,gCAAgC,CAAC,kBAAkB,EAAE,kBAAkB;CAQpF"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.InMemoryClientRegistrationManager = void 0;
13
+ const registration_protocol_1 = require("./registration-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ const oauth2_core_1 = require("@celljs/oauth2-core");
16
+ let InMemoryClientRegistrationManager = class InMemoryClientRegistrationManager {
17
+ constructor() {
18
+ this.registrations = {};
19
+ this.registrationTemplates = {};
20
+ this.initialized = false;
21
+ }
22
+ async get(registrationId) {
23
+ if (!this.initialized) {
24
+ for (const id in this.registrations) {
25
+ if (Object.prototype.hasOwnProperty.call(this.registrations, id)) {
26
+ const template = this.registrationTemplates[id];
27
+ const registration = Object.assign(Object.assign({}, template), this.registrations[id]);
28
+ this.registrations[id] = registration;
29
+ registration.registrationId = id;
30
+ registration.clientAuthenticationMethod = registration.clientAuthenticationMethod || this.deduceClientAuthenticationMethod(registration);
31
+ registration.redirectUri = registration.redirectUri || this.defaultRedirectUri;
32
+ registration.provider = registration.provider || id;
33
+ registration.clientName = registration.clientName || id;
34
+ }
35
+ }
36
+ this.initialized = true;
37
+ }
38
+ return this.registrations[registrationId];
39
+ }
40
+ deduceClientAuthenticationMethod(clientRegistration) {
41
+ if (oauth2_core_1.AuthorizationGrantType.AuthorizationCode === clientRegistration.authorizationGrantType
42
+ && !clientRegistration.clientSecret) {
43
+ return oauth2_core_1.ClientAuthenticationMethod.None;
44
+ }
45
+ return oauth2_core_1.ClientAuthenticationMethod.Basic;
46
+ }
47
+ };
48
+ __decorate([
49
+ (0, core_1.Value)('cell.oauth2.client.registrations'),
50
+ __metadata("design:type", Object)
51
+ ], InMemoryClientRegistrationManager.prototype, "registrations", void 0);
52
+ __decorate([
53
+ (0, core_1.Value)('cell.oauth2.client.registrationTemplates'),
54
+ __metadata("design:type", Object)
55
+ ], InMemoryClientRegistrationManager.prototype, "registrationTemplates", void 0);
56
+ __decorate([
57
+ (0, core_1.Value)('cell.oauth2.client.defaultRedirectUri'),
58
+ __metadata("design:type", String)
59
+ ], InMemoryClientRegistrationManager.prototype, "defaultRedirectUri", void 0);
60
+ InMemoryClientRegistrationManager = __decorate([
61
+ (0, core_1.Component)(registration_protocol_1.ClientRegistrationManager)
62
+ ], InMemoryClientRegistrationManager);
63
+ exports.InMemoryClientRegistrationManager = InMemoryClientRegistrationManager;
64
+ //# sourceMappingURL=registration-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-manager.js","sourceRoot":"","sources":["../../../src/node/registration/registration-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAAwF;AACxF,uCAAgD;AAChD,qDAAyF;AAGlF,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IAAvC;QAGgB,kBAAa,GAAyC,EAAE,CAAC;QAGzD,0BAAqB,GAAyC,EAAE,CAAC;QAK1E,gBAAW,GAAG,KAAK,CAAC;IA8BlC,CAAC;IA5BG,KAAK,CAAC,GAAG,CAAC,cAAsB;QAC5B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE;gBACjC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE;oBAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;oBAChD,MAAM,YAAY,mCAAQ,QAAQ,GAAK,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAE,CAAC;oBAChE,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC;oBACtC,YAAY,CAAC,cAAc,GAAG,EAAE,CAAC;oBACjC,YAAY,CAAC,0BAA0B,GAAG,YAAY,CAAC,0BAA0B,IAAI,IAAI,CAAC,gCAAgC,CAAC,YAAY,CAAC,CAAC;oBACzI,YAAY,CAAC,WAAW,GAAG,YAAY,CAAC,WAAW,IAAI,IAAI,CAAC,kBAAkB,CAAC;oBAC/E,YAAY,CAAC,QAAQ,GAAG,YAAY,CAAC,QAAQ,IAAI,EAAE,CAAC;oBACpD,YAAY,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU,IAAI,EAAE,CAAC;iBAC3D;aACJ;YACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SAC3B;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAC9C,CAAC;IAES,gCAAgC,CAAC,kBAAsC;QAC7E,IAAI,oCAAsB,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,sBAAsB;eACnF,CAAC,kBAAkB,CAAC,YAAY,EAAE;YACrC,OAAO,wCAA0B,CAAC,IAAI,CAAC;SAC1C;QACD,OAAO,wCAA0B,CAAC,KAAK,CAAC;IAC5C,CAAC;CAEJ,CAAA;AAvCG;IAAC,IAAA,YAAK,EAAC,kCAAkC,CAAC;;wEACkC;AAE5E;IAAC,IAAA,YAAK,EAAC,0CAA0C,CAAC;;gFACkC;AAEpF;IAAC,IAAA,YAAK,EAAC,uCAAuC,CAAC;;6EACD;AATrC,iCAAiC;IAD7C,IAAA,gBAAS,EAAC,iDAAyB,CAAC;GACxB,iCAAiC,CAyC7C;AAzCY,8EAAiC"}
@@ -0,0 +1,22 @@
1
+ import { ClientAuthenticationMethod, AuthorizationGrantType } from '@celljs/oauth2-core';
2
+ export declare const ClientRegistrationManager: unique symbol;
3
+ export declare const JwsAlgorithmResolver: unique symbol;
4
+ export declare const MISSING_SIGNATURE_VERIFIER_ERROR_CODE = "missing_signature_verifier";
5
+ export interface ClientRegistration {
6
+ registrationId: string;
7
+ clientId: string;
8
+ clientSecret: string;
9
+ clientAuthenticationMethod: ClientAuthenticationMethod;
10
+ authorizationGrantType: AuthorizationGrantType;
11
+ redirectUri: string;
12
+ scopes: string[];
13
+ provider: string;
14
+ clientName: string;
15
+ }
16
+ export interface ClientRegistrationManager {
17
+ get(registrationId: string): Promise<ClientRegistration | undefined>;
18
+ }
19
+ export interface JwsAlgorithmResolver {
20
+ reolve(clientRegistration: ClientRegistration): Promise<string>;
21
+ }
22
+ //# sourceMappingURL=registration-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/registration/registration-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEzF,eAAO,MAAM,yBAAyB,eAAsC,CAAC;AAC7E,eAAO,MAAM,oBAAoB,eAAiC,CAAC;AACnE,eAAO,MAAM,qCAAqC,+BAA+B,CAAC;AAElF,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B,EAAE,0BAA0B,CAAC;IACvD,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IAEtC,GAAG,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CAExE;AAED,MAAM,WAAW,oBAAoB;IACjC,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnE"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MISSING_SIGNATURE_VERIFIER_ERROR_CODE = exports.JwsAlgorithmResolver = exports.ClientRegistrationManager = void 0;
4
+ exports.ClientRegistrationManager = Symbol('ClientRegistrationManager');
5
+ exports.JwsAlgorithmResolver = Symbol('JwsAlgorithmResolver');
6
+ exports.MISSING_SIGNATURE_VERIFIER_ERROR_CODE = 'missing_signature_verifier';
7
+ //# sourceMappingURL=registration-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-protocol.js","sourceRoot":"","sources":["../../../src/node/registration/registration-protocol.ts"],"names":[],"mappings":";;;AAEa,QAAA,yBAAyB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAChE,QAAA,oBAAoB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AACtD,QAAA,qCAAqC,GAAG,4BAA4B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './user-protocol';
2
+ export * from './oauth2-user-service';
3
+ export * from './oidc-user-service';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./user-protocol"), exports);
18
+ __exportStar(require("./oauth2-user-service"), exports);
19
+ __exportStar(require("./oidc-user-service"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/user/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,wDAAsC;AACtC,sDAAoC"}
@@ -0,0 +1,10 @@
1
+ import { UserService } from '@celljs/security/lib/node';
2
+ import { User } from '@celljs/security';
3
+ import { OAuth2UserRequest, UserResponseClient } from '../endpoint';
4
+ import { ProviderDetailsManager } from '../provider';
5
+ export declare class OAuth2UserService implements UserService<OAuth2UserRequest, User> {
6
+ protected readonly providerDetailsManager: ProviderDetailsManager;
7
+ protected readonly userResponseClient: UserResponseClient<OAuth2UserRequest>;
8
+ load(userRequest: OAuth2UserRequest): Promise<User>;
9
+ }
10
+ //# sourceMappingURL=oauth2-user-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth2-user-service.d.ts","sourceRoot":"","sources":["../../../src/node/user/oauth2-user-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAA4E,MAAM,aAAa,CAAC;AAC9I,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGrD,qBACa,iBAAkB,YAAW,WAAW,CAAC,iBAAiB,EAAE,IAAI,CAAC;IAG1E,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAGlE,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IAEvE,IAAI,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAgC5D"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OAuth2UserService = void 0;
13
+ const core_1 = require("@celljs/core");
14
+ const endpoint_1 = require("../endpoint");
15
+ const provider_1 = require("../provider");
16
+ const oauth2_core_1 = require("@celljs/oauth2-core");
17
+ let OAuth2UserService = class OAuth2UserService {
18
+ async load(userRequest) {
19
+ const { clientRegistration } = userRequest;
20
+ const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
21
+ if (!(providerDetails === null || providerDetails === void 0 ? void 0 : providerDetails.userInfoEndpoint.uri)) {
22
+ throw new oauth2_core_1.OAuth2AuthenticationError({
23
+ errorCode: endpoint_1.MISSING_USER_INFO_URI_ERROR_CODE,
24
+ description: `Missing required UserInfo Uri in UserInfoEndpoint for Client Registration: ${clientRegistration.registrationId}`
25
+ });
26
+ }
27
+ const userNameAttributeName = providerDetails.userInfoEndpoint.userNameAttributeName;
28
+ if (!userNameAttributeName) {
29
+ throw new oauth2_core_1.OAuth2AuthenticationError({
30
+ errorCode: endpoint_1.MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE,
31
+ description: `Missing required "user name" attribute name in UserInfoEndpoint for Client Registration: ${clientRegistration.registrationId}`
32
+ });
33
+ }
34
+ const { userAttributes } = await this.userResponseClient.getUserResponse(userRequest);
35
+ const claims = userAttributes;
36
+ return {
37
+ type: clientRegistration.registrationId,
38
+ username: claims[userNameAttributeName],
39
+ password: '',
40
+ accountNonExpired: true,
41
+ accountNonLocked: true,
42
+ credentialsNonExpired: true,
43
+ enabled: true,
44
+ policies: [],
45
+ claims
46
+ };
47
+ }
48
+ };
49
+ __decorate([
50
+ (0, core_1.Autowired)(provider_1.ProviderDetailsManager),
51
+ __metadata("design:type", Object)
52
+ ], OAuth2UserService.prototype, "providerDetailsManager", void 0);
53
+ __decorate([
54
+ (0, core_1.Autowired)(endpoint_1.UserResponseClient),
55
+ __metadata("design:type", Object)
56
+ ], OAuth2UserService.prototype, "userResponseClient", void 0);
57
+ OAuth2UserService = __decorate([
58
+ (0, core_1.Component)()
59
+ ], OAuth2UserService);
60
+ exports.OAuth2UserService = OAuth2UserService;
61
+ //# sourceMappingURL=oauth2-user-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth2-user-service.js","sourceRoot":"","sources":["../../../src/node/user/oauth2-user-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAoD;AAGpD,0CAA8I;AAC9I,0CAAqD;AACrD,qDAAgE;AAGzD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAQ1B,KAAK,CAAC,IAAI,CAAC,WAA8B;QACrC,MAAM,EAAE,kBAAkB,EAAE,GAAG,WAAW,CAAC;QAC3C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAC3F,IAAI,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,gBAAgB,CAAC,GAAG,CAAA,EAAE;YACxC,MAAM,IAAI,uCAAyB,CAAC;gBAChC,SAAS,EAAE,2CAAgC;gBAC3C,WAAW,EAAE,8EAA8E,kBAAkB,CAAC,cAAc,EAAE;aACjI,CAAC,CAAC;SACN;QACD,MAAM,qBAAqB,GAAG,eAAe,CAAC,gBAAgB,CAAC,qBAAqB,CAAC;QACrF,IAAI,CAAC,qBAAqB,EAAE;YACxB,MAAM,IAAI,uCAAyB,CAAC;gBAChC,SAAS,EAAE,iDAAsC;gBACjD,WAAW,EAAE,4FAA4F,kBAAkB,CAAC,cAAc,EAAE;aAC/I,CAAC,CAAC;SACN;QACD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QAEtF,MAAM,MAAM,GAAG,cAAc,CAAC;QAE9B,OAAO;YACH,IAAI,EAAE,kBAAkB,CAAC,cAAc;YACvC,QAAQ,EAAE,MAAM,CAAC,qBAAqB,CAAC;YACvC,QAAQ,EAAE,EAAE;YACZ,iBAAiB,EAAE,IAAI;YACvB,gBAAgB,EAAE,IAAI;YACtB,qBAAqB,EAAE,IAAI;YAC3B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,EAAE;YACZ,MAAM;SACT,CAAC;IACN,CAAC;CACJ,CAAA;AAtCG;IAAC,IAAA,gBAAS,EAAC,iCAAsB,CAAC;;iEACgC;AAElE;IAAC,IAAA,gBAAS,EAAC,6BAAkB,CAAC;;6DAC+C;AANpE,iBAAiB;IAD7B,IAAA,gBAAS,GAAE;GACC,iBAAiB,CAwC7B;AAxCY,8CAAiB"}
@@ -0,0 +1,13 @@
1
+ import { UserService } from '@celljs/security/lib/node';
2
+ import { User } from '@celljs/security';
3
+ import { OidcUserRequest } from './user-protocol';
4
+ import { OAuth2UserRequest, UserResponseClient } from '../endpoint';
5
+ import { ProviderDetailsManager } from '../provider';
6
+ export declare class OidcUserService implements UserService<OidcUserRequest, User> {
7
+ protected readonly accessibleScopes: string[];
8
+ protected readonly providerDetailsManager: ProviderDetailsManager;
9
+ protected readonly userResponseClient: UserResponseClient<OAuth2UserRequest>;
10
+ load(userRequest: OidcUserRequest): Promise<User>;
11
+ protected shuldRetrieveuserInfo(userRequest: OidcUserRequest): Promise<boolean>;
12
+ }
13
+ //# sourceMappingURL=oidc-user-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidc-user-service.d.ts","sourceRoot":"","sources":["../../../src/node/user/oidc-user-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAyC,MAAM,aAAa,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGrD,qBACa,eAAgB,YAAW,WAAW,CAAC,eAAe,EAAE,IAAI,CAAC;IAGtE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAG9C,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAGlE,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IAEvE,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;cAiDvC,qBAAqB,CAAC,WAAW,EAAE,eAAe;CAsBrE"}