@celljs/oauth2-client 3.8.0 → 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 (146) 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/package.json +74 -9
@@ -0,0 +1,3 @@
1
+ import './index.js';
2
+ declare const _default: import("inversify").interfaces.ContainerModule;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { autoBind } from '@celljs/core';
2
+ import './index.js';
3
+ export default autoBind();
4
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,SAAS,CAAC;AAEjB,eAAe,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './provider-protocol.js';
2
+ export * from './provider-details-manager.js';
@@ -0,0 +1,3 @@
1
+ export * from './provider-protocol.js';
2
+ export * from './provider-details-manager.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { ProviderDetailsManager, ProviderDetails } from './provider-protocol.js';
2
+ export declare class InMemoryProviderDetailsManager implements ProviderDetailsManager {
3
+ protected providers: {
4
+ [id: string]: ProviderDetails;
5
+ };
6
+ protected readonly providerTemplates: {
7
+ [id: string]: ProviderDetails;
8
+ };
9
+ protected initialized: boolean;
10
+ get(providerId: string): Promise<ProviderDetails | undefined>;
11
+ }
@@ -0,0 +1,47 @@
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 { ProviderDetailsManager } from './provider-protocol.js';
11
+ import { Value, Component } from '@celljs/core';
12
+ let InMemoryProviderDetailsManager = class InMemoryProviderDetailsManager {
13
+ constructor() {
14
+ this.providers = {};
15
+ this.providerTemplates = {};
16
+ this.initialized = false;
17
+ }
18
+ async get(providerId) {
19
+ if (!this.initialized) {
20
+ for (const id in this.providers) {
21
+ if (Object.prototype.hasOwnProperty.call(this.providers, id)) {
22
+ const template = this.providerTemplates[id];
23
+ const provider = { ...template, ...this.providers[id] };
24
+ provider.userInfoEndpoint = { ...template === null || template === void 0 ? void 0 : template.userInfoEndpoint, ...provider.userInfoEndpoint };
25
+ provider.configurationMetadata = { ...template === null || template === void 0 ? void 0 : template.configurationMetadata, ...provider.configurationMetadata };
26
+ this.providers[id] = provider;
27
+ }
28
+ }
29
+ this.providers = this.providers || {};
30
+ this.initialized = true;
31
+ }
32
+ return this.providers[providerId] || this.providerTemplates[providerId];
33
+ }
34
+ };
35
+ __decorate([
36
+ Value('cell.oauth2.client.providers'),
37
+ __metadata("design:type", Object)
38
+ ], InMemoryProviderDetailsManager.prototype, "providers", void 0);
39
+ __decorate([
40
+ Value('cell.oauth2.client.providerTemplates'),
41
+ __metadata("design:type", Object)
42
+ ], InMemoryProviderDetailsManager.prototype, "providerTemplates", void 0);
43
+ InMemoryProviderDetailsManager = __decorate([
44
+ Component(ProviderDetailsManager)
45
+ ], InMemoryProviderDetailsManager);
46
+ export { InMemoryProviderDetailsManager };
47
+ //# sourceMappingURL=provider-details-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-details-manager.js","sourceRoot":"","sources":["../../../src/node/provider/provider-details-manager.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,sBAAsB,EAAmB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAApC;QAGO,cAAS,GAAsC,EAAE,CAAC;QAGzC,sBAAiB,GAAsC,EAAE,CAAC;QAEnE,gBAAW,GAAG,KAAK,CAAC;IAoBlC,CAAC;IAlBG,KAAK,CAAC,GAAG,CAAC,UAAkB;QACxB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACpB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBAC9B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC;oBAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;oBAC5C,MAAM,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;oBACxD,QAAQ,CAAC,gBAAgB,GAAG,EAAE,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,EAAE,GAAG,QAAQ,CAAC,gBAAgB,EAAE,CAAC;oBAC5F,QAAQ,CAAC,qBAAqB,GAAG,EAAE,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,qBAAqB,EAAE,GAAG,QAAQ,CAAC,qBAAqB,EAAE,CAAC;oBAC3G,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC;gBAClC,CAAC;YACL,CAAC;YACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;YACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC5B,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC5E,CAAC;CAEJ,CAAA;AAzBa;IADT,KAAK,CAAC,8BAA8B,CAAC;;iEACsB;AAGzC;IADlB,KAAK,CAAC,sCAAsC,CAAC;;yEAC+B;AANpE,8BAA8B;IAD1C,SAAS,CAAC,sBAAsB,CAAC;GACrB,8BAA8B,CA4B1C"}
@@ -0,0 +1,20 @@
1
+ import { AuthenticationMethod } from '@celljs/oauth2-core';
2
+ export declare const ProviderDetailsManager: unique symbol;
3
+ export interface ProviderDetails {
4
+ authorizationUri: string;
5
+ tokenUri: string;
6
+ userInfoEndpoint: UserInfoEndpoint;
7
+ jwkSetUri: string;
8
+ issuerUri: string;
9
+ configurationMetadata: {
10
+ [key: string]: any;
11
+ };
12
+ }
13
+ export interface UserInfoEndpoint {
14
+ uri: string;
15
+ authenticationMethod: AuthenticationMethod;
16
+ userNameAttributeName: string;
17
+ }
18
+ export interface ProviderDetailsManager {
19
+ get(providerId: string): Promise<ProviderDetails | undefined>;
20
+ }
@@ -0,0 +1,2 @@
1
+ export const ProviderDetailsManager = Symbol('ProviderDetailsManager');
2
+ //# sourceMappingURL=provider-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-protocol.js","sourceRoot":"","sources":["../../../src/node/provider/provider-protocol.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { JwtDecoderFactory, JwtDecoder, JwkSetManager } from '@celljs/oauth2-jose';
2
+ import { ClientRegistration, JwsAlgorithmResolver } from './registration-protocol.js';
3
+ import { ProviderDetailsManager } from '../provider/index.js';
4
+ import { KeyLike } from 'jose';
5
+ import { AuthorizationRequest } from '@celljs/oauth2-core';
6
+ import { AuthorizationRequestManager } from '../authorization/index.js';
7
+ export declare class IdTokenJwtDecoderFactory implements JwtDecoderFactory<ClientRegistration> {
8
+ protected readonly jwsAlgorithmResolver: JwsAlgorithmResolver;
9
+ protected readonly authorizationRequestManager: AuthorizationRequestManager<AuthorizationRequest>;
10
+ protected readonly jwkSetManager: JwkSetManager<KeyLike | Uint8Array>;
11
+ protected readonly providerDetailsManager: ProviderDetailsManager;
12
+ protected readonly jwtDecoders: Map<string, JwtDecoder>;
13
+ create(clientRegistration: ClientRegistration): Promise<JwtDecoder>;
14
+ }
@@ -0,0 +1,86 @@
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 { JwkSetManager, JwsAlgorithms } from '@celljs/oauth2-jose';
11
+ import { JwsAlgorithmResolver, MISSING_SIGNATURE_VERIFIER_ERROR_CODE } from './registration-protocol.js';
12
+ import { Component, Autowired } from '@celljs/core';
13
+ import { ProviderDetailsManager } from '../provider/index.js';
14
+ import { jwtVerify, generateSecret } from 'jose';
15
+ import { OAuth2AuthenticationError } from '@celljs/oauth2-core';
16
+ import { AuthorizationRequestManager } from '../authorization/index.js';
17
+ let IdTokenJwtDecoderFactory = class IdTokenJwtDecoderFactory {
18
+ constructor() {
19
+ this.jwtDecoders = new Map();
20
+ }
21
+ async create(clientRegistration) {
22
+ const { registrationId } = clientRegistration;
23
+ let jwtDecoder = this.jwtDecoders.get(registrationId);
24
+ if (!jwtDecoder) {
25
+ const jwsAlgorithm = await this.jwsAlgorithmResolver.reolve(clientRegistration);
26
+ const { jwkSetUri, issuerUri } = await this.providerDetailsManager.get(registrationId);
27
+ let key;
28
+ if (jwsAlgorithm === JwsAlgorithms.RS256) {
29
+ if (!jwkSetUri) {
30
+ throw new OAuth2AuthenticationError({
31
+ errorCode: MISSING_SIGNATURE_VERIFIER_ERROR_CODE,
32
+ description: `Failed to find a Signature Verifier for Client Registration: '${registrationId}'. Check to ensure you have configured the JwkSet URI.`
33
+ });
34
+ }
35
+ key = await this.jwkSetManager.get(jwkSetUri);
36
+ }
37
+ else {
38
+ const { clientSecret } = clientRegistration;
39
+ if (!clientSecret) {
40
+ throw new OAuth2AuthenticationError({
41
+ errorCode: MISSING_SIGNATURE_VERIFIER_ERROR_CODE,
42
+ description: `Failed to find a Signature Verifier for Client Registration: '${registrationId}'. Check to ensure you have configured the client secret.`
43
+ });
44
+ }
45
+ key = await generateSecret(clientRegistration.clientSecret);
46
+ }
47
+ jwtDecoder = {
48
+ decode: async (token) => {
49
+ const { payload, protectedHeader } = await jwtVerify(token, key, {
50
+ issuer: issuerUri,
51
+ audience: clientRegistration.clientId,
52
+ algorithms: [jwsAlgorithm]
53
+ });
54
+ return {
55
+ header: protectedHeader,
56
+ payload,
57
+ token
58
+ };
59
+ }
60
+ };
61
+ this.jwtDecoders.set(registrationId, jwtDecoder);
62
+ }
63
+ return jwtDecoder;
64
+ }
65
+ };
66
+ __decorate([
67
+ Autowired(JwsAlgorithmResolver),
68
+ __metadata("design:type", Object)
69
+ ], IdTokenJwtDecoderFactory.prototype, "jwsAlgorithmResolver", void 0);
70
+ __decorate([
71
+ Autowired(AuthorizationRequestManager),
72
+ __metadata("design:type", Object)
73
+ ], IdTokenJwtDecoderFactory.prototype, "authorizationRequestManager", void 0);
74
+ __decorate([
75
+ Autowired(JwkSetManager),
76
+ __metadata("design:type", Object)
77
+ ], IdTokenJwtDecoderFactory.prototype, "jwkSetManager", void 0);
78
+ __decorate([
79
+ Autowired(ProviderDetailsManager),
80
+ __metadata("design:type", Object)
81
+ ], IdTokenJwtDecoderFactory.prototype, "providerDetailsManager", void 0);
82
+ IdTokenJwtDecoderFactory = __decorate([
83
+ Component()
84
+ ], IdTokenJwtDecoderFactory);
85
+ export { IdTokenJwtDecoderFactory };
86
+ //# sourceMappingURL=id-token-jwt-decoder-facatory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-token-jwt-decoder-facatory.js","sourceRoot":"","sources":["../../../src/node/registration/id-token-jwt-decoder-facatory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAiC,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAsB,oBAAoB,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAC1H,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAmB,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,SAAS,EAAW,cAAc,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAwB,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAGxD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAA9B;QAcgB,gBAAW,GAAG,IAAI,GAAG,EAAsB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AAE,GAAG,EAAE;wBAC7D,MAAM,EAAE,SAAS;wBACjB,QAAQ,EAAE,kBAAkB,CAAC,QAAQ;wBACrC,UAAU,EAAE,CAAE,YAAY,CAAE;qBAC/B,CAAC,CAAC;oBACH,OAAO;wBACH,MAAM,EAAE,eAAe;wBACvB,OAAO;wBACP,KAAK;qBACR,CAAC;gBACN,CAAC;aACJ,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;CAEJ,CAAA;AA1DsB;IADlB,SAAS,CAAC,oBAAoB,CAAC;;sEAC8B;AAG3C;IADlB,SAAS,CAAC,2BAA2B,CAAC;;6EAC2D;AAG/E;IADlB,SAAS,CAAC,aAAa,CAAC;;+DAC6C;AAGnD;IADlB,SAAS,CAAC,sBAAsB,CAAC;;wEACgC;AAZzD,wBAAwB;IADpC,SAAS,EAAE;GACC,wBAAwB,CA6DpC"}
@@ -0,0 +1,4 @@
1
+ export * from './registration-protocol.js';
2
+ export * from './registration-manager.js';
3
+ export * from './id-token-jwt-decoder-facatory.js';
4
+ export * from './jws-algorithm-resolver.js';
@@ -0,0 +1,5 @@
1
+ export * from './registration-protocol.js';
2
+ export * from './registration-manager.js';
3
+ export * from './id-token-jwt-decoder-facatory.js';
4
+ export * from './jws-algorithm-resolver.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/registration/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ClientRegistration, JwsAlgorithmResolver } from './registration-protocol.js';
2
+ export declare class DefaultJwsAlgorithmResolver implements JwsAlgorithmResolver {
3
+ reolve(clientRegistration: ClientRegistration): Promise<string>;
4
+ }
@@ -0,0 +1,19 @@
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
+ import { JwsAlgorithms } from '@celljs/oauth2-jose';
8
+ import { JwsAlgorithmResolver } from './registration-protocol.js';
9
+ import { Component } from '@celljs/core';
10
+ let DefaultJwsAlgorithmResolver = class DefaultJwsAlgorithmResolver {
11
+ async reolve(clientRegistration) {
12
+ return JwsAlgorithms.RS256;
13
+ }
14
+ };
15
+ DefaultJwsAlgorithmResolver = __decorate([
16
+ Component(JwsAlgorithmResolver)
17
+ ], DefaultJwsAlgorithmResolver);
18
+ export { DefaultJwsAlgorithmResolver };
19
+ //# sourceMappingURL=jws-algorithm-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jws-algorithm-resolver.js","sourceRoot":"","sources":["../../../src/node/registration/jws-algorithm-resolver.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAsB,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGlC,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAEpC,KAAK,CAAC,MAAM,CAAC,kBAAsC;QAC/C,OAAO,aAAa,CAAC,KAAK,CAAC;IAC/B,CAAC;CAEJ,CAAA;AANY,2BAA2B;IADvC,SAAS,CAAC,oBAAoB,CAAC;GACnB,2BAA2B,CAMvC"}
@@ -0,0 +1,14 @@
1
+ import { ClientRegistrationManager, ClientRegistration } from './registration-protocol.js';
2
+ import { ClientAuthenticationMethod } from '@celljs/oauth2-core';
3
+ export declare class InMemoryClientRegistrationManager implements ClientRegistrationManager {
4
+ protected readonly registrations: {
5
+ [id: string]: ClientRegistration;
6
+ };
7
+ protected readonly registrationTemplates: {
8
+ [id: string]: ClientRegistration;
9
+ };
10
+ protected readonly defaultRedirectUri: string;
11
+ protected initialized: boolean;
12
+ get(registrationId: string): Promise<ClientRegistration | undefined>;
13
+ protected deduceClientAuthenticationMethod(clientRegistration: ClientRegistration): ClientAuthenticationMethod.Basic | ClientAuthenticationMethod.None;
14
+ }
@@ -0,0 +1,61 @@
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 { ClientRegistrationManager } from './registration-protocol.js';
11
+ import { Value, Component } from '@celljs/core';
12
+ import { AuthorizationGrantType, ClientAuthenticationMethod } from '@celljs/oauth2-core';
13
+ let InMemoryClientRegistrationManager = class InMemoryClientRegistrationManager {
14
+ constructor() {
15
+ this.registrations = {};
16
+ this.registrationTemplates = {};
17
+ this.initialized = false;
18
+ }
19
+ async get(registrationId) {
20
+ if (!this.initialized) {
21
+ for (const id in this.registrations) {
22
+ if (Object.prototype.hasOwnProperty.call(this.registrations, id)) {
23
+ const template = this.registrationTemplates[id];
24
+ const registration = { ...template, ...this.registrations[id] };
25
+ this.registrations[id] = registration;
26
+ registration.registrationId = id;
27
+ registration.clientAuthenticationMethod = registration.clientAuthenticationMethod || this.deduceClientAuthenticationMethod(registration);
28
+ registration.redirectUri = registration.redirectUri || this.defaultRedirectUri;
29
+ registration.provider = registration.provider || id;
30
+ registration.clientName = registration.clientName || id;
31
+ }
32
+ }
33
+ this.initialized = true;
34
+ }
35
+ return this.registrations[registrationId];
36
+ }
37
+ deduceClientAuthenticationMethod(clientRegistration) {
38
+ if (AuthorizationGrantType.AuthorizationCode === clientRegistration.authorizationGrantType
39
+ && !clientRegistration.clientSecret) {
40
+ return ClientAuthenticationMethod.None;
41
+ }
42
+ return ClientAuthenticationMethod.Basic;
43
+ }
44
+ };
45
+ __decorate([
46
+ Value('cell.oauth2.client.registrations'),
47
+ __metadata("design:type", Object)
48
+ ], InMemoryClientRegistrationManager.prototype, "registrations", void 0);
49
+ __decorate([
50
+ Value('cell.oauth2.client.registrationTemplates'),
51
+ __metadata("design:type", Object)
52
+ ], InMemoryClientRegistrationManager.prototype, "registrationTemplates", void 0);
53
+ __decorate([
54
+ Value('cell.oauth2.client.defaultRedirectUri'),
55
+ __metadata("design:type", String)
56
+ ], InMemoryClientRegistrationManager.prototype, "defaultRedirectUri", void 0);
57
+ InMemoryClientRegistrationManager = __decorate([
58
+ Component(ClientRegistrationManager)
59
+ ], InMemoryClientRegistrationManager);
60
+ export { InMemoryClientRegistrationManager };
61
+ //# sourceMappingURL=registration-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-manager.js","sourceRoot":"","sources":["../../../src/node/registration/registration-manager.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,yBAAyB,EAAsB,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAGlF,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;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AAC,kBAAkB,CAAC,YAAY,EAAE,CAAC;YACtC,OAAO,0BAA0B,CAAC,IAAI,CAAC;QAC3C,CAAC;QACD,OAAO,0BAA0B,CAAC,KAAK,CAAC;IAC5C,CAAC;CAEJ,CAAA;AAtCsB;IADlB,KAAK,CAAC,kCAAkC,CAAC;;wEACkC;AAGzD;IADlB,KAAK,CAAC,0CAA0C,CAAC;;gFACkC;AAGjE;IADlB,KAAK,CAAC,uCAAuC,CAAC;;6EACD;AATrC,iCAAiC;IAD7C,SAAS,CAAC,yBAAyB,CAAC;GACxB,iCAAiC,CAyC7C"}
@@ -0,0 +1,21 @@
1
+ import { ClientAuthenticationMethod, AuthorizationGrantType } from '@celljs/oauth2-core';
2
+ export declare const ClientRegistrationManager: unique symbol;
3
+ export declare const JwsAlgorithmResolver: unique symbol;
4
+ export declare const MISSING_SIGNATURE_VERIFIER_ERROR_CODE = "missing_signature_verifier";
5
+ export interface ClientRegistration {
6
+ registrationId: string;
7
+ clientId: string;
8
+ clientSecret: string;
9
+ clientAuthenticationMethod: ClientAuthenticationMethod;
10
+ authorizationGrantType: AuthorizationGrantType;
11
+ redirectUri: string;
12
+ scopes: string[];
13
+ provider: string;
14
+ clientName: string;
15
+ }
16
+ export interface ClientRegistrationManager {
17
+ get(registrationId: string): Promise<ClientRegistration | undefined>;
18
+ }
19
+ export interface JwsAlgorithmResolver {
20
+ reolve(clientRegistration: ClientRegistration): Promise<string>;
21
+ }
@@ -0,0 +1,4 @@
1
+ export const ClientRegistrationManager = Symbol('ClientRegistrationManager');
2
+ export const JwsAlgorithmResolver = Symbol('JwsAlgorithmResolver');
3
+ export const MISSING_SIGNATURE_VERIFIER_ERROR_CODE = 'missing_signature_verifier';
4
+ //# sourceMappingURL=registration-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-protocol.js","sourceRoot":"","sources":["../../../src/node/registration/registration-protocol.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,qCAAqC,GAAG,4BAA4B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './user-protocol.js';
2
+ export * from './oauth2-user-service.js';
3
+ export * from './oidc-user-service.js';
@@ -0,0 +1,4 @@
1
+ export * from './user-protocol.js';
2
+ export * from './oauth2-user-service.js';
3
+ export * from './oidc-user-service.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/user/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { UserService } from '@celljs/security/lib/node';
2
+ import { User } from '@celljs/security';
3
+ import { OAuth2UserRequest, UserResponseClient } from '../endpoint/index.js';
4
+ import { ProviderDetailsManager } from '../provider/index.js';
5
+ export declare class OAuth2UserService implements UserService<OAuth2UserRequest, User> {
6
+ protected readonly providerDetailsManager: ProviderDetailsManager;
7
+ protected readonly userResponseClient: UserResponseClient<OAuth2UserRequest>;
8
+ load(userRequest: OAuth2UserRequest): Promise<User>;
9
+ }
@@ -0,0 +1,58 @@
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 { Component, Autowired } from '@celljs/core';
11
+ import { UserResponseClient, MISSING_USER_INFO_URI_ERROR_CODE, MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE } from '../endpoint/index.js';
12
+ import { ProviderDetailsManager } from '../provider/index.js';
13
+ import { OAuth2AuthenticationError } from '@celljs/oauth2-core';
14
+ let OAuth2UserService = class OAuth2UserService {
15
+ async load(userRequest) {
16
+ const { clientRegistration } = userRequest;
17
+ const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
18
+ if (!(providerDetails === null || providerDetails === void 0 ? void 0 : providerDetails.userInfoEndpoint.uri)) {
19
+ throw new OAuth2AuthenticationError({
20
+ errorCode: MISSING_USER_INFO_URI_ERROR_CODE,
21
+ description: `Missing required UserInfo Uri in UserInfoEndpoint for Client Registration: ${clientRegistration.registrationId}`
22
+ });
23
+ }
24
+ const userNameAttributeName = providerDetails.userInfoEndpoint.userNameAttributeName;
25
+ if (!userNameAttributeName) {
26
+ throw new OAuth2AuthenticationError({
27
+ errorCode: MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE,
28
+ description: `Missing required "user name" attribute name in UserInfoEndpoint for Client Registration: ${clientRegistration.registrationId}`
29
+ });
30
+ }
31
+ const { userAttributes } = await this.userResponseClient.getUserResponse(userRequest);
32
+ const claims = userAttributes;
33
+ return {
34
+ type: clientRegistration.registrationId,
35
+ username: claims[userNameAttributeName],
36
+ password: '',
37
+ accountNonExpired: true,
38
+ accountNonLocked: true,
39
+ credentialsNonExpired: true,
40
+ enabled: true,
41
+ policies: [],
42
+ claims
43
+ };
44
+ }
45
+ };
46
+ __decorate([
47
+ Autowired(ProviderDetailsManager),
48
+ __metadata("design:type", Object)
49
+ ], OAuth2UserService.prototype, "providerDetailsManager", void 0);
50
+ __decorate([
51
+ Autowired(UserResponseClient),
52
+ __metadata("design:type", Object)
53
+ ], OAuth2UserService.prototype, "userResponseClient", void 0);
54
+ OAuth2UserService = __decorate([
55
+ Component()
56
+ ], OAuth2UserService);
57
+ export { OAuth2UserService };
58
+ //# sourceMappingURL=oauth2-user-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth2-user-service.js","sourceRoot":"","sources":["../../../src/node/user/oauth2-user-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,EAAqB,kBAAkB,EAAE,gCAAgC,EAAE,sCAAsC,EAAE,MAAM,aAAa,CAAC;AAC9I,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAQ1B,KAAK,CAAC,IAAI,CAAC,WAA8B;QACrC,MAAM,EAAE,kBAAkB,EAAE,GAAG,WAAW,CAAC;QAC3C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAC3F,IAAI,EAAC,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,gBAAgB,CAAC,GAAG,CAAA,EAAE,CAAC;YACzC,MAAM,IAAI,yBAAyB,CAAC;gBAChC,SAAS,EAAE,gCAAgC;gBAC3C,WAAW,EAAE,8EAA8E,kBAAkB,CAAC,cAAc,EAAE;aACjI,CAAC,CAAC;QACP,CAAC;QACD,MAAM,qBAAqB,GAAG,eAAe,CAAC,gBAAgB,CAAC,qBAAqB,CAAC;QACrF,IAAI,CAAC,qBAAqB,EAAE,CAAC;YACzB,MAAM,IAAI,yBAAyB,CAAC;gBAChC,SAAS,EAAE,sCAAsC;gBACjD,WAAW,EAAE,4FAA4F,kBAAkB,CAAC,cAAc,EAAE;aAC/I,CAAC,CAAC;QACP,CAAC;QACD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QAEtF,MAAM,MAAM,GAAG,cAAc,CAAC;QAE9B,OAAO;YACH,IAAI,EAAE,kBAAkB,CAAC,cAAc;YACvC,QAAQ,EAAE,MAAM,CAAC,qBAAqB,CAAC;YACvC,QAAQ,EAAE,EAAE;YACZ,iBAAiB,EAAE,IAAI;YACvB,gBAAgB,EAAE,IAAI;YACtB,qBAAqB,EAAE,IAAI;YAC3B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,EAAE;YACZ,MAAM;SACT,CAAC;IACN,CAAC;CACJ,CAAA;AArCsB;IADlB,SAAS,CAAC,sBAAsB,CAAC;;iEACgC;AAG/C;IADlB,SAAS,CAAC,kBAAkB,CAAC;;6DAC+C;AANpE,iBAAiB;IAD7B,SAAS,EAAE;GACC,iBAAiB,CAwC7B"}
@@ -0,0 +1,12 @@
1
+ import { UserService } from '@celljs/security/lib/node';
2
+ import { User } from '@celljs/security';
3
+ import { OidcUserRequest } from './user-protocol.js';
4
+ import { OAuth2UserRequest, UserResponseClient } from '../endpoint/index.js';
5
+ import { ProviderDetailsManager } from '../provider/index.js';
6
+ export declare class OidcUserService implements UserService<OidcUserRequest, User> {
7
+ protected readonly accessibleScopes: string[];
8
+ protected readonly providerDetailsManager: ProviderDetailsManager;
9
+ protected readonly userResponseClient: UserResponseClient<OAuth2UserRequest>;
10
+ load(userRequest: OidcUserRequest): Promise<User>;
11
+ protected shuldRetrieveuserInfo(userRequest: OidcUserRequest): Promise<boolean>;
12
+ }
@@ -0,0 +1,95 @@
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 { Value, Component, Autowired } from '@celljs/core';
11
+ import { UserResponseClient, INVALID_USER_INFO_RESPONSE_ERROR_CODE } from '../endpoint/index.js';
12
+ import { ProviderDetailsManager } from '../provider/index.js';
13
+ import { AuthorizationGrantType, StandardClaimNames, OAuth2AuthenticationError, IdTokenClaimNames } from '@celljs/oauth2-core';
14
+ let OidcUserService = class OidcUserService {
15
+ async load(userRequest) {
16
+ var _a;
17
+ const { idToken, clientRegistration } = userRequest;
18
+ let claims = {};
19
+ if (await this.shuldRetrieveuserInfo(userRequest)) {
20
+ const { userAttributes } = await this.userResponseClient.getUserResponse(userRequest);
21
+ claims = { ...userAttributes };
22
+ const subject = claims[StandardClaimNames.SUB];
23
+ // https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse
24
+ // 1) The sub (subject) Claim MUST always be returned in the UserInfo Response
25
+ if (!subject) {
26
+ throw new OAuth2AuthenticationError({
27
+ errorCode: INVALID_USER_INFO_RESPONSE_ERROR_CODE
28
+ });
29
+ }
30
+ // 2) Due to the possibility of token substitution attacks (see Section 16.11),
31
+ // the UserInfo Response is not guaranteed to be about the End-User
32
+ // identified by the sub (subject) element of the ID Token.
33
+ // The sub Claim in the UserInfo Response MUST be verified to exactly match
34
+ // the sub Claim in the ID Token; if they do not match,
35
+ // the UserInfo Response values MUST NOT be used.
36
+ if (subject !== idToken.payload[IdTokenClaimNames.SUB]) {
37
+ throw new OAuth2AuthenticationError({
38
+ errorCode: INVALID_USER_INFO_RESPONSE_ERROR_CODE
39
+ });
40
+ }
41
+ }
42
+ claims = { ...claims, ...idToken.payload };
43
+ const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
44
+ const userNameAttributeName = ((_a = providerDetails === null || providerDetails === void 0 ? void 0 : providerDetails.userInfoEndpoint) === null || _a === void 0 ? void 0 : _a.userNameAttributeName) || IdTokenClaimNames.SUB;
45
+ return {
46
+ type: clientRegistration.registrationId,
47
+ username: claims[userNameAttributeName],
48
+ password: '',
49
+ accountNonExpired: true,
50
+ accountNonLocked: true,
51
+ credentialsNonExpired: true,
52
+ enabled: true,
53
+ policies: [],
54
+ claims,
55
+ idToken
56
+ };
57
+ }
58
+ async shuldRetrieveuserInfo(userRequest) {
59
+ var _a, _b;
60
+ const { clientRegistration, accessToken } = userRequest;
61
+ const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
62
+ // Auto-disabled if UserInfo Endpoint URI is not provided
63
+ if (!((_a = providerDetails === null || providerDetails === void 0 ? void 0 : providerDetails.userInfoEndpoint) === null || _a === void 0 ? void 0 : _a.uri)) {
64
+ return false;
65
+ }
66
+ // The Claims requested by the profile, email, address, and phone scope values
67
+ // are returned from the UserInfo Endpoint (as described in Section 5.3.2),
68
+ // when a response_type value is used that results in an Access Token being issued.
69
+ // However, when no Access Token is issued, which is the case for the response_type=id_token,
70
+ // the resulting Claims are returned in the ID Token.
71
+ // The Authorization Code Grant Flow, which is response_type=code, results in an Access Token being issued.
72
+ if (AuthorizationGrantType.AuthorizationCode === clientRegistration.authorizationGrantType) {
73
+ // Return true if there is at least one match between the authorized scope(s) and accessible scope(s)
74
+ return !((_b = this.accessibleScopes) === null || _b === void 0 ? void 0 : _b.length) || this.accessibleScopes.some(v => accessToken.scopes.indexOf(v) !== -1);
75
+ }
76
+ return false;
77
+ }
78
+ };
79
+ __decorate([
80
+ Value('cell.oauth2.client.accessibleScopes'),
81
+ __metadata("design:type", Array)
82
+ ], OidcUserService.prototype, "accessibleScopes", void 0);
83
+ __decorate([
84
+ Autowired(ProviderDetailsManager),
85
+ __metadata("design:type", Object)
86
+ ], OidcUserService.prototype, "providerDetailsManager", void 0);
87
+ __decorate([
88
+ Autowired(UserResponseClient),
89
+ __metadata("design:type", Object)
90
+ ], OidcUserService.prototype, "userResponseClient", void 0);
91
+ OidcUserService = __decorate([
92
+ Component()
93
+ ], OidcUserService);
94
+ export { OidcUserService };
95
+ //# sourceMappingURL=oidc-user-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidc-user-service.js","sourceRoot":"","sources":["../../../src/node/user/oidc-user-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI3D,OAAO,EAAqB,kBAAkB,EAAE,qCAAqC,EAAE,MAAM,aAAa,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxH,IAAM,eAAe,GAArB,MAAM,eAAe;IAWxB,KAAK,CAAC,IAAI,CAAC,WAA4B;;QACnC,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,WAAW,CAAC;QACpD,IAAI,MAAM,GAA2B,EAAE,CAAC;QACxC,IAAI,MAAM,IAAI,CAAC,qBAAqB,CAAC,WAAW,CAAC,EAAE,CAAC;YAChD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACtF,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAE/C,yEAAyE;YAEzE,8EAA8E;YAC9E,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,MAAM,IAAI,yBAAyB,CAAC;oBAChC,SAAS,EAAE,qCAAqC;iBACnD,CAAC,CAAC;YACP,CAAC;YAED,+EAA+E;YAC/E,mEAAmE;YACnE,2DAA2D;YAC3D,2EAA2E;YAC3E,uDAAuD;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QAC7F,qDAAqD;QACrD,2GAA2G;QAC3G,IAAI,sBAAsB,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,sBAAsB,EAAE,CAAC;YAEzF,qGAAqG;YACrG,OAAO,EAAC,MAAA,IAAI,CAAC,gBAAgB,0CAAE,MAAM,CAAA,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnH,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAA;AA/EsB;IADlB,KAAK,CAAC,qCAAqC,CAAC;;yDACC;AAG3B;IADlB,SAAS,CAAC,sBAAsB,CAAC;;+DACgC;AAG/C;IADlB,SAAS,CAAC,kBAAkB,CAAC;;2DAC+C;AATpE,eAAe;IAD3B,SAAS,EAAE;GACC,eAAe,CAkF3B"}
@@ -0,0 +1,5 @@
1
+ import { Jwt } from '@celljs/oauth2-jose';
2
+ import { OAuth2UserRequest } from '../endpoint/index.js';
3
+ export interface OidcUserRequest extends OAuth2UserRequest {
4
+ idToken: Jwt;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=user-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-protocol.js","sourceRoot":"","sources":["../../../src/node/user/user-protocol.ts"],"names":[],"mappings":""}