@celljs/oauth2-client 3.7.8 → 3.9.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 (219) hide show
  1. package/esm/node/authentication/authentication-protocol.d.ts +24 -0
  2. package/esm/node/authentication/authentication-protocol.js +8 -0
  3. package/esm/node/authentication/authentication-protocol.js.map +1 -0
  4. package/esm/node/authentication/index.d.ts +3 -0
  5. package/esm/node/authentication/index.js +4 -0
  6. package/esm/node/authentication/index.js.map +1 -0
  7. package/esm/node/authentication/oauth2-authentication-provider.d.ts +29 -0
  8. package/esm/node/authentication/oauth2-authentication-provider.js +167 -0
  9. package/esm/node/authentication/oauth2-authentication-provider.js.map +1 -0
  10. package/esm/node/authentication/oidc-authentication-provider.d.ts +17 -0
  11. package/esm/node/authentication/oidc-authentication-provider.js +71 -0
  12. package/esm/node/authentication/oidc-authentication-provider.js.map +1 -0
  13. package/esm/node/authorization/authorization-code-authorized-client-provider.d.ts +4 -0
  14. package/esm/node/authorization/authorization-code-authorized-client-provider.js +24 -0
  15. package/esm/node/authorization/authorization-code-authorized-client-provider.js.map +1 -0
  16. package/esm/node/authorization/authorization-code-grant-middleware.d.ts +25 -0
  17. package/esm/node/authorization/authorization-code-grant-middleware.js +126 -0
  18. package/esm/node/authorization/authorization-code-grant-middleware.js.map +1 -0
  19. package/esm/node/authorization/authorization-failure-handler.d.ts +9 -0
  20. package/esm/node/authorization/authorization-failure-handler.js +32 -0
  21. package/esm/node/authorization/authorization-failure-handler.js.map +1 -0
  22. package/esm/node/authorization/authorization-protocol.d.ts +77 -0
  23. package/esm/node/authorization/authorization-protocol.js +31 -0
  24. package/esm/node/authorization/authorization-protocol.js.map +1 -0
  25. package/esm/node/authorization/authorization-request-manager.d.ts +12 -0
  26. package/esm/node/authorization/authorization-request-manager.js +61 -0
  27. package/esm/node/authorization/authorization-request-manager.js.map +1 -0
  28. package/esm/node/authorization/authorization-request-redirect-middleware.d.ts +19 -0
  29. package/esm/node/authorization/authorization-request-redirect-middleware.js +110 -0
  30. package/esm/node/authorization/authorization-request-redirect-middleware.js.map +1 -0
  31. package/esm/node/authorization/authorization-request-resolver.d.ts +37 -0
  32. package/esm/node/authorization/authorization-request-resolver.js +153 -0
  33. package/esm/node/authorization/authorization-request-resolver.js.map +1 -0
  34. package/esm/node/authorization/authorization-success-handler.d.ts +6 -0
  35. package/esm/node/authorization/authorization-success-handler.js +25 -0
  36. package/esm/node/authorization/authorization-success-handler.js.map +1 -0
  37. package/esm/node/authorization/authorized-client-manager.d.ts +10 -0
  38. package/esm/node/authorization/authorized-client-manager.js +45 -0
  39. package/esm/node/authorization/authorized-client-manager.js.map +1 -0
  40. package/esm/node/authorization/authorized-client-service.d.ts +11 -0
  41. package/esm/node/authorization/authorized-client-service.js +84 -0
  42. package/esm/node/authorization/authorized-client-service.js.map +1 -0
  43. package/esm/node/authorization/client-credentials-authorized-client-provider.d.ts +11 -0
  44. package/esm/node/authorization/client-credentials-authorized-client-provider.js +69 -0
  45. package/esm/node/authorization/client-credentials-authorized-client-provider.js.map +1 -0
  46. package/esm/node/authorization/context-attributes-mapper.d.ts +4 -0
  47. package/esm/node/authorization/context-attributes-mapper.js +25 -0
  48. package/esm/node/authorization/context-attributes-mapper.js.map +1 -0
  49. package/esm/node/authorization/index.d.ts +13 -0
  50. package/esm/node/authorization/index.js +14 -0
  51. package/esm/node/authorization/index.js.map +1 -0
  52. package/esm/node/authorization/password-authorized-client-provider.d.ts +11 -0
  53. package/esm/node/authorization/password-authorized-client-provider.js +82 -0
  54. package/esm/node/authorization/password-authorized-client-provider.js.map +1 -0
  55. package/esm/node/authorization/refresh-token-authorized-client-provider.d.ts +11 -0
  56. package/esm/node/authorization/refresh-token-authorized-client-provider.js +65 -0
  57. package/esm/node/authorization/refresh-token-authorized-client-provider.js.map +1 -0
  58. package/esm/node/constants.d.ts +4 -0
  59. package/esm/node/constants.js +5 -0
  60. package/esm/node/constants.js.map +1 -0
  61. package/esm/node/endpoint/authorization-code-token-response-client.d.ts +11 -0
  62. package/esm/node/endpoint/authorization-code-token-response-client.js +80 -0
  63. package/esm/node/endpoint/authorization-code-token-response-client.js.map +1 -0
  64. package/esm/node/endpoint/client-credentials-token-response-client.d.ts +11 -0
  65. package/esm/node/endpoint/client-credentials-token-response-client.js +77 -0
  66. package/esm/node/endpoint/client-credentials-token-response-client.js.map +1 -0
  67. package/esm/node/endpoint/endpoint-protocol.d.ts +47 -0
  68. package/esm/node/endpoint/endpoint-protocol.js +6 -0
  69. package/esm/node/endpoint/endpoint-protocol.js.map +1 -0
  70. package/esm/node/endpoint/index.d.ts +6 -0
  71. package/esm/node/endpoint/index.js +7 -0
  72. package/esm/node/endpoint/index.js.map +1 -0
  73. package/esm/node/endpoint/password-token-response-client.d.ts +11 -0
  74. package/esm/node/endpoint/password-token-response-client.js +79 -0
  75. package/esm/node/endpoint/password-token-response-client.js.map +1 -0
  76. package/esm/node/endpoint/refresh-token-token-response-client.d.ts +11 -0
  77. package/esm/node/endpoint/refresh-token-token-response-client.js +84 -0
  78. package/esm/node/endpoint/refresh-token-token-response-client.js.map +1 -0
  79. package/esm/node/endpoint/user-response-client.d.ts +8 -0
  80. package/esm/node/endpoint/user-response-client.js +81 -0
  81. package/esm/node/endpoint/user-response-client.js.map +1 -0
  82. package/esm/node/error/error-handler.d.ts +10 -0
  83. package/esm/node/error/error-handler.js +50 -0
  84. package/esm/node/error/error-handler.js.map +1 -0
  85. package/esm/node/error/error-protocol.d.ts +2 -0
  86. package/esm/node/error/error-protocol.js +4 -0
  87. package/esm/node/error/error-protocol.js.map +1 -0
  88. package/esm/node/error/error.d.ts +9 -0
  89. package/esm/node/error/error.js +18 -0
  90. package/esm/node/error/error.js.map +1 -0
  91. package/esm/node/error/index.d.ts +3 -0
  92. package/esm/node/error/index.js +4 -0
  93. package/esm/node/error/index.js.map +1 -0
  94. package/esm/node/index.d.ts +7 -0
  95. package/esm/node/index.js +8 -0
  96. package/esm/node/index.js.map +1 -0
  97. package/esm/node/module.d.ts +3 -0
  98. package/esm/node/module.js +4 -0
  99. package/esm/node/module.js.map +1 -0
  100. package/esm/node/provider/index.d.ts +2 -0
  101. package/esm/node/provider/index.js +3 -0
  102. package/esm/node/provider/index.js.map +1 -0
  103. package/esm/node/provider/provider-details-manager.d.ts +11 -0
  104. package/esm/node/provider/provider-details-manager.js +47 -0
  105. package/esm/node/provider/provider-details-manager.js.map +1 -0
  106. package/esm/node/provider/provider-protocol.d.ts +20 -0
  107. package/esm/node/provider/provider-protocol.js +2 -0
  108. package/esm/node/provider/provider-protocol.js.map +1 -0
  109. package/esm/node/registration/id-token-jwt-decoder-facatory.d.ts +14 -0
  110. package/esm/node/registration/id-token-jwt-decoder-facatory.js +86 -0
  111. package/esm/node/registration/id-token-jwt-decoder-facatory.js.map +1 -0
  112. package/esm/node/registration/index.d.ts +4 -0
  113. package/esm/node/registration/index.js +5 -0
  114. package/esm/node/registration/index.js.map +1 -0
  115. package/esm/node/registration/jws-algorithm-resolver.d.ts +4 -0
  116. package/esm/node/registration/jws-algorithm-resolver.js +19 -0
  117. package/esm/node/registration/jws-algorithm-resolver.js.map +1 -0
  118. package/esm/node/registration/registration-manager.d.ts +14 -0
  119. package/esm/node/registration/registration-manager.js +61 -0
  120. package/esm/node/registration/registration-manager.js.map +1 -0
  121. package/esm/node/registration/registration-protocol.d.ts +21 -0
  122. package/esm/node/registration/registration-protocol.js +4 -0
  123. package/esm/node/registration/registration-protocol.js.map +1 -0
  124. package/esm/node/user/index.d.ts +3 -0
  125. package/esm/node/user/index.js +4 -0
  126. package/esm/node/user/index.js.map +1 -0
  127. package/esm/node/user/oauth2-user-service.d.ts +9 -0
  128. package/esm/node/user/oauth2-user-service.js +58 -0
  129. package/esm/node/user/oauth2-user-service.js.map +1 -0
  130. package/esm/node/user/oidc-user-service.d.ts +12 -0
  131. package/esm/node/user/oidc-user-service.js +95 -0
  132. package/esm/node/user/oidc-user-service.js.map +1 -0
  133. package/esm/node/user/user-protocol.d.ts +5 -0
  134. package/esm/node/user/user-protocol.js +2 -0
  135. package/esm/node/user/user-protocol.js.map +1 -0
  136. package/esm/node/utils/authorization-grant-request-entity-util.d.ts +9 -0
  137. package/esm/node/utils/authorization-grant-request-entity-util.js +26 -0
  138. package/esm/node/utils/authorization-grant-request-entity-util.js.map +1 -0
  139. package/esm/node/utils/authorization-response-util.d.ts +7 -0
  140. package/esm/node/utils/authorization-response-util.js +50 -0
  141. package/esm/node/utils/authorization-response-util.js.map +1 -0
  142. package/esm/node/utils/index.d.ts +2 -0
  143. package/esm/node/utils/index.js +3 -0
  144. package/esm/node/utils/index.js.map +1 -0
  145. package/esm/package.json +3 -0
  146. package/lib/node/authentication/authentication-protocol.js.map +1 -1
  147. package/lib/node/authentication/oauth2-authentication-provider.d.ts.map +1 -1
  148. package/lib/node/authentication/oauth2-authentication-provider.js.map +1 -1
  149. package/lib/node/authentication/oidc-authentication-provider.d.ts.map +1 -1
  150. package/lib/node/authentication/oidc-authentication-provider.js.map +1 -1
  151. package/lib/node/authorization/authorization-code-authorized-client-provider.d.ts.map +1 -1
  152. package/lib/node/authorization/authorization-code-authorized-client-provider.js.map +1 -1
  153. package/lib/node/authorization/authorization-code-grant-middleware.d.ts.map +1 -1
  154. package/lib/node/authorization/authorization-code-grant-middleware.js.map +1 -1
  155. package/lib/node/authorization/authorization-failure-handler.d.ts.map +1 -1
  156. package/lib/node/authorization/authorization-failure-handler.js.map +1 -1
  157. package/lib/node/authorization/authorization-protocol.js.map +1 -1
  158. package/lib/node/authorization/authorization-request-manager.d.ts.map +1 -1
  159. package/lib/node/authorization/authorization-request-manager.js.map +1 -1
  160. package/lib/node/authorization/authorization-request-redirect-middleware.d.ts.map +1 -1
  161. package/lib/node/authorization/authorization-request-redirect-middleware.js.map +1 -1
  162. package/lib/node/authorization/authorization-request-resolver.d.ts.map +1 -1
  163. package/lib/node/authorization/authorization-request-resolver.js +34 -1
  164. package/lib/node/authorization/authorization-request-resolver.js.map +1 -1
  165. package/lib/node/authorization/authorization-success-handler.d.ts.map +1 -1
  166. package/lib/node/authorization/authorization-success-handler.js.map +1 -1
  167. package/lib/node/authorization/authorized-client-manager.d.ts.map +1 -1
  168. package/lib/node/authorization/authorized-client-manager.js.map +1 -1
  169. package/lib/node/authorization/authorized-client-service.d.ts.map +1 -1
  170. package/lib/node/authorization/authorized-client-service.js.map +1 -1
  171. package/lib/node/authorization/client-credentials-authorized-client-provider.d.ts.map +1 -1
  172. package/lib/node/authorization/client-credentials-authorized-client-provider.js.map +1 -1
  173. package/lib/node/authorization/context-attributes-mapper.d.ts.map +1 -1
  174. package/lib/node/authorization/context-attributes-mapper.js.map +1 -1
  175. package/lib/node/authorization/password-authorized-client-provider.d.ts.map +1 -1
  176. package/lib/node/authorization/password-authorized-client-provider.js.map +1 -1
  177. package/lib/node/authorization/refresh-token-authorized-client-provider.d.ts.map +1 -1
  178. package/lib/node/authorization/refresh-token-authorized-client-provider.js.map +1 -1
  179. package/lib/node/endpoint/authorization-code-token-response-client.d.ts.map +1 -1
  180. package/lib/node/endpoint/authorization-code-token-response-client.js +34 -1
  181. package/lib/node/endpoint/authorization-code-token-response-client.js.map +1 -1
  182. package/lib/node/endpoint/client-credentials-token-response-client.d.ts.map +1 -1
  183. package/lib/node/endpoint/client-credentials-token-response-client.js +34 -1
  184. package/lib/node/endpoint/client-credentials-token-response-client.js.map +1 -1
  185. package/lib/node/endpoint/password-token-response-client.d.ts.map +1 -1
  186. package/lib/node/endpoint/password-token-response-client.js +34 -1
  187. package/lib/node/endpoint/password-token-response-client.js.map +1 -1
  188. package/lib/node/endpoint/refresh-token-token-response-client.d.ts.map +1 -1
  189. package/lib/node/endpoint/refresh-token-token-response-client.js +34 -1
  190. package/lib/node/endpoint/refresh-token-token-response-client.js.map +1 -1
  191. package/lib/node/endpoint/user-response-client.d.ts.map +1 -1
  192. package/lib/node/endpoint/user-response-client.js +34 -1
  193. package/lib/node/endpoint/user-response-client.js.map +1 -1
  194. package/lib/node/error/error-handler.d.ts.map +1 -1
  195. package/lib/node/error/error-handler.js.map +1 -1
  196. package/lib/node/error/error.d.ts.map +1 -1
  197. package/lib/node/error/error.js.map +1 -1
  198. package/lib/node/module.d.ts.map +1 -1
  199. package/lib/node/module.js.map +1 -1
  200. package/lib/node/provider/provider-details-manager.d.ts.map +1 -1
  201. package/lib/node/provider/provider-details-manager.js.map +1 -1
  202. package/lib/node/registration/id-token-jwt-decoder-facatory.d.ts.map +1 -1
  203. package/lib/node/registration/id-token-jwt-decoder-facatory.js.map +1 -1
  204. package/lib/node/registration/jws-algorithm-resolver.d.ts.map +1 -1
  205. package/lib/node/registration/jws-algorithm-resolver.js.map +1 -1
  206. package/lib/node/registration/registration-manager.d.ts.map +1 -1
  207. package/lib/node/registration/registration-manager.js.map +1 -1
  208. package/lib/node/user/oauth2-user-service.d.ts.map +1 -1
  209. package/lib/node/user/oauth2-user-service.js.map +1 -1
  210. package/lib/node/user/oidc-user-service.d.ts.map +1 -1
  211. package/lib/node/user/oidc-user-service.js.map +1 -1
  212. package/lib/node/utils/authorization-grant-request-entity-util.js.map +1 -1
  213. package/lib/node/utils/authorization-response-util.js.map +1 -1
  214. package/lib/package.spec.d.ts +1 -0
  215. package/lib/package.spec.js +5 -2
  216. package/lib/package.spec.js.map +1 -1
  217. package/package.json +76 -14
  218. package/src/package.spec.ts +1 -0
  219. package/LICENSE +0 -21
