cidaas-javascript-sdk 2.4.3 → 2.5.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/README.md +2 -3
  3. package/package.json +10 -12
  4. package/src/main/authentication/index.ts +223 -0
  5. package/src/main/global.d.ts +10 -0
  6. package/src/main/index.ts +6 -0
  7. package/src/main/web-auth/ConsentService.ts +98 -0
  8. package/src/main/web-auth/Entities.ts +645 -0
  9. package/src/main/web-auth/Helper.ts +75 -0
  10. package/src/main/web-auth/LoginService.ts +248 -0
  11. package/src/main/web-auth/TokenService.ts +196 -0
  12. package/src/main/web-auth/UserService.ts +388 -0
  13. package/src/main/web-auth/VerificationService.ts +267 -0
  14. package/src/main/web-auth/WebAuth.ts +1706 -0
  15. package/types/authentication/index.d.ts +55 -0
  16. package/types/authentication/index.js +262 -0
  17. package/types/index.d.ts +4 -0
  18. package/types/index.js +9 -0
  19. package/types/web-auth/ConsentService.d.ts +59 -0
  20. package/types/web-auth/ConsentService.js +97 -0
  21. package/types/web-auth/Entities.d.ts +567 -0
  22. package/types/web-auth/Entities.js +88 -0
  23. package/types/web-auth/Helper.d.ts +24 -0
  24. package/types/web-auth/Helper.js +89 -0
  25. package/types/web-auth/LoginService.d.ts +102 -0
  26. package/types/web-auth/LoginService.js +248 -0
  27. package/types/web-auth/TokenService.d.ts +48 -0
  28. package/types/web-auth/TokenService.js +210 -0
  29. package/types/web-auth/UserService.d.ts +143 -0
  30. package/types/web-auth/UserService.js +408 -0
  31. package/types/web-auth/VerificationService.d.ts +125 -0
  32. package/types/web-auth/VerificationService.js +273 -0
  33. package/types/web-auth/WebAuth.d.ts +895 -0
  34. package/types/web-auth/WebAuth.js +1767 -0
  35. package/Changelogs.md +0 -29
  36. package/src/main/.gitkeep +0 -0
  37. package/src/main/authentication/index.js +0 -213
  38. package/src/main/index.js +0 -11
  39. package/src/main/web-auth/exception.js +0 -7
  40. package/src/main/web-auth/webauth.js +0 -1899
  41. package/src/test/sum.js +0 -4
  42. package/src/test/test.js +0 -5
  43. package/types/.DS_Store +0 -0
  44. package/types/main/authentication/index.d.ts +0 -15
  45. package/types/main/index.d.ts +0 -5
  46. package/types/main/web-auth/exception.d.ts +0 -7
  47. package/types/main/web-auth/webauth.d.ts +0 -141
  48. package/types/test/sum.d.ts +0 -2
  49. package/types/test/test.d.ts +0 -1
