cidaas-javascript-sdk 4.0.2 → 4.2.0

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,14 +1,33 @@
1
- ## [4.0.2](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v4.0.1...v4.0.2) (2024-01-18)
1
+ # [4.2.0](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v4.1.0...v4.2.0) (2024-03-14)
2
2
 
3
3
 
4
- ### Bug Fixes
4
+ ### Features
5
5
 
6
- * add error handling ([08017e3](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/08017e3d1da09186f2a4f3bd4b11e606bbeb3043))
7
- * empty commit for release ([b73a4f8](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/b73a4f859d3d2044db883e0d096f0037c76bc6be))
8
- * remove repository from package.json ([4a15688](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/4a15688f8355411049b4f2e63db7737daafd4c7f))
6
+ * add get missing fields from social provider ([fde6303](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/fde630370b0869f836363441b261effa5b2a810f))
9
7
 
10
8
  # Changelog
11
9
 
10
+ ## V4.2.0
11
+
12
+ ### Added
13
+ - add back functionality to get missing field from social provider in getMissingFields() function.
14
+
15
+ ### Changed
16
+ - loginWithBrowser now returning promise
17
+ - registerWithBrowser now returning promise
18
+ - popupSignIn now returning User object after popupSignInCallback is finished
19
+ - popupSignInCallback now returning promise
20
+ - popupSignOut now returning promise
21
+ - popupSignOutCallback now returning promise
22
+
23
+ ## V4.1.0
24
+
25
+ ### Added
26
+ - add latest getInviteUserDetails API, which can be called by specifying function parameter callLatestAPI: true
27
+
28
+ ### Changed
29
+ - support trailing slash on Cidaas options: 'authority'
30
+
12
31
  ## V4.0.2
13
32
 
14
33
  ### Fixed
package/README.md CHANGED
@@ -200,4 +200,4 @@ The SDK will throws Custom Exception if something went wrong during the operatio
200
200
  | HTTP Status Code | When could it be thrown |
201
201
  |----------------- | ----------------------- |
202
202
  | 500 | during creation of WebAuth instance |
203
- | 417 | if there are any other failure |
203
+ | 417 | if there are any other failure |
@@ -19,7 +19,7 @@ export declare class Authentication {
19
19
  *
20
20
  * @param view_type: either 'login' or 'register'
21
21
  */
22
- loginOrRegisterWithBrowser(view_type: string): void;
22
+ loginOrRegisterWithBrowser(view_type: string): Promise<void>;
23
23
  /**
24
24
  * Once login successful, it will automatically redirects you to the redirect url whatever you mentioned in the options.
25
25
  * To complete the login process, call **loginCallback()**. This will parses the access_token, id_token and whatever in hash in the redirect url.
@@ -32,19 +32,15 @@ export declare class Authentication {
32
32
  * });
33
33
  * ```
34
34
  */
35
- loginCallback(): Promise<unknown>;
35
+ loginCallback(): Promise<import("oidc-client-ts").User>;
36
36
  /**
37
37
  * To use the **logout()** method, you need set the redirect url, if not it will automatically redirect to the login page
38
38
  * @example
39
39
  * ```js
40
- * cidaas.logout().then(function () {
41
- * // your logout success code here
42
- * }).catch(function(ex) {
43
- * // your failure code here
44
- * });
40
+ * cidaas.logout();
45
41
  * ```
46
42
  */
47
- logout(): Promise<unknown>;
43
+ logout(): Promise<void>;
48
44
  /**
49
45
  * **logoutCallback()** will parses the details of userState after logout.
50
46
  * @example
@@ -56,45 +52,53 @@ export declare class Authentication {
56
52
  * });
57
53
  * ```
58
54
  */
59
- logoutCallback(): Promise<unknown>;
55
+ logoutCallback(): Promise<import("oidc-client-ts").SignoutResponse>;
60
56
  /**
61
57
  * **popupSignIn()** will open the hosted login page in pop up window.
62
58
  * @example
63
59
  * ```js
64
- * cidaas.popupSignIn();
60
+ * cidaas.popupSignIn().then(function (response) {
61
+ * // the response will give you user details after finishing popupSignInCallback().
62
+ * }).catch(function(ex) {
63
+ * // your failure code here
64
+ * });
65
65
  * ```
66
66
  */
67
- popupSignIn(): void;
67
+ popupSignIn(): Promise<import("oidc-client-ts").User>;
68
68
  /**
69
69
  * To complete the popup login process, call **popupSignInCallback()** from the popup login window.
70
70
  * Popup window will be closed after doing callback
71
71
  * @example
72
72
  * ```js
73
- * cidaas.popupSignInCallback().then(function (response) {
74
- * // the response will give you login details.
75
- * }).catch(function(ex) {
76
- * // your failure code here
77
- * });
73
+ * cidaas.popupSignInCallback();
78
74
  * ```
79
75
  */
80
- popupSignInCallback(): void;
76
+ popupSignInCallback(): Promise<void>;
81
77
  /**
82
78
  * **popupSignOut()** will open the hosted logout page in pop up window.
83
79
  * @example
84
80
  * ```js
85
- * cidaas.popupSignOut()
81
+ * cidaas.popupSignOut().then(function() {
82
+ * // success callback in main application window after finishing popupSignOutCallback().
83
+ * }).catch(function(ex) {
84
+ * // your failure code here
85
+ * });
86
86
  * ```
87
87
  */
88
- popupSignOut(): void;
88
+ popupSignOut(): Promise<void>;
89
89
  /**
90
90
  * calling **popupSignOutCallback()** from the popup window complete popup logout process.
91
91
  * Popup window won't be closed after doing callback
92
92
  * @example
93
93
  * ```js
94
- * cidaas.popupSignOutCallback();
94
+ * cidaas.popupSignOutCallback().then(function() {
95
+ * // success callback in popup window after finishing popupSignOutCallback().
96
+ * }).catch(function(ex) {
97
+ * // your failure code here
98
+ * });
95
99
  * ```
96
100
  */
97
- popupSignOutCallback(): void;
101
+ popupSignOutCallback(): Promise<void>;
98
102
  /**
99
103
  * **silentSignIn()** will open the hosted login page in an iframe.
100
104
  * this function could only be called from the same domain. Cross Domain is not supported for security purpose.
@@ -107,7 +111,7 @@ export declare class Authentication {
107
111
  * });
108
112
  * ```
109
113
  */
110
- silentSignIn(): Promise<unknown>;
114
+ silentSignIn(): Promise<import("oidc-client-ts").User>;
111
115
  /**
112
116
  * To complete the silent login process, call **silentSignInCallback()** from the iframe. This will complete the login process in iframe.
113
117
  * @example
@@ -115,5 +119,5 @@ export declare class Authentication {
115
119
  * cidaas.silentSignInCallback();
116
120
  * ```
117
121
  */
118
- silentSignInCallback(callbackurl?: string): Promise<unknown>;
122
+ silentSignInCallback(callbackurl?: string): Promise<void>;
119
123
  }