@@ -0,0 +1,77 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { INVALID_TOKEN_RESPONSE_ERROR_CODE } from './endpoint-protocol.js';
11
+ import { Component, Autowired } from '@celljs/core';
12
+ import { RestOperations } from '@celljs/http';
13
+ import { ProviderDetailsManager } from '../provider/index.js';
14
+ import { OAuth2ParameterNames, ClientAuthenticationMethod, OAuth2AuthorizationError, AccessTokenResponseConverter } from '@celljs/oauth2-core';
15
+ import { AuthorizationGrantRequestEntityUtil } from '../utils/index.js';
16
+ import * as qs from 'qs';
17
+ let ClientCredentialsTokenResponseClient = class ClientCredentialsTokenResponseClient {
18
+ async getTokenResponse(clientCredentialsGrantRequest) {
19
+ const { clientRegistration } = clientCredentialsGrantRequest;
20
+ const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
21
+ let response;
22
+ try {
23
+ response = await this.restOperations.post(providerDetails.tokenUri, this.buildFormParameters(clientCredentialsGrantRequest), {
24
+ headers: AuthorizationGrantRequestEntityUtil.getTokenRequestHeaders(clientRegistration)
25
+ });
26
+ }
27
+ catch (error) {
28
+ const oauth2Error = {
29
+ errorCode: INVALID_TOKEN_RESPONSE_ERROR_CODE,
30
+ description: `An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: ${(error === null || error === void 0 ? void 0 : error.message) || error}`
31
+ };
32
+ throw new OAuth2AuthorizationError(oauth2Error, error);
33
+ }
34
+ const { data } = response;
35
+ const acccessTokenResponse = this.accessTokenResponseConverter.convert(data);
36
+ if (!acccessTokenResponse.accessToken.scopes || acccessTokenResponse.accessToken.scopes.length === 0) {
37
+ // As per spec, in Section 5.1 Successful Access Token Response
38
+ // https://tools.ietf.org/html/rfc6749#section-5.1
39
+ // If AccessTokenResponse.scope is empty, then default to the scope
40
+ // originally requested by the client in the Token Request
41
+ acccessTokenResponse.accessToken.scopes = clientRegistration.scopes;
42
+ }
43
+ return acccessTokenResponse;
44
+ }
45
+ buildFormParameters(clientCredentialsGrantRequest) {
46
+ const { clientRegistration, authorizationGrantType } = clientCredentialsGrantRequest;
47
+ const formParameters = {
48
+ [OAuth2ParameterNames.GRANT_TYPE]: authorizationGrantType,
49
+ };
50
+ const { clientAuthenticationMethod, clientId, clientSecret, scopes } = clientRegistration;
51
+ if (scopes) {
52
+ formParameters[OAuth2ParameterNames.SCOPE] = scopes.join(' ');
53
+ }
54
+ if (ClientAuthenticationMethod.Post === clientAuthenticationMethod) {
55
+ formParameters[OAuth2ParameterNames.CLIENT_ID] = clientId;
56
+ formParameters[OAuth2ParameterNames.CLIENT_SECRET] = clientSecret;
57
+ }
58
+ return qs.stringify(formParameters);
59
+ }
60
+ };
61
+ __decorate([
62
+ Autowired(RestOperations),
63
+ __metadata("design:type", Function)
64
+ ], ClientCredentialsTokenResponseClient.prototype, "restOperations", void 0);
65
+ __decorate([
66
+ Autowired(ProviderDetailsManager),
67
+ __metadata("design:type", Object)
68
+ ], ClientCredentialsTokenResponseClient.prototype, "providerDetailsManager", void 0);
69
+ __decorate([
70
+ Autowired(AccessTokenResponseConverter),
71
+ __metadata("design:type", AccessTokenResponseConverter)
72
+ ], ClientCredentialsTokenResponseClient.prototype, "accessTokenResponseConverter", void 0);
73
+ ClientCredentialsTokenResponseClient = __decorate([
74
+ Component()
75
+ ], ClientCredentialsTokenResponseClient);
76
+ export { ClientCredentialsTokenResponseClient };
77
+ //# sourceMappingURL=client-credentials-token-response-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-credentials-token-response-client.js","sourceRoot":"","sources":["../../../src/node/endpoint/client-credentials-token-response-client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAA6B,iCAAiC,EAAiC,MAAM,qBAAqB,CAAC;AAClI,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,E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YAC/D,kDAAkD;YAClD,mEAAmE;YACnE,0DAA0D;YAC1D,oBAAoB,CAAC,WAAW,CAAC,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC;QACxE,CAAC;QAED,OAAO,oBAAoB,CAAC;IAChC,CAAC;IAES,mBAAmB,CAAC,6BAA4D;QACtF,MAAM,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,GAAG,6BAA6B,CAAC;QACrF,MAAM,cAAc,GAA2B;YAC3C,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,sBAAsB;SAC5D,CAAC;QACF,MAAM,EAAE,0BAA0B,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAAC;QAC1F,IAAI,MAAM,EAAE,CAAC;YACT,cAAc,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,0BAA0B,CAAC,IAAI,KAAK,0BAA0B,EAAE,CAAC;YACjE,cAAc,CAAC,oBAAoB,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;YAC1D,cAAc,CAAC,oBAAoB,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC;QACtE,CAAC;QACD,OAAO,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;CAEJ,CAAA;AAxDsB;IADlB,SAAS,CAAC,cAAc,CAAC;;4EACwB;AAG/B;IADlB,SAAS,CAAC,sBAAsB,CAAC;;oFACgC;AAG/C;IADlB,SAAS,CAAC,4BAA4B,CAAC;8BACS,4BAA4B;0FAAC;AATrE,oCAAoC;IADhD,SAAS,EAAE;GACC,oCAAoC,CA2DhD"}
@@ -0,0 +1,47 @@
1
+ import { ClientRegistration } from '../registration/index.js';
2
+ import { AuthorizationExchange, AuthorizationGrantType, AccessToken, RefreshToken, AccessTokenResponse } from '@celljs/oauth2-core';
3
+ export declare const UserResponseClient: unique symbol;
4
+ export declare const MISSING_USER_INFO_URI_ERROR_CODE = "missing_user_info_uri";
5
+ export declare const MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE = "missing_user_name_attribute";
6
+ export declare const INVALID_USER_INFO_RESPONSE_ERROR_CODE = "invalid_user_info_response";
7
+ export declare const INVALID_TOKEN_RESPONSE_ERROR_CODE = "invalid_token_response";
8
+ export interface AuthorizationGrantRequest {
9
+ authorizationGrantType: AuthorizationGrantType;
10
+ }
11
+ export interface AuthorizationCodeGrantRequest extends AuthorizationGrantRequest {
12
+ clientRegistration: ClientRegistration;
13
+ authorizationExchange: AuthorizationExchange;
14
+ }
15
+ export interface ClientCredentialsGrantRequest extends AuthorizationGrantRequest {
16
+ clientRegistration: ClientRegistration;
17
+ }
18
+ export interface PasswordGrantRequest extends AuthorizationGrantRequest {
19
+ clientRegistration: ClientRegistration;
20
+ username: string;
21
+ password: string;
22
+ }
23
+ export interface RefreshTokenGrantRequest extends AuthorizationGrantRequest {
24
+ clientRegistration: ClientRegistration;
25
+ accessToken: AccessToken;
26
+ refreshToken: RefreshToken;
27
+ scopes?: string[];
28
+ }
29
+ export interface AccessTokenResponseClient<T extends AuthorizationGrantRequest> {
30
+ getTokenResponse(authorizationRequest: T): Promise<AccessTokenResponse>;
31
+ }
32
+ export interface OAuth2UserRequest {
33
+ clientRegistration: ClientRegistration;
34
+ accessToken: AccessToken;
35
+ additionalParameters: {
36
+ [key: string]: any;
37
+ };
38
+ }
39
+ export interface OAuth2UserResponse {
40
+ username: string;
41
+ userAttributes: {
42
+ [key: string]: any;
43
+ };
44
+ }
45
+ export interface UserResponseClient<T extends OAuth2UserRequest> {
46
+ getUserResponse(authorizationRequest: T): Promise<OAuth2UserResponse>;
47
+ }
@@ -0,0 +1,6 @@
1
+ export const UserResponseClient = Symbol('UserResponseClient');
2
+ export const MISSING_USER_INFO_URI_ERROR_CODE = 'missing_user_info_uri';
3
+ export const MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE = 'missing_user_name_attribute';
4
+ export const INVALID_USER_INFO_RESPONSE_ERROR_CODE = 'invalid_user_info_response';
5
+ export const INVALID_TOKEN_RESPONSE_ERROR_CODE = 'invalid_token_response';
6
+ //# sourceMappingURL=endpoint-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-protocol.js","sourceRoot":"","sources":["../../../src/node/endpoint/endpoint-protocol.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,gCAAgC,GAAG,uBAAuB,CAAC;AACxE,MAAM,CAAC,MAAM,sCAAsC,GAAG,6BAA6B,CAAC;AACpF,MAAM,CAAC,MAAM,qCAAqC,GAAG,4BAA4B,CAAC;AAElF,MAAM,CAAC,MAAM,iCAAiC,GAAG,wBAAwB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './endpoint-protocol.js';
2
+ export * from './authorization-code-token-response-client.js';
3
+ export * from './client-credentials-token-response-client.js';
4
+ export * from './password-token-response-client.js';
5
+ export * from './refresh-token-token-response-client.js';
6
+ export * from './user-response-client.js';
@@ -0,0 +1,7 @@
1
+ export * from './endpoint-protocol.js';
2
+ export * from './authorization-code-token-response-client.js';
3
+ export * from './client-credentials-token-response-client.js';
4
+ export * from './password-token-response-client.js';
5
+ export * from './refresh-token-token-response-client.js';
6
+ export * from './user-response-client.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/endpoint/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { AccessTokenResponseClient, PasswordGrantRequest } from './endpoint-protocol.js';
2
+ import { RestOperations } from '@celljs/http';
3
+ import { ProviderDetailsManager } from '../provider/index.js';
4
+ import { AccessTokenResponse, AccessTokenResponseConverter } from '@celljs/oauth2-core';
5
+ export declare class PasswordTokenResponseClient implements AccessTokenResponseClient<PasswordGrantRequest> {
6
+ protected readonly restOperations: RestOperations;
7
+ protected readonly providerDetailsManager: ProviderDetailsManager;
8
+ protected readonly accessTokenResponseConverter: AccessTokenResponseConverter;
9
+ getTokenResponse(passwordGrantRequest: PasswordGrantRequest): Promise<AccessTokenResponse>;
10
+ protected buildFormParameters(passwordGrantRequest: PasswordGrantRequest): string;
11
+ }
@@ -0,0 +1,79 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { INVALID_TOKEN_RESPONSE_ERROR_CODE } from './endpoint-protocol.js';
11
+ import { Component, Autowired } from '@celljs/core';
12
+ import { RestOperations } from '@celljs/http';
13
+ import { ProviderDetailsManager } from '../provider/index.js';
14
+ import { OAuth2ParameterNames, ClientAuthenticationMethod, OAuth2AuthorizationError, AccessTokenResponseConverter } from '@celljs/oauth2-core';
15
+ import { AuthorizationGrantRequestEntityUtil } from '../utils/index.js';
16
+ import * as qs from 'qs';
17
+ let PasswordTokenResponseClient = class PasswordTokenResponseClient {
18
+ async getTokenResponse(passwordGrantRequest) {
19
+ const { clientRegistration } = passwordGrantRequest;
20
+ const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
21
+ let response;
22
+ try {
23
+ response = await this.restOperations.post(providerDetails.tokenUri, this.buildFormParameters(passwordGrantRequest), {
24
+ headers: AuthorizationGrantRequestEntityUtil.getTokenRequestHeaders(clientRegistration)
25
+ });
26
+ }
27
+ catch (error) {
28
+ const oauth2Error = {
29
+ errorCode: INVALID_TOKEN_RESPONSE_ERROR_CODE,
30
+ description: `An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: ${(error === null || error === void 0 ? void 0 : error.message) || error}`
31
+ };
32
+ throw new OAuth2AuthorizationError(oauth2Error, error);
33
+ }
34
+ const { data } = response;
35
+ const acccessTokenResponse = this.accessTokenResponseConverter.convert(data);
36
+ if (!acccessTokenResponse.accessToken.scopes || acccessTokenResponse.accessToken.scopes.length === 0) {
37
+ // As per spec, in Section 5.1 Successful Access Token Response
38
+ // https://tools.ietf.org/html/rfc6749#section-5.1
39
+ // If AccessTokenResponse.scope is empty, then default to the scope
40
+ // originally requested by the client in the Token Request
41
+ acccessTokenResponse.accessToken.scopes = clientRegistration.scopes;
42
+ }
43
+ return acccessTokenResponse;
44
+ }
45
+ buildFormParameters(passwordGrantRequest) {
46
+ const { clientRegistration, authorizationGrantType, username, password } = passwordGrantRequest;
47
+ const formParameters = {
48
+ [OAuth2ParameterNames.GRANT_TYPE]: authorizationGrantType,
49
+ [OAuth2ParameterNames.USERNAME]: username,
50
+ [OAuth2ParameterNames.PASSWORD]: password
51
+ };
52
+ const { clientAuthenticationMethod, clientId, clientSecret, scopes } = clientRegistration;
53
+ if (scopes) {
54
+ formParameters[OAuth2ParameterNames.SCOPE] = scopes.join(' ');
55
+ }
56
+ if (ClientAuthenticationMethod.Post === clientAuthenticationMethod) {
57
+ formParameters[OAuth2ParameterNames.CLIENT_ID] = clientId;
58
+ formParameters[OAuth2ParameterNames.CLIENT_SECRET] = clientSecret;
59
+ }
60
+ return qs.stringify(formParameters);
61
+ }
62
+ };
63
+ __decorate([
64
+ Autowired(RestOperations),
65
+ __metadata("design:type", Function)
66
+ ], PasswordTokenResponseClient.prototype, "restOperations", void 0);
67
+ __decorate([
68
+ Autowired(ProviderDetailsManager),
69
+ __metadata("design:type", Object)
70
+ ], PasswordTokenResponseClient.prototype, "providerDetailsManager", void 0);
71
+ __decorate([
72
+ Autowired(AccessTokenResponseConverter),
73
+ __metadata("design:type", AccessTokenResponseConverter)
74
+ ], PasswordTokenResponseClient.prototype, "accessTokenResponseConverter", void 0);
75
+ PasswordTokenResponseClient = __decorate([
76
+ Component()
77
+ ], PasswordTokenResponseClient);
78
+ export { PasswordTokenResponseClient };
79
+ //# sourceMappingURL=password-token-response-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password-token-response-client.js","sourceRoot":"","sources":["../../../src/node/endpoint/password-token-response-client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAA6B,iCAAiC,EAAwB,MAAM,qBAAqB,CAAC;AACzH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAuB,oBAAoB,EAAE,0BAA0B,EAAe,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACjL,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGlB,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAWpC,KAAK,CAAC,gBAAgB,CAAC,oBAA0C;QAC7D,MAAM,EAAE,kBAAkB,EAAE,GAAG,oBAAoB,CAAC;QACpD,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAE3F,IAAI,QAAQ,CAAC;QACb,IAAI,CAAC;YACD,QAAQ,GAAG,MAAM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ACF,MAAM,EAAE,0BAA0B,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAAC;QAC1F,IAAI,MAAM,EAAE,CAAC;YACT,cAAc,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,0BAA0B,CAAC,IAAI,KAAK,0BAA0B,EAAE,CAAC;YACjE,cAAc,CAAC,oBAAoB,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;YAC1D,cAAc,CAAC,oBAAoB,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC;QACtE,CAAC;QACD,OAAO,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;CAEJ,CAAA;AA1DsB;IADlB,SAAS,CAAC,cAAc,CAAC;;mEACwB;AAG/B;IADlB,SAAS,CAAC,sBAAsB,CAAC;;2EACgC;AAG/C;IADlB,SAAS,CAAC,4BAA4B,CAAC;8BACS,4BAA4B;iFAAC;AATrE,2BAA2B;IADvC,SAAS,EAAE;GACC,2BAA2B,CA6DvC"}
@@ -0,0 +1,11 @@
1
+ import { AccessTokenResponseClient, RefreshTokenGrantRequest } from './endpoint-protocol.js';
2
+ import { RestOperations } from '@celljs/http';
3
+ import { ProviderDetailsManager } from '../provider/index.js';
4
+ import { AccessTokenResponse, AccessTokenResponseConverter } from '@celljs/oauth2-core';
5
+ export declare class RefreshTokenTokenResponseClient implements AccessTokenResponseClient<RefreshTokenGrantRequest> {
6
+ protected readonly restOperations: RestOperations;
7
+ protected readonly providerDetailsManager: ProviderDetailsManager;
8
+ protected readonly accessTokenResponseConverter: AccessTokenResponseConverter;
9
+ getTokenResponse(refreshTokenGrantRequest: RefreshTokenGrantRequest): Promise<AccessTokenResponse>;
10
+ protected buildFormParameters(refreshTokenGrantRequest: RefreshTokenGrantRequest): string;
11
+ }
@@ -0,0 +1,84 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { INVALID_TOKEN_RESPONSE_ERROR_CODE } from './endpoint-protocol.js';
11
+ import { Component, Autowired } from '@celljs/core';
12
+ import { RestOperations } from '@celljs/http';
13
+ import { ProviderDetailsManager } from '../provider/index.js';
14
+ import { OAuth2ParameterNames, ClientAuthenticationMethod, OAuth2AuthorizationError, AccessTokenResponseConverter } from '@celljs/oauth2-core';
15
+ import { AuthorizationGrantRequestEntityUtil } from '../utils/index.js';
16
+ import * as qs from 'qs';
17
+ let RefreshTokenTokenResponseClient = class RefreshTokenTokenResponseClient {
18
+ async getTokenResponse(refreshTokenGrantRequest) {
19
+ const { clientRegistration, refreshToken, accessToken } = refreshTokenGrantRequest;
20
+ const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
21
+ let response;
22
+ try {
23
+ response = await this.restOperations.post(providerDetails.tokenUri, this.buildFormParameters(refreshTokenGrantRequest), {
24
+ headers: AuthorizationGrantRequestEntityUtil.getTokenRequestHeaders(clientRegistration)
25
+ });
26
+ }
27
+ catch (error) {
28
+ const oauth2Error = {
29
+ errorCode: INVALID_TOKEN_RESPONSE_ERROR_CODE,
30
+ description: `An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: ${(error === null || error === void 0 ? void 0 : error.message) || error}`
31
+ };
32
+ throw new OAuth2AuthorizationError(oauth2Error, error);
33
+ }
34
+ const { data } = response;
35
+ const acccessTokenResponse = this.accessTokenResponseConverter.convert(data);
36
+ if (!acccessTokenResponse.accessToken.scopes || acccessTokenResponse.accessToken.scopes.length === 0) {
37
+ // As per spec, in Section 5.1 Successful Access Token Response
38
+ // https://tools.ietf.org/html/rfc6749#section-5.1
39
+ // If AccessTokenResponse.scope is empty, then default to the scope
40
+ // originally requested by the client in the Token Request
41
+ acccessTokenResponse.accessToken.scopes = accessToken.scopes;
42
+ }
43
+ if (!acccessTokenResponse.refreshToken) {
44
+ acccessTokenResponse.refreshToken = {
45
+ issuedAt: Date.now(),
46
+ tokenValue: refreshToken.tokenValue
47
+ };
48
+ }
49
+ return acccessTokenResponse;
50
+ }
51
+ buildFormParameters(refreshTokenGrantRequest) {
52
+ const { clientRegistration, authorizationGrantType, refreshToken, scopes } = refreshTokenGrantRequest;
53
+ const formParameters = {
54
+ [OAuth2ParameterNames.GRANT_TYPE]: authorizationGrantType,
55
+ [OAuth2ParameterNames.REFRESH_TOKEN]: refreshToken.tokenValue
56
+ };
57
+ if (scopes) {
58
+ formParameters[OAuth2ParameterNames.SCOPE] = scopes.join(' ');
59
+ }
60
+ const { clientAuthenticationMethod, clientId, clientSecret } = clientRegistration;
61
+ if (ClientAuthenticationMethod.Post === clientAuthenticationMethod) {
62
+ formParameters[OAuth2ParameterNames.CLIENT_ID] = clientId;
63
+ formParameters[OAuth2ParameterNames.CLIENT_SECRET] = clientSecret;
64
+ }
65
+ return qs.stringify(formParameters);
66
+ }
67
+ };
68
+ __decorate([
69
+ Autowired(RestOperations),
70
+ __metadata("design:type", Function)
71
+ ], RefreshTokenTokenResponseClient.prototype, "restOperations", void 0);
72
+ __decorate([
73
+ Autowired(ProviderDetailsManager),
74
+ __metadata("design:type", Object)
75
+ ], RefreshTokenTokenResponseClient.prototype, "providerDetailsManager", void 0);
76
+ __decorate([
77
+ Autowired(AccessTokenResponseConverter),
78
+ __metadata("design:type", AccessTokenResponseConverter)
79
+ ], RefreshTokenTokenResponseClient.prototype, "accessTokenResponseConverter", void 0);
80
+ RefreshTokenTokenResponseClient = __decorate([
81
+ Component()
82
+ ], RefreshTokenTokenResponseClient);
83
+ export { RefreshTokenTokenResponseClient };
84
+ //# sourceMappingURL=refresh-token-token-response-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh-token-token-response-client.js","sourceRoot":"","sources":["../../../src/node/endpoint/refresh-token-token-response-client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAA6B,iCAAiC,EAA4B,MAAM,qBAAqB,CAAC;AAC7H,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAuB,oBAAoB,EAAE,0BAA0B,EAAe,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACjL,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGlB,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAWxC,KAAK,CAAC,gBAAgB,CAAC,wBAAkD;QACrE,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,wBAAwB,CAAC;QACnF,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAE3F,IAAI,QAAQ,CAAC;QACb,IAAI,CAAC;YACD,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAA4B,eAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,CAAC,wBAAwB,CAAC,EAAE;gBAChJ,OAAO,EAAE,mCAAmC,CAAC,sBAAsB,CAAC,kBAAkB,CAAC;aAC1F,CAAC,CAAC;QACP,CAAC;QAAC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AAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,EAAE,0BAA0B,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAAC;QAClF,IAAI,0BAA0B,CAAC,IAAI,KAAK,0BAA0B,EAAE,CAAC;YACjE,cAAc,CAAC,oBAAoB,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;YAC1D,cAAc,CAAC,oBAAoB,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC;QACtE,CAAC;QACD,OAAO,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;CAEJ,CAAA;AAhEsB;IADlB,SAAS,CAAC,cAAc,CAAC;;uEACwB;AAG/B;IADlB,SAAS,CAAC,sBAAsB,CAAC;;+EACgC;AAG/C;IADlB,SAAS,CAAC,4BAA4B,CAAC;8BACS,4BAA4B;qFAAC;AATrE,+BAA+B;IAD3C,SAAS,EAAE;GACC,+BAA+B,CAmE3C"}
@@ -0,0 +1,8 @@
1
+ import { UserResponseClient, OAuth2UserRequest, OAuth2UserResponse } from './endpoint-protocol.js';
2
+ import { RestOperations } from '@celljs/http';
3
+ import { ProviderDetailsManager } from '../provider/index.js';
4
+ export declare class DefaultUserResponseClient implements UserResponseClient<OAuth2UserRequest> {
5
+ protected readonly restOperations: RestOperations;
6
+ protected readonly providerDetailsManager: ProviderDetailsManager;
7
+ getUserResponse(userRequest: OAuth2UserRequest): Promise<OAuth2UserResponse>;
8
+ }
@@ -0,0 +1,81 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { UserResponseClient, MISSING_USER_INFO_URI_ERROR_CODE, MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE, INVALID_USER_INFO_RESPONSE_ERROR_CODE } from './endpoint-protocol.js';
11
+ import { Component, Autowired } from '@celljs/core';
12
+ import { RestOperations, HttpHeaders, MediaType, HttpMethod } from '@celljs/http';
13
+ import { ProviderDetailsManager } from '../provider/index.js';
14
+ import { OAuth2ParameterNames, OAuth2AuthorizationError, OAuth2AuthenticationError, AuthenticationMethod } from '@celljs/oauth2-core';
15
+ import * as qs from 'qs';
16
+ let DefaultUserResponseClient = class DefaultUserResponseClient {
17
+ async getUserResponse(userRequest) {
18
+ var _a, _b, _c;
19
+ const { clientRegistration, accessToken } = userRequest;
20
+ const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
21
+ if (!((_a = providerDetails === null || providerDetails === void 0 ? void 0 : providerDetails.userInfoEndpoint) === null || _a === void 0 ? void 0 : _a.uri)) {
22
+ throw new OAuth2AuthenticationError({
23
+ errorCode: MISSING_USER_INFO_URI_ERROR_CODE,
24
+ description: `Missing required UserInfo Uri in UserInfoEndpoint for Client Registration: ${clientRegistration.registrationId}`
25
+ });
26
+ }
27
+ const userNameAttributeName = (_b = providerDetails === null || providerDetails === void 0 ? void 0 : providerDetails.userInfoEndpoint) === null || _b === void 0 ? void 0 : _b.userNameAttributeName;
28
+ if (!userNameAttributeName) {
29
+ throw new OAuth2AuthenticationError({
30
+ errorCode: MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE,
31
+ description: `Missing required "user name" attribute name in UserInfoEndpoint for Client Registration: ${clientRegistration.registrationId}`
32
+ });
33
+ }
34
+ let response;
35
+ try {
36
+ const httpMethod = providerDetails.userInfoEndpoint.authenticationMethod === AuthenticationMethod.Form ? HttpMethod.POST : HttpMethod.GET;
37
+ const config = {
38
+ url: (_c = providerDetails === null || providerDetails === void 0 ? void 0 : providerDetails.userInfoEndpoint) === null || _c === void 0 ? void 0 : _c.uri,
39
+ method: httpMethod,
40
+ headers: {
41
+ [HttpHeaders.ACCEPT]: MediaType.APPLICATION_JSON
42
+ }
43
+ };
44
+ if (httpMethod === HttpMethod.POST) {
45
+ config.headers[HttpHeaders.CONTENT_TYPE] = `${MediaType.APPLICATION_FORM_URLENCODED};charset=UTF-8`;
46
+ config.data = qs.stringify({
47
+ [OAuth2ParameterNames.ACCESS_TOKEN]: accessToken.tokenValue
48
+ });
49
+ }
50
+ else {
51
+ config.headers[HttpHeaders.AUTHORIZATION] = `Bearer ${accessToken.tokenValue}`;
52
+ }
53
+ response = await this.restOperations.request(config);
54
+ }
55
+ catch (error) {
56
+ const oauth2Error = {
57
+ errorCode: INVALID_USER_INFO_RESPONSE_ERROR_CODE,
58
+ description: `An error occurred while attempting to retrieve the UserInfo Resource: ${(error === null || error === void 0 ? void 0 : error.message) || error}`
59
+ };
60
+ throw new OAuth2AuthorizationError(oauth2Error, error);
61
+ }
62
+ const { data } = response;
63
+ return {
64
+ username: data[userNameAttributeName],
65
+ userAttributes: data
66
+ };
67
+ }
68
+ };
69
+ __decorate([
70
+ Autowired(RestOperations),
71
+ __metadata("design:type", Function)
72
+ ], DefaultUserResponseClient.prototype, "restOperations", void 0);
73
+ __decorate([
74
+ Autowired(ProviderDetailsManager),
75
+ __metadata("design:type", Object)
76
+ ], DefaultUserResponseClient.prototype, "providerDetailsManager", void 0);
77
+ DefaultUserResponseClient = __decorate([
78
+ Component(UserResponseClient)
79
+ ], DefaultUserResponseClient);
80
+ export { DefaultUserResponseClient };
81
+ //# sourceMappingURL=user-response-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-response-client.js","sourceRoot":"","sources":["../../../src/node/endpoint/user-response-client.ts"],"names":[],"mappings":";;;;;;;;;AAAA,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,GAAG,QAAQ,CAAC;QAE1B,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,qBAAqB,CAAC;YACrC,cAAc,EAAE,IAAI;SACvB,CAAC;IACN,CAAC;CACJ,CAAA;AA1DsB;IADlB,SAAS,CAAC,cAAc,CAAC;;iEACwB;AAG/B;IADlB,SAAS,CAAC,sBAAsB,CAAC;;yEACgC;AANzD,yBAAyB;IADrC,SAAS,CAAC,kBAAkB,CAAC;GACjB,yBAAyB,CA6DrC"}
@@ -0,0 +1,10 @@
1
+ import { ErrorHandler, Context, RedirectStrategy } from '@celljs/web/lib/node';
2
+ import { OAuth2AuthorizationError, AuthorizationRequest } from '@celljs/oauth2-core';
3
+ import { AuthorizationRequestManager } from '../authorization/index.js';
4
+ export declare class OAuth2AuthorizationErrorHandler implements ErrorHandler {
5
+ readonly priority: number;
6
+ protected readonly redirectStrategy: RedirectStrategy;
7
+ protected readonly authorizationRequestManager: AuthorizationRequestManager<AuthorizationRequest>;
8
+ canHandle(ctx: Context, err: Error): Promise<boolean>;
9
+ handle(ctx: Context, err: OAuth2AuthorizationError): Promise<void>;
10
+ }
@@ -0,0 +1,50 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { OAUTH2_AUTHORIZATION_ERROR_HANDLER_PRIORITY } from './error-protocol.js';
11
+ import { ErrorHandler, RedirectStrategy } from '@celljs/web/lib/node';
12
+ import { Component, Autowired } from '@celljs/core';
13
+ import { OAuth2AuthorizationError, OAuth2ParameterNames } from '@celljs/oauth2-core';
14
+ import { AuthorizationRequestManager } from '../authorization/index.js';
15
+ import __cellCjs2 from 'crypto-js';
16
+ const { enc } = __cellCjs2;
17
+ let OAuth2AuthorizationErrorHandler = class OAuth2AuthorizationErrorHandler {
18
+ constructor() {
19
+ this.priority = OAUTH2_AUTHORIZATION_ERROR_HANDLER_PRIORITY;
20
+ }
21
+ canHandle(ctx, err) {
22
+ return Promise.resolve(err instanceof OAuth2AuthorizationError);
23
+ }
24
+ async handle(ctx, err) {
25
+ const { oauth2Error } = err;
26
+ const authorizationRequest = await this.authorizationRequestManager.remove();
27
+ let redirectUri = `${authorizationRequest.redirectUri}?${OAuth2ParameterNames.ERROR}=${oauth2Error.errorCode}`;
28
+ if (oauth2Error.description) {
29
+ redirectUri = `${redirectUri}&${OAuth2ParameterNames.ERROR_DESCRIPTION}=${enc.Base64.stringify(enc.Utf8.parse(oauth2Error.description))}`;
30
+ }
31
+ if (oauth2Error.uri) {
32
+ redirectUri = `${redirectUri}&${OAuth2ParameterNames.ERROR_URI}=${enc.Base64.stringify(enc.Utf8.parse(oauth2Error.uri))}`;
33
+ }
34
+ await this.redirectStrategy.send(redirectUri);
35
+ ctx.response.end(err.message);
36
+ }
37
+ };
38
+ __decorate([
39
+ Autowired(RedirectStrategy),
40
+ __metadata("design:type", Object)
41
+ ], OAuth2AuthorizationErrorHandler.prototype, "redirectStrategy", void 0);
42
+ __decorate([
43
+ Autowired(AuthorizationRequestManager),
44
+ __metadata("design:type", Object)
45
+ ], OAuth2AuthorizationErrorHandler.prototype, "authorizationRequestManager", void 0);
46
+ OAuth2AuthorizationErrorHandler = __decorate([
47
+ Component(ErrorHandler)
48
+ ], OAuth2AuthorizationErrorHandler);
49
+ export { OAuth2AuthorizationErrorHandler };
50
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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AAW,IAAI,oBAAoB,CAAC,SAAS,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAE9H,CAAC;QAED,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9C,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;CACJ,CAAA;AA1BsB;IADlB,SAAS,CAAC,gBAAgB,CAAC;;yEAC0B;AAGnC;IADlB,SAAS,CAAC,2BAA2B,CAAC;;oFAC2D;AAPzF,+BAA+B;IAD3C,SAAS,CAAC,YAAY,CAAC;GACX,+BAA+B,CA8B3C"}
@@ -0,0 +1,2 @@
1
+ export declare const OAUTH2_AUTHORIZATION_ERROR_HANDLER_PRIORITY: number;
2
+ export declare const CLIENT_AUTHORIZATION_REQUIRED_ERROR_CODE = "client_authorization_required";
@@ -0,0 +1,4 @@
1
+ import { HTTP_ERROR_HANDLER_PRIORITY } from '@celljs/web/lib/node';
2
+ export const OAUTH2_AUTHORIZATION_ERROR_HANDLER_PRIORITY = HTTP_ERROR_HANDLER_PRIORITY + 100;
3
+ export const CLIENT_AUTHORIZATION_REQUIRED_ERROR_CODE = 'client_authorization_required';
4
+ //# sourceMappingURL=error-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-protocol.js","sourceRoot":"","sources":["../../../src/node/error/error-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAEnE,MAAM,CAAC,MAAM,2CAA2C,GAAG,2BAA2B,GAAG,GAAG,CAAC;AAE7F,MAAM,CAAC,MAAM,wCAAwC,GAAG,+BAA+B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { OAuth2AuthorizationError, OAuth2Error } from '@celljs/oauth2-core';
2
+ export declare class ClientAuthorizationError extends OAuth2AuthorizationError {
3
+ oauth2Error: OAuth2Error;
4
+ clientRegistrationId: string;
5
+ constructor(oauth2Error: OAuth2Error, clientRegistrationId: string, error?: Error);
6
+ }
7
+ export declare class ClientAuthorizationRequiredError extends ClientAuthorizationError {
8
+ constructor(clientRegistrationId: string);
9
+ }
@@ -0,0 +1,18 @@
1
+ import { OAuth2AuthorizationError } from '@celljs/oauth2-core';
2
+ import { CLIENT_AUTHORIZATION_REQUIRED_ERROR_CODE } from './error-protocol.js';
3
+ export class ClientAuthorizationError extends OAuth2AuthorizationError {
4
+ constructor(oauth2Error, clientRegistrationId, error) {
5
+ super(oauth2Error, error);
6
+ this.oauth2Error = oauth2Error;
7
+ this.clientRegistrationId = clientRegistrationId;
8
+ }
9
+ }
10
+ export class ClientAuthorizationRequiredError extends ClientAuthorizationError {
11
+ constructor(clientRegistrationId) {
12
+ super({
13
+ errorCode: CLIENT_AUTHORIZATION_REQUIRED_ERROR_CODE,
14
+ description: `Authorization required for Client Registration Id: ${clientRegistrationId}`
15
+ }, clientRegistrationId);
16
+ }
17
+ }
18
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/node/error/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAe,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,wCAAwC,EAAE,MAAM,kBAAkB,CAAC;AAE5E,MAAM,OAAO,wBAAyB,SAAQ,wBAAwB;IAElE,YAA4B,WAAwB,EAAS,oBAA4B,EAAE,KAAa;QACpG,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;2BADF,WAAW;oCAAsB,oBAAoB;IAEjF,CAAC;CAEJ;AAED,MAAM,OAAO,gCAAiC,SAAQ,wBAAwB;IAC1E,YAAY,oBAA4B;QACpC,KAAK,CAAC;YACF,SAAS,EAAE,wCAAwC;YACnD,WAAW,EAAE,sDAAsD,oBAAoB,EAAE;SAC5F,EAAE,oBAAoB,CAAC,CAAC;IAC7B,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ export * from './error-handler.js';
2
+ export * from './error-protocol.js';
3
+ export * from './error.js';
@@ -0,0 +1,4 @@
1
+ export * from './error-handler.js';
2
+ export * from './error-protocol.js';
3
+ export * from './error.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/error/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './registration/index.js';
2
+ export * from './provider/index.js';
3
+ export * from './authorization/index.js';
4
+ export * from './authentication/index.js';
5
+ export * from './endpoint/index.js';
6
+ export * from './constants.js';
7
+ export * from './user/index.js';
@@ -0,0 +1,8 @@
1
+ export * from './registration/index.js';
2
+ export * from './provider/index.js';
3
+ export * from './authorization/index.js';
4
+ export * from './authentication/index.js';
5
+ export * from './endpoint/index.js';
6
+ export * from './constants.js';
7
+ export * from './user/index.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}