cidaas-javascript-sdk 2.0.2 → 2.0.6

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/README.md CHANGED
@@ -16,9 +16,9 @@ This cidaas Javascript SDK library is built on the top of [OIDC client javascrip
16
16
  From CDN
17
17
 
18
18
  ```html
19
- <!-- Release version 2.0.2 -->
19
+ <!-- Release version 2.0.6 -->
20
20
  <!-- Minified version -->
21
- <script src="https://cdn.cidaas.de/javascript/oidc/2.0.2/cidaas-javascript-sdk.min.js"></script>
21
+ <script src="https://cdn.cidaas.de/javascript/oidc/2.0.6/cidaas-javascript-sdk.min.js"></script>
22
22
  ```
23
23
 
24
24
  From npm
@@ -616,6 +616,81 @@ cidaas.changePassword({
616
616
  }
617
617
  ```
618
618
 
619
+ #### Get user profile information
620
+
621
+ To get user profile details, pass access token to ****getProfileInfo()****.
622
+
623
+ ##### Sample code
624
+
625
+ ```js
626
+ cidaas.getProfileInfo({
627
+ access_token: 'your access token'
628
+ }).then(function (response) {
629
+ // type your code here
630
+ }).catch(function (ex) {
631
+ // your failure code here
632
+ });
633
+ ```
634
+
635
+ ##### Response
636
+
637
+ ```json
638
+ {
639
+ "success": true,
640
+ "status": 200,
641
+ "data": {
642
+ "userAccount": {
643
+ "userIds": [
644
+ {
645
+ "key": "self.email",
646
+ "value": "testuser@gmail.com"
647
+ }
648
+ ],
649
+ "className": "de.cidaas.management.db.UserAccounts",
650
+ "_id": "ac45bdda-93bf-44f1-b2ff-8465495c3417",
651
+ "sub": "33361c59-368b-48e3-8739-38d7ee8f7573",
652
+ "user_status_reason": "",
653
+ "userStatus": "VERIFIED",
654
+ "customFields": {
655
+ "Test_consent_HP": true,
656
+ "customer_number": "CN456",
657
+ "invoice_number": "IN456"
658
+ },
659
+ "createdTime": "2021-05-27T07:38:29.579Z",
660
+ "updatedTime": "2021-06-24T11:02:43.188Z",
661
+ "__ref": "1624532562750-69ab9fff-2a71-4a05-8d67-6886376b51d6",
662
+ "__v": 0,
663
+ "lastLoggedInTime": "2021-06-24T11:02:43.186Z",
664
+ "lastUsedIdentity": "bbee960d-6a80-424e-99bd-586d74f1053e",
665
+ "mfa_enabled": true,
666
+ "id": "ac45bdda-93bf-44f1-b2ff-8465495c3417"
667
+ },
668
+ "identity": {
669
+ "_id": "bbee960d-6a80-424e-99bd-586d74f1053e",
670
+ "className": "de.cidaas.core.db.EnternalSocialIdentity",
671
+ "sub": "33361c59-368b-48e3-8739-38d7ee8f7573",
672
+ "provider": "self",
673
+ "email": "testuser@gmail.com",
674
+ "email_verified": true,
675
+ "family_name": "Test",
676
+ "given_name": "User",
677
+ "locale": "en-us",
678
+ "createdTime": "2021-05-27T07:38:29.908Z",
679
+ "updatedTime": "2021-06-24T11:02:43.188Z",
680
+ "__ref": "1624532562750-69ab9fff-2a71-4a05-8d67-6886376b51d6",
681
+ "__v": 0,
682
+ "birthdate": "1993-06-07T18:30:00.000Z",
683
+ "id": "bbee960d-6a80-424e-99bd-586d74f1053e"
684
+ },
685
+ "customFields": {},
686
+ "roles": [
687
+ "USER"
688
+ ],
689
+ "groups": []
690
+ }
691
+ }
692
+ ```
693
+
619
694
  #### Getting user profile
620
695
 
621
696
  To get the user profile information, call ****getUserProfile()****.
@@ -683,7 +758,46 @@ cidaas.logoutUser({
683
758
  access_token : 'your accessToken'
684
759
  });
685
760
  ```
761
+ #### Delete User Account
762
+
763
+ To delete the user account directly in the application, call **deleteUserAccount()**. This method will delete the user account with **requestId** as the **query parameter**.
764
+
765
+ This method takes an object as input.
766
+
767
+ ##### Sample code
686
768
 
769
+ ```js
770
+ options = {
771
+ sub: "7e4f79a9-cfbc-456d-936a-e6bc1de2d4b9",
772
+ requestId: "7d86460b-8288-4341-aed1- 10dd27a4565c",
773
+ accept-language: "en"
774
+ }
775
+ ```
776
+
777
+ The usage of the method is as follows.
778
+
779
+ ```js
780
+ cidaas.deleteUserAccount(options).then(function (response) {
781
+
782
+ // your success code here
783
+
784
+ }).catch(function(ex) {
785
+
786
+ // your failure code here
787
+
788
+ });
789
+ ```
790
+ #### Response
791
+
792
+ ```js
793
+ {
794
+ "success": true,
795
+ "status": 200,
796
+ "data": {
797
+ "result": true
798
+ }
799
+ }
800
+ ```
687
801
  #### Physical Verification
688
802
 
689
803
  After successful login, we can add multifactor authentications.
@@ -1891,3 +2005,4 @@ this.socket.on("status-update", (msg) => {
1891
2005
  }
1892
2006
  });
1893
2007
  ```
2008
+ F
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cidaas-javascript-sdk",
3
- "version": "2.0.2",
3
+ "version": "2.0.6",
4
4
  "author": "cidaas by Widas ID GmbH",
5
5
  "description": "Cidaas native javascript sdk",
6
6
  "license": "MIT",
@@ -137,6 +137,31 @@ WebAuth.prototype.getUserProfile = function (options) {
137
137
  });
138
138
  };
139
139
 
140
+ // get user info (internal)
141
+ WebAuth.prototype.getProfileInfo = function (access_token) {
142
+ return new Promise(function (resolve, reject) {
143
+ try {
144
+ if (!access_token) {
145
+ throw new CustomException("access_token cannot be empty", 417);
146
+ }
147
+ var http = new XMLHttpRequest();
148
+ var _serviceURL = window.webAuthSettings.authority + "/users-srv/internal/userinfo/profile";
149
+ http.onreadystatechange = function () {
150
+ if (http.readyState == 4) {
151
+ resolve(JSON.parse(http.responseText));
152
+ }
153
+ };
154
+ http.open("GET", _serviceURL, true);
155
+ http.setRequestHeader("Content-type", "application/json");
156
+ http.setRequestHeader("access_token", access_token);
157
+ http.send();
158
+ } catch (ex) {
159
+ reject(ex);
160
+ }
161
+ });
162
+ };
163
+
164
+
140
165
  // logout
141
166
  WebAuth.prototype.logout = function () {
142
167
  return new Promise(function (resolve, reject) {
@@ -208,7 +233,11 @@ function createPostPromise(options, serviceurl, errorResolver, access_token) {
208
233
  if (access_token) {
209
234
  http.setRequestHeader("access_token", access_token);
210
235
  }
211
- http.send(JSON.stringify(options));
236
+ if (options) {
237
+ http.send(JSON.stringify(options));
238
+ } else {
239
+ http.send();
240
+ }
212
241
  } catch (ex) {
213
242
  reject(ex);
214
243
  }
@@ -614,6 +643,9 @@ WebAuth.prototype.getCommunicationStatus = function (options) {
614
643
  };
615
644
  http.open("GET", _serviceURL, true);
616
645
  http.setRequestHeader("Content-type", "application/json");
646
+ if (options.requestId) {
647
+ http.setRequestHeader("requestId", options.requestId);
648
+ }
617
649
  http.send();
618
650
  } catch (ex) {
619
651
  reject(ex);
@@ -1045,6 +1077,31 @@ WebAuth.prototype.getScopeConsentDetails = function (options) {
1045
1077
  });
1046
1078
  };
1047
1079
 
1080
+ // get scope consent version details
1081
+ WebAuth.prototype.getScopeConsentVersionDetailsV2 = function (options) {
1082
+ return new Promise(function (resolve, reject) {
1083
+ try {
1084
+ var http = new XMLHttpRequest();
1085
+ var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/v2/consent/versions/details/" + options.scopeid + "?locale=" + options.locale;
1086
+ http.onreadystatechange = function () {
1087
+ if (http.readyState == 4) {
1088
+ if (http.responseText) {
1089
+ resolve(JSON.parse(http.responseText));
1090
+ } else {
1091
+ resolve(false);
1092
+ }
1093
+ }
1094
+ };
1095
+ http.open("GET", _serviceURL, true);
1096
+ http.setRequestHeader("Content-type", "application/json");
1097
+ http.setRequestHeader("Authorization", "Bearer " + options.access_token);
1098
+ http.send();
1099
+ } catch (ex) {
1100
+ reject(ex);
1101
+ }
1102
+ });
1103
+ };
1104
+
1048
1105
  // accept scope Consent
1049
1106
  WebAuth.prototype.acceptScopeConsent = function (options) {
1050
1107
  var _serviceURL = window.webAuthSettings.authority + "/consent-management-srv/consent/scope/accept";
@@ -1492,7 +1549,7 @@ WebAuth.prototype.enrollVerification = function (options) {
1492
1549
  // updateSocket
1493
1550
  WebAuth.prototype.updateSocket = function (status_id) {
1494
1551
  var _serviceURL = window.webAuthSettings.authority + "/verification-srv/v2/notification/status/" + status_id;
1495
- return createPostPromise(options, _serviceURL, undefined);
1552
+ return createPostPromise(undefined, _serviceURL, undefined);
1496
1553
  };
1497
1554
 
1498
1555
  // setupFidoVerification