cidaas-javascript-sdk 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
- ## [3.0.2](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v3.0.1...v3.0.2) (2023-05-03)
1
+ ## [3.0.4](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v3.0.3...v3.0.4) (2023-06-15)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * update declaration file path in dependency file ([bed0b5b](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/bed0b5b7ef52c791c465e1e981363dca2df6de4a))
6
+ * cidaas v3 support and interface adjustment ([07811ef](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/07811efe9a8bcb0f95aab9f779ad6502313ff7bf))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cidaas-javascript-sdk",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "author": "cidaas by Widas ID GmbH",
5
5
  "description": "Cidaas native javascript sdk",
6
6
  "license": "MIT",
@@ -1,10 +1,10 @@
1
- export class AcceptResetPasswordEntity {
2
- resetRequestId: string = "";
3
- exchangeId: string = "";
4
- password: string = "";
5
- confirmPassword: string = "";
6
- provider: string = "";
7
- requestId: string = "";
1
+ export interface AcceptResetPasswordEntity {
2
+ resetRequestId: string ;
3
+ exchangeId: string;
4
+ password: string;
5
+ confirmPassword: string;
6
+ provider?: string;
7
+ requestId?: string;
8
8
  }
9
9
 
10
10
  export class AccessTokenRequest {
@@ -84,20 +84,20 @@ export interface IDeviceRequest {
84
84
  }
85
85
 
86
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;
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
97
  sub: string;
98
- templateKey: string;
99
- name: string;
100
- accept_language: string;
98
+ templateKey?: string;
99
+ name?: string;
100
+ accept_language?: string;
101
101
  }
102
102
 
103
103
  export interface ChangePasswordEntity {
@@ -403,31 +403,31 @@ export interface LoginFormRequestEntity {
403
403
  username: string;
404
404
  password: string;
405
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;
406
+ provider?: string;
407
+ captcha?: string;
408
+ username_type?: string;
409
+ field_key?: string;
410
+ bot_captcha_response?: string;
411
+ csrf_token?: string;
412
412
  dc?: string;
413
413
  device_fp?: string;
414
414
  captcha_ref?: string;
415
415
  locale?: string;
416
- rememberMe: boolean;
417
- remember_me: boolean;
416
+ rememberMe?: boolean;
417
+ remember_me?: boolean;
418
418
  }
419
419
 
420
420
  export interface ResetPasswordEntity {
421
421
  email: string;
422
- mobile: string;
423
- phone: string;
424
- username: string;
425
- resetMedium: string;
426
- processingType: string;
422
+ mobile?: string;
423
+ phone?: string;
424
+ username?: string;
425
+ resetMedium: "SMS" | "EMAIL" | "IVR";
426
+ processingType: "CODE" | "LINK";
427
427
  requestId: string;
428
- provider: string;
429
- resetPasswordId: string;
430
- sub: string;
428
+ provider?: string;
429
+ resetPasswordId?: string;
430
+ sub?: string;
431
431
  }
432
432
 
433
433
  export class TokenIntrospectionEntity {
@@ -479,51 +479,51 @@ export interface UserActivityEntity {
479
479
  }
480
480
 
481
481
  export declare class UserEntity {
482
- userStatus: string;
482
+ userStatus?: string;
483
483
  user_status?: string;
484
- user_status_reason: string;
485
- username: string;
486
- sub: string;
484
+ user_status_reason?: string;
485
+ username?: string;
486
+ sub?: string;
487
487
  originalProviderUserId?: string[];
488
488
  given_name: string;
489
489
  family_name: string;
490
- middle_name: string;
491
- nickname: string;
490
+ middle_name?: string;
491
+ nickname?: string;
492
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;
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
507
  address?: AddressEntity;
508
508
  customFields?: any;
509
509
  identityCustomFields?: any;
510
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;
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
519
  mfa_enabled?: boolean;
520
520
  roles?: string[];
521
521
  groups?: IUserGroupMap[];
522
522
  userGroups?: IUserGroupMap[];
523
- trackId: string;
524
- rawJSON: string;
525
- need_reset_password: boolean;
526
- no_event: boolean;
523
+ trackId?: string;
524
+ rawJSON?: string;
525
+ need_reset_password?: boolean;
526
+ no_event?: boolean;
527
527
  consents?: IConsentField[] | IConsentTrackingEntity[];
528
528
  consent_track_ids?: string[];
529
529
  ignore_default_roles?: string[];
@@ -634,12 +634,12 @@ export class ValidateResetPasswordEntity {
634
634
  }
635
635
 
636
636
  export interface IChangePasswordEntity {
637
- sub: string;
638
- identityId: string;
637
+ sub?: string;
638
+ identityId?: string;
639
639
  old_password: string;
640
640
  new_password: string;
641
641
  confirm_password: string;
642
- accessToken: string;
642
+ accessToken?: string;
643
643
  loginSettingsId: string;
644
- client_id: string;
644
+ client_id?: string;
645
645
  }
@@ -69,7 +69,7 @@ export namespace LoginService {
69
69
  };
70
70
 
71
71
  /**
72
- * register with social
72
+ * with social
73
73
  * @param options
74
74
  * @param queryParams
75
75
  */
@@ -231,10 +231,11 @@ export namespace LoginService {
231
231
  * @param options
232
232
  */
233
233
  export function loginAfterRegister(options: {
234
- device_id: string;
234
+ device_id?: string;
235
235
  dc?: string;
236
- rememberMe: boolean;
237
- trackId: string;
236
+ rememberMe?: boolean;
237
+ trackId?: string;
238
+ device_fp?: string;
238
239
  }) {
239
240
  try {
240
241
  const url = window.webAuthSettings.authority + "/login-srv/login/handle/afterregister/" + options.trackId;
@@ -53,7 +53,7 @@ export namespace UserService {
53
53
  captcha?: string;
54
54
  acceptlanguage?: string;
55
55
  bot_captcha_response?: string;
56
- trackId: string;
56
+ trackId?: string;
57
57
  }) {
58
58
  return new Promise((resolve, reject) => {
59
59
  try {
@@ -178,9 +178,31 @@ export namespace UserService {
178
178
  export function handleResetPassword(options: ValidateResetPasswordEntity) {
179
179
  try {
180
180
  const url = window.webAuthSettings.authority + "/users-srv/resetpassword/validatecode";
181
- let form = Helper.createForm(url, options)
182
- document.body.appendChild(form);
183
- form.submit();
181
+ if (window.webAuthSettings.cidaas_version > 2) {
182
+ let form = Helper.createForm(url, options)
183
+ document.body.appendChild(form);
184
+ form.submit();
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
+ } else {
194
+ resolve(false);
195
+ }
196
+ }
197
+ };
198
+ http.open("POST", url, true);
199
+ http.setRequestHeader("Content-type", "application/json");
200
+ http.send(JSON.stringify(options));
201
+ } catch (ex) {
202
+ reject(ex);
203
+ }
204
+ });
205
+ }
184
206
  } catch (ex) {
185
207
  throw new CustomException(ex, 417);
186
208
  }
@@ -191,11 +213,33 @@ export namespace UserService {
191
213
  * @param options
192
214
  */
193
215
  export function resetPassword(options: AcceptResetPasswordEntity) {
216
+ const url = window.webAuthSettings.authority + "/users-srv/resetpassword/accept";
194
217
  try {
195
- const url = window.webAuthSettings.authority + "/users-srv/resetpassword/accept";
196
- let form = Helper.createForm(url, options)
197
- document.body.appendChild(form);
198
- form.submit();
218
+ if (window.webAuthSettings.cidaas_version > 2) {
219
+ let form = Helper.createForm(url, options)
220
+ document.body.appendChild(form);
221
+ form.submit();
222
+ } else {
223
+ return new Promise(function (resolve, reject) {
224
+ try {
225
+ var http = new XMLHttpRequest();
226
+ http.onreadystatechange = function () {
227
+ if (http.readyState == 4) {
228
+ if (http.responseText) {
229
+ resolve(JSON.parse(http.responseText));
230
+ } else {
231
+ resolve(false);
232
+ }
233
+ }
234
+ };
235
+ http.open("POST", url, true);
236
+ http.setRequestHeader("Content-type", "application/json");
237
+ http.send(JSON.stringify(options));
238
+ } catch (ex) {
239
+ reject(ex);
240
+ }
241
+ });
242
+ }
199
243
  } catch (ex) {
200
244
  throw new CustomException(ex, 417);
201
245
  }
@@ -42,7 +42,7 @@ export class WebAuth {
42
42
 
43
43
  private code_verifier: string;
44
44
 
45
- constructor(settings: UserManagerSettings & { mode?: string }) {
45
+ constructor(settings: UserManagerSettings & { mode?: string, cidaas_version: number }) {
46
46
  try {
47
47
  var usermanager = new UserManager(settings)
48
48
  window.webAuthSettings = settings;
@@ -94,7 +94,7 @@ export class WebAuth {
94
94
  }
95
95
  switch (window.webAuthSettings.mode) {
96
96
  case 'redirect':
97
- window.authentication.redirectSignIn('register');
97
+ window.authentication.redirectSignIn('login');
98
98
  break;
99
99
  case 'window':
100
100
  window.authentication.popupSignIn();
@@ -733,7 +733,7 @@ export class WebAuth {
733
733
  * @param headers
734
734
  * @returns
735
735
  */
736
- register(options: UserEntity, headers: { requestId: string; captcha?: string; acceptlanguage?: string; bot_captcha_response?: string; trackId: string; }) {
736
+ register(options: UserEntity, headers: { requestId: string; captcha?: string; acceptlanguage?: string; bot_captcha_response?: string; trackId?: string; }) {
737
737
  return UserService.register(options, headers);
738
738
  };
739
739
 
@@ -796,7 +796,7 @@ export class WebAuth {
796
796
  * @param options
797
797
  */
798
798
  handleResetPassword(options: ValidateResetPasswordEntity) {
799
- UserService.handleResetPassword(options);
799
+ return UserService.handleResetPassword(options);
800
800
  };
801
801
 
802
802
  /**
@@ -804,7 +804,7 @@ export class WebAuth {
804
804
  * @param options
805
805
  */
806
806
  resetPassword(options: AcceptResetPasswordEntity) {
807
- UserService.resetPassword(options);
807
+ return UserService.resetPassword(options);
808
808
  };
809
809
 
810
810
  /**
@@ -100,7 +100,7 @@ var WebAuth = /** @class */ (function () {
100
100
  }
101
101
  switch (window.webAuthSettings.mode) {
102
102
  case 'redirect':
103
- window.authentication.redirectSignIn('register');
103
+ window.authentication.redirectSignIn('login');
104
104
  break;
105
105
  case 'window':
106
106
  window.authentication.popupSignIn();