@celljs/oauth2-client 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/cell.yml +57 -0
- package/lib/node/authentication/authentication-protocol.d.ts +25 -0
- package/lib/node/authentication/authentication-protocol.d.ts.map +1 -0
- package/lib/node/authentication/authentication-protocol.js +11 -0
- package/lib/node/authentication/authentication-protocol.js.map +1 -0
- package/lib/node/authentication/index.d.ts +4 -0
- package/lib/node/authentication/index.d.ts.map +1 -0
- package/lib/node/authentication/index.js +20 -0
- package/lib/node/authentication/index.js.map +1 -0
- package/lib/node/authentication/oauth2-authentication-provider.d.ts +30 -0
- package/lib/node/authentication/oauth2-authentication-provider.d.ts.map +1 -0
- package/lib/node/authentication/oauth2-authentication-provider.js +170 -0
- package/lib/node/authentication/oauth2-authentication-provider.js.map +1 -0
- package/lib/node/authentication/oidc-authentication-provider.d.ts +18 -0
- package/lib/node/authentication/oidc-authentication-provider.d.ts.map +1 -0
- package/lib/node/authentication/oidc-authentication-provider.js +74 -0
- package/lib/node/authentication/oidc-authentication-provider.js.map +1 -0
- package/lib/node/authorization/authorization-code-authorized-client-provider.d.ts +5 -0
- package/lib/node/authorization/authorization-code-authorized-client-provider.d.ts.map +1 -0
- package/lib/node/authorization/authorization-code-authorized-client-provider.js +27 -0
- package/lib/node/authorization/authorization-code-authorized-client-provider.js.map +1 -0
- package/lib/node/authorization/authorization-code-grant-middleware.d.ts +26 -0
- package/lib/node/authorization/authorization-code-grant-middleware.d.ts.map +1 -0
- package/lib/node/authorization/authorization-code-grant-middleware.js +129 -0
- package/lib/node/authorization/authorization-code-grant-middleware.js.map +1 -0
- package/lib/node/authorization/authorization-failure-handler.d.ts +10 -0
- package/lib/node/authorization/authorization-failure-handler.d.ts.map +1 -0
- package/lib/node/authorization/authorization-failure-handler.js +35 -0
- package/lib/node/authorization/authorization-failure-handler.js.map +1 -0
- package/lib/node/authorization/authorization-protocol.d.ts +78 -0
- package/lib/node/authorization/authorization-protocol.d.ts.map +1 -0
- package/lib/node/authorization/authorization-protocol.js +34 -0
- package/lib/node/authorization/authorization-protocol.js.map +1 -0
- package/lib/node/authorization/authorization-request-manager.d.ts +13 -0
- package/lib/node/authorization/authorization-request-manager.d.ts.map +1 -0
- package/lib/node/authorization/authorization-request-manager.js +64 -0
- package/lib/node/authorization/authorization-request-manager.js.map +1 -0
- package/lib/node/authorization/authorization-request-redirect-middleware.d.ts +20 -0
- package/lib/node/authorization/authorization-request-redirect-middleware.d.ts.map +1 -0
- package/lib/node/authorization/authorization-request-redirect-middleware.js +113 -0
- package/lib/node/authorization/authorization-request-redirect-middleware.js.map +1 -0
- package/lib/node/authorization/authorization-request-resolver.d.ts +38 -0
- package/lib/node/authorization/authorization-request-resolver.d.ts.map +1 -0
- package/lib/node/authorization/authorization-request-resolver.js +155 -0
- package/lib/node/authorization/authorization-request-resolver.js.map +1 -0
- package/lib/node/authorization/authorization-success-handler.d.ts +7 -0
- package/lib/node/authorization/authorization-success-handler.d.ts.map +1 -0
- package/lib/node/authorization/authorization-success-handler.js +28 -0
- package/lib/node/authorization/authorization-success-handler.js.map +1 -0
- package/lib/node/authorization/authorized-client-manager.d.ts +11 -0
- package/lib/node/authorization/authorized-client-manager.d.ts.map +1 -0
- package/lib/node/authorization/authorized-client-manager.js +48 -0
- package/lib/node/authorization/authorized-client-manager.js.map +1 -0
- package/lib/node/authorization/authorized-client-service.d.ts +12 -0
- package/lib/node/authorization/authorized-client-service.d.ts.map +1 -0
- package/lib/node/authorization/authorized-client-service.js +87 -0
- package/lib/node/authorization/authorized-client-service.js.map +1 -0
- package/lib/node/authorization/client-credentials-authorized-client-provider.d.ts +12 -0
- package/lib/node/authorization/client-credentials-authorized-client-provider.d.ts.map +1 -0
- package/lib/node/authorization/client-credentials-authorized-client-provider.js +72 -0
- package/lib/node/authorization/client-credentials-authorized-client-provider.js.map +1 -0
- package/lib/node/authorization/context-attributes-mapper.d.ts +5 -0
- package/lib/node/authorization/context-attributes-mapper.d.ts.map +1 -0
- package/lib/node/authorization/context-attributes-mapper.js +28 -0
- package/lib/node/authorization/context-attributes-mapper.js.map +1 -0
- package/lib/node/authorization/index.d.ts +14 -0
- package/lib/node/authorization/index.d.ts.map +1 -0
- package/lib/node/authorization/index.js +30 -0
- package/lib/node/authorization/index.js.map +1 -0
- package/lib/node/authorization/password-authorized-client-provider.d.ts +12 -0
- package/lib/node/authorization/password-authorized-client-provider.d.ts.map +1 -0
- package/lib/node/authorization/password-authorized-client-provider.js +85 -0
- package/lib/node/authorization/password-authorized-client-provider.js.map +1 -0
- package/lib/node/authorization/refresh-token-authorized-client-provider.d.ts +12 -0
- package/lib/node/authorization/refresh-token-authorized-client-provider.d.ts.map +1 -0
- package/lib/node/authorization/refresh-token-authorized-client-provider.js +68 -0
- package/lib/node/authorization/refresh-token-authorized-client-provider.js.map +1 -0
- package/lib/node/constants.d.ts +5 -0
- package/lib/node/constants.d.ts.map +1 -0
- package/lib/node/constants.js +8 -0
- package/lib/node/constants.js.map +1 -0
- package/lib/node/endpoint/authorization-code-token-response-client.d.ts +12 -0
- package/lib/node/endpoint/authorization-code-token-response-client.d.ts.map +1 -0
- package/lib/node/endpoint/authorization-code-token-response-client.js +83 -0
- package/lib/node/endpoint/authorization-code-token-response-client.js.map +1 -0
- package/lib/node/endpoint/client-credentials-token-response-client.d.ts +12 -0
- package/lib/node/endpoint/client-credentials-token-response-client.d.ts.map +1 -0
- package/lib/node/endpoint/client-credentials-token-response-client.js +80 -0
- package/lib/node/endpoint/client-credentials-token-response-client.js.map +1 -0
- package/lib/node/endpoint/endpoint-protocol.d.ts +48 -0
- package/lib/node/endpoint/endpoint-protocol.d.ts.map +1 -0
- package/lib/node/endpoint/endpoint-protocol.js +9 -0
- package/lib/node/endpoint/endpoint-protocol.js.map +1 -0
- package/lib/node/endpoint/index.d.ts +7 -0
- package/lib/node/endpoint/index.d.ts.map +1 -0
- package/lib/node/endpoint/index.js +23 -0
- package/lib/node/endpoint/index.js.map +1 -0
- package/lib/node/endpoint/password-token-response-client.d.ts +12 -0
- package/lib/node/endpoint/password-token-response-client.d.ts.map +1 -0
- package/lib/node/endpoint/password-token-response-client.js +82 -0
- package/lib/node/endpoint/password-token-response-client.js.map +1 -0
- package/lib/node/endpoint/refresh-token-token-response-client.d.ts +12 -0
- package/lib/node/endpoint/refresh-token-token-response-client.d.ts.map +1 -0
- package/lib/node/endpoint/refresh-token-token-response-client.js +87 -0
- package/lib/node/endpoint/refresh-token-token-response-client.js.map +1 -0
- package/lib/node/endpoint/user-response-client.d.ts +9 -0
- package/lib/node/endpoint/user-response-client.d.ts.map +1 -0
- package/lib/node/endpoint/user-response-client.js +84 -0
- package/lib/node/endpoint/user-response-client.js.map +1 -0
- package/lib/node/error/error-hander.d.ts +11 -0
- package/lib/node/error/error-hander.d.ts.map +1 -0
- package/lib/node/error/error-hander.js +52 -0
- package/lib/node/error/error-hander.js.map +1 -0
- package/lib/node/error/error-protocol.d.ts +3 -0
- package/lib/node/error/error-protocol.d.ts.map +1 -0
- package/lib/node/error/error-protocol.js +7 -0
- package/lib/node/error/error-protocol.js.map +1 -0
- package/lib/node/error/error.d.ts +10 -0
- package/lib/node/error/error.d.ts.map +1 -0
- package/lib/node/error/error.js +23 -0
- package/lib/node/error/error.js.map +1 -0
- package/lib/node/error/index.d.ts +4 -0
- package/lib/node/error/index.d.ts.map +1 -0
- package/lib/node/error/index.js +20 -0
- package/lib/node/error/index.js.map +1 -0
- package/lib/node/index.d.ts +8 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +24 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/module.d.ts +4 -0
- package/lib/node/module.d.ts.map +1 -0
- package/lib/node/module.js +6 -0
- package/lib/node/module.js.map +1 -0
- package/lib/node/provider/index.d.ts +3 -0
- package/lib/node/provider/index.d.ts.map +1 -0
- package/lib/node/provider/index.js +19 -0
- package/lib/node/provider/index.js.map +1 -0
- package/lib/node/provider/provider-details-manager.d.ts +12 -0
- package/lib/node/provider/provider-details-manager.d.ts.map +1 -0
- package/lib/node/provider/provider-details-manager.js +50 -0
- package/lib/node/provider/provider-details-manager.js.map +1 -0
- package/lib/node/provider/provider-protocol.d.ts +21 -0
- package/lib/node/provider/provider-protocol.d.ts.map +1 -0
- package/lib/node/provider/provider-protocol.js +5 -0
- package/lib/node/provider/provider-protocol.js.map +1 -0
- package/lib/node/registration/id-token-jwt-decoder-facatory.d.ts +15 -0
- package/lib/node/registration/id-token-jwt-decoder-facatory.d.ts.map +1 -0
- package/lib/node/registration/id-token-jwt-decoder-facatory.js +89 -0
- package/lib/node/registration/id-token-jwt-decoder-facatory.js.map +1 -0
- package/lib/node/registration/index.d.ts +5 -0
- package/lib/node/registration/index.d.ts.map +1 -0
- package/lib/node/registration/index.js +21 -0
- package/lib/node/registration/index.js.map +1 -0
- package/lib/node/registration/jws-algorithm-resolver.d.ts +5 -0
- package/lib/node/registration/jws-algorithm-resolver.d.ts.map +1 -0
- package/lib/node/registration/jws-algorithm-resolver.js +22 -0
- package/lib/node/registration/jws-algorithm-resolver.js.map +1 -0
- package/lib/node/registration/registration-manager.d.ts +15 -0
- package/lib/node/registration/registration-manager.d.ts.map +1 -0
- package/lib/node/registration/registration-manager.js +64 -0
- package/lib/node/registration/registration-manager.js.map +1 -0
- package/lib/node/registration/registration-protocol.d.ts +22 -0
- package/lib/node/registration/registration-protocol.d.ts.map +1 -0
- package/lib/node/registration/registration-protocol.js +7 -0
- package/lib/node/registration/registration-protocol.js.map +1 -0
- package/lib/node/user/index.d.ts +4 -0
- package/lib/node/user/index.d.ts.map +1 -0
- package/lib/node/user/index.js +20 -0
- package/lib/node/user/index.js.map +1 -0
- package/lib/node/user/oauth2-user-service.d.ts +10 -0
- package/lib/node/user/oauth2-user-service.d.ts.map +1 -0
- package/lib/node/user/oauth2-user-service.js +61 -0
- package/lib/node/user/oauth2-user-service.js.map +1 -0
- package/lib/node/user/oidc-user-service.d.ts +13 -0
- package/lib/node/user/oidc-user-service.d.ts.map +1 -0
- package/lib/node/user/oidc-user-service.js +98 -0
- package/lib/node/user/oidc-user-service.js.map +1 -0
- package/lib/node/user/user-protocol.d.ts +6 -0
- package/lib/node/user/user-protocol.d.ts.map +1 -0
- package/lib/node/user/user-protocol.js +3 -0
- package/lib/node/user/user-protocol.js.map +1 -0
- package/lib/node/utils/authorization-grant-request-entity-util.d.ts +10 -0
- package/lib/node/utils/authorization-grant-request-entity-util.d.ts.map +1 -0
- package/lib/node/utils/authorization-grant-request-entity-util.js +28 -0
- package/lib/node/utils/authorization-grant-request-entity-util.js.map +1 -0
- package/lib/node/utils/authorization-response-util.d.ts +8 -0
- package/lib/node/utils/authorization-response-util.d.ts.map +1 -0
- package/lib/node/utils/authorization-response-util.js +53 -0
- package/lib/node/utils/authorization-response-util.js.map +1 -0
- package/lib/node/utils/index.d.ts +3 -0
- package/lib/node/utils/index.d.ts.map +1 -0
- package/lib/node/utils/index.js +19 -0
- package/lib/node/utils/index.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +4 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +51 -0
- package/src/node/authentication/authentication-protocol.ts +26 -0
- package/src/node/authentication/index.ts +3 -0
- package/src/node/authentication/oauth2-authentication-provider.ts +163 -0
- package/src/node/authentication/oidc-authentication-provider.ts +60 -0
- package/src/node/authorization/authorization-code-authorized-client-provider.ts +16 -0
- package/src/node/authorization/authorization-code-grant-middleware.ts +110 -0
- package/src/node/authorization/authorization-failure-handler.ts +23 -0
- package/src/node/authorization/authorization-protocol.ts +104 -0
- package/src/node/authorization/authorization-request-manager.ts +54 -0
- package/src/node/authorization/authorization-request-redirect-middleware.ts +91 -0
- package/src/node/authorization/authorization-request-resolver.ts +149 -0
- package/src/node/authorization/authorization-success-handler.ts +15 -0
- package/src/node/authorization/authorized-client-manager.ts +35 -0
- package/src/node/authorization/authorized-client-service.ts +73 -0
- package/src/node/authorization/client-credentials-authorized-client-provider.ts +61 -0
- package/src/node/authorization/context-attributes-mapper.ts +18 -0
- package/src/node/authorization/index.ts +13 -0
- package/src/node/authorization/password-authorized-client-provider.ts +78 -0
- package/src/node/authorization/refresh-token-authorized-client-provider.ts +58 -0
- package/src/node/constants.ts +4 -0
- package/src/node/endpoint/authorization-code-token-response-client.ts +73 -0
- package/src/node/endpoint/client-credentials-token-response-client.ts +69 -0
- package/src/node/endpoint/endpoint-protocol.ts +55 -0
- package/src/node/endpoint/index.ts +6 -0
- package/src/node/endpoint/password-token-response-client.ts +71 -0
- package/src/node/endpoint/refresh-token-token-response-client.ts +77 -0
- package/src/node/endpoint/user-response-client.ts +72 -0
- package/src/node/error/error-hander.ts +39 -0
- package/src/node/error/error-protocol.ts +6 -0
- package/src/node/error/error.ts +19 -0
- package/src/node/error/index.ts +3 -0
- package/src/node/index.ts +7 -0
- package/src/node/module.ts +4 -0
- package/src/node/provider/index.ts +2 -0
- package/src/node/provider/provider-details-manager.ts +33 -0
- package/src/node/provider/provider-protocol.ts +24 -0
- package/src/node/registration/id-token-jwt-decoder-facatory.ts +71 -0
- package/src/node/registration/index.ts +4 -0
- package/src/node/registration/jws-algorithm-resolver.ts +12 -0
- package/src/node/registration/registration-manager.ts +47 -0
- package/src/node/registration/registration-protocol.ts +27 -0
- package/src/node/user/index.ts +3 -0
- package/src/node/user/oauth2-user-service.ts +50 -0
- package/src/node/user/oidc-user-service.ts +92 -0
- package/src/node/user/user-protocol.ts +6 -0
- package/src/node/utils/authorization-grant-request-entity-util.ts +26 -0
- package/src/node/utils/authorization-response-util.ts +50 -0
- package/src/node/utils/index.ts +2 -0
- package/src/package.spec.ts +4 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PasswordAuthorizedClientProvider = void 0;
|
|
13
|
+
const authorization_protocol_1 = require("./authorization-protocol");
|
|
14
|
+
const oauth2_core_1 = require("@celljs/oauth2-core");
|
|
15
|
+
const core_1 = require("@celljs/core");
|
|
16
|
+
const error_1 = require("../error");
|
|
17
|
+
const password_token_response_client_1 = require("../endpoint/password-token-response-client");
|
|
18
|
+
let PasswordAuthorizedClientProvider = class PasswordAuthorizedClientProvider {
|
|
19
|
+
async provide(context) {
|
|
20
|
+
const { clientRegistration, authorizedClient, attributes } = context;
|
|
21
|
+
if (oauth2_core_1.AuthorizationGrantType.Password !== clientRegistration.authorizationGrantType) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const username = attributes.get(authorization_protocol_1.AuthorizationContext.USERNAME_ATTRIBUTE_NAME);
|
|
25
|
+
const password = attributes.get(authorization_protocol_1.AuthorizationContext.PASSWORD_ATTRIBUTE_NAME);
|
|
26
|
+
if (!username || !password) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (authorizedClient && !this.hasTokenExpired(authorizedClient.accessToken)) {
|
|
30
|
+
// If client is already authorized but access token is NOT expired than no
|
|
31
|
+
// need for re-authorization
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (authorizedClient && this.hasTokenExpired(authorizedClient.accessToken) && authorizedClient.refreshToken) {
|
|
35
|
+
// If client is already authorized and access token is expired and a refresh
|
|
36
|
+
// token is available, than return and allow
|
|
37
|
+
// RefreshTokenAuthorizedClientProvider to handle the refresh
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// As per spec, in section 4.4.3 Access Token Response
|
|
41
|
+
// https://tools.ietf.org/html/rfc6749#section-4.4.3
|
|
42
|
+
// A refresh token SHOULD NOT be included.
|
|
43
|
+
//
|
|
44
|
+
// Therefore, renewing an expired access token (re-authorization)
|
|
45
|
+
// is the same as acquiring a new access token (authorization).
|
|
46
|
+
const tokenResponse = await this.getTokenResponse(clientRegistration, username, password);
|
|
47
|
+
return {
|
|
48
|
+
clientRegistration,
|
|
49
|
+
principalName: context.principal.name,
|
|
50
|
+
accessToken: tokenResponse.accessToken
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
hasTokenExpired(accessToken) {
|
|
54
|
+
return accessToken.expiresAt - Date.now() < this.clockSkew;
|
|
55
|
+
}
|
|
56
|
+
getTokenResponse(clientRegistration, username, password) {
|
|
57
|
+
try {
|
|
58
|
+
return this.accessTokenResponseClient.getTokenResponse({
|
|
59
|
+
authorizationGrantType: oauth2_core_1.AuthorizationGrantType.Password,
|
|
60
|
+
clientRegistration,
|
|
61
|
+
username,
|
|
62
|
+
password
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error instanceof oauth2_core_1.OAuth2AuthorizationError) {
|
|
67
|
+
throw new error_1.ClientAuthorizationError(error.oauth2Error, clientRegistration.registrationId, error);
|
|
68
|
+
}
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, core_1.Value)('cell.oauth2.client.clockSkew'),
|
|
75
|
+
__metadata("design:type", Number)
|
|
76
|
+
], PasswordAuthorizedClientProvider.prototype, "clockSkew", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, core_1.Autowired)(password_token_response_client_1.PasswordTokenResponseClient),
|
|
79
|
+
__metadata("design:type", password_token_response_client_1.PasswordTokenResponseClient)
|
|
80
|
+
], PasswordAuthorizedClientProvider.prototype, "accessTokenResponseClient", void 0);
|
|
81
|
+
PasswordAuthorizedClientProvider = __decorate([
|
|
82
|
+
(0, core_1.Component)(authorization_protocol_1.AuthorizedClientProvider)
|
|
83
|
+
], PasswordAuthorizedClientProvider);
|
|
84
|
+
exports.PasswordAuthorizedClientProvider = PasswordAuthorizedClientProvider;
|
|
85
|
+
//# sourceMappingURL=password-authorized-client-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-authorized-client-provider.js","sourceRoot":"","sources":["../../../src/node/authorization/password-authorized-client-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEAA4G;AAC5G,qDAAoG;AACpG,uCAA2D;AAE3D,oCAAoD;AACpD,+FAAyF;AAGlF,IAAM,gCAAgC,GAAtC,MAAM,gCAAgC;IAQzC,KAAK,CAAC,OAAO,CAAC,OAA6B;QACvC,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QACrE,IAAI,oCAAsB,CAAC,QAAQ,KAAK,kBAAkB,CAAC,sBAAsB,EAAE;YAC/E,OAAQ;SACX;QAED,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,6CAAoB,CAAC,uBAAuB,CAAC,CAAC;QAC9E,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,6CAAoB,CAAC,uBAAuB,CAAC,CAAC;QAE9E,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE;YACxB,OAAO;SACV;QAED,IAAI,gBAAgB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE;YACzE,0EAA0E;YAC1E,4BAA4B;YAC5B,OAAO;SACV;QAED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AAwB,CAAC;GACvB,gCAAgC,CAqE5C;AArEY,4EAAgC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AuthorizedClientProvider, AuthorizationContext, AuthorizedClient } from './authorization-protocol';
|
|
2
|
+
import { AccessToken } from '@celljs/oauth2-core';
|
|
3
|
+
import { RefreshTokenTokenResponseClient } from '../endpoint';
|
|
4
|
+
import { ClientRegistration } from '../registration';
|
|
5
|
+
export declare class RefreshTokenAuthorizedClientProvider implements AuthorizedClientProvider {
|
|
6
|
+
protected readonly clockSkew: number;
|
|
7
|
+
protected readonly accessTokenResponseClient: RefreshTokenTokenResponseClient;
|
|
8
|
+
provide(context: AuthorizationContext): Promise<AuthorizedClient | undefined>;
|
|
9
|
+
hasTokenExpired(accessToken: AccessToken): boolean;
|
|
10
|
+
protected getTokenResponse(clientRegistration: ClientRegistration, authorizedClient: AuthorizedClient, scopes?: string[]): Promise<import("@celljs/oauth2-core").AccessTokenResponse>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=refresh-token-authorized-client-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh-token-authorized-client-provider.d.ts","sourceRoot":"","sources":["../../../src/node/authorization/refresh-token-authorized-client-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAoD,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEpG,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAIrD,qBACa,oCAAqC,YAAW,wBAAwB;IAGjF,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAGrC,SAAS,CAAC,QAAQ,CAAC,yBAAyB,EAAE,+BAA+B,CAAC;IAExE,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAmBnF,eAAe,CAAC,WAAW,EAAE,WAAW;IAIxC,SAAS,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE;CAiB3H"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RefreshTokenAuthorizedClientProvider = void 0;
|
|
13
|
+
const authorization_protocol_1 = require("./authorization-protocol");
|
|
14
|
+
const oauth2_core_1 = require("@celljs/oauth2-core");
|
|
15
|
+
const core_1 = require("@celljs/core");
|
|
16
|
+
const endpoint_1 = require("../endpoint");
|
|
17
|
+
const error_1 = require("../error");
|
|
18
|
+
const assert_1 = require("assert");
|
|
19
|
+
let RefreshTokenAuthorizedClientProvider = class RefreshTokenAuthorizedClientProvider {
|
|
20
|
+
async provide(context) {
|
|
21
|
+
const { clientRegistration, authorizedClient, attributes } = context;
|
|
22
|
+
if (!authorizedClient || !authorizedClient.refreshToken || !this.hasTokenExpired(authorizedClient.accessToken)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const scopes = attributes.get(authorization_protocol_1.AuthorizationContext.REQUEST_SCOPE_ATTRIBUTE_NAME);
|
|
26
|
+
(0, assert_1.ok)(scopes || Array.isArray(scopes), `The context attribute must be of type Array '${authorization_protocol_1.AuthorizationContext.REQUEST_SCOPE_ATTRIBUTE_NAME}'`);
|
|
27
|
+
const tokenResponse = await this.getTokenResponse(clientRegistration, authorizedClient, scopes);
|
|
28
|
+
return {
|
|
29
|
+
clientRegistration,
|
|
30
|
+
principalName: context.principal.name,
|
|
31
|
+
accessToken: tokenResponse.accessToken,
|
|
32
|
+
refreshToken: tokenResponse.refreshToken
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
hasTokenExpired(accessToken) {
|
|
36
|
+
return accessToken.expiresAt - Date.now() < this.clockSkew;
|
|
37
|
+
}
|
|
38
|
+
getTokenResponse(clientRegistration, authorizedClient, scopes) {
|
|
39
|
+
try {
|
|
40
|
+
return this.accessTokenResponseClient.getTokenResponse({
|
|
41
|
+
authorizationGrantType: oauth2_core_1.AuthorizationGrantType.RefreshToken,
|
|
42
|
+
clientRegistration,
|
|
43
|
+
accessToken: authorizedClient.accessToken,
|
|
44
|
+
refreshToken: authorizedClient.refreshToken,
|
|
45
|
+
scopes
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error instanceof oauth2_core_1.OAuth2AuthorizationError) {
|
|
50
|
+
throw new error_1.ClientAuthorizationError(error.oauth2Error, clientRegistration.registrationId, error);
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, core_1.Value)('cell.oauth2.client.clockSkew'),
|
|
58
|
+
__metadata("design:type", Number)
|
|
59
|
+
], RefreshTokenAuthorizedClientProvider.prototype, "clockSkew", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, core_1.Autowired)(endpoint_1.RefreshTokenTokenResponseClient),
|
|
62
|
+
__metadata("design:type", endpoint_1.RefreshTokenTokenResponseClient)
|
|
63
|
+
], RefreshTokenAuthorizedClientProvider.prototype, "accessTokenResponseClient", void 0);
|
|
64
|
+
RefreshTokenAuthorizedClientProvider = __decorate([
|
|
65
|
+
(0, core_1.Component)(authorization_protocol_1.AuthorizedClientProvider)
|
|
66
|
+
], RefreshTokenAuthorizedClientProvider);
|
|
67
|
+
exports.RefreshTokenAuthorizedClientProvider = RefreshTokenAuthorizedClientProvider;
|
|
68
|
+
//# sourceMappingURL=refresh-token-authorized-client-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh-token-authorized-client-provider.js","sourceRoot":"","sources":["../../../src/node/authorization/refresh-token-authorized-client-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEAA4G;AAC5G,qDAAoG;AACpG,uCAA2D;AAC3D,0CAA8D;AAE9D,oCAAoD;AACpD,mCAA4B;AAGrB,IAAM,oCAAoC,GAA1C,MAAM,oCAAoC;IAQ7C,KAAK,CAAC,OAAO,CAAC,OAA6B;QACvC,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QACrE,IAAI,CAAC,gBAAgB,IAAI,CAAC,gBAAgB,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE;YAC5G,OAAO;SACV;QAED,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,6CAAoB,CAAC,4BAA4B,CAAC,CAAC;QAEjF,IAAA,WAAE,EAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,gDAAgD,6CAAoB,CAAC,4BAA4B,GAAG,CAAC,CAAC;QAE1I,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;QAChG,OAAO;YACH,kBAAkB;YAClB,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,IAAI;YACrC,WAAW,EAAE,aAAa,CAAC,WAAW;YACtC,YAAY,EAAE,aAAa,CAAC,YAAY;SAC3C,CAAC;IACN,CAAC;IAED,eAAe,CAAC,WAAwB;QACpC,OAAO,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;IAC/D,CAAC;IAES,gBAAgB,CAAC,kBAAsC,EAAE,gBAAkC,EAAE,MAAiB;QACpH,IAAI;YACA,OAAO,IAAI,CAAC,yBAAyB,CAAC,gBAAgB,CAAC;gBACnD,sBAAsB,EAAE,oCAAsB,CAAC,YAAY;gBAC3D,kBAAkB;gBAClB,WAAW,EAAE,gBAAgB,CAAC,WAAW;gBACzC,YAAY,EAAE,gBAAgB,CAAC,YAAa;gBAC5C,MAAM;aACT,CAAC,CAAC;SACN;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,KAAK,YAAY,sCAAwB,EAAE;gBAC3C,MAAM,IAAI,gCAAwB,CAAC,KAAK,CAAC,WAAW,EAAE,kBAAkB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;aACnG;YACD,MAAM,KAAK,CAAC;SACf;IACL,CAAC;CAEJ,CAAA;AA9CG;IAAC,IAAA,YAAK,EAAC,8BAA8B,CAAC;;uEACD;AAErC;IAAC,IAAA,gBAAS,EAAC,0CAA+B,CAAC;8BACG,0CAA+B;uFAAC;AANrE,oCAAoC;IADhD,IAAA,gBAAS,EAAC,iDAAwB,CAAC;GACvB,oCAAoC,CAgDhD;AAhDY,oFAAoC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const AUTHORIZATION_REQUEST_BASE_URI = "cell.oauth2.client.authorizationRequestBaseUri";
|
|
2
|
+
export declare const DEFAULT_REDIRECT_URI = "cell.oauth2.client.defaultRedirectUri";
|
|
3
|
+
export declare const AUTHORIZATION_CODE_GRANT_URI = "cell.oauth2.client.authorizationCodeGrantUri";
|
|
4
|
+
export declare const REDIRECT_LOGIN_PATH = "cell.oauth2.client.redirectLoginPath";
|
|
5
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/node/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,mDAAmD,CAAC;AAC/F,eAAO,MAAM,oBAAoB,0CAA0C,CAAC;AAC5E,eAAO,MAAM,4BAA4B,iDAAiD,CAAC;AAC3F,eAAO,MAAM,mBAAmB,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REDIRECT_LOGIN_PATH = exports.AUTHORIZATION_CODE_GRANT_URI = exports.DEFAULT_REDIRECT_URI = exports.AUTHORIZATION_REQUEST_BASE_URI = void 0;
|
|
4
|
+
exports.AUTHORIZATION_REQUEST_BASE_URI = 'cell.oauth2.client.authorizationRequestBaseUri';
|
|
5
|
+
exports.DEFAULT_REDIRECT_URI = 'cell.oauth2.client.defaultRedirectUri';
|
|
6
|
+
exports.AUTHORIZATION_CODE_GRANT_URI = 'cell.oauth2.client.authorizationCodeGrantUri';
|
|
7
|
+
exports.REDIRECT_LOGIN_PATH = 'cell.oauth2.client.redirectLoginPath';
|
|
8
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/node/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,8BAA8B,GAAG,gDAAgD,CAAC;AAClF,QAAA,oBAAoB,GAAG,uCAAuC,CAAC;AAC/D,QAAA,4BAA4B,GAAG,8CAA8C,CAAC;AAC9E,QAAA,mBAAmB,GAAG,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AccessTokenResponseClient, AuthorizationCodeGrantRequest } from './endpoint-protocol';
|
|
2
|
+
import { RestOperations } from '@celljs/http';
|
|
3
|
+
import { ProviderDetailsManager } from '../provider';
|
|
4
|
+
import { AccessTokenResponse, AccessTokenResponseConverter } from '@celljs/oauth2-core';
|
|
5
|
+
export declare class AuthorizationCodeTokenResponseClient implements AccessTokenResponseClient<AuthorizationCodeGrantRequest> {
|
|
6
|
+
protected readonly restOperations: RestOperations;
|
|
7
|
+
protected readonly providerDetailsManager: ProviderDetailsManager;
|
|
8
|
+
protected readonly accessTokenResponseConverter: AccessTokenResponseConverter;
|
|
9
|
+
getTokenResponse(authorizationCodeGrantRequest: AuthorizationCodeGrantRequest): Promise<AccessTokenResponse>;
|
|
10
|
+
protected buildFormParameters(authorizationCodeGrantRequest: AuthorizationCodeGrantRequest): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=authorization-code-token-response-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-code-token-response-client.d.ts","sourceRoot":"","sources":["../../../src/node/endpoint/authorization-code-token-response-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,6BAA6B,EAAqC,MAAM,qBAAqB,CAAC;AAElI,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,mBAAmB,EACxB,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAI9D,qBACa,oCAAqC,YAAW,yBAAyB,CAAC,6BAA6B,CAAC;IAGjH,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAGlD,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAGlE,SAAS,CAAC,QAAQ,CAAC,4BAA4B,EAAE,4BAA4B,CAAC;IAExE,gBAAgB,CAAC,6BAA6B,EAAE,6BAA6B,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgClH,SAAS,CAAC,mBAAmB,CAAC,6BAA6B,EAAE,6BAA6B;CAmB7F"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthorizationCodeTokenResponseClient = void 0;
|
|
13
|
+
const endpoint_protocol_1 = require("./endpoint-protocol");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
const http_1 = require("@celljs/http");
|
|
16
|
+
const provider_1 = require("../provider");
|
|
17
|
+
const oauth2_core_1 = require("@celljs/oauth2-core");
|
|
18
|
+
const utils_1 = require("../utils");
|
|
19
|
+
const qs = require("qs");
|
|
20
|
+
let AuthorizationCodeTokenResponseClient = class AuthorizationCodeTokenResponseClient {
|
|
21
|
+
async getTokenResponse(authorizationCodeGrantRequest) {
|
|
22
|
+
const { clientRegistration } = authorizationCodeGrantRequest;
|
|
23
|
+
const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
|
|
24
|
+
let response;
|
|
25
|
+
try {
|
|
26
|
+
response = await this.restOperations.post(providerDetails.tokenUri, this.buildFormParameters(authorizationCodeGrantRequest), {
|
|
27
|
+
headers: utils_1.AuthorizationGrantRequestEntityUtil.getTokenRequestHeaders(clientRegistration)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const oauth2Error = {
|
|
32
|
+
errorCode: endpoint_protocol_1.INVALID_TOKEN_RESPONSE_ERROR_CODE,
|
|
33
|
+
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}`
|
|
34
|
+
};
|
|
35
|
+
throw new oauth2_core_1.OAuth2AuthorizationError(oauth2Error, error);
|
|
36
|
+
}
|
|
37
|
+
const { data } = response;
|
|
38
|
+
const acccessTokenResponse = this.accessTokenResponseConverter.convert(data);
|
|
39
|
+
if (!acccessTokenResponse.accessToken.scopes || acccessTokenResponse.accessToken.scopes.length === 0) {
|
|
40
|
+
// As per spec, in Section 5.1 Successful Access Token Response
|
|
41
|
+
// https://tools.ietf.org/html/rfc6749#section-5.1
|
|
42
|
+
// If AccessTokenResponse.scope is empty, then default to the scope
|
|
43
|
+
// originally requested by the client in the Token Request
|
|
44
|
+
acccessTokenResponse.accessToken.scopes = clientRegistration.scopes;
|
|
45
|
+
}
|
|
46
|
+
return acccessTokenResponse;
|
|
47
|
+
}
|
|
48
|
+
buildFormParameters(authorizationCodeGrantRequest) {
|
|
49
|
+
const { authorizationExchange, clientRegistration, authorizationGrantType } = authorizationCodeGrantRequest;
|
|
50
|
+
const { authorizationRequest, authorizationResponse } = authorizationExchange;
|
|
51
|
+
const formParameters = {
|
|
52
|
+
[oauth2_core_1.OAuth2ParameterNames.GRANT_TYPE]: authorizationGrantType,
|
|
53
|
+
[oauth2_core_1.OAuth2ParameterNames.CODE]: authorizationResponse.code,
|
|
54
|
+
[oauth2_core_1.OAuth2ParameterNames.REDIRECT_URI]: authorizationRequest.redirectUri,
|
|
55
|
+
[oauth2_core_1.PkceParameterNames.CODE_VERIFIER]: authorizationRequest.attributes[oauth2_core_1.PkceParameterNames.CODE_VERIFIER]
|
|
56
|
+
};
|
|
57
|
+
const { clientAuthenticationMethod, clientId, clientSecret } = clientRegistration;
|
|
58
|
+
if (oauth2_core_1.ClientAuthenticationMethod.Basic !== clientAuthenticationMethod) {
|
|
59
|
+
formParameters[oauth2_core_1.OAuth2ParameterNames.CLIENT_ID] = clientId;
|
|
60
|
+
}
|
|
61
|
+
if (oauth2_core_1.ClientAuthenticationMethod.Post === clientAuthenticationMethod) {
|
|
62
|
+
formParameters[oauth2_core_1.OAuth2ParameterNames.CLIENT_SECRET] = clientSecret;
|
|
63
|
+
}
|
|
64
|
+
return qs.stringify(formParameters);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, core_1.Autowired)(http_1.RestOperations),
|
|
69
|
+
__metadata("design:type", Function)
|
|
70
|
+
], AuthorizationCodeTokenResponseClient.prototype, "restOperations", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, core_1.Autowired)(provider_1.ProviderDetailsManager),
|
|
73
|
+
__metadata("design:type", Object)
|
|
74
|
+
], AuthorizationCodeTokenResponseClient.prototype, "providerDetailsManager", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, core_1.Autowired)(oauth2_core_1.AccessTokenResponseConverter),
|
|
77
|
+
__metadata("design:type", oauth2_core_1.AccessTokenResponseConverter)
|
|
78
|
+
], AuthorizationCodeTokenResponseClient.prototype, "accessTokenResponseConverter", void 0);
|
|
79
|
+
AuthorizationCodeTokenResponseClient = __decorate([
|
|
80
|
+
(0, core_1.Component)()
|
|
81
|
+
], AuthorizationCodeTokenResponseClient);
|
|
82
|
+
exports.AuthorizationCodeTokenResponseClient = AuthorizationCodeTokenResponseClient;
|
|
83
|
+
//# sourceMappingURL=authorization-code-token-response-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-code-token-response-client.js","sourceRoot":"","sources":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GACC,oCAAoC,CA8DhD;AA9DY,oFAAoC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AccessTokenResponseClient, ClientCredentialsGrantRequest } from './endpoint-protocol';
|
|
2
|
+
import { RestOperations } from '@celljs/http';
|
|
3
|
+
import { ProviderDetailsManager } from '../provider';
|
|
4
|
+
import { AccessTokenResponse, AccessTokenResponseConverter } from '@celljs/oauth2-core';
|
|
5
|
+
export declare class ClientCredentialsTokenResponseClient implements AccessTokenResponseClient<ClientCredentialsGrantRequest> {
|
|
6
|
+
protected readonly restOperations: RestOperations;
|
|
7
|
+
protected readonly providerDetailsManager: ProviderDetailsManager;
|
|
8
|
+
protected readonly accessTokenResponseConverter: AccessTokenResponseConverter;
|
|
9
|
+
getTokenResponse(clientCredentialsGrantRequest: ClientCredentialsGrantRequest): Promise<AccessTokenResponse>;
|
|
10
|
+
protected buildFormParameters(clientCredentialsGrantRequest: ClientCredentialsGrantRequest): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=client-credentials-token-response-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-credentials-token-response-client.d.ts","sourceRoot":"","sources":["../../../src/node/endpoint/client-credentials-token-response-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAqC,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAElI,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAA2F,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAIjL,qBACa,oCAAqC,YAAW,yBAAyB,CAAC,6BAA6B,CAAC;IAGjH,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAGlD,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAGlE,SAAS,CAAC,QAAQ,CAAC,4BAA4B,EAAE,4BAA4B,CAAC;IAExE,gBAAgB,CAAC,6BAA6B,EAAE,6BAA6B,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgClH,SAAS,CAAC,mBAAmB,CAAC,6BAA6B,EAAE,6BAA6B;CAgB7F"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ClientCredentialsTokenResponseClient = void 0;
|
|
13
|
+
const endpoint_protocol_1 = require("./endpoint-protocol");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
const http_1 = require("@celljs/http");
|
|
16
|
+
const provider_1 = require("../provider");
|
|
17
|
+
const oauth2_core_1 = require("@celljs/oauth2-core");
|
|
18
|
+
const utils_1 = require("../utils");
|
|
19
|
+
const qs = require("qs");
|
|
20
|
+
let ClientCredentialsTokenResponseClient = class ClientCredentialsTokenResponseClient {
|
|
21
|
+
async getTokenResponse(clientCredentialsGrantRequest) {
|
|
22
|
+
const { clientRegistration } = clientCredentialsGrantRequest;
|
|
23
|
+
const providerDetails = await this.providerDetailsManager.get(clientRegistration.provider);
|
|
24
|
+
let response;
|
|
25
|
+
try {
|
|
26
|
+
response = await this.restOperations.post(providerDetails.tokenUri, this.buildFormParameters(clientCredentialsGrantRequest), {
|
|
27
|
+
headers: utils_1.AuthorizationGrantRequestEntityUtil.getTokenRequestHeaders(clientRegistration)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const oauth2Error = {
|
|
32
|
+
errorCode: endpoint_protocol_1.INVALID_TOKEN_RESPONSE_ERROR_CODE,
|
|
33
|
+
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}`
|
|
34
|
+
};
|
|
35
|
+
throw new oauth2_core_1.OAuth2AuthorizationError(oauth2Error, error);
|
|
36
|
+
}
|
|
37
|
+
const { data } = response;
|
|
38
|
+
const acccessTokenResponse = this.accessTokenResponseConverter.convert(data);
|
|
39
|
+
if (!acccessTokenResponse.accessToken.scopes || acccessTokenResponse.accessToken.scopes.length === 0) {
|
|
40
|
+
// As per spec, in Section 5.1 Successful Access Token Response
|
|
41
|
+
// https://tools.ietf.org/html/rfc6749#section-5.1
|
|
42
|
+
// If AccessTokenResponse.scope is empty, then default to the scope
|
|
43
|
+
// originally requested by the client in the Token Request
|
|
44
|
+
acccessTokenResponse.accessToken.scopes = clientRegistration.scopes;
|
|
45
|
+
}
|
|
46
|
+
return acccessTokenResponse;
|
|
47
|
+
}
|
|
48
|
+
buildFormParameters(clientCredentialsGrantRequest) {
|
|
49
|
+
const { clientRegistration, authorizationGrantType } = clientCredentialsGrantRequest;
|
|
50
|
+
const formParameters = {
|
|
51
|
+
[oauth2_core_1.OAuth2ParameterNames.GRANT_TYPE]: authorizationGrantType,
|
|
52
|
+
};
|
|
53
|
+
const { clientAuthenticationMethod, clientId, clientSecret, scopes } = clientRegistration;
|
|
54
|
+
if (scopes) {
|
|
55
|
+
formParameters[oauth2_core_1.OAuth2ParameterNames.SCOPE] = scopes.join(' ');
|
|
56
|
+
}
|
|
57
|
+
if (oauth2_core_1.ClientAuthenticationMethod.Post === clientAuthenticationMethod) {
|
|
58
|
+
formParameters[oauth2_core_1.OAuth2ParameterNames.CLIENT_ID] = clientId;
|
|
59
|
+
formParameters[oauth2_core_1.OAuth2ParameterNames.CLIENT_SECRET] = clientSecret;
|
|
60
|
+
}
|
|
61
|
+
return qs.stringify(formParameters);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, core_1.Autowired)(http_1.RestOperations),
|
|
66
|
+
__metadata("design:type", Function)
|
|
67
|
+
], ClientCredentialsTokenResponseClient.prototype, "restOperations", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, core_1.Autowired)(provider_1.ProviderDetailsManager),
|
|
70
|
+
__metadata("design:type", Object)
|
|
71
|
+
], ClientCredentialsTokenResponseClient.prototype, "providerDetailsManager", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, core_1.Autowired)(oauth2_core_1.AccessTokenResponseConverter),
|
|
74
|
+
__metadata("design:type", oauth2_core_1.AccessTokenResponseConverter)
|
|
75
|
+
], ClientCredentialsTokenResponseClient.prototype, "accessTokenResponseConverter", void 0);
|
|
76
|
+
ClientCredentialsTokenResponseClient = __decorate([
|
|
77
|
+
(0, core_1.Component)()
|
|
78
|
+
], ClientCredentialsTokenResponseClient);
|
|
79
|
+
exports.ClientCredentialsTokenResponseClient = ClientCredentialsTokenResponseClient;
|
|
80
|
+
//# 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,2DAAkI;AAClI,uCAAoD;AACpD,uCAA8C;AAC9C,0CAAqD;AACrD,qDAAiL;AACjL,oCAA+D;AAC/D,yBAAyB;AAGlB,IAAM,oCAAoC,GAA1C,MAAM,oCAAoC;IAW7C,KAAK,CAAC,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Ac,GAA2B;YAC3C,CAAC,kCAAoB,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;YACR,cAAc,CAAC,kCAAoB,CAAC,KAAK,CAAC,GAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAClE;QACD,IAAI,wCAA0B,CAAC,IAAI,KAAK,0BAA0B,EAAE;YAChE,cAAc,CAAC,kCAAoB,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;YAC1D,cAAc,CAAC,kCAAoB,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC;SACrE;QACD,OAAO,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;CAEJ,CAAA;AAzDG;IAAC,IAAA,gBAAS,EAAC,qBAAc,CAAC;;4EACwB;AAElD;IAAC,IAAA,gBAAS,EAAC,iCAAsB,CAAC;;oFACgC;AAElE;IAAC,IAAA,gBAAS,EAAC,0CAA4B,CAAC;8BACS,0CAA4B;0FAAC;AATrE,oCAAoC;IADhD,IAAA,gBAAS,GAAE;GACC,oCAAoC,CA2DhD;AA3DY,oFAAoC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ClientRegistration } from '../registration';
|
|
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
|
+
}
|
|
48
|
+
//# sourceMappingURL=endpoint-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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,kBAAkB,CAAC;IACvC,WAAW,EAAE,WAAW,CAAC;IACzB,oBAAoB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAChD;AAED,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CACzC;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,iBAAiB;IAC3D,eAAe,CAAC,oBAAoB,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACzE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INVALID_TOKEN_RESPONSE_ERROR_CODE = exports.INVALID_USER_INFO_RESPONSE_ERROR_CODE = exports.MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE = exports.MISSING_USER_INFO_URI_ERROR_CODE = exports.UserResponseClient = void 0;
|
|
4
|
+
exports.UserResponseClient = Symbol('UserResponseClient');
|
|
5
|
+
exports.MISSING_USER_INFO_URI_ERROR_CODE = 'missing_user_info_uri';
|
|
6
|
+
exports.MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE = 'missing_user_name_attribute';
|
|
7
|
+
exports.INVALID_USER_INFO_RESPONSE_ERROR_CODE = 'invalid_user_info_response';
|
|
8
|
+
exports.INVALID_TOKEN_RESPONSE_ERROR_CODE = 'invalid_token_response';
|
|
9
|
+
//# 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,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAElD,QAAA,gCAAgC,GAAG,uBAAuB,CAAC;AAC3D,QAAA,sCAAsC,GAAG,6BAA6B,CAAC;AACvE,QAAA,qCAAqC,GAAG,4BAA4B,CAAC;AAErE,QAAA,iCAAiC,GAAG,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './endpoint-protocol';
|
|
2
|
+
export * from './authorization-code-token-response-client';
|
|
3
|
+
export * from './client-credentials-token-response-client';
|
|
4
|
+
export * from './password-token-response-client';
|
|
5
|
+
export * from './refresh-token-token-response-client';
|
|
6
|
+
export * from './user-response-client';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","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,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./endpoint-protocol"), exports);
|
|
18
|
+
__exportStar(require("./authorization-code-token-response-client"), exports);
|
|
19
|
+
__exportStar(require("./client-credentials-token-response-client"), exports);
|
|
20
|
+
__exportStar(require("./password-token-response-client"), exports);
|
|
21
|
+
__exportStar(require("./refresh-token-token-response-client"), exports);
|
|
22
|
+
__exportStar(require("./user-response-client"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/endpoint/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,6EAA2D;AAC3D,6EAA2D;AAC3D,mEAAiD;AACjD,wEAAsD;AACtD,yDAAuC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AccessTokenResponseClient, PasswordGrantRequest } from './endpoint-protocol';
|
|
2
|
+
import { RestOperations } from '@celljs/http';
|
|
3
|
+
import { ProviderDetailsManager } from '../provider';
|
|
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
|
+
}
|
|
12
|
+
//# sourceMappingURL=password-token-response-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-token-response-client.d.ts","sourceRoot":"","sources":["../../../src/node/endpoint/password-token-response-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAqC,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEzH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAA2F,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAIjL,qBACa,2BAA4B,YAAW,yBAAyB,CAAC,oBAAoB,CAAC;IAG/F,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAGlD,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAGlE,SAAS,CAAC,QAAQ,CAAC,4BAA4B,EAAE,4BAA4B,CAAC;IAExE,gBAAgB,CAAC,oBAAoB,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgChG,SAAS,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,oBAAoB;CAkB3E"}
|