cidaas-javascript-sdk 5.0.0 → 5.1.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,27 +1,16 @@
1
- # [5.0.0](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v4.3.3...v5.0.0) (2024-12-19)
1
+ # [5.1.0](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v5.0.0...v5.1.0) (2025-11-14)
2
2
 
3
3
 
4
- * feat()!: upgrade to v5 ([e5ac651](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/e5ac65125adbacf1e38dd21af5aad7d000eeb5e3))
4
+ ### Bug Fixes
5
5
 
6
+ * update doc ([9e8f48f](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/9e8f48fbe0a296435e7330a6c0cc22a12d506e06))
6
7
 
7
- ### BREAKING CHANGES
8
8
 
9
- * ### Changed
10
- - **Breaking** Rework library to calls functions from various modules
11
- - **Breaking** Rework renewToken() to store the newly generated token in user storage
12
- - **Breaking** Move setAcceptLanguageHeader function to Helper class
13
- - **Breaking** Rename getUserInfo() to getUserInfoFromStorage()
14
- - **Breaking** Rename getAccessToken() to generateTokenFromCode()
15
- - **Breaking** Standardize enums
16
- - **Breaking** Use enum instead of string for some function parameter
9
+ ### Features
17
10
 
18
- ### Removed
19
- - **Breaking** Removed silentSignin() & silentSignInCallback() function
20
- - **Breaking** Removed popupSignInCallback() & popupSignOutCallback()function
21
- - **Breaking** Removed logoutUser() function
22
- - **Breaking** Removed validateAccessToken() function
23
- - **Breaking** Removed createPreloginWebauth function
24
- - **Breaking** Removed unused & deprecated function parameters
11
+ * **login-service:** improve social login with flexible query parameters ([9492a9e](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/9492a9e52faa6f230662c949039119d84e88df8f))
12
+ * **login-service:** improve social login with flexible query parameters ([21bb073](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/21bb07346878cf2550eeaf258523f1f568270d9c))
13
+ * **login-service:** improve social login with flexible query parameters ([ed7bc6a](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/ed7bc6a46a06ab6bef5d4553e0e78802f2c950e0))
25
14
 
26
15
  # Changelog
27
16
 
package/README.md CHANGED
@@ -13,13 +13,14 @@
13
13
 
14
14
  # Cidaas Javascript SDK
15
15
 
