@sudoplatform/sudo-user 11.0.0 → 12.0.1
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/cjs/client/apiClient.d.ts +25 -0
- package/cjs/client/apiClient.js +149 -0
- package/cjs/client/apiClient.js.map +1 -0
- package/cjs/core/api-key-names.d.ts +8 -0
- package/cjs/core/api-key-names.js +12 -0
- package/cjs/core/api-key-names.js.map +1 -0
- package/cjs/core/auth-store.d.ts +51 -0
- package/cjs/core/auth-store.js +92 -0
- package/cjs/core/auth-store.js.map +1 -0
- package/cjs/core/crypto.d.ts +3 -0
- package/cjs/core/crypto.js +3 -0
- package/cjs/core/crypto.js.map +1 -0
- package/cjs/core/key-manager.d.ts +31 -0
- package/cjs/core/key-manager.js +113 -0
- package/cjs/core/key-manager.js.map +1 -0
- package/cjs/core/protected-store.d.ts +5 -0
- package/cjs/core/protected-store.js +3 -0
- package/cjs/core/protected-store.js.map +1 -0
- package/cjs/core/publisher.d.ts +6 -0
- package/cjs/core/publisher.js +3 -0
- package/cjs/core/publisher.js.map +1 -0
- package/cjs/core/sdk-config.d.ts +52 -0
- package/cjs/core/sdk-config.js +61 -0
- package/cjs/core/sdk-config.js.map +1 -0
- package/cjs/core/subscriber.d.ts +3 -0
- package/cjs/core/subscriber.js +3 -0
- package/cjs/core/subscriber.js.map +1 -0
- package/cjs/gen/graphql-types.d.ts +101 -0
- package/cjs/gen/graphql-types.js +105 -0
- package/cjs/gen/graphql-types.js.map +1 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +13 -0
- package/cjs/index.js.map +1 -0
- package/cjs/runtimes/browser/browser-crypto.d.ts +2 -0
- package/cjs/runtimes/browser/browser-crypto.js +10 -0
- package/cjs/runtimes/browser/browser-crypto.js.map +1 -0
- package/cjs/runtimes/node/node-crypto.d.ts +2 -0
- package/cjs/runtimes/node/node-crypto.js +9 -0
- package/cjs/runtimes/node/node-crypto.js.map +1 -0
- package/cjs/sdk.d.ts +1 -0
- package/cjs/sdk.js +9 -0
- package/cjs/sdk.js.map +1 -0
- package/cjs/user/auth-provider.d.ts +97 -0
- package/cjs/user/auth-provider.js +116 -0
- package/cjs/user/auth-provider.js.map +1 -0
- package/cjs/user/auth.d.ts +64 -0
- package/cjs/user/auth.js +136 -0
- package/cjs/user/auth.js.map +1 -0
- package/cjs/user/error.d.ts +18 -0
- package/cjs/user/error.js +33 -0
- package/cjs/user/error.js.map +1 -0
- package/cjs/user/identity-provider.d.ts +73 -0
- package/cjs/user/identity-provider.js +245 -0
- package/cjs/user/identity-provider.js.map +1 -0
- package/cjs/user/user-client-interface.d.ts +168 -0
- package/cjs/user/user-client-interface.js +3 -0
- package/cjs/user/user-client-interface.js.map +1 -0
- package/cjs/user/user-client.d.ts +82 -0
- package/cjs/user/user-client.js +440 -0
- package/cjs/user/user-client.js.map +1 -0
- package/cjs/user/user-key-names.d.ts +6 -0
- package/cjs/user/user-key-names.js +10 -0
- package/cjs/user/user-key-names.js.map +1 -0
- package/cjs/utils/resolvable-promise.d.ts +9 -0
- package/cjs/utils/resolvable-promise.js +20 -0
- package/cjs/utils/resolvable-promise.js.map +1 -0
- package/docs/classes/AlreadyRegisteredError.html +4 -4
- package/docs/classes/IdentityServiceConfigNotFoundError.html +4 -4
- package/lib/client/apiClient.js +135 -180
- package/lib/client/apiClient.js.map +1 -0
- package/lib/core/api-key-names.js +8 -14
- package/lib/core/api-key-names.js.map +1 -0
- package/lib/core/auth-store.js +82 -138
- package/lib/core/auth-store.js.map +1 -0
- package/lib/core/crypto.js +2 -5
- package/lib/core/crypto.js.map +1 -0
- package/lib/core/key-manager.js +98 -148
- package/lib/core/key-manager.js.map +1 -0
- package/lib/core/protected-store.d.ts +5 -0
- package/lib/core/protected-store.js +2 -5
- package/lib/core/protected-store.js.map +1 -0
- package/lib/core/publisher.js +2 -5
- package/lib/core/publisher.js.map +1 -0
- package/lib/core/sdk-config.js +56 -56
- package/lib/core/sdk-config.js.map +1 -0
- package/lib/core/subscriber.js +2 -5
- package/lib/core/subscriber.js.map +1 -0
- package/lib/gen/graphql-types.js +96 -135
- package/lib/gen/graphql-types.js.map +1 -0
- package/lib/index.js +6 -67
- package/lib/index.js.map +1 -0
- package/lib/runtimes/browser/browser-crypto.d.ts +2 -0
- package/lib/runtimes/browser/browser-crypto.js +6 -14
- package/lib/runtimes/browser/browser-crypto.js.map +1 -0
- package/lib/runtimes/node/node-crypto.js +5 -11
- package/lib/runtimes/node/node-crypto.js.map +1 -0
- package/lib/sdk.js +6 -18
- package/lib/sdk.js.map +1 -0
- package/lib/user/auth-provider.js +81 -131
- package/lib/user/auth-provider.js.map +1 -0
- package/lib/user/auth.js +127 -179
- package/lib/user/auth.js.map +1 -0
- package/lib/user/error.js +15 -33
- package/lib/user/error.js.map +1 -0
- package/lib/user/identity-provider.js +232 -261
- package/lib/user/identity-provider.js.map +1 -0
- package/lib/user/user-client-interface.js +2 -5
- package/lib/user/user-client-interface.js.map +1 -0
- package/lib/user/user-client.js +423 -510
- package/lib/user/user-client.js.map +1 -0
- package/lib/user/user-key-names.js +6 -12
- package/lib/user/user-key-names.js.map +1 -0
- package/lib/utils/resolvable-promise.js +13 -19
- package/lib/utils/resolvable-promise.js.map +1 -0
- package/package.json +22 -21
|
@@ -1,42 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TESTAuthenticationProvider = exports.TESTAuthenticationInfo = exports.LocalAuthenticationProvider = exports.LocalAuthenticationInfo = void 0;
|
|
7
|
-
|
|
8
|
-
var JWT = _interopRequireWildcard(require("jsonwebtoken"));
|
|
9
|
-
|
|
10
|
-
var _uuid = require("uuid");
|
|
11
|
-
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
1
|
+
import * as JWT from 'jsonwebtoken';
|
|
2
|
+
import { v4 } from 'uuid';
|
|
18
3
|
/**
|
|
19
4
|
* Authentication info consisting of a JWT signed using the TEST registration key.
|
|
20
5
|
*/
|
|
21
|
-
class TESTAuthenticationInfo {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
getUsername() {
|
|
37
|
-
return '';
|
|
38
|
-
}
|
|
39
|
-
|
|
6
|
+
export class TESTAuthenticationInfo {
|
|
7
|
+
constructor(jwt) {
|
|
8
|
+
this.jwt = jwt;
|
|
9
|
+
this.type = 'TEST';
|
|
10
|
+
}
|
|
11
|
+
isValid() {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
encode() {
|
|
15
|
+
return this.jwt;
|
|
16
|
+
}
|
|
17
|
+
getUsername() {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
40
20
|
}
|
|
41
21
|
/**
|
|
42
22
|
* Authentication provider for generating authentication info using a TEST registration key.
|
|
@@ -46,70 +26,50 @@ class TESTAuthenticationInfo {
|
|
|
46
26
|
* @param keyId key ID of the TEST registration key which is obtained from the admin console.
|
|
47
27
|
* @param attributes additional attributes to be added to the issued authentication info.
|
|
48
28
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
alg: 'RS256',
|
|
75
|
-
kid: this.keyId
|
|
76
|
-
},
|
|
77
|
-
algorithm: 'RS256'
|
|
78
|
-
});
|
|
79
|
-
return new TESTAuthenticationInfo(jwt);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
reset() {// Not implemented
|
|
83
|
-
}
|
|
84
|
-
|
|
29
|
+
export class TESTAuthenticationProvider {
|
|
30
|
+
constructor(name, privateKey, keyId = 'register_key', attributes) {
|
|
31
|
+
this.name = name;
|
|
32
|
+
this.privateKey = privateKey;
|
|
33
|
+
this.keyId = keyId;
|
|
34
|
+
this.attributes = attributes;
|
|
35
|
+
this.testRegistrationIssuer = 'testRegisterIssuer';
|
|
36
|
+
this.testRegistrationAudience = 'testRegisterAudience';
|
|
37
|
+
}
|
|
38
|
+
async getAuthenticationInfo() {
|
|
39
|
+
const jwt = JWT.sign(this.attributes ? this.attributes : {}, this.privateKey, {
|
|
40
|
+
jwtid: v4(),
|
|
41
|
+
audience: this.testRegistrationAudience,
|
|
42
|
+
expiresIn: '60s',
|
|
43
|
+
notBefore: '0m',
|
|
44
|
+
subject: `${this.name}-${v4()}`,
|
|
45
|
+
issuer: this.testRegistrationIssuer,
|
|
46
|
+
header: { alg: 'RS256', kid: this.keyId },
|
|
47
|
+
algorithm: 'RS256',
|
|
48
|
+
});
|
|
49
|
+
return new TESTAuthenticationInfo(jwt);
|
|
50
|
+
}
|
|
51
|
+
reset() {
|
|
52
|
+
// Not implemented
|
|
53
|
+
}
|
|
85
54
|
}
|
|
86
55
|
/**
|
|
87
56
|
* Authentication info consisting of a JWT signed using the locally stored private key.
|
|
88
57
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
encode() {
|
|
106
|
-
return this.jwt;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
getUsername() {
|
|
110
|
-
return this.username;
|
|
111
|
-
}
|
|
112
|
-
|
|
58
|
+
export class LocalAuthenticationInfo {
|
|
59
|
+
constructor(jwt, username) {
|
|
60
|
+
this.jwt = jwt;
|
|
61
|
+
this.username = username;
|
|
62
|
+
this.type = 'FSSO';
|
|
63
|
+
}
|
|
64
|
+
isValid() {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
encode() {
|
|
68
|
+
return this.jwt;
|
|
69
|
+
}
|
|
70
|
+
getUsername() {
|
|
71
|
+
return this.username;
|
|
72
|
+
}
|
|
113
73
|
}
|
|
114
74
|
/**
|
|
115
75
|
* Authentication info consisting of a JWT signed using the locally stored private key.
|
|
@@ -120,39 +80,29 @@ class LocalAuthenticationInfo {
|
|
|
120
80
|
* @param username username to be associated with the issued authentication info.
|
|
121
81
|
* @param attributes additional attributes to be added to the issued authentication info.
|
|
122
82
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
},
|
|
148
|
-
algorithm: 'RS256'
|
|
149
|
-
});
|
|
150
|
-
return new LocalAuthenticationInfo(jwt, this.username);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
reset() {// Not implemented
|
|
154
|
-
}
|
|
155
|
-
|
|
83
|
+
export class LocalAuthenticationProvider {
|
|
84
|
+
constructor(name, privateKey, keyId, username, attributes) {
|
|
85
|
+
this.name = name;
|
|
86
|
+
this.privateKey = privateKey;
|
|
87
|
+
this.keyId = keyId;
|
|
88
|
+
this.username = username;
|
|
89
|
+
this.attributes = attributes;
|
|
90
|
+
}
|
|
91
|
+
async getAuthenticationInfo() {
|
|
92
|
+
const jwt = JWT.sign(this.attributes ? this.attributes : {}, this.privateKey, {
|
|
93
|
+
jwtid: v4(),
|
|
94
|
+
audience: 'identity-service',
|
|
95
|
+
expiresIn: '60s',
|
|
96
|
+
notBefore: '0m',
|
|
97
|
+
subject: this.username,
|
|
98
|
+
issuer: this.name,
|
|
99
|
+
header: { alg: 'RS256', kid: this.keyId },
|
|
100
|
+
algorithm: 'RS256',
|
|
101
|
+
});
|
|
102
|
+
return new LocalAuthenticationInfo(jwt, this.username);
|
|
103
|
+
}
|
|
104
|
+
reset() {
|
|
105
|
+
// Not implemented
|
|
106
|
+
}
|
|
156
107
|
}
|
|
157
|
-
|
|
158
|
-
exports.LocalAuthenticationProvider = LocalAuthenticationProvider;
|
|
108
|
+
//# sourceMappingURL=auth-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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C,KAAK,EAAE;YACzC,SAAS,EAAE,OAAO;SACnB,CACF,CAAA;QACD,OAAO,IAAI,uBAAuB,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;IACxD,CAAC;IAED,KAAK;QACH,kBAAkB;IACpB,CAAC;CACF"}
|
package/lib/user/auth.js
CHANGED
|
@@ -1,183 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
-
|
|
26
|
-
const DefaultRefreshTokenLifetime = 60;
|
|
27
|
-
exports.DefaultRefreshTokenLifetime = DefaultRefreshTokenLifetime;
|
|
28
|
-
|
|
29
|
-
class CognitoAuthUI {
|
|
30
|
-
constructor(authenticationStore, federatedSignInConfig, keyManager, logger, launchUriFn) {
|
|
31
|
-
this.authenticationStore = authenticationStore;
|
|
32
|
-
this.federatedSignInConfig = federatedSignInConfig;
|
|
33
|
-
this.keyManager = keyManager;
|
|
34
|
-
this.launchUriFn = launchUriFn;
|
|
35
|
-
|
|
36
|
-
_defineProperty(this, "auth", void 0);
|
|
37
|
-
|
|
38
|
-
_defineProperty(this, "tokensRefreshedPromise", void 0);
|
|
39
|
-
|
|
40
|
-
_defineProperty(this, "refreshTokenLifetime", void 0);
|
|
41
|
-
|
|
42
|
-
_defineProperty(this, "logger", void 0);
|
|
43
|
-
|
|
44
|
-
this.authenticationStore.subscribe(this);
|
|
45
|
-
this.auth = this.initCognitoAuthSDK();
|
|
46
|
-
const refreshTokenLifetime = this.federatedSignInConfig.refreshTokenLifetime;
|
|
47
|
-
this.refreshTokenLifetime = refreshTokenLifetime ?? DefaultRefreshTokenLifetime;
|
|
48
|
-
this.logger = logger;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
initCognitoAuthSDK() {
|
|
52
|
-
const cognitoAuthConfig = {
|
|
53
|
-
ClientId: this.federatedSignInConfig.appClientId,
|
|
54
|
-
AppWebDomain: this.federatedSignInConfig.webDomain,
|
|
55
|
-
IdentityProvider: this.federatedSignInConfig.identityProvider,
|
|
56
|
-
RedirectUriSignIn: this.federatedSignInConfig.signInRedirectUri,
|
|
57
|
-
RedirectUriSignOut: this.federatedSignInConfig.signOutRedirectUri,
|
|
58
|
-
TokenScopesArray: ['openid'],
|
|
59
|
-
Storage: this.authenticationStore,
|
|
60
|
-
LaunchUri: this.launchUriFn
|
|
61
|
-
};
|
|
62
|
-
const auth = new _amazonCognitoAuthJs.CognitoAuth(cognitoAuthConfig);
|
|
63
|
-
auth.useCodeGrantFlow();
|
|
64
|
-
auth.userhandler = {
|
|
65
|
-
onSuccess: result => {
|
|
66
|
-
this.logger.info('Successfully signed in.', {
|
|
67
|
-
result
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
onFailure: error => {
|
|
71
|
-
this.logger.error(new _sudoCommon.AuthenticationError(error).message);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
return auth;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
presentFederatedSignInUI() {
|
|
78
|
-
this.auth.getSession();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async processFederatedSignInTokens(url) {
|
|
82
|
-
this.tokensRefreshedPromise = (0, _resolvablePromise.createResolvablePromise)();
|
|
83
|
-
this.auth.parseCognitoWebResponse(url);
|
|
84
|
-
const authDetails = await this.tokensRefreshedPromise;
|
|
85
|
-
await this.storeTokensInKeyManager(authDetails);
|
|
86
|
-
return authDetails.authenticationTokens;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* This function is called when the authentication store notifies subscribers of an item update.
|
|
90
|
-
*
|
|
91
|
-
* @param itemName the name of the item being updated
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
update(itemName) {
|
|
96
|
-
if (itemName === 'idToken') {
|
|
97
|
-
const authTokens = this.getAuthTokens();
|
|
98
|
-
const userId = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.userId);
|
|
99
|
-
|
|
100
|
-
if (authTokens && userId) {
|
|
101
|
-
this.tokensRefreshedPromise?.resolve({
|
|
102
|
-
authenticationTokens: authTokens,
|
|
103
|
-
userId
|
|
104
|
-
});
|
|
105
|
-
}
|
|
1
|
+
import { AuthenticationError } from '@sudoplatform/sudo-common';
|
|
2
|
+
import { CognitoAuth } from 'amazon-cognito-auth-js';
|
|
3
|
+
import { apiKeyNames } from '../core/api-key-names';
|
|
4
|
+
import { createResolvablePromise, } from '../utils/resolvable-promise';
|
|
5
|
+
import * as JWT from 'jsonwebtoken';
|
|
6
|
+
import { userKeyNames } from './user-key-names';
|
|
7
|
+
export const DefaultRefreshTokenLifetime = 60;
|
|
8
|
+
export class CognitoAuthUI {
|
|
9
|
+
constructor(authenticationStore, federatedSignInConfig, keyManager, logger, launchUriFn) {
|
|
10
|
+
this.authenticationStore = authenticationStore;
|
|
11
|
+
this.federatedSignInConfig = federatedSignInConfig;
|
|
12
|
+
this.keyManager = keyManager;
|
|
13
|
+
this.launchUriFn = launchUriFn;
|
|
14
|
+
this.authenticationStore.subscribe(this);
|
|
15
|
+
this.auth = this.initCognitoAuthSDK();
|
|
16
|
+
const refreshTokenLifetime = this.federatedSignInConfig.refreshTokenLifetime;
|
|
17
|
+
this.refreshTokenLifetime =
|
|
18
|
+
refreshTokenLifetime ?? DefaultRefreshTokenLifetime;
|
|
19
|
+
this.logger = logger;
|
|
106
20
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
getAuthTokens() {
|
|
132
|
-
const idToken = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.idToken);
|
|
133
|
-
const accessToken = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.accessToken);
|
|
134
|
-
const refreshToken = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.refreshToken);
|
|
135
|
-
const tokenExpiry = this.getTokenExpiry();
|
|
136
|
-
|
|
137
|
-
if (idToken && accessToken && refreshToken && tokenExpiry) {
|
|
138
|
-
return {
|
|
139
|
-
idToken: idToken,
|
|
140
|
-
accessToken: accessToken,
|
|
141
|
-
refreshToken: refreshToken,
|
|
142
|
-
tokenExpiry: tokenExpiry.getTime()
|
|
143
|
-
};
|
|
144
|
-
} else {
|
|
145
|
-
return undefined;
|
|
21
|
+
initCognitoAuthSDK() {
|
|
22
|
+
const cognitoAuthConfig = {
|
|
23
|
+
ClientId: this.federatedSignInConfig.appClientId,
|
|
24
|
+
AppWebDomain: this.federatedSignInConfig.webDomain,
|
|
25
|
+
IdentityProvider: this.federatedSignInConfig.identityProvider,
|
|
26
|
+
RedirectUriSignIn: this.federatedSignInConfig.signInRedirectUri,
|
|
27
|
+
RedirectUriSignOut: this.federatedSignInConfig.signOutRedirectUri,
|
|
28
|
+
TokenScopesArray: ['openid'],
|
|
29
|
+
Storage: this.authenticationStore,
|
|
30
|
+
LaunchUri: this.launchUriFn,
|
|
31
|
+
};
|
|
32
|
+
const auth = new CognitoAuth(cognitoAuthConfig);
|
|
33
|
+
auth.useCodeGrantFlow();
|
|
34
|
+
auth.userhandler = {
|
|
35
|
+
onSuccess: (result) => {
|
|
36
|
+
this.logger.info('Successfully signed in.', { result });
|
|
37
|
+
},
|
|
38
|
+
onFailure: (error) => {
|
|
39
|
+
this.logger.error(new AuthenticationError(error).message);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
return auth;
|
|
146
43
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
44
|
+
presentFederatedSignInUI() {
|
|
45
|
+
this.auth.getSession();
|
|
46
|
+
}
|
|
47
|
+
async processFederatedSignInTokens(url) {
|
|
48
|
+
this.tokensRefreshedPromise =
|
|
49
|
+
createResolvablePromise();
|
|
50
|
+
this.auth.parseCognitoWebResponse(url);
|
|
51
|
+
const authDetails = await this.tokensRefreshedPromise;
|
|
52
|
+
await this.storeTokensInKeyManager(authDetails);
|
|
53
|
+
return authDetails.authenticationTokens;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* This function is called when the authentication store notifies subscribers of an item update.
|
|
57
|
+
*
|
|
58
|
+
* @param itemName the name of the item being updated
|
|
59
|
+
*/
|
|
60
|
+
update(itemName) {
|
|
61
|
+
if (itemName === 'idToken') {
|
|
62
|
+
const authTokens = this.getAuthTokens();
|
|
63
|
+
const userId = this.authenticationStore.getItem(apiKeyNames.userId);
|
|
64
|
+
if (authTokens && userId) {
|
|
65
|
+
this.tokensRefreshedPromise?.resolve({
|
|
66
|
+
authenticationTokens: authTokens,
|
|
67
|
+
userId,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
this.logger.debug('Updated: ', { itemName });
|
|
72
|
+
}
|
|
73
|
+
reset() {
|
|
74
|
+
const cognitoAuthAny = this.auth;
|
|
75
|
+
cognitoAuthAny.clearCachedTokensScopes();
|
|
76
|
+
cognitoAuthAny.signInUserSession = null;
|
|
77
|
+
cognitoAuthAny.signInUserSession = cognitoAuthAny.getCachedSession();
|
|
78
|
+
}
|
|
79
|
+
presentSignOutUI() {
|
|
80
|
+
const signOutUrl = this.auth.getFQDNSignOut();
|
|
81
|
+
this.auth.launchUri(signOutUrl);
|
|
82
|
+
}
|
|
83
|
+
async storeRefreshTokenLifetime(refreshTokenLifetime) {
|
|
84
|
+
const tokenLifetime = refreshTokenLifetime * 24 * 60 * 60 * 1000 + new Date().getTime();
|
|
85
|
+
await this.keyManager.removeItem(apiKeyNames.refreshTokenExpiry);
|
|
86
|
+
await this.keyManager.addString(apiKeyNames.refreshTokenExpiry, tokenLifetime.toString());
|
|
87
|
+
}
|
|
88
|
+
getAuthTokens() {
|
|
89
|
+
const idToken = this.authenticationStore.getItem(apiKeyNames.idToken);
|
|
90
|
+
const accessToken = this.authenticationStore.getItem(apiKeyNames.accessToken);
|
|
91
|
+
const refreshToken = this.authenticationStore.getItem(apiKeyNames.refreshToken);
|
|
92
|
+
const tokenExpiry = this.getTokenExpiry();
|
|
93
|
+
if (idToken && accessToken && refreshToken && tokenExpiry) {
|
|
94
|
+
return {
|
|
95
|
+
idToken: idToken,
|
|
96
|
+
accessToken: accessToken,
|
|
97
|
+
refreshToken: refreshToken,
|
|
98
|
+
tokenExpiry: tokenExpiry.getTime(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
getTokenExpiry() {
|
|
106
|
+
const expiry = this.authenticationStore.getItem(apiKeyNames.tokenExpiry);
|
|
107
|
+
return expiry ? new Date(Number(expiry) * 1000) : undefined;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Store the authentication tokens and user id of the signed in user in the key manager.
|
|
111
|
+
*/
|
|
112
|
+
async storeTokensInKeyManager(authDetails) {
|
|
113
|
+
await this.keyManager.removeItem(userKeyNames.userId);
|
|
114
|
+
await this.keyManager.removeItem(apiKeyNames.idToken);
|
|
115
|
+
await this.keyManager.removeItem(apiKeyNames.accessToken);
|
|
116
|
+
await this.keyManager.removeItem(apiKeyNames.refreshToken);
|
|
117
|
+
await this.keyManager.removeItem(apiKeyNames.tokenExpiry);
|
|
118
|
+
const authTokens = authDetails.authenticationTokens;
|
|
119
|
+
await this.keyManager.addString(userKeyNames.userId, authDetails.userId);
|
|
120
|
+
await this.keyManager.addString(apiKeyNames.idToken, authTokens.idToken);
|
|
121
|
+
await this.keyManager.addString(apiKeyNames.accessToken, authTokens.accessToken);
|
|
122
|
+
await this.keyManager.addString(apiKeyNames.refreshToken, authTokens.refreshToken);
|
|
123
|
+
const decoded = JWT.decode(authTokens.idToken, { complete: true });
|
|
124
|
+
if (decoded) {
|
|
125
|
+
const tokenExpiry = decoded.payload['exp'];
|
|
126
|
+
await this.keyManager.addString(apiKeyNames.tokenExpiry, tokenExpiry);
|
|
127
|
+
}
|
|
128
|
+
await this.storeRefreshTokenLifetime(this.refreshTokenLifetime);
|
|
176
129
|
}
|
|
177
|
-
|
|
178
|
-
await this.storeRefreshTokenLifetime(this.refreshTokenLifetime);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
130
|
}
|
|
182
|
-
|
|
183
|
-
exports.CognitoAuthUI = CognitoAuthUI;
|
|
131
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/user/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAU,MAAM,2BAA2B,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAKnD,OAAO,EACL,uBAAuB,GAExB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAgC/C,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAA;AAE7C,MAAM,OAAO,aAAa;IAMxB,YACU,mBAAwC,EACxC,qBAA4C,EAC5C,UAAsB,EAC9B,MAAc,EACN,WAAmC;QAJnC,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,eAAU,GAAV,UAAU,CAAY;QAEtB,gBAAW,GAAX,WAAW,CAAwB;QAE3C,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAA;QAErC,MAAM,oBAAoB,GAAG,IAAI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
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.IdentityServiceConfigNotFoundError = exports.AlreadyRegisteredError = void 0;
|
|
7
|
-
|
|
8
1
|
class UserError extends Error {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
constructor(msg) {
|
|
3
|
+
super(msg);
|
|
4
|
+
this.name = this.constructor.name;
|
|
5
|
+
if (Error.captureStackTrace) {
|
|
6
|
+
Error.captureStackTrace(this, this.constructor);
|
|
7
|
+
}
|
|
15
8
|
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
9
|
}
|
|
19
10
|
/**
|
|
20
11
|
* Indicates the user associated with the client is already registered.
|
|
21
12
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
super('User is already registered.');
|
|
27
|
-
}
|
|
28
|
-
|
|
13
|
+
export class AlreadyRegisteredError extends UserError {
|
|
14
|
+
constructor() {
|
|
15
|
+
super('User is already registered.');
|
|
16
|
+
}
|
|
29
17
|
}
|
|
30
18
|
/**
|
|
31
19
|
* Indicates the configuration related to Identity Service is not found. This may indicate that Identity Service
|
|
32
20
|
* is not deployed into your runtime instance or the config file that
|
|
33
21
|
* you are using is invalid.
|
|
34
22
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class IdentityServiceConfigNotFoundError extends UserError {
|
|
40
|
-
constructor() {
|
|
41
|
-
super('Identity service configuration not found.');
|
|
42
|
-
}
|
|
43
|
-
|
|
23
|
+
export class IdentityServiceConfigNotFoundError extends UserError {
|
|
24
|
+
constructor() {
|
|
25
|
+
super('Identity service configuration not found.');
|
|
26
|
+
}
|
|
44
27
|
}
|
|
45
|
-
|
|
46
|
-
exports.IdentityServiceConfigNotFoundError = IdentityServiceConfigNotFoundError;
|
|
28
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/user/error.ts"],"names":[],"mappings":"AAAA,MAAM,SAAU,SAAQ,KAAK;IAC3B,YAAY,GAAY;QACtB,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,IAAI,KAAK,CAAC,iBAAiB,EAAE;YAC3B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;SAChD;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAAS;IACnD;QACE,KAAK,CAAC,6BAA6B,CAAC,CAAA;IACtC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,kCAAmC,SAAQ,SAAS;IAC/D;QACE,KAAK,CAAC,2CAA2C,CAAC,CAAA;IACpD,CAAC;CACF"}
|