@@ -23,33 +23,18 @@ var Authentication = /** @class */ (function () {
23
23
  * @param view_type: either 'login' or 'register'
24
24
  */
25
25
  Authentication.prototype.loginOrRegisterWithBrowser = function (view_type) {
26
- try {
27
- if (this.userManager) {
28
- if (this.webAuthSettings) {
29
- if (!this.webAuthSettings.extraQueryParams) {
30
- this.webAuthSettings.extraQueryParams = {};
31
- }
32
- this.webAuthSettings.extraQueryParams.view_type = view_type;
33
- if (this.webAuthSettings.scope) {
34
- if (this.webAuthSettings.response_type.indexOf("id_token") == -1 && this.webAuthSettings.scope.indexOf("openid") != -1 && !this.webAuthSettings.extraQueryParams.nonce) {
35
- this.webAuthSettings.extraQueryParams.nonce = new Date().getTime().toString();
36
- }
37
- }
38
- }
39
- this.userManager.signinRedirect({
40
- extraQueryParams: this.webAuthSettings.extraQueryParams,
41
- redirect_uri: this.webAuthSettings.redirect_uri
42
- }).then(function () {
43
- console.log("Redirect logged in using cidaas sdk");
44
- });
45
- }
46
- else {
47
- throw "user manager is null";
48
- }
26
+ var _a;
27
+ if (!this.webAuthSettings.extraQueryParams) {
28
+ this.webAuthSettings.extraQueryParams = {};
49
29
  }
50
- catch (ex) {
51
- console.log("user manager instance is empty : " + ex);
30
+ this.webAuthSettings.extraQueryParams.view_type = view_type;
31
+ if (this.webAuthSettings.response_type.indexOf("id_token") == -1 && ((_a = this.webAuthSettings.scope) === null || _a === void 0 ? void 0 : _a.indexOf("openid")) != -1 && !this.webAuthSettings.extraQueryParams.nonce) {
32
+ this.webAuthSettings.extraQueryParams.nonce = new Date().getTime().toString();
52
33
  }
34
+ return this.userManager.signinRedirect({
35
+ extraQueryParams: this.webAuthSettings.extraQueryParams,
36
+ redirect_uri: this.webAuthSettings.redirect_uri
37
+ });
53
38
  };
54
39
  ;
55
40
  /**
@@ -65,65 +50,18 @@ var Authentication = /** @class */ (function () {
65
50
  * ```
66
51
  */
67
52
  Authentication.prototype.loginCallback = function () {
68
- var _this = this;
69
- return new Promise(function (resolve, reject) {
70
- try {
71
- if (_this.userManager) {
72
- _this.userManager.signinRedirectCallback()
73
- .then(function (user) {
74
- if (user) {
75
- resolve(user);
76
- return;
77
- }
78
- resolve(undefined);
79
- })["catch"](function (ex) {
80
- reject(ex);
81
- });
82
- }
83
- else {
84
- throw "user manager is null";
85
- }
86
- }
87
- catch (ex) {
88
- reject(ex);
89
- }
90
- });
53
+ return this.userManager.signinRedirectCallback();
91
54
  };
92
55
  /**
93
56
  * To use the **logout()** method, you need set the redirect url, if not it will automatically redirect to the login page
94
57
  * @example
95
58
  * ```js
96
- * cidaas.logout().then(function () {
97
- * // your logout success code here
98
- * }).catch(function(ex) {
99
- * // your failure code here
100
- * });
59
+ * cidaas.logout();
101
60
  * ```
102
61
  */
103
62
  Authentication.prototype.logout = function () {
104
- var _this = this;
105
- return new Promise(function (resolve, reject) {
106
- try {
107
- if (_this.userManager && _this.webAuthSettings) {
108
- _this.userManager.signoutRedirect({
109
- state: _this.webAuthSettings
110
- }).then(function (resp) {
111
- console.log('signed out', resp);
112
- window.authentication.logoutCallback().then(function (resp) {
113
- resolve(resp);
114
- });
115
- });
116
- }
117
- else {
118
- throw "user manager or settings is null";
119
- }
120
- }
121
- catch (ex) {
122
- reject(ex);
123
- }
124
- });
63
+ return this.userManager.signoutRedirect({ state: this.webAuthSettings });
125
64
  };
126
- ;
127
65
  /**
128
66
  * **logoutCallback()** will parses the details of userState after logout.
129
67
  * @example
@@ -136,47 +74,22 @@ var Authentication = /** @class */ (function () {
136
74
  * ```
137
75
  */
138
76
  Authentication.prototype.logoutCallback = function () {
139
- var _this = this;
140
- return new Promise(function (resolve, reject) {
141
- try {
142
- if (_this.userManager) {
143
- _this.userManager.signoutRedirectCallback().then(function (resp) {
144
- console.log("Signed out");
145
- resolve(resp);
146
- });
147
- }
148
- else {
149
- resolve(undefined);
150
- throw "user manager is null";
151
- }
152
- }
153
- catch (ex) {
154
- reject(ex);
155
- }
156
- });
77
+ return this.userManager.signoutRedirectCallback();
157
78
  };
158
79
  ;
159
80
  /**
160
81
  * **popupSignIn()** will open the hosted login page in pop up window.
161
82
  * @example
162
83
  * ```js
163
- * cidaas.popupSignIn();
84
+ * cidaas.popupSignIn().then(function (response) {
85
+ * // the response will give you user details after finishing popupSignInCallback().
86
+ * }).catch(function(ex) {
87
+ * // your failure code here
88
+ * });
164
89
  * ```
165
90
  */
166
91
  Authentication.prototype.popupSignIn = function () {
167
- try {
168
- if (this.userManager && this.webAuthSettings) {
169
- this.userManager.signinPopup().then(function () {
170
- console.log("signed in");
171
- });
172
- }
173
- else {
174
- throw "user manager or settings is null";
175
- }
176
- }
177
- catch (ex) {
178
- console.error(ex);
179
- }
92
+ return this.userManager.signinPopup();
180
93
  };
181
94
  ;
182
95
  /**
@@ -184,47 +97,26 @@ var Authentication = /** @class */ (function () {
184
97
  * Popup window will be closed after doing callback
185
98
  * @example
186
99
  * ```js
187
- * cidaas.popupSignInCallback().then(function (response) {
188
- * // the response will give you login details.
189
- * }).catch(function(ex) {
190
- * // your failure code here
191
- * });
100
+ * cidaas.popupSignInCallback();
192
101
  * ```
193
102
  */
194
103
  Authentication.prototype.popupSignInCallback = function () {
195
- try {
196
- if (this.userManager) {
197
- this.userManager.signinPopupCallback();
198
- }
199
- }
200
- catch (ex) {
201
- console.error(ex);
202
- }
104
+ return this.userManager.signinPopupCallback();
203
105
  };
204
106
  ;
205
107
  /**
206
108
  * **popupSignOut()** will open the hosted logout page in pop up window.
207
109
  * @example
208
110
  * ```js
209
- * cidaas.popupSignOut()
111
+ * cidaas.popupSignOut().then(function() {
112
+ * // success callback in main application window after finishing popupSignOutCallback().
113
+ * }).catch(function(ex) {
114
+ * // your failure code here
115
+ * });
210
116
  * ```
211
117
  */
212
118
  Authentication.prototype.popupSignOut = function () {
213
- try {
214
- if (this.userManager && this.webAuthSettings) {
215
- this.userManager.signoutPopup({
216
- state: this.webAuthSettings
217
- }).then(function (resp) {
218
- console.log('signed out', resp);
219
- });
220
- }
221
- else {
222
- throw "user manager or settings is null";
223
- }
224
- }
225
- catch (ex) {
226
- console.error(ex);
227
- }
119
+ return this.userManager.signoutPopup({ state: this.webAuthSettings });
228
120
  };
229
121
  ;
230
122
  /**
@@ -232,21 +124,15 @@ var Authentication = /** @class */ (function () {
232
124
  * Popup window won't be closed after doing callback
233
125
  * @example
234
126
  * ```js
235
- * cidaas.popupSignOutCallback();
127
+ * cidaas.popupSignOutCallback().then(function() {
128
+ * // success callback in popup window after finishing popupSignOutCallback().
129
+ * }).catch(function(ex) {
130
+ * // your failure code here
131
+ * });
236
132
  * ```
237
133
  */
238
134
  Authentication.prototype.popupSignOutCallback = function () {
239
- try {
240
- if (this.userManager) {
241
- this.userManager.signoutPopupCallback(this.webAuthSettings.post_logout_redirect_uri, true);
242
- }
243
- else {
244
- throw "user manager is null";
245
- }
246
- }
247
- catch (ex) {
248
- console.error(ex);
249
- }
135
+ return this.userManager.signoutPopupCallback(this.webAuthSettings.post_logout_redirect_uri, true);
250
136
  };
251
137
  ;
252
138
  /**
@@ -262,28 +148,9 @@ var Authentication = /** @class */ (function () {
262
148
  * ```
263
149
  */
264
150
  Authentication.prototype.silentSignIn = function () {
265
- var _this = this;
266
- return new Promise(function (resolve, reject) {
267
- try {
268
- if (_this.userManager && _this.webAuthSettings) {
269
- _this.userManager.signinSilent({
270
- state: _this.webAuthSettings,
271
- silentRequestTimeoutInSeconds: 60
272
- }).then(function (user) {
273
- if (user) {
274
- resolve(user);
275
- return;
276
- }
277
- resolve(undefined);
278
- });
279
- }
280
- else {
281
- throw "user manager or web auth settings is null";
282
- }
283
- }
284
- catch (ex) {
285
- reject(ex);
286
- }
151
+ return this.userManager.signinSilent({
152
+ state: this.webAuthSettings,
153
+ silentRequestTimeoutInSeconds: 60
287
154
  });
288
155
  };
289
156
  ;
@@ -295,29 +162,7 @@ var Authentication = /** @class */ (function () {
295
162
  * ```
296
163
  */
297
164
  Authentication.prototype.silentSignInCallback = function (callbackurl) {
298
- var _this = this;
299
- return new Promise(function (resolve, reject) {
300
- try {
301
- if (_this.userManager) {
302
- _this.userManager.signinSilentCallback(callbackurl)
303
- .then(function (user) {
304
- if (user) {
305
- resolve(user);
306
- return;
307
- }
308
- resolve(undefined);
309
- })["catch"](function (e) {
310
- reject(e);
311
- });
312
- }
313
- else {
314
- throw "user manager is null";
315
- }
316
- }
317
- catch (ex) {
318
- reject(ex);
319
- }
320
- });
165
+ return this.userManager.signinSilentCallback(callbackurl);
321
166
  };
322
167
  ;
323
168
  return Authentication;
@@ -178,7 +178,6 @@ var LoginService;
178
178
  function firstTimeChangePassword(options) {
179
179
  try {
180
180
  var url = window.webAuthSettings.authority + "/login-srv/precheck/continue/" + options.loginSettingsId;
181
- ;
182
181
  var form = Helper_1.Helper.createForm(url, options);
183
182
  document.body.appendChild(form);
184
183
  form.submit();
@@ -55,11 +55,14 @@ export declare namespace UserService {
55
55
  trackId?: string;
56
56
  }): Promise<unknown>;
57
57
  /**
58
- * to get information about invitation details, call **getInviteUserDetails()**
58
+ * to get information about invitation details, call **getInviteUserDetails()**. This API allows to retrieve invitation details and prefill the registration form.
59
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/0b5efa5a2db5d-prefill-the-user-invitation for more details.
60
+ * Minimum cidaas version to use latest api is v3.100
59
61
  * @example
60
62
  * ```js
61
63
  * const options = {
62
64
  * invite_id: 'id of user invitation'
65
+ * callLatestAPI: 'true' // call latest api if parameter is given. By default, the older api will be called
63
66
  * }
64
67
  * cidaas.getInviteUserDetails(options)
65
68
  * .then(function () {
@@ -71,6 +74,7 @@ export declare namespace UserService {
71
74
  */
72
75
  function getInviteUserDetails(options: {
73
76
  invite_id: string;
77
+ callLatestAPI?: boolean;
74
78
  }): Promise<unknown>;
75
79
  /**
76
80
  * Once registration successful, verify the account based on the flow. To get the details, call **getCommunicationStatus()**.
@@ -67,11 +67,14 @@ var UserService;
67
67
  UserService.register = register;
68
68
  ;
69
69
  /**
70
- * to get information about invitation details, call **getInviteUserDetails()**
70
+ * to get information about invitation details, call **getInviteUserDetails()**. This API allows to retrieve invitation details and prefill the registration form.
71
+ * Please refer to the api document https://docs.cidaas.com/docs/cidaas-iam/0b5efa5a2db5d-prefill-the-user-invitation for more details.
72
+ * Minimum cidaas version to use latest api is v3.100
71
73
  * @example
72
74
  * ```js
73
75
  * const options = {
74
76
  * invite_id: 'id of user invitation'
77
+ * callLatestAPI: 'true' // call latest api if parameter is given. By default, the older api will be called
75
78
  * }
76
79
  * cidaas.getInviteUserDetails(options)
77
80
  * .then(function () {
@@ -82,7 +85,13 @@ var UserService;
82
85
  * ```
83
86
  */
84
87
  function getInviteUserDetails(options) {
85
- var _serviceURL = window.webAuthSettings.authority + "/users-srv/invite/info/" + options.invite_id;
88
+ var _serviceURL = "";
89
+ if (options.callLatestAPI) {
90
+ _serviceURL = window.webAuthSettings.authority + "/useractions-srv/invitations/" + options.invite_id;
91
+ }
92
+ else {
93
+ _serviceURL = window.webAuthSettings.authority + "/users-srv/invite/info/" + options.invite_id;
94
+ }
86
95
  return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
87
96
  }
88
97
  UserService.getInviteUserDetails = getInviteUserDetails;
@@ -1,38 +1,39 @@
1
1
  import { SigninState, UserManagerSettings } from "oidc-client-ts";
2
2
  import { AccessTokenRequest, TokenIntrospectionEntity, UserEntity, ResetPasswordEntity, IConfiguredListRequestEntity, IInitVerificationAuthenticationRequestEntity, FindUserEntity, IUserEntity, IEnrollVerificationSetupRequestEntity, IUserLinkEntity, ChangePasswordEntity, IConsentAcceptEntity, IAuthVerificationAuthenticationRequestEntity, LoginFormRequestEntity, AccountVerificationRequestEntity, ValidateResetPasswordEntity, AcceptResetPasswordEntity, PhysicalVerificationLoginRequest, IChangePasswordEntity, IUserActivityPayloadEntity } from "./Entities";
3
+ export declare const createPreloginWebauth: (authority: string) => WebAuth;
3
4
  export declare class WebAuth {
4
5
  constructor(settings: UserManagerSettings);
5
6
  /**
6
7
  * login
7
8
  */
8
- loginWithBrowser(): void;
9
+ loginWithBrowser(): any;
9
10
  /**
10
11
  * popupSignIn
11
12
  */
12
- popupSignIn(): void;
13
+ popupSignIn(): any;
13
14
  /**
14
15
  * silentSignIn
15
16
  */
16
- silentSignIn(): Promise<unknown>;
17
+ silentSignIn(): any;
17
18
  /**
18
19
  * register
19
20
  */
20
- registerWithBrowser(): void;
21
+ registerWithBrowser(): any;
21
22
  /**
22
23
  * login callback
23
24
  * @returns
24
25
  */
25
- loginCallback(): Promise<unknown>;
26
+ loginCallback(): any;
26
27
  /**
27
28
  * popup signin callback
28
29
  * @returns
29
30
  */
30
- popupSignInCallback(): Promise<unknown>;
31
+ popupSignInCallback(): any;
31
32
  /**
32
33
  * silent signin callback
33
34
  * @returns
34
35
  */
35
- silentSignInCallback(): Promise<unknown>;
36
+ silentSignInCallback(): any;
36
37
  /**
37
38
  * To get the user profile information by using oidc-client-ts library, call **getUserInfo()**. This will return the basic user profile details along with groups, roles and whatever scopes you mentioned in the options.
38
39
  * @example
@@ -41,7 +42,7 @@ export declare class WebAuth {
41
42
  * // the response will give you profile details.
42
43
  * }).catch(function(ex) {
43
44
  * // your failure code here
44
- * });;
45
+ * });
45
46
  * ```
46
47
  */
47
48
  getUserInfo(): Promise<any>;
@@ -49,22 +50,22 @@ export declare class WebAuth {
49
50
  * logout by using oidc-client-ts library
50
51
  * @returns
51
52
  */
52
- logout(): Promise<unknown>;
53
+ logout(): any;
53
54
  /**
54
55
  * popup signout
55
56
  * @returns
56
57
  */
57
- popupSignOut(): Promise<unknown>;
58
+ popupSignOut(): any;
58
59
  /**
59
60
  * logout callback
60
61
  * @returns
61
62
  */
62
- logoutCallback(): Promise<unknown>;
63
+ logoutCallback(): any;
63
64
  /**
64
65
  * popup signout callback
65
66
  * @returns
66
67
  */
67
- popupSignOutCallback(): Promise<unknown>;
68
+ popupSignOutCallback(): any;
68
69
  /**
69
70
  * To get the generated login url, call **getLoginURL()**. This will call authz service and generate login url to be used.
70
71
  * @example
@@ -73,7 +74,7 @@ export declare class WebAuth {
73
74
  * // the response will give you login url.
74
75
  * }).catch(function(ex) {
75
76
  * // your failure code here
76
- * });;
77
+ * });
77
78
  * ```
78
79
  */
79
80
  getLoginURL(state?: SigninState): Promise<unknown>;
@@ -85,7 +86,7 @@ export declare class WebAuth {
85
86
  * // the response will give you request id.
86
87
  * }).catch(function(ex) {
87
88
  * // your failure code here
88
- * });;
89
+ * });
89
90
  * ```
90
91
  */
91
92
  getRequestId(): Promise<unknown>;
@@ -97,7 +98,7 @@ export declare class WebAuth {
97
98
  * // the response will give you tenant details
98
99
  * }).catch(function(ex) {
99
100
  * // your failure code here
100
- * });;
101
+ * });
101
102
  * ```
102
103
  */
103
104
  getTenantInfo(): Promise<unknown>;
@@ -273,6 +274,7 @@ export declare class WebAuth {
273
274
  */
274
275
  getInviteUserDetails(options: {
275
276
  invite_id: string;
277
+ callLatestAPI?: boolean;
276
278
  }): Promise<unknown>;
277
279
  /**
278
280
  * get Communication status
@@ -589,10 +591,26 @@ export declare class WebAuth {
589
591
  }): Promise<unknown>;
590
592
  /**
591
593
  * getMissingFields
592
- * @param trackId
593
- * @returns
594
+ * @param trackId - required. If only trackId is given, it will get missing fields from cidaas after succesfull registration using default provider
595
+ * @param useSocialProvider - optional. If given, it will get missing fields from social provider after successful registration using social provider
596
+ *
597
+ * @example
598
+ * ```js
599
+ * const trackId = 'your track id'
600
+ * const useSocialProvider = {
601
+ * requestId: 'request id from cidaas'
602
+ * };
603
+ * cidaas.getMissingFields(trackId, useSocialProvider).then(function (resp) {
604
+ * // your success code
605
+ * }).catch(function(ex) {
606
+ * // your failure code
607
+ * });
608
+ * ```
609
+ *
594
610
  */
595
- getMissingFields(trackId: string): Promise<unknown>;
611
+ getMissingFields(trackId: string, useSocialProvider?: {
612
+ requestId: string;
613
+ }): Promise<unknown>;
596
614
  /**
597
615
  * progressiveRegistration
598
616
  * @param options
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  exports.__esModule = true;
50
- exports.WebAuth = void 0;
50
+ exports.WebAuth = exports.createPreloginWebauth = void 0;
51
51
  var oidc_client_ts_1 = require("oidc-client-ts");
52
52
  var authentication_1 = require("../authentication");
53
53
  var Helper_1 = require("./Helper");
@@ -56,6 +56,10 @@ var UserService_1 = require("./UserService");
56
56
  var TokenService_1 = require("./TokenService");
57
57
  var VerificationService_1 = require("./VerificationService");
58
58
  var ConsentService_1 = require("./ConsentService");
59
+ var createPreloginWebauth = function (authority) {
60
+ return new WebAuth({ 'authority': authority });
61
+ };
62
+ exports.createPreloginWebauth = createPreloginWebauth;
59
63
  var WebAuth = /** @class */ (function () {
60
64
  function WebAuth(settings) {
61
65
  try {
@@ -65,12 +69,15 @@ var WebAuth = /** @class */ (function () {
65
69
  if (!settings.scope) {
66
70
  settings.scope = "email openid profile mobile";
67
71
  }
72
+ if (settings.authority && settings.authority.charAt(settings.authority.length - 1) === '/') {
73
+ settings.authority = settings.authority.slice(0, settings.authority.length - 1);
74
+ }
68
75
  var usermanager = new oidc_client_ts_1.UserManager(settings);
69
76
  window.webAuthSettings = settings;
70
77
  window.usermanager = usermanager;
71
78
  window.localeSettings = null;
72
79
  window.authentication = new authentication_1.Authentication(window.webAuthSettings, window.usermanager);
73
- window.usermanager.events.addSilentRenewError(function (error) {
80
+ window.usermanager.events.addSilentRenewError(function () {
74
81
  throw new Helper_1.CustomException("Error while renewing silent login", 500);
75
82
  });
76
83
  }
@@ -83,66 +90,40 @@ var WebAuth = /** @class */ (function () {
83
90
  * login
84
91
  */
85
92
  WebAuth.prototype.loginWithBrowser = function () {
86
- try {
87
- if (!window.webAuthSettings && !window.authentication) {
88
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
89
- }
90
- window.authentication.loginOrRegisterWithBrowser('login');
91
- }
92
- catch (ex) {
93
- console.log(ex);
93
+ if (!window.webAuthSettings || !window.authentication) {
94
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
94
95
  }
96
+ return window.authentication.loginOrRegisterWithBrowser('login');
95
97
  };
96
98
  ;
97
99
  /**
98
100
  * popupSignIn
99
101
  */
100
102
  WebAuth.prototype.popupSignIn = function () {
101
- try {
102
- if (!window.webAuthSettings && !window.authentication) {
103
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
104
- }
105
- window.authentication.popupSignIn();
106
- }
107
- catch (ex) {
108
- console.log(ex);
103
+ if (!window.webAuthSettings || !window.authentication) {
104
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
109
105
  }
106
+ return window.authentication.popupSignIn();
110
107
  };
111
108
  ;
112
109
  /**
113
110
  * silentSignIn
114
111
  */
115
112
  WebAuth.prototype.silentSignIn = function () {
116
- return new Promise(function (resolve, reject) {
117
- try {
118
- if (!window.webAuthSettings && !window.authentication) {
119
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
120
- }
121
- window.authentication.silentSignIn().then(function (user) {
122
- resolve(user);
123
- })["catch"](function (ex) {
124
- reject(ex);
125
- });
126
- }
127
- catch (ex) {
128
- console.log(ex);
129
- }
130
- });
113
+ if (!window.webAuthSettings || !window.authentication) {
114
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
115
+ }
116
+ return window.authentication.silentSignIn();
131
117
  };
132
118
  ;
133
119
  /**
134
120
  * register
135
121
  */
136
122
  WebAuth.prototype.registerWithBrowser = function () {
137
- try {
138
- if (!window.webAuthSettings && !window.authentication) {
139
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
140
- }
141
- window.authentication.loginOrRegisterWithBrowser('register');
142
- }
143
- catch (ex) {
144
- console.log(ex);
123
+ if (!window.webAuthSettings || !window.authentication) {
124
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
145
125
  }
126
+ return window.authentication.loginOrRegisterWithBrowser('register');
146
127
  };
147
128
  ;
148
129
  /**
@@ -150,16 +131,10 @@ var WebAuth = /** @class */ (function () {
150
131
  * @returns
151
132
  */
152
133
  WebAuth.prototype.loginCallback = function () {
153
- return new Promise(function (resolve, reject) {
154
- if (!window.webAuthSettings && !window.authentication) {
155
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
156
- }
157
- window.authentication.loginCallback().then(function (user) {
158
- resolve(user);
159
- })["catch"](function (ex) {
160
- reject(ex);
161
- });
162
- });
134
+ if (!window.webAuthSettings || !window.authentication) {
135
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
136
+ }
137
+ return window.authentication.loginCallback();
163
138
  };
164
139
  ;
165
140
  /**
@@ -167,17 +142,10 @@ var WebAuth = /** @class */ (function () {
167
142
  * @returns
168
143
  */
169
144
  WebAuth.prototype.popupSignInCallback = function () {
170
- return new Promise(function (resolve, reject) {
171
- try {
172
- if (!window.webAuthSettings && !window.authentication) {
173
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
174
- }
175
- window.authentication.popupSignInCallback();
176
- }
177
- catch (ex) {
178
- console.log(ex);
179
- }
180
- });
145
+ if (!window.webAuthSettings || !window.authentication) {
146
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
147
+ }
148
+ return window.authentication.popupSignInCallback();
181
149
  };
182
150
  ;
183
151
  /**
@@ -185,21 +153,10 @@ var WebAuth = /** @class */ (function () {
185
153
  * @returns
186
154
  */
187
155
  WebAuth.prototype.silentSignInCallback = function () {
188
- return new Promise(function (resolve, reject) {
189
- try {
190
- if (!window.webAuthSettings && !window.authentication) {
191
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
192
- }
193
- window.authentication.silentSignInCallback().then(function (data) {
194
- resolve(data);
195
- })["catch"](function (error) {
196
- reject(error);
197
- });
198
- }
199
- catch (ex) {
200
- console.log(ex);
201
- }
202
- });
156
+ if (!window.webAuthSettings || !window.authentication) {
157
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
158
+ }
159
+ return window.authentication.silentSignInCallback();
203
160
  };
204
161
  ;
205
162
  /**
@@ -210,25 +167,19 @@ var WebAuth = /** @class */ (function () {
210
167
  * // the response will give you profile details.
211
168
  * }).catch(function(ex) {
212
169
  * // your failure code here
213
- * });;
170
+ * });
214
171
  * ```
215
172
  */
216
173
  WebAuth.prototype.getUserInfo = function () {
217
174
  return __awaiter(this, void 0, void 0, function () {
218
- var e_1;
219
175
  return __generator(this, function (_a) {
220
176
  switch (_a.label) {
221
177
  case 0:
222
- _a.trys.push([0, 4, , 5]);
223
- if (!window.usermanager) return [3 /*break*/, 2];
178
+ if (!window.usermanager) {
179
+ return [2 /*return*/, Promise.reject(new Helper_1.CustomException("UserManager cannot be empty", 417))];
180
+ }
224
181
  return [4 /*yield*/, window.usermanager.getUser()];
225
182
  case 1: return [2 /*return*/, _a.sent()];
226
- case 2: throw new Helper_1.CustomException("UserManager cannot be empty", 417);
227
- case 3: return [3 /*break*/, 5];
228
- case 4:
229
- e_1 = _a.sent();
230
- throw e_1;
231
- case 5: return [2 /*return*/];
232
183
  }
233
184
  });
234
185
  });
@@ -239,20 +190,10 @@ var WebAuth = /** @class */ (function () {
239
190
  * @returns
240
191
  */
241
192
  WebAuth.prototype.logout = function () {
242
- return new Promise(function (resolve, reject) {
243
- try {
244
- if (!window.webAuthSettings && !window.authentication) {
245
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
246
- }
247
- window.authentication.logout().then(function (result) {
248
- resolve(result);
249
- return;
250
- });
251
- }
252
- catch (ex) {
253
- reject(ex);
254
- }
255
- });
193
+ if (!window.webAuthSettings || !window.authentication) {
194
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
195
+ }
196
+ return window.authentication.logout();
256
197
  };
257
198
  ;
258
199
  /**
@@ -260,17 +201,10 @@ var WebAuth = /** @class */ (function () {
260
201
  * @returns
261
202
  */
262
203
  WebAuth.prototype.popupSignOut = function () {
263
- return new Promise(function (resolve, reject) {
264
- try {
265
- if (!window.webAuthSettings && !window.authentication) {
266
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
267
- }
268
- window.authentication.popupSignOut();
269
- }
270
- catch (ex) {
271
- reject(ex);
272
- }
273
- });
204
+ if (!window.webAuthSettings || !window.authentication) {
205
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
206
+ }
207
+ return window.authentication.popupSignOut();
274
208
  };
275
209
  ;
276
210
  /**
@@ -278,19 +212,10 @@ var WebAuth = /** @class */ (function () {
278
212
  * @returns
279
213
  */
280
214
  WebAuth.prototype.logoutCallback = function () {
281
- return new Promise(function (resolve, reject) {
282
- try {
283
- if (!window.webAuthSettings && !window.authentication) {
284
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
285
- }
286
- window.authentication.logoutCallback().then(function (resp) {
287
- resolve(resp);
288
- });
289
- }
290
- catch (ex) {
291
- reject(ex);
292
- }
293
- });
215
+ if (!window.webAuthSettings || !window.authentication) {
216
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
217
+ }
218
+ return window.authentication.logoutCallback();
294
219
  };
295
220
  ;
296
221
  /**
@@ -298,17 +223,10 @@ var WebAuth = /** @class */ (function () {
298
223
  * @returns
299
224
  */
300
225
  WebAuth.prototype.popupSignOutCallback = function () {
301
- return new Promise(function (resolve, reject) {
302
- try {
303
- if (!window.webAuthSettings && !window.authentication) {
304
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
305
- }
306
- window.authentication.popupSignOutCallback();
307
- }
308
- catch (ex) {
309
- reject(ex);
310
- }
311
- });
226
+ if (!window.webAuthSettings || !window.authentication) {
227
+ return Promise.reject(new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417));
228
+ }
229
+ return window.authentication.popupSignOutCallback();
312
230
  };
313
231
  ;
314
232
  /**
@@ -319,7 +237,7 @@ var WebAuth = /** @class */ (function () {
319
237
  * // the response will give you login url.
320
238
  * }).catch(function(ex) {
321
239
  * // your failure code here
322
- * });;
240
+ * });
323
241
  * ```
324
242
  */
325
243
  WebAuth.prototype.getLoginURL = function (state) {
@@ -327,7 +245,6 @@ var WebAuth = /** @class */ (function () {
327
245
  try {
328
246
  window.usermanager._client.createSigninRequest({ state: state }).then(function (signinRequest) {
329
247
  resolve(signinRequest.url);
330
- return;
331
248
  });
332
249
  }
333
250
  catch (e) {
@@ -344,7 +261,7 @@ var WebAuth = /** @class */ (function () {
344
261
  * // the response will give you request id.
345
262
  * }).catch(function(ex) {
346
263
  * // your failure code here
347
- * });;
264
+ * });
348
265
  * ```
349
266
  */
350
267
  WebAuth.prototype.getRequestId = function () {
@@ -363,7 +280,7 @@ var WebAuth = /** @class */ (function () {
363
280
  * // the response will give you tenant details
364
281
  * }).catch(function(ex) {
365
282
  * // your failure code here
366
- * });;
283
+ * });
367
284
  * ```
368
285
  */
369
286
  WebAuth.prototype.getTenantInfo = function () {
@@ -382,12 +299,7 @@ var WebAuth = /** @class */ (function () {
382
299
  * ```
383
300
  */
384
301
  WebAuth.prototype.logoutUser = function (options) {
385
- try {
386
- window.location.href = window.webAuthSettings.authority + "/session/end_session?access_token_hint=" + options.access_token + "&post_logout_redirect_uri=" + window.webAuthSettings.post_logout_redirect_uri;
387
- }
388
- catch (ex) {
389
- throw new Helper_1.CustomException(ex, 417);
390
- }
302
+ window.location.href = window.webAuthSettings.authority + "/session/end_session?access_token_hint=" + options.access_token + "&post_logout_redirect_uri=" + window.webAuthSettings.post_logout_redirect_uri;
391
303
  };
392
304
  ;
393
305
  /**
@@ -950,11 +862,31 @@ var WebAuth = /** @class */ (function () {
950
862
  ;
951
863
  /**
952
864
  * getMissingFields
953
- * @param trackId
954
- * @returns
865
+ * @param trackId - required. If only trackId is given, it will get missing fields from cidaas after succesfull registration using default provider
866
+ * @param useSocialProvider - optional. If given, it will get missing fields from social provider after successful registration using social provider
867
+ *
868
+ * @example
869
+ * ```js
870
+ * const trackId = 'your track id'
871
+ * const useSocialProvider = {
872
+ * requestId: 'request id from cidaas'
873
+ * };
874
+ * cidaas.getMissingFields(trackId, useSocialProvider).then(function (resp) {
875
+ * // your success code
876
+ * }).catch(function(ex) {
877
+ * // your failure code
878
+ * });
879
+ * ```
880
+ *
955
881
  */
956
- WebAuth.prototype.getMissingFields = function (trackId) {
957
- return TokenService_1.TokenService.getMissingFields(trackId);
882
+ WebAuth.prototype.getMissingFields = function (trackId, useSocialProvider) {
883
+ if (useSocialProvider) {
884
+ var _serviceURL = window.webAuthSettings.authority + "/public-srv/public/trackinfo/" + useSocialProvider.requestId + "/" + trackId;
885
+ return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, false, "GET");
886
+ }
887
+ else {
888
+ return TokenService_1.TokenService.getMissingFields(trackId);
889
+ }
958
890
  };
959
891
  ;
960
892
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cidaas-javascript-sdk",
3
- "version": "4.0.2",
3
+ "version": "4.2.0",
4
4
  "author": "cidaas by Widas ID GmbH",
5
5
  "description": "Cidaas native javascript sdk",
6
6
  "license": "MIT",