cidaas-javascript-sdk 2.4.3 → 2.5.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/CHANGELOG.md +5 -3
- package/README.md +2 -3
- package/package.json +10 -12
- package/src/main/authentication/index.ts +223 -0
- package/src/main/global.d.ts +10 -0
- package/src/main/index.ts +6 -0
- package/src/main/web-auth/ConsentService.ts +98 -0
- package/src/main/web-auth/Entities.ts +645 -0
- package/src/main/web-auth/Helper.ts +75 -0
- package/src/main/web-auth/LoginService.ts +248 -0
- package/src/main/web-auth/TokenService.ts +196 -0
- package/src/main/web-auth/UserService.ts +388 -0
- package/src/main/web-auth/VerificationService.ts +267 -0
- package/src/main/web-auth/WebAuth.ts +1706 -0
- package/types/authentication/index.d.ts +55 -0
- package/types/authentication/index.js +262 -0
- package/types/index.d.ts +4 -0
- package/types/index.js +9 -0
- package/types/web-auth/ConsentService.d.ts +59 -0
- package/types/web-auth/ConsentService.js +97 -0
- package/types/web-auth/Entities.d.ts +567 -0
- package/types/web-auth/Entities.js +88 -0
- package/types/web-auth/Helper.d.ts +24 -0
- package/types/web-auth/Helper.js +89 -0
- package/types/web-auth/LoginService.d.ts +102 -0
- package/types/web-auth/LoginService.js +248 -0
- package/types/web-auth/TokenService.d.ts +48 -0
- package/types/web-auth/TokenService.js +210 -0
- package/types/web-auth/UserService.d.ts +143 -0
- package/types/web-auth/UserService.js +408 -0
- package/types/web-auth/VerificationService.d.ts +125 -0
- package/types/web-auth/VerificationService.js +273 -0
- package/types/web-auth/WebAuth.d.ts +895 -0
- package/types/web-auth/WebAuth.js +1767 -0
- package/src/main/.gitkeep +0 -0
- package/src/main/authentication/index.js +0 -213
- package/src/main/index.js +0 -11
- package/src/main/web-auth/exception.js +0 -7
- package/src/main/web-auth/webauth.js +0 -1899
- package/src/test/sum.js +0 -4
- package/src/test/test.js +0 -5
- package/types/.DS_Store +0 -0
- package/types/main/authentication/index.d.ts +0 -15
- package/types/main/index.d.ts +0 -5
- package/types/main/web-auth/exception.d.ts +0 -7
- package/types/main/web-auth/webauth.d.ts +0 -141
- package/types/test/sum.d.ts +0 -2
- package/types/test/test.d.ts +0 -1
|
@@ -0,0 +1,388 @@
|
|
|
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
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
try {
|
|
22
|
+
if (!options.access_token) {
|
|
23
|
+
throw new CustomException("access_token cannot be empty", 417);
|
|
24
|
+
}
|
|
25
|
+
var http = new XMLHttpRequest();
|
|
26
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo";
|
|
27
|
+
http.onreadystatechange = function () {
|
|
28
|
+
if (http.readyState == 4) {
|
|
29
|
+
resolve(JSON.parse(http.responseText));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
http.open("GET", _serviceURL, true);
|
|
33
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
34
|
+
http.setRequestHeader("Authorization", `Bearer ${options.access_token}`);
|
|
35
|
+
if (window.localeSettings) {
|
|
36
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
37
|
+
}
|
|
38
|
+
http.send();
|
|
39
|
+
} catch (ex) {
|
|
40
|
+
reject(ex);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* register user
|
|
47
|
+
* @param options
|
|
48
|
+
* @param headers
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
export function register(options: UserEntity, headers: {
|
|
52
|
+
requestId: string;
|
|
53
|
+
captcha?: string;
|
|
54
|
+
acceptlanguage?: string;
|
|
55
|
+
bot_captcha_response?: string;
|
|
56
|
+
trackId: string;
|
|
57
|
+
}) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
try {
|
|
60
|
+
|
|
61
|
+
var http = new XMLHttpRequest();
|
|
62
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/register";
|
|
63
|
+
if (options.invite_id) {
|
|
64
|
+
_serviceURL = _serviceURL + "?invite_id=" + options.invite_id;
|
|
65
|
+
}
|
|
66
|
+
http.onreadystatechange = function () {
|
|
67
|
+
if (http.readyState == 4) {
|
|
68
|
+
if (http.responseText) {
|
|
69
|
+
resolve(JSON.parse(http.responseText));
|
|
70
|
+
} else {
|
|
71
|
+
resolve(false);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
http.open("POST", _serviceURL, true);
|
|
76
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
77
|
+
http.setRequestHeader("requestId", headers.requestId);
|
|
78
|
+
if (headers.captcha) {
|
|
79
|
+
http.setRequestHeader("captcha", headers.captcha);
|
|
80
|
+
}
|
|
81
|
+
if (headers.acceptlanguage) {
|
|
82
|
+
http.setRequestHeader("accept-language", headers.acceptlanguage);
|
|
83
|
+
} else if (window.localeSettings) {
|
|
84
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
85
|
+
}
|
|
86
|
+
if (headers.bot_captcha_response) {
|
|
87
|
+
http.setRequestHeader("bot_captcha_response", headers.bot_captcha_response);
|
|
88
|
+
}
|
|
89
|
+
if (headers.trackId) {
|
|
90
|
+
http.setRequestHeader("trackid", headers.trackId);
|
|
91
|
+
}
|
|
92
|
+
http.send(JSON.stringify(options));
|
|
93
|
+
} catch (ex) {
|
|
94
|
+
reject(ex);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* get invite info
|
|
101
|
+
* @param options
|
|
102
|
+
* @returns
|
|
103
|
+
*/
|
|
104
|
+
export function getInviteUserDetails(options: { invite_id: string }) {
|
|
105
|
+
return new Promise((resolve, reject) => {
|
|
106
|
+
try {
|
|
107
|
+
var http = new XMLHttpRequest();
|
|
108
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/invite/info/" + options.invite_id;
|
|
109
|
+
http.onreadystatechange = function () {
|
|
110
|
+
if (http.readyState == 4) {
|
|
111
|
+
if (http.responseText) {
|
|
112
|
+
resolve(JSON.parse(http.responseText));
|
|
113
|
+
} else {
|
|
114
|
+
resolve(false);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
http.open("GET", _serviceURL, true);
|
|
119
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
120
|
+
if (window.localeSettings) {
|
|
121
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
122
|
+
}
|
|
123
|
+
http.send();
|
|
124
|
+
} catch (ex) {
|
|
125
|
+
reject(ex);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* get Communication status
|
|
132
|
+
* @param options
|
|
133
|
+
* @returns
|
|
134
|
+
*/
|
|
135
|
+
export function getCommunicationStatus(options: { sub: string, requestId: string }) {
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
137
|
+
try {
|
|
138
|
+
var http = new XMLHttpRequest();
|
|
139
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/communication/status/" + options.sub;
|
|
140
|
+
http.onreadystatechange = function () {
|
|
141
|
+
if (http.readyState == 4) {
|
|
142
|
+
if (http.responseText) {
|
|
143
|
+
resolve(JSON.parse(http.responseText));
|
|
144
|
+
} else {
|
|
145
|
+
resolve(false);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
http.open("GET", _serviceURL, true);
|
|
150
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
151
|
+
if (options.requestId) {
|
|
152
|
+
http.setRequestHeader("requestId", options.requestId);
|
|
153
|
+
}
|
|
154
|
+
if (window.localeSettings) {
|
|
155
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
156
|
+
}
|
|
157
|
+
http.send();
|
|
158
|
+
} catch (ex) {
|
|
159
|
+
reject(ex);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* initiate reset password
|
|
166
|
+
* @param options
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
export function initiateResetPassword(options: ResetPasswordEntity) {
|
|
170
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/resetpassword/initiate";
|
|
171
|
+
return Helper.createPostPromise(options, _serviceURL, false);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* handle reset password
|
|
176
|
+
* @param options
|
|
177
|
+
*/
|
|
178
|
+
export function handleResetPassword(options: ValidateResetPasswordEntity) {
|
|
179
|
+
try {
|
|
180
|
+
const url = window.webAuthSettings.authority + "/users-srv/resetpassword/validatecode";
|
|
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
|
+
* reset password
|
|
191
|
+
* @param options
|
|
192
|
+
*/
|
|
193
|
+
export function resetPassword(options: AcceptResetPasswordEntity) {
|
|
194
|
+
try {
|
|
195
|
+
const url = window.webAuthSettings.authority + "/users-srv/resetpassword/accept";
|
|
196
|
+
let form = Helper.createForm(url, options)
|
|
197
|
+
document.body.appendChild(form);
|
|
198
|
+
form.submit();
|
|
199
|
+
} catch (ex) {
|
|
200
|
+
throw new CustomException(ex, 417);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* get Deduplication details
|
|
206
|
+
* @param options
|
|
207
|
+
* @returns
|
|
208
|
+
*/
|
|
209
|
+
export function getDeduplicationDetails(options: { trackId: string }) {
|
|
210
|
+
return new Promise((resolve, reject) => {
|
|
211
|
+
try {
|
|
212
|
+
var http = new XMLHttpRequest();
|
|
213
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/info/" + options.trackId;
|
|
214
|
+
http.onreadystatechange = function () {
|
|
215
|
+
if (http.readyState == 4) {
|
|
216
|
+
if (http.responseText) {
|
|
217
|
+
resolve(JSON.parse(http.responseText));
|
|
218
|
+
} else {
|
|
219
|
+
resolve(false);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
http.open("GET", _serviceURL, true);
|
|
224
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
225
|
+
if (window.localeSettings) {
|
|
226
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
227
|
+
}
|
|
228
|
+
http.send();
|
|
229
|
+
} catch (ex) {
|
|
230
|
+
reject(ex);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* deduplication login
|
|
237
|
+
* @param options
|
|
238
|
+
*/
|
|
239
|
+
export function deduplicationLogin(options: { trackId: string, requestId: string, sub: string }) {
|
|
240
|
+
try {
|
|
241
|
+
var form = document.createElement('form');
|
|
242
|
+
form.action = window.webAuthSettings.authority + "/users-srv/deduplication/login/redirection?trackId=" + options.trackId + "&requestId=" + options.requestId + "&sub=" + options.sub;
|
|
243
|
+
form.method = 'POST';
|
|
244
|
+
document.body.appendChild(form);
|
|
245
|
+
form.submit();
|
|
246
|
+
} catch (ex) {
|
|
247
|
+
throw new CustomException(ex, 417);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* register Deduplication
|
|
253
|
+
* @param options
|
|
254
|
+
* @returns
|
|
255
|
+
*/
|
|
256
|
+
export function registerDeduplication(options: { trackId: string }) {
|
|
257
|
+
return new Promise((resolve, reject) => {
|
|
258
|
+
try {
|
|
259
|
+
var http = new XMLHttpRequest();
|
|
260
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/register/" + options.trackId;
|
|
261
|
+
http.onreadystatechange = function () {
|
|
262
|
+
if (http.readyState == 4) {
|
|
263
|
+
resolve(JSON.parse(http.responseText));
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
http.open("POST", _serviceURL, true);
|
|
267
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
268
|
+
if (window.localeSettings) {
|
|
269
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
270
|
+
}
|
|
271
|
+
http.send();
|
|
272
|
+
} catch (ex) {
|
|
273
|
+
reject(ex);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* change password
|
|
280
|
+
* @param options
|
|
281
|
+
* @param access_token
|
|
282
|
+
* @returns
|
|
283
|
+
*/
|
|
284
|
+
export function changePassword(options: ChangePasswordEntity, access_token: string) {
|
|
285
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/changepassword";
|
|
286
|
+
return Helper.createPostPromise(options, _serviceURL, false, access_token);
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* update profile
|
|
291
|
+
* @param options
|
|
292
|
+
* @param access_token
|
|
293
|
+
* @param sub
|
|
294
|
+
* @returns
|
|
295
|
+
*/
|
|
296
|
+
export function updateProfile(options: UserEntity, access_token: string, sub: string) {
|
|
297
|
+
return new Promise((resolve, reject) => {
|
|
298
|
+
try {
|
|
299
|
+
var http = new XMLHttpRequest();
|
|
300
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/profile/" + sub;
|
|
301
|
+
http.onreadystatechange = function () {
|
|
302
|
+
if (http.readyState == 4) {
|
|
303
|
+
if (http.responseText) {
|
|
304
|
+
resolve(JSON.parse(http.responseText));
|
|
305
|
+
} else {
|
|
306
|
+
resolve(false);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
http.open("PUT", _serviceURL, true);
|
|
311
|
+
http.setRequestHeader("Content-type", "application/json");
|
|
312
|
+
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
313
|
+
if (window.localeSettings) {
|
|
314
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
315
|
+
}
|
|
316
|
+
http.send(JSON.stringify(options));
|
|
317
|
+
} catch (ex) {
|
|
318
|
+
throw new CustomException(ex, 417);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* initiate link accoount
|
|
325
|
+
* @param options
|
|
326
|
+
* @param access_token
|
|
327
|
+
* @returns
|
|
328
|
+
*/
|
|
329
|
+
export function initiateLinkAccount(options: IUserLinkEntity, access_token: string) {
|
|
330
|
+
options.user_name_type = 'email';
|
|
331
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/initiate";
|
|
332
|
+
return Helper.createPostPromise(options, _serviceURL, false, access_token);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* complete link accoount
|
|
337
|
+
* @param options
|
|
338
|
+
* @param access_token
|
|
339
|
+
* @returns
|
|
340
|
+
*/
|
|
341
|
+
export function completeLinkAccount(options: { code?: string; link_request_id?: string; }, access_token: string) {
|
|
342
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/complete";
|
|
343
|
+
return Helper.createPostPromise(options, _serviceURL, false, access_token);
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* get linked users
|
|
348
|
+
* @param access_token
|
|
349
|
+
* @param sub
|
|
350
|
+
* @returns
|
|
351
|
+
*/
|
|
352
|
+
export function getLinkedUsers(access_token: string, sub: string) {
|
|
353
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo/social/" + sub;
|
|
354
|
+
return Helper.createPostPromise(undefined, _serviceURL, false, access_token);
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* unlink accoount
|
|
359
|
+
* @param access_token
|
|
360
|
+
* @param identityId
|
|
361
|
+
* @returns
|
|
362
|
+
*/
|
|
363
|
+
export function unlinkAccount(access_token: string, identityId: string) {
|
|
364
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unlink/" + identityId;
|
|
365
|
+
return Helper.createPostPromise(undefined, _serviceURL, false, access_token);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* deleteUserAccount
|
|
370
|
+
* @param options
|
|
371
|
+
* @returns
|
|
372
|
+
*/
|
|
373
|
+
export function deleteUserAccount(options: { access_token: string, sub: string }) {
|
|
374
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unregister/scheduler/schedule/" + options.sub;
|
|
375
|
+
return Helper.createPostPromise(options, _serviceURL, undefined, options.access_token);
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* check if an user exists
|
|
381
|
+
* @param options
|
|
382
|
+
* @returns
|
|
383
|
+
*/
|
|
384
|
+
export function userCheckExists(options: FindUserEntity) {
|
|
385
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/checkexists/" + options.requestId;
|
|
386
|
+
return Helper.createPostPromise(options, _serviceURL, undefined);
|
|
387
|
+
};
|
|
388
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IConfiguredListRequestEntity,
|
|
3
|
+
IInitVerificationAuthenticationRequestEntity,
|
|
4
|
+
FidoSetupEntity,
|
|
5
|
+
IEnrollVerificationSetupRequestEntity,
|
|
6
|
+
IAuthVerificationAuthenticationRequestEntity,
|
|
7
|
+
FaceVerificationAuthenticationRequestEntity,
|
|
8
|
+
AccountVerificationRequestEntity,
|
|
9
|
+
} from "./Entities"
|
|
10
|
+
import { Helper, CustomException } from "./Helper";
|
|
11
|
+
|
|
12
|
+
export namespace VerificationService {
|
|
13
|
+
/**
|
|
14
|
+
* initiate verification
|
|
15
|
+
* @param options
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export function initiateAccountVerification(options: AccountVerificationRequestEntity) {
|
|
19
|
+
try {
|
|
20
|
+
const url = window.webAuthSettings.authority + "/verification-srv/account/initiate";
|
|
21
|
+
let form = Helper.createForm(url, options)
|
|
22
|
+
document.body.appendChild(form);
|
|
23
|
+
form.submit();
|
|
24
|
+
} catch (ex) {
|
|
25
|
+
throw new CustomException(ex, 417);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* initiate verification and return response
|
|
31
|
+
* @param options
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export function initiateAccountVerificationAsynFn(options: AccountVerificationRequestEntity) {
|
|
35
|
+
try {
|
|
36
|
+
var searchParams = new URLSearchParams(options);
|
|
37
|
+
var response = fetch(window.webAuthSettings.authority + "/verification-srv/account/initiate", {
|
|
38
|
+
method: "POST",
|
|
39
|
+
redirect: "follow",
|
|
40
|
+
body: searchParams.toString(),
|
|
41
|
+
headers: {
|
|
42
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return response;
|
|
47
|
+
} catch (ex) {
|
|
48
|
+
throw new CustomException(ex, 417);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* verify account
|
|
55
|
+
* @param options
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
export function verifyAccount(options: {
|
|
59
|
+
accvid: string;
|
|
60
|
+
code: string;
|
|
61
|
+
}) {
|
|
62
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/account/verify";
|
|
63
|
+
return Helper.createPostPromise(options, _serviceURL, false);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* get mfa list v2
|
|
68
|
+
* @param options
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
export function getMFAListV2(options: IConfiguredListRequestEntity) {
|
|
72
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/public/configured/list";
|
|
73
|
+
return Helper.createPostPromise(options, _serviceURL, false);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* cancel mfa v2
|
|
78
|
+
* @param options
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
export function cancelMFAV2(options: {
|
|
82
|
+
exchange_id: string;
|
|
83
|
+
reason: string;
|
|
84
|
+
type: string;
|
|
85
|
+
}) {
|
|
86
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/cancel/" + options.type;
|
|
87
|
+
return Helper.createPostPromise(options, _serviceURL, undefined);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param access_token
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
94
|
+
export function getAllVerificationList(access_token: string) {
|
|
95
|
+
return new Promise((resolve, reject) => {
|
|
96
|
+
try {
|
|
97
|
+
var http = new XMLHttpRequest();
|
|
98
|
+
http.onreadystatechange = function () {
|
|
99
|
+
if (http.readyState == 4) {
|
|
100
|
+
if (http.responseText) {
|
|
101
|
+
resolve(JSON.parse(http.responseText));
|
|
102
|
+
} else {
|
|
103
|
+
resolve(undefined);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
http.open("GET", `${window.webAuthSettings.authority}/verification-srv/config/list`, true);
|
|
108
|
+
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
109
|
+
if (window.localeSettings) {
|
|
110
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
111
|
+
}
|
|
112
|
+
http.send();
|
|
113
|
+
} catch (ex) {
|
|
114
|
+
reject(ex);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* enrollVerification
|
|
121
|
+
* @param options
|
|
122
|
+
* @returns
|
|
123
|
+
*/
|
|
124
|
+
export function enrollVerification(options: IEnrollVerificationSetupRequestEntity) {
|
|
125
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/enroll/" + options.verification_type;
|
|
126
|
+
return Helper.createPostPromise(options, _serviceURL, undefined);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @deprecated This function is no longer supported, instead use {this.updateStatus()}
|
|
131
|
+
* @param status_id
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
export function updateSocket(status_id: string) {
|
|
135
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/notification/status/" + status_id;
|
|
136
|
+
return Helper.createPostPromise(undefined, _serviceURL, undefined);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* update the status of notification
|
|
141
|
+
* @param status_id
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
export function updateStatus(status_id: string) {
|
|
145
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/notification/status/" + status_id;
|
|
146
|
+
return Helper.createPostPromise(undefined, _serviceURL, undefined);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* setupFidoVerification
|
|
151
|
+
* @param options
|
|
152
|
+
* @returns
|
|
153
|
+
*/
|
|
154
|
+
export function setupFidoVerification(options: FidoSetupEntity) {
|
|
155
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/initiate/suggestmfa/" + options.verification_type;
|
|
156
|
+
return Helper.createPostPromise(options, _serviceURL, undefined);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* checkVerificationTypeConfigured
|
|
161
|
+
* @param options
|
|
162
|
+
* @returns
|
|
163
|
+
*/
|
|
164
|
+
export function checkVerificationTypeConfigured(options: IConfiguredListRequestEntity) {
|
|
165
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/public/configured/check/" + options.verification_type;
|
|
166
|
+
return Helper.createPostPromise(options, _serviceURL, undefined);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* initiate mfa v2
|
|
171
|
+
* @param options
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
export function initiateMFAV2(options: IInitVerificationAuthenticationRequestEntity) {
|
|
175
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/" + options.type;
|
|
176
|
+
return Helper.createPostPromise(options, _serviceURL, false);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @deprecated
|
|
181
|
+
* @param options
|
|
182
|
+
* @param verificationType
|
|
183
|
+
* @returns
|
|
184
|
+
*/
|
|
185
|
+
export function initiateMfaV1(options: any, verificationType: string) {
|
|
186
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + verificationType.toLowerCase() + "/initiate";
|
|
187
|
+
return Helper.createPostPromise(options, _serviceURL, false);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* authenticate mfa v2
|
|
192
|
+
* @param options
|
|
193
|
+
* @returns
|
|
194
|
+
*/
|
|
195
|
+
export function authenticateMFAV2(options: IAuthVerificationAuthenticationRequestEntity) {
|
|
196
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/" + options.type;
|
|
197
|
+
return Helper.createPostPromise(options, _serviceURL, undefined);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* authenticateVerification form type (for face)
|
|
202
|
+
* @param options
|
|
203
|
+
* @returns
|
|
204
|
+
*/
|
|
205
|
+
export function authenticateFaceVerification(options: FaceVerificationAuthenticationRequestEntity) {
|
|
206
|
+
return new Promise((resolve, reject) => {
|
|
207
|
+
try {
|
|
208
|
+
var http = new XMLHttpRequest();
|
|
209
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/face";
|
|
210
|
+
http.onreadystatechange = function () {
|
|
211
|
+
if (http.readyState == 4) {
|
|
212
|
+
if (http.responseText) {
|
|
213
|
+
resolve(JSON.parse(http.responseText));
|
|
214
|
+
} else {
|
|
215
|
+
resolve(undefined);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
http.open("POST", _serviceURL, true);
|
|
220
|
+
http.setRequestHeader("Content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
|
|
221
|
+
if (window.localeSettings) {
|
|
222
|
+
http.setRequestHeader("accept-language", window.localeSettings);
|
|
223
|
+
}
|
|
224
|
+
http.send(JSON.stringify(options));
|
|
225
|
+
} catch (ex) {
|
|
226
|
+
reject(ex);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @deprecated
|
|
233
|
+
* setup verification - v1
|
|
234
|
+
* @param options
|
|
235
|
+
* @param access_token
|
|
236
|
+
* @param verificationType
|
|
237
|
+
* @returns
|
|
238
|
+
*/
|
|
239
|
+
export function setupVerificationV1(options: any, access_token: string, verificationType: string) {
|
|
240
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + verificationType.toLowerCase() + "/setup";
|
|
241
|
+
return Helper.createPostPromise(options, _serviceURL, false, access_token);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @deprecated
|
|
246
|
+
* enroll verification - v1
|
|
247
|
+
* @param options
|
|
248
|
+
* @param access_token
|
|
249
|
+
* @param verificationType
|
|
250
|
+
* @returns
|
|
251
|
+
*/
|
|
252
|
+
export function enrollVerificationV1(options: any, access_token: string, verificationType: string) {
|
|
253
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + verificationType.toLowerCase() + "/enroll";
|
|
254
|
+
return Helper.createPostPromise(options, _serviceURL, false, access_token);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @deprecated
|
|
259
|
+
* authenticate mfa - v1
|
|
260
|
+
* @param verificationType
|
|
261
|
+
* @returns
|
|
262
|
+
*/
|
|
263
|
+
export function authenticateMfaV1(options: any, verificationType: string) {
|
|
264
|
+
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + verificationType.toLowerCase() + "/authenticate";
|
|
265
|
+
return Helper.createPostPromise(options, _serviceURL, false);
|
|
266
|
+
}
|
|
267
|
+
}
|