@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,155 @@
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.DefaultAuthorizationRequestResolver = exports.REGISTRATION_ID_URI_VARIABLE_NAME = void 0;
13
+ const authorization_protocol_1 = require("./authorization-protocol");
14
+ const oauth2_core_1 = require("@celljs/oauth2-core");
15
+ const core_1 = require("@celljs/core");
16
+ const registration_1 = require("../registration");
17
+ const node_1 = require("@celljs/web/lib/node");
18
+ const constants_1 = require("../constants");
19
+ const node_2 = require("@celljs/security/lib/node");
20
+ const crypto_js_1 = require("crypto-js");
21
+ const provider_1 = require("../provider");
22
+ const qs = require("qs");
23
+ const web_1 = require("@celljs/web");
24
+ exports.REGISTRATION_ID_URI_VARIABLE_NAME = 'registrationId';
25
+ let DefaultAuthorizationRequestResolver = class DefaultAuthorizationRequestResolver {
26
+ async resolve(clientRegistrationId) {
27
+ const registrationId = clientRegistrationId || await this.resolveRegistrationId();
28
+ if (registrationId) {
29
+ const redirectUriAction = this.getAction();
30
+ return this.doResolve(registrationId, redirectUriAction);
31
+ }
32
+ }
33
+ async doResolve(registrationId, redirectUriAction) {
34
+ const clientRegistration = await this.clientRegistrationManager.get(registrationId);
35
+ if (!clientRegistration) {
36
+ throw new core_1.IllegalArgumentError(`Invalid Client Registration with Id: ${registrationId}`);
37
+ }
38
+ const attributes = {};
39
+ attributes[oauth2_core_1.OAuth2ParameterNames.REGISTRATION_ID] = clientRegistration.registrationId;
40
+ if (oauth2_core_1.AuthorizationGrantType.AuthorizationCode === clientRegistration.authorizationGrantType) {
41
+ const additionalParameters = {};
42
+ const scopes = clientRegistration.scopes;
43
+ if (scopes.indexOf(oauth2_core_1.OidcScopes.OPENID)) {
44
+ await this.addNonceParameters(attributes, additionalParameters);
45
+ }
46
+ if (oauth2_core_1.ClientAuthenticationMethod.None === clientRegistration.clientAuthenticationMethod) {
47
+ await this.addPkceParameters(attributes, additionalParameters);
48
+ }
49
+ const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
50
+ if (!providerDetails) {
51
+ throw new core_1.IllegalArgumentError(`Invalid Provider Details with Id: ${clientRegistration.provider}`);
52
+ }
53
+ const authorizationRequest = {
54
+ authorizationGrantType: clientRegistration.authorizationGrantType,
55
+ responseType: clientRegistration.authorizationGrantType === oauth2_core_1.AuthorizationGrantType.AuthorizationCode ? oauth2_core_1.AuthorizationResponseType.Code : undefined,
56
+ clientId: clientRegistration.clientId,
57
+ authorizationUri: providerDetails.authorizationUri,
58
+ redirectUri: await this.expandRedirectUri(clientRegistration, redirectUriAction),
59
+ scopes: clientRegistration.scopes,
60
+ state: await this.base64StringKeyGenerator.generateKey(),
61
+ attributes,
62
+ additionalParameters
63
+ };
64
+ authorizationRequest.authorizationRequestUri = `${authorizationRequest.authorizationUri}?${qs.stringify(this.getParameters(authorizationRequest))}`;
65
+ return authorizationRequest;
66
+ }
67
+ throw new core_1.IllegalArgumentError(`Invalid Authorization Grant Type (${clientRegistration.authorizationGrantType}) for Client Registration with Id: ${clientRegistration.registrationId}`);
68
+ }
69
+ getParameters(authorizationRequest) {
70
+ const parameters = {};
71
+ parameters[oauth2_core_1.OAuth2ParameterNames.RESPONSE_TYPE] = authorizationRequest.responseType;
72
+ parameters[oauth2_core_1.OAuth2ParameterNames.CLIENT_ID] = authorizationRequest.clientId;
73
+ if (authorizationRequest.scopes) {
74
+ parameters[oauth2_core_1.OAuth2ParameterNames.SCOPE] = authorizationRequest.scopes.join(' ');
75
+ }
76
+ if (authorizationRequest.state) {
77
+ parameters[oauth2_core_1.OAuth2ParameterNames.STATE] = authorizationRequest.state;
78
+ }
79
+ if (authorizationRequest.redirectUri) {
80
+ parameters[oauth2_core_1.OAuth2ParameterNames.REDIRECT_URI] = authorizationRequest.redirectUri;
81
+ }
82
+ for (const key in authorizationRequest.additionalParameters) {
83
+ if (Object.prototype.hasOwnProperty.call(authorizationRequest.additionalParameters, key)) {
84
+ parameters[key] = authorizationRequest.additionalParameters[key];
85
+ }
86
+ }
87
+ return parameters;
88
+ }
89
+ expandRedirectUri(clientRegistration, action) {
90
+ const redirectUri = clientRegistration.redirectUri || this.defaultRedirectUri;
91
+ return this.pathResolver.resolve(web_1.UrlUtil.isAbsoluteUrl(redirectUri) ? '' : this.endpoint, redirectUri.replace('{action}', action).replace(`{${exports.REGISTRATION_ID_URI_VARIABLE_NAME}}`, clientRegistration.registrationId));
92
+ }
93
+ async addNonceParameters(attributes, additionalParameters) {
94
+ const nonce = await this.base64StringKeyGenerator.generateKey(96);
95
+ const nonceHash = this.createHash(nonce);
96
+ attributes[oauth2_core_1.OidcParameterNames.NONCE] = nonce;
97
+ additionalParameters[oauth2_core_1.OidcParameterNames.NONCE] = nonceHash;
98
+ }
99
+ async addPkceParameters(attributes, additionalParameters) {
100
+ const codeVerifier = await this.base64StringKeyGenerator.generateKey(96);
101
+ attributes[oauth2_core_1.PkceParameterNames.CODE_VERIFIER] = codeVerifier;
102
+ const codeChallenge = this.createHash(codeVerifier);
103
+ additionalParameters[oauth2_core_1.PkceParameterNames.CODE_CHALLENGE] = codeChallenge;
104
+ additionalParameters[oauth2_core_1.PkceParameterNames.CODE_CHALLENGE_METHOD] = 'S256';
105
+ }
106
+ createHash(nonce) {
107
+ return crypto_js_1.enc.Base64.stringify((0, crypto_js_1.SHA256)(nonce));
108
+ }
109
+ async resolveRegistrationId() {
110
+ const params = await this.requestMatcher.match(`${this.authorizationRequestBaseUri}/:${exports.REGISTRATION_ID_URI_VARIABLE_NAME}`);
111
+ if (params) {
112
+ return params[exports.REGISTRATION_ID_URI_VARIABLE_NAME];
113
+ }
114
+ }
115
+ getAction(defaultAction = 'login') {
116
+ return node_1.Context.getRequest().query['action'] || defaultAction;
117
+ }
118
+ };
119
+ __decorate([
120
+ (0, core_1.Autowired)(registration_1.ClientRegistrationManager),
121
+ __metadata("design:type", Object)
122
+ ], DefaultAuthorizationRequestResolver.prototype, "clientRegistrationManager", void 0);
123
+ __decorate([
124
+ (0, core_1.Autowired)(provider_1.ProviderDetailsManager),
125
+ __metadata("design:type", Object)
126
+ ], DefaultAuthorizationRequestResolver.prototype, "providerDetailsManager", void 0);
127
+ __decorate([
128
+ (0, core_1.Autowired)(node_1.RequestMatcher),
129
+ __metadata("design:type", Object)
130
+ ], DefaultAuthorizationRequestResolver.prototype, "requestMatcher", void 0);
131
+ __decorate([
132
+ (0, core_1.Autowired)(node_2.Base64StringKeyGenerator),
133
+ __metadata("design:type", node_2.Base64StringKeyGenerator)
134
+ ], DefaultAuthorizationRequestResolver.prototype, "base64StringKeyGenerator", void 0);
135
+ __decorate([
136
+ (0, core_1.Autowired)(web_1.PathResolver),
137
+ __metadata("design:type", Object)
138
+ ], DefaultAuthorizationRequestResolver.prototype, "pathResolver", void 0);
139
+ __decorate([
140
+ (0, core_1.Value)(constants_1.AUTHORIZATION_REQUEST_BASE_URI),
141
+ __metadata("design:type", String)
142
+ ], DefaultAuthorizationRequestResolver.prototype, "authorizationRequestBaseUri", void 0);
143
+ __decorate([
144
+ (0, core_1.Value)(constants_1.DEFAULT_REDIRECT_URI),
145
+ __metadata("design:type", String)
146
+ ], DefaultAuthorizationRequestResolver.prototype, "defaultRedirectUri", void 0);
147
+ __decorate([
148
+ (0, core_1.Value)(web_1.ENDPOINT),
149
+ __metadata("design:type", String)
150
+ ], DefaultAuthorizationRequestResolver.prototype, "endpoint", void 0);
151
+ DefaultAuthorizationRequestResolver = __decorate([
152
+ (0, core_1.Component)(authorization_protocol_1.AuthorizationRequestResolver)
153
+ ], DefaultAuthorizationRequestResolver);
154
+ exports.DefaultAuthorizationRequestResolver = DefaultAuthorizationRequestResolver;
155
+ //# sourceMappingURL=authorization-request-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-request-resolver.js","sourceRoot":"","sources":["../../../src/node/authorization/authorization-request-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEAAwE;AACxE,qDACmK;AACnK,uCAAiF;AACjF,kDAAgF;AAChF,+CAA+D;AAC/D,4CAAoF;AACpF,oDAAqE;AACrE,yCAAwC;AACxC,0CAAqD;AACrD,yBAAyB;AACzB,qCAA8D;AAEjD,QAAA,iCAAiC,GAAG,gBAAgB,CAAC;AAG3D,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IA0B5C,KAAK,CAAC,OAAO,CAAC,oBAA6B;QACvC,MAAM,cAAc,GAAG,oBAAoB,IAAI,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAClF,IAAI,cAAc,EAAE;YAChB,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAC3C,O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C;IAAC,IAAA,YAAK,EAAC,cAAQ,CAAC;;qEACoB;AAxB3B,mCAAmC;IAD/C,IAAA,gBAAS,EAAC,qDAA4B,CAAC;GAC3B,mCAAmC,CAoI/C;AApIY,kFAAmC"}
@@ -0,0 +1,7 @@
1
+ import { AuthorizationSuccessHandler, AuthorizedClient, AuthorizedClientManager } from './authorization-protocol';
2
+ import { Authentication } from '@celljs/security/lib/node';
3
+ export declare class DefaultAuthorizationSuccessHandler implements AuthorizationSuccessHandler {
4
+ protected readonly authorizedClientManager: AuthorizedClientManager<AuthorizedClient>;
5
+ onAuthorizationSuccess(authorizedClient: AuthorizedClient, principal: Authentication): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=authorization-success-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-success-handler.d.ts","sourceRoot":"","sources":["../../../src/node/authorization/authorization-success-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAClH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,qBACa,kCAAmC,YAAW,2BAA2B;IAGlF,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;IAEtF,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAIvG"}
@@ -0,0 +1,28 @@
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.DefaultAuthorizationSuccessHandler = void 0;
13
+ const authorization_protocol_1 = require("./authorization-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ let DefaultAuthorizationSuccessHandler = class DefaultAuthorizationSuccessHandler {
16
+ onAuthorizationSuccess(authorizedClient, principal) {
17
+ return this.authorizedClientManager.save(authorizedClient, principal.name);
18
+ }
19
+ };
20
+ __decorate([
21
+ (0, core_1.Autowired)(authorization_protocol_1.AuthorizedClientManager),
22
+ __metadata("design:type", Object)
23
+ ], DefaultAuthorizationSuccessHandler.prototype, "authorizedClientManager", void 0);
24
+ DefaultAuthorizationSuccessHandler = __decorate([
25
+ (0, core_1.Component)(authorization_protocol_1.AuthorizationSuccessHandler)
26
+ ], DefaultAuthorizationSuccessHandler);
27
+ exports.DefaultAuthorizationSuccessHandler = DefaultAuthorizationSuccessHandler;
28
+ //# sourceMappingURL=authorization-success-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-success-handler.js","sourceRoot":"","sources":["../../../src/node/authorization/authorization-success-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEAAkH;AAElH,uCAAoD;AAG7C,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IAK3C,sBAAsB,CAAC,gBAAkC,EAAE,SAAyB;QAChF,OAAO,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/E,CAAC;CAEJ,CAAA;AAPG;IAAC,IAAA,gBAAS,EAAC,gDAAuB,CAAC;;mFACmD;AAH7E,kCAAkC;IAD9C,IAAA,gBAAS,EAAC,oDAA2B,CAAC;GAC1B,kCAAkC,CAS9C;AATY,gFAAkC"}
@@ -0,0 +1,11 @@
1
+ import { AuthorizedClient, AuthorizedClientManager } from './authorization-protocol';
2
+ import { ClientRegistrationManager } from '../registration';
3
+ export declare class InMemoryAuthorizedClientManager implements AuthorizedClientManager<AuthorizedClient> {
4
+ protected readonly authorizedClients: Map<string, AuthorizedClient>;
5
+ protected readonly clientRegistrationManager: ClientRegistrationManager;
6
+ get(clientRegistrationId: string, principalName: string): Promise<AuthorizedClient | undefined>;
7
+ save(authorizedClient: AuthorizedClient, principalName: string): Promise<void>;
8
+ remove(clientRegistrationId: string, principalName: string): Promise<void>;
9
+ protected getId(clientRegistrationId: string, principalName: string): string;
10
+ }
11
+ //# sourceMappingURL=authorized-client-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorized-client-manager.d.ts","sourceRoot":"","sources":["../../../src/node/authorization/authorized-client-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAErF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,qBACa,+BAAgC,YAAW,uBAAuB,CAAC,gBAAgB,CAAC;IAE7F,SAAS,CAAC,QAAQ,CAAC,iBAAiB,gCAAuC;IAG3E,SAAS,CAAC,QAAQ,CAAC,yBAAyB,EAAE,yBAAyB,CAAC;IAElE,GAAG,CAAC,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAM/F,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9E,MAAM,CAAC,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhF,SAAS,CAAC,KAAK,CAAC,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAItE"}
@@ -0,0 +1,48 @@
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.InMemoryAuthorizedClientManager = void 0;
13
+ const authorization_protocol_1 = require("./authorization-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ const registration_1 = require("../registration");
16
+ let InMemoryAuthorizedClientManager = class InMemoryAuthorizedClientManager {
17
+ constructor() {
18
+ this.authorizedClients = new Map();
19
+ }
20
+ async get(clientRegistrationId, principalName) {
21
+ const registration = await this.clientRegistrationManager.get(clientRegistrationId);
22
+ if (registration) {
23
+ return this.authorizedClients.get(this.getId(clientRegistrationId, principalName));
24
+ }
25
+ }
26
+ async save(authorizedClient, principalName) {
27
+ const { clientRegistration } = authorizedClient;
28
+ this.authorizedClients.set(this.getId(clientRegistration.registrationId, principalName), authorizedClient);
29
+ }
30
+ async remove(clientRegistrationId, principalName) {
31
+ const registration = await this.clientRegistrationManager.get(clientRegistrationId);
32
+ if (registration) {
33
+ this.authorizedClients.delete(this.getId(clientRegistrationId, principalName));
34
+ }
35
+ }
36
+ getId(clientRegistrationId, principalName) {
37
+ return `${clientRegistrationId}@${principalName}`;
38
+ }
39
+ };
40
+ __decorate([
41
+ (0, core_1.Autowired)(registration_1.ClientRegistrationManager),
42
+ __metadata("design:type", Object)
43
+ ], InMemoryAuthorizedClientManager.prototype, "clientRegistrationManager", void 0);
44
+ InMemoryAuthorizedClientManager = __decorate([
45
+ (0, core_1.Component)(authorization_protocol_1.AuthorizedClientManager)
46
+ ], InMemoryAuthorizedClientManager);
47
+ exports.InMemoryAuthorizedClientManager = InMemoryAuthorizedClientManager;
48
+ //# sourceMappingURL=authorized-client-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorized-client-manager.js","sourceRoot":"","sources":["../../../src/node/authorization/authorized-client-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEAAqF;AACrF,uCAAoD;AACpD,kDAA4D;AAGrD,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAArC;QAEgB,sBAAiB,GAAG,IAAI,GAAG,EAA4B,CAAC;IA2B/E,CAAC;IAtBG,KAAK,CAAC,GAAG,CAAC,oBAA4B,EAAE,aAAqB;QACzD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QACpF,IAAI,YAAY,EAAE;YACd,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC,CAAC;SACtF;IACL,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,gBAAkC,EAAE,aAAqB;QAChE,MAAM,EAAE,kBAAkB,EAAE,GAAG,gBAAgB,CAAC;QAChD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,cAAc,EAAE,aAAa,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC/G,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,oBAA4B,EAAE,aAAqB;QAC5D,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QACpF,IAAI,YAAY,EAAE;YACd,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC,CAAC;SAClF;IACL,CAAC;IAES,KAAK,CAAC,oBAA4B,EAAE,aAAqB;QAC/D,OAAO,GAAG,oBAAoB,IAAI,aAAa,EAAE,CAAC;IACtD,CAAC;CAEJ,CAAA;AAzBG;IAAC,IAAA,gBAAS,EAAC,wCAAyB,CAAC;;kFACmC;AAL/D,+BAA+B;IAD3C,IAAA,gBAAS,EAAC,gDAAuB,CAAC;GACtB,+BAA+B,CA6B3C;AA7BY,0EAA+B"}
@@ -0,0 +1,12 @@
1
+ import { AuthorizedClientService, AuthorizeRequest, AuthorizedClient, AuthorizedClientProvider, AuthorizedClientManager, ContextAttributesMapper, AuthorizationSuccessHandler, AuthorizationFailureHandler } from './authorization-protocol';
2
+ import { ClientRegistrationManager } from '../registration';
3
+ export declare class DefaultAuthorizedClientService implements AuthorizedClientService {
4
+ protected readonly authorizedClientProviders: AuthorizedClientProvider[];
5
+ protected readonly clientRegistrationManager: ClientRegistrationManager;
6
+ protected readonly authorizedClientManager: AuthorizedClientManager<AuthorizedClient>;
7
+ protected readonly contextAttributesMapper: ContextAttributesMapper;
8
+ protected readonly authorizationSuccessHandler: AuthorizationSuccessHandler;
9
+ protected readonly authorizationFailureHandler: AuthorizationFailureHandler;
10
+ authorize(authorizeRequest: AuthorizeRequest): Promise<AuthorizedClient | undefined>;
11
+ }
12
+ //# sourceMappingURL=authorized-client-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorized-client-service.d.ts","sourceRoot":"","sources":["../../../src/node/authorization/authorized-client-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,wBAAwB,EAAwB,uBAAuB,EACzI,uBAAuB,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAExH,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAI5D,qBACa,8BAA+B,YAAW,uBAAuB;IAG1E,SAAS,CAAC,QAAQ,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,CAAC;IAGzE,SAAS,CAAC,QAAQ,CAAC,yBAAyB,EAAE,yBAAyB,CAAC;IAGxE,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;IAGtF,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;IAGpE,SAAS,CAAC,QAAQ,CAAC,2BAA2B,EAAE,2BAA2B,CAAC;IAG5E,SAAS,CAAC,QAAQ,CAAC,2BAA2B,EAAE,2BAA2B,CAAC;IAEtE,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;CA4C7F"}
@@ -0,0 +1,87 @@
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.DefaultAuthorizedClientService = void 0;
13
+ const authorization_protocol_1 = require("./authorization-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ const registration_1 = require("../registration");
16
+ const assert_1 = require("assert");
17
+ const oauth2_core_1 = require("@celljs/oauth2-core");
18
+ let DefaultAuthorizedClientService = class DefaultAuthorizedClientService {
19
+ async authorize(authorizeRequest) {
20
+ const { clientRegistrationId, principal, authorizedClient, attributes } = authorizeRequest;
21
+ const contextAttributes = await this.contextAttributesMapper.apply(authorizeRequest);
22
+ if (attributes) {
23
+ for (const [key, value] of attributes.entries()) {
24
+ contextAttributes.set(key, value);
25
+ }
26
+ }
27
+ const context = {
28
+ principal,
29
+ attributes: contextAttributes
30
+ };
31
+ if (!authorizedClient) {
32
+ const clientRegistration = await this.clientRegistrationManager.get(clientRegistrationId);
33
+ (0, assert_1.ok)(clientRegistration, `Could not find ClientRegistration with id '${clientRegistrationId}'`);
34
+ context.clientRegistration = clientRegistration;
35
+ context.authorizedClient = await this.authorizedClientManager.get(clientRegistrationId, principal.name);
36
+ }
37
+ let client;
38
+ try {
39
+ for (const authorizedClientProvider of this.authorizedClientProviders) {
40
+ client = await authorizedClientProvider.provide(context);
41
+ if (client) {
42
+ break;
43
+ }
44
+ }
45
+ }
46
+ catch (error) {
47
+ if (error instanceof oauth2_core_1.OAuth2AuthorizationError) {
48
+ await this.authorizationFailureHandler.onAuthorizationFailure(error, principal);
49
+ }
50
+ throw error;
51
+ }
52
+ if (client) {
53
+ await this.authorizationSuccessHandler.onAuthorizationSuccess(client, principal);
54
+ return client;
55
+ }
56
+ return authorizedClient;
57
+ }
58
+ };
59
+ __decorate([
60
+ (0, core_1.Autowired)(authorization_protocol_1.AuthorizedClientProvider),
61
+ __metadata("design:type", Array)
62
+ ], DefaultAuthorizedClientService.prototype, "authorizedClientProviders", void 0);
63
+ __decorate([
64
+ (0, core_1.Autowired)(registration_1.ClientRegistrationManager),
65
+ __metadata("design:type", Object)
66
+ ], DefaultAuthorizedClientService.prototype, "clientRegistrationManager", void 0);
67
+ __decorate([
68
+ (0, core_1.Autowired)(authorization_protocol_1.AuthorizedClientManager),
69
+ __metadata("design:type", Object)
70
+ ], DefaultAuthorizedClientService.prototype, "authorizedClientManager", void 0);
71
+ __decorate([
72
+ (0, core_1.Autowired)(authorization_protocol_1.ContextAttributesMapper),
73
+ __metadata("design:type", Object)
74
+ ], DefaultAuthorizedClientService.prototype, "contextAttributesMapper", void 0);
75
+ __decorate([
76
+ (0, core_1.Autowired)(authorization_protocol_1.AuthorizationSuccessHandler),
77
+ __metadata("design:type", Object)
78
+ ], DefaultAuthorizedClientService.prototype, "authorizationSuccessHandler", void 0);
79
+ __decorate([
80
+ (0, core_1.Autowired)(authorization_protocol_1.AuthorizationFailureHandler),
81
+ __metadata("design:type", Object)
82
+ ], DefaultAuthorizedClientService.prototype, "authorizationFailureHandler", void 0);
83
+ DefaultAuthorizedClientService = __decorate([
84
+ (0, core_1.Component)(authorization_protocol_1.AuthorizedClientService)
85
+ ], DefaultAuthorizedClientService);
86
+ exports.DefaultAuthorizedClientService = DefaultAuthorizedClientService;
87
+ //# sourceMappingURL=authorized-client-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorized-client-service.js","sourceRoot":"","sources":["../../../src/node/authorization/authorized-client-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEACwH;AACxH,uCAAoD;AACpD,kDAA4D;AAC5D,mCAA4B;AAC5B,qDAA+D;AAGxD,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAoBvC,KAAK,CAAC,SAAS,CAAC,gBAAkC;QAC9C,MAAM,EAAE,oBAAoB,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,gBAAgB,CAAC;QAC3F,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAErF,IAAI,UAAU,EAAE;YACZ,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE;gBAC7C,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACrC;SACJ;QACD,MAAM,OAAO,GAAyB;YAClC,SAAS;YACT,UAAU,EAAE,iBAAiB;SAChC,CAAC;QACF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C;AAE5E;IAAC,IAAA,gBAAS,EAAC,oDAA2B,CAAC;;mFACqC;AAlBnE,8BAA8B;IAD1C,IAAA,gBAAS,EAAC,gDAAuB,CAAC;GACtB,8BAA8B,CAgE1C;AAhEY,wEAA8B"}
@@ -0,0 +1,12 @@
1
+ import { AuthorizedClientProvider, AuthorizationContext, AuthorizedClient } from './authorization-protocol';
2
+ import { AccessToken } from '@celljs/oauth2-core';
3
+ import { ClientCredentialsTokenResponseClient } from '../endpoint';
4
+ import { ClientRegistration } from '../registration';
5
+ export declare class ClientCredentialsAuthorizedClientProvider implements AuthorizedClientProvider {
6
+ protected readonly clockSkew: number;
7
+ protected readonly accessTokenResponseClient: ClientCredentialsTokenResponseClient;
8
+ provide(context: AuthorizationContext): Promise<AuthorizedClient | undefined>;
9
+ hasTokenExpired(accessToken: AccessToken): boolean;
10
+ protected getTokenResponse(clientRegistration: ClientRegistration): Promise<import("@celljs/oauth2-core").AccessTokenResponse>;
11
+ }
12
+ //# sourceMappingURL=client-credentials-authorized-client-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-credentials-authorized-client-provider.d.ts","sourceRoot":"","sources":["../../../src/node/authorization/client-credentials-authorized-client-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAoD,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEpG,OAAO,EAAE,oCAAoC,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,qBACa,yCAA0C,YAAW,wBAAwB;IAGtF,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAGrC,SAAS,CAAC,QAAQ,CAAC,yBAAyB,EAAE,oCAAoC,CAAC;IAE7E,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IA0BnF,eAAe,CAAC,WAAW,EAAE,WAAW;IAIxC,SAAS,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,kBAAkB;CAcpE"}
@@ -0,0 +1,72 @@
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.ClientCredentialsAuthorizedClientProvider = void 0;
13
+ const authorization_protocol_1 = require("./authorization-protocol");
14
+ const oauth2_core_1 = require("@celljs/oauth2-core");
15
+ const core_1 = require("@celljs/core");
16
+ const endpoint_1 = require("../endpoint");
17
+ const error_1 = require("../error");
18
+ let ClientCredentialsAuthorizedClientProvider = class ClientCredentialsAuthorizedClientProvider {
19
+ async provide(context) {
20
+ const { clientRegistration, authorizedClient } = context;
21
+ if (oauth2_core_1.AuthorizationGrantType.ClientCredentials !== clientRegistration.authorizationGrantType) {
22
+ return;
23
+ }
24
+ if (authorizedClient && !this.hasTokenExpired(authorizedClient.accessToken)) {
25
+ // If client is already authorized but access token is NOT expired than no
26
+ // need for re-authorization
27
+ return;
28
+ }
29
+ // As per spec, in section 4.4.3 Access Token Response
30
+ // https://tools.ietf.org/html/rfc6749#section-4.4.3
31
+ // A refresh token SHOULD NOT be included.
32
+ //
33
+ // Therefore, renewing an expired access token (re-authorization)
34
+ // is the same as acquiring a new access token (authorization).
35
+ const tokenResponse = await this.getTokenResponse(clientRegistration);
36
+ return {
37
+ clientRegistration,
38
+ principalName: context.principal.name,
39
+ accessToken: tokenResponse.accessToken
40
+ };
41
+ }
42
+ hasTokenExpired(accessToken) {
43
+ return accessToken.expiresAt - Date.now() < this.clockSkew;
44
+ }
45
+ getTokenResponse(clientRegistration) {
46
+ try {
47
+ return this.accessTokenResponseClient.getTokenResponse({
48
+ authorizationGrantType: oauth2_core_1.AuthorizationGrantType.ClientCredentials,
49
+ clientRegistration
50
+ });
51
+ }
52
+ catch (error) {
53
+ if (error instanceof oauth2_core_1.OAuth2AuthorizationError) {
54
+ throw new error_1.ClientAuthorizationError(error.oauth2Error, clientRegistration.registrationId, error);
55
+ }
56
+ throw error;
57
+ }
58
+ }
59
+ };
60
+ __decorate([
61
+ (0, core_1.Value)('cell.oauth2.client.clockSkew'),
62
+ __metadata("design:type", Number)
63
+ ], ClientCredentialsAuthorizedClientProvider.prototype, "clockSkew", void 0);
64
+ __decorate([
65
+ (0, core_1.Autowired)(endpoint_1.ClientCredentialsTokenResponseClient),
66
+ __metadata("design:type", endpoint_1.ClientCredentialsTokenResponseClient)
67
+ ], ClientCredentialsAuthorizedClientProvider.prototype, "accessTokenResponseClient", void 0);
68
+ ClientCredentialsAuthorizedClientProvider = __decorate([
69
+ (0, core_1.Component)(authorization_protocol_1.AuthorizedClientProvider)
70
+ ], ClientCredentialsAuthorizedClientProvider);
71
+ exports.ClientCredentialsAuthorizedClientProvider = ClientCredentialsAuthorizedClientProvider;
72
+ //# sourceMappingURL=client-credentials-authorized-client-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-credentials-authorized-client-provider.js","sourceRoot":"","sources":["../../../src/node/authorization/client-credentials-authorized-client-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEAA4G;AAC5G,qDAAoG;AACpG,uCAA2D;AAC3D,0CAAmE;AAEnE,oCAAoD;AAG7C,IAAM,yCAAyC,GAA/C,MAA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AAS,EAAC,+CAAoC,CAAC;8BACF,+CAAoC;4FAAC;AAN1E,yCAAyC;IADrD,IAAA,gBAAS,EAAC,iDAAwB,CAAC;GACvB,yCAAyC,CAoDrD;AApDY,8FAAyC"}
@@ -0,0 +1,5 @@
1
+ import { ContextAttributesMapper, AuthorizeRequest } from './authorization-protocol';
2
+ export declare class DefaultContextAttributesMapper implements ContextAttributesMapper {
3
+ apply(authorizeRequest: AuthorizeRequest): Promise<Map<string, any>>;
4
+ }
5
+ //# sourceMappingURL=context-attributes-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-attributes-mapper.d.ts","sourceRoot":"","sources":["../../../src/node/authorization/context-attributes-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAwB,MAAM,0BAA0B,CAAC;AAK3G,qBACa,8BAA+B,YAAW,uBAAuB;IAEpE,KAAK,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAS7E"}
@@ -0,0 +1,28 @@
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.DefaultContextAttributesMapper = void 0;
10
+ const authorization_protocol_1 = require("./authorization-protocol");
11
+ const core_1 = require("@celljs/core");
12
+ const node_1 = require("@celljs/web/lib/node");
13
+ const oauth2_core_1 = require("@celljs/oauth2-core");
14
+ let DefaultContextAttributesMapper = class DefaultContextAttributesMapper {
15
+ async apply(authorizeRequest) {
16
+ const contextAttributes = new Map();
17
+ const scopes = node_1.Context.getAttr(oauth2_core_1.OAuth2ParameterNames.SCOPE, node_1.AttributeScope.Request);
18
+ if (scopes) {
19
+ contextAttributes.set(authorization_protocol_1.AuthorizationContext.REQUEST_SCOPE_ATTRIBUTE_NAME, scopes.split(' '));
20
+ }
21
+ return contextAttributes;
22
+ }
23
+ };
24
+ DefaultContextAttributesMapper = __decorate([
25
+ (0, core_1.Component)(authorization_protocol_1.ContextAttributesMapper)
26
+ ], DefaultContextAttributesMapper);
27
+ exports.DefaultContextAttributesMapper = DefaultContextAttributesMapper;
28
+ //# sourceMappingURL=context-attributes-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-attributes-mapper.js","sourceRoot":"","sources":["../../../src/node/authorization/context-attributes-mapper.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qEAA2G;AAC3G,uCAAyC;AACzC,+CAA+D;AAC/D,qDAA2D;AAGpD,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAEvC,KAAK,CAAC,KAAK,CAAC,gBAAkC;QAC1C,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAe,CAAC;QACjD,MAAM,MAAM,GAAG,cAAO,CAAC,OAAO,CAAS,kCAAoB,CAAC,KAAK,EAAE,qBAAc,CAAC,OAAO,CAAC,CAAC;QAC3F,IAAI,MAAM,EAAE;YACR,iBAAiB,CAAC,GAAG,CAAC,6CAAoB,CAAC,4BAA4B,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;SAC/F;QACD,OAAO,iBAAiB,CAAC;IAC7B,CAAC;CAEJ,CAAA;AAXY,8BAA8B;IAD1C,IAAA,gBAAS,EAAC,gDAAuB,CAAC;GACtB,8BAA8B,CAW1C;AAXY,wEAA8B"}
@@ -0,0 +1,14 @@
1
+ export * from './authorization-protocol';
2
+ export * from './authorization-request-resolver';
3
+ export * from './authorized-client-manager';
4
+ export * from './authorization-request-manager';
5
+ export * from './authorization-request-redirect-middleware';
6
+ export * from './authorization-code-grant-middleware';
7
+ export * from './authorization-code-authorized-client-provider';
8
+ export * from './client-credentials-authorized-client-provider';
9
+ export * from './password-authorized-client-provider';
10
+ export * from './refresh-token-authorized-client-provider';
11
+ export * from './context-attributes-mapper';
12
+ export * from './authorization-failure-handler';
13
+ export * from './authorization-success-handler';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/authorization/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,uCAAuC,CAAC;AACtD,cAAc,iDAAiD,CAAC;AAChE,cAAc,iDAAiD,CAAC;AAChE,cAAc,uCAAuC,CAAC;AACtD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,30 @@
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("./authorization-protocol"), exports);
18
+ __exportStar(require("./authorization-request-resolver"), exports);
19
+ __exportStar(require("./authorized-client-manager"), exports);
20
+ __exportStar(require("./authorization-request-manager"), exports);
21
+ __exportStar(require("./authorization-request-redirect-middleware"), exports);
22
+ __exportStar(require("./authorization-code-grant-middleware"), exports);
23
+ __exportStar(require("./authorization-code-authorized-client-provider"), exports);
24
+ __exportStar(require("./client-credentials-authorized-client-provider"), exports);
25
+ __exportStar(require("./password-authorized-client-provider"), exports);
26
+ __exportStar(require("./refresh-token-authorized-client-provider"), exports);
27
+ __exportStar(require("./context-attributes-mapper"), exports);
28
+ __exportStar(require("./authorization-failure-handler"), exports);
29
+ __exportStar(require("./authorization-success-handler"), exports);
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/authorization/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,mEAAiD;AACjD,8DAA4C;AAC5C,kEAAgD;AAChD,8EAA4D;AAC5D,wEAAsD;AACtD,kFAAgE;AAChE,kFAAgE;AAChE,wEAAsD;AACtD,6EAA2D;AAC3D,8DAA4C;AAC5C,kEAAgD;AAChD,kEAAgD"}
@@ -0,0 +1,12 @@
1
+ import { AuthorizedClientProvider, AuthorizationContext, AuthorizedClient } from './authorization-protocol';
2
+ import { AccessToken } from '@celljs/oauth2-core';
3
+ import { ClientRegistration } from '../registration';
4
+ import { PasswordTokenResponseClient } from '../endpoint/password-token-response-client';
5
+ export declare class PasswordAuthorizedClientProvider implements AuthorizedClientProvider {
6
+ protected readonly clockSkew: number;
7
+ protected readonly accessTokenResponseClient: PasswordTokenResponseClient;
8
+ provide(context: AuthorizationContext): Promise<AuthorizedClient | undefined>;
9
+ hasTokenExpired(accessToken: AccessToken): boolean;
10
+ protected getTokenResponse(clientRegistration: ClientRegistration, username: string, password: string): Promise<import("@celljs/oauth2-core").AccessTokenResponse>;
11
+ }
12
+ //# sourceMappingURL=password-authorized-client-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-authorized-client-provider.d.ts","sourceRoot":"","sources":["../../../src/node/authorization/password-authorized-client-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAoD,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,qBACa,gCAAiC,YAAW,wBAAwB;IAG7E,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAGrC,SAAS,CAAC,QAAQ,CAAC,yBAAyB,EAAE,2BAA2B,CAAC;IAEpE,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAwCnF,eAAe,CAAC,WAAW,EAAE,WAAW;IAIxC,SAAS,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAiBxG"}