cidaas-javascript-sdk 2.0.10 → 2.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.
package/.prettierrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "printWidth": 120,
3
+ "trailingComma": "all",
4
+ "singleQuote": true,
5
+ "tabWidth": 4
6
+ }
package/README.md CHANGED
@@ -1818,7 +1818,56 @@ this.cidaas.consentContinue({
1818
1818
  sub: 'your sub',
1819
1819
  });
1820
1820
  ```
1821
+ ##### Accept claim
1821
1822
 
1823
+ To accept Claim Consent, call ****acceptClaimConsent()****
1824
+
1825
+ ##### Sample code
1826
+ ```js
1827
+ this.cidaas.acceptClaimConsent({
1828
+ q: 'your sub',
1829
+ client_id: 'your client id',
1830
+ accepted: "accepted claims with array eg: []"
1831
+ }).then((response) => {
1832
+ // type your code here
1833
+ }).catch((err) => {
1834
+ // your failure code here
1835
+ });
1836
+ ```
1837
+
1838
+ ##### Response
1839
+ ```json
1840
+ {
1841
+ "success":true,
1842
+ "status":200,
1843
+ "data": true
1844
+ }
1845
+ ```
1846
+
1847
+ ##### Revoke claim
1848
+
1849
+ To revoke Claim Consent, call ****revokeClaimConsent()****
1850
+
1851
+ ##### Sample code
1852
+ ```js
1853
+ this.cidaas.revokeClaimConsent({
1854
+ sub: 'your sub',
1855
+ revoked_claims: "revoked claims with array eg: []"
1856
+ }).then((response) => {
1857
+ // type your code here
1858
+ }).catch((err) => {
1859
+ // your failure code here
1860
+ });
1861
+ ```
1862
+
1863
+ ##### Response
1864
+ ```json
1865
+ {
1866
+ "success":true,
1867
+ "status":200,
1868
+ "data": true
1869
+ }
1870
+ ```
1822
1871
  #### Deduplication
1823
1872
 
1824
1873
  ##### Get deduplication details
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cidaas-javascript-sdk",
3
- "version": "2.0.10",
3
+ "version": "2.1.1",
4
4
  "author": "cidaas by Widas ID GmbH",
5
5
  "description": "Cidaas native javascript sdk",
6
6
  "license": "MIT",
@@ -17,23 +17,23 @@
17
17
  "build-types": "npx -p typescript tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir types"
18
18
  },
19
19
  "dependencies": {
20
- "crypto-js": "^3.1.9-1",
20
+ "crypto-js": "^4.1.1",
21
21
  "oidc-client": "^1.11.5"
22
22
  },
23
23
  "devDependencies": {
24
- "compression-webpack-plugin": "^7.1.2",
25
- "jest": "26.6.3",
26
- "terser-webpack-plugin": "^5.1.1",
24
+ "compression-webpack-plugin": "^9.0.0",
25
+ "jest": "27.3.1",
26
+ "terser-webpack-plugin": "^5.2.4",
27
27
  "typescript": "^4.5.4",
28
- "webpack": "^5.27.2",
29
- "webpack-cli": "^4.5.0",
30
- "webpack-dev-server": "^3.11.2",
31
- "webpack-hot-middleware": "^2.25.0",
32
- "webpack-merge": "^5.7.3"
28
+ "webpack": "^5.59.1",
29
+ "webpack-cli": "^4.9.1",
30
+ "webpack-dev-server": "^4.3.1",
31
+ "webpack-hot-middleware": "^2.25.1",
32
+ "webpack-merge": "^5.8.0"
33
33
  },
34
34
  "jest": {
35
35
  "collectCoverageFrom": [
36
36
  "src/main/**/*.{js,jsx,mjs}"
37
37
  ]
38
38
  }
39
- }
39
+ }
@@ -10,6 +10,7 @@ function WebAuth(settings) {
10
10
  var usermanager = new Oidc.UserManager(settings);
11
11
  window.webAuthSettings = settings;
12
12
  window.usermanager = usermanager;
13
+ window.localeSettings = null;
13
14
  window.authentication = new Authentication(window.webAuthSettings, window.usermanager);
14
15
  window.usermanager.events.addSilentRenewError(function (error) {
15
16
  throw new CustomException("Error while renewing silent login", 500);
@@ -134,6 +135,9 @@ WebAuth.prototype.getUserProfile = function (options) {
134
135
  http.open("GET", _serviceURL, true);
135
136
  http.setRequestHeader("Content-type", "application/json");
136
137
  http.setRequestHeader("access_token", options.access_token);
138
+ if (window.localeSettings) {
139
+ http.setRequestHeader("accept-language", window.localeSettings);
140
+ }
137
141
  http.send();
138
142
  } catch (ex) {
139
143
  reject(ex);
@@ -158,6 +162,9 @@ WebAuth.prototype.getProfileInfo = function (access_token) {
158
162
  http.open("GET", _serviceURL, true);
159
163
  http.setRequestHeader("Content-type", "application/json");
160
164
  http.setRequestHeader("access_token", access_token);
165
+ if (window.localeSettings) {
166
+ http.setRequestHeader("accept-language", window.localeSettings);
167
+ }
161
168
  http.send();
162
169
  } catch (ex) {
163
170
  reject(ex);
@@ -237,6 +244,9 @@ function createPostPromise(options, serviceurl, errorResolver, access_token) {
237
244
  if (access_token) {
238
245
  http.setRequestHeader("access_token", access_token);
239
246
  }
247
+ if (window.localeSettings) {
248
+ http.setRequestHeader("accept-language", window.localeSettings);
249
+ }
240
250
  if (options) {
241
251
  http.send(JSON.stringify(options));
242
252
  } else {
@@ -265,6 +275,9 @@ WebAuth.prototype.renewToken = function (options) {
265
275
  };
266
276
  http.open("POST", _serviceURL, true);
267
277
  http.setRequestHeader("Content-type", "application/json");
278
+ if (window.localeSettings) {
279
+ http.setRequestHeader("accept-language", window.localeSettings);
280
+ }
268
281
  http.send(JSON.stringify(options));
269
282
  } catch (ex) {
270
283
  reject(ex);
@@ -339,6 +352,9 @@ WebAuth.prototype.getAccessToken = function (options) {
339
352
  };
340
353
  http.open("POST", _serviceURL, true);
341
354
  http.setRequestHeader("Content-type", "application/json");
355
+ if (window.localeSettings) {
356
+ http.setRequestHeader("accept-language", window.localeSettings);
357
+ }
342
358
  http.send(JSON.stringify(options));
343
359
  } catch (ex) {
344
360
  reject(ex);
@@ -362,6 +378,9 @@ WebAuth.prototype.validateAccessToken = function (options) {
362
378
  };
363
379
  http.open("POST", _serviceURL, true);
364
380
  http.setRequestHeader("Content-type", "application/json");
381
+ if (window.localeSettings) {
382
+ http.setRequestHeader("accept-language", window.localeSettings);
383
+ }
365
384
  http.send(JSON.stringify(options));
366
385
  } catch (ex) {
367
386
  reject(ex);
@@ -403,6 +422,9 @@ WebAuth.prototype.getRequestId = function () {
403
422
  };
404
423
  http.open("POST", _serviceURL, true);
405
424
  http.setRequestHeader("Content-type", "application/json");
425
+ if (window.localeSettings) {
426
+ http.setRequestHeader("accept-language", window.localeSettings);
427
+ }
406
428
  http.send(JSON.stringify(bodyParams));
407
429
  } catch (ex) {
408
430
  reject(ex);
@@ -428,6 +450,29 @@ WebAuth.prototype.loginWithCredentials = function (options) {
428
450
  }
429
451
  document.body.appendChild(form);
430
452
  form.submit();
453
+
454
+ } catch (ex) {
455
+ throw new CustomException(ex, 417);
456
+ }
457
+ };
458
+
459
+ // login with username and password and return response
460
+ WebAuth.prototype.loginWithCredentialsAsynFn = async function (options) {
461
+ try {
462
+
463
+ const searchParams = new URLSearchParams(options);
464
+
465
+ const response = fetch(window.webAuthSettings.authority + "/login-srv/login", {
466
+ method: "POST",
467
+ redirect: "follow",
468
+ body: searchParams.toString(),
469
+ headers: {
470
+ "Content-Type": "application/x-www-form-urlencoded",
471
+ }
472
+ });
473
+
474
+ return response;
475
+
431
476
  } catch (ex) {
432
477
  throw new CustomException(ex, 417);
433
478
  }
@@ -476,6 +521,9 @@ WebAuth.prototype.getMissingFields = function (options) {
476
521
  };
477
522
  http.open("GET", _serviceURL, true);
478
523
  http.setRequestHeader("Content-type", "application/json");
524
+ if (window.localeSettings) {
525
+ http.setRequestHeader("accept-language", window.localeSettings);
526
+ }
479
527
  http.send();
480
528
  } catch (ex) {
481
529
  reject(ex);
@@ -500,6 +548,9 @@ WebAuth.prototype.getTenantInfo = function () {
500
548
  };
501
549
  http.open("GET", _serviceURL, true);
502
550
  http.setRequestHeader("Content-type", "application/json");
551
+ if (window.localeSettings) {
552
+ http.setRequestHeader("accept-language", window.localeSettings);
553
+ }
503
554
  http.send();
504
555
  } catch (ex) {
505
556
  reject(ex);
@@ -533,6 +584,9 @@ WebAuth.prototype.getClientInfo = function (options) {
533
584
  };
534
585
  http.open("GET", _serviceURL, true);
535
586
  http.setRequestHeader("Content-type", "application/json");
587
+ if (window.localeSettings) {
588
+ http.setRequestHeader("accept-language", window.localeSettings);
589
+ }
536
590
  http.send();
537
591
  } catch (ex) {
538
592
  reject(ex);
@@ -561,6 +615,9 @@ WebAuth.prototype.getRegistrationSetup = function (options) {
561
615
  };
562
616
  http.open("GET", _serviceURL, true);
563
617
  http.setRequestHeader("Content-type", "application/json");
618
+ if (window.localeSettings) {
619
+ http.setRequestHeader("accept-language", window.localeSettings);
620
+ }
564
621
  http.send();
565
622
  } catch (ex) {
566
623
  reject(ex);
@@ -595,6 +652,8 @@ WebAuth.prototype.register = function (options, headers) {
595
652
  }
596
653
  if (headers.acceptlanguage) {
597
654
  http.setRequestHeader("accept-language", headers.acceptlanguage);
655
+ } else if (window.localeSettings) {
656
+ http.setRequestHeader("accept-language", window.localeSettings);
598
657
  }
599
658
  if (headers.bot_captcha_response) {
600
659
  http.setRequestHeader("bot_captcha_response", headers.bot_captcha_response);
@@ -627,6 +686,9 @@ WebAuth.prototype.getInviteUserDetails = function (options) {
627
686
  };
628
687
  http.open("GET", _serviceURL, true);
629
688
  http.setRequestHeader("Content-type", "application/json");
689
+ if (window.localeSettings) {
690
+ http.setRequestHeader("accept-language", window.localeSettings);
691
+ }
630
692
  http.send();
631
693
  } catch (ex) {
632
694
  reject(ex);
@@ -654,6 +716,9 @@ WebAuth.prototype.getCommunicationStatus = function (options) {
654
716
  if (options.requestId) {
655
717
  http.setRequestHeader("requestId", options.requestId);
656
718
  }
719
+ if (window.localeSettings) {
720
+ http.setRequestHeader("accept-language", window.localeSettings);
721
+ }
657
722
  http.send();
658
723
  } catch (ex) {
659
724
  reject(ex);
@@ -684,6 +749,29 @@ WebAuth.prototype.initiateAccountVerification = function (options) {
684
749
  }
685
750
  };
686
751
 
752
+ // initiate verification and return response
753
+ WebAuth.prototype.initiateAccountVerificationAsynFn = async function (options) {
754
+ try {
755
+
756
+ const searchParams = new URLSearchParams(options);
757
+
758
+ const response = fetch(window.webAuthSettings.authority + "/verification-srv/account/initiate", {
759
+ method: "POST",
760
+ redirect: "follow",
761
+ body: searchParams.toString(),
762
+ headers: {
763
+ "Content-Type": "application/x-www-form-urlencoded",
764
+ }
765
+ });
766
+
767
+ return response;
768
+
769
+ } catch (ex) {
770
+ throw new CustomException(ex, 417);
771
+ }
772
+
773
+ };
774
+
687
775
  // verofy account
688
776
  WebAuth.prototype.verifyAccount = function (options) {
689
777
  var _serviceURL = window.webAuthSettings.authority + "/verification-srv/account/verify";
@@ -769,6 +857,9 @@ WebAuth.prototype.getMFAList = function (options) {
769
857
  };
770
858
  http.open("GET", _serviceURL, true);
771
859
  http.setRequestHeader("Content-type", "application/json");
860
+ if (window.localeSettings) {
861
+ http.setRequestHeader("accept-language", window.localeSettings);
862
+ }
772
863
  http.send();
773
864
  } catch (ex) {
774
865
  reject(ex);
@@ -1037,6 +1128,9 @@ WebAuth.prototype.getConsentDetails = function (options) {
1037
1128
  };
1038
1129
  http.open("GET", _serviceURL, true);
1039
1130
  http.setRequestHeader("Content-type", "application/json");
1131
+ if (window.localeSettings) {
1132
+ http.setRequestHeader("accept-language", window.localeSettings);
1133
+ }
1040
1134
  http.send();
1041
1135
  } catch (ex) {
1042
1136
  reject(ex);
@@ -1078,6 +1172,9 @@ WebAuth.prototype.getScopeConsentDetails = function (options) {
1078
1172
  };
1079
1173
  http.open("GET", _serviceURL, true);
1080
1174
  http.setRequestHeader("Content-type", "application/json");
1175
+ if (window.localeSettings) {
1176
+ http.setRequestHeader("accept-language", window.localeSettings);
1177
+ }
1081
1178
  http.send();
1082
1179
  } catch (ex) {
1083
1180
  reject(ex);
@@ -1103,6 +1200,9 @@ WebAuth.prototype.getScopeConsentVersionDetailsV2 = function (options) {
1103
1200
  http.open("GET", _serviceURL, true);
1104
1201
  http.setRequestHeader("Content-type", "application/json");
1105
1202
  http.setRequestHeader("Authorization", "Bearer " + options.access_token);
1203
+ if (window.localeSettings) {
1204
+ http.setRequestHeader("accept-language", window.localeSettings);
1205
+ }
1106
1206
  http.send();
1107
1207
  } catch (ex) {
1108
1208
  reject(ex);
@@ -1148,6 +1248,12 @@ WebAuth.prototype.claimConsentContinue = function (options) {
1148
1248
  }
1149
1249
  };
1150
1250
 
1251
+ // revoke claim Consent
1252
+ WebAuth.prototype.revokeClaimConsent = function (options) {
1253
+ var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/claim/revoke";
1254
+ return createPostPromise(options, _serviceURL, false);
1255
+ };
1256
+
1151
1257
 
1152
1258
  // get Deduplication details
1153
1259
  WebAuth.prototype.getDeduplicationDetails = function (options) {
@@ -1166,6 +1272,9 @@ WebAuth.prototype.getDeduplicationDetails = function (options) {
1166
1272
  };
1167
1273
  http.open("GET", _serviceURL, true);
1168
1274
  http.setRequestHeader("Content-type", "application/json");
1275
+ if (window.localeSettings) {
1276
+ http.setRequestHeader("accept-language", window.localeSettings);
1277
+ }
1169
1278
  http.send();
1170
1279
  } catch (ex) {
1171
1280
  reject(ex);
@@ -1199,6 +1308,9 @@ WebAuth.prototype.registerDeduplication = function (options) {
1199
1308
  };
1200
1309
  http.open("POST", _serviceURL, true);
1201
1310
  http.setRequestHeader("Content-type", "application/json");
1311
+ if (window.localeSettings) {
1312
+ http.setRequestHeader("accept-language", window.localeSettings);
1313
+ }
1202
1314
  http.send();
1203
1315
  } catch (ex) {
1204
1316
  reject(ex);
@@ -1301,6 +1413,9 @@ WebAuth.prototype.updateProfile = function (options, access_token, sub) {
1301
1413
  http.open("PUT", _serviceURL, true);
1302
1414
  http.setRequestHeader("Content-type", "application/json");
1303
1415
  http.setRequestHeader("access_token", access_token);
1416
+ if (window.localeSettings) {
1417
+ http.setRequestHeader("accept-language", window.localeSettings);
1418
+ }
1304
1419
  http.send(JSON.stringify(options));
1305
1420
  } catch (ex) {
1306
1421
  throw new CustomException(ex, 417);
@@ -1332,6 +1447,9 @@ WebAuth.prototype.getUnreviewedDevices = function (access_token, sub) {
1332
1447
  http.open("GET", _serviceURL, true);
1333
1448
  http.setRequestHeader("Content-type", "application/json");
1334
1449
  http.setRequestHeader("access_token", access_token);
1450
+ if (window.localeSettings) {
1451
+ http.setRequestHeader("accept-language", window.localeSettings);
1452
+ }
1335
1453
  http.send();
1336
1454
  } catch (ex) {
1337
1455
  throw new CustomException(ex, 417);
@@ -1357,6 +1475,9 @@ WebAuth.prototype.getReviewedDevices = function (access_token, sub) {
1357
1475
  http.open("GET", _serviceURL, true);
1358
1476
  http.setRequestHeader("Content-type", "application/json");
1359
1477
  http.setRequestHeader("access_token", access_token);
1478
+ if (window.localeSettings) {
1479
+ http.setRequestHeader("accept-language", window.localeSettings);
1480
+ }
1360
1481
  http.send();
1361
1482
  } catch (ex) {
1362
1483
  throw new CustomException(ex, 417);
@@ -1382,6 +1503,9 @@ WebAuth.prototype.reviewDevice = function (options, access_token, sub) {
1382
1503
  http.open("PUT", _serviceURL, true);
1383
1504
  http.setRequestHeader("Content-type", "application/json");
1384
1505
  http.setRequestHeader("access_token", access_token);
1506
+ if (window.localeSettings) {
1507
+ http.setRequestHeader("accept-language", window.localeSettings);
1508
+ }
1385
1509
  http.send(JSON.stringify(options));
1386
1510
  } catch (ex) {
1387
1511
  throw new CustomException(ex, 417);
@@ -1413,6 +1537,9 @@ WebAuth.prototype.viewAcceptedConsent = function (options, access_token) {
1413
1537
  http.open("GET", _serviceURL, true);
1414
1538
  http.setRequestHeader("Content-type", "application/json");
1415
1539
  http.setRequestHeader("access_token", access_token);
1540
+ if (window.localeSettings) {
1541
+ http.setRequestHeader("accept-language", window.localeSettings);
1542
+ }
1416
1543
  http.send();
1417
1544
  } catch (ex) {
1418
1545
  throw new CustomException(ex, 417);
@@ -1615,6 +1742,9 @@ WebAuth.prototype.authenticateFaceVerification = function (options) {
1615
1742
  };
1616
1743
  http.open("POST", _serviceURL, true);
1617
1744
  http.setRequestHeader("Content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
1745
+ if (window.localeSettings) {
1746
+ http.setRequestHeader("accept-language", window.localeSettings);
1747
+ }
1618
1748
  http.send(JSON.stringify(options));
1619
1749
  } catch (ex) {
1620
1750
  reject(ex);
@@ -1651,6 +1781,9 @@ WebAuth.prototype.getMissingFieldsLogin = function (trackId) {
1651
1781
  };
1652
1782
  http.open("GET", _serviceURL, true);
1653
1783
  http.setRequestHeader("Content-type", "application/json");
1784
+ if (window.localeSettings) {
1785
+ http.setRequestHeader("accept-language", window.localeSettings);
1786
+ }
1654
1787
  http.send();
1655
1788
  } catch (ex) {
1656
1789
  reject(ex);
@@ -1679,6 +1812,8 @@ WebAuth.prototype.progressiveRegistration = function (options, headers) {
1679
1812
  http.setRequestHeader("trackId", headers.trackId);
1680
1813
  if (headers.acceptlanguage) {
1681
1814
  http.setRequestHeader("accept-language", headers.acceptlanguage);
1815
+ } else if (window.localeSettings) {
1816
+ http.setRequestHeader("accept-language", window.localeSettings);
1682
1817
  }
1683
1818
  http.send(JSON.stringify(options));
1684
1819
  } catch (ex) {
@@ -1715,4 +1850,8 @@ WebAuth.prototype.userCheckExists = function (options) {
1715
1850
  return createPostPromise(options, _serviceURL, undefined);
1716
1851
  };
1717
1852
 
1853
+ WebAuth.prototype.setAcceptLanguageHeader = function (acceptLanguage) {
1854
+ window.localeSettings = acceptLanguage;
1855
+ }
1856
+
1718
1857
  module.exports = WebAuth;
@@ -20,6 +20,7 @@ declare class WebAuth {
20
20
  validateAccessToken(options: any): Promise<any>;
21
21
  getRequestId(): Promise<any>;
22
22
  loginWithCredentials(options: any): void;
23
+ loginWithCredentialsAsynFn(options: any): Promise<Response>;
23
24
  loginWithSocial(options: any, queryParams: any): void;
24
25
  registerWithSocial(options: any, queryParams: any): void;
25
26
  getMissingFields(options: any): Promise<any>;
@@ -31,6 +32,7 @@ declare class WebAuth {
31
32
  getInviteUserDetails(options: any): Promise<any>;
32
33
  getCommunicationStatus(options: any): Promise<any>;
33
34
  initiateAccountVerification(options: any): void;
35
+ initiateAccountVerificationAsynFn(options: any): Promise<Response>;
34
36
  verifyAccount(options: any): Promise<any>;
35
37
  initiateResetPassword(options: any): Promise<any>;
36
38
  handleResetPassword(options: any): void;
@@ -81,6 +83,7 @@ declare class WebAuth {
81
83
  scopeConsentContinue(options: any): void;
82
84
  acceptClaimConsent(options: any): Promise<any>;
83
85
  claimConsentContinue(options: any): void;
86
+ revokeClaimConsent(options: any): Promise<any>;
84
87
  getDeduplicationDetails(options: any): Promise<any>;
85
88
  deduplicationLogin(options: any): void;
86
89
  registerDeduplication(options: any): Promise<any>;
@@ -129,4 +132,5 @@ declare class WebAuth {
129
132
  progressiveRegistration(options: any, headers: any): Promise<any>;
130
133
  loginAfterRegister(options: any): void;
131
134
  userCheckExists(options: any): Promise<any>;
135
+ setAcceptLanguageHeader(acceptLanguage: any): void;
132
136
  }