cidaas-javascript-sdk 3.1.3 → 3.1.4
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/CHANGELOG.md +2 -2
- package/dist/authentication/index.d.ts +55 -0
- package/{src/main/authentication/index.ts → dist/authentication/index.js} +127 -88
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/web-auth/ConsentService.d.ts +59 -0
- package/dist/web-auth/ConsentService.js +73 -0
- package/dist/web-auth/Entities.d.ts +533 -0
- package/dist/web-auth/Entities.js +78 -0
- package/dist/web-auth/Helper.d.ts +24 -0
- package/dist/web-auth/Helper.js +89 -0
- package/dist/web-auth/LoginService.d.ts +103 -0
- package/dist/web-auth/LoginService.js +248 -0
- package/dist/web-auth/TokenService.d.ts +48 -0
- package/dist/web-auth/TokenService.js +160 -0
- package/dist/web-auth/UserService.d.ts +143 -0
- package/dist/web-auth/UserService.js +311 -0
- package/dist/web-auth/VerificationService.d.ts +125 -0
- package/dist/web-auth/VerificationService.js +251 -0
- package/dist/web-auth/WebAuth.d.ts +882 -0
- package/dist/web-auth/WebAuth.js +1570 -0
- package/package.json +7 -8
- package/src/main/global.d.ts +0 -10
- package/src/main/index.ts +0 -6
- package/src/main/web-auth/ConsentService.ts +0 -76
- package/src/main/web-auth/Entities.ts +0 -610
- package/src/main/web-auth/Helper.ts +0 -75
- package/src/main/web-auth/LoginService.ts +0 -249
- package/src/main/web-auth/TokenService.ts +0 -106
- package/src/main/web-auth/UserService.ts +0 -297
- package/src/main/web-auth/VerificationService.ts +0 -247
- package/src/main/web-auth/WebAuth.ts +0 -1516
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { Helper, CustomException } from "./Helper";
|
|
2
|
-
import {
|
|
3
|
-
IUserEntity,
|
|
4
|
-
LoginFormRequestEntity,
|
|
5
|
-
PhysicalVerificationLoginRequest,
|
|
6
|
-
LoginFormRequestAsyncEntity,
|
|
7
|
-
IChangePasswordEntity
|
|
8
|
-
} from "./Entities"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export namespace LoginService {
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* login with username and password
|
|
15
|
-
* @param options
|
|
16
|
-
*/
|
|
17
|
-
export function loginWithCredentials(options: LoginFormRequestEntity) {
|
|
18
|
-
try {
|
|
19
|
-
const url = window.webAuthSettings.authority + "/login-srv/login";
|
|
20
|
-
let form = Helper.createForm(url, options)
|
|
21
|
-
document.body.appendChild(form);
|
|
22
|
-
form.submit();
|
|
23
|
-
} catch (ex) {
|
|
24
|
-
throw new CustomException(ex, 417);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* login with username and password and return response
|
|
30
|
-
* @param options
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
export function loginWithCredentialsAsynFn(options: LoginFormRequestAsyncEntity) {
|
|
34
|
-
try {
|
|
35
|
-
var searchParams = new URLSearchParams(options);
|
|
36
|
-
var response = fetch(window.webAuthSettings.authority + "/login-srv/login", {
|
|
37
|
-
method: "POST",
|
|
38
|
-
redirect: "follow",
|
|
39
|
-
body: searchParams.toString(),
|
|
40
|
-
headers: {
|
|
41
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return response;
|
|
46
|
-
} catch (ex) {
|
|
47
|
-
throw new CustomException(ex, 417);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* login with social
|
|
53
|
-
* @param options
|
|
54
|
-
* @param queryParams
|
|
55
|
-
*/
|
|
56
|
-
export function loginWithSocial(
|
|
57
|
-
options: { provider: string; requestId: string; },
|
|
58
|
-
queryParams: { dc: string; device_fp: string }
|
|
59
|
-
) {
|
|
60
|
-
try {
|
|
61
|
-
var _serviceURL = window.webAuthSettings.authority + "/login-srv/social/login/" + options.provider.toLowerCase() + "/" + options.requestId;
|
|
62
|
-
if (queryParams && queryParams.dc && queryParams.device_fp) {
|
|
63
|
-
_serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
|
|
64
|
-
}
|
|
65
|
-
window.location.href = _serviceURL;
|
|
66
|
-
} catch (ex) {
|
|
67
|
-
console.log(ex);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* with social
|
|
73
|
-
* @param options
|
|
74
|
-
* @param queryParams
|
|
75
|
-
*/
|
|
76
|
-
export function registerWithSocial(
|
|
77
|
-
options: { provider: string; requestId: string; },
|
|
78
|
-
queryParams: { dc: string; device_fp: string }) {
|
|
79
|
-
try {
|
|
80
|
-
var _serviceURL = window.webAuthSettings.authority + "/login-srv/social/register/" + options.provider.toLowerCase() + "/" + options.requestId;
|
|
81
|
-
if (queryParams && queryParams.dc && queryParams.device_fp) {
|
|
82
|
-
_serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
|
|
83
|
-
}
|
|
84
|
-
window.location.href = _serviceURL;
|
|
85
|
-
} catch (ex) {
|
|
86
|
-
console.log(ex);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* passwordless login
|
|
92
|
-
* @param options
|
|
93
|
-
*/
|
|
94
|
-
export function passwordlessLogin(options: PhysicalVerificationLoginRequest) {
|
|
95
|
-
try {
|
|
96
|
-
const url = window.webAuthSettings.authority + "/login-srv/verification/login";
|
|
97
|
-
let form = Helper.createForm(url, options)
|
|
98
|
-
document.body.appendChild(form);
|
|
99
|
-
form.submit();
|
|
100
|
-
} catch (ex) {
|
|
101
|
-
throw new CustomException(ex, 417);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* scope consent continue after token pre check
|
|
107
|
-
* @param options
|
|
108
|
-
*/
|
|
109
|
-
export function scopeConsentContinue(options: { track_id: string }) {
|
|
110
|
-
try {
|
|
111
|
-
var form = document.createElement('form');
|
|
112
|
-
form.action = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
113
|
-
form.method = 'POST';
|
|
114
|
-
document.body.appendChild(form);
|
|
115
|
-
form.submit();
|
|
116
|
-
} catch (ex) {
|
|
117
|
-
throw new CustomException(ex, 417);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* claim consent continue login
|
|
123
|
-
* @param options
|
|
124
|
-
*/
|
|
125
|
-
export function claimConsentContinue(options: { track_id: string }) {
|
|
126
|
-
try {
|
|
127
|
-
var form = document.createElement('form');
|
|
128
|
-
form.action = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
129
|
-
form.method = 'POST';
|
|
130
|
-
document.body.appendChild(form);
|
|
131
|
-
form.submit();
|
|
132
|
-
} catch (ex) {
|
|
133
|
-
throw new CustomException(ex, 417);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* consent continue login
|
|
139
|
-
* @param options
|
|
140
|
-
*/
|
|
141
|
-
export function consentContinue(options: {
|
|
142
|
-
client_id: string;
|
|
143
|
-
consent_refs: string[];
|
|
144
|
-
sub: string;
|
|
145
|
-
scopes: string[];
|
|
146
|
-
matcher: any;
|
|
147
|
-
track_id: string;
|
|
148
|
-
}) {
|
|
149
|
-
try {
|
|
150
|
-
const url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
151
|
-
let form = Helper.createForm(url, options)
|
|
152
|
-
document.body.appendChild(form);
|
|
153
|
-
form.submit();
|
|
154
|
-
} catch (ex) {
|
|
155
|
-
throw new CustomException(ex, 417);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* mfa continue login
|
|
161
|
-
* @param options
|
|
162
|
-
*/
|
|
163
|
-
export function mfaContinue(options: PhysicalVerificationLoginRequest & { track_id: string }) {
|
|
164
|
-
try {
|
|
165
|
-
const url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
166
|
-
let form = Helper.createForm(url, options)
|
|
167
|
-
document.body.appendChild(form);
|
|
168
|
-
form.submit();
|
|
169
|
-
} catch (ex) {
|
|
170
|
-
throw new CustomException(ex, 417);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* change password continue
|
|
176
|
-
* @param options
|
|
177
|
-
*/
|
|
178
|
-
export function firstTimeChangePassword(options: IChangePasswordEntity) {
|
|
179
|
-
try {
|
|
180
|
-
const url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.loginSettingsId;;
|
|
181
|
-
let form = Helper.createForm(url, options)
|
|
182
|
-
document.body.appendChild(form);
|
|
183
|
-
form.submit();
|
|
184
|
-
} catch (ex) {
|
|
185
|
-
throw new CustomException(ex, 417);
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* progressiveRegistration
|
|
191
|
-
* @param options
|
|
192
|
-
* @param headers
|
|
193
|
-
* @returns
|
|
194
|
-
*/
|
|
195
|
-
export function progressiveRegistration(options: IUserEntity, headers: {
|
|
196
|
-
requestId: string;
|
|
197
|
-
trackId: string;
|
|
198
|
-
acceptlanguage: string;
|
|
199
|
-
}) {
|
|
200
|
-
return new Promise((resolve, reject) => {
|
|
201
|
-
try {
|
|
202
|
-
var http = new XMLHttpRequest();
|
|
203
|
-
var _serviceURL = window.webAuthSettings.authority + "/login-srv/progressive/update/user";
|
|
204
|
-
http.onreadystatechange = function () {
|
|
205
|
-
if (http.readyState == 4) {
|
|
206
|
-
if (http.responseText) {
|
|
207
|
-
resolve(JSON.parse(http.responseText));
|
|
208
|
-
} else {
|
|
209
|
-
resolve(undefined);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
http.open("POST", _serviceURL, true);
|
|
214
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
215
|
-
http.setRequestHeader("requestId", headers.requestId);
|
|
216
|
-
http.setRequestHeader("trackId", headers.trackId);
|
|
217
|
-
if (headers.acceptlanguage) {
|
|
218
|
-
http.setRequestHeader("accept-language", headers.acceptlanguage);
|
|
219
|
-
} else if (window.localeSettings) {
|
|
220
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
221
|
-
}
|
|
222
|
-
http.send(JSON.stringify(options));
|
|
223
|
-
} catch (ex) {
|
|
224
|
-
reject(ex);
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* loginAfterRegister
|
|
231
|
-
* @param options
|
|
232
|
-
*/
|
|
233
|
-
export function loginAfterRegister(options: {
|
|
234
|
-
device_id?: string;
|
|
235
|
-
dc?: string;
|
|
236
|
-
rememberMe?: boolean;
|
|
237
|
-
trackId?: string;
|
|
238
|
-
device_fp?: string;
|
|
239
|
-
}) {
|
|
240
|
-
try {
|
|
241
|
-
const url = window.webAuthSettings.authority + "/login-srv/login/handle/afterregister/" + options.trackId;
|
|
242
|
-
let form = Helper.createForm(url, options)
|
|
243
|
-
document.body.appendChild(form);
|
|
244
|
-
form.submit();
|
|
245
|
-
} catch (ex) {
|
|
246
|
-
throw new CustomException(ex, 417);
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { AccessTokenRequest, TokenIntrospectionEntity, ISuggestedMFAActionConfig } from "./Entities"
|
|
2
|
-
import { Helper, CustomException } from "./Helper";
|
|
3
|
-
|
|
4
|
-
export namespace TokenService {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* renew token using refresh token
|
|
8
|
-
* @param options
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
export function renewToken(options: AccessTokenRequest) {
|
|
12
|
-
if (!options.refresh_token) {
|
|
13
|
-
throw new CustomException("refresh_token cannot be empty", 417);
|
|
14
|
-
}
|
|
15
|
-
options.client_id = window.webAuthSettings.client_id;
|
|
16
|
-
options.grant_type = 'refresh_token';
|
|
17
|
-
const _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
18
|
-
return Helper.createPostPromise(options, _serviceURL, undefined, "POST");
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* get access token from code
|
|
23
|
-
* @param options
|
|
24
|
-
* @returns
|
|
25
|
-
*/
|
|
26
|
-
export async function getAccessToken(options: AccessTokenRequest) {
|
|
27
|
-
if (!options.code) {
|
|
28
|
-
throw new CustomException("code cannot be empty", 417);
|
|
29
|
-
}
|
|
30
|
-
options.client_id = window.webAuthSettings.client_id;
|
|
31
|
-
options.redirect_uri = window.webAuthSettings.redirect_uri;
|
|
32
|
-
options.grant_type = "authorization_code";
|
|
33
|
-
if (!window.webAuthSettings.disablePKCE) {
|
|
34
|
-
var signInRequest = await window.usermanager._client.createSigninRequest(window.webAuthSettings);
|
|
35
|
-
options.code_verifier = signInRequest.state?.code_verifier;
|
|
36
|
-
}
|
|
37
|
-
const _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
38
|
-
return Helper.createPostPromise(options, _serviceURL, undefined, "POST");
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* validate access token
|
|
43
|
-
* @param options
|
|
44
|
-
* @returns
|
|
45
|
-
*/
|
|
46
|
-
export function validateAccessToken(options: TokenIntrospectionEntity) {
|
|
47
|
-
if (!options.token || !options.token_type_hint) {
|
|
48
|
-
throw new CustomException("token or token_type_hint cannot be empty", 417);
|
|
49
|
-
}
|
|
50
|
-
const _serviceURL = window.webAuthSettings.authority + "/token-srv/introspect";
|
|
51
|
-
return Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* get scope consent details
|
|
56
|
-
* @param options
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
export function getScopeConsentDetails(options: {
|
|
60
|
-
track_id: string;
|
|
61
|
-
locale: string;
|
|
62
|
-
}) {
|
|
63
|
-
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + options.track_id + "?acceptLanguage=" + options.locale;
|
|
64
|
-
return Helper.createPostPromise(undefined, _serviceURL, false, "GET");
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* updateSuggestMFA
|
|
69
|
-
* @param track_id
|
|
70
|
-
* @param options
|
|
71
|
-
* @returns
|
|
72
|
-
*/
|
|
73
|
-
export function updateSuggestMFA(track_id: string, options: ISuggestedMFAActionConfig) {
|
|
74
|
-
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/suggested/mfa/update/" + track_id;
|
|
75
|
-
return Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* getMissingFieldsLogin
|
|
80
|
-
* @param trackId
|
|
81
|
-
* @returns
|
|
82
|
-
*/
|
|
83
|
-
export function getMissingFieldsLogin(trackId: string) {
|
|
84
|
-
const _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + trackId;
|
|
85
|
-
return Helper.createPostPromise(undefined, _serviceURL, false, "GET");
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* device code flow - verify
|
|
90
|
-
* @param code
|
|
91
|
-
*/
|
|
92
|
-
export function deviceCodeVerify(code: string) {
|
|
93
|
-
var params = `user_code=${encodeURI(code)}`;
|
|
94
|
-
var url = `${window.webAuthSettings.authority}/token-srv/device/verify?${params}`;
|
|
95
|
-
try {
|
|
96
|
-
const options = {
|
|
97
|
-
user_code: encodeURI(code)
|
|
98
|
-
}
|
|
99
|
-
let form = Helper.createForm(url, options, 'GET');
|
|
100
|
-
document.body.appendChild(form);
|
|
101
|
-
form.submit();
|
|
102
|
-
} catch (ex) {
|
|
103
|
-
throw new Error(ex);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UserEntity,
|
|
3
|
-
ResetPasswordEntity,
|
|
4
|
-
FindUserEntity,
|
|
5
|
-
IUserLinkEntity,
|
|
6
|
-
ChangePasswordEntity,
|
|
7
|
-
ValidateResetPasswordEntity,
|
|
8
|
-
AcceptResetPasswordEntity,
|
|
9
|
-
} from "./Entities"
|
|
10
|
-
import { Helper, CustomException } from "./Helper";
|
|
11
|
-
|
|
12
|
-
export namespace UserService {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* get user info
|
|
16
|
-
* @param options
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
export function getUserProfile(options: { access_token: string }) {
|
|
20
|
-
if (!options.access_token) {
|
|
21
|
-
throw new CustomException("access_token cannot be empty", 417);
|
|
22
|
-
}
|
|
23
|
-
const _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo";
|
|
24
|
-
return Helper.createPostPromise(undefined, _serviceURL, undefined, "GET", options.access_token);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* register user
|
|
29
|
-
* @param options
|
|
30
|
-
* @param headers
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
export function register(options: UserEntity, headers: {
|
|
34
|
-
requestId: string;
|
|
35
|
-
captcha?: string;
|
|
36
|
-
acceptlanguage?: string;
|
|
37
|
-
bot_captcha_response?: string;
|
|
38
|
-
trackId?: string;
|
|
39
|
-
}) {
|
|
40
|
-
return new Promise((resolve, reject) => {
|
|
41
|
-
try {
|
|
42
|
-
|
|
43
|
-
var http = new XMLHttpRequest();
|
|
44
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/register";
|
|
45
|
-
if (options.invite_id) {
|
|
46
|
-
_serviceURL = _serviceURL + "?invite_id=" + options.invite_id;
|
|
47
|
-
}
|
|
48
|
-
http.onreadystatechange = function () {
|
|
49
|
-
if (http.readyState == 4) {
|
|
50
|
-
if (http.responseText) {
|
|
51
|
-
resolve(JSON.parse(http.responseText));
|
|
52
|
-
} else {
|
|
53
|
-
resolve(false);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
http.open("POST", _serviceURL, true);
|
|
58
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
59
|
-
http.setRequestHeader("requestId", headers.requestId);
|
|
60
|
-
if (headers.captcha) {
|
|
61
|
-
http.setRequestHeader("captcha", headers.captcha);
|
|
62
|
-
}
|
|
63
|
-
if (headers.acceptlanguage) {
|
|
64
|
-
http.setRequestHeader("accept-language", headers.acceptlanguage);
|
|
65
|
-
} else if (window.localeSettings) {
|
|
66
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
67
|
-
}
|
|
68
|
-
if (headers.bot_captcha_response) {
|
|
69
|
-
http.setRequestHeader("bot_captcha_response", headers.bot_captcha_response);
|
|
70
|
-
}
|
|
71
|
-
if (headers.trackId) {
|
|
72
|
-
http.setRequestHeader("trackid", headers.trackId);
|
|
73
|
-
}
|
|
74
|
-
http.send(JSON.stringify(options));
|
|
75
|
-
} catch (ex) {
|
|
76
|
-
reject(ex);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* get invite info
|
|
83
|
-
* @param options
|
|
84
|
-
* @returns
|
|
85
|
-
*/
|
|
86
|
-
export function getInviteUserDetails(options: { invite_id: string }) {
|
|
87
|
-
const _serviceURL = window.webAuthSettings.authority + "/users-srv/invite/info/" + options.invite_id;
|
|
88
|
-
return Helper.createPostPromise(undefined, _serviceURL, false, "GET");
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* get Communication status
|
|
93
|
-
* @param options
|
|
94
|
-
* @returns
|
|
95
|
-
*/
|
|
96
|
-
export function getCommunicationStatus(options: { sub: string, requestId: string }) {
|
|
97
|
-
return new Promise((resolve, reject) => {
|
|
98
|
-
try {
|
|
99
|
-
var http = new XMLHttpRequest();
|
|
100
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/communication/status/" + options.sub;
|
|
101
|
-
http.onreadystatechange = function () {
|
|
102
|
-
if (http.readyState == 4) {
|
|
103
|
-
if (http.responseText) {
|
|
104
|
-
resolve(JSON.parse(http.responseText));
|
|
105
|
-
} else {
|
|
106
|
-
resolve(false);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
http.open("GET", _serviceURL, true);
|
|
111
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
112
|
-
if (options.requestId) {
|
|
113
|
-
http.setRequestHeader("requestId", options.requestId);
|
|
114
|
-
}
|
|
115
|
-
if (window.localeSettings) {
|
|
116
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
117
|
-
}
|
|
118
|
-
http.send();
|
|
119
|
-
} catch (ex) {
|
|
120
|
-
reject(ex);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* initiate reset password
|
|
127
|
-
* @param options
|
|
128
|
-
* @returns
|
|
129
|
-
*/
|
|
130
|
-
export function initiateResetPassword(options: ResetPasswordEntity) {
|
|
131
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/resetpassword/initiate";
|
|
132
|
-
return Helper.createPostPromise(options, _serviceURL, false, "POST");
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* handle reset password
|
|
137
|
-
* @param options
|
|
138
|
-
*/
|
|
139
|
-
export function handleResetPassword(options: ValidateResetPasswordEntity) {
|
|
140
|
-
try {
|
|
141
|
-
const url = window.webAuthSettings.authority + "/users-srv/resetpassword/validatecode";
|
|
142
|
-
if (window.webAuthSettings.cidaas_version > 2) {
|
|
143
|
-
let form = Helper.createForm(url, options)
|
|
144
|
-
document.body.appendChild(form);
|
|
145
|
-
form.submit();
|
|
146
|
-
} else {
|
|
147
|
-
return Helper.createPostPromise(options, url, false, "POST");
|
|
148
|
-
}
|
|
149
|
-
} catch (ex) {
|
|
150
|
-
throw new CustomException(ex, 417);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* reset password
|
|
156
|
-
* @param options
|
|
157
|
-
*/
|
|
158
|
-
export function resetPassword(options: AcceptResetPasswordEntity) {
|
|
159
|
-
const url = window.webAuthSettings.authority + "/users-srv/resetpassword/accept";
|
|
160
|
-
try {
|
|
161
|
-
if (window.webAuthSettings.cidaas_version > 2) {
|
|
162
|
-
let form = Helper.createForm(url, options)
|
|
163
|
-
document.body.appendChild(form);
|
|
164
|
-
form.submit();
|
|
165
|
-
} else {
|
|
166
|
-
return Helper.createPostPromise(options, url, false, "POST");
|
|
167
|
-
}
|
|
168
|
-
} catch (ex) {
|
|
169
|
-
throw new CustomException(ex, 417);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* get Deduplication details
|
|
175
|
-
* @param options
|
|
176
|
-
* @returns
|
|
177
|
-
*/
|
|
178
|
-
export function getDeduplicationDetails(options: { trackId: string }) {
|
|
179
|
-
const _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/info/" + options.trackId;
|
|
180
|
-
return Helper.createPostPromise(options, _serviceURL, false, "GET", undefined);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* deduplication login
|
|
185
|
-
* @param options
|
|
186
|
-
*/
|
|
187
|
-
export function deduplicationLogin(options: { trackId: string, requestId: string, sub: string }) {
|
|
188
|
-
try {
|
|
189
|
-
var form = document.createElement('form');
|
|
190
|
-
form.action = window.webAuthSettings.authority + "/users-srv/deduplication/login/redirection?trackId=" + options.trackId + "&requestId=" + options.requestId + "&sub=" + options.sub;
|
|
191
|
-
form.method = 'POST';
|
|
192
|
-
document.body.appendChild(form);
|
|
193
|
-
form.submit();
|
|
194
|
-
} catch (ex) {
|
|
195
|
-
throw new CustomException(ex, 417);
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* register Deduplication
|
|
201
|
-
* @param options
|
|
202
|
-
* @returns
|
|
203
|
-
*/
|
|
204
|
-
export function registerDeduplication(options: { trackId: string }) {
|
|
205
|
-
const _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/register/" + options.trackId;
|
|
206
|
-
return Helper.createPostPromise(undefined, _serviceURL, undefined, "POST");
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* change password
|
|
211
|
-
* @param options
|
|
212
|
-
* @param access_token
|
|
213
|
-
* @returns
|
|
214
|
-
*/
|
|
215
|
-
export function changePassword(options: ChangePasswordEntity, access_token: string) {
|
|
216
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/changepassword";
|
|
217
|
-
return Helper.createPostPromise(options, _serviceURL, false, "POST", access_token);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* update profile
|
|
222
|
-
* @param options
|
|
223
|
-
* @param access_token
|
|
224
|
-
* @param sub
|
|
225
|
-
* @returns
|
|
226
|
-
*/
|
|
227
|
-
export function updateProfile(options: UserEntity, access_token: string, sub: string) {
|
|
228
|
-
const _serviceURL = window.webAuthSettings.authority + "/users-srv/user/profile/" + sub;
|
|
229
|
-
return Helper.createPostPromise(options, _serviceURL, false, "PUT", access_token);
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* initiate link accoount
|
|
234
|
-
* @param options
|
|
235
|
-
* @param access_token
|
|
236
|
-
* @returns
|
|
237
|
-
*/
|
|
238
|
-
export function initiateLinkAccount(options: IUserLinkEntity, access_token: string) {
|
|
239
|
-
options.user_name_type = 'email';
|
|
240
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/initiate";
|
|
241
|
-
return Helper.createPostPromise(options, _serviceURL, false, "POST", access_token);
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* complete link accoount
|
|
246
|
-
* @param options
|
|
247
|
-
* @param access_token
|
|
248
|
-
* @returns
|
|
249
|
-
*/
|
|
250
|
-
export function completeLinkAccount(options: { code?: string; link_request_id?: string; }, access_token: string) {
|
|
251
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/complete";
|
|
252
|
-
return Helper.createPostPromise(options, _serviceURL, false, "POST", access_token);
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* get linked users
|
|
257
|
-
* @param access_token
|
|
258
|
-
* @param sub
|
|
259
|
-
* @returns
|
|
260
|
-
*/
|
|
261
|
-
export function getLinkedUsers(access_token: string, sub: string) {
|
|
262
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo/social/" + sub;
|
|
263
|
-
return Helper.createPostPromise(undefined, _serviceURL, false, "POST", access_token);
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* unlink accoount
|
|
268
|
-
* @param access_token
|
|
269
|
-
* @param identityId
|
|
270
|
-
* @returns
|
|
271
|
-
*/
|
|
272
|
-
export function unlinkAccount(access_token: string, identityId: string) {
|
|
273
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unlink/" + identityId;
|
|
274
|
-
return Helper.createPostPromise(undefined, _serviceURL, false, "POST", access_token);
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* deleteUserAccount
|
|
279
|
-
* @param options
|
|
280
|
-
* @returns
|
|
281
|
-
*/
|
|
282
|
-
export function deleteUserAccount(options: { access_token: string, sub: string }) {
|
|
283
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unregister/scheduler/schedule/" + options.sub;
|
|
284
|
-
return Helper.createPostPromise(options, _serviceURL, undefined, "POST", options.access_token);
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* check if an user exists from users-actions-srv
|
|
290
|
-
* @param options
|
|
291
|
-
* @returns
|
|
292
|
-
*/
|
|
293
|
-
export function userCheckExists(options: FindUserEntity) {
|
|
294
|
-
var _serviceURL = window.webAuthSettings.authority + "/useractions-srv/userexistence/" + options.requestId + "?webfinger=" + options.webfinger + "&rememberMe=" + options.rememberMe;
|
|
295
|
-
return Helper.createPostPromise(options, _serviceURL, undefined, "POST");
|
|
296
|
-
};
|
|
297
|
-
}
|