cidaas-javascript-sdk 3.0.5 → 3.1.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,143 +0,0 @@
1
- import { UserEntity, ResetPasswordEntity, FindUserEntity, IUserLinkEntity, ChangePasswordEntity, ValidateResetPasswordEntity, AcceptResetPasswordEntity } from "./Entities";
2
- export declare namespace UserService {
3
- /**
4
- * get user info
5
- * @param options
6
- * @returns
7
- */
8
- function getUserProfile(options: {
9
- access_token: string;
10
- }): Promise<unknown>;
11
- /**
12
- * register user
13
- * @param options
14
- * @param headers
15
- * @returns
16
- */
17
- function register(options: UserEntity, headers: {
18
- requestId: string;
19
- captcha?: string;
20
- acceptlanguage?: string;
21
- bot_captcha_response?: string;
22
- trackId?: string;
23
- }): Promise<unknown>;
24
- /**
25
- * get invite info
26
- * @param options
27
- * @returns
28
- */
29
- function getInviteUserDetails(options: {
30
- invite_id: string;
31
- }): Promise<unknown>;
32
- /**
33
- * get Communication status
34
- * @param options
35
- * @returns
36
- */
37
- function getCommunicationStatus(options: {
38
- sub: string;
39
- requestId: string;
40
- }): Promise<unknown>;
41
- /**
42
- * initiate reset password
43
- * @param options
44
- * @returns
45
- */
46
- function initiateResetPassword(options: ResetPasswordEntity): Promise<unknown>;
47
- /**
48
- * handle reset password
49
- * @param options
50
- */
51
- function handleResetPassword(options: ValidateResetPasswordEntity): Promise<unknown>;
52
- /**
53
- * reset password
54
- * @param options
55
- */
56
- function resetPassword(options: AcceptResetPasswordEntity): Promise<unknown>;
57
- /**
58
- * get Deduplication details
59
- * @param options
60
- * @returns
61
- */
62
- function getDeduplicationDetails(options: {
63
- trackId: string;
64
- }): Promise<unknown>;
65
- /**
66
- * deduplication login
67
- * @param options
68
- */
69
- function deduplicationLogin(options: {
70
- trackId: string;
71
- requestId: string;
72
- sub: string;
73
- }): void;
74
- /**
75
- * register Deduplication
76
- * @param options
77
- * @returns
78
- */
79
- function registerDeduplication(options: {
80
- trackId: string;
81
- }): Promise<unknown>;
82
- /**
83
- * change password
84
- * @param options
85
- * @param access_token
86
- * @returns
87
- */
88
- function changePassword(options: ChangePasswordEntity, access_token: string): Promise<unknown>;
89
- /**
90
- * update profile
91
- * @param options
92
- * @param access_token
93
- * @param sub
94
- * @returns
95
- */
96
- function updateProfile(options: UserEntity, access_token: string, sub: string): Promise<unknown>;
97
- /**
98
- * initiate link accoount
99
- * @param options
100
- * @param access_token
101
- * @returns
102
- */
103
- function initiateLinkAccount(options: IUserLinkEntity, access_token: string): Promise<unknown>;
104
- /**
105
- * complete link accoount
106
- * @param options
107
- * @param access_token
108
- * @returns
109
- */
110
- function completeLinkAccount(options: {
111
- code?: string;
112
- link_request_id?: string;
113
- }, access_token: string): Promise<unknown>;
114
- /**
115
- * get linked users
116
- * @param access_token
117
- * @param sub
118
- * @returns
119
- */
120
- function getLinkedUsers(access_token: string, sub: string): Promise<unknown>;
121
- /**
122
- * unlink accoount
123
- * @param access_token
124
- * @param identityId
125
- * @returns
126
- */
127
- function unlinkAccount(access_token: string, identityId: string): Promise<unknown>;
128
- /**
129
- * deleteUserAccount
130
- * @param options
131
- * @returns
132
- */
133
- function deleteUserAccount(options: {
134
- access_token: string;
135
- sub: string;
136
- }): Promise<unknown>;
137
- /**
138
- * check if an user exists
139
- * @param options
140
- * @returns
141
- */
142
- function userCheckExists(options: FindUserEntity): Promise<unknown>;
143
- }
@@ -1,458 +0,0 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.UserService = void 0;
4
- var Helper_1 = require("./Helper");
5
- var UserService;
6
- (function (UserService) {
7
- /**
8
- * get user info
9
- * @param options
10
- * @returns
11
- */
12
- function getUserProfile(options) {
13
- return new Promise(function (resolve, reject) {
14
- try {
15
- if (!options.access_token) {
16
- throw new Helper_1.CustomException("access_token cannot be empty", 417);
17
- }
18
- var http = new XMLHttpRequest();
19
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo";
20
- http.onreadystatechange = function () {
21
- if (http.readyState == 4) {
22
- resolve(JSON.parse(http.responseText));
23
- }
24
- };
25
- http.open("GET", _serviceURL, true);
26
- http.setRequestHeader("Content-type", "application/json");
27
- http.setRequestHeader("Authorization", "Bearer ".concat(options.access_token));
28
- if (window.localeSettings) {
29
- http.setRequestHeader("accept-language", window.localeSettings);
30
- }
31
- http.send();
32
- }
33
- catch (ex) {
34
- reject(ex);
35
- }
36
- });
37
- }
38
- UserService.getUserProfile = getUserProfile;
39
- ;
40
- /**
41
- * register user
42
- * @param options
43
- * @param headers
44
- * @returns
45
- */
46
- function register(options, headers) {
47
- return new Promise(function (resolve, reject) {
48
- try {
49
- var http = new XMLHttpRequest();
50
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/register";
51
- if (options.invite_id) {
52
- _serviceURL = _serviceURL + "?invite_id=" + options.invite_id;
53
- }
54
- http.onreadystatechange = function () {
55
- if (http.readyState == 4) {
56
- if (http.responseText) {
57
- resolve(JSON.parse(http.responseText));
58
- }
59
- else {
60
- resolve(false);
61
- }
62
- }
63
- };
64
- http.open("POST", _serviceURL, true);
65
- http.setRequestHeader("Content-type", "application/json");
66
- http.setRequestHeader("requestId", headers.requestId);
67
- if (headers.captcha) {
68
- http.setRequestHeader("captcha", headers.captcha);
69
- }
70
- if (headers.acceptlanguage) {
71
- http.setRequestHeader("accept-language", headers.acceptlanguage);
72
- }
73
- else if (window.localeSettings) {
74
- http.setRequestHeader("accept-language", window.localeSettings);
75
- }
76
- if (headers.bot_captcha_response) {
77
- http.setRequestHeader("bot_captcha_response", headers.bot_captcha_response);
78
- }
79
- if (headers.trackId) {
80
- http.setRequestHeader("trackid", headers.trackId);
81
- }
82
- http.send(JSON.stringify(options));
83
- }
84
- catch (ex) {
85
- reject(ex);
86
- }
87
- });
88
- }
89
- UserService.register = register;
90
- ;
91
- /**
92
- * get invite info
93
- * @param options
94
- * @returns
95
- */
96
- function getInviteUserDetails(options) {
97
- return new Promise(function (resolve, reject) {
98
- try {
99
- var http = new XMLHttpRequest();
100
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/invite/info/" + options.invite_id;
101
- http.onreadystatechange = function () {
102
- if (http.readyState == 4) {
103
- if (http.responseText) {
104
- resolve(JSON.parse(http.responseText));
105
- }
106
- else {
107
- resolve(false);
108
- }
109
- }
110
- };
111
- http.open("GET", _serviceURL, true);
112
- http.setRequestHeader("Content-type", "application/json");
113
- if (window.localeSettings) {
114
- http.setRequestHeader("accept-language", window.localeSettings);
115
- }
116
- http.send();
117
- }
118
- catch (ex) {
119
- reject(ex);
120
- }
121
- });
122
- }
123
- UserService.getInviteUserDetails = getInviteUserDetails;
124
- ;
125
- /**
126
- * get Communication status
127
- * @param options
128
- * @returns
129
- */
130
- function getCommunicationStatus(options) {
131
- return new Promise(function (resolve, reject) {
132
- try {
133
- var http = new XMLHttpRequest();
134
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/communication/status/" + options.sub;
135
- http.onreadystatechange = function () {
136
- if (http.readyState == 4) {
137
- if (http.responseText) {
138
- resolve(JSON.parse(http.responseText));
139
- }
140
- else {
141
- resolve(false);
142
- }
143
- }
144
- };
145
- http.open("GET", _serviceURL, true);
146
- http.setRequestHeader("Content-type", "application/json");
147
- if (options.requestId) {
148
- http.setRequestHeader("requestId", options.requestId);
149
- }
150
- if (window.localeSettings) {
151
- http.setRequestHeader("accept-language", window.localeSettings);
152
- }
153
- http.send();
154
- }
155
- catch (ex) {
156
- reject(ex);
157
- }
158
- });
159
- }
160
- UserService.getCommunicationStatus = getCommunicationStatus;
161
- ;
162
- /**
163
- * initiate reset password
164
- * @param options
165
- * @returns
166
- */
167
- function initiateResetPassword(options) {
168
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/resetpassword/initiate";
169
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false);
170
- }
171
- UserService.initiateResetPassword = initiateResetPassword;
172
- ;
173
- /**
174
- * handle reset password
175
- * @param options
176
- */
177
- function handleResetPassword(options) {
178
- try {
179
- var url_1 = window.webAuthSettings.authority + "/users-srv/resetpassword/validatecode";
180
- if (window.webAuthSettings.cidaas_version > 2) {
181
- var form = Helper_1.Helper.createForm(url_1, options);
182
- document.body.appendChild(form);
183
- form.submit();
184
- }
185
- else {
186
- return new Promise(function (resolve, reject) {
187
- try {
188
- var http = new XMLHttpRequest();
189
- http.onreadystatechange = function () {
190
- if (http.readyState == 4) {
191
- if (http.responseText) {
192
- resolve(JSON.parse(http.responseText));
193
- }
194
- else {
195
- resolve(false);
196
- }
197
- }
198
- };
199
- http.open("POST", url_1, true);
200
- http.setRequestHeader("Content-type", "application/json");
201
- http.send(JSON.stringify(options));
202
- }
203
- catch (ex) {
204
- reject(ex);
205
- }
206
- });
207
- }
208
- }
209
- catch (ex) {
210
- throw new Helper_1.CustomException(ex, 417);
211
- }
212
- }
213
- UserService.handleResetPassword = handleResetPassword;
214
- ;
215
- /**
216
- * reset password
217
- * @param options
218
- */
219
- function resetPassword(options) {
220
- var url = window.webAuthSettings.authority + "/users-srv/resetpassword/accept";
221
- try {
222
- if (window.webAuthSettings.cidaas_version > 2) {
223
- var form = Helper_1.Helper.createForm(url, options);
224
- document.body.appendChild(form);
225
- form.submit();
226
- }
227
- else {
228
- return new Promise(function (resolve, reject) {
229
- try {
230
- var http = new XMLHttpRequest();
231
- http.onreadystatechange = function () {
232
- if (http.readyState == 4) {
233
- if (http.responseText) {
234
- resolve(JSON.parse(http.responseText));
235
- }
236
- else {
237
- resolve(false);
238
- }
239
- }
240
- };
241
- http.open("POST", url, true);
242
- http.setRequestHeader("Content-type", "application/json");
243
- http.send(JSON.stringify(options));
244
- }
245
- catch (ex) {
246
- reject(ex);
247
- }
248
- });
249
- }
250
- }
251
- catch (ex) {
252
- throw new Helper_1.CustomException(ex, 417);
253
- }
254
- }
255
- UserService.resetPassword = resetPassword;
256
- ;
257
- /**
258
- * get Deduplication details
259
- * @param options
260
- * @returns
261
- */
262
- function getDeduplicationDetails(options) {
263
- return new Promise(function (resolve, reject) {
264
- try {
265
- var http = new XMLHttpRequest();
266
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/info/" + options.trackId;
267
- http.onreadystatechange = function () {
268
- if (http.readyState == 4) {
269
- if (http.responseText) {
270
- resolve(JSON.parse(http.responseText));
271
- }
272
- else {
273
- resolve(false);
274
- }
275
- }
276
- };
277
- http.open("GET", _serviceURL, true);
278
- http.setRequestHeader("Content-type", "application/json");
279
- if (window.localeSettings) {
280
- http.setRequestHeader("accept-language", window.localeSettings);
281
- }
282
- http.send();
283
- }
284
- catch (ex) {
285
- reject(ex);
286
- }
287
- });
288
- }
289
- UserService.getDeduplicationDetails = getDeduplicationDetails;
290
- ;
291
- /**
292
- * deduplication login
293
- * @param options
294
- */
295
- function deduplicationLogin(options) {
296
- try {
297
- var form = document.createElement('form');
298
- form.action = window.webAuthSettings.authority + "/users-srv/deduplication/login/redirection?trackId=" + options.trackId + "&requestId=" + options.requestId + "&sub=" + options.sub;
299
- form.method = 'POST';
300
- document.body.appendChild(form);
301
- form.submit();
302
- }
303
- catch (ex) {
304
- throw new Helper_1.CustomException(ex, 417);
305
- }
306
- }
307
- UserService.deduplicationLogin = deduplicationLogin;
308
- ;
309
- /**
310
- * register Deduplication
311
- * @param options
312
- * @returns
313
- */
314
- function registerDeduplication(options) {
315
- return new Promise(function (resolve, reject) {
316
- try {
317
- var http = new XMLHttpRequest();
318
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/register/" + options.trackId;
319
- http.onreadystatechange = function () {
320
- if (http.readyState == 4) {
321
- resolve(JSON.parse(http.responseText));
322
- }
323
- };
324
- http.open("POST", _serviceURL, true);
325
- http.setRequestHeader("Content-type", "application/json");
326
- if (window.localeSettings) {
327
- http.setRequestHeader("accept-language", window.localeSettings);
328
- }
329
- http.send();
330
- }
331
- catch (ex) {
332
- reject(ex);
333
- }
334
- });
335
- }
336
- UserService.registerDeduplication = registerDeduplication;
337
- ;
338
- /**
339
- * change password
340
- * @param options
341
- * @param access_token
342
- * @returns
343
- */
344
- function changePassword(options, access_token) {
345
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/changepassword";
346
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, access_token);
347
- }
348
- UserService.changePassword = changePassword;
349
- ;
350
- /**
351
- * update profile
352
- * @param options
353
- * @param access_token
354
- * @param sub
355
- * @returns
356
- */
357
- function updateProfile(options, access_token, sub) {
358
- return new Promise(function (resolve, reject) {
359
- try {
360
- var http = new XMLHttpRequest();
361
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/profile/" + sub;
362
- http.onreadystatechange = function () {
363
- if (http.readyState == 4) {
364
- if (http.responseText) {
365
- resolve(JSON.parse(http.responseText));
366
- }
367
- else {
368
- resolve(false);
369
- }
370
- }
371
- };
372
- http.open("PUT", _serviceURL, true);
373
- http.setRequestHeader("Content-type", "application/json");
374
- http.setRequestHeader("Authorization", "Bearer ".concat(access_token));
375
- if (window.localeSettings) {
376
- http.setRequestHeader("accept-language", window.localeSettings);
377
- }
378
- http.send(JSON.stringify(options));
379
- }
380
- catch (ex) {
381
- throw new Helper_1.CustomException(ex, 417);
382
- }
383
- });
384
- }
385
- UserService.updateProfile = updateProfile;
386
- ;
387
- /**
388
- * initiate link accoount
389
- * @param options
390
- * @param access_token
391
- * @returns
392
- */
393
- function initiateLinkAccount(options, access_token) {
394
- options.user_name_type = 'email';
395
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/initiate";
396
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, access_token);
397
- }
398
- UserService.initiateLinkAccount = initiateLinkAccount;
399
- ;
400
- /**
401
- * complete link accoount
402
- * @param options
403
- * @param access_token
404
- * @returns
405
- */
406
- function completeLinkAccount(options, access_token) {
407
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/complete";
408
- return Helper_1.Helper.createPostPromise(options, _serviceURL, false, access_token);
409
- }
410
- UserService.completeLinkAccount = completeLinkAccount;
411
- ;
412
- /**
413
- * get linked users
414
- * @param access_token
415
- * @param sub
416
- * @returns
417
- */
418
- function getLinkedUsers(access_token, sub) {
419
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo/social/" + sub;
420
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, access_token);
421
- }
422
- UserService.getLinkedUsers = getLinkedUsers;
423
- ;
424
- /**
425
- * unlink accoount
426
- * @param access_token
427
- * @param identityId
428
- * @returns
429
- */
430
- function unlinkAccount(access_token, identityId) {
431
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unlink/" + identityId;
432
- return Helper_1.Helper.createPostPromise(undefined, _serviceURL, false, access_token);
433
- }
434
- UserService.unlinkAccount = unlinkAccount;
435
- ;
436
- /**
437
- * deleteUserAccount
438
- * @param options
439
- * @returns
440
- */
441
- function deleteUserAccount(options) {
442
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unregister/scheduler/schedule/" + options.sub;
443
- return Helper_1.Helper.createPostPromise(options, _serviceURL, undefined, options.access_token);
444
- }
445
- UserService.deleteUserAccount = deleteUserAccount;
446
- ;
447
- /**
448
- * check if an user exists
449
- * @param options
450
- * @returns
451
- */
452
- function userCheckExists(options) {
453
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/checkexists/" + options.requestId;
454
- return Helper_1.Helper.createPostPromise(options, _serviceURL, undefined);
455
- }
456
- UserService.userCheckExists = userCheckExists;
457
- ;
458
- })(UserService = exports.UserService || (exports.UserService = {}));