cidaas-javascript-sdk 3.1.5 → 4.0.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/CHANGELOG.md +54 -2
- package/README.md +96 -2508
- package/dist/authentication/index.d.ts +90 -26
- package/dist/authentication/index.js +117 -56
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist/web-auth/ConsentService.d.ts +87 -23
- package/dist/web-auth/ConsentService.js +95 -32
- package/dist/web-auth/Entities.d.ts +22 -39
- package/dist/web-auth/Helper.d.ts +1 -1
- package/dist/web-auth/Helper.js +20 -5
- package/dist/web-auth/JwtHelper.d.ts +7 -0
- package/dist/web-auth/JwtHelper.js +90 -0
- package/dist/web-auth/LoginService.d.ts +99 -58
- package/dist/web-auth/LoginService.js +100 -128
- package/dist/web-auth/TokenService.d.ts +120 -25
- package/dist/web-auth/TokenService.js +161 -36
- package/dist/web-auth/UserService.d.ts +260 -62
- package/dist/web-auth/UserService.js +304 -153
- package/dist/web-auth/VerificationService.d.ts +198 -99
- package/dist/web-auth/VerificationService.js +204 -177
- package/dist/web-auth/WebAuth.d.ts +219 -454
- package/dist/web-auth/WebAuth.js +370 -904
- package/package.json +2 -4
|
@@ -5,143 +5,158 @@ var Helper_1 = require("./Helper");
|
|
|
5
5
|
var UserService;
|
|
6
6
|
(function (UserService) {
|
|
7
7
|
/**
|
|
8
|
-
* get user
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
8
|
+
* To get the user profile information by using cidaas internal api, call **getUserProfile()**.
|
|
9
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/2zfvjx3vtq6g6-get-user-info for more details.
|
|
10
|
+
* @example
|
|
11
|
+
* ```js
|
|
12
|
+
* const options = {
|
|
13
|
+
* access_token: 'your access token'
|
|
14
|
+
* }
|
|
15
|
+
* cidaas.getUserProfile(options)
|
|
16
|
+
* .then(function () {
|
|
17
|
+
* // the response will give you user profile information.
|
|
18
|
+
* }).catch(function (ex) {
|
|
19
|
+
* // your failure code here
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
11
22
|
*/
|
|
12
23
|
function getUserProfile(options) {
|
|
13
24
|
if (!options.access_token) {
|
|
14
25
|
throw new Helper_1.CustomException("access_token cannot be empty", 417);
|
|
15
26
|
}
|
|
16
27
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo";
|
|
17
|
-
return Helper_1.Helper.
|
|
28
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, undefined, "GET", options.access_token);
|
|
18
29
|
}
|
|
19
30
|
UserService.getUserProfile = getUserProfile;
|
|
20
31
|
;
|
|
21
32
|
/**
|
|
22
|
-
* register user
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
33
|
+
* To register user, call **register()**. This method will create a new user.
|
|
34
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/427632e587203-register-a-new-user for more details.
|
|
35
|
+
* Note: Only requestId in the headers is required.
|
|
36
|
+
* @example
|
|
37
|
+
* ```js
|
|
38
|
+
* const headers = {
|
|
39
|
+
* requestId: 'your_received_requestId',
|
|
40
|
+
* captcha: 'captcha',
|
|
41
|
+
* acceptlanguage: 'acceptlanguage',
|
|
42
|
+
* bot_captcha_response: 'bot_captcha_response'
|
|
43
|
+
* };
|
|
44
|
+
*
|
|
45
|
+
* cidaas.register({
|
|
46
|
+
* email: 'xxx123@xxx.com',
|
|
47
|
+
* given_name: 'xxxxx',
|
|
48
|
+
* family_name: 'yyyyy',
|
|
49
|
+
* password: '123456',
|
|
50
|
+
* password_echo: '123456',
|
|
51
|
+
* provider: 'your provider', // FACEBOOK, GOOGLE, SELF
|
|
52
|
+
* acceptlanguage: 'your locale' // optional example: de-de, en-US
|
|
53
|
+
* }, headers).then(function (response) {
|
|
54
|
+
* // the response will give you client registration details.
|
|
55
|
+
* }).catch(function(ex) {
|
|
56
|
+
* // your failure code here
|
|
57
|
+
* });
|
|
58
|
+
*```
|
|
26
59
|
*/
|
|
27
60
|
function register(options, headers) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_serviceURL = _serviceURL + "?invite_id=" + options.invite_id;
|
|
34
|
-
}
|
|
35
|
-
http.onreadystatechange = function () {
|
|
36
|
-
if (http.readyState == 4) {
|
|
37
|
-
if (http.responseText) {
|
|
38
|
-
resolve(JSON.parse(http.responseText));
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
resolve(false);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
http.open("POST", _serviceURL, true);
|
|
46
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
47
|
-
http.setRequestHeader("requestId", headers.requestId);
|
|
48
|
-
if (headers.captcha) {
|
|
49
|
-
http.setRequestHeader("captcha", headers.captcha);
|
|
50
|
-
}
|
|
51
|
-
if (headers.acceptlanguage) {
|
|
52
|
-
http.setRequestHeader("accept-language", headers.acceptlanguage);
|
|
53
|
-
}
|
|
54
|
-
else if (window.localeSettings) {
|
|
55
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
56
|
-
}
|
|
57
|
-
if (headers.bot_captcha_response) {
|
|
58
|
-
http.setRequestHeader("bot_captcha_response", headers.bot_captcha_response);
|
|
59
|
-
}
|
|
60
|
-
if (headers.trackId) {
|
|
61
|
-
http.setRequestHeader("trackid", headers.trackId);
|
|
62
|
-
}
|
|
63
|
-
http.send(JSON.stringify(options));
|
|
64
|
-
}
|
|
65
|
-
catch (ex) {
|
|
66
|
-
reject(ex);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
61
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/register";
|
|
62
|
+
if (options.invite_id) {
|
|
63
|
+
_serviceURL = _serviceURL + "?invite_id=" + options.invite_id;
|
|
64
|
+
}
|
|
65
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", undefined, headers);
|
|
69
66
|
}
|
|
70
67
|
UserService.register = register;
|
|
71
68
|
;
|
|
72
69
|
/**
|
|
73
|
-
* get
|
|
74
|
-
* @
|
|
75
|
-
*
|
|
70
|
+
* to get information about invitation details, call **getInviteUserDetails()**
|
|
71
|
+
* @example
|
|
72
|
+
* ```js
|
|
73
|
+
* const options = {
|
|
74
|
+
* invite_id: 'id of user invitation'
|
|
75
|
+
* }
|
|
76
|
+
* cidaas.getInviteUserDetails(options)
|
|
77
|
+
* .then(function () {
|
|
78
|
+
* // the response will give you information about the invitation.
|
|
79
|
+
* }).catch(function (ex) {
|
|
80
|
+
* // your failure code here
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
76
83
|
*/
|
|
77
84
|
function getInviteUserDetails(options) {
|
|
78
85
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/invite/info/" + options.invite_id;
|
|
79
|
-
return Helper_1.Helper.
|
|
86
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
|
|
80
87
|
}
|
|
81
88
|
UserService.getInviteUserDetails = getInviteUserDetails;
|
|
82
89
|
;
|
|
83
90
|
/**
|
|
84
|
-
* get
|
|
85
|
-
* @
|
|
86
|
-
*
|
|
91
|
+
* Once registration successful, verify the account based on the flow. To get the details, call **getCommunicationStatus()**.
|
|
92
|
+
* @example
|
|
93
|
+
* ```js
|
|
94
|
+
* cidaas.getCommunicationStatus({
|
|
95
|
+
* sub: 'your sub', // which you will get on the registration response
|
|
96
|
+
* }).then(function (response) {
|
|
97
|
+
* // the response will give you account details once its verified.
|
|
98
|
+
* }).catch(function(ex) {
|
|
99
|
+
* // your failure code here
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
87
102
|
*/
|
|
88
|
-
function getCommunicationStatus(options) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var http = new XMLHttpRequest();
|
|
92
|
-
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/communication/status/" + options.sub;
|
|
93
|
-
http.onreadystatechange = function () {
|
|
94
|
-
if (http.readyState == 4) {
|
|
95
|
-
if (http.responseText) {
|
|
96
|
-
resolve(JSON.parse(http.responseText));
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
resolve(false);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
http.open("GET", _serviceURL, true);
|
|
104
|
-
http.setRequestHeader("Content-type", "application/json");
|
|
105
|
-
if (options.requestId) {
|
|
106
|
-
http.setRequestHeader("requestId", options.requestId);
|
|
107
|
-
}
|
|
108
|
-
if (window.localeSettings) {
|
|
109
|
-
http.setRequestHeader("accept-language", window.localeSettings);
|
|
110
|
-
}
|
|
111
|
-
http.send();
|
|
112
|
-
}
|
|
113
|
-
catch (ex) {
|
|
114
|
-
reject(ex);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
103
|
+
function getCommunicationStatus(options, headers) {
|
|
104
|
+
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/communication/status/" + options.sub;
|
|
105
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET", undefined, headers);
|
|
117
106
|
}
|
|
118
107
|
UserService.getCommunicationStatus = getCommunicationStatus;
|
|
119
108
|
;
|
|
120
109
|
/**
|
|
121
|
-
* initiate
|
|
122
|
-
*
|
|
123
|
-
* @
|
|
110
|
+
* To initiate the password resetting, call **initiateResetPassword()**. This will send verification code to your email or mobile based on the resetMedium you mentioned.
|
|
111
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/6b29bac6002f4-initiate-password-reset for more details.
|
|
112
|
+
* @example
|
|
113
|
+
* ```js
|
|
114
|
+
* cidaas.initiateResetPassword({
|
|
115
|
+
* email: 'xxxxxx@xxx.com',
|
|
116
|
+
* processingType: 'CODE',
|
|
117
|
+
* requestId: 'your requestId',
|
|
118
|
+
* resetMedium: 'email'
|
|
119
|
+
* }).then(function (response) {
|
|
120
|
+
* // the response will give you password reset details.
|
|
121
|
+
* }).catch(function(ex) {
|
|
122
|
+
* // your failure code here
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
124
125
|
*/
|
|
125
126
|
function initiateResetPassword(options) {
|
|
126
127
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/resetpassword/initiate";
|
|
127
|
-
return Helper_1.Helper.
|
|
128
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST");
|
|
128
129
|
}
|
|
129
130
|
UserService.initiateResetPassword = initiateResetPassword;
|
|
130
131
|
;
|
|
131
132
|
/**
|
|
132
|
-
* handle reset password
|
|
133
|
-
*
|
|
133
|
+
* To handle the reset password by entering the verification code you received, call **handleResetPassword()**. This will check if your verification code was valid or not, and allows you to proceed to the next step.
|
|
134
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/3t8ztokeb7cfz-handle-reset-password for more details.
|
|
135
|
+
* @example
|
|
136
|
+
* ```js
|
|
137
|
+
* const handleResponseAsJson = 'true if the response need to be handled the old way (as json). In the current handling, the response information will be given as query parameter in redirect url.';
|
|
138
|
+
* cidaas.handleResetPassword({
|
|
139
|
+
* code: 'your code in email or sms or ivr',
|
|
140
|
+
* resetRequestId: 'your resetRequestId' // which you will get on initiate reset password response
|
|
141
|
+
* }, handleResponseAsJson).then(function (response) {
|
|
142
|
+
* // the response will give you valid verification code.
|
|
143
|
+
* }).catch(function(ex) {
|
|
144
|
+
* // your failure code here
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
134
147
|
*/
|
|
135
|
-
function handleResetPassword(options) {
|
|
148
|
+
function handleResetPassword(options, handleResponseAsJson) {
|
|
136
149
|
try {
|
|
137
150
|
var url = window.webAuthSettings.authority + "/users-srv/resetpassword/validatecode";
|
|
138
|
-
if (
|
|
151
|
+
if (!handleResponseAsJson) {
|
|
152
|
+
// current handling will redirect and give query parameters
|
|
139
153
|
var form = Helper_1.Helper.createForm(url, options);
|
|
140
154
|
document.body.appendChild(form);
|
|
141
155
|
form.submit();
|
|
142
156
|
}
|
|
143
157
|
else {
|
|
144
|
-
|
|
158
|
+
// older cidaas service handling return json object
|
|
159
|
+
return Helper_1.Helper.createHttpPromise(options, url, false, "POST");
|
|
145
160
|
}
|
|
146
161
|
}
|
|
147
162
|
catch (ex) {
|
|
@@ -151,19 +166,35 @@ var UserService;
|
|
|
151
166
|
UserService.handleResetPassword = handleResetPassword;
|
|
152
167
|
;
|
|
153
168
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
169
|
+
* To finish reseting the password, call **resetPassword()**. This will allow you to change your password.
|
|
170
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/qa9ny0gkzlf6y-accept-reset-password for more details.
|
|
171
|
+
* @example
|
|
172
|
+
* ```js
|
|
173
|
+
* const handleResponseAsJson = 'true if the response need to be handled the old way (as json). In the current handling, user will be redirected to success page after successful reset password.';
|
|
174
|
+
* cidaas.resetPassword({
|
|
175
|
+
* password: '123456',
|
|
176
|
+
* confirmPassword: '123456',
|
|
177
|
+
* exchangeId: 'your exchangeId', // which you will get on handle reset password response
|
|
178
|
+
* resetRequestId: 'your resetRequestId' // which you will get on handle reset password response
|
|
179
|
+
* }).then(function (response) {
|
|
180
|
+
* // the response will give you reset password details.
|
|
181
|
+
* }).catch(function(ex) {
|
|
182
|
+
* // your failure code here
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
function resetPassword(options, handleResponseAsJson) {
|
|
158
187
|
var url = window.webAuthSettings.authority + "/users-srv/resetpassword/accept";
|
|
159
188
|
try {
|
|
160
|
-
if (
|
|
189
|
+
if (!handleResponseAsJson) {
|
|
190
|
+
// current handling will redirect and give query parameters
|
|
161
191
|
var form = Helper_1.Helper.createForm(url, options);
|
|
162
192
|
document.body.appendChild(form);
|
|
163
193
|
form.submit();
|
|
164
194
|
}
|
|
165
195
|
else {
|
|
166
|
-
|
|
196
|
+
// older cidaas service handling return json object
|
|
197
|
+
return Helper_1.Helper.createHttpPromise(options, url, false, "POST");
|
|
167
198
|
}
|
|
168
199
|
}
|
|
169
200
|
catch (ex) {
|
|
@@ -173,25 +204,39 @@ var UserService;
|
|
|
173
204
|
UserService.resetPassword = resetPassword;
|
|
174
205
|
;
|
|
175
206
|
/**
|
|
176
|
-
* get
|
|
177
|
-
* @
|
|
178
|
-
*
|
|
207
|
+
* To get the list of existing users in deduplication, call **getDeduplicationDetails()**.
|
|
208
|
+
* @example
|
|
209
|
+
* ```js
|
|
210
|
+
* this.cidaas.getDeduplicationDetails({
|
|
211
|
+
* track_id: 'your track id'
|
|
212
|
+
* }).then((response) => {
|
|
213
|
+
* // the response will give you deduplication details of users.
|
|
214
|
+
* }).catch((err) => {
|
|
215
|
+
* // your failure code here
|
|
216
|
+
* });
|
|
217
|
+
* ```
|
|
179
218
|
*/
|
|
180
219
|
function getDeduplicationDetails(options) {
|
|
181
220
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/info/" + options.trackId;
|
|
182
|
-
return Helper_1.Helper.
|
|
221
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "GET");
|
|
183
222
|
}
|
|
184
223
|
UserService.getDeduplicationDetails = getDeduplicationDetails;
|
|
185
224
|
;
|
|
186
225
|
/**
|
|
187
|
-
* deduplication
|
|
188
|
-
* @
|
|
226
|
+
* To use the existing users in deduplication, you need to call **deduplicationLogin()**.
|
|
227
|
+
* @example
|
|
228
|
+
* ```js
|
|
229
|
+
* this.cidaas.deduplicationLogin({
|
|
230
|
+
* sub: 'your sub',
|
|
231
|
+
* requestId: 'request id from deduplication initialisation after register',
|
|
232
|
+
* trackId: 'track id from deduplication initialisation after register'
|
|
233
|
+
* })
|
|
234
|
+
* ```
|
|
189
235
|
*/
|
|
190
236
|
function deduplicationLogin(options) {
|
|
191
237
|
try {
|
|
192
|
-
var
|
|
193
|
-
form
|
|
194
|
-
form.method = 'POST';
|
|
238
|
+
var url = window.webAuthSettings.authority + "/users-srv/deduplication/login/redirection?trackId=" + options.trackId + "&requestId=" + options.requestId + "&sub=" + options.sub;
|
|
239
|
+
var form = Helper_1.Helper.createForm(url, {});
|
|
195
240
|
document.body.appendChild(form);
|
|
196
241
|
form.submit();
|
|
197
242
|
}
|
|
@@ -202,109 +247,215 @@ var UserService;
|
|
|
202
247
|
UserService.deduplicationLogin = deduplicationLogin;
|
|
203
248
|
;
|
|
204
249
|
/**
|
|
205
|
-
* register
|
|
206
|
-
* @
|
|
207
|
-
*
|
|
250
|
+
* To register new user in deduplication, call **registerDeduplication()**.
|
|
251
|
+
* @example
|
|
252
|
+
* ```js
|
|
253
|
+
* this.cidaas.registerDeduplication({
|
|
254
|
+
* track_id: 'track id from deduplication initialisation after register',
|
|
255
|
+
* }).then((response) => {
|
|
256
|
+
* // the response will give you new registered deduplication user.
|
|
257
|
+
* }).catch((err) => {
|
|
258
|
+
* // your failure code here
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
208
261
|
*/
|
|
209
262
|
function registerDeduplication(options) {
|
|
210
263
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/deduplication/register/" + options.trackId;
|
|
211
|
-
return Helper_1.Helper.
|
|
264
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, undefined, "POST");
|
|
212
265
|
}
|
|
213
266
|
UserService.registerDeduplication = registerDeduplication;
|
|
214
267
|
;
|
|
215
268
|
/**
|
|
216
|
-
* change password
|
|
217
|
-
*
|
|
218
|
-
* @
|
|
219
|
-
*
|
|
269
|
+
* To change the password, call **changePassword()**. This will allow you to change your password.
|
|
270
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/8221883241464-change-password for more details.
|
|
271
|
+
* @example
|
|
272
|
+
* ```js
|
|
273
|
+
* cidaas.changePassword({
|
|
274
|
+
* old_password: 'your old password',
|
|
275
|
+
* new_password: 'your new password',
|
|
276
|
+
* confirm_password: 'your new password',
|
|
277
|
+
* sub: 'your sub',
|
|
278
|
+
* }, 'your access token')
|
|
279
|
+
* .then(function () {
|
|
280
|
+
* // your success code
|
|
281
|
+
* }).catch(function (ex) {
|
|
282
|
+
* // your failure code
|
|
283
|
+
* });
|
|
284
|
+
* ```
|
|
220
285
|
*/
|
|
221
286
|
function changePassword(options, access_token) {
|
|
222
287
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/changepassword";
|
|
223
|
-
return Helper_1.Helper.
|
|
288
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", access_token);
|
|
224
289
|
}
|
|
225
290
|
UserService.changePassword = changePassword;
|
|
226
291
|
;
|
|
227
292
|
/**
|
|
228
|
-
* update profile
|
|
229
|
-
*
|
|
230
|
-
* @
|
|
231
|
-
*
|
|
232
|
-
*
|
|
293
|
+
* To update the user profile information, call **updateProfile()**.
|
|
294
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/i3uqnxcpxr19r-update-user-profile for more details.
|
|
295
|
+
* @example
|
|
296
|
+
* ```js
|
|
297
|
+
* cidaas.updateProfile({
|
|
298
|
+
* family_name: 'Doe',
|
|
299
|
+
* given_name: 'John',
|
|
300
|
+
* provider: 'self',
|
|
301
|
+
* acceptlanguage: 'your locale' // optional example: de-de, en-US
|
|
302
|
+
* }, 'your access token', 'your sub').then(function () {
|
|
303
|
+
* // the response will give you updated user profile info.
|
|
304
|
+
* }).catch(function (ex) {
|
|
305
|
+
* // your failure code here
|
|
306
|
+
* });
|
|
307
|
+
* ```
|
|
233
308
|
*/
|
|
234
309
|
function updateProfile(options, access_token, sub) {
|
|
235
310
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/profile/" + sub;
|
|
236
|
-
return Helper_1.Helper.
|
|
311
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "PUT", access_token);
|
|
237
312
|
}
|
|
238
313
|
UserService.updateProfile = updateProfile;
|
|
239
314
|
;
|
|
240
315
|
/**
|
|
241
|
-
* initiate
|
|
242
|
-
* @
|
|
243
|
-
*
|
|
244
|
-
*
|
|
316
|
+
* To initiate account linking, call **initiateLinkAccount()**.
|
|
317
|
+
* @example
|
|
318
|
+
* ```js
|
|
319
|
+
* const options = {
|
|
320
|
+
* master_sub: 'sub of the user who initiates the user link',
|
|
321
|
+
* user_name_to_link: 'username of the user which should get linked',
|
|
322
|
+
* user_name_type: 'type of user name to link. E.g. email'
|
|
323
|
+
* }
|
|
324
|
+
* const access_token = 'your access token'
|
|
325
|
+
* this.cidaas.initiateLinkAccount(options, access_token).then((response) => {
|
|
326
|
+
* // your success code
|
|
327
|
+
* }).catch((err) => {
|
|
328
|
+
* // your failure code here
|
|
329
|
+
* });
|
|
330
|
+
* ```
|
|
245
331
|
*/
|
|
246
332
|
function initiateLinkAccount(options, access_token) {
|
|
247
333
|
options.user_name_type = 'email';
|
|
248
334
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/initiate";
|
|
249
|
-
return Helper_1.Helper.
|
|
335
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", access_token);
|
|
250
336
|
}
|
|
251
337
|
UserService.initiateLinkAccount = initiateLinkAccount;
|
|
252
338
|
;
|
|
253
339
|
/**
|
|
254
|
-
* complete
|
|
255
|
-
* @
|
|
256
|
-
*
|
|
257
|
-
*
|
|
340
|
+
* To complete account linking, call **completeLinkAccount()**.
|
|
341
|
+
* @example
|
|
342
|
+
* ```js
|
|
343
|
+
* const options = {
|
|
344
|
+
* code: 'code which is sent to account to be linked',
|
|
345
|
+
* link_request_id: 'comes from initiateLinkAccount'
|
|
346
|
+
* }
|
|
347
|
+
* const access_token = 'your access token'
|
|
348
|
+
* this.cidaas.completeLinkAccount(options, access_token).then((response) => {
|
|
349
|
+
* // your success code
|
|
350
|
+
* }).catch((err) => {
|
|
351
|
+
* // your failure code here
|
|
352
|
+
* });
|
|
353
|
+
* ```
|
|
258
354
|
*/
|
|
259
355
|
function completeLinkAccount(options, access_token) {
|
|
260
356
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/link/complete";
|
|
261
|
-
return Helper_1.Helper.
|
|
357
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", access_token);
|
|
262
358
|
}
|
|
263
359
|
UserService.completeLinkAccount = completeLinkAccount;
|
|
264
360
|
;
|
|
265
361
|
/**
|
|
266
|
-
* get linked
|
|
267
|
-
* @
|
|
268
|
-
*
|
|
269
|
-
*
|
|
362
|
+
* To get all the linked accounts, call **getLinkedUsers()**.
|
|
363
|
+
* @example
|
|
364
|
+
* ```js
|
|
365
|
+
* const acccess_token= 'your access token';
|
|
366
|
+
* const sub = 'your sub';
|
|
367
|
+
*
|
|
368
|
+
* cidaas.getLinkedUsers(access_token, sub)
|
|
369
|
+
* .then(function (response) {
|
|
370
|
+
* // type your code here
|
|
371
|
+
* })
|
|
372
|
+
* .catch(function (ex) {
|
|
373
|
+
* // your failure code here
|
|
374
|
+
* });
|
|
375
|
+
* ```
|
|
270
376
|
*/
|
|
271
377
|
function getLinkedUsers(access_token, sub) {
|
|
272
378
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/userinfo/social/" + sub;
|
|
273
|
-
return Helper_1.Helper.
|
|
379
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET", access_token);
|
|
274
380
|
}
|
|
275
381
|
UserService.getLinkedUsers = getLinkedUsers;
|
|
276
382
|
;
|
|
277
383
|
/**
|
|
278
|
-
* unlink
|
|
279
|
-
* @
|
|
280
|
-
*
|
|
281
|
-
*
|
|
384
|
+
* To unlink an account for a user, call **unlinkAccount()**.
|
|
385
|
+
* @example
|
|
386
|
+
* ```js
|
|
387
|
+
* const acccess_token= "your access token";
|
|
388
|
+
* const identityId = "comes from getLinkedUsers";
|
|
389
|
+
*
|
|
390
|
+
* cidaas.unlinkAccount(access_token, identityId)
|
|
391
|
+
* .then(function (response) {
|
|
392
|
+
* // type your code here
|
|
393
|
+
* })
|
|
394
|
+
* .catch(function (ex) {
|
|
395
|
+
* // your failure code here
|
|
396
|
+
* });
|
|
397
|
+
* ```
|
|
282
398
|
*/
|
|
283
399
|
function unlinkAccount(access_token, identityId) {
|
|
284
400
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unlink/" + identityId;
|
|
285
|
-
return Helper_1.Helper.
|
|
401
|
+
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "POST", access_token);
|
|
286
402
|
}
|
|
287
403
|
UserService.unlinkAccount = unlinkAccount;
|
|
288
404
|
;
|
|
289
405
|
/**
|
|
290
|
-
* deleteUserAccount
|
|
291
|
-
*
|
|
292
|
-
* @
|
|
406
|
+
* To delete the user account directly in the application, call **deleteUserAccount()**.
|
|
407
|
+
* Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/x133xdifl1sx9-schedule-user-deletion for more details.
|
|
408
|
+
* @example
|
|
409
|
+
* ```js
|
|
410
|
+
* options = {
|
|
411
|
+
* access_token: "your access token",
|
|
412
|
+
* sub: "your sub"
|
|
413
|
+
* }
|
|
414
|
+
*
|
|
415
|
+
* cidaas.deleteUserAccount(options).then(function (response) {
|
|
416
|
+
* // your success code
|
|
417
|
+
* }).catch(function(ex) {
|
|
418
|
+
* // your failure code here
|
|
419
|
+
* });
|
|
420
|
+
* ```
|
|
293
421
|
*/
|
|
294
422
|
function deleteUserAccount(options) {
|
|
295
423
|
var _serviceURL = window.webAuthSettings.authority + "/users-srv/user/unregister/scheduler/schedule/" + options.sub;
|
|
296
|
-
return Helper_1.Helper.
|
|
424
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST", options.access_token);
|
|
297
425
|
}
|
|
298
426
|
UserService.deleteUserAccount = deleteUserAccount;
|
|
299
427
|
;
|
|
300
428
|
/**
|
|
301
|
-
* check if
|
|
302
|
-
* @
|
|
303
|
-
*
|
|
429
|
+
* To check if user exists, call **userCheckExists()**.
|
|
430
|
+
* @example
|
|
431
|
+
* options = {
|
|
432
|
+
* requestId: "your request id",
|
|
433
|
+
* email: "your email"
|
|
434
|
+
* }
|
|
435
|
+
*
|
|
436
|
+
* cidaas.userCheckExists(options).then(function (response) {
|
|
437
|
+
* // your success code
|
|
438
|
+
* }).catch(function(ex) {
|
|
439
|
+
* // your failure code here
|
|
440
|
+
* });
|
|
441
|
+
* ```
|
|
304
442
|
*/
|
|
305
443
|
function userCheckExists(options) {
|
|
306
|
-
var
|
|
307
|
-
|
|
444
|
+
var queryParameter = '';
|
|
445
|
+
if (options.webfinger || options.rememberMe) {
|
|
446
|
+
queryParameter += '?';
|
|
447
|
+
if (options.webfinger) {
|
|
448
|
+
queryParameter += 'webfinger=' + options.webfinger;
|
|
449
|
+
if (options.rememberMe) {
|
|
450
|
+
queryParameter += '&rememberMe=' + options.rememberMe;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
else if (options.rememberMe) {
|
|
454
|
+
queryParameter += 'rememberMe=' + options.rememberMe;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
var _serviceURL = window.webAuthSettings.authority + "/useractions-srv/userexistence/" + options.requestId + queryParameter;
|
|
458
|
+
return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST");
|
|
308
459
|
}
|
|
309
460
|
UserService.userCheckExists = userCheckExists;
|
|
310
461
|
;
|