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
|
@@ -1,1899 +0,0 @@
|
|
|
1
|
-
var Authentication = require('../authentication');
|
|
2
|
-
var CustomException = require('./exception');
|
|
3
|
-
var Oidc = require('oidc-client');
|
|
4
|
-
var CryptoJS = require("crypto-js");
|
|
5
|
-
var fingerprint = require('@fingerprintjs/fingerprintjs');
|
|
6
|
-
|
|
7
|
-
var code_verifier;
|
|
8
|
-
|
|
9
|
-
function WebAuth(settings) {
|
|
10
|
-
try {
|
|
11
|
-
var usermanager = new Oidc.UserManager(settings);
|
|
12
|
-
window.webAuthSettings = settings;
|
|
13
|
-
window.usermanager = usermanager;
|
|
14
|
-
window.localeSettings = null;
|
|
15
|
-
window.authentication = new Authentication(window.webAuthSettings, window.usermanager);
|
|
16
|
-
window.usermanager.events.addSilentRenewError(function (error) {
|
|
17
|
-
throw new CustomException("Error while renewing silent login", 500);
|
|
18
|
-
});
|
|
19
|
-
} catch (ex) {
|
|
20
|
-
console.log(ex);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var registrationFields = [];
|
|
25
|
-
|
|
26
|
-
// added the common header
|
|
27
|
-
function createHeaders(http, options) {
|
|
28
|
-
http.setRequestHeader("Content-Type", "application/json");
|
|
29
|
-
if (options && options.acceptlanguage) {
|
|
30
|
-
http.setRequestHeader("Accept-Language", options.acceptlanguage);
|
|
31
|
-
} else if (window.localeSettings) {
|
|
32
|
-
http.setRequestHeader("Accept-Language", window.localeSettings);
|
|
33
|
-
}
|
|
34
|
-
return http;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// prototype methods
|
|
38
|
-
// login
|
|
39
|
-
WebAuth.prototype.loginWithBrowser = function () {
|
|
40
|
-
try {
|
|
41
|
-
if (!window.webAuthSettings && !window.authentication) {
|
|
42
|
-
throw new CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
|
|
43
|
-
}
|
|
44
|
-
if (!window.webAuthSettings.mode) {
|
|
45
|
-
window.webAuthSettings.mode = 'redirect';
|
|
46
|
-
}
|
|
47
|
-
if (window.webAuthSettings.mode == 'redirect') {
|
|
48
|
-
window.authentication.redirectSignIn('login');
|
|
49
|
-
} else if (window.webAuthSettings.mode == 'window') {
|
|
50
|
-
window.authentication.popupSignIn();
|
|
51
|
-
} else if (window.webAuthSettings.mode == 'silent') {
|
|
52
|
-
window.authentication.silentSignIn();
|
|
53
|
-
}
|
|
54
|
-
} catch (ex) {
|
|
55
|
-
console.log(ex);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// register
|
|
60
|
-
WebAuth.prototype.registerWithBrowser = function () {
|
|
61
|
-
try {
|
|
62
|
-
if (!window.webAuthSettings && !window.authentication) {
|
|
63
|
-
throw new CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
|
|
64
|
-
}
|
|
65
|
-
if (!window.webAuthSettings.mode) {
|
|
66
|
-
window.webAuthSettings.mode = 'redirect';
|
|
67
|
-
}
|
|
68
|
-
if (window.webAuthSettings.mode == 'redirect') {
|
|
69
|
-
window.authentication.redirectSignIn('register');
|
|
70
|
-
} else if (window.webAuthSettings.mode == 'window') {
|
|
71
|
-
window.authentication.popupSignIn();
|
|
72
|
-
} else if (window.webAuthSettings.mode == 'silent') {
|
|
73
|
-
window.authentication.silentSignIn();
|
|
74
|
-
}
|
|
75
|
-
} catch (ex) {
|
|
76
|
-
console.log(ex);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// login callback
|
|
81
|
-
WebAuth.prototype.loginCallback = function () {
|
|
82
|
-
return new Promise(function (resolve, reject) {
|
|
83
|
-
try {
|
|
84
|
-
if (!window.webAuthSettings && !window.authentication) {
|
|
85
|
-
throw new CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
|
|
86
|
-
}
|
|
87
|
-
if (!window.webAuthSettings.mode) {
|
|
88
|
-
window.webAuthSettings.mode = 'redirect';
|
|
89
|
-
}
|
|
90
|
-
if (window.webAuthSettings.mode == 'redirect') {
|
|
91
|
-
window.authentication.redirectSignInCallback().then(function (user) {
|
|
92
|
-
resolve(user);
|
|
93
|
-
}).catch(function (ex) {
|
|
94
|
-
reject(ex);
|
|
95
|
-
});
|
|
96
|
-
} else if (window.webAuthSettings.mode == 'window') {
|
|
97
|
-
window.authentication.popupSignInCallback();
|
|
98
|
-
} else if (window.webAuthSettings.mode == 'silent') {
|
|
99
|
-
window.authentication.silentSignInCallbackV2().then(function (data) {
|
|
100
|
-
resolve(data);
|
|
101
|
-
}).catch(function (error) {
|
|
102
|
-
reject(error);
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
} catch (ex) {
|
|
106
|
-
console.log(ex);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// get user info
|
|
112
|
-
WebAuth.prototype.getUserInfo = function () {
|
|
113
|
-
return new Promise(function (resolve, reject) {
|
|
114
|
-
try {
|
|
115
|
-
if (window.usermanager) {
|
|
116
|
-
window.usermanager.getUser()
|
|
117
|
-
.then(function (user) {
|
|
118
|
-
if (user) {
|
|
119
|
-
resolve(user);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
resolve(undefined);
|
|
123
|
-
});
|
|
124
|
-
} else {
|
|
125
|
-
throw new CustomException("UserManager cannot be empty", 417);
|
|
126
|
-
}
|
|
127
|
-
} catch (ex) {
|
|
128
|
-
reject(ex);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// get user info
|
|
134
|
-
WebAuth.prototype.getUserProfile = function (options) {
|
|
135
|
-
return new Promise(function (resolve, reject) {
|
|
136
|
-
try {
|
|
137
|
-
if (!options.access_token) {
|
|
138
|
-
throw new CustomException("access_token cannot be empty", 417);
|
|
139
|
-
}
|
|
140
|
-
var http = new XMLHttpRequest();
|
|
141
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo";
|
|
142
|
-
http.onreadystatechange = function () {
|
|
143
|
-
if (http.readyState == 4) {
|
|
144
|
-
resolve(JSON.parse(http.responseText));
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
http.open("GET", _serviceURL, true);
|
|
148
|
-
http = createHeaders(http, options);
|
|
149
|
-
http.setRequestHeader("Authorization", `Bearer ${options.access_token}`);
|
|
150
|
-
http.send();
|
|
151
|
-
} catch (ex) {
|
|
152
|
-
reject(ex);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
// get user info (internal)
|
|
158
|
-
WebAuth.prototype.getProfileInfo = function (access_token) {
|
|
159
|
-
return new Promise(function (resolve, reject) {
|
|
160
|
-
try {
|
|
161
|
-
if (!access_token) {
|
|
162
|
-
throw new CustomException("access_token cannot be empty", 417);
|
|
163
|
-
}
|
|
164
|
-
var http = new XMLHttpRequest();
|
|
165
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/internal/userinfo/profile";
|
|
166
|
-
http.onreadystatechange = function () {
|
|
167
|
-
if (http.readyState == 4) {
|
|
168
|
-
resolve(JSON.parse(http.responseText));
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
http.open("GET", _serviceURL, true);
|
|
172
|
-
http = createHeaders(http, null);
|
|
173
|
-
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
174
|
-
http.send();
|
|
175
|
-
} catch (ex) {
|
|
176
|
-
reject(ex);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
// logout
|
|
183
|
-
WebAuth.prototype.logout = function () {
|
|
184
|
-
return new Promise(function (resolve, reject) {
|
|
185
|
-
try {
|
|
186
|
-
if (!window.webAuthSettings && !window.authentication) {
|
|
187
|
-
throw new CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
|
|
188
|
-
}
|
|
189
|
-
if (!window.webAuthSettings.mode) {
|
|
190
|
-
window.webAuthSettings.mode = 'redirect';
|
|
191
|
-
}
|
|
192
|
-
if (window.webAuthSettings.mode == 'redirect') {
|
|
193
|
-
window.authentication.redirectSignOut().then(function (result) {
|
|
194
|
-
resolve(result);
|
|
195
|
-
return;
|
|
196
|
-
});
|
|
197
|
-
} else if (window.webAuthSettings.mode == 'window') {
|
|
198
|
-
window.authentication.popupSignOut();
|
|
199
|
-
} else if (window.webAuthSettings.mode == 'silent') {
|
|
200
|
-
window.authentication.redirectSignOut();
|
|
201
|
-
} else {
|
|
202
|
-
resolve(undefined);
|
|
203
|
-
}
|
|
204
|
-
} catch (ex) {
|
|
205
|
-
reject(ex);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
// logout callback
|
|
211
|
-
WebAuth.prototype.logoutCallback = function () {
|
|
212
|
-
return new Promise(function (resolve, reject) {
|
|
213
|
-
try {
|
|
214
|
-
if (!window.webAuthSettings && !window.authentication) {
|
|
215
|
-
throw new CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
|
|
216
|
-
}
|
|
217
|
-
if (!window.webAuthSettings.mode) {
|
|
218
|
-
window.webAuthSettings.mode = 'redirect';
|
|
219
|
-
}
|
|
220
|
-
if (window.webAuthSettings.mode == 'redirect') {
|
|
221
|
-
window.authentication.redirectSignOutCallback().then(function (resp) {
|
|
222
|
-
resolve(resp);
|
|
223
|
-
});
|
|
224
|
-
} else if (window.webAuthSettings.mode == 'window') {
|
|
225
|
-
window.authentication.popupSignOutCallback();
|
|
226
|
-
} else if (window.webAuthSettings.mode == 'silent') {
|
|
227
|
-
window.authentication.redirectSignOutCallback();
|
|
228
|
-
}
|
|
229
|
-
} catch (ex) {
|
|
230
|
-
reject(ex);
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
function createPostPromise(options, serviceurl, errorResolver, access_token) {
|
|
236
|
-
return new Promise(function (resolve, reject) {
|
|
237
|
-
try {
|
|
238
|
-
var http = new XMLHttpRequest();
|
|
239
|
-
http.onreadystatechange = function () {
|
|
240
|
-
if (http.readyState == 4) {
|
|
241
|
-
if (http.responseText) {
|
|
242
|
-
resolve(JSON.parse(http.responseText));
|
|
243
|
-
} else {
|
|
244
|
-
resolve(errorResolver);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
http.open("POST", serviceurl, true);
|
|
249
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
250
|
-
if (access_token) {
|
|
251
|
-
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
252
|
-
}
|
|
253
|
-
if (options) {
|
|
254
|
-
http.send(JSON.stringify(options));
|
|
255
|
-
} else {
|
|
256
|
-
http.send();
|
|
257
|
-
}
|
|
258
|
-
} catch (ex) {
|
|
259
|
-
reject(ex);
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
// renew token
|
|
264
|
-
WebAuth.prototype.renewToken = function (options) {
|
|
265
|
-
return new Promise(function (resolve, reject) {
|
|
266
|
-
try {
|
|
267
|
-
if (!options.refresh_token) {
|
|
268
|
-
throw new CustomException("refresh_token cannot be empty", 417);
|
|
269
|
-
}
|
|
270
|
-
options.client_id = window.webAuthSettings.client_id;
|
|
271
|
-
options.grant_type = 'refresh_token';
|
|
272
|
-
var http = new XMLHttpRequest();
|
|
273
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
274
|
-
http.onreadystatechange = function () {
|
|
275
|
-
if (http.readyState == 4) {
|
|
276
|
-
resolve(JSON.parse(http.responseText));
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
http.open("POST", _serviceURL, true);
|
|
280
|
-
http = createHeaders(http, options);
|
|
281
|
-
http.send(JSON.stringify(options));
|
|
282
|
-
} catch (ex) {
|
|
283
|
-
reject(ex);
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
WebAuth.prototype.generateCodeVerifier = function () {
|
|
289
|
-
code_verifier = this.generateRandomString(32);
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
WebAuth.prototype.generateRandomString = function (length) {
|
|
293
|
-
var text = "";
|
|
294
|
-
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
295
|
-
for (var i = 0; i < length; i++) {
|
|
296
|
-
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
297
|
-
}
|
|
298
|
-
return text;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
WebAuth.prototype.generateCodeChallenge = function (code_verifier) {
|
|
302
|
-
return this.base64URL(CryptoJS.SHA256(code_verifier));
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
WebAuth.prototype.base64URL = function (string) {
|
|
306
|
-
return string.toString(CryptoJS.enc.Base64).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
// get login url
|
|
310
|
-
WebAuth.prototype.getLoginURL = function (options = {}) {
|
|
311
|
-
var settings = window.webAuthSettings;
|
|
312
|
-
if (!settings.response_type) {
|
|
313
|
-
settings.response_type = "code";
|
|
314
|
-
}
|
|
315
|
-
if (!settings.scope) {
|
|
316
|
-
settings.scope = "email openid profile mobile";
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
this.generateCodeVerifier();
|
|
320
|
-
|
|
321
|
-
var loginURL = settings.authority + "/authz-srv/authz?client_id=" + settings.client_id;
|
|
322
|
-
loginURL += "&redirect_uri=" + settings.redirect_uri;
|
|
323
|
-
loginURL += "&nonce=" + new Date().getTime().toString();
|
|
324
|
-
loginURL += "&response_type=" + settings.response_type;
|
|
325
|
-
loginURL += "&code_challenge=" + this.generateCodeChallenge(code_verifier);
|
|
326
|
-
loginURL += "&code_challenge_method=S256";
|
|
327
|
-
if (settings.response_mode && settings.response_mode == 'query') {
|
|
328
|
-
loginURL += "&response_mode=" + settings.response_mode;
|
|
329
|
-
}
|
|
330
|
-
loginURL += "&scope=" + settings.scope;
|
|
331
|
-
if(options && options.max_age){
|
|
332
|
-
loginURL += "&max_age=" + options.max_age;
|
|
333
|
-
}
|
|
334
|
-
console.log(loginURL);
|
|
335
|
-
return loginURL;
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
// get access token from code
|
|
339
|
-
WebAuth.prototype.getAccessToken = function (options) {
|
|
340
|
-
return new Promise(function (resolve, reject) {
|
|
341
|
-
try {
|
|
342
|
-
if (!options.code) {
|
|
343
|
-
throw new CustomException("code cannot be empty", 417);
|
|
344
|
-
}
|
|
345
|
-
options.client_id = window.webAuthSettings.client_id;
|
|
346
|
-
options.redirect_uri = window.webAuthSettings.redirect_uri;
|
|
347
|
-
options.code_verifier = code_verifier;
|
|
348
|
-
options.grant_type = "authorization_code";
|
|
349
|
-
var http = new XMLHttpRequest();
|
|
350
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/token";
|
|
351
|
-
http.onreadystatechange = function () {
|
|
352
|
-
if (http.readyState == 4) {
|
|
353
|
-
resolve(JSON.parse(http.responseText));
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
http.open("POST", _serviceURL, true);
|
|
357
|
-
http = createHeaders(http, options);
|
|
358
|
-
http.send(JSON.stringify(options));
|
|
359
|
-
} catch (ex) {
|
|
360
|
-
reject(ex);
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
// validate access token
|
|
366
|
-
WebAuth.prototype.validateAccessToken = function (options) {
|
|
367
|
-
return new Promise(function (resolve, reject) {
|
|
368
|
-
try {
|
|
369
|
-
if (!options.token || !options.token_type_hint) {
|
|
370
|
-
throw new CustomException("token or token_type_hint cannot be empty", 417);
|
|
371
|
-
}
|
|
372
|
-
var http = new XMLHttpRequest();
|
|
373
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/introspect";
|
|
374
|
-
http.onreadystatechange = function () {
|
|
375
|
-
if (http.readyState == 4) {
|
|
376
|
-
resolve(JSON.parse(http.responseText));
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
http.open("POST", _serviceURL, true);
|
|
380
|
-
http = createHeaders(http, options);
|
|
381
|
-
http.send(JSON.stringify(options));
|
|
382
|
-
} catch (ex) {
|
|
383
|
-
reject(ex);
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
// get request id
|
|
390
|
-
WebAuth.prototype.getRequestId = function () {
|
|
391
|
-
return new Promise(function (resolve, reject) {
|
|
392
|
-
try {
|
|
393
|
-
var respone_type = window.webAuthSettings.response_type;
|
|
394
|
-
if (!respone_type) {
|
|
395
|
-
respone_type = "token";
|
|
396
|
-
}
|
|
397
|
-
var response_mode = window.webAuthSettings.response_mode;
|
|
398
|
-
if (!response_mode) {
|
|
399
|
-
response_mode = "fragment";
|
|
400
|
-
}
|
|
401
|
-
var bodyParams = {
|
|
402
|
-
"client_id": window.webAuthSettings.client_id,
|
|
403
|
-
"redirect_uri": window.webAuthSettings.redirect_uri,
|
|
404
|
-
"response_type": respone_type,
|
|
405
|
-
"response_mode": response_mode,
|
|
406
|
-
"scope": window.webAuthSettings.scope,
|
|
407
|
-
"nonce": new Date().getTime().toString()
|
|
408
|
-
};
|
|
409
|
-
var http = new XMLHttpRequest();
|
|
410
|
-
var _serviceURL = window.webAuthSettings.authority + "/authz-srv/authrequest/authz/generate";
|
|
411
|
-
http.onreadystatechange = function () {
|
|
412
|
-
if (http.readyState == 4) {
|
|
413
|
-
if (http.responseText) {
|
|
414
|
-
resolve(JSON.parse(http.responseText));
|
|
415
|
-
} else {
|
|
416
|
-
resolve(false);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
http.open("POST", _serviceURL, true);
|
|
421
|
-
http = createHeaders(http, null);
|
|
422
|
-
http.send(JSON.stringify(bodyParams));
|
|
423
|
-
} catch (ex) {
|
|
424
|
-
reject(ex);
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
// login with username and password
|
|
430
|
-
WebAuth.prototype.loginWithCredentials = function (options) {
|
|
431
|
-
try {
|
|
432
|
-
var form = document.createElement('form');
|
|
433
|
-
form.action = window.webAuthSettings.authority + "/login-srv/login";
|
|
434
|
-
form.method = 'POST';
|
|
435
|
-
for (var key in options) {
|
|
436
|
-
if (options.hasOwnProperty(key)) {
|
|
437
|
-
var hiddenField = document.createElement("input");
|
|
438
|
-
hiddenField.setAttribute("type", "hidden");
|
|
439
|
-
hiddenField.setAttribute("name", key);
|
|
440
|
-
hiddenField.setAttribute("value", options[key]);
|
|
441
|
-
|
|
442
|
-
form.appendChild(hiddenField);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
document.body.appendChild(form);
|
|
446
|
-
form.submit();
|
|
447
|
-
|
|
448
|
-
} catch (ex) {
|
|
449
|
-
throw new CustomException(ex, 417);
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
// login with username and password and return response
|
|
454
|
-
WebAuth.prototype.loginWithCredentialsAsynFn = async function (options) {
|
|
455
|
-
try {
|
|
456
|
-
|
|
457
|
-
const searchParams = new URLSearchParams(options);
|
|
458
|
-
|
|
459
|
-
const response = fetch(window.webAuthSettings.authority + "/login-srv/login", {
|
|
460
|
-
method: "POST",
|
|
461
|
-
redirect: "follow",
|
|
462
|
-
body: searchParams.toString(),
|
|
463
|
-
headers: {
|
|
464
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
return response;
|
|
469
|
-
|
|
470
|
-
} catch (ex) {
|
|
471
|
-
throw new CustomException(ex, 417);
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
// login with social
|
|
476
|
-
WebAuth.prototype.loginWithSocial = function (options, queryParams) {
|
|
477
|
-
try {
|
|
478
|
-
var _serviceURL = window.webAuthSettings.authority + "/login-srv/social/login/" + options.provider.toLowerCase() + "/" + options.requestId;
|
|
479
|
-
if (queryParams && queryParams.dc && queryParams.device_fp) {
|
|
480
|
-
_serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
|
|
481
|
-
}
|
|
482
|
-
window.location.href = _serviceURL;
|
|
483
|
-
} catch (ex) {
|
|
484
|
-
console.log(ex);
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
// register with social
|
|
489
|
-
WebAuth.prototype.registerWithSocial = function (options, queryParams) {
|
|
490
|
-
try {
|
|
491
|
-
var _serviceURL = window.webAuthSettings.authority + "/login-srv/social/register/" + options.provider.toLowerCase() + "/" + options.requestId;
|
|
492
|
-
if (queryParams && queryParams.dc && queryParams.device_fp) {
|
|
493
|
-
_serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
|
|
494
|
-
}
|
|
495
|
-
window.location.href = _serviceURL;
|
|
496
|
-
} catch (ex) {
|
|
497
|
-
console.log(ex);
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
// get missing fields
|
|
502
|
-
WebAuth.prototype.getMissingFields = function (options) {
|
|
503
|
-
return new Promise(function (resolve, reject) {
|
|
504
|
-
try {
|
|
505
|
-
var http = new XMLHttpRequest();
|
|
506
|
-
var _serviceURL = window.webAuthSettings.authority + "/public-srv/public/trackinfo/" + options.requestId + "/" + options.trackId;
|
|
507
|
-
http.onreadystatechange = function () {
|
|
508
|
-
if (http.readyState == 4) {
|
|
509
|
-
if (http.responseText) {
|
|
510
|
-
resolve(JSON.parse(http.responseText));
|
|
511
|
-
} else {
|
|
512
|
-
resolve(false);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
};
|
|
516
|
-
http.open("GET", _serviceURL, true);
|
|
517
|
-
http = createHeaders(http, options);
|
|
518
|
-
http.send();
|
|
519
|
-
} catch (ex) {
|
|
520
|
-
reject(ex);
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
// get Tenant info
|
|
526
|
-
WebAuth.prototype.getTenantInfo = function () {
|
|
527
|
-
return new Promise(function (resolve, reject) {
|
|
528
|
-
try {
|
|
529
|
-
var http = new XMLHttpRequest();
|
|
530
|
-
var _serviceURL = window.webAuthSettings.authority + "/public-srv/tenantinfo/basic";
|
|
531
|
-
http.onreadystatechange = function () {
|
|
532
|
-
if (http.readyState == 4) {
|
|
533
|
-
if (http.responseText) {
|
|
534
|
-
resolve(JSON.parse(http.responseText));
|
|
535
|
-
} else {
|
|
536
|
-
resolve(false);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
http.open("GET", _serviceURL, true);
|
|
541
|
-
http = createHeaders(http, null);
|
|
542
|
-
http.send();
|
|
543
|
-
} catch (ex) {
|
|
544
|
-
reject(ex);
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
// logout api call
|
|
550
|
-
WebAuth.prototype.logoutUser = function (options) {
|
|
551
|
-
try {
|
|
552
|
-
window.location.href = window.webAuthSettings.authority + "/session/end_session?access_token_hint=" + options.access_token + "&post_logout_redirect_uri=" + window.webAuthSettings.post_logout_redirect_uri;
|
|
553
|
-
} catch (ex) {
|
|
554
|
-
throw new CustomException(ex, 417);
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
// get Client Info
|
|
559
|
-
WebAuth.prototype.getClientInfo = function (options) {
|
|
560
|
-
return new Promise(function (resolve, reject) {
|
|
561
|
-
try {
|
|
562
|
-
var http = new XMLHttpRequest();
|
|
563
|
-
var _serviceURL = window.webAuthSettings.authority + "/public-srv/public/" + options.requestId;
|
|
564
|
-
http.onreadystatechange = function () {
|
|
565
|
-
if (http.readyState == 4) {
|
|
566
|
-
if (http.responseText) {
|
|
567
|
-
resolve(JSON.parse(http.responseText));
|
|
568
|
-
} else {
|
|
569
|
-
resolve(false);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
http.open("GET", _serviceURL, true);
|
|
574
|
-
http = createHeaders(http, options);
|
|
575
|
-
http.send();
|
|
576
|
-
} catch (ex) {
|
|
577
|
-
reject(ex);
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
// get all devices associated to the client
|
|
583
|
-
WebAuth.prototype.getDevicesInfo = function (options) {
|
|
584
|
-
return new Promise(function (resolve, reject) {
|
|
585
|
-
try {
|
|
586
|
-
var http = new XMLHttpRequest();
|
|
587
|
-
var _serviceURL = window.webAuthSettings.authority + "/device-srv/devices";
|
|
588
|
-
http.onreadystatechange = function () {
|
|
589
|
-
if (http.readyState == 4) {
|
|
590
|
-
if (http.responseText) {
|
|
591
|
-
resolve(JSON.parse(http.responseText));
|
|
592
|
-
} else {
|
|
593
|
-
resolve(false);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
http.open("GET", _serviceURL, true);
|
|
598
|
-
http = createHeaders(http, options);
|
|
599
|
-
if (window.navigator.userAgent) {
|
|
600
|
-
http.setRequestBody("userAgent", window.navigator.userAgent)
|
|
601
|
-
}
|
|
602
|
-
http.send();
|
|
603
|
-
} catch (ex) {
|
|
604
|
-
reject(ex);
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
// delete a device
|
|
610
|
-
WebAuth.prototype.deleteDevice = function (options) {
|
|
611
|
-
return new Promise(function (resolve, reject) {
|
|
612
|
-
try {
|
|
613
|
-
var http = new XMLHttpRequest();
|
|
614
|
-
var _serviceURL = window.webAuthSettings.authority + "/device-srv/device/" + options.device_id;
|
|
615
|
-
http.onreadystatechange = function () {
|
|
616
|
-
if (http.readyState == 4) {
|
|
617
|
-
if (http.responseText) {
|
|
618
|
-
resolve(JSON.parse(http.responseText));
|
|
619
|
-
} else {
|
|
620
|
-
resolve(false);
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
http.open("DELETE", _serviceURL, true);
|
|
625
|
-
http = createHeaders(http, options);
|
|
626
|
-
if (window.navigator.userAgent) {
|
|
627
|
-
http.setRequestBody("userAgent", window.navigator.userAgent)
|
|
628
|
-
}
|
|
629
|
-
http.send();
|
|
630
|
-
} catch (ex) {
|
|
631
|
-
reject(ex);
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
};
|
|
635
|
-
|
|
636
|
-
// get Registration setup
|
|
637
|
-
WebAuth.prototype.getRegistrationSetup = function (options) {
|
|
638
|
-
return new Promise(function (resolve, reject) {
|
|
639
|
-
try {
|
|
640
|
-
var http = new XMLHttpRequest();
|
|
641
|
-
var _serviceURL = window.webAuthSettings.authority + "/registration-setup-srv/public/list?acceptlanguage=" + options.acceptlanguage + "&requestId=" + options.requestId;
|
|
642
|
-
http.onreadystatechange = function () {
|
|
643
|
-
if (http.readyState == 4) {
|
|
644
|
-
if (http.responseText) {
|
|
645
|
-
var parsedResponse = JSON.parse(http.responseText);
|
|
646
|
-
if (parsedResponse && parsedResponse.data && parsedResponse.data.length > 0) {
|
|
647
|
-
registrationFields = parsedResponse.data;
|
|
648
|
-
}
|
|
649
|
-
resolve(parsedResponse);
|
|
650
|
-
} else {
|
|
651
|
-
resolve(false);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
};
|
|
655
|
-
http.open("GET", _serviceURL, true);
|
|
656
|
-
http = createHeaders(http, options);
|
|
657
|
-
http.send();
|
|
658
|
-
} catch (ex) {
|
|
659
|
-
reject(ex);
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
// register user
|
|
665
|
-
WebAuth.prototype.register = function (options, headers) {
|
|
666
|
-
return new Promise(function (resolve, reject) {
|
|
667
|
-
try {
|
|
668
|
-
|
|
669
|
-
var http = new XMLHttpRequest();
|
|
670
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/register";
|
|
671
|
-
if (options.invite_id) {
|
|
672
|
-
_serviceURL = _serviceURL + "?invite_id=" + options.invite_id;
|
|
673
|
-
}
|
|
674
|
-
http.onreadystatechange = function () {
|
|
675
|
-
if (http.readyState == 4) {
|
|
676
|
-
if (http.responseText) {
|
|
677
|
-
resolve(JSON.parse(http.responseText));
|
|
678
|
-
} else {
|
|
679
|
-
resolve(false);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
};
|
|
683
|
-
http.open("POST", _serviceURL, true);
|
|
684
|
-
http = createHeaders(http, options);
|
|
685
|
-
http.setRequestHeader("requestId", headers.requestId);
|
|
686
|
-
if (headers.captcha) {
|
|
687
|
-
http.setRequestHeader("captcha", headers.captcha);
|
|
688
|
-
}
|
|
689
|
-
if (headers.bot_captcha_response) {
|
|
690
|
-
http.setRequestHeader("bot_captcha_response", headers.bot_captcha_response);
|
|
691
|
-
}
|
|
692
|
-
let trackId = headers.trackid || headers.trackId;
|
|
693
|
-
if (trackId) {
|
|
694
|
-
http.setRequestHeader("trackid", trackId);
|
|
695
|
-
}
|
|
696
|
-
http.send(JSON.stringify(options));
|
|
697
|
-
} catch (ex) {
|
|
698
|
-
reject(ex);
|
|
699
|
-
}
|
|
700
|
-
});
|
|
701
|
-
};
|
|
702
|
-
|
|
703
|
-
// get invite info
|
|
704
|
-
WebAuth.prototype.getInviteUserDetails = function (options) {
|
|
705
|
-
return new Promise(function (resolve, reject) {
|
|
706
|
-
try {
|
|
707
|
-
var http = new XMLHttpRequest();
|
|
708
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/invite/info/" + options.invite_id;
|
|
709
|
-
http.onreadystatechange = function () {
|
|
710
|
-
if (http.readyState == 4) {
|
|
711
|
-
if (http.responseText) {
|
|
712
|
-
resolve(JSON.parse(http.responseText));
|
|
713
|
-
} else {
|
|
714
|
-
resolve(false);
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
http.open("GET", _serviceURL, true);
|
|
719
|
-
http = createHeaders(http, options);
|
|
720
|
-
http.send();
|
|
721
|
-
} catch (ex) {
|
|
722
|
-
reject(ex);
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
};
|
|
726
|
-
|
|
727
|
-
// get Communication status
|
|
728
|
-
WebAuth.prototype.getCommunicationStatus = function (options) {
|
|
729
|
-
return new Promise(function (resolve, reject) {
|
|
730
|
-
try {
|
|
731
|
-
var http = new XMLHttpRequest();
|
|
732
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/communication/status/" + options.sub;
|
|
733
|
-
http.onreadystatechange = function () {
|
|
734
|
-
if (http.readyState == 4) {
|
|
735
|
-
if (http.responseText) {
|
|
736
|
-
resolve(JSON.parse(http.responseText));
|
|
737
|
-
} else {
|
|
738
|
-
resolve(false);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
http.open("GET", _serviceURL, true);
|
|
743
|
-
http = createHeaders(http, options);
|
|
744
|
-
if (options.requestId) {
|
|
745
|
-
http.setRequestHeader("requestId", options.requestId);
|
|
746
|
-
}
|
|
747
|
-
http.send();
|
|
748
|
-
} catch (ex) {
|
|
749
|
-
reject(ex);
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
// initiate verification
|
|
755
|
-
WebAuth.prototype.initiateAccountVerification = function (options) {
|
|
756
|
-
try {
|
|
757
|
-
var form = document.createElement('form');
|
|
758
|
-
form.action = window.webAuthSettings.authority + "/verification-srv/account/initiate";
|
|
759
|
-
form.method = 'POST';
|
|
760
|
-
for (var key in options) {
|
|
761
|
-
if (options.hasOwnProperty(key)) {
|
|
762
|
-
var hiddenField = document.createElement("input");
|
|
763
|
-
hiddenField.setAttribute("type", "hidden");
|
|
764
|
-
hiddenField.setAttribute("name", key);
|
|
765
|
-
hiddenField.setAttribute("value", options[key]);
|
|
766
|
-
|
|
767
|
-
form.appendChild(hiddenField);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
document.body.appendChild(form);
|
|
771
|
-
form.submit();
|
|
772
|
-
} catch (ex) {
|
|
773
|
-
throw new CustomException(ex, 417);
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
|
|
777
|
-
// initiate verification and return response
|
|
778
|
-
WebAuth.prototype.initiateAccountVerificationAsynFn = async function (options) {
|
|
779
|
-
try {
|
|
780
|
-
|
|
781
|
-
const searchParams = new URLSearchParams(options);
|
|
782
|
-
|
|
783
|
-
const response = fetch(window.webAuthSettings.authority + "/verification-srv/account/initiate", {
|
|
784
|
-
method: "POST",
|
|
785
|
-
redirect: "follow",
|
|
786
|
-
body: searchParams.toString(),
|
|
787
|
-
headers: {
|
|
788
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
789
|
-
}
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
return response;
|
|
793
|
-
|
|
794
|
-
} catch (ex) {
|
|
795
|
-
throw new CustomException(ex, 417);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
};
|
|
799
|
-
|
|
800
|
-
// verofy account
|
|
801
|
-
WebAuth.prototype.verifyAccount = function (options) {
|
|
802
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/account/verify";
|
|
803
|
-
return createPostPromise(options, _serviceURL, false);
|
|
804
|
-
};
|
|
805
|
-
|
|
806
|
-
// initiate reset password
|
|
807
|
-
WebAuth.prototype.initiateResetPassword = function (options) {
|
|
808
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/resetpassword/initiate";
|
|
809
|
-
return createPostPromise(options, _serviceURL, false);
|
|
810
|
-
};
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
// handle reset password
|
|
814
|
-
WebAuth.prototype.handleResetPassword = function (options) {
|
|
815
|
-
try {
|
|
816
|
-
var form = document.createElement('form');
|
|
817
|
-
form.action = window.webAuthSettings.authority + "/users-srv/resetpassword/validatecode";
|
|
818
|
-
form.method = 'POST';
|
|
819
|
-
for (var key in options) {
|
|
820
|
-
if (options.hasOwnProperty(key)) {
|
|
821
|
-
var hiddenField = document.createElement("input");
|
|
822
|
-
hiddenField.setAttribute("type", "hidden");
|
|
823
|
-
hiddenField.setAttribute("name", key);
|
|
824
|
-
hiddenField.setAttribute("value", options[key]);
|
|
825
|
-
|
|
826
|
-
form.appendChild(hiddenField);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
document.body.appendChild(form);
|
|
830
|
-
form.submit();
|
|
831
|
-
} catch (ex) {
|
|
832
|
-
throw new CustomException(ex, 417);
|
|
833
|
-
}
|
|
834
|
-
};
|
|
835
|
-
|
|
836
|
-
// reset password
|
|
837
|
-
WebAuth.prototype.resetPassword = function (options) {
|
|
838
|
-
try {
|
|
839
|
-
var form = document.createElement('form');
|
|
840
|
-
form.action = window.webAuthSettings.authority + "/users-srv/resetpassword/accept";
|
|
841
|
-
form.method = 'POST';
|
|
842
|
-
for (var key in options) {
|
|
843
|
-
if (options.hasOwnProperty(key)) {
|
|
844
|
-
var hiddenField = document.createElement("input");
|
|
845
|
-
hiddenField.setAttribute("type", "hidden");
|
|
846
|
-
hiddenField.setAttribute("name", key);
|
|
847
|
-
hiddenField.setAttribute("value", options[key]);
|
|
848
|
-
|
|
849
|
-
form.appendChild(hiddenField);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
document.body.appendChild(form);
|
|
853
|
-
form.submit();
|
|
854
|
-
} catch (ex) {
|
|
855
|
-
throw new CustomException(ex, 417);
|
|
856
|
-
}
|
|
857
|
-
};
|
|
858
|
-
|
|
859
|
-
// get mfa list
|
|
860
|
-
WebAuth.prototype.getMFAList = function (options) {
|
|
861
|
-
return new Promise(function (resolve, reject) {
|
|
862
|
-
try {
|
|
863
|
-
var query = "";
|
|
864
|
-
if (!options.email && !options.sub) {
|
|
865
|
-
throw new CustomException("either sub or email cannot be empty", 417);
|
|
866
|
-
}
|
|
867
|
-
if (options.sub) {
|
|
868
|
-
query = "?sub=" + options.sub;
|
|
869
|
-
} else {
|
|
870
|
-
query = "?email=" + options.email;
|
|
871
|
-
}
|
|
872
|
-
var http = new XMLHttpRequest();
|
|
873
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/settings/list" + query;
|
|
874
|
-
http.onreadystatechange = function () {
|
|
875
|
-
if (http.readyState == 4) {
|
|
876
|
-
if (http.responseText) {
|
|
877
|
-
resolve(JSON.parse(http.responseText));
|
|
878
|
-
} else {
|
|
879
|
-
resolve(false);
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
http.open("GET", _serviceURL, true);
|
|
884
|
-
http = createHeaders(http, options);
|
|
885
|
-
http.send();
|
|
886
|
-
} catch (ex) {
|
|
887
|
-
reject(ex);
|
|
888
|
-
}
|
|
889
|
-
});
|
|
890
|
-
};
|
|
891
|
-
|
|
892
|
-
// get mfa list v2
|
|
893
|
-
WebAuth.prototype.getMFAListV2 = function (options) {
|
|
894
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/public/configured/list";
|
|
895
|
-
return createPostPromise(options, _serviceURL, false);
|
|
896
|
-
};
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
// initiate mfa v2
|
|
901
|
-
WebAuth.prototype.initiateMFAV2 = function (options) {
|
|
902
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/" + options.type;
|
|
903
|
-
return createPostPromise(options, _serviceURL, false);
|
|
904
|
-
};
|
|
905
|
-
|
|
906
|
-
// initiate email
|
|
907
|
-
WebAuth.prototype.initiateEmail = function (options) {
|
|
908
|
-
options.verificationType = "EMAIL"
|
|
909
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
910
|
-
return createPostPromise(options, _serviceURL, false);
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
// initiate email v2
|
|
914
|
-
WebAuth.prototype.initiateEmailV2 = function (options) {
|
|
915
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/email";
|
|
916
|
-
return createPostPromise(options, _serviceURL, false);
|
|
917
|
-
};
|
|
918
|
-
|
|
919
|
-
// initiate sms
|
|
920
|
-
WebAuth.prototype.initiateSMS = function (options) {
|
|
921
|
-
options.verificationType = "SMS";
|
|
922
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
923
|
-
return createPostPromise(options, _serviceURL, false);
|
|
924
|
-
};
|
|
925
|
-
|
|
926
|
-
// initiate sms v2
|
|
927
|
-
WebAuth.prototype.initiateSMSV2 = function (options) {
|
|
928
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/sms";
|
|
929
|
-
return createPostPromise(options, _serviceURL, false);
|
|
930
|
-
};
|
|
931
|
-
|
|
932
|
-
// initiate ivr
|
|
933
|
-
WebAuth.prototype.initiateIVR = function (options) {
|
|
934
|
-
options.verificationType = "IVR";
|
|
935
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
936
|
-
return createPostPromise(options, _serviceURL, false);
|
|
937
|
-
};
|
|
938
|
-
|
|
939
|
-
// initiate ivr v2
|
|
940
|
-
WebAuth.prototype.initiateIVRV2 = function (options) {
|
|
941
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/ivr";
|
|
942
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
943
|
-
};
|
|
944
|
-
|
|
945
|
-
// initiate backupcode
|
|
946
|
-
WebAuth.prototype.initiateBackupcode = function (options) {
|
|
947
|
-
options.verificationType = "BACKUPCODE";
|
|
948
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
949
|
-
return createPostPromise(options, _serviceURL, false);
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
// initiate backupcode v2
|
|
953
|
-
WebAuth.prototype.initiateBackupcodeV2 = function (options) {
|
|
954
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/backupcode";
|
|
955
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
// initiate TOTP
|
|
959
|
-
WebAuth.prototype.initiateTOTP = function (options) {
|
|
960
|
-
options.verificationType = "TOTP";
|
|
961
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
962
|
-
return createPostPromise(options, _serviceURL, false);
|
|
963
|
-
};
|
|
964
|
-
|
|
965
|
-
// initiate totp v2
|
|
966
|
-
WebAuth.prototype.initiateTOTPV2 = function (options) {
|
|
967
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/totp";
|
|
968
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
969
|
-
};
|
|
970
|
-
|
|
971
|
-
// initiate Pattern
|
|
972
|
-
WebAuth.prototype.initiatePattern = function (options) {
|
|
973
|
-
options.verificationType = "PATTERN";
|
|
974
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
975
|
-
return createPostPromise(options, _serviceURL, false);
|
|
976
|
-
};
|
|
977
|
-
|
|
978
|
-
// initiate pattern v2
|
|
979
|
-
WebAuth.prototype.initiatePatternV2 = function (options) {
|
|
980
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/pattern";
|
|
981
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
// initiate touchid
|
|
985
|
-
WebAuth.prototype.initiateTouchId = function (options) {
|
|
986
|
-
options.verificationType = "TOUCHID";
|
|
987
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
988
|
-
return createPostPromise(options, _serviceURL, false);
|
|
989
|
-
};
|
|
990
|
-
|
|
991
|
-
// initiate touchid v2
|
|
992
|
-
WebAuth.prototype.initiateTouchIdV2 = function (options) {
|
|
993
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/touchid";
|
|
994
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
995
|
-
};
|
|
996
|
-
|
|
997
|
-
// initiate smart push
|
|
998
|
-
WebAuth.prototype.initiateSmartPush = function (options) {
|
|
999
|
-
options.verificationType = "PUSH";
|
|
1000
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
1001
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1002
|
-
};
|
|
1003
|
-
|
|
1004
|
-
// initiate smart push v2
|
|
1005
|
-
WebAuth.prototype.initiateSmartPushV2 = function (options) {
|
|
1006
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/push";
|
|
1007
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
|
-
// initiate Face
|
|
1011
|
-
WebAuth.prototype.initiateFace = function (options) {
|
|
1012
|
-
options.verificationType = "FACE";
|
|
1013
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
1014
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1015
|
-
};
|
|
1016
|
-
|
|
1017
|
-
// initiate face v2
|
|
1018
|
-
WebAuth.prototype.initiateFaceV2 = function (options) {
|
|
1019
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/face";
|
|
1020
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1021
|
-
};
|
|
1022
|
-
|
|
1023
|
-
// initiate Voice
|
|
1024
|
-
WebAuth.prototype.initiateVoice = function (options) {
|
|
1025
|
-
options.verificationType = "VOICE";
|
|
1026
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/initiate";
|
|
1027
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1028
|
-
};
|
|
1029
|
-
|
|
1030
|
-
// initiate voice v2
|
|
1031
|
-
WebAuth.prototype.initiateVoiceV2 = function (options) {
|
|
1032
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/voice";
|
|
1033
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1034
|
-
};
|
|
1035
|
-
|
|
1036
|
-
// authenticate mfa v2
|
|
1037
|
-
WebAuth.prototype.authenticateMFAV2 = function (options) {
|
|
1038
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/" + options.type;
|
|
1039
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
// cancel mfa v2
|
|
1043
|
-
WebAuth.prototype.cancelMFAV2 = function (options) {
|
|
1044
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/cancel/" + options.type;
|
|
1045
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1046
|
-
};
|
|
1047
|
-
|
|
1048
|
-
// authenticate email
|
|
1049
|
-
WebAuth.prototype.authenticateEmail = function (options) {
|
|
1050
|
-
options.verificationType = "EMAIL";
|
|
1051
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/authenticate";
|
|
1052
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1053
|
-
};
|
|
1054
|
-
|
|
1055
|
-
// authenticate email v2
|
|
1056
|
-
WebAuth.prototype.authenticateEmailV2 = function (options) {
|
|
1057
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/email";
|
|
1058
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1059
|
-
};
|
|
1060
|
-
|
|
1061
|
-
// authenticate sms
|
|
1062
|
-
WebAuth.prototype.authenticateSMS = function (options) {
|
|
1063
|
-
options.verificationType = "SMS";
|
|
1064
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/authenticate";
|
|
1065
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
// authenticate sms v2
|
|
1069
|
-
WebAuth.prototype.authenticateSMSV2 = function (options) {
|
|
1070
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/sms";
|
|
1071
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1072
|
-
};
|
|
1073
|
-
|
|
1074
|
-
// authenticate ivr
|
|
1075
|
-
WebAuth.prototype.authenticateIVR = function (options) {
|
|
1076
|
-
options.verificationType = "IVR";
|
|
1077
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/authenticate";
|
|
1078
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1079
|
-
};
|
|
1080
|
-
|
|
1081
|
-
// authenticate ivr v2
|
|
1082
|
-
WebAuth.prototype.authenticateIVRV2 = function (options) {
|
|
1083
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/ivr";
|
|
1084
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1085
|
-
};
|
|
1086
|
-
|
|
1087
|
-
// authenticate backupcode
|
|
1088
|
-
WebAuth.prototype.authenticateBackupcode = function (options) {
|
|
1089
|
-
options.verificationType = "BACKUPCODE";
|
|
1090
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/authenticate";
|
|
1091
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1092
|
-
};
|
|
1093
|
-
|
|
1094
|
-
// authenticate backupcode v2
|
|
1095
|
-
WebAuth.prototype.authenticateBackupcodeV2 = function (options) {
|
|
1096
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/backupcode";
|
|
1097
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1098
|
-
};
|
|
1099
|
-
|
|
1100
|
-
// authenticate totp
|
|
1101
|
-
WebAuth.prototype.authenticateTOTP = function (options) {
|
|
1102
|
-
options.verificationType = "TOTP";
|
|
1103
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/authenticate";
|
|
1104
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1105
|
-
};
|
|
1106
|
-
|
|
1107
|
-
// authenticate totp v2
|
|
1108
|
-
WebAuth.prototype.authenticateTOTPV2 = function (options) {
|
|
1109
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/totp";
|
|
1110
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1111
|
-
};
|
|
1112
|
-
|
|
1113
|
-
// passwordless login
|
|
1114
|
-
WebAuth.prototype.passwordlessLogin = function (options) {
|
|
1115
|
-
try {
|
|
1116
|
-
var form = document.createElement('form');
|
|
1117
|
-
form.action = window.webAuthSettings.authority + "/login-srv/verification/login";
|
|
1118
|
-
form.method = 'POST';
|
|
1119
|
-
for (var key in options) {
|
|
1120
|
-
if (options.hasOwnProperty(key)) {
|
|
1121
|
-
var hiddenField = document.createElement("input");
|
|
1122
|
-
hiddenField.setAttribute("type", "hidden");
|
|
1123
|
-
hiddenField.setAttribute("name", key);
|
|
1124
|
-
hiddenField.setAttribute("value", options[key]);
|
|
1125
|
-
|
|
1126
|
-
form.appendChild(hiddenField);
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
document.body.appendChild(form);
|
|
1130
|
-
form.submit();
|
|
1131
|
-
} catch (ex) {
|
|
1132
|
-
throw new CustomException(ex, 417);
|
|
1133
|
-
}
|
|
1134
|
-
};
|
|
1135
|
-
|
|
1136
|
-
// get consent details
|
|
1137
|
-
WebAuth.prototype.getConsentDetails = function (options) {
|
|
1138
|
-
return new Promise(function (resolve, reject) {
|
|
1139
|
-
try {
|
|
1140
|
-
var http = new XMLHttpRequest();
|
|
1141
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/settings/public?name=" + options.consent_name;
|
|
1142
|
-
http.onreadystatechange = function () {
|
|
1143
|
-
if (http.readyState == 4) {
|
|
1144
|
-
if (http.responseText) {
|
|
1145
|
-
resolve(JSON.parse(http.responseText));
|
|
1146
|
-
} else {
|
|
1147
|
-
resolve(false);
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
};
|
|
1151
|
-
http.open("GET", _serviceURL, true);
|
|
1152
|
-
http = createHeaders(http, options);
|
|
1153
|
-
http.send();
|
|
1154
|
-
} catch (ex) {
|
|
1155
|
-
reject(ex);
|
|
1156
|
-
}
|
|
1157
|
-
});
|
|
1158
|
-
};
|
|
1159
|
-
|
|
1160
|
-
// get user consent details
|
|
1161
|
-
WebAuth.prototype.getConsentDetailsV2 = function (options) {
|
|
1162
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/public/info";
|
|
1163
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1164
|
-
};
|
|
1165
|
-
|
|
1166
|
-
// acceptConsent
|
|
1167
|
-
WebAuth.prototype.acceptConsent = function (options) {
|
|
1168
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/user/status";
|
|
1169
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1170
|
-
};
|
|
1171
|
-
|
|
1172
|
-
WebAuth.prototype.acceptConsentV2 = function (options) {
|
|
1173
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/usage/accept";
|
|
1174
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1175
|
-
};
|
|
1176
|
-
|
|
1177
|
-
// get scope consent details
|
|
1178
|
-
WebAuth.prototype.getScopeConsentDetails = function (options) {
|
|
1179
|
-
return new Promise(function (resolve, reject) {
|
|
1180
|
-
try {
|
|
1181
|
-
var http = new XMLHttpRequest();
|
|
1182
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + options.track_id + "?acceptLanguage=" + options.locale;
|
|
1183
|
-
http.onreadystatechange = function () {
|
|
1184
|
-
if (http.readyState == 4) {
|
|
1185
|
-
if (http.responseText) {
|
|
1186
|
-
resolve(JSON.parse(http.responseText));
|
|
1187
|
-
} else {
|
|
1188
|
-
resolve(false);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
};
|
|
1192
|
-
http.open("GET", _serviceURL, true);
|
|
1193
|
-
http = createHeaders(http, options);
|
|
1194
|
-
http.send();
|
|
1195
|
-
} catch (ex) {
|
|
1196
|
-
reject(ex);
|
|
1197
|
-
}
|
|
1198
|
-
});
|
|
1199
|
-
};
|
|
1200
|
-
|
|
1201
|
-
// get scope consent version details
|
|
1202
|
-
WebAuth.prototype.getScopeConsentVersionDetailsV2 = function (options) {
|
|
1203
|
-
return new Promise(function (resolve, reject) {
|
|
1204
|
-
try {
|
|
1205
|
-
var http = new XMLHttpRequest();
|
|
1206
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/versions/details/" + options.scopeid + "?locale=" + options.locale;
|
|
1207
|
-
http.onreadystatechange = function () {
|
|
1208
|
-
if (http.readyState == 4) {
|
|
1209
|
-
if (http.responseText) {
|
|
1210
|
-
resolve(JSON.parse(http.responseText));
|
|
1211
|
-
} else {
|
|
1212
|
-
resolve(false);
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
};
|
|
1216
|
-
http.open("GET", _serviceURL, true);
|
|
1217
|
-
http = createHeaders(http, options);
|
|
1218
|
-
http.setRequestHeader("Authorization", `Bearer ${options.access_token}`);
|
|
1219
|
-
http.send();
|
|
1220
|
-
} catch (ex) {
|
|
1221
|
-
reject(ex);
|
|
1222
|
-
}
|
|
1223
|
-
});
|
|
1224
|
-
};
|
|
1225
|
-
|
|
1226
|
-
// accept scope Consent
|
|
1227
|
-
WebAuth.prototype.acceptScopeConsent = function (options) {
|
|
1228
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/scope/accept";
|
|
1229
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1230
|
-
};
|
|
1231
|
-
|
|
1232
|
-
// scope consent continue login
|
|
1233
|
-
WebAuth.prototype.scopeConsentContinue = function (options) {
|
|
1234
|
-
try {
|
|
1235
|
-
var form = document.createElement('form');
|
|
1236
|
-
form.action = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
1237
|
-
form.method = 'POST';
|
|
1238
|
-
document.body.appendChild(form);
|
|
1239
|
-
form.submit();
|
|
1240
|
-
} catch (ex) {
|
|
1241
|
-
throw new CustomException(ex, 417);
|
|
1242
|
-
}
|
|
1243
|
-
};
|
|
1244
|
-
|
|
1245
|
-
// accept claim Consent
|
|
1246
|
-
WebAuth.prototype.acceptClaimConsent = function (options) {
|
|
1247
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/accept";
|
|
1248
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1249
|
-
};
|
|
1250
|
-
|
|
1251
|
-
// claim consent continue login
|
|
1252
|
-
WebAuth.prototype.claimConsentContinue = function (options) {
|
|
1253
|
-
try {
|
|
1254
|
-
var form = document.createElement('form');
|
|
1255
|
-
form.action = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
1256
|
-
form.method = 'POST';
|
|
1257
|
-
document.body.appendChild(form);
|
|
1258
|
-
form.submit();
|
|
1259
|
-
} catch (ex) {
|
|
1260
|
-
throw new CustomException(ex, 417);
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
|
-
|
|
1264
|
-
// revoke claim Consent
|
|
1265
|
-
WebAuth.prototype.revokeClaimConsent = function (options) {
|
|
1266
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/revoke";
|
|
1267
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1268
|
-
};
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
// get Deduplication details
|
|
1272
|
-
WebAuth.prototype.getDeduplicationDetails = function (options) {
|
|
1273
|
-
return new Promise(function (resolve, reject) {
|
|
1274
|
-
try {
|
|
1275
|
-
var http = new XMLHttpRequest();
|
|
1276
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/info/" + options.trackId;
|
|
1277
|
-
http.onreadystatechange = function () {
|
|
1278
|
-
if (http.readyState == 4) {
|
|
1279
|
-
if (http.responseText) {
|
|
1280
|
-
resolve(JSON.parse(http.responseText));
|
|
1281
|
-
} else {
|
|
1282
|
-
resolve(false);
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
};
|
|
1286
|
-
http.open("GET", _serviceURL, true);
|
|
1287
|
-
http = createHeaders(http, options);
|
|
1288
|
-
http.send();
|
|
1289
|
-
} catch (ex) {
|
|
1290
|
-
reject(ex);
|
|
1291
|
-
}
|
|
1292
|
-
});
|
|
1293
|
-
};
|
|
1294
|
-
|
|
1295
|
-
// deduplication login
|
|
1296
|
-
WebAuth.prototype.deduplicationLogin = function (options) {
|
|
1297
|
-
try {
|
|
1298
|
-
var form = document.createElement('form');
|
|
1299
|
-
form.action = window.webAuthSettings.authority + "/users-srv/deduplication/login/redirection?trackId=" + options.trackId + "&requestId=" + options.requestId + "&sub=" + options.sub;
|
|
1300
|
-
form.method = 'POST';
|
|
1301
|
-
document.body.appendChild(form);
|
|
1302
|
-
form.submit();
|
|
1303
|
-
} catch (ex) {
|
|
1304
|
-
throw new CustomException(ex, 417);
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
|
|
1308
|
-
// register Deduplication
|
|
1309
|
-
WebAuth.prototype.registerDeduplication = function (options) {
|
|
1310
|
-
return new Promise(function (resolve, reject) {
|
|
1311
|
-
try {
|
|
1312
|
-
var http = new XMLHttpRequest();
|
|
1313
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/register/" + options.trackId;
|
|
1314
|
-
http.onreadystatechange = function () {
|
|
1315
|
-
if (http.readyState == 4) {
|
|
1316
|
-
resolve(JSON.parse(http.responseText));
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
http.open("POST", _serviceURL, true);
|
|
1320
|
-
http = createHeaders(http, options);
|
|
1321
|
-
http.send();
|
|
1322
|
-
} catch (ex) {
|
|
1323
|
-
reject(ex);
|
|
1324
|
-
}
|
|
1325
|
-
});
|
|
1326
|
-
};
|
|
1327
|
-
|
|
1328
|
-
// consent continue login
|
|
1329
|
-
WebAuth.prototype.consentContinue = function (options) {
|
|
1330
|
-
try {
|
|
1331
|
-
var form = document.createElement('form');
|
|
1332
|
-
form.action = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
1333
|
-
form.method = 'POST';
|
|
1334
|
-
for (var key in options) {
|
|
1335
|
-
if (options.hasOwnProperty(key)) {
|
|
1336
|
-
var hiddenField = document.createElement("input");
|
|
1337
|
-
hiddenField.setAttribute("type", "hidden");
|
|
1338
|
-
hiddenField.setAttribute("name", key);
|
|
1339
|
-
hiddenField.setAttribute("value", options[key]);
|
|
1340
|
-
|
|
1341
|
-
form.appendChild(hiddenField);
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
document.body.appendChild(form);
|
|
1345
|
-
form.submit();
|
|
1346
|
-
} catch (ex) {
|
|
1347
|
-
throw new CustomException(ex, 417);
|
|
1348
|
-
}
|
|
1349
|
-
};
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
// mfa continue login
|
|
1353
|
-
WebAuth.prototype.mfaContinue = function (options) {
|
|
1354
|
-
try {
|
|
1355
|
-
var form = document.createElement('form');
|
|
1356
|
-
form.action = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.track_id;
|
|
1357
|
-
form.method = 'POST';
|
|
1358
|
-
for (var key in options) {
|
|
1359
|
-
if (options.hasOwnProperty(key)) {
|
|
1360
|
-
var hiddenField = document.createElement("input");
|
|
1361
|
-
hiddenField.setAttribute("type", "hidden");
|
|
1362
|
-
hiddenField.setAttribute("name", key);
|
|
1363
|
-
hiddenField.setAttribute("value", options[key]);
|
|
1364
|
-
|
|
1365
|
-
form.appendChild(hiddenField);
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
document.body.appendChild(form);
|
|
1369
|
-
form.submit();
|
|
1370
|
-
} catch (ex) {
|
|
1371
|
-
throw new CustomException(ex, 417);
|
|
1372
|
-
}
|
|
1373
|
-
};
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
// change password continue
|
|
1377
|
-
WebAuth.prototype.firstTimeChangePassword = function (options) {
|
|
1378
|
-
try {
|
|
1379
|
-
var form = document.createElement('form');
|
|
1380
|
-
form.action = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.loginSettingsId;
|
|
1381
|
-
form.method = 'POST';
|
|
1382
|
-
for (var key in options) {
|
|
1383
|
-
if (options.hasOwnProperty(key)) {
|
|
1384
|
-
var hiddenField = document.createElement("input");
|
|
1385
|
-
hiddenField.setAttribute("type", "hidden");
|
|
1386
|
-
hiddenField.setAttribute("name", key);
|
|
1387
|
-
hiddenField.setAttribute("value", options[key]);
|
|
1388
|
-
|
|
1389
|
-
form.appendChild(hiddenField);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
document.body.appendChild(form);
|
|
1393
|
-
form.submit();
|
|
1394
|
-
} catch (ex) {
|
|
1395
|
-
throw new CustomException(ex, 417);
|
|
1396
|
-
}
|
|
1397
|
-
};
|
|
1398
|
-
|
|
1399
|
-
// change password
|
|
1400
|
-
WebAuth.prototype.changePassword = function (options, access_token) {
|
|
1401
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/changepassword";
|
|
1402
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1403
|
-
};
|
|
1404
|
-
|
|
1405
|
-
// update profile
|
|
1406
|
-
WebAuth.prototype.updateProfile = function (options, access_token, sub) {
|
|
1407
|
-
return new Promise(function (resolve, reject) {
|
|
1408
|
-
try {
|
|
1409
|
-
var http = new XMLHttpRequest();
|
|
1410
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/profile/" + sub;
|
|
1411
|
-
http.onreadystatechange = function () {
|
|
1412
|
-
if (http.readyState == 4) {
|
|
1413
|
-
if (http.responseText) {
|
|
1414
|
-
resolve(JSON.parse(http.responseText));
|
|
1415
|
-
} else {
|
|
1416
|
-
resolve(false);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
};
|
|
1420
|
-
http.open("PUT", _serviceURL, true);
|
|
1421
|
-
http = createHeaders(http, options);
|
|
1422
|
-
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1423
|
-
http.send(JSON.stringify(options));
|
|
1424
|
-
} catch (ex) {
|
|
1425
|
-
throw new CustomException(ex, 417);
|
|
1426
|
-
}
|
|
1427
|
-
});
|
|
1428
|
-
};
|
|
1429
|
-
|
|
1430
|
-
// get user activities
|
|
1431
|
-
WebAuth.prototype.getUserActivities = function (options, access_token) {
|
|
1432
|
-
var _serviceURL = window.webAuthSettings.authority + "/useractivity-srv/latestactivity";
|
|
1433
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1434
|
-
};
|
|
1435
|
-
|
|
1436
|
-
// get unreviewed devices
|
|
1437
|
-
WebAuth.prototype.getUnreviewedDevices = function (access_token, sub) {
|
|
1438
|
-
return new Promise(function (resolve, reject) {
|
|
1439
|
-
try {
|
|
1440
|
-
var http = new XMLHttpRequest();
|
|
1441
|
-
var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/unreviewlist/" + sub;
|
|
1442
|
-
http.onreadystatechange = function () {
|
|
1443
|
-
if (http.readyState == 4) {
|
|
1444
|
-
if (http.responseText) {
|
|
1445
|
-
resolve(JSON.parse(http.responseText));
|
|
1446
|
-
} else {
|
|
1447
|
-
resolve(false);
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
};
|
|
1451
|
-
http.open("GET", _serviceURL, true);
|
|
1452
|
-
http = createHeaders(http, null);
|
|
1453
|
-
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1454
|
-
|
|
1455
|
-
http.send();
|
|
1456
|
-
} catch (ex) {
|
|
1457
|
-
throw new CustomException(ex, 417);
|
|
1458
|
-
}
|
|
1459
|
-
});
|
|
1460
|
-
};
|
|
1461
|
-
|
|
1462
|
-
// get reviewed devices
|
|
1463
|
-
WebAuth.prototype.getReviewedDevices = function (access_token, sub) {
|
|
1464
|
-
return new Promise(function (resolve, reject) {
|
|
1465
|
-
try {
|
|
1466
|
-
var http = new XMLHttpRequest();
|
|
1467
|
-
var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/reviewlist/" + sub;
|
|
1468
|
-
http.onreadystatechange = function () {
|
|
1469
|
-
if (http.readyState == 4) {
|
|
1470
|
-
if (http.responseText) {
|
|
1471
|
-
resolve(JSON.parse(http.responseText));
|
|
1472
|
-
} else {
|
|
1473
|
-
resolve(false);
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
};
|
|
1477
|
-
http.open("GET", _serviceURL, true);
|
|
1478
|
-
http = createHeaders(http, null);
|
|
1479
|
-
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1480
|
-
http.send();
|
|
1481
|
-
} catch (ex) {
|
|
1482
|
-
throw new CustomException(ex, 417);
|
|
1483
|
-
}
|
|
1484
|
-
});
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
|
-
// review device
|
|
1488
|
-
WebAuth.prototype.reviewDevice = function (options, access_token, sub) {
|
|
1489
|
-
return new Promise(function (resolve, reject) {
|
|
1490
|
-
try {
|
|
1491
|
-
var http = new XMLHttpRequest();
|
|
1492
|
-
var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/updatereview";
|
|
1493
|
-
http.onreadystatechange = function () {
|
|
1494
|
-
if (http.readyState == 4) {
|
|
1495
|
-
if (http.responseText) {
|
|
1496
|
-
resolve(JSON.parse(http.responseText));
|
|
1497
|
-
} else {
|
|
1498
|
-
resolve(false);
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
};
|
|
1502
|
-
http.open("PUT", _serviceURL, true);
|
|
1503
|
-
http = createHeaders(http, options);
|
|
1504
|
-
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1505
|
-
http.send(JSON.stringify(options));
|
|
1506
|
-
} catch (ex) {
|
|
1507
|
-
throw new CustomException(ex, 417);
|
|
1508
|
-
}
|
|
1509
|
-
});
|
|
1510
|
-
};
|
|
1511
|
-
|
|
1512
|
-
// get accepted consent list
|
|
1513
|
-
WebAuth.prototype.getAcceptedConsentList = function (options, access_token) {
|
|
1514
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/user/details/consent";
|
|
1515
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1516
|
-
};
|
|
1517
|
-
|
|
1518
|
-
// view accepted consent
|
|
1519
|
-
WebAuth.prototype.viewAcceptedConsent = function (options, access_token) {
|
|
1520
|
-
return new Promise(function (resolve, reject) {
|
|
1521
|
-
try {
|
|
1522
|
-
var http = new XMLHttpRequest();
|
|
1523
|
-
var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/user/receipt/" + options.consentReceiptID + "?sub=" + options.sub;
|
|
1524
|
-
http.onreadystatechange = function () {
|
|
1525
|
-
if (http.readyState == 4) {
|
|
1526
|
-
if (http.responseText) {
|
|
1527
|
-
resolve(JSON.parse(http.responseText));
|
|
1528
|
-
} else {
|
|
1529
|
-
resolve(false);
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
};
|
|
1533
|
-
http.open("GET", _serviceURL, true);
|
|
1534
|
-
http = createHeaders(http, options);
|
|
1535
|
-
http.setRequestHeader("Authorization", `Bearer ${access_token}`);
|
|
1536
|
-
http.send();
|
|
1537
|
-
} catch (ex) {
|
|
1538
|
-
throw new CustomException(ex, 417);
|
|
1539
|
-
}
|
|
1540
|
-
});
|
|
1541
|
-
};
|
|
1542
|
-
|
|
1543
|
-
// get configured verification list
|
|
1544
|
-
WebAuth.prototype.getConfiguredVerificationList = function (options, access_token) {
|
|
1545
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/settings/list";
|
|
1546
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1547
|
-
};
|
|
1548
|
-
|
|
1549
|
-
// initiate link accoount
|
|
1550
|
-
WebAuth.prototype.initiateLinkAccount = function (options, access_token) {
|
|
1551
|
-
options.user_name_type = 'email';
|
|
1552
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/initiate";
|
|
1553
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1554
|
-
};
|
|
1555
|
-
|
|
1556
|
-
// complete link accoount
|
|
1557
|
-
WebAuth.prototype.completeLinkAccount = function (options, access_token) {
|
|
1558
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/complete";
|
|
1559
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1560
|
-
};
|
|
1561
|
-
|
|
1562
|
-
// get linked users
|
|
1563
|
-
WebAuth.prototype.getLinkedUsers = function (access_token, sub) {
|
|
1564
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo/social/" + sub;
|
|
1565
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1566
|
-
};
|
|
1567
|
-
|
|
1568
|
-
// unlink accoount
|
|
1569
|
-
WebAuth.prototype.unlinkAccount = function (access_token, identityId) {
|
|
1570
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unlink/" + identityId;
|
|
1571
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1572
|
-
};
|
|
1573
|
-
|
|
1574
|
-
// get all verification list
|
|
1575
|
-
WebAuth.prototype.getAllVerificationList = function (access_token) {
|
|
1576
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/config/list";
|
|
1577
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1578
|
-
};
|
|
1579
|
-
|
|
1580
|
-
// image upload
|
|
1581
|
-
WebAuth.prototype.updateProfileImage = function (options, access_token) {
|
|
1582
|
-
var _serviceURL = window.webAuthSettings.authority + "/image-srv/profile/upload";
|
|
1583
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1584
|
-
};
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
// setup email
|
|
1588
|
-
WebAuth.prototype.setupEmail = function (options) {
|
|
1589
|
-
options.verificationType = "EMAIL";
|
|
1590
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1591
|
-
return createPostPromise(options, _serviceURL, false, undefined);
|
|
1592
|
-
};
|
|
1593
|
-
|
|
1594
|
-
// setup sms
|
|
1595
|
-
WebAuth.prototype.setupSMS = function (options) {
|
|
1596
|
-
options.verificationType = "SMS";
|
|
1597
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1598
|
-
return createPostPromise(options, _serviceURL, false, undefined);
|
|
1599
|
-
};
|
|
1600
|
-
|
|
1601
|
-
// setup ivr
|
|
1602
|
-
WebAuth.prototype.setupIVR = function (options) {
|
|
1603
|
-
options.verificationType = "IVR";
|
|
1604
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1605
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1606
|
-
};
|
|
1607
|
-
|
|
1608
|
-
// setup backupcode
|
|
1609
|
-
WebAuth.prototype.setupBackupcode = function (options, access_token) {
|
|
1610
|
-
options.verificationType = "BACKUPCODE";
|
|
1611
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1612
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1613
|
-
};
|
|
1614
|
-
|
|
1615
|
-
// setup totp
|
|
1616
|
-
WebAuth.prototype.setupTOTP = function (options, access_token) {
|
|
1617
|
-
options.verificationType = "TOTP";
|
|
1618
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1619
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1620
|
-
};
|
|
1621
|
-
|
|
1622
|
-
// setup pattern
|
|
1623
|
-
WebAuth.prototype.setupPattern = function (options, access_token) {
|
|
1624
|
-
options.verificationType = "PATTERN";
|
|
1625
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1626
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1627
|
-
};
|
|
1628
|
-
|
|
1629
|
-
// setup touch
|
|
1630
|
-
WebAuth.prototype.setupTouchId = function (options, access_token) {
|
|
1631
|
-
options.verificationType = "TOUCHID";
|
|
1632
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1633
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1634
|
-
};
|
|
1635
|
-
|
|
1636
|
-
// setup smart push
|
|
1637
|
-
WebAuth.prototype.setupSmartPush = function (options, access_token) {
|
|
1638
|
-
options.verificationType = "PUSH";
|
|
1639
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1640
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1641
|
-
};
|
|
1642
|
-
|
|
1643
|
-
// setup face
|
|
1644
|
-
WebAuth.prototype.setupFace = function (options, access_token) {
|
|
1645
|
-
options.verificationType = "FACE";
|
|
1646
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1647
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1648
|
-
};
|
|
1649
|
-
|
|
1650
|
-
// setup voice
|
|
1651
|
-
WebAuth.prototype.setupVoice = function (options, access_token) {
|
|
1652
|
-
options.verificationType = "VOICE";
|
|
1653
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/setup";
|
|
1654
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1655
|
-
};
|
|
1656
|
-
|
|
1657
|
-
// enroll Email
|
|
1658
|
-
WebAuth.prototype.enrollEmail = function (options, access_token) {
|
|
1659
|
-
options.verificationType = "EMAIL";
|
|
1660
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/enroll";
|
|
1661
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1662
|
-
};
|
|
1663
|
-
|
|
1664
|
-
// enroll SMS
|
|
1665
|
-
WebAuth.prototype.enrollSMS = function (options, access_token) {
|
|
1666
|
-
options.verificationType = "SMS";
|
|
1667
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/enroll";
|
|
1668
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1669
|
-
};
|
|
1670
|
-
|
|
1671
|
-
// enroll IVR
|
|
1672
|
-
WebAuth.prototype.enrollIVR = function (options, access_token) {
|
|
1673
|
-
options.verificationType = "IVR";
|
|
1674
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/enroll";
|
|
1675
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1676
|
-
};
|
|
1677
|
-
|
|
1678
|
-
// enroll TOTP
|
|
1679
|
-
WebAuth.prototype.enrollTOTP = function (options, access_token) {
|
|
1680
|
-
options.verificationType = "TOTP";
|
|
1681
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + options.verificationType.toString().toLowerCase() + "/enroll";
|
|
1682
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1683
|
-
};
|
|
1684
|
-
|
|
1685
|
-
// updateSuggestMFA
|
|
1686
|
-
WebAuth.prototype.updateSuggestMFA = function (track_id, options) {
|
|
1687
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/suggested/mfa/update/" + track_id;
|
|
1688
|
-
return createPostPromise(options, _serviceURL, false);
|
|
1689
|
-
};
|
|
1690
|
-
|
|
1691
|
-
// enrollVerification
|
|
1692
|
-
WebAuth.prototype.enrollVerification = function (options) {
|
|
1693
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/enroll/" + options.verification_type;
|
|
1694
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1695
|
-
};
|
|
1696
|
-
|
|
1697
|
-
// updateSocket
|
|
1698
|
-
WebAuth.prototype.updateSocket = function (status_id) {
|
|
1699
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/notification/status/" + status_id;
|
|
1700
|
-
return createPostPromise(undefined, _serviceURL, undefined);
|
|
1701
|
-
};
|
|
1702
|
-
|
|
1703
|
-
// setupFidoVerification
|
|
1704
|
-
WebAuth.prototype.setupFidoVerification = function (options) {
|
|
1705
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/initiate/suggestmfa/" + options.verification_type;
|
|
1706
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1707
|
-
};
|
|
1708
|
-
|
|
1709
|
-
// checkVerificationTypeConfigured
|
|
1710
|
-
WebAuth.prototype.checkVerificationTypeConfigured = function (options) {
|
|
1711
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/public/configured/check/" + options.verification_type;
|
|
1712
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1713
|
-
};
|
|
1714
|
-
|
|
1715
|
-
// authenticateVerification
|
|
1716
|
-
WebAuth.prototype.authenticateVerification = function (options) {
|
|
1717
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/" + options.verification_type;
|
|
1718
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1719
|
-
};
|
|
1720
|
-
|
|
1721
|
-
// authenticateVerification form type (for face)
|
|
1722
|
-
WebAuth.prototype.authenticateFaceVerification = function (options) {
|
|
1723
|
-
return new Promise(function (resolve, reject) {
|
|
1724
|
-
try {
|
|
1725
|
-
var http = new XMLHttpRequest();
|
|
1726
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/face";
|
|
1727
|
-
http.onreadystatechange = function () {
|
|
1728
|
-
if (http.readyState == 4) {
|
|
1729
|
-
if (http.responseText) {
|
|
1730
|
-
resolve(JSON.parse(http.responseText));
|
|
1731
|
-
} else {
|
|
1732
|
-
resolve(undefined);
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
};
|
|
1736
|
-
http.open("POST", _serviceURL, true);
|
|
1737
|
-
http = createHeaders(http, options);
|
|
1738
|
-
http.setRequestHeader("Content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
|
|
1739
|
-
http.send(JSON.stringify(options));
|
|
1740
|
-
} catch (ex) {
|
|
1741
|
-
reject(ex);
|
|
1742
|
-
}
|
|
1743
|
-
});
|
|
1744
|
-
};
|
|
1745
|
-
|
|
1746
|
-
// initiateVerification
|
|
1747
|
-
WebAuth.prototype.initiateVerification = function (options) {
|
|
1748
|
-
var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/" + options.verification_type;
|
|
1749
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1750
|
-
};
|
|
1751
|
-
|
|
1752
|
-
// deleteUserAccount
|
|
1753
|
-
WebAuth.prototype.deleteUserAccount = function (options) {
|
|
1754
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unregister/scheduler/schedule/" + options.sub;
|
|
1755
|
-
return createPostPromise(options, _serviceURL, undefined, options.access_token);
|
|
1756
|
-
};
|
|
1757
|
-
|
|
1758
|
-
// getMissingFieldsLogin
|
|
1759
|
-
WebAuth.prototype.getMissingFieldsLogin = function (trackId) {
|
|
1760
|
-
return new Promise(function (resolve, reject) {
|
|
1761
|
-
try {
|
|
1762
|
-
var http = new XMLHttpRequest();
|
|
1763
|
-
var _serviceURL = window.webAuthSettings.authority + "/token-srv/prelogin/metadata/" + trackId;
|
|
1764
|
-
http.onreadystatechange = function () {
|
|
1765
|
-
if (http.readyState == 4) {
|
|
1766
|
-
if (http.responseText) {
|
|
1767
|
-
resolve(JSON.parse(http.responseText));
|
|
1768
|
-
} else {
|
|
1769
|
-
resolve(undefined);
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
};
|
|
1773
|
-
http.open("GET", _serviceURL, true);
|
|
1774
|
-
http = createHeaders(http, null);
|
|
1775
|
-
http.send();
|
|
1776
|
-
} catch (ex) {
|
|
1777
|
-
reject(ex);
|
|
1778
|
-
}
|
|
1779
|
-
});
|
|
1780
|
-
};
|
|
1781
|
-
|
|
1782
|
-
// progressiveRegistration
|
|
1783
|
-
WebAuth.prototype.progressiveRegistration = function (options, headers) {
|
|
1784
|
-
return new Promise(function (resolve, reject) {
|
|
1785
|
-
try {
|
|
1786
|
-
var http = new XMLHttpRequest();
|
|
1787
|
-
var _serviceURL = window.webAuthSettings.authority + "/login-srv/progressive/update/user";
|
|
1788
|
-
http.onreadystatechange = function () {
|
|
1789
|
-
if (http.readyState == 4) {
|
|
1790
|
-
if (http.responseText) {
|
|
1791
|
-
resolve(JSON.parse(http.responseText));
|
|
1792
|
-
} else {
|
|
1793
|
-
resolve(undefined);
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
};
|
|
1797
|
-
http.open("POST", _serviceURL, true);
|
|
1798
|
-
http = createHeaders(http, options);
|
|
1799
|
-
http.setRequestHeader("requestId", headers.requestId);
|
|
1800
|
-
http.setRequestHeader("trackId", headers.trackId);
|
|
1801
|
-
http.send(JSON.stringify(options));
|
|
1802
|
-
} catch (ex) {
|
|
1803
|
-
reject(ex);
|
|
1804
|
-
}
|
|
1805
|
-
});
|
|
1806
|
-
};
|
|
1807
|
-
|
|
1808
|
-
// loginAfterRegister
|
|
1809
|
-
WebAuth.prototype.loginAfterRegister = function (options) {
|
|
1810
|
-
try {
|
|
1811
|
-
var form = document.createElement('form');
|
|
1812
|
-
form.action = window.webAuthSettings.authority + "/login-srv/login/handle/afterregister/" + options.trackId;
|
|
1813
|
-
form.method = 'POST';
|
|
1814
|
-
for (var key in options) {
|
|
1815
|
-
if (options.hasOwnProperty(key)) {
|
|
1816
|
-
var hiddenField = document.createElement("input");
|
|
1817
|
-
hiddenField.setAttribute("type", "hidden");
|
|
1818
|
-
hiddenField.setAttribute("name", key);
|
|
1819
|
-
hiddenField.setAttribute("value", options[key]);
|
|
1820
|
-
|
|
1821
|
-
form.appendChild(hiddenField);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
document.body.appendChild(form);
|
|
1825
|
-
form.submit();
|
|
1826
|
-
} catch (ex) {
|
|
1827
|
-
throw new CustomException(ex, 417);
|
|
1828
|
-
}
|
|
1829
|
-
};
|
|
1830
|
-
|
|
1831
|
-
// device code flow - verify
|
|
1832
|
-
WebAuth.prototype.deviceCodeVerify = function (code) {
|
|
1833
|
-
const params = `user_code=${encodeURI(code)}`;
|
|
1834
|
-
const url = `${window.webAuthSettings.authority}/token-srv/device/verify?${params}`;
|
|
1835
|
-
try {
|
|
1836
|
-
const form = document.createElement('form');
|
|
1837
|
-
form.action = url
|
|
1838
|
-
form.method = 'GET';
|
|
1839
|
-
const hiddenField = document.createElement("input");
|
|
1840
|
-
hiddenField.setAttribute("type", "hidden");
|
|
1841
|
-
hiddenField.setAttribute("name", 'user_code');
|
|
1842
|
-
hiddenField.setAttribute("value", encodeURI(code));
|
|
1843
|
-
|
|
1844
|
-
form.appendChild(hiddenField);
|
|
1845
|
-
document.body.appendChild(form);
|
|
1846
|
-
form.submit();
|
|
1847
|
-
} catch (ex) {
|
|
1848
|
-
throw new Error(ex);
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
WebAuth.prototype.userCheckExists = function (options) {
|
|
1854
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/checkexists/" + options.requestId;
|
|
1855
|
-
return createPostPromise(options, _serviceURL, undefined);
|
|
1856
|
-
};
|
|
1857
|
-
|
|
1858
|
-
WebAuth.prototype.setAcceptLanguageHeader = function (acceptLanguage) {
|
|
1859
|
-
window.localeSettings = acceptLanguage;
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
// get device info
|
|
1863
|
-
WebAuth.prototype.getDeviceInfo = function () {
|
|
1864
|
-
return new Promise(function (resolve, reject) {
|
|
1865
|
-
try {
|
|
1866
|
-
const value = ('; ' + document.cookie).split(`; cidaas_dr=`).pop().split(';')[0];
|
|
1867
|
-
const fpPromise = fingerprint.load();
|
|
1868
|
-
var options = { fingerprint: "", userAgent: "" };
|
|
1869
|
-
if (!value) {
|
|
1870
|
-
(async () => {
|
|
1871
|
-
const fp = await fpPromise;
|
|
1872
|
-
const result = await fp.get();
|
|
1873
|
-
options.fingerprint = result.visitorId
|
|
1874
|
-
options.userAgent = window.navigator.userAgent
|
|
1875
|
-
var http = new XMLHttpRequest();
|
|
1876
|
-
var _serviceURL = window.webAuthSettings.authority + "/device-srv/deviceinfo";
|
|
1877
|
-
http.onreadystatechange = function () {
|
|
1878
|
-
if (http.readyState == 4) {
|
|
1879
|
-
resolve(JSON.parse(http.responseText));
|
|
1880
|
-
}
|
|
1881
|
-
};
|
|
1882
|
-
http.open("POST", _serviceURL, true);
|
|
1883
|
-
http = createHeaders(http, options);
|
|
1884
|
-
http.send(JSON.stringify(options));
|
|
1885
|
-
})();
|
|
1886
|
-
}
|
|
1887
|
-
} catch (ex) {
|
|
1888
|
-
reject(ex);
|
|
1889
|
-
}
|
|
1890
|
-
});
|
|
1891
|
-
};
|
|
1892
|
-
|
|
1893
|
-
// initiates a new user link to link two existing users
|
|
1894
|
-
WebAuth.prototype.userAccountLink = function (options, access_token) {
|
|
1895
|
-
var _serviceURL = window.webAuthSettings.authority + "/useractions-srv/users/" + options.sub + "/link";
|
|
1896
|
-
return createPostPromise(options, _serviceURL, false, access_token);
|
|
1897
|
-
};
|
|
1898
|
-
|
|
1899
|
-
module.exports = WebAuth;
|