cidaas-javascript-sdk 4.3.3 → 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.
Files changed (51) hide show
  1. package/CHANGELOG.md +40 -4
  2. package/README.md +156 -94
  3. package/dist/authentication-service/AuthenticationService.d.ts +140 -0
  4. package/dist/authentication-service/AuthenticationService.js +210 -0
  5. package/dist/{authentication/Authentication.model.d.ts → authentication-service/AuthenticationService.model.d.ts} +18 -12
  6. package/dist/{authentication/Authentication.model.js → authentication-service/AuthenticationService.model.js} +2 -2
  7. package/dist/common/Common.model.d.ts +15 -19
  8. package/dist/common/Common.model.js +17 -17
  9. package/dist/common/ConfigUserProvider.d.ts +10 -0
  10. package/dist/common/ConfigUserProvider.js +28 -0
  11. package/dist/common/Helper.d.ts +7 -0
  12. package/dist/common/Helper.js +19 -0
  13. package/dist/common/User.model.d.ts +0 -4
  14. package/dist/consent-service/ConsentService.d.ts +99 -95
  15. package/dist/consent-service/ConsentService.js +125 -122
  16. package/dist/consent-service/ConsentService.model.d.ts +14 -16
  17. package/dist/device-service/DeviceService.d.ts +49 -0
  18. package/dist/device-service/DeviceService.js +79 -0
  19. package/dist/device-service/DeviceService.model.d.ts +6 -0
  20. package/dist/id-validation-service/IdValidationService.d.ts +28 -0
  21. package/dist/id-validation-service/IdValidationService.js +59 -0
  22. package/dist/id-validation-service/IdValidationService.model.d.ts +8 -0
  23. package/dist/id-validation-service/IdValidationService.model.js +2 -0
  24. package/dist/index.d.ts +22 -3
  25. package/dist/index.js +35 -18
  26. package/dist/login-service/LoginService.d.ts +143 -141
  27. package/dist/login-service/LoginService.js +255 -232
  28. package/dist/login-service/LoginService.model.d.ts +9 -51
  29. package/dist/login-service/LoginService.model.js +1 -1
  30. package/dist/public-service/PublicService.d.ts +57 -0
  31. package/dist/public-service/PublicService.js +73 -0
  32. package/dist/public-service/PublicService.model.d.ts +20 -0
  33. package/dist/public-service/PublicService.model.js +2 -0
  34. package/dist/token-service/TokenService.d.ts +104 -138
  35. package/dist/token-service/TokenService.js +164 -219
  36. package/dist/token-service/TokenService.model.d.ts +3 -44
  37. package/dist/token-service/TokenService.model.js +3 -16
  38. package/dist/user-service/UserService.d.ts +381 -315
  39. package/dist/user-service/UserService.js +552 -426
  40. package/dist/user-service/UserService.model.d.ts +48 -14
  41. package/dist/user-service/UserService.model.js +4 -4
  42. package/dist/verification-service/VerificationService.d.ts +281 -223
  43. package/dist/verification-service/VerificationService.js +343 -287
  44. package/dist/verification-service/VerificationService.model.d.ts +4 -5
  45. package/package.json +6 -4
  46. package/dist/authentication/Authentication.d.ts +0 -139
  47. package/dist/authentication/Authentication.js +0 -186
  48. package/dist/web-auth/WebAuth.d.ts +0 -665
  49. package/dist/web-auth/WebAuth.js +0 -955
  50. package/dist/web-auth/webauth.model.d.ts +0 -66
  51. /package/dist/{web-auth/webauth.model.js → device-service/DeviceService.model.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,13 +1,49 @@
1
- ## [4.3.3](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/compare/v4.3.2...v4.3.3) (2024-11-28)
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
4
  ### Bug Fixes
5
5
 
6
- * fix vulnerabilty from npm audit ([2f8e0c5](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/2f8e0c5498e45d865ad4bdca8005339d5857c37e))
7
- * semantic release format ([0d8b601](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/0d8b6014a673098a44d18297777ce1c65ba35602))
6
+ * update doc ([9e8f48f](https://gitlab.widas.de/cidaas-public-devkits/cidaas-public-sdks/cidaas-javascript-sdk/commit/9e8f48fbe0a296435e7330a6c0cc22a12d506e06))
7
+
8
+
9
+ ### Features
10
+
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))
8
14
 
9
15
  # Changelog
10
16
 
17
+ ## V5.0.0
18
+
19
+ If you are upgrading from v4.x.x, please see [UPGRADING.md](UPGRADING_V5.md)
20
+
21
+ ### Fixed
22
+ - Fix vulnerabilities from `npm audit`
23
+
24
+ ### Added
25
+ - Add invokeIdValidationCase() function
26
+ - Add [documentation](https://cidaas.github.io/cidaas-javascript-sdk) generated by typedoc
27
+
28
+ ### Changed
29
+ - Support tokens from predefined user storage
30
+ - Use latest version of oidc client ts library
31
+ - **Breaking** Rework library to calls functions from various modules
32
+ - **Breaking** Rework renewToken() to store the newly generated token in user storage
33
+ - **Breaking** Move setAcceptLanguageHeader function to Helper class
34
+ - **Breaking** Rename getUserInfo() to getUserInfoFromStorage()
35
+ - **Breaking** Rename getAccessToken() to generateTokenFromCode()
36
+ - **Breaking** Standardize enums
37
+ - **Breaking** Use enum instead of string for some function parameter
38
+
39
+ ### Removed
40
+ - **Breaking** Removed silentSignin() & silentSignInCallback() function
41
+ - **Breaking** Removed popupSignInCallback() & popupSignOutCallback()function
42
+ - **Breaking** Removed logoutUser() function
43
+ - **Breaking** Removed validateAccessToken() function
44
+ - **Breaking** Removed createPreloginWebauth function
45
+ - **Breaking** Removed unused & deprecated function parameters
46
+
11
47
  ## V4.3.3
12
48
 
13
49
  ## Changed
@@ -111,7 +147,7 @@
111
147
 
112
148
  ## V4.0.0
113
149
 
114
- If you are upgrading from v3.x.x, please see ['UPGRADING.md'](UPGRADING.md)
150
+ If you are upgrading from v3.x.x, please see [UPGRADING.md](UPGRADING_V4.md)
115
151
 
116
152
  ### Fixed
117
153
  - fix vulnerabilities from `npm audit`
package/README.md CHANGED
@@ -13,28 +13,29 @@
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)
24
+ * [Documentation](https://cidaas.github.io/cidaas-javascript-sdk)
23
25
  * [Installation](#installation)
24
26
  * [Initialisation](#initialisation)
25
27
  * [Usage](#usage)
26
28
  * [Functions Overview](#functions-overview)
27
- <!--ts-->
28
- * [Authentication Functions](#authentication-functions)
29
- * [Login Management](#login-management)
30
- * [User Management](#user-management)
31
- * [Token Management](#token-management)
32
- * [Verification Management](#verification-management)
33
- * [Consent Management](#consent-management)
34
- * [Other Functionality](#other-functionality)
35
- <!--te-->
36
29
  * [Possible Error](#possible-error)
37
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
+
38
39
  ### Installation
39
40
 
40
41
  From CDN
@@ -52,9 +53,9 @@ npm install cidaas-javascript-sdk
52
53
 
53
54
  ### Initialisation
54
55
 
55
- 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.
56
57
 
57
- 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:
58
59
 
59
60
  | Property Name | Required | Description |
60
61
  | ------ | ------ | ------ |
@@ -63,8 +64,10 @@ Cidaas options variable support every [OIDC Client UserManagerSettings Propertie
63
64
  | redirect_uri | yes | URL to be redirected after successful login attempt. |
64
65
  | post_logout_redirect_uri | no | URL to be redirected after successful logout attempt. |
65
66
  | scope | no | the scope the application requires and requests from cidaas. The default value is 'openid' if no properties is being sent. |
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. |
68
+ | automaticSilentRenew | no | configure whether automatic token renewal will be activated. The default value is true. |
66
69
 
67
- an example of Cidaas options variable looks like this:
70
+ an example of Oidc settings variable looks like this:
68
71
 
69
72
  ```js
70
73
  const options = {
@@ -76,10 +79,103 @@ const options = {
76
79
  }
77
80
  ```
78
81
 
82
+ ### Configure user storage (Optional)
83
+
84
+ The following storages are supported to store authenticated user information, such as tokens information & user profile:
85
+ * window.sessionStorage (default)
86
+ * window.localStorage
87
+ * InMemoryWebStorage (all Information will be cleared after browser refresh) in case user do not want to save token in window object
88
+
89
+ additionally, user can also define custom storage in the client side by implementing Storage class.
90
+
91
+ If there is no userStore properties being send in Oidc settings variable, it will use session storage by default.
92
+
93
+ In case local storage is prefered to be used, then Oidc settings can be modified as following:
94
+
95
+ ```js
96
+ const options = {
97
+ authority: 'your domain base url',
98
+ ...,
99
+ userStore: new WebStorageStateStore({ store: window.localStorage })
100
+ }
101
+ ```
102
+
103
+ In case custom solution for storing authenticated user information is being used, or saving the token in memory is preferred, you can configured userStore with InMemoryWebStorage. Authenticated user information will be cleared as soon as the page is refreshed afterwards.
104
+
105
+ ```js
106
+ const options = {
107
+ authority: 'your domain base url',
108
+ ...,
109
+ userStore: new WebStorageStateStore({ store: new InMemoryWebStorage()})
110
+ }
111
+ ```
112
+
113
+ see [usage](#get-tokens-and-user-profile-information-from-user-storage) to get the stored informations from user storage.
114
+
115
+ ### Configure automatic token renewal (Optional)
116
+
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:
118
+
119
+ ```js
120
+ const options = {
121
+ authority: 'your domain base url',
122
+ ...,
123
+ automaticSilentRenew: false
124
+ }
125
+ ```
126
+
79
127
  ### Initialise the cidaas sdk using the configured options mentioned above:
80
128
 
129
+ Cidaas ConfigUserProvider have to be initialised to be added to each of the modules as dependencies:
130
+
131
+ Example of Cidaas Service:
81
132
  ```js
82
- const cidaas = new CidaasSDK.WebAuth(options);
133
+ export class CidaasService {
134
+ cidaasConfigUserProvider: ConfigUserProvider;
135
+ authenticationService: AuthenticationService;
136
+ verificationService: VerificationService;
137
+ options: OidcSettings = { ... };
138
+
139
+ constructor() {
140
+ // init ConfigUserProvider
141
+ this.cidaasConfigUserProvider = new ConfigUserProvider(this.options);
142
+ // init authentication module
143
+ this.authenticationService = new AuthenticationService(this.cidaasConfigUserProvider);
144
+ // init verification module
145
+ this.verificationService = new VerificationService(this.cidaasConfigUserProvider);
146
+ }
147
+
148
+ // get authentication module
149
+ getAuthenticationService() {
150
+ return this.authenticationService;
151
+ }
152
+
153
+ // get verification module
154
+ getVerificationService() {
155
+ return this.verificationService
156
+ }
157
+ }
158
+ ```
159
+
160
+ Usage in Component:
161
+ ```js
162
+ // inject cidaas service
163
+ constructor(private cidaasService: CidaasService, ...) {}
164
+
165
+ ...
166
+
167
+ // init each of cidaas modules which are needed in the component
168
+ this.cidaasAuthenticationService = this.cidaasService.getAuthenticationService();
169
+ this.cidaasVerificationService = this.cidaasService.getVerificationService();
170
+
171
+ ...
172
+
173
+ // call functions from each of the modules
174
+ this.cidaasAuthenticationService.loginCallback();
175
+ ...
176
+ this.cidaasVerificationService.getMFAList(getMFAListOptions);
177
+ ...
178
+
83
179
  ```
84
180
 
85
181
  ### Usage
@@ -89,15 +185,15 @@ const cidaas = new CidaasSDK.WebAuth(options);
89
185
  To login through cidaas sdk, call **loginWithBrowser()**. This will redirect you to the hosted login page.
90
186
 
91
187
  ```js
92
- cidaas.loginWithBrowser();
188
+ cidaasAuthenticationService.loginWithBrowser();
93
189
  ```
94
190
 
95
- 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.
96
192
 
97
193
  To complete the login process, call **logincallback()**.
98
194
 
99
195
  ```js
100
- cidaas.loginCallback().then(function(response) {
196
+ cidaasAuthenticationService.loginCallback().then(function(response) {
101
197
  // the response will give you login details.
102
198
  }).catch(function(ex) {
103
199
  // your failure code here
@@ -106,96 +202,62 @@ cidaas.loginCallback().then(function(response) {
106
202
 
107
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.
108
204
 
109
- There are code documentations for each of the functions with example code of how to call them individually.
110
-
111
- ### Functions Overview
112
-
113
- Cidaas Javascript SDK features the following functionality:
114
-
115
- #### Authentication Functions
205
+ #### Login With Social Provider
116
206
 
117
- The SDK offers multiple way to authenticate user. Whether using browser redirection, in a pop up window, or in an iframe for silent sign in. The functions for authentication could be found [here](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/src/main/authentication/Authentication.ts)
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.
118
208
 
119
- | SDK Functions | Description |
120
- |----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
121
- | loginWithBrowser, registerWithBrowser, loginCallback, logout, logoutCallback | The SDK support browser redirection for authenticating user. The authentication process will then happens in a new tab. This is the default authentication function of the SDK |
122
- | popupSignIn, popupSignInCallback, popupSignOut, popupSignOutCallback | The SDK support using pop up window for authenticating user. The authentication process will then happens in a new popup window |
123
- | silentSignIn, silentSignInCallback | The SDK support silent authentication. The authentication process will then happens in an iframe. |
124
-
125
- #### Login Management
126
-
127
- The login functions could be found [here](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/src/main/login-service/LoginService.ts). The SDK support the following login management functions:
128
-
129
- | SDK Functions | Description |
130
- |----------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
131
- | passwordlessLogin, loginWithCredentials, loginWithSocial | User could authenticate themselves using passwordless authentication, classic password credentials, as well as using social provider such as google or social media platform |
132
- | loginPrecheck, consentContinue, firstTimeChangePassword, mfaContinue | Depending on the missing information from loginPrecheck, user will be redirected to another page after login to either accepting consent, changing password, continuing MFA process, or do progressive registration |
133
- | getMissingFields, progressiveRegistration | In case a new required field is added in registration settings, it is possible to use the sdk to inform user of the changes and asked them to fill in the missing required fields by the next login |
134
- | loginAfterRegister | By calling this sdk function, user could directly login to the app after successful registration |
135
- | actionGuestLogin | If user has guestLoginForm prepared, it could be called using this function |
136
-
137
- #### User Management
138
-
139
- The user functions could be found [here](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/src/main/user-service/UserService.ts). The SDK support the following user management functions:
140
-
141
- | SDK Functions | Description |
142
- |-------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
143
- | getRegistrationSetup, register, registerWithSocial | Registering a new user is possible by using classic registration (getting registration fields information & call register function) or by using social provider |
144
- | getUserProfile, getInviteUserDetails, getCommunicationStatus, updateProfile, updateProfileImage, deleteUserAccount, userCheckExists | To maintain user, functions for getting user information by using cidaas internal api, updating user information, removing user, as well as check if user exist are supported |
145
- | getUserInfo | The SDK could be used to get user information by using oidc client ts library |
146
- | getUserActivities | In case user want to see the history of his activities, getUserActivities function is provided |
147
- | initiateResetPassword, handleResetPassword, resetPassword | In case user want to reset password, password reset flow is supported. From initiating the reset password, handling the code or link which has been sent to predefined medium such as email, sms & ivr, and finishing up the reset password |
148
- | changePassword | In case user want to change password, changePassword function is provided |
149
- | registerDeduplication, deduplicationLogin, getDeduplicationDetails | In case a new user is registered with similiar information as existing user, deduplication could be activated to either proceed with the registration, or combine the user with an existing one |
150
- | initiateLinkAccount, completeLinkAccount, unlinkAccount, getLinkedUsers | Linking und unlinking user account with another account, as well as getting linked user is supported |
209
+ ```js
210
+ cidaasLoginService.loginWithSocial({
211
+ provider: 'facebook',
212
+ requestId: 'your requestId'
213
+ });
214
+ ```
151
215
 
152
- #### Token Management
216
+ You can also pass optional query parameters:
153
217
 
154
- The token functions could be found [here](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/src/main/token-service/TokenService.ts). The SDK support the following token management functions:
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
+ ```
155
229
 
156
- | SDK Functions | Description |
157
- |--------------------------------------|-----------------------------------------------------------------------------------------------------|
158
- | getAccessToken | The SDK facilitate login using PKCE flow by exchanging code after succesful login with access token |
159
- | renewToken | Session renewal is possible by using refresh token |
160
- | initiateDeviceCode, deviceCodeVerify | Device code flow is supported for authenticating user without user interaction possibilty in device |
161
- | validateAccessToken | Token validation could be done by using introspection endpoint |
162
- | offlineTokenCheck | To save API call, offline token check function could be used |
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.
163
231
 
164
- #### Verification Management
232
+ To complete the login process, call **logincallback()**.
165
233
 
166
- The verification functions could be found [here](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/src/main/verification-service/VerificationService.ts). The SDK support the following verification management functions:
234
+ ```js
235
+ cidaasAuthenticationService.loginCallback().then(function(response) {
236
+ // the response will give you login details.
237
+ }).catch(function(ex) {
238
+ // your failure code here
239
+ });
240
+ ```
167
241
 
168
- | SDK Functions | Description |
169
- |---------------------------------------------------------------------|---------------------------------------------------------------------------------------|
170
- | initiateMFA, authenticateMFA | The SDK support initiating & authenticating MFA, which starts passwordless login flow |
171
- | initiateAccountVerification, verifyAccount | User account verification using preconfigured MFA is supported |
172
- | cancelMFA | MFA process could be aborted in case something go the wrong way |
173
- | getAllVerificationList, getMFAList, checkVerificationTypeConfigured | Information about every supported MFA Verification types, List of configured MFA, and details about particular configured verification type are provided by the SDK |
174
- | initiateEnrollment, enrollVerification, getEnrollmentStatus | Additional MFA verification type could be enrolled using the sdk |
175
- | initiateVerification, configureVerification, configureFriendlyName | The SDK support configuring verification request as well as friendly name |
242
+ After successful loginCallback, You will get access token, along with id token and refresh token in the json response, depends on your application configuration.
176
243
 
177
- #### Consent Management
244
+ There are code documentations for each of the functions with example code of how to call them individually.
178
245
 
179
- The consent functions could be found [here](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/src/main/consent-service/ConsentService.ts). The SDK support the following consent management functions:
246
+ #### Get Tokens And User Profile Information From User Storage
180
247
 
181
- | SDK Functions | Description |
182
- |---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
183
- | getConsentDetails, getConsentVersionDetails | The SDK could be used to get consent details as well as details of consent's version |
184
- | acceptConsent, acceptScopeConsent, acceptClaimConsent, revokeClaimConsent | The SDK support accepting consent (app level consent, scope consent or claim consent) as well as revoke claim consent |
248
+ To get information from user storage, call **getUserInfoFromStorage()**. This function will fetch stored information from predefined user storage (session storage, local storage or in memory)
185
249
 
186
- #### Other Functionality
250
+ ```js
251
+ cidaasAuthenticationService.getUserInfoFromStorage().then(function(response) {
252
+ // the response will contains tokens & user profile information.
253
+ }).catch(function(ex) {
254
+ // your failure code here
255
+ });
256
+ ```
187
257
 
188
- general SDK functions could be found [here](https://github.com/Cidaas/cidaas-javascript-sdk/blob/master/src/main/web-auth/WebAuth.ts). The SDK support the following other functionality:
258
+ ### Functions Overview
189
259
 
190
- | SDK Functions | Description |
191
- |------------------------------------------------|---------------------------------------------------------------------------------------------|
192
- | getRequestId | The SDK could be used to get request id, which is required as input to call other functions |
193
- | getLoginURL | Getting login authz url is supported by the SDK |
194
- | getTenantInfo, getClientInfo | Getting public information such as tenant info & client info is supported by the SDK |
195
- | setAcceptLanguageHeader | The SDK could be used to change response language |
196
- | createDeviceInfo, getDevicesInfo, deleteDevice | Creating, getting, and removing device information is supported by the SDK |
197
- | logoutUser | The SDK could be used to end user session by using cidaas internal api |
198
- | userActionOnEnrollment | The SDK could be used to run predefined action after enrollment |
260
+ Cidaas javascript SDK functions can be found on the [documentation](https://cidaas.github.io/cidaas-javascript-sdk).
199
261
 
200
262
  ## Possible Error
201
263
 
@@ -0,0 +1,140 @@
1
+ import ConfigUserProvider from '../common/ConfigUserProvider';
2
+ import { OidcManager, OidcSettings, LoginRedirectOptions, LogoutRedirectOptions, PopupSignInOptions, PopupSignOutOptions, RenewTokenOptions, User, LogoutResponse, LoginRequestOptions } from './AuthenticationService.model';
3
+ export declare class AuthenticationService {
4
+ userManager: OidcManager;
5
+ config: OidcSettings;
6
+ configUserProvider: ConfigUserProvider;
7
+ constructor(configUserProvider: ConfigUserProvider);
8
+ /**
9
+ * To register through cidaas sdk, call **registerWithBrowser()**. This will generate and redirect the app to authz url in same window for register view.
10
+ * Afterwards you will be redirected to the hosted registration page.
11
+ * @example
12
+ * ```js
13
+ * cidaasAuthenticationService.registerWithBrowser();
14
+ * ```
15
+ * @param {LoginRedirectOptions} options to over-ride the client config for redirect login
16
+ */
17
+ registerWithBrowser(options?: LoginRedirectOptions): Promise<void>;
18
+ /**
19
+ * To login through cidaas sdk, call **loginWithBrowser()**. This will generate and redirect the app to authz url in same window for logging in. Afterwards you will be redirected to the hosted login page.
20
+ * Once login successful, it will automatically redirects you to the redirect url, which is configured in cidaas config.
21
+ * @example
22
+ * ```js
23
+ * cidaasAuthenticationService.loginWithBrowser();
24
+ * ```
25
+ * @param {LoginRedirectOptions} options to over-ride the client config for redirect login
26
+ */
27
+ loginWithBrowser(options?: LoginRedirectOptions): Promise<void>;
28
+ /**
29
+ * To open the hosted login page in pop up window, call **popupSignIn()**. This will generate and open authz url in a popup window.
30
+ * On successful sign in, authenticated user is returned.
31
+ * @example
32
+ * ```js
33
+ * cidaasAuthenticationService.popupSignIn().then(function (response) {
34
+ * // the response will give you user details after finishing loginCallback().
35
+ * }).catch(function(ex) {
36
+ * // your failure code here
37
+ * });
38
+ * ```
39
+ * @param {PopupSignInOptions} options optional options to over-ride the client config for popup sign in
40
+ */
41
+ popupSignIn(options?: PopupSignInOptions): Promise<User>;
42
+ /**
43
+ * Once login successful, it will automatically redirects you to the redirect url, which is configured in cidaas config.
44
+ * To complete the login process, call **loginCallback()**. This will parses needed informations such as tokens in the redirect url.
45
+ *
46
+ * @example
47
+ * ```js
48
+ * cidaasAuthenticationService.loginCallback().then(function (response: User) {
49
+ * // the response will give you login details.
50
+ * }).catch(function(ex) {
51
+ * // your failure code here
52
+ * });
53
+ * ```
54
+ * @param {string} url optional url to read sign in state from
55
+ */
56
+ loginCallback(url?: string): Promise<import("oidc-client-ts").User>;
57
+ /**
58
+ * To end user session, call **logout()**. You need set the redirect url, if not it will automatically redirect to the login page
59
+ * @example
60
+ * ```js
61
+ * cidaasAuthenticationService.logout();
62
+ * ```
63
+ * @param {LogoutRedirectOptions} options optional logout options to override cidaas configuration
64
+ */
65
+ logout(options?: LogoutRedirectOptions): Promise<void>;
66
+ /**
67
+ * To open the hosted logout page in pop up window, call **popupSignOut()**.
68
+ * @example
69
+ * ```js
70
+ * cidaasAuthenticationService.popupSignOut().then(function() {
71
+ * // success callback in main application window after finishing popupSignOutCallback().
72
+ * }).catch(function(ex) {
73
+ * // your failure code here
74
+ * });
75
+ * ```
76
+ *
77
+ * @param {PopupSignOutOptions} options optional logout options to override cidaas configuration
78
+ */
79
+ popupSignOut(options?: PopupSignOutOptions): Promise<void>;
80
+ /**
81
+ * **logoutCallback()** will parses the details of userState after logout.
82
+ * Get the logout call state from the url provided, if none is provided current window url is used.
83
+ * @example
84
+ * ```js
85
+ * cidaasAuthenticationService.logoutCallback().then(function (response: LogoutResponse) {
86
+ * // the response will give you userState details.
87
+ * }).catch(function(ex) {
88
+ * // your failure code here
89
+ * });
90
+ * ```
91
+ * @param {string} url optional url to read signout state from,
92
+ * @param {boolean} keepopen optional boolean to keep the popup window open after logout, in case of popupSignOut()
93
+ */
94
+ logoutCallback(url?: string, keepopen?: boolean): Promise<LogoutResponse | undefined>;
95
+ /**
96
+ * **renewToken()** will update user information in user storage with a new token, based on refresh token that is stored in the storage.
97
+ * On successful token renewal, authenticated user is returned
98
+ *
99
+ * @example
100
+ * ```js
101
+ * cidaasAuthenticationService.renewToken().then(function (response) {
102
+ * // the response will give you user details.
103
+ * }).catch(function(ex) {
104
+ * // your failure code here
105
+ * });
106
+ * ```
107
+ * @param {RenewTokenOptions} options options to over-ride the client config for renewing token.
108
+ * @returns {Promise<User>} Authenticated user
109
+ */
110
+ renewToken(options?: RenewTokenOptions): Promise<User>;
111
+ /**
112
+ * To get the generated login url, call **getLoginURL()**. This will call authz service and generate login url to be used.
113
+ * @example
114
+ * ```js
115
+ * cidaasAuthenticationService.getLoginURL().then(function (response) {
116
+ * // the response will give you login url.
117
+ * }).catch(function(ex) {
118
+ * // your failure code here
119
+ * });
120
+ * ```
121
+ * @param {LoginRequestOptions} options login options to override config settings provided
122
+ * @return {Promise<string>} authz url for login
123
+ */
124
+ getLoginURL(options?: LoginRequestOptions): Promise<string>;
125
+ /**
126
+ * To get the user informations from defined UserStorage, call **getUserInfoFromStorage()**.
127
+ * This will fetch informations about the authenticated user such as tokens & user profiles, which has been stored in predefined user storage based on cidaas configuration. (default is session storage)
128
+ *
129
+ * @example
130
+ * ```js
131
+ * cidaasAuthenticationService.getUserInfoFromStorage().then(function (response) {
132
+ * // the response will give you profile details.
133
+ * }).catch(function(ex) {
134
+ * // your failure code here
135
+ * });
136
+ * ```
137
+ * @return {Promise<User|null>} returns authenticated user if present, else null
138
+ */
139
+ getUserInfoFromStorage(): Promise<User | null>;
140
+ }