@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.
Files changed (50) hide show
  1. package/docs/.nojekyll +1 -0
  2. package/docs/assets/highlight.css +22 -0
  3. package/docs/assets/icons.css +1043 -0
  4. package/docs/assets/{images/icons.png → icons.png} +0 -0
  5. package/docs/assets/{images/icons@2x.png → icons@2x.png} +0 -0
  6. package/docs/assets/main.js +52 -0
  7. package/docs/assets/search.js +1 -0
  8. package/docs/assets/style.css +1388 -0
  9. package/docs/assets/{images/widgets.png → widgets.png} +0 -0
  10. package/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
  11. package/docs/classes/AlreadyRegisteredError.html +8 -0
  12. package/docs/classes/DefaultSudoUserClient.html +68 -0
  13. package/docs/classes/IdentityServiceConfigNotFoundError.html +10 -0
  14. package/docs/classes/LocalAuthenticationProvider.html +12 -0
  15. package/docs/classes/TESTAuthenticationProvider.html +11 -0
  16. package/docs/index.html +44 -159
  17. package/docs/interfaces/AuthenticationProvider.html +6 -0
  18. package/docs/interfaces/AuthenticationTokens.html +7 -0
  19. package/docs/interfaces/SudoUserClient.html +90 -0
  20. package/docs/modules.html +1 -143
  21. package/lib/client/apiClient.js +9 -6
  22. package/lib/core/auth-store.js +5 -1
  23. package/lib/core/key-manager.js +2 -1
  24. package/lib/core/sdk-config.d.ts +17 -3
  25. package/lib/core/sdk-config.js +23 -8
  26. package/lib/gen/graphql-types.d.ts +9 -9
  27. package/lib/index.d.ts +1 -1
  28. package/lib/index.js +20 -15
  29. package/lib/sdk.d.ts +1 -0
  30. package/lib/sdk.js +18 -0
  31. package/lib/user/auth-provider.js +1 -1
  32. package/lib/user/auth.d.ts +1 -0
  33. package/lib/user/auth.js +6 -3
  34. package/lib/user/error.d.ts +13 -1
  35. package/lib/user/error.js +31 -4
  36. package/lib/user/identity-provider.js +6 -4
  37. package/lib/user/user-client.js +19 -16
  38. package/package.json +49 -46
  39. package/docs/assets/css/main.css +0 -2660
  40. package/docs/assets/js/main.js +0 -248
  41. package/docs/assets/js/search.js +0 -1
  42. package/docs/classes/alreadyregisterederror.html +0 -346
  43. package/docs/classes/defaultsudouserclient.html +0 -1045
  44. package/docs/classes/localauthenticationprovider.html +0 -287
  45. package/docs/classes/testauthenticationprovider.html +0 -317
  46. package/docs/interfaces/authenticationprovider.html +0 -216
  47. package/docs/interfaces/authenticationtokens.html +0 -233
  48. package/docs/interfaces/sudouserclient.html +0 -855
  49. package/lib/core/protected-store.d.ts +0 -5
  50. package/lib/runtimes/browser/browser-crypto.d.ts +0 -2
@@ -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 _options$logger, _options$config, _options$authenticati, _options$identityProv, _this$config, _options$apiClient;
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 = (_options$logger = options === null || options === void 0 ? void 0 : options.logger) !== null && _options$logger !== void 0 ? _options$logger : new _sudoCommon.DefaultLogger('SudoUser', 'warn');
63
- this.config = (_options$config = options === null || options === void 0 ? void 0 : options.config) !== null && _options$config !== void 0 ? _options$config : _sudoCommon.DefaultConfigurationManager.getInstance().bindConfigSet(_sdkConfig.Config, undefined);
64
- this.authenticationStore = (_options$authenticati = options === null || options === void 0 ? void 0 : options.authenticationStore) !== null && _options$authenticati !== void 0 ? _options$authenticati : new _authStore.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 = (_options$identityProv = options === null || options === void 0 ? void 0 : options.identityProvider) !== null && _options$identityProv !== void 0 ? _options$identityProv : new _identityProvider.CognitoUserPoolIdentityProvider(this.keyManager, this.config, this.logger);
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
- var _options$authUI;
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 = (_options$apiClient = options === null || options === void 0 ? void 0 : options.apiClient) !== null && _options$apiClient !== void 0 ? _options$apiClient : new _apiClient.ApiClient(this.config.identityService.region, this.config.identityService.apiUrl, this, this.logger);
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 (error) {
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 (error) {
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 (error) {
205
- throw new _sudoCommon.AuthenticationError(error);
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', error.message); // return an empty id token
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": "9.0.2",
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": "/bin/bash -c 'jest test/unit'",
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 --emitDeclarationOnly",
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.29.0",
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": "^1.0.2",
37
+ "@sudoplatform/sudo-web-crypto-provider": "^3.0.0",
38
38
  "amazon-cognito-auth-js": "^1.3.3",
39
- "apollo-cache-inmemory": "1.3.12",
39
+ "apollo-cache-inmemory": "^1.6.6",
40
40
  "asn1js": "^2.1.1",
41
41
  "aws-appsync": "4.0.3",
42
- "graphql": "^15.5.1",
43
- "jsonwebtoken": "^8.5.0",
44
- "lodash": "^4.17.20",
45
- "node-localstorage": "^2.2.1",
46
- "tslib": "^2.3.0",
47
- "uuid": "^8.3.1"
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.14.5",
51
- "@babel/core": "^7.14.6",
52
- "@babel/plugin-proposal-class-properties": "^7.14.5",
53
- "@babel/plugin-proposal-private-methods": "^7.14.5",
54
- "@babel/preset-env": "^7.14.7",
55
- "@babel/preset-typescript": "^7.14.5",
56
- "@graphql-codegen/add": "^2.0.2",
57
- "@graphql-codegen/cli": "^2.1.1",
58
- "@graphql-codegen/typed-document-node": "^1.18.8",
59
- "@graphql-codegen/typescript": "^1.22.3",
60
- "@graphql-codegen/typescript-operations": "^1.18.2",
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": "^5.0.2",
63
- "@types/amazon-cognito-auth-js": "^1.2.2",
64
- "@types/graphql": "^14.5.0",
65
- "@types/jest": "^26.0.23",
66
- "@types/jsonwebtoken": "^8.5.2",
67
- "@types/lodash": "^4.14.170",
68
- "@types/node": "^14.17.3",
69
- "@types/node-localstorage": "^1.3.0",
70
- "@types/uuid": "^8.3.0",
71
- "@typescript-eslint/eslint-plugin": "^4.28.0",
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": "^7.29.0",
81
+ "eslint": "^8.0.1",
75
82
  "eslint-config-prettier": "^8.3.0",
76
- "eslint-plugin-import": "^2.23.4",
77
- "eslint-plugin-prettier": "^3.4.0",
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.0.5",
83
- "monocle-ts": "^2.3.10",
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.21.2",
90
- "typescript": "^4.3.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": "^5.0.1",
97
+ "@sudoplatform/sudo-common": "^6.0.0",
95
98
  "io-ts": "^2.2.11"
96
99
  }
97
100
  }