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.
@@ -5,9 +5,21 @@ var Helper_1 = require("./Helper");
5
5
  var VerificationService;
6
6
  (function (VerificationService) {
7
7
  /**
8
- * initiate verification
9
- * @param options
10
- * @returns
8
+ * To initiate the account verification, call **initiateAccountVerification()**. This will send verification code email or sms or ivr based on the verificationMedium you mentioned.
9
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/cgans5erj5alg-init-account-verification for more details.
10
+ * @example
11
+ * ```js
12
+ * cidaas.initiateAccountVerification({
13
+ * verificationMedium: 'email',
14
+ * requestId: 'your requestId',
15
+ * processingType: 'CODE',
16
+ * email: 'your email'
17
+ * }).then(function (response) {
18
+ * // the response will give you account verification details.
19
+ * }).catch(function(ex) {
20
+ * // your failure code here
21
+ * });
22
+ * ```
11
23
  */
12
24
  function initiateAccountVerification(options) {
13
25
  try {
@@ -23,229 +35,244 @@ var VerificationService;
23
35
  VerificationService.initiateAccountVerification = initiateAccountVerification;
24
36
  ;
25
37
  /**
26
- * initiate verification and return response
27
- * @param options
28
- * @returns
29
- */
30
- function initiateAccountVerificationAsynFn(options) {
31
- try {
32
- var searchParams = new URLSearchParams(options);
33
- var response = fetch(window.webAuthSettings.authority + "/verification-srv/account/initiate", {
34
- method: "POST",
35
- redirect: "follow",
36
- body: searchParams.toString(),
37
- headers: {
38
- "Content-Type": "application/x-www-form-urlencoded"
39
- }
40
- });
41
- return response;
42
- }
43
- catch (ex) {
44
- throw new Helper_1.CustomException(ex, 417);
45
- }
46
- }
47
- VerificationService.initiateAccountVerificationAsynFn = initiateAccountVerificationAsynFn;
48
- ;
49
- /**
50
- * verify account
51
- * @param options
52
- * @returns
38
+ * To complete the verification, call **verifyAccount()**.
39
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/r8h9mvavvw2e6-verify-account for more details.
40
+ * @example
41
+ * ```js
42
+ * cidaas.verifyAccount({
43
+ * accvid: 'your accvid', // which you will get on initiate account verification response
44
+ * code: 'your code in email or sms or ivr'
45
+ * }).then(function (response) {
46
+ * // the response will give you account verification ID and unique code.
47
+ * }).catch(function(ex) {
48
+ * // your failure code here
49
+ * });
50
+ * ```
53
51
  */
54
52
  function verifyAccount(options) {
55
53
  var _serviceURL = window.webAuthSettings.authority + "/verification-srv/account/verify";
56
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST");
54
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
57
55
  }
58
56
  VerificationService.verifyAccount = verifyAccount;
59
57
  ;
60
58
  /**
61
- * get mfa list v2
62
- * @param options
63
- * @returns
59
+ * To get all configured multi factor authentication, call **getMFAList()**.
60
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/ee688a9c52b63-list-of-configured-verification-methods for more details.
61
+ * @example
62
+ * ```js
63
+ * cidaas.getMFAList({
64
+ * request_id: 'your request id',
65
+ * email: 'your email'
66
+ * }).then(function (response) {
67
+ * // the response will give you list of configured multi factor authentication
68
+ * }).catch(function(ex) {
69
+ * // your failure code here
70
+ * });
71
+ * ```
64
72
  */
65
- function getMFAListV2(options) {
73
+ function getMFAList(options) {
66
74
  var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/public/configured/list";
67
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST");
75
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
68
76
  }
69
- VerificationService.getMFAListV2 = getMFAListV2;
77
+ VerificationService.getMFAList = getMFAList;
70
78
  ;
71
79
  /**
72
- * cancel mfa v2
73
- * @param options
74
- * @returns
80
+ * to cancel mfa process, call **cancelMFA()**.
81
+ * @example
82
+ * ```js
83
+ * cidaas.cancelMFA({
84
+ * exchange_id: 'exchange id from initiateMFA() response',
85
+ * reason: 'reason of mfa cancelation',
86
+ * type: 'authentication type e.g. email'
87
+ * }).then(function (response) {
88
+ * // your success code here
89
+ * }).catch(function(ex) {
90
+ * // your failure code here
91
+ * });
92
+ * ```
75
93
  */
76
- function cancelMFAV2(options) {
77
- var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/cancel/" + options.type;
78
- return Helper_1.Helper.createPostPromise(options, _serviceURL, undefined, "POST");
94
+ function cancelMFA(options) {
95
+ var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/cancel/" + options.type;
96
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST");
79
97
  }
80
- VerificationService.cancelMFAV2 = cancelMFAV2;
98
+ VerificationService.cancelMFA = cancelMFA;
81
99
  ;
82
100
  /**
83
- * @param access_token
84
- * @returns
101
+ * To get list of all verification type configured, call **getAllVerificationList()**. access_token must be passed as function parameter.
102
+ * @example
103
+ * ```js
104
+ * const access_token = "your access token";
105
+ *
106
+ * cidaas.getAllVerificationList(access_token)
107
+ * .then(function (response) {
108
+ * // type your code here
109
+ * })
110
+ * .catch(function (ex) {
111
+ * // your failure code here
112
+ * });
113
+ * ```
85
114
  */
86
115
  function getAllVerificationList(access_token) {
87
116
  var _serviceURL = "".concat(window.webAuthSettings.authority, "/verification-srv/config/list");
88
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, undefined, "GET", access_token);
117
+ return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, undefined, "GET", access_token);
89
118
  }
90
119
  VerificationService.getAllVerificationList = getAllVerificationList;
91
120
  ;
92
121
  /**
93
- * enrollVerification
94
- * @param options
95
- * @returns
122
+ * To initiate enrollment of new multi factor authentication, call **initiateEnrollment()**.
123
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/branches/master/f85aef6754714-initiate-physical-verification-setup for more details.
124
+ * @example
125
+ * ```js
126
+ * const access_token = "your access token";
127
+ * const options = {
128
+ * verification_type: 'one of verification_type such as fido2, face, ivr',
129
+ * deviceInfo: {
130
+ * deviceId: '',
131
+ * location: {lat: '', lon: ''}
132
+ * }
133
+ * }
134
+ *
135
+ * cidaas.initiateEnrollment(options, access_token)
136
+ * .then(function (response) {
137
+ * // type your code here
138
+ * })
139
+ * .catch(function (ex) {
140
+ * // your failure code here
141
+ * });
142
+ * ```
96
143
  */
97
- function enrollVerification(options) {
98
- var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/enroll/" + options.verification_type;
99
- return Helper_1.Helper.createPostPromise(options, _serviceURL, undefined, "POST");
144
+ function initiateEnrollment(options, accessToken) {
145
+ var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/initiate/" + options.verification_type;
146
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST", accessToken);
100
147
  }
101
- VerificationService.enrollVerification = enrollVerification;
148
+ VerificationService.initiateEnrollment = initiateEnrollment;
102
149
  ;
103
150
  /**
104
- * @deprecated This function is no longer supported, instead use {this.updateStatus()}
105
- * @param status_id
106
- * @returns
107
- */
108
- function updateSocket(status_id) {
151
+ * to get the status of MFA enrollment, call **getEnrollmentStatus()**.
152
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/branches/master/b06447d02d8e0-get-status-of-physical-verification-setup-configuration for more details.
153
+ * @example
154
+ * ```js
155
+ * cidaas.getEnrollmentStatus('statusId from initiateEnrollment()', 'your access token')
156
+ * .then(function (response) {
157
+ * // type your code here
158
+ * })
159
+ * .catch(function (ex) {
160
+ * // your failure code here
161
+ * });
162
+ * ```
163
+ */
164
+ function getEnrollmentStatus(status_id, accessToken) {
109
165
  var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/notification/status/" + status_id;
110
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, undefined, "POST");
166
+ return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, undefined, "POST", accessToken);
111
167
  }
112
- VerificationService.updateSocket = updateSocket;
168
+ VerificationService.getEnrollmentStatus = getEnrollmentStatus;
113
169
  ;
114
170
  /**
115
- * update the status of notification
116
- * @param status_id
117
- * @returns
171
+ * to finish enrollment process of new multi factor authentication, call **enrollVerification()**.
172
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/branches/master/20ec76e937b27-enroll-physical-verification-setup for more details.
173
+ * @example
174
+ * ```js
175
+ * const fidoPayload = {
176
+ * sub: 'your sub',
177
+ * exchange_id: 'exchange_id from initiateEnrollment()',
178
+ * verification_type: 'fido2',
179
+ * fido2_client_response: {
180
+ * client_response: 'client_response from doing fido process',
181
+ * fidoRequestId: 'fidoRequestId from initiateEnrollment',
182
+ * }
183
+ * }
184
+ * cidaas.enrollVerification(fidoPayload)
185
+ * .then(function (response) {
186
+ * // type your code here
187
+ * })
188
+ * .catch(function (ex) {
189
+ * // your failure code here
190
+ * });
191
+ * ```
118
192
  */
119
- function updateStatus(status_id) {
120
- var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/notification/status/" + status_id;
121
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, undefined, "POST");
122
- }
123
- VerificationService.updateStatus = updateStatus;
124
- ;
125
- /**
126
- * setupFidoVerification
127
- * @param options
128
- * @returns
129
- */
130
- function setupFidoVerification(options) {
131
- var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/initiate/suggestmfa/" + options.verification_type;
132
- return Helper_1.Helper.createPostPromise(options, _serviceURL, undefined, "POST");
193
+ function enrollVerification(options) {
194
+ var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/enroll/" + options.verification_type;
195
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST");
133
196
  }
134
- VerificationService.setupFidoVerification = setupFidoVerification;
197
+ VerificationService.enrollVerification = enrollVerification;
135
198
  ;
136
199
  /**
137
- * checkVerificationTypeConfigured
138
- * @param options
139
- * @returns
200
+ * to see details of configured verification type, call **checkVerificationTypeConfigured()**.
201
+ * @example
202
+ * ```js
203
+ * cidaas.checkVerificationTypeConfigured({
204
+ * request_id: 'your request id',
205
+ * email: 'your email',
206
+ * verification_type: 'email'
207
+ * }).then(function (response) {
208
+ * // type your code here
209
+ * })
210
+ * .catch(function (ex) {
211
+ * // your failure code here
212
+ * });
213
+ * ```
140
214
  */
141
215
  function checkVerificationTypeConfigured(options) {
142
216
  var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/setup/public/configured/check/" + options.verification_type;
143
- return Helper_1.Helper.createPostPromise(options, _serviceURL, undefined, "POST");
217
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST");
144
218
  }
145
219
  VerificationService.checkVerificationTypeConfigured = checkVerificationTypeConfigured;
146
220
  ;
147
221
  /**
148
- * initiate mfa v2
149
- * @param options
150
- * @returns
222
+ * to initiate multi factor auhentication, call **initiateMFA()**.
223
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/2a3ea581bb249-initiate-verification for more details.
224
+ * @example
225
+ * ```js
226
+ * const access_token = "your access token";
227
+ * const options = {
228
+ * request_id: 'your request id',
229
+ * usage_type: 'PASSWORDLESS_AUTHENTICATION',
230
+ * type: 'email'
231
+ * email: 'your email'
232
+ * }
233
+ * }
234
+ *
235
+ * cidaas.initiateMFA(options, access_token)
236
+ * .then(function (response) {
237
+ * // type your code here
238
+ * })
239
+ * .catch(function (ex) {
240
+ * // your failure code here
241
+ * });
242
+ * ```
151
243
  */
152
- function initiateMFAV2(options) {
244
+ function initiateMFA(options, accessToken) {
153
245
  var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/initiate/" + options.type;
154
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST");
246
+ // TODO: remove accessToken parameter in the next major release
247
+ if (accessToken) {
248
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", accessToken);
249
+ }
250
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
155
251
  }
156
- VerificationService.initiateMFAV2 = initiateMFAV2;
252
+ VerificationService.initiateMFA = initiateMFA;
157
253
  ;
158
254
  /**
159
- * @deprecated
160
- * @param options
161
- * @param verificationType
162
- * @returns
163
- */
164
- function initiateMfaV1(options, verificationType) {
165
- var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + verificationType.toLowerCase() + "/initiate";
166
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST");
167
- }
168
- VerificationService.initiateMfaV1 = initiateMfaV1;
169
- /**
170
- * authenticate mfa v2
171
- * @param options
172
- * @returns
255
+ * to authenticate with multi factor auhentication, call **authenticateMFA()**.
256
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/1aa38936252d6-perform-the-authentication-method for more details.
257
+ * @example
258
+ * ```js
259
+ * cidaas.authenticateMFA({
260
+ * type: 'email',
261
+ * client_id: 'your client id',
262
+ * exchange_id: exchange id from initiateMFA(),
263
+ * pass_code: 'code to authenticate'
264
+ * }).then(function (response) {
265
+ * // type your code here
266
+ * })
267
+ * .catch(function (ex) {
268
+ * // your failure code here
269
+ * });
270
+ * ```
173
271
  */
174
- function authenticateMFAV2(options) {
272
+ function authenticateMFA(options) {
175
273
  var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/" + options.type;
176
- return Helper_1.Helper.createPostPromise(options, _serviceURL, undefined, "POST");
177
- }
178
- VerificationService.authenticateMFAV2 = authenticateMFAV2;
179
- ;
180
- /**
181
- * authenticateVerification form type (for face)
182
- * @param options
183
- * @returns
184
- */
185
- function authenticateFaceVerification(options) {
186
- return new Promise(function (resolve, reject) {
187
- try {
188
- var http = new XMLHttpRequest();
189
- var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/authenticate/authenticate/face";
190
- http.onreadystatechange = function () {
191
- if (http.readyState == 4) {
192
- if (http.responseText) {
193
- resolve(JSON.parse(http.responseText));
194
- }
195
- else {
196
- resolve(undefined);
197
- }
198
- }
199
- };
200
- http.open("POST", _serviceURL, true);
201
- http.setRequestHeader("Content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
202
- if (window.localeSettings) {
203
- http.setRequestHeader("accept-language", window.localeSettings);
204
- }
205
- http.send(JSON.stringify(options));
206
- }
207
- catch (ex) {
208
- reject(ex);
209
- }
210
- });
274
+ return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST");
211
275
  }
212
- VerificationService.authenticateFaceVerification = authenticateFaceVerification;
276
+ VerificationService.authenticateMFA = authenticateMFA;
213
277
  ;
214
- /**
215
- * @deprecated
216
- * setup verification - v1
217
- * @param options
218
- * @param access_token
219
- * @param verificationType
220
- * @returns
221
- */
222
- function setupVerificationV1(options, access_token, verificationType) {
223
- var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + verificationType.toLowerCase() + "/setup";
224
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST", access_token);
225
- }
226
- VerificationService.setupVerificationV1 = setupVerificationV1;
227
- /**
228
- * @deprecated
229
- * enroll verification - v1
230
- * @param options
231
- * @param access_token
232
- * @param verificationType
233
- * @returns
234
- */
235
- function enrollVerificationV1(options, access_token, verificationType) {
236
- var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + verificationType.toLowerCase() + "/enroll";
237
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST", access_token);
238
- }
239
- VerificationService.enrollVerificationV1 = enrollVerificationV1;
240
- /**
241
- * @deprecated
242
- * authenticate mfa - v1
243
- * @param verificationType
244
- * @returns
245
- */
246
- function authenticateMfaV1(options, verificationType) {
247
- var _serviceURL = window.webAuthSettings.authority + "/verification-srv/" + verificationType.toLowerCase() + "/authenticate";
248
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, "POST");
249
- }
250
- VerificationService.authenticateMfaV1 = authenticateMfaV1;
251
278
  })(VerificationService = exports.VerificationService || (exports.VerificationService = {}));