@sudoplatform/sudo-user 9.0.2 → 10.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/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/icons.css +1043 -0
- package/docs/assets/{images/icons.png → icons.png} +0 -0
- package/docs/assets/{images/icons@2x.png → icons@2x.png} +0 -0
- package/docs/assets/main.js +52 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1388 -0
- package/docs/assets/{images/widgets.png → widgets.png} +0 -0
- package/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
- package/docs/classes/AlreadyRegisteredError.html +8 -0
- package/docs/classes/DefaultSudoUserClient.html +68 -0
- package/docs/classes/IdentityServiceConfigNotFoundError.html +10 -0
- package/docs/classes/LocalAuthenticationProvider.html +12 -0
- package/docs/classes/TESTAuthenticationProvider.html +11 -0
- package/docs/index.html +44 -159
- package/docs/interfaces/AuthenticationProvider.html +6 -0
- package/docs/interfaces/AuthenticationTokens.html +7 -0
- package/docs/interfaces/SudoUserClient.html +90 -0
- package/docs/modules.html +1 -143
- package/lib/client/apiClient.js +9 -6
- package/lib/core/auth-store.js +5 -1
- package/lib/core/key-manager.js +2 -1
- package/lib/core/sdk-config.d.ts +17 -3
- package/lib/core/sdk-config.js +23 -8
- package/lib/gen/graphql-types.d.ts +9 -9
- package/lib/index.d.ts +1 -1
- package/lib/index.js +20 -15
- package/lib/sdk.d.ts +1 -0
- package/lib/sdk.js +18 -0
- package/lib/user/auth-provider.js +1 -1
- package/lib/user/auth.d.ts +1 -0
- package/lib/user/auth.js +6 -3
- package/lib/user/error.d.ts +13 -1
- package/lib/user/error.js +31 -4
- package/lib/user/identity-provider.js +6 -4
- package/lib/user/user-client.js +19 -16
- package/package.json +49 -46
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/classes/alreadyregisterederror.html +0 -346
- package/docs/classes/defaultsudouserclient.html +0 -1045
- package/docs/classes/localauthenticationprovider.html +0 -287
- package/docs/classes/testauthenticationprovider.html +0 -317
- package/docs/interfaces/authenticationprovider.html +0 -216
- package/docs/interfaces/authenticationtokens.html +0 -233
- package/docs/interfaces/sudouserclient.html +0 -855
- package/lib/core/protected-store.d.ts +0 -5
- package/lib/runtimes/browser/browser-crypto.d.ts +0 -2
package/lib/user/user-client.js
CHANGED
|
@@ -39,7 +39,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
39
39
|
|
|
40
40
|
class DefaultSudoUserClient {
|
|
41
41
|
constructor(options) {
|
|
42
|
-
var
|
|
42
|
+
var _this$config;
|
|
43
43
|
|
|
44
44
|
_defineProperty(this, "config", void 0);
|
|
45
45
|
|
|
@@ -59,9 +59,9 @@ class DefaultSudoUserClient {
|
|
|
59
59
|
|
|
60
60
|
_defineProperty(this, "launchUriFn", void 0);
|
|
61
61
|
|
|
62
|
-
this.logger = (
|
|
63
|
-
this.config = (
|
|
64
|
-
this.authenticationStore = (
|
|
62
|
+
this.logger = (options === null || options === void 0 ? void 0 : options.logger) ?? new _sudoCommon.DefaultLogger('SudoUser', 'warn');
|
|
63
|
+
this.config = (options === null || options === void 0 ? void 0 : options.config) ?? (0, _sdkConfig.getIdentityServiceConfig)();
|
|
64
|
+
this.authenticationStore = (options === null || options === void 0 ? void 0 : options.authenticationStore) ?? new _authStore.AuthenticationStore();
|
|
65
65
|
|
|
66
66
|
if (options !== null && options !== void 0 && options.sudoKeyManager) {
|
|
67
67
|
this.sudoUserKeyManager = options === null || options === void 0 ? void 0 : options.sudoKeyManager;
|
|
@@ -72,16 +72,14 @@ class DefaultSudoUserClient {
|
|
|
72
72
|
|
|
73
73
|
this.keyManager = new _keyManager.KeyManager(this.sudoUserKeyManager);
|
|
74
74
|
this.launchUriFn = options === null || options === void 0 ? void 0 : options.launchUriFn;
|
|
75
|
-
this.identityProvider = (
|
|
75
|
+
this.identityProvider = (options === null || options === void 0 ? void 0 : options.identityProvider) ?? new _identityProvider.CognitoUserPoolIdentityProvider(this.keyManager, this.config, this.logger);
|
|
76
76
|
const federatedSignInConfig = (_this$config = this.config) === null || _this$config === void 0 ? void 0 : _this$config.federatedSignIn;
|
|
77
77
|
|
|
78
78
|
if (federatedSignInConfig) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.authUI = (_options$authUI = options === null || options === void 0 ? void 0 : options.authUI) !== null && _options$authUI !== void 0 ? _options$authUI : new _auth.CognitoAuthUI(this.authenticationStore, federatedSignInConfig, this.keyManager, this.logger, this.launchUriFn);
|
|
79
|
+
this.authUI = (options === null || options === void 0 ? void 0 : options.authUI) ?? new _auth.CognitoAuthUI(this.authenticationStore, federatedSignInConfig, this.keyManager, this.logger, this.launchUriFn);
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
this.apiClient = (
|
|
82
|
+
this.apiClient = (options === null || options === void 0 ? void 0 : options.apiClient) ?? new _apiClient.ApiClient(this.config.identityService.region, this.config.identityService.apiUrl, this, this.logger);
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
get sudoKeyManager() {
|
|
@@ -93,11 +91,12 @@ class DefaultSudoUserClient {
|
|
|
93
91
|
var _this$authUI;
|
|
94
92
|
|
|
95
93
|
(_this$authUI = this.authUI) === null || _this$authUI === void 0 ? void 0 : _this$authUI.presentFederatedSignInUI();
|
|
96
|
-
} catch (
|
|
94
|
+
} catch (err) {
|
|
95
|
+
const error = err;
|
|
97
96
|
this.logger.error('Failed to launch the federated sign in UI.', {
|
|
98
97
|
error
|
|
99
98
|
});
|
|
100
|
-
throw new _sudoCommon.AuthenticationError(error);
|
|
99
|
+
throw new _sudoCommon.AuthenticationError(error.message);
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
|
|
@@ -113,11 +112,12 @@ class DefaultSudoUserClient {
|
|
|
113
112
|
} else {
|
|
114
113
|
throw new _sudoCommon.AuthenticationError('Authentication tokens missing.');
|
|
115
114
|
}
|
|
116
|
-
} catch (
|
|
115
|
+
} catch (err) {
|
|
116
|
+
const error = err;
|
|
117
117
|
this.logger.error('Failed to process the federated sign in redirect.', {
|
|
118
118
|
error
|
|
119
119
|
});
|
|
120
|
-
throw new _sudoCommon.AuthenticationError(error);
|
|
120
|
+
throw new _sudoCommon.AuthenticationError(error.message);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -201,8 +201,9 @@ class DefaultSudoUserClient {
|
|
|
201
201
|
} else {
|
|
202
202
|
throw new _sudoCommon.NotRegisteredError('Not registered.');
|
|
203
203
|
}
|
|
204
|
-
} catch (
|
|
205
|
-
|
|
204
|
+
} catch (err) {
|
|
205
|
+
const error = err;
|
|
206
|
+
throw new _sudoCommon.AuthenticationError(error.message);
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
|
|
@@ -220,7 +221,9 @@ class DefaultSudoUserClient {
|
|
|
220
221
|
const authTokens = await this.refreshTokens(refreshToken);
|
|
221
222
|
return authTokens.idToken;
|
|
222
223
|
} catch (error) {
|
|
223
|
-
this.logger.info('getLatestAuthToken: Token refresh failed',
|
|
224
|
+
this.logger.info('getLatestAuthToken: Token refresh failed', {
|
|
225
|
+
error
|
|
226
|
+
}); // return an empty id token
|
|
224
227
|
|
|
225
228
|
return '';
|
|
226
229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudoplatform/sudo-user",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.1",
|
|
4
4
|
"author": "Anonyome Labs, Inc.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"lint:prettier": "prettier -l \"{bin,test,src}/**/*.{js,json,jsx,ts,tsx}\"",
|
|
14
14
|
"codegen": "graphql-codegen -c codegen.yml",
|
|
15
15
|
"verify": "yarn audit && yarn lint",
|
|
16
|
-
"unit-test": "
|
|
16
|
+
"unit-test": "yarn jest test/unit --verbose --coverage",
|
|
17
17
|
"integration-test": "/bin/bash -c 'jest test/integration'",
|
|
18
18
|
"test": "yarn unit-test",
|
|
19
19
|
"build": "yarn codegen && yarn verify && yarn build:transpile && yarn build:declarations && yarn build:docs",
|
|
20
20
|
"build:transpile": "babel src --out-dir lib --extensions '.ts'",
|
|
21
|
-
"build:declarations": "tsc --
|
|
21
|
+
"build:declarations": "tsc --project tsconfig.declarations.json",
|
|
22
22
|
"build:docs": "typedoc --excludePrivate --out docs src/index.ts"
|
|
23
23
|
},
|
|
24
24
|
"main": "lib/index.js",
|
|
@@ -32,66 +32,69 @@
|
|
|
32
32
|
"./lib/runtimes/node/node-crypto.js": "./lib/runtimes/browser/browser-crypto.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@aws-sdk/client-cognito-identity-provider": "^3.
|
|
35
|
+
"@aws-sdk/client-cognito-identity-provider": "^3.37.0",
|
|
36
36
|
"@graphql-typed-document-node/core": "^3.1.0",
|
|
37
|
-
"@sudoplatform/sudo-web-crypto-provider": "^
|
|
37
|
+
"@sudoplatform/sudo-web-crypto-provider": "^3.0.0",
|
|
38
38
|
"amazon-cognito-auth-js": "^1.3.3",
|
|
39
|
-
"apollo-cache-inmemory": "1.
|
|
39
|
+
"apollo-cache-inmemory": "^1.6.6",
|
|
40
40
|
"asn1js": "^2.1.1",
|
|
41
41
|
"aws-appsync": "4.0.3",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
42
|
+
"fp-ts": "^2.11.5",
|
|
43
|
+
"graphql": "^15.6.1",
|
|
44
|
+
"io-ts": "^2.2.16",
|
|
45
|
+
"jsonwebtoken": "^8.5.1",
|
|
46
|
+
"lodash": "^4.17.21",
|
|
47
|
+
"monocle-ts": "^2.3.11",
|
|
48
|
+
"newtype-ts": "^0.3.4",
|
|
49
|
+
"tslib": "^2.3.1",
|
|
50
|
+
"uuid": "^8.3.2"
|
|
51
|
+
},
|
|
52
|
+
"resolutions": {
|
|
53
|
+
"apollo-cache-inmemory": "^1.6.6",
|
|
54
|
+
"@graphql-codegen/**/ansi-regex": "^5.0.1"
|
|
48
55
|
},
|
|
49
56
|
"devDependencies": {
|
|
50
|
-
"@babel/cli": "^7.
|
|
51
|
-
"@babel/core": "^7.
|
|
52
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
53
|
-
"@babel/plugin-proposal-private-methods": "^7.
|
|
54
|
-
"@babel/preset-env": "^7.
|
|
55
|
-
"@babel/preset-typescript": "^7.
|
|
56
|
-
"@graphql-codegen/add": "^
|
|
57
|
-
"@graphql-codegen/cli": "^2.
|
|
58
|
-
"@graphql-codegen/
|
|
59
|
-
"@graphql-codegen/
|
|
60
|
-
"@graphql-codegen/typescript
|
|
57
|
+
"@babel/cli": "^7.16.0",
|
|
58
|
+
"@babel/core": "^7.16.0",
|
|
59
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
60
|
+
"@babel/plugin-proposal-private-methods": "^7.16.0",
|
|
61
|
+
"@babel/preset-env": "^7.16.0",
|
|
62
|
+
"@babel/preset-typescript": "^7.16.0",
|
|
63
|
+
"@graphql-codegen/add": "^3.1.0",
|
|
64
|
+
"@graphql-codegen/cli": "^2.2.1",
|
|
65
|
+
"@graphql-codegen/plugin-helpers": "^2.2.0",
|
|
66
|
+
"@graphql-codegen/typed-document-node": "^2.1.6",
|
|
67
|
+
"@graphql-codegen/typescript": "^2.2.4",
|
|
68
|
+
"@graphql-codegen/typescript-operations": "^2.1.8",
|
|
61
69
|
"@graphql-typed-document-node/apollo-client-2": "^1.0.0",
|
|
62
|
-
"@sudoplatform/sudo-common": "^
|
|
63
|
-
"@types/amazon-cognito-auth-js": "^1.
|
|
64
|
-
"@types/
|
|
65
|
-
"@types/jest": "^
|
|
66
|
-
"@types/jsonwebtoken": "^8.5.
|
|
67
|
-
"@types/lodash": "^4.14.
|
|
68
|
-
"@types/node": "^14.17.
|
|
69
|
-
"@types/
|
|
70
|
-
"@
|
|
71
|
-
"@typescript-eslint/
|
|
72
|
-
"@typescript-eslint/parser": "^4.28.0",
|
|
70
|
+
"@sudoplatform/sudo-common": "^6.0.0",
|
|
71
|
+
"@types/amazon-cognito-auth-js": "^1.3.0",
|
|
72
|
+
"@types/firefox-webext-browser": "^82.0.1",
|
|
73
|
+
"@types/jest": "^27.0.2",
|
|
74
|
+
"@types/jsonwebtoken": "^8.5.6",
|
|
75
|
+
"@types/lodash": "^4.14.177",
|
|
76
|
+
"@types/node": "^14.17.27",
|
|
77
|
+
"@types/uuid": "^8.3.1",
|
|
78
|
+
"@typescript-eslint/eslint-plugin": "^5.1.0",
|
|
79
|
+
"@typescript-eslint/parser": "^5.1.0",
|
|
73
80
|
"apollo-client": "^2.6.10",
|
|
74
|
-
"eslint": "^
|
|
81
|
+
"eslint": "^8.0.1",
|
|
75
82
|
"eslint-config-prettier": "^8.3.0",
|
|
76
|
-
"eslint-plugin-import": "^2.
|
|
77
|
-
"eslint-plugin-prettier": "^
|
|
78
|
-
"fp-ts": "^2.10.5",
|
|
79
|
-
"io-ts": "^2.2.11",
|
|
83
|
+
"eslint-plugin-import": "^2.25.2",
|
|
84
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
80
85
|
"isomorphic-fetch": "^3.0.0",
|
|
81
86
|
"isomorphic-webcrypto": "^2.3.8",
|
|
82
|
-
"jest": "27.
|
|
83
|
-
"
|
|
84
|
-
"newtype-ts": "^0.3.2",
|
|
85
|
-
"prettier": "^2.3.1",
|
|
87
|
+
"jest": "27.3.1",
|
|
88
|
+
"prettier": "^2.4.1",
|
|
86
89
|
"react": "16.13.1",
|
|
87
90
|
"subscriptions-transport-ws": "^0.9.19",
|
|
88
91
|
"ts-mockito": "^2.6.1",
|
|
89
|
-
"typedoc": "0.
|
|
90
|
-
"typescript": "^4.
|
|
92
|
+
"typedoc": "^0.22.9",
|
|
93
|
+
"typescript": "^4.4.4",
|
|
91
94
|
"websocket": "^1.0.34"
|
|
92
95
|
},
|
|
93
96
|
"peerDependencies": {
|
|
94
|
-
"@sudoplatform/sudo-common": "^
|
|
97
|
+
"@sudoplatform/sudo-common": "^6.0.0",
|
|
95
98
|
"io-ts": "^2.2.11"
|
|
96
99
|
}
|
|
97
100
|
}
|