@@ -0,0 +1,645 @@
1
+ export class AcceptResetPasswordEntity {
2
+ resetRequestId: string = "";
3
+ exchangeId: string = "";
4
+ password: string = "";
5
+ confirmPassword: string = "";
6
+ provider: string = "";
7
+ requestId: string = "";
8
+ }
9
+
10
+ export class AccessTokenRequest {
11
+ grant_type?: string;
12
+ code?: string;
13
+ redirect_uri?: string;
14
+ client_id?: string;
15
+ client_secret?: string;
16
+ state?: string;
17
+ scope?: string;
18
+ refresh_token?: string;
19
+ code_verifier?: string;
20
+ username?: string;
21
+ password?: string;
22
+ requestId?: string;
23
+ provider?: string;
24
+ host?: string;
25
+ client_assertion?: string;
26
+ client_assertion_type?: string;
27
+
28
+ client_ip?: string;
29
+ captcha?: string;
30
+ locale?: string;
31
+ username_type?: string;
32
+ signature?: string;
33
+ remember_me?: boolean;
34
+
35
+
36
+ user_agent: string = "";
37
+ ip_address: string = "";
38
+ accept_language: string = "";
39
+ lat: string = "";
40
+ lng: string = "";
41
+ finger_print: string = "";
42
+ referrer: string = "";
43
+
44
+ pre_login_id: string = "";
45
+
46
+ login_type: string = "";
47
+
48
+ // device code flow
49
+ device_code: string = "";
50
+
51
+ // for social logins
52
+ sub?: string;
53
+ identityId?: string;
54
+ providerUserId?: string;
55
+
56
+ mfa_exchange_id?: string;
57
+ dc?: string;
58
+
59
+ field_key?: string;
60
+ }
61
+ export class PhysicalVerificationLoginRequest {
62
+ q?: string;
63
+ sub?: string;
64
+ requestId?: string;
65
+ status_id?: string;
66
+ verificationType?: string;
67
+ deviceInfo?: IDeviceRequest;
68
+ device_fp?: string;
69
+ }
70
+ export interface IDeviceRequest {
71
+ userAgent: string;
72
+ ipAddress: string;
73
+ lat: string;
74
+ lon: string;
75
+ deviceId: string;
76
+ usedTime: Date;
77
+ purpose: string;
78
+ requestId: string;
79
+ sub: string;
80
+ pushNotificationId: string;
81
+ deviceMake: string;
82
+ deviceModel: string;
83
+ deviceType: string;
84
+ }
85
+
86
+ export type AccountVerificationRequestEntity = {
87
+ email: string;
88
+ mobile: string;
89
+ phone: string;
90
+ username: string;
91
+ verificationMedium: string;
92
+ processingType: string;
93
+ requestId: string;
94
+ client_id: string;
95
+ redirect_uri: string;
96
+ response_type: string;
97
+ sub: string;
98
+ templateKey: string;
99
+ name: string;
100
+ accept_language: string;
101
+ }
102
+
103
+ export interface ChangePasswordEntity {
104
+ sub: string;
105
+ identityId: string;
106
+ old_password: string;
107
+ new_password: string;
108
+ confirm_password: string;
109
+ accessToken: string;
110
+ }
111
+
112
+ export interface FidoSetupEntity {
113
+ track_id: string;
114
+ fido_request_type: string;
115
+ mobile_number: string;
116
+ phone: string;
117
+ security_questions: string[];
118
+ verification_type: string;
119
+ }
120
+
121
+ export class FindUserEntity {
122
+ sub: string = "";
123
+ email: string = "";
124
+ mobile: string = "";
125
+ username: string = "";
126
+ customFields: any;
127
+ provider: string = "";
128
+ providerUserId: string = "";
129
+
130
+ sub_not: string = "";
131
+
132
+ //additional param
133
+ requestId: string
134
+ }
135
+
136
+ export interface IAddressEntity {
137
+ formatted: string;
138
+ street_address: string;
139
+ locality: string;
140
+ region: string;
141
+ postal_code: string;
142
+ country: string;
143
+ }
144
+
145
+ export interface IAuthVerificationAuthenticationRequestEntity extends FaceVerificationAuthenticationRequestEntity {
146
+ type: string;
147
+ verification_type?: string
148
+ }
149
+
150
+ export interface FIDO2EnrollEntity {
151
+ client_response?: any;
152
+ fidoRequestId?: string;
153
+ }
154
+
155
+ export interface FaceVerificationAuthenticationRequestEntity {
156
+ exchange_id: string;
157
+ pass_code?: string;
158
+ client_id: string;
159
+ device_id?: string;
160
+ push_id?: string;
161
+ password?: string;
162
+ upload_attempt?: number;
163
+ fido2_client_response?: FIDO2EnrollEntity;
164
+ single_factor_auth?: boolean;
165
+ captcha?: string;
166
+ captcha_ref?: string;
167
+ bot_captcha_response?: string;
168
+ csrf_token?: string;
169
+ }
170
+
171
+ export interface IConfiguredListRequestEntity {
172
+ sub: string;
173
+ email: string;
174
+ mobile_number: string;
175
+ username: string;
176
+ request_id: string;
177
+
178
+
179
+ verification_types: string[];
180
+ single_factor_sub_ref: string;
181
+ device_fp: string;
182
+ provider: string;
183
+ device_id: string;
184
+
185
+ // additional params
186
+ verification_type: string
187
+
188
+ }
189
+
190
+ export interface IConsentAcceptEntity {
191
+ client_id: string;
192
+ consent_id: string;
193
+ consent_version_id: string;
194
+ sub: string;
195
+ scopes: string[];
196
+ url: string;
197
+ matcher: any;
198
+ field_key: string;
199
+ accepted_fields: string[];
200
+ accepted_by: string;
201
+ skipped: boolean;
202
+ action_type: string;
203
+ action_id: string;
204
+ q: string;
205
+ revoked: boolean;
206
+ }
207
+
208
+
209
+ export interface IEnrollVerificationSetupRequestEntity {
210
+ exchange_id: string;
211
+ device_id: string;
212
+ finger_print: string;
213
+ client_id: string;
214
+ push_id: string;
215
+ pass_code: string;
216
+ pkce_key: string;
217
+
218
+
219
+ face_attempt: number;
220
+ attempt: number;
221
+
222
+ fido2_client_response: FIDO2EnrollEntity;
223
+
224
+ //additional params
225
+ verification_type: string;
226
+ }
227
+
228
+ export interface IInitVerificationAuthenticationRequestEntity {
229
+ q: string;
230
+ sub: string;
231
+ email: string;
232
+ mobile_number: string;
233
+ username: string;
234
+
235
+ client_id: string;
236
+ request_id: string;
237
+ usage_type: string;
238
+
239
+ medium_id: string;
240
+
241
+ single_factor_auth: boolean;
242
+
243
+ push_id: string;
244
+ device_id: string;
245
+
246
+
247
+ single_factor_sub_ref: string;
248
+
249
+ verification_types: string[];
250
+ device_fp: string;
251
+ provider: string;
252
+ processingType: string;
253
+ trackId: string;
254
+
255
+ //added additionaly
256
+ type?: string
257
+ verification_type?: string
258
+ }
259
+
260
+ export interface IMobileEntity {
261
+ given_phone: string;
262
+ phone: string;
263
+ country: string;
264
+ dail_code: string;
265
+ carrier_type: string;
266
+ carrier_name: string;
267
+ national_format: string;
268
+ international_format: string;
269
+ E164_format: string;
270
+ }
271
+
272
+
273
+ export interface ISuggestedMFAActionConfig {
274
+ sub?: string;
275
+ do_not_ask_again?: boolean;
276
+ later?: boolean;
277
+ }
278
+
279
+ export interface IUserEntity {
280
+ userStatus: string;
281
+ user_status: string;
282
+ user_status_reason: string;
283
+ username: string;
284
+ sub: string;
285
+ given_name: string;
286
+ family_name: string;
287
+ middle_name: string;
288
+ nickname: string;
289
+ originalProviderUserId?: string[];
290
+ email: string;
291
+ email_verified: boolean;
292
+ mobile_number: string;
293
+ mobile_number_obj: IMobileEntity | null;
294
+ mobile_number_verified: boolean;
295
+ phone_number: string;
296
+ phone_number_obj: IMobileEntity | null;
297
+ phone_number_verified: boolean;
298
+ profile: string;
299
+ picture: string;
300
+ website: string;
301
+ gender: string;
302
+ zoneinfo: string;
303
+ locale: string;
304
+ birthdate: Date | null;
305
+ address?: IAddressEntity;
306
+ customFields?: any;
307
+ identityCustomFields?: any;
308
+ password: string;
309
+ provider: string;
310
+ providerUserId: string;
311
+ identityId: string;
312
+ mfa_enabled?: boolean;
313
+ roles: string[];
314
+ userGroups: IUserGroupMap[];
315
+ groups?: IUserGroupMap[];
316
+ rawJSON: string;
317
+ trackId: string;
318
+ need_reset_password: boolean;
319
+ }
320
+
321
+
322
+ export interface IUserEntity {
323
+ userStatus: string;
324
+ user_status: string;
325
+ user_status_reason: string;
326
+ username: string;
327
+ sub: string;
328
+ given_name: string;
329
+ family_name: string;
330
+ middle_name: string;
331
+ nickname: string;
332
+ originalProviderUserId?: string[];
333
+ email: string;
334
+ email_verified: boolean;
335
+ mobile_number: string;
336
+ mobile_number_obj: IMobileEntity | null;
337
+ mobile_number_verified: boolean;
338
+ phone_number: string;
339
+ phone_number_obj: IMobileEntity | null;
340
+ phone_number_verified: boolean;
341
+ profile: string;
342
+ picture: string;
343
+ website: string;
344
+ gender: string;
345
+ zoneinfo: string;
346
+ locale: string;
347
+ birthdate: Date | null;
348
+ address?: IAddressEntity;
349
+ customFields?: any;
350
+ identityCustomFields?: any;
351
+ password: string;
352
+ provider: string;
353
+ providerUserId: string;
354
+ identityId: string;
355
+ mfa_enabled?: boolean;
356
+ roles: string[];
357
+ userGroups: IUserGroupMap[];
358
+ groups?: IUserGroupMap[];
359
+ rawJSON: string;
360
+ trackId: string;
361
+ need_reset_password: boolean;
362
+ }
363
+
364
+
365
+ export interface IUserGroupMap {
366
+ sub: string;
367
+ groupId: string;
368
+ roles: string[];
369
+ appendRole: boolean;
370
+ }
371
+
372
+ export interface IUserLinkEntity {
373
+ master_sub: string;
374
+ user_name_type: string;
375
+ user_name_to_link: string;
376
+ link_accepted_by: string;
377
+ link_response_time: Date;
378
+ link_accepted: boolean;
379
+ communication_type: string;
380
+ verification_status_id: string;
381
+ type: string;
382
+ status: string;
383
+ }
384
+ export type LoginFormRequestAsyncEntity = {
385
+ username: string;
386
+ password: string;
387
+ requestId: string;
388
+ provider: string;
389
+ captcha: string;
390
+ username_type: string;
391
+ field_key: string;
392
+ bot_captcha_response: string;
393
+ csrf_token: string;
394
+ dc?: string;
395
+ device_fp?: string;
396
+ captcha_ref?: string;
397
+ locale?: string;
398
+ rememberMe: string;
399
+ remember_me: string;
400
+ }
401
+
402
+ export interface LoginFormRequestEntity {
403
+ username: string;
404
+ password: string;
405
+ requestId: string;
406
+ provider: string;
407
+ captcha: string;
408
+ username_type: string;
409
+ field_key: string;
410
+ bot_captcha_response: string;
411
+ csrf_token: string;
412
+ dc?: string;
413
+ device_fp?: string;
414
+ captcha_ref?: string;
415
+ locale?: string;
416
+ rememberMe: boolean;
417
+ remember_me: boolean;
418
+ }
419
+
420
+ export interface ResetPasswordEntity {
421
+ email: string;
422
+ mobile: string;
423
+ phone: string;
424
+ username: string;
425
+ resetMedium: string;
426
+ processingType: string;
427
+ requestId: string;
428
+ provider: string;
429
+ resetPasswordId: string;
430
+ sub: string;
431
+ }
432
+
433
+ export class TokenIntrospectionEntity {
434
+ token: string = "";
435
+ token_type_hint?: string;
436
+ roles?: string[];
437
+ scopes?: string[];
438
+
439
+
440
+
441
+ groups?: GroupValidationEntity[];
442
+ strictGroupValidation: boolean = false;
443
+ strictScopeValidation: boolean = false;
444
+
445
+ strictRoleValidation: boolean = false;
446
+ strictValidation: boolean = false;
447
+
448
+ client_id?: string;
449
+ client_secret?: string;
450
+
451
+ request_url?: string;
452
+ request_time?: number;
453
+ request_headers?: any;
454
+
455
+
456
+ }
457
+ export class GroupValidationEntity {
458
+ groupId?: string;
459
+ groupType?: string;
460
+ roles?: string[];
461
+ strictRoleValidation: boolean = false;
462
+ strictValidation: boolean = false;
463
+ }
464
+
465
+ export class UpdateReviewDeviceEntity {
466
+ userId: string = "";
467
+ device: string = "";
468
+ browser: string = "";
469
+ location: string = "";
470
+ }
471
+
472
+ export interface UserActivityEntity {
473
+ skip?: Number;
474
+ take?: Number;
475
+ sub?: string;
476
+ startDate?: string;
477
+ endDate?: string;
478
+ events?: [string];
479
+ }
480
+
481
+ export declare class UserEntity {
482
+ userStatus: string;
483
+ user_status?: string;
484
+ user_status_reason: string;
485
+ username: string;
486
+ sub: string;
487
+ originalProviderUserId?: string[];
488
+ given_name: string;
489
+ family_name: string;
490
+ middle_name: string;
491
+ nickname: string;
492
+ email: string;
493
+ email_verified: boolean;
494
+ mobile_number: string;
495
+ mobile_number_obj: IMobileEntity | null;
496
+ mobile_number_verified: boolean;
497
+ phone_number: string;
498
+ phone_number_obj: IMobileEntity | null;
499
+ phone_number_verified: boolean;
500
+ profile: string;
501
+ picture: string;
502
+ website: string;
503
+ gender: string;
504
+ zoneinfo: string;
505
+ locale: string;
506
+ birthdate: Date | string;
507
+ address?: AddressEntity;
508
+ customFields?: any;
509
+ identityCustomFields?: any;
510
+ password: string;
511
+ password_echo?: string;
512
+ password_hash_info: any | null;
513
+ generate_password: boolean;
514
+ provider: string;
515
+ identityId: string;
516
+ providerUserId: string;
517
+ providerBusinessIds: string[];
518
+ street_address: string;
519
+ mfa_enabled?: boolean;
520
+ roles?: string[];
521
+ groups?: IUserGroupMap[];
522
+ userGroups?: IUserGroupMap[];
523
+ trackId: string;
524
+ rawJSON: string;
525
+ need_reset_password: boolean;
526
+ no_event: boolean;
527
+ consents?: IConsentField[] | IConsentTrackingEntity[];
528
+ consent_track_ids?: string[];
529
+ ignore_default_roles?: string[];
530
+ createdTime?: Date;
531
+ identities?: IIdentity[];
532
+ _id?: string;
533
+ id?: string;
534
+ invite_id?: string
535
+ }
536
+ export interface IConsentTrackingEntity {
537
+ state?: string;
538
+ fieldKey: string;
539
+ consentId: string;
540
+ versionId?: string;
541
+ time?: Date;
542
+ scopes: string[];
543
+ acceptedBy: string;
544
+ }
545
+
546
+ export interface IConsentField {
547
+ field_key?: string;
548
+ value?: boolean;
549
+ }
550
+
551
+ export interface IUserGroupMap {
552
+ sub: string;
553
+ groupId: string;
554
+ roles: string[];
555
+ appendRole: boolean;
556
+ eventType: string;
557
+ status: number;
558
+ }
559
+
560
+ export declare class AddressEntity {
561
+ formatted: string;
562
+ street_address: string;
563
+ locality: string;
564
+ region: string;
565
+ postal_code: string;
566
+ country: string;
567
+ }
568
+
569
+ export interface IIdentity {
570
+ identityId: string;
571
+ sub: string;
572
+ given_name: string;
573
+ family_name: string;
574
+ middle_name: string;
575
+ nickname: string;
576
+ email: string;
577
+ email_verified: boolean;
578
+ mobile_number: string;
579
+ mobile_number_obj: IMobileEntity;
580
+ mobile_number_verified: boolean;
581
+ phone_number: string;
582
+ phone_number_obj: IMobileEntity;
583
+ phone_number_verified: boolean;
584
+ profile: string;
585
+ picture: string;
586
+ website: string;
587
+ gender: string;
588
+ zoneinfo: string;
589
+ locale: string;
590
+ birthdate: Date | string;
591
+ address: IUserAddress;
592
+ street_address: string;
593
+ provider: string;
594
+ providerUserId: string;
595
+ username: string;
596
+ identityCustomFields: any;
597
+ providerBusinessIds: string[];
598
+ originalProviderUserId?: string[];
599
+ raw_json: string;
600
+ password_hash_info: any | null;
601
+ password: string;
602
+ createdTime: Date;
603
+ updatedTime: Date;
604
+ }
605
+
606
+ export interface IMobileEntity {
607
+ _id: string;
608
+ id: string;
609
+ given_phone: string;
610
+ phone: string;
611
+ country: string;
612
+ dail_code: string;
613
+ carrier_type: string;
614
+ carrier_name: string;
615
+ national_format: string;
616
+ international_format: string;
617
+ E164_format: string;
618
+ }
619
+
620
+ export interface IUserAddress {
621
+ _id: string;
622
+ id: string;
623
+ formatted: string;
624
+ street_address: string;
625
+ locality: string;
626
+ region: string;
627
+ postal_code: string;
628
+ country: string;
629
+ }
630
+
631
+ export class ValidateResetPasswordEntity {
632
+ resetRequestId: string = "";
633
+ code: string = "";
634
+ }
635
+
636
+ export interface IChangePasswordEntity {
637
+ sub: string;
638
+ identityId: string;
639
+ old_password: string;
640
+ new_password: string;
641
+ confirm_password: string;
642
+ accessToken: string;
643
+ loginSettingsId: string;
644
+ client_id: string;
645
+ }
@@ -0,0 +1,75 @@
1
+ export class Helper {
2
+ /**
3
+ * create form
4
+ * @param form
5
+ * @param options
6
+ * @returns
7
+ */
8
+ static createForm(url: string, options: any, method: string = 'POST') {
9
+ var form = document.createElement('form');
10
+ form.action = url;
11
+ form.method = method;
12
+ for (var key in options) {
13
+ if (options.hasOwnProperty(key)) {
14
+ var hiddenField = document.createElement("input");
15
+ hiddenField.setAttribute("type", "hidden");
16
+ hiddenField.setAttribute("name", key);
17
+ hiddenField.setAttribute("value", options[key]);
18
+ form.appendChild(hiddenField);
19
+ }
20
+ }
21
+ return form;
22
+ }
23
+
24
+ /**
25
+ * utility function to create and make post request
26
+ * @param options
27
+ * @param serviceurl
28
+ * @param errorResolver
29
+ * @param access_token
30
+ * @param headers
31
+ * @returns
32
+ */
33
+ static createPostPromise(options: any, serviceurl: string, errorResolver: boolean, access_token?: string, headers?: any) {
34
+ return new Promise((resolve, reject) => {
35
+ try {
36
+ var http = new XMLHttpRequest();
37
+ http.onreadystatechange = function () {
38
+ if (http.readyState == 4) {
39
+ if (http.responseText) {
40
+ resolve(JSON.parse(http.responseText));
41
+ } else {
42
+ resolve(errorResolver);
43
+ }
44
+ }
45
+ };
46
+ http.open("POST", serviceurl, true);
47
+ http.setRequestHeader("Content-type", "application/json");
48
+ if (headers) {
49
+ for (var key in headers) {
50
+ if (headers.hasOwnProperty(key)) {
51
+ http.setRequestHeader(key, headers[key]);
52
+ }
53
+ }
54
+ }
55
+ if (access_token) {
56
+ http.setRequestHeader("Authorization", `Bearer ${access_token}`);
57
+ }
58
+ if (window.localeSettings) {
59
+ http.setRequestHeader("accept-language", window.localeSettings);
60
+ }
61
+ if (options) {
62
+ http.send(JSON.stringify(options));
63
+ } else {
64
+ http.send();
65
+ }
66
+ } catch (ex) {
67
+ reject(ex);
68
+ }
69
+ });
70
+ }
71
+ }
72
+
73
+ export class CustomException {
74
+ constructor(public errorMessage: string, public statusCode: number) { }
75
+ }