cidaas-javascript-sdk 5.0.0 → 5.1.2
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,29 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
## [5.1.2](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v5.1.1...v5.1.2) (2026-02-25)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
### Bug Fixes
|
|
5
5
|
|
|
6
|
+
* semantic release format ([c9a9045](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/c9a90453672be396b6852ba2519f6bdbc377e21d))
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
# Changelog
|
|
8
9
|
|
|
9
|
-
|
|
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
|
|
10
|
+
## V5.1.1
|
|
17
11
|
|
|
18
|
-
###
|
|
19
|
-
-
|
|
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
|
|
12
|
+
### Fixed
|
|
13
|
+
- api adjustments for initiateAccountVerification(), verifyAccount(), getAllVerificationList(), initiateMFA(), authenticateMFA()
|
|
25
14
|
|
|
26
|
-
|
|
15
|
+
## V5.1.0
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- improve social login with flexible query parameters
|
|
19
|
+
- update doc
|
|
27
20
|
|
|
28
21
|
## V5.0.0
|
|
29
22
|
|
package/README.md
CHANGED
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
# Cidaas Javascript SDK
|
|
15
15
|
|
|
16
|
-
This cidaas
|
|
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-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
48
|
-
|
|
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
|
-
|
|
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
|
|
75
|
-
|
|
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
|
-
|
|
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 */
|
|
@@ -65,6 +67,10 @@ export interface PasswordlessLoginRequest {
|
|
|
65
67
|
* Either sub or q have to be provided, depends on what is given from the query parameter.
|
|
66
68
|
*/
|
|
67
69
|
q?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Link id used to complete Account Linking after successful authentication
|
|
72
|
+
*/
|
|
73
|
+
'link-id'?: string;
|
|
68
74
|
}
|
|
69
75
|
export interface FirstTimeChangePasswordRequest {
|
|
70
76
|
/** Old password to be changed */
|
|
@@ -26,7 +26,7 @@ class VerificationService {
|
|
|
26
26
|
*/
|
|
27
27
|
initiateAccountVerification(options) {
|
|
28
28
|
try {
|
|
29
|
-
const url = this.config.authority
|
|
29
|
+
const url = `${this.config.authority}/verification-actions-srv/account/initiation`;
|
|
30
30
|
const form = Helper_1.Helper.createForm(url, options);
|
|
31
31
|
document.body.appendChild(form);
|
|
32
32
|
form.submit();
|
|
@@ -51,7 +51,7 @@ class VerificationService {
|
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
53
|
verifyAccount(options, headers) {
|
|
54
|
-
const _serviceURL = this.config.authority
|
|
54
|
+
const _serviceURL = `${this.config.authority}/verification-actions-srv/account`;
|
|
55
55
|
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", undefined, headers);
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -112,7 +112,7 @@ class VerificationService {
|
|
|
112
112
|
* ```
|
|
113
113
|
*/
|
|
114
114
|
getAllVerificationList(access_token, headers) {
|
|
115
|
-
const _serviceURL = `${this.config.authority}/verification-srv/config
|
|
115
|
+
const _serviceURL = `${this.config.authority}/verification-actions-srv/config`;
|
|
116
116
|
if (access_token) {
|
|
117
117
|
return Helper_1.Helper.createHttpPromise(undefined, _serviceURL, undefined, "GET", access_token, headers);
|
|
118
118
|
}
|
|
@@ -244,7 +244,7 @@ class VerificationService {
|
|
|
244
244
|
* ```
|
|
245
245
|
*/
|
|
246
246
|
initiateMFA(options, headers) {
|
|
247
|
-
const _serviceURL = this.config.authority
|
|
247
|
+
const _serviceURL = `${this.config.authority}/verification-srv/authentication/${options.type}/initiation`;
|
|
248
248
|
return Helper_1.Helper.createHttpPromise(options, _serviceURL, false, "POST", undefined, headers);
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
@@ -266,7 +266,7 @@ class VerificationService {
|
|
|
266
266
|
* ```
|
|
267
267
|
*/
|
|
268
268
|
authenticateMFA(options, headers) {
|
|
269
|
-
const _serviceURL = this.config.authority
|
|
269
|
+
const _serviceURL = `${this.config.authority}/verification-srv/authentication/${options.type}/verification`;
|
|
270
270
|
return Helper_1.Helper.createHttpPromise(options, _serviceURL, undefined, "POST", undefined, headers);
|
|
271
271
|
}
|
|
272
272
|
/**
|