@sudoplatform/sudo-user 10.0.1 → 11.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/docs/assets/highlight.css +2 -2
- package/docs/assets/main.js +4 -2
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +446 -610
- package/docs/classes/AlreadyRegisteredError.html +163 -8
- package/docs/classes/DefaultSudoUserClient.html +568 -55
- 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 -78
- package/docs/modules.html +62 -1
- package/lib/client/apiClient.js +9 -25
- package/lib/core/auth-store.js +1 -1
- package/lib/gen/graphql-types.d.ts +5 -4
- package/lib/user/auth.js +1 -3
- package/lib/user/identity-provider.d.ts +7 -0
- package/lib/user/identity-provider.js +32 -13
- package/lib/user/user-client-interface.d.ts +4 -0
- package/lib/user/user-client.d.ts +1 -0
- package/lib/user/user-client.js +33 -21
- package/package.json +54 -46
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
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>
|
package/lib/client/apiClient.js
CHANGED
|
@@ -44,8 +44,6 @@ class ApiClient {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
async deregister() {
|
|
47
|
-
var _result$errors;
|
|
48
|
-
|
|
49
47
|
if (!(await this.sudoUserClient.isSignedIn())) {
|
|
50
48
|
throw new _sudoCommon.NotSignedInError();
|
|
51
49
|
}
|
|
@@ -58,10 +56,8 @@ class ApiClient {
|
|
|
58
56
|
fetchPolicy: 'no-cache'
|
|
59
57
|
});
|
|
60
58
|
} catch (err) {
|
|
61
|
-
var _apolloError$graphQLE;
|
|
62
|
-
|
|
63
59
|
const apolloError = err;
|
|
64
|
-
const error =
|
|
60
|
+
const error = apolloError.graphQLErrors?.[0];
|
|
65
61
|
|
|
66
62
|
if (error) {
|
|
67
63
|
throw this.graphQLErrorsToClientError(error);
|
|
@@ -70,17 +66,15 @@ class ApiClient {
|
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
68
|
|
|
73
|
-
const error =
|
|
69
|
+
const error = result.errors?.[0];
|
|
74
70
|
|
|
75
71
|
if (error) {
|
|
76
72
|
throw this.graphQLErrorsToClientError(error);
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
if (result.data) {
|
|
80
|
-
var _result$data$deregist;
|
|
81
|
-
|
|
82
76
|
return {
|
|
83
|
-
success:
|
|
77
|
+
success: result.data.deregister?.success ? true : false
|
|
84
78
|
};
|
|
85
79
|
} else {
|
|
86
80
|
throw new _sudoCommon.FatalError('deregister did not return any result.');
|
|
@@ -88,8 +82,6 @@ class ApiClient {
|
|
|
88
82
|
}
|
|
89
83
|
|
|
90
84
|
async globalSignOut() {
|
|
91
|
-
var _result$errors2;
|
|
92
|
-
|
|
93
85
|
if (!(await this.sudoUserClient.isSignedIn())) {
|
|
94
86
|
throw new _sudoCommon.NotSignedInError();
|
|
95
87
|
}
|
|
@@ -102,10 +94,8 @@ class ApiClient {
|
|
|
102
94
|
fetchPolicy: 'no-cache'
|
|
103
95
|
});
|
|
104
96
|
} catch (err) {
|
|
105
|
-
var _apolloError$graphQLE2;
|
|
106
|
-
|
|
107
97
|
const apolloError = err;
|
|
108
|
-
const error =
|
|
98
|
+
const error = apolloError.graphQLErrors?.[0];
|
|
109
99
|
|
|
110
100
|
if (error) {
|
|
111
101
|
throw this.graphQLErrorsToClientError(error);
|
|
@@ -114,17 +104,15 @@ class ApiClient {
|
|
|
114
104
|
}
|
|
115
105
|
}
|
|
116
106
|
|
|
117
|
-
const error =
|
|
107
|
+
const error = result.errors?.[0];
|
|
118
108
|
|
|
119
109
|
if (error) {
|
|
120
110
|
throw this.graphQLErrorsToClientError(error);
|
|
121
111
|
}
|
|
122
112
|
|
|
123
113
|
if (result.data) {
|
|
124
|
-
var _result$data$globalSi;
|
|
125
|
-
|
|
126
114
|
return {
|
|
127
|
-
success:
|
|
115
|
+
success: result.data.globalSignOut?.success ? true : false
|
|
128
116
|
};
|
|
129
117
|
} else {
|
|
130
118
|
throw new _sudoCommon.FatalError('globalSignOut did not return any result.');
|
|
@@ -132,8 +120,6 @@ class ApiClient {
|
|
|
132
120
|
}
|
|
133
121
|
|
|
134
122
|
async registerFederatedId(input) {
|
|
135
|
-
var _result$errors3, _result$data, _result$data$register;
|
|
136
|
-
|
|
137
123
|
let result;
|
|
138
124
|
|
|
139
125
|
try {
|
|
@@ -145,10 +131,8 @@ class ApiClient {
|
|
|
145
131
|
fetchPolicy: 'no-cache'
|
|
146
132
|
});
|
|
147
133
|
} catch (err) {
|
|
148
|
-
var _apolloError$graphQLE3;
|
|
149
|
-
|
|
150
134
|
const apolloError = err;
|
|
151
|
-
const error =
|
|
135
|
+
const error = apolloError.graphQLErrors?.[0];
|
|
152
136
|
|
|
153
137
|
if (error) {
|
|
154
138
|
throw this.graphQLErrorsToClientError(error);
|
|
@@ -157,13 +141,13 @@ class ApiClient {
|
|
|
157
141
|
}
|
|
158
142
|
}
|
|
159
143
|
|
|
160
|
-
const error =
|
|
144
|
+
const error = result.errors?.[0];
|
|
161
145
|
|
|
162
146
|
if (error) {
|
|
163
147
|
throw this.graphQLErrorsToClientError(error);
|
|
164
148
|
}
|
|
165
149
|
|
|
166
|
-
const identityId =
|
|
150
|
+
const identityId = result.data?.registerFederatedId?.identityId;
|
|
167
151
|
|
|
168
152
|
if (identityId) {
|
|
169
153
|
return {
|
package/lib/core/auth-store.js
CHANGED
|
@@ -86,7 +86,7 @@ class AuthenticationStore {
|
|
|
86
86
|
|
|
87
87
|
const secret = _classPrivateFieldGet(this, _secrets)[key];
|
|
88
88
|
|
|
89
|
-
return
|
|
89
|
+
return secret?.type === 'string' ? secret.value : undefined;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Removes a secret
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
2
2
|
export declare type Maybe<T> = T | undefined;
|
|
3
|
+
export declare type InputMaybe<T> = T | undefined;
|
|
3
4
|
export declare type Exact<T extends {
|
|
4
5
|
[key: string]: unknown;
|
|
5
6
|
}> = {
|
|
@@ -47,7 +48,7 @@ export declare type Mutation = {
|
|
|
47
48
|
registerFederatedId?: Maybe<FederatedId>;
|
|
48
49
|
};
|
|
49
50
|
export declare type MutationRegisterFederatedIdArgs = {
|
|
50
|
-
input?:
|
|
51
|
+
input?: InputMaybe<RegisterFederatedIdInput>;
|
|
51
52
|
};
|
|
52
53
|
export declare type Query = {
|
|
53
54
|
__typename?: 'Query';
|
|
@@ -67,7 +68,7 @@ export declare type DeregisterMutation = {
|
|
|
67
68
|
deregister?: {
|
|
68
69
|
__typename?: 'Deregister';
|
|
69
70
|
success: boolean;
|
|
70
|
-
} |
|
|
71
|
+
} | undefined;
|
|
71
72
|
};
|
|
72
73
|
export declare type GlobalSignOutMutationVariables = Exact<{
|
|
73
74
|
[key: string]: never;
|
|
@@ -77,7 +78,7 @@ export declare type GlobalSignOutMutation = {
|
|
|
77
78
|
globalSignOut?: {
|
|
78
79
|
__typename?: 'GlobalSignOut';
|
|
79
80
|
success: boolean;
|
|
80
|
-
} |
|
|
81
|
+
} | undefined;
|
|
81
82
|
};
|
|
82
83
|
export declare type RegisterFederatedIdMutationVariables = Exact<{
|
|
83
84
|
input: RegisterFederatedIdInput;
|
|
@@ -87,7 +88,7 @@ export declare type RegisterFederatedIdMutation = {
|
|
|
87
88
|
registerFederatedId?: {
|
|
88
89
|
__typename?: 'FederatedId';
|
|
89
90
|
identityId: string;
|
|
90
|
-
} |
|
|
91
|
+
} | undefined;
|
|
91
92
|
};
|
|
92
93
|
export declare const DeregisterDocument: DocumentNode<DeregisterMutation, Exact<{
|
|
93
94
|
[key: string]: never;
|
package/lib/user/auth.js
CHANGED
|
@@ -98,9 +98,7 @@ class CognitoAuthUI {
|
|
|
98
98
|
const userId = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.userId);
|
|
99
99
|
|
|
100
100
|
if (authTokens && userId) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
(_this$tokensRefreshed = this.tokensRefreshedPromise) === null || _this$tokensRefreshed === void 0 ? void 0 : _this$tokensRefreshed.resolve({
|
|
101
|
+
this.tokensRefreshedPromise?.resolve({
|
|
104
102
|
authenticationTokens: authTokens,
|
|
105
103
|
userId
|
|
106
104
|
});
|
|
@@ -45,6 +45,12 @@ export interface IdentityProvider {
|
|
|
45
45
|
* @return Successful authentication result AuthenticationTokens containing refreshed tokens
|
|
46
46
|
*/
|
|
47
47
|
refreshTokens(refreshToken: string): Promise<AuthenticationTokens>;
|
|
48
|
+
/**
|
|
49
|
+
* Signs out the user from this device.
|
|
50
|
+
*
|
|
51
|
+
* @param refreshToken refresh token to revoke to sign out this device.
|
|
52
|
+
*/
|
|
53
|
+
signOut(refreshToken: string): Promise<void>;
|
|
48
54
|
}
|
|
49
55
|
export declare class CognitoUserPoolIdentityProvider implements IdentityProvider {
|
|
50
56
|
private keyManager;
|
|
@@ -62,5 +68,6 @@ export declare class CognitoUserPoolIdentityProvider implements IdentityProvider
|
|
|
62
68
|
signInWithKey(userId: string, keyId: string): Promise<AuthenticationTokens>;
|
|
63
69
|
signInWithToken(userId: string, token: string, type: string): Promise<AuthenticationTokens>;
|
|
64
70
|
refreshTokens(refreshToken: string): Promise<AuthenticationTokens>;
|
|
71
|
+
signOut(refreshToken: string): Promise<void>;
|
|
65
72
|
private storeRefreshTokenLifetime;
|
|
66
73
|
}
|
|
@@ -130,10 +130,10 @@ class CognitoUserPoolIdentityProvider {
|
|
|
130
130
|
});
|
|
131
131
|
const respondToAuthChallengeResult = await this.idpService.send(respondToAuthChallenge);
|
|
132
132
|
const authResult = respondToAuthChallengeResult.AuthenticationResult;
|
|
133
|
-
const idToken = authResult
|
|
134
|
-
const accessToken = authResult
|
|
135
|
-
const refreshToken = authResult
|
|
136
|
-
const tokenExpiry = authResult
|
|
133
|
+
const idToken = authResult?.IdToken;
|
|
134
|
+
const accessToken = authResult?.AccessToken;
|
|
135
|
+
const refreshToken = authResult?.RefreshToken;
|
|
136
|
+
const tokenExpiry = authResult?.ExpiresIn;
|
|
137
137
|
|
|
138
138
|
if (idToken && accessToken && refreshToken && tokenExpiry) {
|
|
139
139
|
const authTokens = {
|
|
@@ -181,10 +181,10 @@ class CognitoUserPoolIdentityProvider {
|
|
|
181
181
|
});
|
|
182
182
|
const respondToAuthChallengeResult = await this.idpService.send(respondToAuthChallenge);
|
|
183
183
|
const authResult = respondToAuthChallengeResult.AuthenticationResult;
|
|
184
|
-
const idToken = authResult
|
|
185
|
-
const accessToken = authResult
|
|
186
|
-
const refreshToken = authResult
|
|
187
|
-
const tokenExpiry = authResult
|
|
184
|
+
const idToken = authResult?.IdToken;
|
|
185
|
+
const accessToken = authResult?.AccessToken;
|
|
186
|
+
const refreshToken = authResult?.RefreshToken;
|
|
187
|
+
const tokenExpiry = authResult?.ExpiresIn;
|
|
188
188
|
|
|
189
189
|
if (idToken && accessToken && refreshToken && tokenExpiry) {
|
|
190
190
|
const authTokens = {
|
|
@@ -207,8 +207,6 @@ class CognitoUserPoolIdentityProvider {
|
|
|
207
207
|
async refreshTokens(refreshToken) {
|
|
208
208
|
return new Promise(async (resolve, reject) => {
|
|
209
209
|
try {
|
|
210
|
-
var _initiateAuthResult$A, _initiateAuthResult$A2, _initiateAuthResult$A3;
|
|
211
|
-
|
|
212
210
|
const initiateAuth = new _clientCognitoIdentityProvider.InitiateAuthCommand({
|
|
213
211
|
ClientId: this.config.identityService.clientId,
|
|
214
212
|
AuthFlow: 'REFRESH_TOKEN_AUTH',
|
|
@@ -217,9 +215,9 @@ class CognitoUserPoolIdentityProvider {
|
|
|
217
215
|
}
|
|
218
216
|
});
|
|
219
217
|
const initiateAuthResult = await this.idpService.send(initiateAuth);
|
|
220
|
-
const idToken =
|
|
221
|
-
const accessToken =
|
|
222
|
-
const tokenExpiry =
|
|
218
|
+
const idToken = initiateAuthResult.AuthenticationResult?.IdToken;
|
|
219
|
+
const accessToken = initiateAuthResult.AuthenticationResult?.AccessToken;
|
|
220
|
+
const tokenExpiry = initiateAuthResult.AuthenticationResult?.ExpiresIn;
|
|
223
221
|
|
|
224
222
|
if (idToken && accessToken && tokenExpiry) {
|
|
225
223
|
const authTokens = {
|
|
@@ -240,6 +238,27 @@ class CognitoUserPoolIdentityProvider {
|
|
|
240
238
|
});
|
|
241
239
|
}
|
|
242
240
|
|
|
241
|
+
async signOut(refreshToken) {
|
|
242
|
+
return new Promise((resolve, reject) => {
|
|
243
|
+
const params = {
|
|
244
|
+
Token: refreshToken,
|
|
245
|
+
ClientId: this.config.identityService.clientId
|
|
246
|
+
};
|
|
247
|
+
const revokeToken = new _clientCognitoIdentityProvider.RevokeTokenCommand(params);
|
|
248
|
+
this.idpService.send(revokeToken, (error, data) => {
|
|
249
|
+
if (error) {
|
|
250
|
+
this.logger.error(error.message);
|
|
251
|
+
reject(new _sudoCommon.SignOutError(error.message));
|
|
252
|
+
} else {
|
|
253
|
+
this.logger.info('User successfully signed out.', {
|
|
254
|
+
data
|
|
255
|
+
});
|
|
256
|
+
resolve();
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
243
262
|
async storeRefreshTokenLifetime(refreshTokenLifetime) {
|
|
244
263
|
const tokenLifetime = refreshTokenLifetime * 24 * 60 * 60 * 1000 + new Date().getTime();
|
|
245
264
|
await this.keyManager.removeItem(_apiKeyNames.apiKeyNames.refreshTokenExpiry);
|
|
@@ -107,6 +107,10 @@ export interface SudoUserClient {
|
|
|
107
107
|
* @param name claim name.
|
|
108
108
|
*/
|
|
109
109
|
getUserClaim(name: string): Promise<any | undefined>;
|
|
110
|
+
/**
|
|
111
|
+
* Signs out the user from this device.
|
|
112
|
+
*/
|
|
113
|
+
signOut(): Promise<void>;
|
|
110
114
|
/**
|
|
111
115
|
* Signs out the user from all devices.
|
|
112
116
|
*/
|
|
@@ -42,6 +42,7 @@ export declare class DefaultSudoUserClient implements SudoUserClient {
|
|
|
42
42
|
isSignedIn(): Promise<boolean>;
|
|
43
43
|
refreshTokens(refreshToken: string): Promise<AuthenticationTokens>;
|
|
44
44
|
getLatestAuthToken(): Promise<string>;
|
|
45
|
+
signOut(): Promise<void>;
|
|
45
46
|
globalSignOut(): Promise<void>;
|
|
46
47
|
registerWithAuthenticationProvider(authenticationProvider: AuthenticationProvider, registrationId?: string): Promise<string>;
|
|
47
48
|
signInWithAuthenticationProvider(authenticationProvider: AuthenticationProvider): Promise<AuthenticationTokens>;
|
package/lib/user/user-client.js
CHANGED
|
@@ -39,8 +39,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
39
39
|
|
|
40
40
|
class DefaultSudoUserClient {
|
|
41
41
|
constructor(options) {
|
|
42
|
-
var _this$config;
|
|
43
|
-
|
|
44
42
|
_defineProperty(this, "config", void 0);
|
|
45
43
|
|
|
46
44
|
_defineProperty(this, "keyManager", void 0);
|
|
@@ -59,27 +57,27 @@ class DefaultSudoUserClient {
|
|
|
59
57
|
|
|
60
58
|
_defineProperty(this, "launchUriFn", void 0);
|
|
61
59
|
|
|
62
|
-
this.logger =
|
|
63
|
-
this.config =
|
|
64
|
-
this.authenticationStore =
|
|
60
|
+
this.logger = options?.logger ?? new _sudoCommon.DefaultLogger('SudoUser', 'warn');
|
|
61
|
+
this.config = options?.config ?? (0, _sdkConfig.getIdentityServiceConfig)();
|
|
62
|
+
this.authenticationStore = options?.authenticationStore ?? new _authStore.AuthenticationStore();
|
|
65
63
|
|
|
66
|
-
if (options
|
|
67
|
-
this.sudoUserKeyManager = options
|
|
64
|
+
if (options?.sudoKeyManager) {
|
|
65
|
+
this.sudoUserKeyManager = options?.sudoKeyManager;
|
|
68
66
|
} else {
|
|
69
67
|
const cryptoProvider = new _sudoWebCryptoProvider.WebSudoCryptoProvider('SudoUserClient', 'com.sudoplatform.appservicename');
|
|
70
68
|
this.sudoUserKeyManager = new _sudoCommon.DefaultSudoKeyManager(cryptoProvider);
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
this.keyManager = new _keyManager.KeyManager(this.sudoUserKeyManager);
|
|
74
|
-
this.launchUriFn = options
|
|
75
|
-
this.identityProvider =
|
|
76
|
-
const federatedSignInConfig =
|
|
72
|
+
this.launchUriFn = options?.launchUriFn;
|
|
73
|
+
this.identityProvider = options?.identityProvider ?? new _identityProvider.CognitoUserPoolIdentityProvider(this.keyManager, this.config, this.logger);
|
|
74
|
+
const federatedSignInConfig = this.config?.federatedSignIn;
|
|
77
75
|
|
|
78
76
|
if (federatedSignInConfig) {
|
|
79
|
-
this.authUI =
|
|
77
|
+
this.authUI = options?.authUI ?? new _auth.CognitoAuthUI(this.authenticationStore, federatedSignInConfig, this.keyManager, this.logger, this.launchUriFn);
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
this.apiClient =
|
|
80
|
+
this.apiClient = options?.apiClient ?? new _apiClient.ApiClient(this.config.identityService.region, this.config.identityService.apiUrl, this, this.logger);
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
get sudoKeyManager() {
|
|
@@ -88,9 +86,7 @@ class DefaultSudoUserClient {
|
|
|
88
86
|
|
|
89
87
|
presentFederatedSignInUI() {
|
|
90
88
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
(_this$authUI = this.authUI) === null || _this$authUI === void 0 ? void 0 : _this$authUI.presentFederatedSignInUI();
|
|
89
|
+
this.authUI?.presentFederatedSignInUI();
|
|
94
90
|
} catch (err) {
|
|
95
91
|
const error = err;
|
|
96
92
|
this.logger.error('Failed to launch the federated sign in UI.', {
|
|
@@ -102,9 +98,7 @@ class DefaultSudoUserClient {
|
|
|
102
98
|
|
|
103
99
|
async processFederatedSignInTokens(url) {
|
|
104
100
|
try {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
let authTokens = await ((_this$authUI2 = this.authUI) === null || _this$authUI2 === void 0 ? void 0 : _this$authUI2.processFederatedSignInTokens(url));
|
|
101
|
+
let authTokens = await this.authUI?.processFederatedSignInTokens(url);
|
|
108
102
|
|
|
109
103
|
if (authTokens) {
|
|
110
104
|
authTokens = await this.registerFederatedIdAndRefreshTokens(authTokens);
|
|
@@ -241,6 +235,26 @@ class DefaultSudoUserClient {
|
|
|
241
235
|
}
|
|
242
236
|
}
|
|
243
237
|
|
|
238
|
+
async signOut() {
|
|
239
|
+
let refreshToken;
|
|
240
|
+
|
|
241
|
+
try {
|
|
242
|
+
refreshToken = await this.getRefreshToken();
|
|
243
|
+
} catch (err) {
|
|
244
|
+
if (err instanceof _sudoCommon.KeyNotFoundError) {
|
|
245
|
+
throw new _sudoCommon.NotSignedInError();
|
|
246
|
+
} else {
|
|
247
|
+
throw err;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (refreshToken) {
|
|
252
|
+
await this.identityProvider.signOut(refreshToken);
|
|
253
|
+
} else {
|
|
254
|
+
throw new _sudoCommon.NotSignedInError();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
244
258
|
async globalSignOut() {
|
|
245
259
|
if (!(await this.isSignedIn())) {
|
|
246
260
|
throw new _sudoCommon.NotSignedInError();
|
|
@@ -363,9 +377,7 @@ class DefaultSudoUserClient {
|
|
|
363
377
|
}
|
|
364
378
|
|
|
365
379
|
presentSignOutUI() {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
(_this$authUI3 = this.authUI) === null || _this$authUI3 === void 0 ? void 0 : _this$authUI3.presentSignOutUI();
|
|
380
|
+
this.authUI?.presentSignOutUI();
|
|
369
381
|
}
|
|
370
382
|
|
|
371
383
|
reset() {
|