@sudoplatform/sudo-user 10.1.0 → 12.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/{lib → cjs/src}/client/apiClient.d.ts +0 -0
- package/cjs/src/client/apiClient.js +149 -0
- package/cjs/src/client/apiClient.js.map +1 -0
- package/{lib → cjs/src}/core/api-key-names.d.ts +0 -0
- package/cjs/src/core/api-key-names.js +12 -0
- package/cjs/src/core/api-key-names.js.map +1 -0
- package/{lib → cjs/src}/core/auth-store.d.ts +0 -0
- package/cjs/src/core/auth-store.js +92 -0
- package/cjs/src/core/auth-store.js.map +1 -0
- package/{lib → cjs/src}/core/crypto.d.ts +0 -0
- package/cjs/src/core/crypto.js +3 -0
- package/cjs/src/core/crypto.js.map +1 -0
- package/{lib → cjs/src}/core/key-manager.d.ts +0 -0
- package/cjs/src/core/key-manager.js +113 -0
- package/cjs/src/core/key-manager.js.map +1 -0
- package/cjs/src/core/protected-store.d.ts +5 -0
- package/cjs/src/core/protected-store.js +3 -0
- package/cjs/src/core/protected-store.js.map +1 -0
- package/{lib → cjs/src}/core/publisher.d.ts +0 -0
- package/cjs/src/core/publisher.js +3 -0
- package/cjs/src/core/publisher.js.map +1 -0
- package/{lib → cjs/src}/core/sdk-config.d.ts +0 -0
- package/cjs/src/core/sdk-config.js +61 -0
- package/cjs/src/core/sdk-config.js.map +1 -0
- package/{lib → cjs/src}/core/subscriber.d.ts +0 -0
- package/cjs/src/core/subscriber.js +3 -0
- package/cjs/src/core/subscriber.js.map +1 -0
- package/{lib → cjs/src}/gen/graphql-types.d.ts +5 -4
- package/cjs/src/gen/graphql-types.js +105 -0
- package/cjs/src/gen/graphql-types.js.map +1 -0
- package/{lib → cjs/src}/index.d.ts +0 -0
- package/cjs/src/index.js +13 -0
- package/cjs/src/index.js.map +1 -0
- package/{lib/runtimes/node/node-crypto.d.ts → cjs/src/runtimes/browser/browser-crypto.d.ts} +0 -0
- package/cjs/src/runtimes/browser/browser-crypto.js +10 -0
- package/cjs/src/runtimes/browser/browser-crypto.js.map +1 -0
- package/cjs/src/runtimes/node/node-crypto.d.ts +2 -0
- package/cjs/src/runtimes/node/node-crypto.js +9 -0
- package/cjs/src/runtimes/node/node-crypto.js.map +1 -0
- package/{lib → cjs/src}/sdk.d.ts +0 -0
- package/cjs/src/sdk.js +9 -0
- package/cjs/src/sdk.js.map +1 -0
- package/{lib → cjs/src}/user/auth-provider.d.ts +0 -0
- package/cjs/src/user/auth-provider.js +116 -0
- package/cjs/src/user/auth-provider.js.map +1 -0
- package/{lib → cjs/src}/user/auth.d.ts +0 -0
- package/cjs/src/user/auth.js +136 -0
- package/cjs/src/user/auth.js.map +1 -0
- package/{lib → cjs/src}/user/error.d.ts +0 -0
- package/{lib → cjs/src}/user/error.js +16 -29
- package/cjs/src/user/error.js.map +1 -0
- package/{lib → cjs/src}/user/identity-provider.d.ts +0 -0
- package/cjs/src/user/identity-provider.js +245 -0
- package/cjs/src/user/identity-provider.js.map +1 -0
- package/{lib → cjs/src}/user/user-client-interface.d.ts +0 -0
- package/cjs/src/user/user-client-interface.js +3 -0
- package/cjs/src/user/user-client-interface.js.map +1 -0
- package/{lib → cjs/src}/user/user-client.d.ts +0 -0
- package/cjs/src/user/user-client.js +440 -0
- package/cjs/src/user/user-client.js.map +1 -0
- package/{lib → cjs/src}/user/user-key-names.d.ts +0 -0
- package/cjs/src/user/user-key-names.js +10 -0
- package/cjs/src/user/user-key-names.js.map +1 -0
- package/{lib → cjs/src}/utils/resolvable-promise.d.ts +0 -0
- package/cjs/src/utils/resolvable-promise.js +20 -0
- package/cjs/src/utils/resolvable-promise.js.map +1 -0
- package/cjs/test/integration/user-client-int.spec.d.ts +1 -0
- package/cjs/test/integration/user-client-int.spec.js +206 -0
- package/cjs/test/integration/user-client-int.spec.js.map +1 -0
- package/cjs/test/unit/core/sdk-config.spec.d.ts +1 -0
- package/cjs/test/unit/core/sdk-config.spec.js +51 -0
- package/cjs/test/unit/core/sdk-config.spec.js.map +1 -0
- package/cjs/test/unit/key-manager.spec.d.ts +1 -0
- package/cjs/test/unit/key-manager.spec.js +23 -0
- package/cjs/test/unit/key-manager.spec.js.map +1 -0
- package/cjs/test/unit/user-client.spec.d.ts +1 -0
- package/cjs/test/unit/user-client.spec.js +323 -0
- package/cjs/test/unit/user-client.spec.js.map +1 -0
- package/docs/assets/highlight.css +3 -3
- package/docs/assets/main.js +4 -2
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +427 -617
- package/docs/classes/AlreadyRegisteredError.html +163 -8
- package/docs/classes/DefaultSudoUserClient.html +568 -57
- package/docs/classes/IdentityServiceConfigNotFoundError.html +163 -8
- package/docs/classes/LocalAuthenticationProvider.html +131 -12
- package/docs/classes/TESTAuthenticationProvider.html +146 -11
- package/docs/index.html +47 -2
- package/docs/interfaces/AuthenticationProvider.html +89 -6
- package/docs/interfaces/AuthenticationTokens.html +97 -7
- package/docs/interfaces/SudoUserClient.html +431 -80
- package/docs/modules.html +62 -1
- package/lib/src/client/apiClient.d.ts +25 -0
- package/lib/src/client/apiClient.js +145 -0
- package/lib/src/client/apiClient.js.map +1 -0
- package/lib/src/core/api-key-names.d.ts +8 -0
- package/lib/src/core/api-key-names.js +9 -0
- package/lib/src/core/api-key-names.js.map +1 -0
- package/lib/src/core/auth-store.d.ts +51 -0
- package/lib/src/core/auth-store.js +88 -0
- package/lib/src/core/auth-store.js.map +1 -0
- package/lib/src/core/crypto.d.ts +3 -0
- package/lib/src/core/crypto.js +2 -0
- package/lib/src/core/crypto.js.map +1 -0
- package/lib/src/core/key-manager.d.ts +31 -0
- package/lib/src/core/key-manager.js +108 -0
- package/lib/src/core/key-manager.js.map +1 -0
- package/lib/src/core/protected-store.d.ts +5 -0
- package/lib/src/core/protected-store.js +2 -0
- package/lib/src/core/protected-store.js.map +1 -0
- package/lib/src/core/publisher.d.ts +6 -0
- package/lib/src/core/publisher.js +2 -0
- package/lib/src/core/publisher.js.map +1 -0
- package/lib/src/core/sdk-config.d.ts +52 -0
- package/lib/src/core/sdk-config.js +56 -0
- package/lib/src/core/sdk-config.js.map +1 -0
- package/lib/src/core/subscriber.d.ts +3 -0
- package/lib/src/core/subscriber.js +2 -0
- package/lib/src/core/subscriber.js.map +1 -0
- package/lib/src/gen/graphql-types.d.ts +101 -0
- package/lib/src/gen/graphql-types.js +102 -0
- package/lib/src/gen/graphql-types.js.map +1 -0
- package/lib/src/index.d.ts +4 -0
- package/lib/src/index.js +6 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/runtimes/browser/browser-crypto.d.ts +2 -0
- package/lib/src/runtimes/browser/browser-crypto.js +7 -0
- package/lib/src/runtimes/browser/browser-crypto.js.map +1 -0
- package/lib/src/runtimes/node/node-crypto.d.ts +2 -0
- package/lib/src/runtimes/node/node-crypto.js +6 -0
- package/lib/src/runtimes/node/node-crypto.js.map +1 -0
- package/lib/src/sdk.d.ts +1 -0
- package/lib/src/sdk.js +6 -0
- package/lib/src/sdk.js.map +1 -0
- package/lib/src/user/auth-provider.d.ts +97 -0
- package/lib/src/user/auth-provider.js +108 -0
- package/lib/src/user/auth-provider.js.map +1 -0
- package/lib/src/user/auth.d.ts +64 -0
- package/lib/src/user/auth.js +131 -0
- package/lib/src/user/auth.js.map +1 -0
- package/lib/src/user/error.d.ts +18 -0
- package/lib/src/user/error.js +28 -0
- package/lib/src/user/error.js.map +1 -0
- package/lib/src/user/identity-provider.d.ts +73 -0
- package/lib/src/user/identity-provider.js +241 -0
- package/lib/src/user/identity-provider.js.map +1 -0
- package/lib/src/user/user-client-interface.d.ts +168 -0
- package/lib/src/user/user-client-interface.js +2 -0
- package/lib/src/user/user-client-interface.js.map +1 -0
- package/lib/src/user/user-client.d.ts +82 -0
- package/lib/src/user/user-client.js +435 -0
- package/lib/src/user/user-client.js.map +1 -0
- package/lib/src/user/user-key-names.d.ts +6 -0
- package/lib/src/user/user-key-names.js +7 -0
- package/lib/src/user/user-key-names.js.map +1 -0
- package/lib/src/utils/resolvable-promise.d.ts +9 -0
- package/lib/src/utils/resolvable-promise.js +16 -0
- package/lib/src/utils/resolvable-promise.js.map +1 -0
- package/lib/test/integration/user-client-int.spec.d.ts +1 -0
- package/lib/test/integration/user-client-int.spec.js +203 -0
- package/lib/test/integration/user-client-int.spec.js.map +1 -0
- package/lib/test/unit/core/sdk-config.spec.d.ts +1 -0
- package/lib/test/unit/core/sdk-config.spec.js +49 -0
- package/lib/test/unit/core/sdk-config.spec.js.map +1 -0
- package/lib/test/unit/key-manager.spec.d.ts +1 -0
- package/lib/test/unit/key-manager.spec.js +21 -0
- package/lib/test/unit/key-manager.spec.js.map +1 -0
- package/lib/test/unit/user-client.spec.d.ts +1 -0
- package/lib/test/unit/user-client.spec.js +320 -0
- package/lib/test/unit/user-client.spec.js.map +1 -0
- package/package.json +47 -41
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/lib/client/apiClient.js +0 -206
- package/lib/core/api-key-names.js +0 -15
- package/lib/core/auth-store.js +0 -144
- package/lib/core/crypto.js +0 -5
- package/lib/core/key-manager.js +0 -158
- package/lib/core/protected-store.js +0 -5
- package/lib/core/publisher.js +0 -5
- package/lib/core/sdk-config.js +0 -56
- package/lib/core/subscriber.js +0 -5
- package/lib/gen/graphql-types.js +0 -141
- package/lib/index.js +0 -67
- package/lib/runtimes/browser/browser-crypto.js +0 -15
- package/lib/runtimes/node/node-crypto.js +0 -12
- package/lib/sdk.js +0 -18
- package/lib/user/auth-provider.js +0 -158
- package/lib/user/auth.js +0 -185
- package/lib/user/identity-provider.js +0 -272
- package/lib/user/user-client-interface.js +0 -5
- package/lib/user/user-client.js +0 -530
- package/lib/user/user-key-names.js +0 -13
- package/lib/utils/resolvable-promise.js +0 -22
package/docs/modules.html
CHANGED
|
@@ -1 +1,62 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@sudoplatform/sudo-user</title><meta name="description" content="Documentation for @sudoplatform/sudo-user"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>@sudoplatform/sudo-user</title><meta name="description" content="Documentation for @sudoplatform/sudo-user"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
|
|
2
|
+
<div class="tsd-toolbar-contents container">
|
|
3
|
+
<div class="table-cell" id="tsd-search" data-base=".">
|
|
4
|
+
<div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
|
|
5
|
+
<ul class="results">
|
|
6
|
+
<li class="state loading">Preparing search index...</li>
|
|
7
|
+
<li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">@sudoplatform/sudo-user</a></div>
|
|
8
|
+
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
|
|
9
|
+
<div class="container container-main">
|
|
10
|
+
<div class="col-8 col-content">
|
|
11
|
+
<div class="tsd-page-title">
|
|
12
|
+
<h2>@sudoplatform/sudo-user</h2></div>
|
|
13
|
+
<section class="tsd-panel-group tsd-index-group">
|
|
14
|
+
<section class="tsd-panel tsd-index-panel">
|
|
15
|
+
<h3 class="tsd-index-heading uppercase">Index</h3>
|
|
16
|
+
<section class="tsd-index-section">
|
|
17
|
+
<h3 class="tsd-index-heading">Classes</h3>
|
|
18
|
+
<div class="tsd-index-list"><a href="classes/AlreadyRegisteredError.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-128-path"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)" id="icon-128-text"></path></svg><span>Already<wbr/>Registered<wbr/>Error</span></a>
|
|
19
|
+
<a href="classes/DefaultSudoUserClient.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Default<wbr/>Sudo<wbr/>User<wbr/>Client</span></a>
|
|
20
|
+
<a href="classes/IdentityServiceConfigNotFoundError.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Identity<wbr/>Service<wbr/>Config<wbr/>Not<wbr/>Found<wbr/>Error</span></a>
|
|
21
|
+
<a href="classes/LocalAuthenticationProvider.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Local<wbr/>Authentication<wbr/>Provider</span></a>
|
|
22
|
+
<a href="classes/TESTAuthenticationProvider.html" class="tsd-index-link tsd-kind-class"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>TESTAuthentication<wbr/>Provider</span></a>
|
|
23
|
+
</div></section>
|
|
24
|
+
<section class="tsd-index-section">
|
|
25
|
+
<h3 class="tsd-index-heading">Interfaces</h3>
|
|
26
|
+
<div class="tsd-index-list"><a href="interfaces/AuthenticationProvider.html" class="tsd-index-link tsd-kind-interface"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-256-path"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)" id="icon-256-text"></path></svg><span>Authentication<wbr/>Provider</span></a>
|
|
27
|
+
<a href="interfaces/AuthenticationTokens.html" class="tsd-index-link tsd-kind-interface"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg><span>Authentication<wbr/>Tokens</span></a>
|
|
28
|
+
<a href="interfaces/SudoUserClient.html" class="tsd-index-link tsd-kind-interface"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg><span>Sudo<wbr/>User<wbr/>Client</span></a>
|
|
29
|
+
</div></section></section></section></div>
|
|
30
|
+
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
|
31
|
+
<div class="tsd-navigation settings">
|
|
32
|
+
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
|
|
33
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
|
|
34
|
+
<div class="tsd-accordion-details">
|
|
35
|
+
<div class="tsd-filter-visibility">
|
|
36
|
+
<h4 class="uppercase">Member Visibility</h4><form>
|
|
37
|
+
<ul id="tsd-filter-options">
|
|
38
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li>
|
|
39
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li>
|
|
40
|
+
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div>
|
|
41
|
+
<div class="tsd-theme-toggle">
|
|
42
|
+
<h4 class="uppercase">Theme</h4><select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
|
|
43
|
+
<nav class="tsd-navigation primary">
|
|
44
|
+
<details class="tsd-index-accordion" open><summary class="tsd-accordion-summary">
|
|
45
|
+
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
|
|
46
|
+
<div class="tsd-accordion-details">
|
|
47
|
+
<ul>
|
|
48
|
+
<li class="current selected"><a href="modules.html">@sudoplatform/sudo-<wbr/>user</a>
|
|
49
|
+
<ul></ul></li></ul></div></details></nav>
|
|
50
|
+
<nav class="tsd-navigation secondary menu-sticky">
|
|
51
|
+
<ul>
|
|
52
|
+
<li class="tsd-kind-class"><a href="classes/AlreadyRegisteredError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Already<wbr/>Registered<wbr/>Error</a></li>
|
|
53
|
+
<li class="tsd-kind-class"><a href="classes/DefaultSudoUserClient.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Default<wbr/>Sudo<wbr/>User<wbr/>Client</a></li>
|
|
54
|
+
<li class="tsd-kind-class"><a href="classes/IdentityServiceConfigNotFoundError.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Identity<wbr/>Service<wbr/>Config<wbr/>Not<wbr/>Found<wbr/>Error</a></li>
|
|
55
|
+
<li class="tsd-kind-class"><a href="classes/LocalAuthenticationProvider.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>Local<wbr/>Authentication<wbr/>Provider</a></li>
|
|
56
|
+
<li class="tsd-kind-class"><a href="classes/TESTAuthenticationProvider.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg>TESTAuthentication<wbr/>Provider</a></li>
|
|
57
|
+
<li class="tsd-kind-interface"><a href="interfaces/AuthenticationProvider.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg>Authentication<wbr/>Provider</a></li>
|
|
58
|
+
<li class="tsd-kind-interface"><a href="interfaces/AuthenticationTokens.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg>Authentication<wbr/>Tokens</a></li>
|
|
59
|
+
<li class="tsd-kind-interface"><a href="interfaces/SudoUserClient.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg>Sudo<wbr/>User<wbr/>Client</a></li></ul></nav></div></div>
|
|
60
|
+
<div class="container tsd-generator">
|
|
61
|
+
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
|
|
62
|
+
<div class="overlay"></div><script src="assets/main.js"></script></body></html>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RegisterFederatedIdInput } from '../gen/graphql-types';
|
|
2
|
+
import { Logger } from '@sudoplatform/sudo-common';
|
|
3
|
+
import { SudoUserClient } from '../user/user-client-interface';
|
|
4
|
+
/**
|
|
5
|
+
* AppSync wrapper to use to invoke Identity Service APIs.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ApiClient {
|
|
8
|
+
private client;
|
|
9
|
+
private region;
|
|
10
|
+
private graphqlUrl;
|
|
11
|
+
private sudoUserClient;
|
|
12
|
+
private logger;
|
|
13
|
+
constructor(region: string, graphqlUrl: string, sudoUserClient: SudoUserClient, logger: Logger);
|
|
14
|
+
deregister(): Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
globalSignOut(): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
registerFederatedId(input: RegisterFederatedIdInput): Promise<{
|
|
21
|
+
identityId: string;
|
|
22
|
+
}>;
|
|
23
|
+
reset(): void;
|
|
24
|
+
private graphQLErrorsToClientError;
|
|
25
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { AWSAppSyncClient, AUTH_TYPE } from 'aws-appsync';
|
|
2
|
+
import { DeregisterDocument, RegisterFederatedIdDocument, GlobalSignOutDocument, } from '../gen/graphql-types';
|
|
3
|
+
import { NotSignedInError, FatalError, ServiceError, UnknownGraphQLError, NotAuthorizedError, } from '@sudoplatform/sudo-common';
|
|
4
|
+
/**
|
|
5
|
+
* AppSync wrapper to use to invoke Identity Service APIs.
|
|
6
|
+
*/
|
|
7
|
+
export class ApiClient {
|
|
8
|
+
constructor(region, graphqlUrl, sudoUserClient, logger) {
|
|
9
|
+
this.region = region;
|
|
10
|
+
this.graphqlUrl = graphqlUrl;
|
|
11
|
+
this.sudoUserClient = sudoUserClient;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
this.client = new AWSAppSyncClient({
|
|
14
|
+
url: graphqlUrl,
|
|
15
|
+
region: region,
|
|
16
|
+
auth: {
|
|
17
|
+
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
|
|
18
|
+
jwtToken: async () => await sudoUserClient.getLatestAuthToken(),
|
|
19
|
+
},
|
|
20
|
+
disableOffline: true,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async deregister() {
|
|
24
|
+
if (!(await this.sudoUserClient.isSignedIn())) {
|
|
25
|
+
throw new NotSignedInError();
|
|
26
|
+
}
|
|
27
|
+
let result;
|
|
28
|
+
try {
|
|
29
|
+
result = await this.client.mutate({
|
|
30
|
+
mutation: DeregisterDocument,
|
|
31
|
+
fetchPolicy: 'no-cache',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const apolloError = err;
|
|
36
|
+
const error = apolloError.graphQLErrors?.[0];
|
|
37
|
+
if (error) {
|
|
38
|
+
throw this.graphQLErrorsToClientError(error);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new UnknownGraphQLError(err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const error = result.errors?.[0];
|
|
45
|
+
if (error) {
|
|
46
|
+
throw this.graphQLErrorsToClientError(error);
|
|
47
|
+
}
|
|
48
|
+
if (result.data) {
|
|
49
|
+
return { success: result.data.deregister?.success ? true : false };
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
throw new FatalError('deregister did not return any result.');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async globalSignOut() {
|
|
56
|
+
if (!(await this.sudoUserClient.isSignedIn())) {
|
|
57
|
+
throw new NotSignedInError();
|
|
58
|
+
}
|
|
59
|
+
let result;
|
|
60
|
+
try {
|
|
61
|
+
result = await this.client.mutate({
|
|
62
|
+
mutation: GlobalSignOutDocument,
|
|
63
|
+
fetchPolicy: 'no-cache',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
const apolloError = err;
|
|
68
|
+
const error = apolloError.graphQLErrors?.[0];
|
|
69
|
+
if (error) {
|
|
70
|
+
throw this.graphQLErrorsToClientError(error);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw new UnknownGraphQLError(err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const error = result.errors?.[0];
|
|
77
|
+
if (error) {
|
|
78
|
+
throw this.graphQLErrorsToClientError(error);
|
|
79
|
+
}
|
|
80
|
+
if (result.data) {
|
|
81
|
+
return { success: result.data.globalSignOut?.success ? true : false };
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw new FatalError('globalSignOut did not return any result.');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async registerFederatedId(input) {
|
|
88
|
+
let result;
|
|
89
|
+
try {
|
|
90
|
+
result = await this.client.mutate({
|
|
91
|
+
mutation: RegisterFederatedIdDocument,
|
|
92
|
+
variables: { input },
|
|
93
|
+
fetchPolicy: 'no-cache',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
const apolloError = err;
|
|
98
|
+
const error = apolloError.graphQLErrors?.[0];
|
|
99
|
+
if (error) {
|
|
100
|
+
throw this.graphQLErrorsToClientError(error);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
throw new UnknownGraphQLError(err);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const error = result.errors?.[0];
|
|
107
|
+
if (error) {
|
|
108
|
+
throw this.graphQLErrorsToClientError(error);
|
|
109
|
+
}
|
|
110
|
+
const identityId = result.data?.registerFederatedId?.identityId;
|
|
111
|
+
if (identityId) {
|
|
112
|
+
return {
|
|
113
|
+
identityId,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
throw new FatalError('registerFederatedId did not return expected result.');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
reset() {
|
|
121
|
+
this.client.clearStore();
|
|
122
|
+
this.client = new AWSAppSyncClient({
|
|
123
|
+
url: this.graphqlUrl,
|
|
124
|
+
region: this.region,
|
|
125
|
+
auth: {
|
|
126
|
+
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
|
|
127
|
+
jwtToken: async () => await this.sudoUserClient.getLatestAuthToken(),
|
|
128
|
+
},
|
|
129
|
+
disableOffline: true,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
graphQLErrorsToClientError(error) {
|
|
133
|
+
this.logger.error('GraphQL call failed.', { error });
|
|
134
|
+
if (error.errorType === 'sudoplatform.ServiceError') {
|
|
135
|
+
return new ServiceError(error.message);
|
|
136
|
+
}
|
|
137
|
+
else if (error.errorType === 'sudoplatform.identity.TokenValidationError') {
|
|
138
|
+
return new NotAuthorizedError();
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return new UnknownGraphQLError(error);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=apiClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../../src/client/apiClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAEL,kBAAkB,EAElB,2BAA2B,EAG3B,qBAAqB,GACtB,MAAM,sBAAsB,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AAI,gBAAgB,CAAC;YACjC,GAAG,EAAE,IAAI,CAAC,UAAU;YACpB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE;gBACJ,IAAI,EAAE,SAAS,CAAC,yBAAyB;gBACzC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE;aACrE;YACD,cAAc,EAAE,IAAI;SACrB,CAAC,CAAA;IACJ,CAAC;IAEO,0BAA0B,CAAC,KAAmB;QACpD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAEpD,IAAI,KAAK,CAAC,SAAS,KAAK,2BAA2B,EAAE;YACnD,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;SACvC;aAAM,IACL,KAAK,CAAC,SAAS,KAAK,4CAA4C,EAChE;YACA,OAAO,IAAI,kBAAkB,EAAE,CAAA;SAChC;aAAM;YACL,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAA;SACtC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key-names.js","sourceRoot":"","sources":["../../../src/core/api-key-names.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;IAC1B,kBAAkB,EAAE,oBAAoB;IACxC,MAAM,EAAE,cAAc;CACvB,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Publisher } from './publisher';
|
|
2
|
+
import { Subscriber } from './subscriber';
|
|
3
|
+
export interface Store {
|
|
4
|
+
setItem(keyId: string, value: string): Promise<void>;
|
|
5
|
+
getItem(keyId: string): string | undefined;
|
|
6
|
+
removeItem(keyId: string): void;
|
|
7
|
+
reset(): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Stores authentication details such as tokens and username
|
|
11
|
+
*/
|
|
12
|
+
export declare class AuthenticationStore implements Store, Publisher {
|
|
13
|
+
#private;
|
|
14
|
+
subscribers: Subscriber[];
|
|
15
|
+
/** Adds a secret into private _secrets object */
|
|
16
|
+
private addSecret;
|
|
17
|
+
/**
|
|
18
|
+
* Adds a string value into authentication store
|
|
19
|
+
*/
|
|
20
|
+
setItem(keyId: string, value: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns a string value from authentication store
|
|
23
|
+
*/
|
|
24
|
+
getItem(keyId: string): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Removes a secret
|
|
27
|
+
*/
|
|
28
|
+
removeItem(keyId: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Clears all secrets
|
|
31
|
+
*/
|
|
32
|
+
reset(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Register a subscriber to be notified when items are added
|
|
35
|
+
*
|
|
36
|
+
* @param subscriber a subscriber to be notified when items are added
|
|
37
|
+
*/
|
|
38
|
+
subscribe(subscriber: Subscriber): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Remove a subscriber from the list of subscribers
|
|
41
|
+
*
|
|
42
|
+
* @param subscriber the subscriber to be removed
|
|
43
|
+
*/
|
|
44
|
+
unsubscribe(subscriber: Subscriber): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Notify all subscribers that a change event was triggered for a specific item
|
|
47
|
+
*
|
|
48
|
+
* @param itemName the name of the item that changed
|
|
49
|
+
*/
|
|
50
|
+
notifySubscribers(itemName: string): Promise<void>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var _AuthenticationStore_secrets;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
+
import * as JWT from 'jsonwebtoken';
|
|
4
|
+
/**
|
|
5
|
+
* Stores authentication details such as tokens and username
|
|
6
|
+
*/
|
|
7
|
+
export class AuthenticationStore {
|
|
8
|
+
constructor() {
|
|
9
|
+
/** Do not expose these directly */
|
|
10
|
+
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
|
|
11
|
+
_AuthenticationStore_secrets.set(this, {});
|
|
12
|
+
this.subscribers = [];
|
|
13
|
+
}
|
|
14
|
+
/** Adds a secret into private _secrets object */
|
|
15
|
+
async addSecret(keyId, secret) {
|
|
16
|
+
const key = keyId.substr(keyId.lastIndexOf('.') + 1);
|
|
17
|
+
__classPrivateFieldGet(this, _AuthenticationStore_secrets, "f")[key] = secret;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Adds a string value into authentication store
|
|
21
|
+
*/
|
|
22
|
+
async setItem(keyId, value) {
|
|
23
|
+
const key = keyId.substr(keyId.lastIndexOf('.') + 1);
|
|
24
|
+
if (key === 'idToken') {
|
|
25
|
+
// Store the token expiry
|
|
26
|
+
const decoded = JWT.decode(value, { complete: true });
|
|
27
|
+
if (decoded) {
|
|
28
|
+
const tokenExpiry = decoded.payload['exp'];
|
|
29
|
+
await this.addSecret('tokenExpiry', {
|
|
30
|
+
type: 'string',
|
|
31
|
+
value: tokenExpiry,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
await this.addSecret(key, { type: 'string', value });
|
|
36
|
+
await this.notifySubscribers(key);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns a string value from authentication store
|
|
40
|
+
*/
|
|
41
|
+
getItem(keyId) {
|
|
42
|
+
const key = keyId.substr(keyId.lastIndexOf('.') + 1);
|
|
43
|
+
const secret = __classPrivateFieldGet(this, _AuthenticationStore_secrets, "f")[key];
|
|
44
|
+
return secret?.type === 'string' ? secret.value : undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Removes a secret
|
|
48
|
+
*/
|
|
49
|
+
removeItem(keyId) {
|
|
50
|
+
const key = keyId.substr(keyId.lastIndexOf('.') + 1);
|
|
51
|
+
delete __classPrivateFieldGet(this, _AuthenticationStore_secrets, "f")[key];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Clears all secrets
|
|
55
|
+
*/
|
|
56
|
+
reset() {
|
|
57
|
+
__classPrivateFieldSet(this, _AuthenticationStore_secrets, {}, "f");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Register a subscriber to be notified when items are added
|
|
61
|
+
*
|
|
62
|
+
* @param subscriber a subscriber to be notified when items are added
|
|
63
|
+
*/
|
|
64
|
+
async subscribe(subscriber) {
|
|
65
|
+
this.subscribers.push(subscriber);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Remove a subscriber from the list of subscribers
|
|
69
|
+
*
|
|
70
|
+
* @param subscriber the subscriber to be removed
|
|
71
|
+
*/
|
|
72
|
+
async unsubscribe(subscriber) {
|
|
73
|
+
const index = this.subscribers.indexOf(subscriber);
|
|
74
|
+
this.subscribers.splice(index, 1);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Notify all subscribers that a change event was triggered for a specific item
|
|
78
|
+
*
|
|
79
|
+
* @param itemName the name of the item that changed
|
|
80
|
+
*/
|
|
81
|
+
async notifySubscribers(itemName) {
|
|
82
|
+
for (const subscriber of this.subscribers) {
|
|
83
|
+
subscriber.update(itemName);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
_AuthenticationStore_secrets = new WeakMap();
|
|
88
|
+
//# sourceMappingURL=auth-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-store.js","sourceRoot":"","sources":["../../../src/core/auth-store.ts"],"names":[],"mappings":";;AAEA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAcnC;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACE,mCAAmC;QACnC,0EAA0E;QAC1E,uCAAmC,EAAE,EAAA;QACrC,gBAAW,GA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IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IAC7D,CAAC;IAED;;OAEG;IACI,UAAU,CAAC,KAAa;QAC7B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QACpD,OAAO,uBAAA,IAAI,oCAAS,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC;IAED;;OAEG;IACI,KAAK;QACV,uBAAA,IAAI,gCAAY,EAAE,MAAA,CAAA;IACpB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,SAAS,CAAC,UAAsB;QAC3C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,UAAsB;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QAClD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB,CAAC,QAAgB;QACtC,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE;YACzC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;SAC5B;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/core/crypto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PublicKeyFormat, SudoKeyManager } from '@sudoplatform/sudo-common';
|
|
2
|
+
export interface PublicKey {
|
|
3
|
+
keyId: string;
|
|
4
|
+
algorithm: string;
|
|
5
|
+
symmetricAlgorithm: string;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
keyFormat: PublicKeyFormat;
|
|
8
|
+
}
|
|
9
|
+
export interface KeyPair {
|
|
10
|
+
publicKey: unknown;
|
|
11
|
+
publicKeyFormat: PublicKeyFormat;
|
|
12
|
+
privateKey: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface KeyManager {
|
|
15
|
+
addString(keyId: string, value: string): Promise<void>;
|
|
16
|
+
getString(keyId: string): Promise<string | undefined>;
|
|
17
|
+
generateKeyPair(keyId?: string): Promise<string>;
|
|
18
|
+
exportPublicKey(keyId: string): Promise<PublicKey>;
|
|
19
|
+
signJWT(keyId: string, payload: Record<string, unknown>): Promise<string>;
|
|
20
|
+
reset(): Promise<void>;
|
|
21
|
+
removeItem(keyId: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Key Manager
|
|
25
|
+
*/
|
|
26
|
+
export declare class KeyManager implements KeyManager {
|
|
27
|
+
private sudoKeyManager;
|
|
28
|
+
private static Constants;
|
|
29
|
+
constructor(sudoKeyManager: SudoKeyManager);
|
|
30
|
+
retrieveKeyPair(keyId: string): Promise<KeyPair>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { DecodeError, KeyNotFoundError, } from '@sudoplatform/sudo-common';
|
|
2
|
+
import JWT from 'jsonwebtoken';
|
|
3
|
+
import * as uuid from 'uuid';
|
|
4
|
+
import { cryptoProvider } from '../runtimes/node/node-crypto';
|
|
5
|
+
/**
|
|
6
|
+
* Key Manager
|
|
7
|
+
*/
|
|
8
|
+
export class KeyManager {
|
|
9
|
+
constructor(sudoKeyManager) {
|
|
10
|
+
this.sudoKeyManager = sudoKeyManager;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Adds a string value into key manager
|
|
14
|
+
*/
|
|
15
|
+
async addString(keyId, value) {
|
|
16
|
+
await this.sudoKeyManager.addPassword(new TextEncoder().encode(value).buffer, keyId);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns a string value from key manager
|
|
20
|
+
*/
|
|
21
|
+
async getString(keyId) {
|
|
22
|
+
const passwordBuffer = await this.sudoKeyManager.getPassword(keyId);
|
|
23
|
+
if (!passwordBuffer) {
|
|
24
|
+
throw new KeyNotFoundError(`No key found for keyId: ${keyId}`);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
return new TextDecoder('utf-8', { fatal: true }).decode(passwordBuffer);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
const error = err;
|
|
31
|
+
throw new DecodeError(error.message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generates and adds a new key pair into key manager
|
|
36
|
+
* @returns Key ID
|
|
37
|
+
*/
|
|
38
|
+
async generateKeyPair(keyId = uuid.v4()) {
|
|
39
|
+
await this.sudoKeyManager.generateKeyPair(keyId);
|
|
40
|
+
return keyId;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Removes a secret
|
|
44
|
+
*/
|
|
45
|
+
async removeItem(id) {
|
|
46
|
+
await this.sudoKeyManager.deletePassword(id);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Signs a JWT with a signing key that is in key manager
|
|
50
|
+
* @returns JWT data
|
|
51
|
+
*/
|
|
52
|
+
async signJWT(keyId, payload) {
|
|
53
|
+
const privateKeyBits = await this.sudoKeyManager.getPrivateKey(keyId);
|
|
54
|
+
if (!privateKeyBits) {
|
|
55
|
+
throw new KeyNotFoundError(`No key found for keyId: ${keyId}`);
|
|
56
|
+
}
|
|
57
|
+
const base64encoded = cryptoProvider.arrayBufferToBase64(privateKeyBits);
|
|
58
|
+
//PEM encode private key
|
|
59
|
+
const signingKey = `-----BEGIN PRIVATE KEY-----\n${base64encoded}\n-----END PRIVATE KEY-----`;
|
|
60
|
+
return JWT.sign(payload, signingKey, {
|
|
61
|
+
algorithm: 'RS256',
|
|
62
|
+
keyid: keyId,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Exports public key in a format for use with SudoPlatform
|
|
67
|
+
*/
|
|
68
|
+
async exportPublicKey(keyId) {
|
|
69
|
+
const publicKey = await this.sudoKeyManager.getPublicKey(keyId);
|
|
70
|
+
if (!publicKey) {
|
|
71
|
+
throw new Error('Invalid key ID for exportPublicKey');
|
|
72
|
+
}
|
|
73
|
+
const base64encoded = cryptoProvider.arrayBufferToBase64(publicKey.keyData);
|
|
74
|
+
return {
|
|
75
|
+
keyId,
|
|
76
|
+
algorithm: KeyManager.Constants.publicKeyAlgorithm,
|
|
77
|
+
symmetricAlgorithm: KeyManager.Constants.symmetricAlgorithm,
|
|
78
|
+
publicKey: base64encoded,
|
|
79
|
+
keyFormat: publicKey.keyFormat,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Clears all private keys from memory
|
|
84
|
+
*/
|
|
85
|
+
async reset() {
|
|
86
|
+
await this.sudoKeyManager.removeAllKeys();
|
|
87
|
+
}
|
|
88
|
+
async retrieveKeyPair(keyId) {
|
|
89
|
+
const publicKey = await this.sudoKeyManager.getPublicKey(keyId);
|
|
90
|
+
if (!publicKey) {
|
|
91
|
+
throw new KeyNotFoundError(`Public key not found for keyId: ${keyId}`);
|
|
92
|
+
}
|
|
93
|
+
const privateKey = await this.sudoKeyManager.getPrivateKey(keyId);
|
|
94
|
+
if (!privateKey) {
|
|
95
|
+
throw new KeyNotFoundError(`Private key not found for keyId: ${keyId}`);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
publicKey: cryptoProvider.arrayBufferToBase64(publicKey.keyData),
|
|
99
|
+
publicKeyFormat: publicKey.keyFormat,
|
|
100
|
+
privateKey: cryptoProvider.arrayBufferToBase64(privateKey),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
KeyManager.Constants = {
|
|
105
|
+
publicKeyAlgorithm: 'RSA',
|
|
106
|
+
symmetricAlgorithm: 'AES/256',
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=key-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-manager.js","sourceRoot":"","sources":["../../../src/core/key-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,GAGjB,MAAM,2BAA2B,CAAA;AAClC,OAAO,GAAG,MAAM,cAAc,CAAA;AAC9B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AA0B7D;;GAEG;AACH,MAAM,OAAO,UAAU;IAMrB,YAAoB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAEtD;;OAEG;IACI,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,KAAa;QACjD,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CACnC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EACtC,KAAK,CACN,CAAA;IACH,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,SAAS,CAAC,KAAa;QAClC,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QACnE,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,IAAI,gBAAgB,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAA;SAC/D;QACD,IAAI;YACF,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;SACxE;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,KAAK,GAAG,GAAY,CAAA;YAC1B,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;SACrC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,eAAe,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE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