cidaas-javascript-sdk 3.1.5 → 4.0.1

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.
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -38,7 +49,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
49
  exports.__esModule = true;
39
50
  exports.WebAuth = void 0;
40
51
  var oidc_client_ts_1 = require("oidc-client-ts");
41
- var CryptoJS = require("crypto-js");
42
52
  var authentication_1 = require("../authentication");
43
53
  var Helper_1 = require("./Helper");
44
54
  var LoginService_1 = require("./LoginService");
@@ -55,12 +65,6 @@ var WebAuth = /** @class */ (function () {
55
65
  if (!settings.scope) {
56
66
  settings.scope = "email openid profile mobile";
57
67
  }
58
- if (!settings.mode) {
59
- settings.mode = 'redirect';
60
- }
61
- if (!settings.cidaas_version) {
62
- settings.cidaas_version = 2;
63
- }
64
68
  var usermanager = new oidc_client_ts_1.UserManager(settings);
65
69
  window.webAuthSettings = settings;
66
70
  window.usermanager = usermanager;
@@ -74,14 +78,6 @@ var WebAuth = /** @class */ (function () {
74
78
  console.log(ex);
75
79
  }
76
80
  }
77
- /**
78
- * @param string
79
- * @returns
80
- */
81
- WebAuth.prototype.base64URL = function (string) {
82
- return string.toString(CryptoJS.enc.Base64).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
83
- };
84
- ;
85
81
  // prototype methods
86
82
  /**
87
83
  * login
@@ -91,23 +87,49 @@ var WebAuth = /** @class */ (function () {
91
87
  if (!window.webAuthSettings && !window.authentication) {
92
88
  throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
93
89
  }
94
- switch (window.webAuthSettings.mode) {
95
- case 'redirect':
96
- window.authentication.redirectSignIn('login');
97
- break;
98
- case 'window':
99
- window.authentication.popupSignIn();
100
- break;
101
- case 'silent':
102
- window.authentication.silentSignIn();
103
- break;
90
+ window.authentication.loginOrRegisterWithBrowser('login');
91
+ }
92
+ catch (ex) {
93
+ console.log(ex);
94
+ }
95
+ };
96
+ ;
97
+ /**
98
+ * popupSignIn
99
+ */
100
+ WebAuth.prototype.popupSignIn = function () {
101
+ try {
102
+ if (!window.webAuthSettings && !window.authentication) {
103
+ throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
104
104
  }
105
+ window.authentication.popupSignIn();
105
106
  }
106
107
  catch (ex) {
107
108
  console.log(ex);
108
109
  }
109
110
  };
110
111
  ;
112
+ /**
113
+ * silentSignIn
114
+ */
115
+ WebAuth.prototype.silentSignIn = function () {
116
+ return new Promise(function (resolve, reject) {
117
+ try {
118
+ if (!window.webAuthSettings && !window.authentication) {
119
+ throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
120
+ }
121
+ window.authentication.silentSignIn().then(function (user) {
122
+ resolve(user);
123
+ })["catch"](function (ex) {
124
+ reject(ex);
125
+ });
126
+ }
127
+ catch (ex) {
128
+ console.log(ex);
129
+ }
130
+ });
131
+ };
132
+ ;
111
133
  /**
112
134
  * register
113
135
  */
@@ -116,17 +138,7 @@ var WebAuth = /** @class */ (function () {
116
138
  if (!window.webAuthSettings && !window.authentication) {
117
139
  throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
118
140
  }
119
- switch (window.webAuthSettings.mode) {
120
- case 'redirect':
121
- window.authentication.redirectSignIn('register');
122
- break;
123
- case 'window':
124
- window.authentication.popupSignIn();
125
- break;
126
- case 'silent':
127
- window.authentication.silentSignIn();
128
- break;
129
- }
141
+ window.authentication.loginOrRegisterWithBrowser('register');
130
142
  }
131
143
  catch (ex) {
132
144
  console.log(ex);
@@ -143,25 +155,29 @@ var WebAuth = /** @class */ (function () {
143
155
  if (!window.webAuthSettings && !window.authentication) {
144
156
  throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
145
157
  }
146
- switch (window.webAuthSettings.mode) {
147
- case 'redirect':
148
- window.authentication.redirectSignInCallback().then(function (user) {
149
- resolve(user);
150
- })["catch"](function (ex) {
151
- reject(ex);
152
- });
153
- break;
154
- case 'window':
155
- window.authentication.popupSignInCallback();
156
- break;
157
- case 'silent':
158
- window.authentication.silentSignInCallbackV2().then(function (data) {
159
- resolve(data);
160
- })["catch"](function (error) {
161
- reject(error);
162
- });
163
- break;
158
+ window.authentication.loginCallback().then(function (user) {
159
+ resolve(user);
160
+ })["catch"](function (ex) {
161
+ reject(ex);
162
+ });
163
+ }
164
+ catch (ex) {
165
+ console.log(ex);
166
+ }
167
+ });
168
+ };
169
+ ;
170
+ /**
171
+ * popup signin callback
172
+ * @returns
173
+ */
174
+ WebAuth.prototype.popupSignInCallback = function () {
175
+ return new Promise(function (resolve, reject) {
176
+ try {
177
+ if (!window.webAuthSettings && !window.authentication) {
178
+ throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
164
179
  }
180
+ window.authentication.popupSignInCallback();
165
181
  }
166
182
  catch (ex) {
167
183
  console.log(ex);
@@ -170,9 +186,38 @@ var WebAuth = /** @class */ (function () {
170
186
  };
171
187
  ;
172
188
  /**
173
- * get user info
189
+ * silent signin callback
174
190
  * @returns
175
191
  */
192
+ WebAuth.prototype.silentSignInCallback = function () {
193
+ return new Promise(function (resolve, reject) {
194
+ try {
195
+ if (!window.webAuthSettings && !window.authentication) {
196
+ throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
197
+ }
198
+ window.authentication.silentSignInCallback().then(function (data) {
199
+ resolve(data);
200
+ })["catch"](function (error) {
201
+ reject(error);
202
+ });
203
+ }
204
+ catch (ex) {
205
+ console.log(ex);
206
+ }
207
+ });
208
+ };
209
+ ;
210
+ /**
211
+ * To get the user profile information by using oidc-client-ts library, call **getUserInfo()**. This will return the basic user profile details along with groups, roles and whatever scopes you mentioned in the options.
212
+ * @example
213
+ * ```js
214
+ * cidaas.getUserInfo().then(function (response) {
215
+ * // the response will give you profile details.
216
+ * }).catch(function(ex) {
217
+ * // your failure code here
218
+ * });;
219
+ * ```
220
+ */
176
221
  WebAuth.prototype.getUserInfo = function () {
177
222
  return __awaiter(this, void 0, void 0, function () {
178
223
  var e_1;
@@ -195,7 +240,7 @@ var WebAuth = /** @class */ (function () {
195
240
  };
196
241
  ;
197
242
  /**
198
- * logout
243
+ * logout by using oidc-client-ts library
199
244
  * @returns
200
245
  */
201
246
  WebAuth.prototype.logout = function () {
@@ -204,21 +249,10 @@ var WebAuth = /** @class */ (function () {
204
249
  if (!window.webAuthSettings && !window.authentication) {
205
250
  throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
206
251
  }
207
- if (window.webAuthSettings.mode == 'redirect') {
208
- window.authentication.redirectSignOut().then(function (result) {
209
- resolve(result);
210
- return;
211
- });
212
- }
213
- else if (window.webAuthSettings.mode == 'window') {
214
- window.authentication.popupSignOut();
215
- }
216
- else if (window.webAuthSettings.mode == 'silent') {
217
- window.authentication.redirectSignOut();
218
- }
219
- else {
220
- resolve(undefined);
221
- }
252
+ window.authentication.logout().then(function (result) {
253
+ resolve(result);
254
+ return;
255
+ });
222
256
  }
223
257
  catch (ex) {
224
258
  reject(ex);
@@ -227,26 +261,16 @@ var WebAuth = /** @class */ (function () {
227
261
  };
228
262
  ;
229
263
  /**
230
- * logout callback
264
+ * popup signout
231
265
  * @returns
232
266
  */
233
- WebAuth.prototype.logoutCallback = function () {
267
+ WebAuth.prototype.popupSignOut = function () {
234
268
  return new Promise(function (resolve, reject) {
235
269
  try {
236
270
  if (!window.webAuthSettings && !window.authentication) {
237
271
  throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
238
272
  }
239
- if (window.webAuthSettings.mode == 'redirect') {
240
- window.authentication.redirectSignOutCallback().then(function (resp) {
241
- resolve(resp);
242
- });
243
- }
244
- else if (window.webAuthSettings.mode == 'window') {
245
- window.authentication.popupSignOutCallback();
246
- }
247
- else if (window.webAuthSettings.mode == 'silent') {
248
- window.authentication.redirectSignOutCallback();
249
- }
273
+ window.authentication.popupSignOut();
250
274
  }
251
275
  catch (ex) {
252
276
  reject(ex);
@@ -255,79 +279,36 @@ var WebAuth = /** @class */ (function () {
255
279
  };
256
280
  ;
257
281
  /**
258
- * get login url
282
+ * logout callback
259
283
  * @returns
260
284
  */
261
- WebAuth.prototype.getLoginURL = function () {
262
- var _this = this;
263
- var loginUrl;
264
- var finish = false;
265
- (function () { return __awaiter(_this, void 0, void 0, function () {
266
- var e_2;
267
- return __generator(this, function (_a) {
268
- switch (_a.label) {
269
- case 0:
270
- _a.trys.push([0, 2, , 3]);
271
- return [4 /*yield*/, window.usermanager._client.getSignInRedirectUrl()];
272
- case 1:
273
- loginUrl = _a.sent();
274
- return [3 /*break*/, 3];
275
- case 2:
276
- e_2 = _a.sent();
277
- //TODO: define Error handling
278
- console.log(e_2);
279
- return [3 /*break*/, 3];
280
- case 3:
281
- finish = true;
282
- return [2 /*return*/];
285
+ WebAuth.prototype.logoutCallback = function () {
286
+ return new Promise(function (resolve, reject) {
287
+ try {
288
+ if (!window.webAuthSettings && !window.authentication) {
289
+ throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
283
290
  }
284
- });
285
- }); })();
286
- while (!finish) { } // A simple synchronous loop to wait async call is finish
287
- return loginUrl;
291
+ window.authentication.logoutCallback().then(function (resp) {
292
+ resolve(resp);
293
+ });
294
+ }
295
+ catch (ex) {
296
+ reject(ex);
297
+ }
298
+ });
288
299
  };
289
300
  ;
290
301
  /**
291
- * get request id
302
+ * popup signout callback
292
303
  * @returns
293
304
  */
294
- WebAuth.prototype.getRequestId = function () {
305
+ WebAuth.prototype.popupSignOutCallback = function () {
295
306
  return new Promise(function (resolve, reject) {
296
307
  try {
297
- var respone_type = window.webAuthSettings.response_type;
298
- if (!respone_type) {
299
- respone_type = "token";
300
- }
301
- var response_mode = window.webAuthSettings.response_mode;
302
- if (!response_mode) {
303
- response_mode = "fragment";
304
- }
305
- var bodyParams = {
306
- "client_id": window.webAuthSettings.client_id,
307
- "redirect_uri": window.webAuthSettings.redirect_uri,
308
- "response_type": respone_type,
309
- "response_mode": response_mode,
310
- "scope": window.webAuthSettings.scope,
311
- "nonce": new Date().getTime().toString()
312
- };
313
- var http = new XMLHttpRequest();
314
- var _serviceURL = window.webAuthSettings.authority + "/authz-srv/authrequest/authz/generate";
315
- http.onreadystatechange = function () {
316
- if (http.readyState == 4) {
317
- if (http.responseText) {
318
- resolve(JSON.parse(http.responseText));
319
- }
320
- else {
321
- resolve(false);
322
- }
323
- }
324
- };
325
- http.open("POST", _serviceURL, true);
326
- http.setRequestHeader("Content-type", "application/json");
327
- if (window.localeSettings) {
328
- http.setRequestHeader("accept-language", window.localeSettings);
308
+ if (!window.webAuthSettings && !window.authentication) {
309
+ throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
329
310
  }
330
- http.send(JSON.stringify(bodyParams));
311
+ window.authentication.popupSignOutCallback();
331
312
  }
332
313
  catch (ex) {
333
314
  reject(ex);
@@ -336,27 +317,74 @@ var WebAuth = /** @class */ (function () {
336
317
  };
337
318
  ;
338
319
  /**
339
- * get missing fields
340
- * @param options
341
- * @returns
320
+ * To get the generated login url, call **getLoginURL()**. This will call authz service and generate login url to be used.
321
+ * @example
322
+ * ```js
323
+ * cidaas.getLoginURL().then(function (response) {
324
+ * // the response will give you login url.
325
+ * }).catch(function(ex) {
326
+ * // your failure code here
327
+ * });;
328
+ * ```
342
329
  */
343
- WebAuth.prototype.getMissingFields = function (options) {
344
- var _serviceURL = window.webAuthSettings.authority + "/public-srv/public/trackinfo/" + options.requestId + "/" + options.trackId;
345
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
330
+ WebAuth.prototype.getLoginURL = function (state) {
331
+ return new Promise(function (resolve, reject) {
332
+ try {
333
+ window.usermanager._client.createSigninRequest({ state: state }).then(function (signinRequest) {
334
+ resolve(signinRequest.url);
335
+ return;
336
+ });
337
+ }
338
+ catch (e) {
339
+ reject(e);
340
+ }
341
+ });
346
342
  };
347
343
  ;
348
344
  /**
349
- * get Tenant info
350
- * @returns
345
+ * Each and every proccesses starts with requestId, it is an entry point to login or register. For getting the requestId, call **getRequestId()**.
346
+ * @example
347
+ * ```js
348
+ * cidaas.getRequestId().then(function (response) {
349
+ * // the response will give you request id.
350
+ * }).catch(function(ex) {
351
+ * // your failure code here
352
+ * });;
353
+ * ```
354
+ */
355
+ WebAuth.prototype.getRequestId = function () {
356
+ var _a, _b;
357
+ var ui_locales = window.webAuthSettings.ui_locales;
358
+ var options = __assign({ 'client_id': window.webAuthSettings.client_id, 'redirect_uri': window.webAuthSettings.redirect_uri, 'response_type': (_a = window.webAuthSettings.response_type) !== null && _a !== void 0 ? _a : 'token', "response_mode": (_b = window.webAuthSettings.response_mode) !== null && _b !== void 0 ? _b : 'fragment', "scope": window.webAuthSettings.scope, "nonce": new Date().getTime().toString() }, (ui_locales && { ui_locales: ui_locales } || {}));
359
+ var serviceURL = window.webAuthSettings.authority + '/authz-srv/authrequest/authz/generate';
360
+ return Helper_1.Helper.createHttpPromise(options, serviceURL, false, "POST");
361
+ };
362
+ ;
363
+ /**
364
+ * To get the tenant basic information, call **getTenantInfo()**. This will return the basic tenant details such as tenant name and allowed login with types (Email, Mobile, Username).
365
+ * @example
366
+ * ```js
367
+ * cidaas.getTenantInfo().then(function (response) {
368
+ * // the response will give you tenant details
369
+ * }).catch(function(ex) {
370
+ * // your failure code here
371
+ * });;
372
+ * ```
351
373
  */
352
374
  WebAuth.prototype.getTenantInfo = function () {
353
375
  var _serviceURL = window.webAuthSettings.authority + "/public-srv/tenantinfo/basic";
354
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
376
+ return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
355
377
  };
356
378
  ;
357
379
  /**
358
- * logout api call
359
- * @param options
380
+ * To logout the user by using cidaas internal api, call **logoutUser()**.
381
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/3b5ce6a54bf29-logout for more details.
382
+ * @example
383
+ * ```js
384
+ * cidaas.logoutUser({
385
+ * access_token : 'your accessToken'
386
+ * });
387
+ * ```
360
388
  */
361
389
  WebAuth.prototype.logoutUser = function (options) {
362
390
  try {
@@ -368,156 +396,120 @@ var WebAuth = /** @class */ (function () {
368
396
  };
369
397
  ;
370
398
  /**
371
- * get Client Info
372
- * @param options
373
- * @returns
399
+ * To get the client basic information, call **getClientInfo()**. This will return the basic client details such as client name and its details.
400
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/dc8a6cfb28abb-public-page-information for more details.
401
+ * @example
402
+ * ```js
403
+ * cidaas.getClientInfo({
404
+ * requestId: 'your requestId',
405
+ * }).then(function (resp) {
406
+ * // the response will give you client info.
407
+ * }).catch(function(ex) {
408
+ * // your failure code here
409
+ * });
410
+ * ```
374
411
  */
375
412
  WebAuth.prototype.getClientInfo = function (options) {
376
413
  var _serviceURL = window.webAuthSettings.authority + "/public-srv/public/" + options.requestId;
377
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
414
+ return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
378
415
  };
379
416
  ;
380
417
  /**
381
- * get all devices associated to the client
382
- * @param options
383
- * @returns
418
+ * To get all devices information associated to the client, call **getDevicesInfo()**
419
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/2a2feed70303c-get-device-by-user for more details.
420
+ * @example
421
+ * ```js
422
+ * const options = {};
423
+ * const accessToken = 'your access token';
424
+ * cidaas.getDevicesInfo(options, accessToken).then(function (resp) {
425
+ * // the response will give you devices informations.
426
+ * }).catch(function(ex) {
427
+ * // your failure code here
428
+ * });
429
+ * ```
384
430
  */
385
- WebAuth.prototype.getDevicesInfo = function (options) {
431
+ WebAuth.prototype.getDevicesInfo = function (options, accessToken) {
386
432
  options.userAgent = window.navigator.userAgent;
387
433
  var _serviceURL = window.webAuthSettings.authority + "/device-srv/devices";
388
434
  if (window.navigator.userAgent) {
389
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "GET");
435
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "GET", accessToken);
390
436
  }
391
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET");
392
- };
393
- ;
394
- /**
395
- * delete a device
396
- * @param options
397
- * @returns
398
- */
399
- WebAuth.prototype.deleteDevice = function (options) {
437
+ return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET", accessToken);
438
+ };
439
+ ;
440
+ /**
441
+ * To delete device associated to the client, call **deleteDevice()**
442
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/3d44ad903d6e8-logout-the-user-for-a-device for more details.
443
+ * @example
444
+ * ```js
445
+ * const options = {
446
+ * device_id: 'id of device associated to the client.' // call **getDevicesInfo()** to get List of device ids and its details.
447
+ * };
448
+ * const accessToken = 'your access token';
449
+ * cidaas.deleteDevice(options, accessToken).then(function (resp) {
450
+ * // your success code
451
+ * }).catch(function(ex) {
452
+ * // your failure code
453
+ * });
454
+ * ```
455
+ */
456
+ WebAuth.prototype.deleteDevice = function (options, accessToken) {
400
457
  var _serviceURL = window.webAuthSettings.authority + "/device-srv/device/" + options.device_id;
401
458
  options.userAgent = window.navigator.userAgent;
402
459
  if (window.navigator.userAgent) {
403
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "DELETE");
460
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "DELETE", accessToken);
404
461
  }
405
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "DELETE");
462
+ return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "DELETE", accessToken);
406
463
  };
407
464
  ;
408
465
  /**
409
- * get Registration setup
410
- * @param options
411
- * @returns
466
+ * To handle registration, first you need the registration fields. To get the registration fields, call **getRegistrationSetup()**. This will return the fields that has to be needed while registration.
467
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/4eae72956f65a-registration-field-setup for more details.
468
+ * @example
469
+ * ```js
470
+ * cidaas.getRegistrationSetup({
471
+ * requestId: 'your requestId',
472
+ * acceptlanguage: 'your locale' // optional example: de-de, en-US
473
+ * }).then(function (resp) {
474
+ * // the response will give you fields that are required.
475
+ * }).catch(function(ex) {
476
+ * // your failure code here
477
+ * });
478
+ * ```
412
479
  */
413
480
  WebAuth.prototype.getRegistrationSetup = function (options) {
414
- return new Promise(function (resolve, reject) {
415
- try {
416
- var http = new XMLHttpRequest();
417
- var _serviceURL = window.webAuthSettings.authority + "/registration-setup-srv/public/list?acceptlanguage=" + options.acceptlanguage + "&requestId=" + options.requestId;
418
- http.onreadystatechange = function () {
419
- if (http.readyState == 4) {
420
- if (http.responseText) {
421
- var parsedResponse = JSON.parse(http.responseText);
422
- if (parsedResponse && parsedResponse.data && parsedResponse.data.length > 0) {
423
- var registrationFields = parsedResponse.data;
424
- }
425
- resolve(parsedResponse);
426
- }
427
- else {
428
- resolve(false);
429
- }
430
- }
431
- };
432
- http.open("GET", _serviceURL, true);
433
- http.setRequestHeader("Content-type", "application/json");
434
- var acceptLanguage = options.acceptlanguage ? options.acceptlanguage : window === null || window === void 0 ? void 0 : window.localeSettings;
435
- http.setRequestHeader("accept-language", acceptLanguage);
436
- http.send();
437
- }
438
- catch (ex) {
439
- reject(ex);
440
- }
441
- });
442
- };
443
- ;
444
- /**
445
- * get unreviewed devices
446
- * @param access_token
447
- * @param sub
448
- * @returns
449
- */
450
- WebAuth.prototype.getUnreviewedDevices = function (access_token, sub) {
451
- var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/unreviewlist/" + sub;
452
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET", access_token);
453
- };
454
- ;
455
- /**
456
- * get reviewed devices
457
- * @param access_token
458
- * @param sub
459
- * @returns
460
- */
461
- WebAuth.prototype.getReviewedDevices = function (access_token, sub) {
462
- var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/reviewlist/" + sub;
463
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, "GET", access_token);
481
+ var serviceURL = window.webAuthSettings.authority + '/registration-setup-srv/public/list?acceptlanguage=' + options.acceptlanguage + '&requestId=' + options.requestId;
482
+ return Helper_1.Helper.createHttpPromise(undefined, serviceURL, false, 'GET');
483
+ };
484
+ ;
485
+ /**
486
+ * to generate device info, call **createDeviceInfo()**.
487
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/9b5a892afaf0b-create-device-info for more details.
488
+ * @example
489
+ * ```js
490
+ * cidaas.createDeviceInfo().then(function (resp) {
491
+ * // your success code
492
+ * }).catch(function(ex) {
493
+ * // your failure code
494
+ * });
495
+ * ```
496
+ */
497
+ WebAuth.prototype.createDeviceInfo = function () {
498
+ var value = ('; ' + document.cookie).split("; cidaas_dr=").pop().split(';')[0];
499
+ if (!value) {
500
+ var options = {
501
+ userAgent: window.navigator.userAgent
502
+ };
503
+ var serviceURL = window.webAuthSettings.authority + '/device-srv/deviceinfo';
504
+ return Helper_1.Helper.createHttpPromise(options, serviceURL, false, 'POST');
505
+ }
464
506
  };
465
507
  ;
466
508
  /**
467
- * review device
509
+ * get the user profile information
468
510
  * @param options
469
- * @param access_token
470
511
  * @returns
471
512
  */
472
- WebAuth.prototype.reviewDevice = function (options, access_token) {
473
- var _serviceURL = window.webAuthSettings.authority + "/reports-srv/device/updatereview";
474
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "PUT", access_token);
475
- };
476
- ;
477
- /**
478
- * get device info
479
- * @returns
480
- */
481
- WebAuth.prototype.getDeviceInfo = function () {
482
- var _this = this;
483
- return new Promise(function (resolve, reject) {
484
- try {
485
- var value = ('; ' + document.cookie).split("; cidaas_dr=").pop().split(';')[0];
486
- var options = { userAgent: "" };
487
- if (!value) {
488
- (function () { return __awaiter(_this, void 0, void 0, function () {
489
- var http, _serviceURL;
490
- return __generator(this, function (_a) {
491
- options.userAgent = window.navigator.userAgent;
492
- http = new XMLHttpRequest();
493
- _serviceURL = window.webAuthSettings.authority + "/device-srv/deviceinfo";
494
- http.onreadystatechange = function () {
495
- if (http.readyState == 4) {
496
- resolve(JSON.parse(http.responseText));
497
- }
498
- };
499
- http.open("POST", _serviceURL, true);
500
- http.setRequestHeader("Content-type", "application/json");
501
- if (window.localeSettings) {
502
- http.setRequestHeader("accept-language", window.localeSettings);
503
- }
504
- http.send(JSON.stringify(options));
505
- return [2 /*return*/];
506
- });
507
- }); })();
508
- }
509
- }
510
- catch (ex) {
511
- reject(ex);
512
- }
513
- });
514
- };
515
- ;
516
- /**
517
- * get user info
518
- * @param options
519
- * @returns
520
- */
521
513
  WebAuth.prototype.getUserProfile = function (options) {
522
514
  return UserService_1.UserService.getUserProfile(options);
523
515
  };
@@ -557,24 +549,6 @@ var WebAuth = /** @class */ (function () {
557
549
  LoginService_1.LoginService.loginWithCredentials(options);
558
550
  };
559
551
  ;
560
- /**
561
- * login with username and password and return response
562
- * @param options
563
- * @returns
564
- */
565
- WebAuth.prototype.loginWithCredentialsAsynFn = function (options) {
566
- return __awaiter(this, void 0, void 0, function () {
567
- return __generator(this, function (_a) {
568
- switch (_a.label) {
569
- case 0: return [4 /*yield*/, LoginService_1.LoginService.loginWithCredentialsAsynFn(options)];
570
- case 1:
571
- _a.sent();
572
- return [2 /*return*/];
573
- }
574
- });
575
- });
576
- };
577
- ;
578
552
  /**
579
553
  * login with social
580
554
  * @param options
@@ -617,8 +591,8 @@ var WebAuth = /** @class */ (function () {
617
591
  * @param options
618
592
  * @returns
619
593
  */
620
- WebAuth.prototype.getCommunicationStatus = function (options) {
621
- return UserService_1.UserService.getCommunicationStatus(options);
594
+ WebAuth.prototype.getCommunicationStatus = function (options, headers) {
595
+ return UserService_1.UserService.getCommunicationStatus(options, headers);
622
596
  };
623
597
  ;
624
598
  /**
@@ -630,22 +604,6 @@ var WebAuth = /** @class */ (function () {
630
604
  VerificationService_1.VerificationService.initiateAccountVerification(options);
631
605
  };
632
606
  ;
633
- /**
634
- * initiate verification and return response
635
- * @param options
636
- * @returns
637
- */
638
- WebAuth.prototype.initiateAccountVerificationAsynFn = function (options) {
639
- return __awaiter(this, void 0, void 0, function () {
640
- return __generator(this, function (_a) {
641
- switch (_a.label) {
642
- case 0: return [4 /*yield*/, VerificationService_1.VerificationService.initiateAccountVerificationAsynFn(options)];
643
- case 1: return [2 /*return*/, _a.sent()];
644
- }
645
- });
646
- });
647
- };
648
- ;
649
607
  /**
650
608
  * verify account
651
609
  * @param options
@@ -681,21 +639,21 @@ var WebAuth = /** @class */ (function () {
681
639
  };
682
640
  ;
683
641
  /**
684
- * get mfa list v2
642
+ * get mfa list
685
643
  * @param options
686
644
  * @returns
687
645
  */
688
- WebAuth.prototype.getMFAListV2 = function (options) {
689
- return VerificationService_1.VerificationService.getMFAListV2(options);
646
+ WebAuth.prototype.getMFAList = function (options) {
647
+ return VerificationService_1.VerificationService.getMFAList(options);
690
648
  };
691
649
  ;
692
650
  /**
693
- * cancel mfa v2
651
+ * cancel mfa
694
652
  * @param options
695
653
  * @returns
696
654
  */
697
- WebAuth.prototype.cancelMFAV2 = function (options) {
698
- return VerificationService_1.VerificationService.cancelMFAV2(options);
655
+ WebAuth.prototype.cancelMFA = function (options) {
656
+ return VerificationService_1.VerificationService.cancelMFA(options);
699
657
  };
700
658
  ;
701
659
  /**
@@ -711,17 +669,17 @@ var WebAuth = /** @class */ (function () {
711
669
  * @param options
712
670
  * @returns
713
671
  */
714
- WebAuth.prototype.getConsentDetailsV2 = function (options) {
715
- return ConsentService_1.ConsentService.getConsentDetailsV2(options);
672
+ WebAuth.prototype.getConsentDetails = function (options) {
673
+ return ConsentService_1.ConsentService.getConsentDetails(options);
716
674
  };
717
675
  ;
718
676
  /**
719
- * accept consent v2
677
+ * accept consent
720
678
  * @param options
721
679
  * @returns
722
680
  */
723
- WebAuth.prototype.acceptConsentV2 = function (options) {
724
- return ConsentService_1.ConsentService.acceptConsentV2(options);
681
+ WebAuth.prototype.acceptConsent = function (options) {
682
+ return ConsentService_1.ConsentService.acceptConsent(options);
725
683
  };
726
684
  ;
727
685
  /**
@@ -729,8 +687,8 @@ var WebAuth = /** @class */ (function () {
729
687
  * @param options
730
688
  * @returns
731
689
  */
732
- WebAuth.prototype.getScopeConsentDetails = function (options) {
733
- return TokenService_1.TokenService.getScopeConsentDetails(options);
690
+ WebAuth.prototype.loginPrecheck = function (options) {
691
+ return TokenService_1.TokenService.loginPrecheck(options);
734
692
  };
735
693
  ;
736
694
  /**
@@ -738,8 +696,8 @@ var WebAuth = /** @class */ (function () {
738
696
  * @param options
739
697
  * @returns
740
698
  */
741
- WebAuth.prototype.getScopeConsentVersionDetailsV2 = function (options) {
742
- return ConsentService_1.ConsentService.getScopeConsentVersionDetailsV2(options);
699
+ WebAuth.prototype.getConsentVersionDetails = function (options) {
700
+ return ConsentService_1.ConsentService.getConsentVersionDetails(options);
743
701
  };
744
702
  ;
745
703
  /**
@@ -751,14 +709,6 @@ var WebAuth = /** @class */ (function () {
751
709
  return ConsentService_1.ConsentService.acceptScopeConsent(options);
752
710
  };
753
711
  ;
754
- /**
755
- * scope consent continue login
756
- * @param options
757
- */
758
- WebAuth.prototype.scopeConsentContinue = function (options) {
759
- LoginService_1.LoginService.scopeConsentContinue(options);
760
- };
761
- ;
762
712
  /**
763
713
  * accept claim Consent
764
714
  * @param options
@@ -768,14 +718,6 @@ var WebAuth = /** @class */ (function () {
768
718
  return ConsentService_1.ConsentService.acceptClaimConsent(options);
769
719
  };
770
720
  ;
771
- /**
772
- * claim consent continue login
773
- * @param options
774
- */
775
- WebAuth.prototype.claimConsentContinue = function (options) {
776
- LoginService_1.LoginService.claimConsentContinue(options);
777
- };
778
- ;
779
721
  /**
780
722
  * revoke claim Consent
781
723
  * @param options
@@ -858,16 +800,29 @@ var WebAuth = /** @class */ (function () {
858
800
  };
859
801
  ;
860
802
  /**
861
- * get user activities
862
- * @param options
863
- * @param access_token
864
- * @returns
803
+ * To get user activities, call **getUserActivities()**.
804
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/346141453781e-get-user-activities for more details.
805
+ * @example
806
+ * ```js
807
+ * const options = {
808
+ * sub: 'your sub',
809
+ * dateFilter: {
810
+ * from_date: 'date in UTC format',
811
+ * to:date: 'date in UTC format'
812
+ * }
813
+ * };
814
+ * const accessToken = 'your access token';
815
+ * cidaas.getUserActivities(options, accessToken).then(function (resp) {
816
+ * // your success code
817
+ * }).catch(function(ex) {
818
+ * // your failure code
819
+ * });
820
+ * ```
865
821
  */
866
- WebAuth.prototype.getUserActivities = function (options, access_token) {
867
- var _serviceURL = window.webAuthSettings.authority + "/useractivity-srv/latestactivity";
868
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST", access_token);
822
+ WebAuth.prototype.getUserActivities = function (options, accessToken) {
823
+ var serviceURL = window.webAuthSettings.authority + '/activity-streams-srv/user-activities';
824
+ return Helper_1.Helper.createHttpPromise(options, serviceURL, false, 'POST', accessToken);
869
825
  };
870
- ;
871
826
  /**
872
827
  * @param access_token
873
828
  * @returns
@@ -917,24 +872,40 @@ var WebAuth = /** @class */ (function () {
917
872
  };
918
873
  ;
919
874
  /**
920
- * image upload
921
- * @param options
922
- * @param access_token
923
- * @returns
924
- */
875
+ * To change profile image, call **updateProfileImage()**.
876
+ * @example
877
+ * ```js
878
+ * const options = {
879
+ * image_key: 'id for your image e.g. user sub',
880
+ * photo: yourImageFile,
881
+ * filename: 'name of your image file'
882
+ * };
883
+ * const accessToken = 'your access token';
884
+ * cidaas.updateProfileImage(options, accessToken).then(function (resp) {
885
+ * // your success code
886
+ * }).catch(function(ex) {
887
+ * // your failure code
888
+ * });
889
+ * ```
890
+ */
925
891
  WebAuth.prototype.updateProfileImage = function (options, access_token) {
926
- var _serviceURL = window.webAuthSettings.authority + "/image-srv/profile/upload";
927
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST", access_token);
928
- };
929
- ;
930
- /**
931
- * updateSuggestMFA
932
- * @param track_id
933
- * @param options
934
- * @returns
935
- */
936
- WebAuth.prototype.updateSuggestMFA = function (track_id, options) {
937
- return TokenService_1.TokenService.updateSuggestMFA(track_id, options);
892
+ var serviceURL = window.webAuthSettings.authority + "/image-srv/profile/upload";
893
+ var form = document.createElement('form');
894
+ form.action = serviceURL;
895
+ form.method = 'POST';
896
+ var image_key = document.createElement('input');
897
+ image_key.setAttribute('type', 'hidden');
898
+ image_key.setAttribute('name', 'image_key');
899
+ form.appendChild(image_key);
900
+ var photo = document.createElement('input');
901
+ photo.setAttribute('type', 'file');
902
+ photo.setAttribute('hidden', 'true');
903
+ photo.setAttribute("name", "photo");
904
+ form.appendChild(photo);
905
+ var formdata = new FormData(form);
906
+ formdata.set('image_key', options.image_key);
907
+ formdata.set('photo', options.photo, options.filename);
908
+ return Helper_1.Helper.createHttpPromise(options, serviceURL, undefined, 'POST', access_token, null, formdata);
938
909
  };
939
910
  ;
940
911
  /**
@@ -942,17 +913,8 @@ var WebAuth = /** @class */ (function () {
942
913
  * @param options
943
914
  * @returns
944
915
  */
945
- WebAuth.prototype.enrollVerification = function (options) {
946
- return VerificationService_1.VerificationService.enrollVerification(options);
947
- };
948
- ;
949
- /**
950
- * @deprecated This function is no longer supported, instead use {this.updateStatus()}
951
- * @param status_id
952
- * @returns
953
- */
954
- WebAuth.prototype.updateSocket = function (status_id) {
955
- return VerificationService_1.VerificationService.updateStatus(status_id);
916
+ WebAuth.prototype.initiateEnrollment = function (options, accessToken) {
917
+ return VerificationService_1.VerificationService.initiateEnrollment(options, accessToken);
956
918
  };
957
919
  ;
958
920
  /**
@@ -960,17 +922,17 @@ var WebAuth = /** @class */ (function () {
960
922
  * @param status_id
961
923
  * @returns
962
924
  */
963
- WebAuth.prototype.updateStatus = function (status_id) {
964
- return VerificationService_1.VerificationService.updateStatus(status_id);
925
+ WebAuth.prototype.getEnrollmentStatus = function (status_id, accessToken) {
926
+ return VerificationService_1.VerificationService.getEnrollmentStatus(status_id, accessToken);
965
927
  };
966
928
  ;
967
929
  /**
968
- * setupFidoVerification
930
+ * enrollVerification
969
931
  * @param options
970
932
  * @returns
971
933
  */
972
- WebAuth.prototype.setupFidoVerification = function (options) {
973
- return VerificationService_1.VerificationService.setupFidoVerification(options);
934
+ WebAuth.prototype.enrollVerification = function (options) {
935
+ return VerificationService_1.VerificationService.enrollVerification(options);
974
936
  };
975
937
  ;
976
938
  /**
@@ -992,12 +954,12 @@ var WebAuth = /** @class */ (function () {
992
954
  };
993
955
  ;
994
956
  /**
995
- * getMissingFieldsLogin
957
+ * getMissingFields
996
958
  * @param trackId
997
959
  * @returns
998
960
  */
999
- WebAuth.prototype.getMissingFieldsLogin = function (trackId) {
1000
- return TokenService_1.TokenService.getMissingFieldsLogin(trackId);
961
+ WebAuth.prototype.getMissingFields = function (trackId) {
962
+ return TokenService_1.TokenService.getMissingFields(trackId);
1001
963
  };
1002
964
  ;
1003
965
  /**
@@ -1011,13 +973,11 @@ var WebAuth = /** @class */ (function () {
1011
973
  };
1012
974
  ;
1013
975
  /**
1014
- * loginAfterRegister
1015
- * @param options
976
+ * device code flow - initiate
1016
977
  */
1017
- WebAuth.prototype.loginAfterRegister = function (options) {
1018
- LoginService_1.LoginService.loginAfterRegister(options);
978
+ WebAuth.prototype.initiateDeviceCode = function (clientId) {
979
+ return TokenService_1.TokenService.initiateDeviceCode(clientId);
1019
980
  };
1020
- ;
1021
981
  /**
1022
982
  * device code flow - verify
1023
983
  * @param code
@@ -1042,526 +1002,32 @@ var WebAuth = /** @class */ (function () {
1042
1002
  window.localeSettings = acceptLanguage;
1043
1003
  };
1044
1004
  /**
1045
- * initiate mfa v2
1005
+ * initiate mfa
1046
1006
  * @param options
1047
1007
  * @returns
1048
1008
  */
1049
- WebAuth.prototype.initiateMFAV2 = function (options) {
1050
- return VerificationService_1.VerificationService.initiateMFAV2(options);
1051
- };
1052
- ;
1053
- /**
1054
- * initiateVerification
1055
- * @param options
1056
- */
1057
- WebAuth.prototype.initiateVerification = function (options) {
1058
- options.type = options.verification_type;
1059
- this.initiateMFAV2(options);
1060
- };
1061
- ;
1062
- /**
1063
- * initiate email v2
1064
- * @param options
1065
- */
1066
- WebAuth.prototype.initiateEmailV2 = function (options) {
1067
- options.type = "email";
1068
- this.initiateMFAV2(options);
1069
- };
1070
- ;
1071
- /**
1072
- * initiate sms v2
1073
- * @param options
1074
- */
1075
- WebAuth.prototype.initiateSMSV2 = function (options) {
1076
- options.type = "sms";
1077
- this.initiateMFAV2(options);
1078
- };
1079
- ;
1080
- /**
1081
- * initiate ivr v2
1082
- * @param options
1083
- */
1084
- WebAuth.prototype.initiateIVRV2 = function (options) {
1085
- options.type = "ivr";
1086
- this.initiateMFAV2(options);
1087
- };
1088
- ;
1089
- /**
1090
- * initiate backupcode v2
1091
- * @param options
1092
- */
1093
- WebAuth.prototype.initiateBackupcodeV2 = function (options) {
1094
- options.type = "backupcode";
1095
- this.initiateMFAV2(options);
1096
- };
1097
- ;
1098
- /**
1099
- * initiate totp v2
1100
- * @param options
1101
- */
1102
- WebAuth.prototype.initiateTOTPV2 = function (options) {
1103
- options.type = "totp";
1104
- this.initiateMFAV2(options);
1105
- };
1106
- ;
1107
- /**
1108
- * initiate pattern v2
1109
- * @param options
1110
- */
1111
- WebAuth.prototype.initiatePatternV2 = function (options) {
1112
- options.type = "pattern";
1113
- this.initiateMFAV2(options);
1114
- };
1115
- ;
1116
- /**
1117
- * initiate touchid v2
1118
- * @param options
1119
- */
1120
- WebAuth.prototype.initiateTouchIdV2 = function (options) {
1121
- options.type = "touchid";
1122
- this.initiateMFAV2(options);
1123
- };
1124
- ;
1125
- /**
1126
- * initiate smart push v2
1127
- * @param options
1128
- */
1129
- WebAuth.prototype.initiateSmartPushV2 = function (options) {
1130
- options.type = "push";
1131
- this.initiateMFAV2(options);
1132
- };
1133
- ;
1134
- /**
1135
- * initiate face v2
1136
- * @param options
1137
- */
1138
- WebAuth.prototype.initiateFaceV2 = function (options) {
1139
- options.type = "face";
1140
- this.initiateMFAV2(options);
1141
- };
1142
- ;
1143
- /**
1144
- * initiate voice v2
1145
- * @param options
1146
- */
1147
- WebAuth.prototype.initiateVoiceV2 = function (options) {
1148
- options.type = "voice";
1149
- this.initiateMFAV2(options);
1150
- };
1151
- ;
1152
- /**
1153
- * @deprecated
1154
- * @param options
1155
- * @param verificationType
1156
- * @returns
1157
- */
1158
- WebAuth.prototype.initiateMfaV1 = function (options, verificationType) {
1159
- return VerificationService_1.VerificationService.initiateMfaV1(options, verificationType);
1160
- };
1161
- /**
1162
- * @deprecated
1163
- * initiate email - v1
1164
- * @param options
1165
- */
1166
- WebAuth.prototype.initiateEmail = function (options) {
1167
- var verificationType = "EMAIL";
1168
- this.initiateMfaV1(options, verificationType);
1169
- };
1170
- ;
1171
- /**
1172
- * @deprecated
1173
- * initiate SMS - v1
1174
- * @param options
1175
- */
1176
- WebAuth.prototype.initiateSMS = function (options) {
1177
- var verificationType = "SMS";
1178
- this.initiateMfaV1(options, verificationType);
1179
- };
1180
- ;
1181
- /**
1182
- * @deprecated
1183
- * initiate IVR - v1
1184
- * @param options
1185
- */
1186
- WebAuth.prototype.initiateIVR = function (options) {
1187
- var verificationType = "IVR";
1188
- this.initiateMfaV1(options, verificationType);
1189
- };
1190
- ;
1191
- /**
1192
- * @deprecated
1193
- * initiate backup code - v1
1194
- * @param options
1195
- */
1196
- WebAuth.prototype.initiateBackupcode = function (options) {
1197
- var verificationType = "BACKUPCODE";
1198
- this.initiateMfaV1(options, verificationType);
1199
- };
1200
- ;
1201
- /**
1202
- * @deprecated
1203
- * initiate TOTP - v1
1204
- * @param options
1205
- */
1206
- WebAuth.prototype.initiateTOTP = function (options) {
1207
- var verificationType = "TOTP";
1208
- this.initiateMfaV1(options, verificationType);
1209
- };
1210
- ;
1211
- /**
1212
- * @deprecated
1213
- * initiate pattern - v1
1214
- * @param options
1215
- */
1216
- WebAuth.prototype.initiatePattern = function (options) {
1217
- var verificationType = "PATTERN";
1218
- this.initiateMfaV1(options, verificationType);
1219
- };
1220
- ;
1221
- /**
1222
- * @deprecated
1223
- * initiate touchid - v1
1224
- * @param options
1225
- */
1226
- WebAuth.prototype.initiateTouchId = function (options) {
1227
- var verificationType = "TOUCHID";
1228
- this.initiateMfaV1(options, verificationType);
1229
- };
1230
- ;
1231
- /**
1232
- * @deprecated
1233
- * initiate push - v1
1234
- * @param options
1235
- */ WebAuth.prototype.initiateSmartPush = function (options) {
1236
- var verificationType = "PUSH";
1237
- this.initiateMfaV1(options, verificationType);
1238
- };
1239
- ;
1240
- /**
1241
- * @deprecated
1242
- * initiate face - v1
1243
- * @param options
1244
- */
1245
- WebAuth.prototype.initiateFace = function (options) {
1246
- var verificationType = "FACE";
1247
- this.initiateMfaV1(options, verificationType);
1248
- };
1249
- ;
1250
- /**
1251
- * @deprecated
1252
- * initiate Voice - v1
1253
- * @param options
1254
- */
1255
- WebAuth.prototype.initiateVoice = function (options) {
1256
- var verificationType = "VOICE";
1257
- this.initiateMfaV1(options, verificationType);
1258
- };
1259
- ;
1260
- /**
1261
- * authenticate mfa v2
1262
- * @param options
1263
- * @returns
1264
- */
1265
- WebAuth.prototype.authenticateMFAV2 = function (options) {
1266
- return VerificationService_1.VerificationService.authenticateMFAV2(options);
1267
- };
1268
- ;
1269
- /**
1270
- * authenticateVerification
1271
- * @param options
1272
- */
1273
- WebAuth.prototype.authenticateVerification = function (options) {
1274
- options.type = options.verification_type;
1275
- this.authenticateMFAV2(options);
1276
- };
1277
- ;
1278
- /**
1279
- * authenticate email v2
1280
- * @param options
1281
- */
1282
- WebAuth.prototype.authenticateEmailV2 = function (options) {
1283
- options.type = "email";
1284
- this.authenticateMFAV2(options);
1285
- };
1286
- ;
1287
- /**
1288
- * authenticate sms v2
1289
- * @param options
1290
- */
1291
- WebAuth.prototype.authenticateSMSV2 = function (options) {
1292
- options.type = "sms";
1293
- this.authenticateMFAV2(options);
1294
- };
1295
- ;
1296
- /**
1297
- * authenticate ivr v2
1298
- * @param options
1299
- */
1300
- WebAuth.prototype.authenticateIVRV2 = function (options) {
1301
- options.type = "ivr";
1302
- this.authenticateMFAV2(options);
1303
- };
1304
- ;
1305
- /**
1306
- * authenticate backupcode v2
1307
- * @param options
1308
- */
1309
- WebAuth.prototype.authenticateBackupcodeV2 = function (options) {
1310
- options.type = "backupcode";
1311
- this.authenticateMFAV2(options);
1312
- };
1313
- ;
1314
- /**
1315
- * authenticate totp v2
1316
- * @param options
1317
- */
1318
- WebAuth.prototype.authenticateTOTPV2 = function (options) {
1319
- options.type = "totp";
1320
- this.authenticateMFAV2(options);
1321
- };
1322
- ;
1323
- /**
1324
- * authenticateVerification form type (for face)
1325
- * @param options
1326
- * @returns
1327
- */
1328
- WebAuth.prototype.authenticateFaceVerification = function (options) {
1329
- return VerificationService_1.VerificationService.authenticateFaceVerification(options);
1330
- };
1331
- ;
1332
- /**
1333
- * @deprecated
1334
- * setup verification - v1
1335
- * @param options
1336
- * @param access_token
1337
- * @param verificationType
1338
- * @returns
1339
- */
1340
- WebAuth.prototype.setupVerificationV1 = function (options, access_token, verificationType) {
1341
- return VerificationService_1.VerificationService.setupVerificationV1(options, access_token, verificationType);
1342
- };
1343
- /**
1344
- * @deprecated
1345
- * setup email - v1
1346
- * @param options
1347
- * @param access_token
1348
- */
1349
- WebAuth.prototype.setupEmail = function (options, access_token) {
1350
- var verificationType = "EMAIL";
1351
- this.setupVerificationV1(options, access_token, verificationType);
1352
- };
1353
- ;
1354
- /**
1355
- * @deprecated
1356
- * setup sms - v1
1357
- * @param options
1358
- * @param access_token
1359
- */
1360
- WebAuth.prototype.setupSMS = function (options, access_token) {
1361
- var verificationType = "SMS";
1362
- this.setupVerificationV1(options, access_token, verificationType);
1363
- };
1364
- ;
1365
- /**
1366
- * @deprecated
1367
- * setup ivr - v1
1368
- * @param options
1369
- * @param access_token
1370
- */
1371
- WebAuth.prototype.setupIVR = function (options, access_token) {
1372
- var verificationType = "IVR";
1373
- this.setupVerificationV1(options, access_token, verificationType);
1374
- };
1375
- ;
1376
- /**
1377
- * @deprecated
1378
- * setup backupcode - v1
1379
- * @param options
1380
- * @param access_token
1381
- */
1382
- WebAuth.prototype.setupBackupcode = function (options, access_token) {
1383
- var verificationType = "BACKUPCODE";
1384
- this.setupVerificationV1(options, access_token, verificationType);
1385
- };
1386
- ;
1387
- /**
1388
- * @deprecated
1389
- * setup totp - v1
1390
- * @param options
1391
- * @param access_token
1392
- */
1393
- WebAuth.prototype.setupTOTP = function (options, access_token) {
1394
- var verificationType = "TOTP";
1395
- this.setupVerificationV1(options, access_token, verificationType);
1396
- };
1397
- ;
1398
- /**
1399
- * @deprecated
1400
- * setup pattern - v1
1401
- * @param options
1402
- * @param access_token
1403
- */
1404
- WebAuth.prototype.setupPattern = function (options, access_token) {
1405
- var verificationType = "PATTERN";
1406
- this.setupVerificationV1(options, access_token, verificationType);
1407
- };
1408
- ;
1409
- /**
1410
- * @deprecated
1411
- * setup touch - v1
1412
- * @param options
1413
- * @param access_token
1414
- */
1415
- WebAuth.prototype.setupTouchId = function (options, access_token) {
1416
- var verificationType = "TOUCHID";
1417
- this.setupVerificationV1(options, access_token, verificationType);
1418
- };
1419
- ;
1420
- /**
1421
- * @deprecated
1422
- * setup smart push - v1
1423
- * @param options
1424
- * @param access_token
1425
- */
1426
- WebAuth.prototype.setupSmartPush = function (options, access_token) {
1427
- var verificationType = "PUSH";
1428
- this.setupVerificationV1(options, access_token, verificationType);
1429
- };
1430
- ;
1431
- /**
1432
- * @deprecated
1433
- * setup face - v1
1434
- * @param options
1435
- * @param access_token
1436
- */
1437
- WebAuth.prototype.setupFace = function (options, access_token) {
1438
- var verificationType = "FACE";
1439
- this.setupVerificationV1(options, access_token, verificationType);
1440
- };
1441
- ;
1442
- /**
1443
- * @deprecated
1444
- * setup voice - v1
1445
- * @param options
1446
- * @param access_token
1447
- */
1448
- WebAuth.prototype.setupVoice = function (options, access_token) {
1449
- var verificationType = "VOICE";
1450
- this.setupVerificationV1(options, access_token, verificationType);
1451
- };
1452
- ;
1453
- /**
1454
- * @deprecated
1455
- * enroll verification - v1
1456
- * @param options
1457
- * @param access_token
1458
- * @param verificationType
1459
- * @returns
1460
- */
1461
- WebAuth.prototype.enrollVerificationV1 = function (options, access_token, verificationType) {
1462
- return VerificationService_1.VerificationService.enrollVerificationV1(options, access_token, verificationType);
1463
- };
1464
- /**
1465
- * @deprecated
1466
- * enroll email - v1
1467
- * @param options
1468
- * @param access_token
1469
- */
1470
- WebAuth.prototype.enrollEmail = function (options, access_token) {
1471
- var verificationType = "EMAIL";
1472
- this.enrollVerificationV1(options, access_token, verificationType);
1473
- };
1474
- ;
1475
- /**
1476
- * @deprecated
1477
- * enroll SMS - v1
1478
- * @param options
1479
- * @param access_token
1480
- */
1481
- WebAuth.prototype.enrollSMS = function (options, access_token) {
1482
- var verificationType = "SMS";
1483
- this.enrollVerificationV1(options, access_token, verificationType);
1484
- };
1485
- ;
1486
- /**
1487
- * @deprecated
1488
- * enroll IVR - v1
1489
- * @param options
1490
- * @param access_token
1491
- */
1492
- WebAuth.prototype.enrollIVR = function (options, access_token) {
1493
- var verificationType = "IVR";
1494
- this.enrollVerificationV1(options, access_token, verificationType);
1009
+ WebAuth.prototype.initiateMFA = function (options, accessToken) {
1010
+ // TODO: remove accessToken parameter in the next major release
1011
+ if (accessToken) {
1012
+ return VerificationService_1.VerificationService.initiateMFA(options, accessToken);
1013
+ }
1014
+ return VerificationService_1.VerificationService.initiateMFA(options);
1495
1015
  };
1496
1016
  ;
1497
1017
  /**
1498
- * @deprecated
1499
- * enroll TOTP - v1
1018
+ * authenticate mfa
1500
1019
  * @param options
1501
- * @param access_token
1502
- */
1503
- WebAuth.prototype.enrollTOTP = function (options, access_token) {
1504
- var verificationType = "TOTP";
1505
- this.enrollVerificationV1(options, access_token, verificationType);
1506
- };
1507
- ;
1508
- /**
1509
- * @deprecated
1510
- * authenticate mfa - v1
1511
- * @param verificationType
1512
1020
  * @returns
1513
1021
  */
1514
- WebAuth.prototype.authenticateMfaV1 = function (options, verificationType) {
1515
- return VerificationService_1.VerificationService.authenticateMfaV1(options, verificationType);
1516
- };
1517
- /**
1518
- * @deprecated
1519
- * authenticate email - v1
1520
- * @param options
1521
- */
1522
- WebAuth.prototype.authenticateEmail = function (options) {
1523
- var verificationType = "EMAIL";
1524
- this.authenticateMfaV1(options, verificationType);
1525
- };
1526
- ;
1527
- /**
1528
- * @deprecated
1529
- * authenticate sms - v1
1530
- * @param options
1531
- */
1532
- WebAuth.prototype.authenticateSMS = function (options) {
1533
- var verificationType = "SMS";
1534
- this.authenticateMfaV1(options, verificationType);
1022
+ WebAuth.prototype.authenticateMFA = function (options) {
1023
+ return VerificationService_1.VerificationService.authenticateMFA(options);
1535
1024
  };
1536
1025
  ;
1537
1026
  /**
1538
- * @deprecated
1539
- * authenticate ivr - v1
1540
- * @param options
1541
- */
1542
- WebAuth.prototype.authenticateIVR = function (options) {
1543
- var verificationType = "IVR";
1544
- this.authenticateMfaV1(options, verificationType);
1545
- };
1546
- ;
1547
- /**
1548
- * @deprecated
1549
- * authenticate totp - v1
1550
- * @param options
1551
- */
1552
- WebAuth.prototype.authenticateTOTP = function (options) {
1553
- var verificationType = "TOTP";
1554
- this.authenticateMfaV1(options, verificationType);
1555
- };
1556
- ;
1557
- /**
1558
- * @deprecated
1559
- * authenticate backupcode - v1
1560
- * @param options
1027
+ * offline token check
1561
1028
  */
1562
- WebAuth.prototype.authenticateBackupcode = function (options) {
1563
- var verificationType = "BACKUPCODE";
1564
- this.authenticateMfaV1(options, verificationType);
1029
+ WebAuth.prototype.offlineTokenCheck = function (accessToken) {
1030
+ return TokenService_1.TokenService.offlineTokenCheck(accessToken);
1565
1031
  };
1566
1032
  ;
1567
1033
  return WebAuth;