16
- This cidaas Javascript SDK library is built on the top of [OIDC client typescript library](https://github.com/authts/oidc-client-ts).
16
+ This cidaas javascript SDK library is built on the top of [OIDC client typescript library](https://github.com/authts/oidc-client-ts).
17
17
 
18
- Please check the [Changelog](https://github.com/Cidaas/cidaas-sdk-javascript-v2/blob/master/CHANGELOG.md) for more information about the latest release.
18
+ Please check the [Changelog](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/CHANGELOG.md) for more information about the latest release.
19
19
 
20
20
  ## Table of Contents
21
21
 
22
22
  <!--ts-->
23
+ * [Overview](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/overview/overview.md)
23
24
  * [Documentation](https://cidaas.github.io/cidaas-javascript-sdk)
24
25
  * [Installation](#installation)
25
26
  * [Initialisation](#initialisation)
@@ -27,6 +28,14 @@ Please check the [Changelog](https://github.com/Cidaas/cidaas-sdk-javascript-v2/
27
28
  * [Functions Overview](#functions-overview)
28
29
  * [Possible Error](#possible-error)
29
30
 
31
+ ### Overview
32
+
33
+ [Here](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/overview/overview.md) you can find general overview of cidaas javascript SDK
34
+
35
+ ### Documentation
36
+
37
+ [Here](https://cidaas.github.io/cidaas-javascript-sdk) you can find technical documentation of cidaas javascript SDK
38
+
30
39
  ### Installation
31
40
 
32
41
  From CDN
@@ -44,9 +53,9 @@ npm install cidaas-javascript-sdk
44
53
 
45
54
  ### Initialisation
46
55
 
47
- After adding the sdk library, create a local file such as **cidaas.service.ts** and define Cidaas options variable there for initializing cidaas sdk.
56
+ After adding the sdk library, create a local file such as **cidaas.service.ts** and define Oidc settings variable there for initializing cidaas sdk.
48
57
 
49
- Cidaas options variable support every [OIDC Client UserManagerSettings Properties](https://authts.github.io/oidc-client-ts/interfaces/UserManagerSettings.html) which has the following notable properties:
58
+ Oidc settings variable support every [OIDC Client UserManagerSettings Properties](https://authts.github.io/oidc-client-ts/interfaces/UserManagerSettings.html) which has the following notable properties:
50
59
 
51
60
  | Property Name | Required | Description |
52
61
  | ------ | ------ | ------ |
@@ -58,7 +67,7 @@ Cidaas options variable support every [OIDC Client UserManagerSettings Propertie
58
67
  | userStore | no | define where authenticated user information will be saved on the client application. The default value is session storage if no properties is being sent. |
59
68
  | automaticSilentRenew | no | configure whether automatic token renewal will be activated. The default value is true. |
60
69
 
61
- an example of Cidaas options variable looks like this:
70
+ an example of Oidc settings variable looks like this:
62
71
 
63
72
  ```js
64
73
  const options = {
@@ -79,9 +88,9 @@ The following storages are supported to store authenticated user information, su
79
88
 
80
89
  additionally, user can also define custom storage in the client side by implementing Storage class.
81
90
 
82
- If there is no userStore properties being send in Cidaas options variable, it will use session storage by default.
91
+ If there is no userStore properties being send in Oidc settings variable, it will use session storage by default.
83
92
 
84
- In case local storage is prefered to be used, then Cidaas options can be modified as following:
93
+ In case local storage is prefered to be used, then Oidc settings can be modified as following:
85
94
 
86
95
  ```js
87
96
  const options = {
@@ -105,7 +114,7 @@ see [usage](#get-tokens-and-user-profile-information-from-user-storage) to get t
105
114
 
106
115
  ### Configure automatic token renewal (Optional)
107
116
 
108
- By default, The SDK will generate new tokens based on refresh token stored in user storage, one minute before the access token is expiring. To disable this behaviour, Cidaas options can be modified as following:
117
+ By default, The SDK will generate new tokens based on refresh token stored in user storage, one minute before the access token is expiring. To disable this behaviour, Oidc settings can be modified as following:
109
118
 
110
119
  ```js
111
120
  const options = {
@@ -117,7 +126,7 @@ const options = {
117
126
 
118
127
  ### Initialise the cidaas sdk using the configured options mentioned above:
119
128
 
120
- Cidaas ConfigUserProvider have to be initialise to be added to each of the modules as dependencies:
129
+ Cidaas ConfigUserProvider have to be initialised to be added to each of the modules as dependencies:
121
130
 
122
131
  Example of Cidaas Service:
123
132
  ```js
@@ -137,7 +146,7 @@ export class CidaasService {
137
146
  }
138
147
 
139
148
  // get authentication module
140
- getAuthentication() {
149
+ getAuthenticationService() {
141
150
  return this.authenticationService;
142
151
  }
143
152
 
@@ -169,8 +178,6 @@ this.cidaasVerificationService.getMFAList(getMFAListOptions);
169
178
 
170
179
  ```
171
180
 
172
- Each of the functions and its module can be looked in the doc.
173
-
174
181
  ### Usage
175
182
 
176
183
  #### Login With Browser
@@ -181,7 +188,46 @@ To login through cidaas sdk, call **loginWithBrowser()**. This will redirect you
181
188
  cidaasAuthenticationService.loginWithBrowser();
182
189
  ```
183
190
 
184
- once login is successful, it will automatically redirects you to redirect_uri you have configured in cidaas options. You will get information such as code & state as redirect url parameter (query or fragment), which is needed to get access token.
191
+ once login is successful, it will automatically redirects you to redirect_uri you have configured in Oidc settings. You will get information such as code & state as redirect url parameter (query or fragment), which is needed to get access token.
192
+
193
+ To complete the login process, call **logincallback()**.
194
+
195
+ ```js
196
+ cidaasAuthenticationService.loginCallback().then(function(response) {
197
+ // the response will give you login details.
198
+ }).catch(function(ex) {
199
+ // your failure code here
200
+ });
201
+ ```
202
+
203
+ After successful loginCallback, You will get access token, along with id token and refresh token in the json response, depends on your application configuration.
204
+
205
+ #### Login With Social Provider
206
+
207
+ To login with social providers (e.g., Facebook, Google, LinkedIn), initialize the LoginService module and call **loginWithSocial()**. This will redirect you to the social provider's login page.
208
+
209
+ ```js
210
+ cidaasLoginService.loginWithSocial({
211
+ provider: 'facebook',
212
+ requestId: 'your requestId'
213
+ });
214
+ ```
215
+
216
+ You can also pass optional query parameters:
217
+
218
+ ```js
219
+ cidaasLoginService.loginWithSocial({
220
+ provider: 'facebook',
221
+ requestId: 'your requestId'
222
+ }, {
223
+ dc: 'device-capacity',
224
+ device_fp: 'device-fingerprint',
225
+ // Any additional custom query parameters
226
+ customParam: 'customValue'
227
+ });
228
+ ```
229
+
230
+ once login is successful, it will automatically redirects you to redirect_uri you have configured in Oidc settings. You will get information such as code & state as redirect url parameter (query or fragment), which is needed to get access token.
185
231
 
186
232
  To complete the login process, call **logincallback()**.
187
233
 
@@ -211,7 +257,7 @@ cidaasAuthenticationService.getUserInfoFromStorage().then(function(response) {
211
257
 
212
258
  ### Functions Overview
213
259
 
214
- Cidaas Javascript SDK Functions can be found on the [documentation](https://cidaas.github.io/cidaas-javascript-sdk).
260
+ Cidaas javascript SDK functions can be found on the [documentation](https://cidaas.github.io/cidaas-javascript-sdk).
215
261
 
216
262
  ## Possible Error
217
263
 
@@ -42,15 +42,31 @@ class LoginService {
42
42
  * ```
43
43
  */
44
44
  loginWithSocial(options, queryParams) {
45
+ if (!options.provider || !options.requestId) {
46
+ throw new Helper_1.CustomException("provider and requestId cannot be empty", 417);
47
+ }
45
48
  try {
46
49
  let _serviceURL = this.config.authority + "/login-srv/social/login/" + options.provider.toLowerCase() + "/" + options.requestId;
47
- if (queryParams && queryParams.dc && queryParams.device_fp) {
48
- _serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
50
+ if (queryParams) {
51
+ const params = new URLSearchParams();
52
+ Object.keys(queryParams).forEach(key => {
53
+ const value = queryParams[key];
54
+ if (value !== undefined && value !== null && value !== '') {
55
+ params.append(key, value);
56
+ }
57
+ });
58
+ const queryString = params.toString();
59
+ if (queryString) {
60
+ _serviceURL = _serviceURL + "?" + queryString;
61
+ }
49
62
  }
50
63
  window.location.href = _serviceURL;
51
64
  }
52
65
  catch (ex) {
53
- console.log(ex);
66
+ if (ex instanceof Helper_1.CustomException) {
67
+ throw ex;
68
+ }
69
+ throw new Helper_1.CustomException(String(ex), 417);
54
70
  }
55
71
  }
56
72
  /**
@@ -69,15 +85,31 @@ class LoginService {
69
85
  * ```
70
86
  */
71
87
  registerWithSocial(options, queryParams) {
88
+ if (!options.provider || !options.requestId) {
89
+ throw new Helper_1.CustomException("provider and requestId cannot be empty", 417);
90
+ }
72
91
  try {
73
92
  let _serviceURL = this.config.authority + "/login-srv/social/register/" + options.provider.toLowerCase() + "/" + options.requestId;
74
- if (queryParams && queryParams.dc && queryParams.device_fp) {
75
- _serviceURL = _serviceURL + "?dc=" + queryParams.dc + "&device_fp=" + queryParams.device_fp;
93
+ if (queryParams) {
94
+ const params = new URLSearchParams();
95
+ Object.keys(queryParams).forEach(key => {
96
+ const value = queryParams[key];
97
+ if (value !== undefined && value !== null && value !== '') {
98
+ params.append(key, value);
99
+ }
100
+ });
101
+ const queryString = params.toString();
102
+ if (queryString) {
103
+ _serviceURL = _serviceURL + "?" + queryString;
104
+ }
76
105
  }
77
106
  window.location.href = _serviceURL;
78
107
  }
79
108
  catch (ex) {
80
- console.log(ex);
109
+ if (ex instanceof Helper_1.CustomException) {
110
+ throw ex;
111
+ }
112
+ throw new Helper_1.CustomException(String(ex), 417);
81
113
  }
82
114
  }
83
115
  /**
@@ -45,6 +45,8 @@ export interface SocialProviderQueryParameter {
45
45
  dc?: string;
46
46
  /** Device finger print */
47
47
  device_fp?: string;
48
+ /** Additional custom query parameters */
49
+ [key: string]: string | undefined;
48
50
  }
49
51
  export interface PasswordlessLoginRequest {
50
52
  /** Request id returned from the authorization call */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cidaas-javascript-sdk",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "author": "cidaas by Widas ID GmbH",
5
5
  "description": "Cidaas native javascript sdk",
6
6
  "license": "MIT",