cidaas-javascript-sdk 4.1.0 → 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,18 +1,25 @@
1
- # [4.1.0](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v4.0.2...v4.1.0) (2024-01-19)
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
4
  ### Features
5
5
 
6
- * **[1441](https://gitlab.widas.de/cidaas-v2/framework/issues/-/issues/1441):** Add the new method for Get Invite User details ([5917eb0](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/5917eb0cf98248c66d0b149cb41cf27be69c41ae))
7
- * **[1441](https://gitlab.widas.de/cidaas-v2/framework/issues/-/issues/1441):** Add the new method for Get Invite User details ([ffc503d](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/ffc503dfde2510c8000e18cb437b5ab0a7578ee8))
8
- * **[1441](https://gitlab.widas.de/cidaas-v2/framework/issues/-/issues/1441):** Add the new method for Get Invite User details ([a3d2860](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/a3d28601490b0303c9f86b60aeda3c5a46788966))
9
- * **[1441](https://gitlab.widas.de/cidaas-v2/framework/issues/-/issues/1441):** Add the new method for Get Invite User details ([88cd3b7](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/88cd3b766de7ede953594cc47d34d6e45dc3e17b))
10
- * **[1441](https://gitlab.widas.de/cidaas-v2/framework/issues/-/issues/1441):** Add the new method for Get Invite User details ([1c347ef](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/1c347efc9a54d787538416b3eee1d609238b4b1d))
11
- * **[1441](https://gitlab.widas.de/cidaas-v2/framework/issues/-/issues/1441):** Add the new method for Get Invite User details ([df4630a](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/df4630a8d8def6ef36d402f230f6ada86875e71e))
12
- * **[1441](https://gitlab.widas.de/cidaas-v2/framework/issues/-/issues/1441):** Add the new method for Get Invite User details ([3a2ce7e](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/3a2ce7ec82b3ae91ffc8066081f905972f278985))
6
+ * add get missing fields from social provider ([fde6303](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/fde630370b0869f836363441b261effa5b2a810f))
13
7
 
14
8
  # Changelog
15
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
+
16
23
  ## V4.1.0
17
24
 
18
25
  ### Added
@@ -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();
@@ -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>;
@@ -590,10 +591,26 @@ export declare class WebAuth {
590
591
  }): Promise<unknown>;
591
592
  /**
592
593
  * getMissingFields
593
- * @param trackId
594
- * @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
+ *
595
610
  */
596
- getMissingFields(trackId: string): Promise<unknown>;
611
+ getMissingFields(trackId: string, useSocialProvider?: {
612
+ requestId: string;
613
+ }): Promise<unknown>;
597
614
  /**
598
615
  * progressiveRegistration
599
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 {
@@ -73,7 +77,7 @@ var WebAuth = /** @class */ (function () {
73
77
  window.usermanager = usermanager;
74
78
  window.localeSettings = null;
75
79
  window.authentication = new authentication_1.Authentication(window.webAuthSettings, window.usermanager);
76
- window.usermanager.events.addSilentRenewError(function (error) {
80
+ window.usermanager.events.addSilentRenewError(function () {
77
81
  throw new Helper_1.CustomException("Error while renewing silent login", 500);
78
82
  });
79
83
  }
@@ -86,66 +90,40 @@ var WebAuth = /** @class */ (function () {
86
90
  * login
87
91
  */
88
92
  WebAuth.prototype.loginWithBrowser = function () {
89
- try {
90
- if (!window.webAuthSettings && !window.authentication) {
91
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
92
- }
93
- window.authentication.loginOrRegisterWithBrowser('login');
94
- }
95
- catch (ex) {
96
- 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));
97
95
  }
96
+ return window.authentication.loginOrRegisterWithBrowser('login');
98
97
  };
99
98
  ;
100
99
  /**
101
100
  * popupSignIn
102
101
  */
103
102
  WebAuth.prototype.popupSignIn = function () {
104
- try {
105
- if (!window.webAuthSettings && !window.authentication) {
106
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
107
- }
108
- window.authentication.popupSignIn();
109
- }
110
- catch (ex) {
111
- 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));
112
105
  }
106
+ return window.authentication.popupSignIn();
113
107
  };
114
108
  ;
115
109
  /**
116
110
  * silentSignIn
117
111
  */
118
112
  WebAuth.prototype.silentSignIn = function () {
119
- return new Promise(function (resolve, reject) {
120
- try {
121
- if (!window.webAuthSettings && !window.authentication) {
122
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
123
- }
124
- window.authentication.silentSignIn().then(function (user) {
125
- resolve(user);
126
- })["catch"](function (ex) {
127
- reject(ex);
128
- });
129
- }
130
- catch (ex) {
131
- console.log(ex);
132
- }
133
- });
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();
134
117
  };
135
118
  ;
136
119
  /**
137
120
  * register
138
121
  */
139
122
  WebAuth.prototype.registerWithBrowser = function () {
140
- try {
141
- if (!window.webAuthSettings && !window.authentication) {
142
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
143
- }
144
- window.authentication.loginOrRegisterWithBrowser('register');
145
- }
146
- catch (ex) {
147
- 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));
148
125
  }
126
+ return window.authentication.loginOrRegisterWithBrowser('register');
149
127
  };
150
128
  ;
151
129
  /**
@@ -153,16 +131,10 @@ var WebAuth = /** @class */ (function () {
153
131
  * @returns
154
132
  */
155
133
  WebAuth.prototype.loginCallback = function () {
156
- return new Promise(function (resolve, reject) {
157
- if (!window.webAuthSettings && !window.authentication) {
158
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
159
- }
160
- window.authentication.loginCallback().then(function (user) {
161
- resolve(user);
162
- })["catch"](function (ex) {
163
- reject(ex);
164
- });
165
- });
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();
166
138
  };
167
139
  ;
168
140
  /**
@@ -170,17 +142,10 @@ var WebAuth = /** @class */ (function () {
170
142
  * @returns
171
143
  */
172
144
  WebAuth.prototype.popupSignInCallback = function () {
173
- return new Promise(function (resolve, reject) {
174
- try {
175
- if (!window.webAuthSettings && !window.authentication) {
176
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
177
- }
178
- window.authentication.popupSignInCallback();
179
- }
180
- catch (ex) {
181
- console.log(ex);
182
- }
183
- });
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();
184
149
  };
185
150
  ;
186
151
  /**
@@ -188,21 +153,10 @@ var WebAuth = /** @class */ (function () {
188
153
  * @returns
189
154
  */
190
155
  WebAuth.prototype.silentSignInCallback = function () {
191
- return new Promise(function (resolve, reject) {
192
- try {
193
- if (!window.webAuthSettings && !window.authentication) {
194
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
195
- }
196
- window.authentication.silentSignInCallback().then(function (data) {
197
- resolve(data);
198
- })["catch"](function (error) {
199
- reject(error);
200
- });
201
- }
202
- catch (ex) {
203
- console.log(ex);
204
- }
205
- });
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();
206
160
  };
207
161
  ;
208
162
  /**
@@ -213,25 +167,19 @@ var WebAuth = /** @class */ (function () {
213
167
  * // the response will give you profile details.
214
168
  * }).catch(function(ex) {
215
169
  * // your failure code here
216
- * });;
170
+ * });
217
171
  * ```
218
172
  */
219
173
  WebAuth.prototype.getUserInfo = function () {
220
174
  return __awaiter(this, void 0, void 0, function () {
221
- var e_1;
222
175
  return __generator(this, function (_a) {
223
176
  switch (_a.label) {
224
177
  case 0:
225
- _a.trys.push([0, 4, , 5]);
226
- 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
+ }
227
181
  return [4 /*yield*/, window.usermanager.getUser()];
228
182
  case 1: return [2 /*return*/, _a.sent()];
229
- case 2: throw new Helper_1.CustomException("UserManager cannot be empty", 417);
230
- case 3: return [3 /*break*/, 5];
231
- case 4:
232
- e_1 = _a.sent();
233
- throw e_1;
234
- case 5: return [2 /*return*/];
235
183
  }
236
184
  });
237
185
  });
@@ -242,20 +190,10 @@ var WebAuth = /** @class */ (function () {
242
190
  * @returns
243
191
  */
244
192
  WebAuth.prototype.logout = function () {
245
- return new Promise(function (resolve, reject) {
246
- try {
247
- if (!window.webAuthSettings && !window.authentication) {
248
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
249
- }
250
- window.authentication.logout().then(function (result) {
251
- resolve(result);
252
- return;
253
- });
254
- }
255
- catch (ex) {
256
- reject(ex);
257
- }
258
- });
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();
259
197
  };
260
198
  ;
261
199
  /**
@@ -263,17 +201,10 @@ var WebAuth = /** @class */ (function () {
263
201
  * @returns
264
202
  */
265
203
  WebAuth.prototype.popupSignOut = function () {
266
- return new Promise(function (resolve, reject) {
267
- try {
268
- if (!window.webAuthSettings && !window.authentication) {
269
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
270
- }
271
- window.authentication.popupSignOut();
272
- }
273
- catch (ex) {
274
- reject(ex);
275
- }
276
- });
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();
277
208
  };
278
209
  ;
279
210
  /**
@@ -281,19 +212,10 @@ var WebAuth = /** @class */ (function () {
281
212
  * @returns
282
213
  */
283
214
  WebAuth.prototype.logoutCallback = function () {
284
- return new Promise(function (resolve, reject) {
285
- try {
286
- if (!window.webAuthSettings && !window.authentication) {
287
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
288
- }
289
- window.authentication.logoutCallback().then(function (resp) {
290
- resolve(resp);
291
- });
292
- }
293
- catch (ex) {
294
- reject(ex);
295
- }
296
- });
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();
297
219
  };
298
220
  ;
299
221
  /**
@@ -301,17 +223,10 @@ var WebAuth = /** @class */ (function () {
301
223
  * @returns
302
224
  */
303
225
  WebAuth.prototype.popupSignOutCallback = function () {
304
- return new Promise(function (resolve, reject) {
305
- try {
306
- if (!window.webAuthSettings && !window.authentication) {
307
- throw new Helper_1.CustomException("Settings or Authentication instance in OIDC cannot be empty", 417);
308
- }
309
- window.authentication.popupSignOutCallback();
310
- }
311
- catch (ex) {
312
- reject(ex);
313
- }
314
- });
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();
315
230
  };
316
231
  ;
317
232
  /**
@@ -322,7 +237,7 @@ var WebAuth = /** @class */ (function () {
322
237
  * // the response will give you login url.
323
238
  * }).catch(function(ex) {
324
239
  * // your failure code here
325
- * });;
240
+ * });
326
241
  * ```
327
242
  */
328
243
  WebAuth.prototype.getLoginURL = function (state) {
@@ -330,7 +245,6 @@ var WebAuth = /** @class */ (function () {
330
245
  try {
331
246
  window.usermanager._client.createSigninRequest({ state: state }).then(function (signinRequest) {
332
247
  resolve(signinRequest.url);
333
- return;
334
248
  });
335
249
  }
336
250
  catch (e) {
@@ -347,7 +261,7 @@ var WebAuth = /** @class */ (function () {
347
261
  * // the response will give you request id.
348
262
  * }).catch(function(ex) {
349
263
  * // your failure code here
350
- * });;
264
+ * });
351
265
  * ```
352
266
  */
353
267
  WebAuth.prototype.getRequestId = function () {
@@ -366,7 +280,7 @@ var WebAuth = /** @class */ (function () {
366
280
  * // the response will give you tenant details
367
281
  * }).catch(function(ex) {
368
282
  * // your failure code here
369
- * });;
283
+ * });
370
284
  * ```
371
285
  */
372
286
  WebAuth.prototype.getTenantInfo = function () {
@@ -385,12 +299,7 @@ var WebAuth = /** @class */ (function () {
385
299
  * ```
386
300
  */
387
301
  WebAuth.prototype.logoutUser = function (options) {
388
- try {
389
- 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;
390
- }
391
- catch (ex) {
392
- throw new Helper_1.CustomException(ex, 417);
393
- }
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;
394
303
  };
395
304
  ;
396
305
  /**
@@ -953,11 +862,31 @@ var WebAuth = /** @class */ (function () {
953
862
  ;
954
863
  /**
955
864
  * getMissingFields
956
- * @param trackId
957
- * @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
+ *
958
881
  */
959
- WebAuth.prototype.getMissingFields = function (trackId) {
960
- 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
+ }
961
890
  };
962
891
  ;
963
892
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cidaas-javascript-sdk",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "author": "cidaas by Widas ID GmbH",
5
5
  "description": "Cidaas native javascript sdk",
6
6
  "license": "MIT",