@asgardeo/auth-spa 0.2.20 → 0.3.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 (54) hide show
  1. package/README.md +111 -89
  2. package/dist/asgardeo-spa.production.esm.js +19 -16
  3. package/dist/asgardeo-spa.production.esm.js.map +1 -1
  4. package/dist/asgardeo-spa.production.js +19 -16
  5. package/dist/asgardeo-spa.production.js.map +1 -1
  6. package/dist/asgardeo-spa.production.min.js +1 -1
  7. package/dist/asgardeo-spa.production.min.js.map +1 -1
  8. package/dist/polyfilled/asgardeo-spa.production.esm.js +42 -39
  9. package/dist/polyfilled/asgardeo-spa.production.esm.js.map +1 -1
  10. package/dist/polyfilled/asgardeo-spa.production.js +42 -39
  11. package/dist/polyfilled/asgardeo-spa.production.js.map +1 -1
  12. package/dist/polyfilled/asgardeo-spa.production.min.js +1 -1
  13. package/dist/polyfilled/asgardeo-spa.production.min.js.map +1 -1
  14. package/dist/src/client.d.ts +7 -4
  15. package/dist/src/client.d.ts.map +1 -1
  16. package/dist/src/client.js +14 -11
  17. package/dist/src/client.js.map +1 -1
  18. package/dist/src/clients/main-thread-client.d.ts.map +1 -1
  19. package/dist/src/clients/main-thread-client.js +40 -34
  20. package/dist/src/clients/main-thread-client.js.map +1 -1
  21. package/dist/src/clients/web-worker-client.d.ts.map +1 -1
  22. package/dist/src/clients/web-worker-client.js +7 -9
  23. package/dist/src/clients/web-worker-client.js.map +1 -1
  24. package/dist/src/models/client.d.ts +2 -2
  25. package/dist/src/models/client.d.ts.map +1 -1
  26. package/dist/src/utils/crypto-utils.d.ts +2 -4
  27. package/dist/src/utils/crypto-utils.d.ts.map +1 -1
  28. package/dist/src/utils/crypto-utils.js +3 -6
  29. package/dist/src/utils/crypto-utils.js.map +1 -1
  30. package/dist/src/worker/client.worker.d.ts.map +1 -1
  31. package/dist/src/worker/client.worker.js +3 -3
  32. package/dist/src/worker/client.worker.js.map +1 -1
  33. package/dist/src/worker/worker-core.d.ts.map +1 -1
  34. package/dist/src/worker/worker-core.js +48 -42
  35. package/dist/src/worker/worker-core.js.map +1 -1
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +2 -2
  38. package/src/client.ts +24 -43
  39. package/src/clients/main-thread-client.ts +63 -75
  40. package/src/clients/web-worker-client.ts +20 -30
  41. package/src/models/client.ts +2 -3
  42. package/src/utils/crypto-utils.ts +15 -19
  43. package/src/worker/client.worker.ts +5 -10
  44. package/src/worker/worker-core.ts +81 -89
  45. package/dist/src/exception/exception.d.ts +0 -27
  46. package/dist/src/exception/exception.d.ts.map +0 -1
  47. package/dist/src/exception/exception.js +0 -30
  48. package/dist/src/exception/exception.js.map +0 -1
  49. package/dist/src/exception/index.d.ts +0 -19
  50. package/dist/src/exception/index.d.ts.map +0 -1
  51. package/dist/src/exception/index.js +0 -19
  52. package/dist/src/exception/index.js.map +0 -1
  53. package/src/exception/exception.ts +0 -44
  54. package/src/exception/index.ts +0 -19
package/README.md CHANGED
@@ -54,6 +54,7 @@
54
54
  - [Develop](#develop)
55
55
  - [Prerequisites](#prerequisites)
56
56
  - [Installing Dependencies](#installing-dependencies)
57
+ - [Error Codes](#error-codes)
57
58
  - [Contribute](#contribute)
58
59
  - [License](#license)
59
60
 
@@ -91,12 +92,12 @@ Or simply load the SDK by importing the script into the header of your HTML file
91
92
  // This client is a class and can be instantiated as follows.
92
93
  var auth = AsgardeoAuth.AsgardeoSPAClient.getInstance();
93
94
 
94
- // Once instantiated, the client can be initialized by passing the relevant parameters such as the server origin, redirect URL, client ID, etc.
95
+ // Once instantiated, the client can be initialized by passing the relevant parameters such as the baseUrl, redirect URL, client ID, etc.
95
96
  auth.initialize({
96
97
  signInRedirectURL: "http://localhost:3000/sign-in",
97
98
  signOutRedirectURL: "http://localhost:3000/dashboard",
98
99
  clientID: "client ID",
99
- serverOrigin: "https://api.asgardeo.io/t/<org_name>"
100
+ baseUrl: "https://api.asgardeo.io/t/<org_name>"
100
101
  });
101
102
 
102
103
  // To sign in, simply call the `signIn()` method.
@@ -123,7 +124,7 @@ auth.initialize({
123
124
  signInRedirectURL: "http://localhost:3000/sign-in",
124
125
  signOutRedirectURL: "http://localhost:3000/dashboard",
125
126
  clientID: "client ID",
126
- serverOrigin: "https://api.asgardeo.io/t/<org_name>"
127
+ baseUrl: "https://api.asgardeo.io/t/<org_name>"
127
128
  });
128
129
 
129
130
  // To sign in, simply call the `signIn()` method.
@@ -152,7 +153,7 @@ Before trying out the sample apps, you need to create an application in **Asgard
152
153
 
153
154
  4. Click on Register. You will be navigated to management page of the **sample** application.
154
155
 
155
- 5. Add `https://localhost:5000` to **Allowed Origins** under **Access** tab and check **Public client** option.
156
+ 5. Add `https://localhost:3000` to **Allowed Origins** under **Access** tab and check **Public client** option.
156
157
 
157
158
  6. Click on **Update** at the bottom.
158
159
 
@@ -166,19 +167,19 @@ npm run build
166
167
 
167
168
  #### 1. HTML JavaScript Sample
168
169
 
169
- The _Callback URL_ of this app is `http://localhost:5000`.
170
+ The _Callback URL_ of this app is `http://localhost:3000`.
170
171
 
171
172
  You can try out the HTML JavaScript Sample App from the [samples/asgardeo-html-js-app](/samples/asgardeo-html-js-app/). The instructions to run the app can be found [here](/samples/asgardeo-html-js-app/README.md)
172
173
 
173
174
  #### 2. React JavaScript Sample
174
175
 
175
- The _Callback URL_ of this app is `http://localhost:5000`.
176
+ The _Callback URL_ of this app is `http://localhost:3000`.
176
177
 
177
178
  You can try out the React JS Sample App from the [samples/asgardeo-react-js-app](/samples/asgardeo-react-js-app). The instructions to run the app can be found [here](/samples/asgardeo-react-js-app/README.md)
178
179
 
179
180
  #### 3. React Typescript Sample
180
181
 
181
- The _Callback URL_ of this app is `http://localhost:5000`.
182
+ The _Callback URL_ of this app is `http://localhost:3000`.
182
183
 
183
184
  You can try out the React Typescript Sample App from the [samples/asgardeo-react-ts-app](/samples/asgardeo-react-ts-app). The instructions to run the app can be found [here](/samples/asgardeo-react-ts-app/README.md)
184
185
 
@@ -280,7 +281,7 @@ const config = {
280
281
  signInRedirectURL: "http://localhost:3000/sign-in",
281
282
  signOutRedirectURL: "http://localhost:3000/dashboard",
282
283
  clientID: "client ID",
283
- serverOrigin: "https://api.asgardeo.io/t/<org_name>"
284
+ baseUrl: "https://api.asgardeo.io/t/<org_name>"
284
285
  }
285
286
 
286
287
  auth.initialize(config);
@@ -341,7 +342,9 @@ The `sign-in` hook is used to fire a callback function after signing in is succe
341
342
  ```typeScript
342
343
  auth.signIn();
343
344
  ```
345
+
344
346
  ---
347
+
345
348
  ### trySignInSilently
346
349
 
347
350
  ```typescript
@@ -361,13 +364,13 @@ This returns a promise that resolves with a `[BasicUserInfo](#BasicUserInfo)` ob
361
364
 
362
365
  The `sign-in` hook is used to fire a callback function after signing in is successful. Check the [on()](#on) section for more information.
363
366
 
364
- > :warning: ***Since this method uses an iFrame, this method will not work if third-party cookies are blocked in the browser.***
367
+ > :warning: **_Since this method uses an iFrame, this method will not work if third-party cookies are blocked in the browser._**
365
368
 
366
369
  #### Example
367
370
 
368
371
  ```typescript
369
- auth.trySignInSilently().then((response)=>{
370
- if(response) {
372
+ auth.trySignInSilently().then((response) => {
373
+ if (response) {
371
374
  // The user is signed in.
372
375
  // handle basic user info
373
376
  }
@@ -409,10 +412,10 @@ httpRequest(config: HttpRequestConfig): Promise<HttpResponse>;
409
412
  1. config: `[HttpRequestConfig](#httpRequestConfig)`
410
413
  A config object with the settings necessary to send http requests. This object is similar to the `AxiosRequestConfig` but provides these additional attributes:
411
414
 
412
- |Attribute|Type|Default|Description|
413
- |--|--|--|--|
414
- |`attachToken`|`boolean`|`true`|If set to `true`, the token will be attached to the request header.|
415
- |`shouldEncodeToFormData`|`boolean`|`false`|If set to `true`, the request body will be encoded to `FormData`. The body (specified by the `data` attribute) should be a Javascript object. |
415
+ | Attribute | Type | Default | Description |
416
+ |--------------------------|-----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------|
417
+ | `attachToken` | `boolean` | `true` | If set to `true`, the token will be attached to the request header. |
418
+ | `shouldEncodeToFormData` | `boolean` | `false` | If set to `true`, the request body will be encoded to `FormData`. The body (specified by the `data` attribute) should be a Javascript object. |
416
419
 
417
420
  #### Returns
418
421
 
@@ -566,7 +569,7 @@ A Promise that resolves with an object containing the endpoints. To learn more a
566
569
  This method returns a promise that resolves with an object containing the OIDC endpoints obtained from the `.well-known` endpoint. The object contains the following attributes.
567
570
 
568
571
  | Attribute | Description |
569
- | --------------------- | ---------------------------------------------------------------------------------- |
572
+ |-----------------------|------------------------------------------------------------------------------------|
570
573
  | `"authorize"` | The endpoint to which the authorization request should be sent. |
571
574
  | `"jwks"` | The endpoint from which JSON Web Key Set can be obtained. |
572
575
  | `"oidcSessionIFrame"` | The URL of the page that should be loaded in an IFrame to get session information. |
@@ -674,14 +677,14 @@ A Promise that resolves with the [`BasicUserInfo`](#BasicUserInfo) object.
674
677
  This refreshes the access token and stores the refreshed session information in either the session or local storage as per your configuration. Note that this method cannot be used when the storage type is set to `webWorker` since the web worker automatically refreshes the token and there is no need for the developer to do it.
675
678
 
676
679
  This method also returns a Promise that resolves with an object containing the attributes mentioned in the table below.
677
- |Attribute|Description|
678
- |--|--|
679
- `"accessToken"`| The new access token |
680
- `"expiresIn"`| The expiry time in seconds|
681
- `"idToken"`| The ID token|
682
- `"refreshToken"`| The refresh token|
683
- `"scope"`| The scope of the access token|
684
- `"tokenType"`| The type of the token. E.g.: Bearer|
680
+ | Attribute | Description |
681
+ |------------------|-------------------------------------|
682
+ | `"accessToken"` | The new access token |
683
+ | `"expiresIn"` | The expiry time in seconds |
684
+ | `"idToken"` | The ID token |
685
+ | `"refreshToken"` | The refresh token |
686
+ | `"scope"` | The scope of the access token |
687
+ | `"tokenType"` | The type of the token. E.g.: Bearer |
685
688
 
686
689
  #### Example
687
690
 
@@ -715,17 +718,17 @@ The `on` method is used to hook callback functions to authentication methods. Th
715
718
  If you are using TypeScript, you may want to use the `Hooks` enum that consists of the following string literals instead of directly inputting the string value.
716
719
 
717
720
  | Hook | Method to which the callback function is attached | Returned Response |
718
- | :----------------------- | :------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------- |
721
+ |:-------------------------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------|
719
722
  | `"sign-in"` | `signIn()` | The user information. See [getUserInfo()](#getuserinfo)'s return type for more details. |
720
723
  | `"sign-out"` | `signOut()` | |
721
724
  | `"initialize"` | `initialize()` | A boolean value indicating if the initialization was successful or not. |
722
- | `"http-request-start"` | `httpRequest()` (Called before an http request is sent) |
723
- | `"http-request-finish"` | `httpRequest()` (Called after an http request is sent and response is received.) |
724
- | `"http-request-error"` | `httpRequest()` (Called when an http request returns an error) |
725
- | `"http-request-success"` | `httpRequest()` (Called when an http requests returns a response successfully) |
725
+ | `"http-request-start"` | `httpRequest()` (Called before an http request is sent) | |
726
+ | `"http-request-finish"` | `httpRequest()` (Called after an http request is sent and response is received.) | |
727
+ | `"http-request-error"` | `httpRequest()` (Called when an http request returns an error) | |
728
+ | `"http-request-success"` | `httpRequest()` (Called when an http requests returns a response successfully) | |
726
729
  | `"revoke-access-token"` | `revokeAccessToken()` | A boolean value indicating if the process was successful or not |
727
730
  | `"custom-grant"` | `customGrant()` | Returns the response from the custom grant request. |
728
- | `sign-out-failed` | `signOut()` (Called when sign out fails) | An object of type [`SignOutError`](#SignOutError).|
731
+ | `sign-out-failed` | `signOut()` (Called when sign out fails) | An object of type [`SignOutError`](#SignOutError). |
729
732
 
730
733
  **When the user signs out, the user is taken to the Asgardeo's logout page and then redirected back to the SPA on successful log out. Hence, developers should ensure that the `"sign-out"` hook is called when the page the user is redirected to loads.**
731
734
 
@@ -910,39 +913,39 @@ auth.initialize(config);
910
913
  The `AuthClientConfig<Config>` interface extends the `AuthClientConfig<T>` interface provided by the `Asgardeo JavaScript Auth SDK` with the `Config` interface. This table lists the attributes that the `AuthClientConfig<T>` interface takes.
911
914
 
912
915
  This table shows the extended attributes provided by the `Config` interface.
913
- | Attribute | Required/Optional | Type | Default Value | Description |
914
- |:----|:----|:----|:----|:----|
915
- | [`storage`](#storage) | Optional | `"sessionStorage"`, `"webWorker"`, `"localStorage"` | `"sessionStorage"` | The storage medium where the session information such as the access token should be stored.| |
916
- | `resourceServerURLs` |Required if the `storage` is set to `webWorker` | `string[]` | `[]` | The URLs of the API endpoints. This is needed only if the storage method is set to `webWorker`. When API calls are made through the [`httpRequest`](#httprequest) or the [`httpRequestAll`](#httprequestall) method, only the calls to the endpoints specified in the `baseURL` attribute will be allowed. Everything else will be denied. | |
917
- |`requestTimeout` | Optional | `number`| 60000 (seconds) | Specifies in seconds how long a request to the web worker should wait before being timed out. |
918
- |`sessionRefreshInterval`|Optional|`number`| 300 (seconds)|Specifies how often the session state should be checked. To check the authentication state, the authorization endpoint is queried with the `prompt` parameter set to `none`.|
919
- |`checkSessionInterval` |Optional|`number`|3 (seconds)| Specifies how often the check-session iFrame should be queried to check the session state. This is used to perform single logout. |
920
- |`enableOIDCSessionManagement` |Optional|`boolean`| false | Flag to enable OIDC Session Management |
916
+ | Attribute | Required/Optional | Type | Default Value | Description |
917
+ |:------------------------------|:------------------------------------------------|:----------------------------------------------------|:-------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
918
+ | [`storage`](#storage) | Optional | `"sessionStorage"`, `"webWorker"`, `"localStorage"` | `"sessionStorage"` | The storage medium where the session information such as the access token should be stored. |
919
+ | `resourceServerURLs` | Required if the `storage` is set to `webWorker` | `string[]` | `[]` | The URLs of the API endpoints. This is needed only if the storage method is set to `webWorker`. When API calls are made through the [`httpRequest`](#httprequest) or the [`httpRequestAll`](#httprequestall) method, only the calls to the endpoints specified in the `baseURL` attribute will be allowed. Everything else will be denied. |
920
+ | `requestTimeout` | Optional | `number` | 60000 (seconds) | Specifies in seconds how long a request to the web worker should wait before being timed out. |
921
+ | `sessionRefreshInterval` | Optional | `number` | 300 (seconds) | Specifies how often the session state should be checked. To check the authentication state, the authorization endpoint is queried with the `prompt` parameter set to `none`. |
922
+ | `checkSessionInterval` | Optional | `number` | 3 (seconds) | Specifies how often the check-session iFrame should be queried to check the session state. This is used to perform single logout. |
923
+ | `enableOIDCSessionManagement` | Optional | `boolean` | false | Flag to enable OIDC Session Management |
921
924
 
922
925
  #### The AuthClientConfig Interface
923
926
 
924
- | Attribute | Required/Optional | Type | Default Value | Description |
925
- | ---------------------------- | ----------------- | --------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
926
- | `signInRedirectURL` | Required | `string` | "" | The URL to redirect to after the user authorizes the client app. eg: `https//localhost:3000/sign-in` |
927
- | `signOutRedirectURL` | Optional | `string` | The `signInRedirectURL` URL will be used if this value is not provided. | The URL to redirect to after the user | signs out. eg: `http://localhost:3000/dashboard` |
928
- | `clientHost` | Optional | `string` | The origin of the client app obtained using `window.origin` | The hostname of the client app. eg: `https://localhost:3000` |
929
- | `clientID` | Required | `string` | "" | The client ID of the OIDC application hosted in the Asgardeo. |
930
- | `clientSecret` | Optional | `string` | "" | The client secret of the OIDC application |
931
- | `enablePKCE` | Optional | `boolean` | `true` | Specifies if a PKCE should be sent with the request for the authorization code. |
932
- | `prompt` | Optional | `string` | "" | Specifies the prompt type of an OIDC request |
933
- | `responseMode` | Optional | `ResponseMode` | `"query"` | Specifies the response mode. The value can either be `query` or `form_post` |
934
- | `scope` | Optional | `string[]` | `["openid"]` | Specifies the requested scopes. |
935
- | `serverOrigin` | Required | `string` | "" | The origin of the Identity Provider. eg: `https://api.asgardeo.io/t/<org_name>` |
936
- | `endpoints` | Optional | `OIDCEndpoints` | [OIDC Endpoints Default Values](#oidc-endpoints) | The OIDC endpoint URLs. The SDK will try to obtain the endpoint URLS | using the `.well-known` endpoint. If this fails, the SDK will use these endpoint URLs. If this attribute is not set, then the default endpoint URLs will be | used. However, if the `overrideWellEndpointConfig` is set to `true`, then this will override the endpoints obtained from the `.well-known` endpoint. |
937
- | `overrideWellEndpointConfig` | Optional | `boolean` | `false` | If this option is set to `true`, then the `endpoints` object will override endpoints obtained | from the `.well-known` endpoint. If this is set to `false`, then this will be used as a fallback if the request to the `.well-known` endpoint fails. |
938
- | `wellKnownEndpoint` | Optional | `string` | `"/oauth2/token/.well-known/openid-configuration"` | The URL of the `.well-known` endpoint. |
939
- | `validateIDToken` | Optional | `boolean` | `true` | Allows you to enable/disable JWT ID token validation after obtaining the ID token. |
940
- | `clockTolerance` | Optional | `number` | `60` | Allows you to configure the leeway when validating the id_token. |
927
+ | Attribute | Required/Optional | Type | Default Value | Description |
928
+ |------------------------------|---------------------------------------------------------------------------------------------------|-----------------|-------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
929
+ | `signInRedirectURL` | Required | `string` | "" | The URL to redirect to after the user authorizes the client app. eg: `https//localhost:3000/sign-in` |
930
+ | `signOutRedirectURL` | Optional | `string` | The `signInRedirectURL` URL will be used if this value is not provided. | The URL to redirect to after the user |
931
+ | `clientHost` | Optional | `string` | The origin of the client app obtained using `window.origin` | The hostname of the client app. eg: `https://localhost:3000` |
932
+ | `clientID` | Required | `string` | "" | The client ID of the OIDC application hosted in the Asgardeo. |
933
+ | `clientSecret` | Optional | `string` | "" | The client secret of the OIDC application |
934
+ | `enablePKCE` | Optional | `boolean` | `true` | Specifies if a PKCE should be sent with the request for the authorization code. |
935
+ | `prompt` | Optional | `string` | "" | Specifies the prompt type of an OIDC request |
936
+ | `responseMode` | Optional | `ResponseMode` | `"query"` | Specifies the response mode. The value can either be `query` or `form_post` |
937
+ | `scope` | Optional | `string[]` | `["openid"]` | Specifies the requested scopes. |
938
+ | `baseUrl` | Required | `string` | "" | The origin of the Identity Provider. eg: `https://api.asgardeo.io/t/<org_name>` |
939
+ | `overrideWellEndpointConfig` | Optional | `boolean` | `false` | If this option is set to `true`, then the `endpoints` object will override endpoints obtained |
940
+ | `endpoints` | Optional (Required to provide all endpoints, if `wellKnownEndpoint` or `baseUrl` is not provided) | `OIDCEndpoints` | [OIDC Endpoints Default Values](#oidc-endpoints) | The OIDC endpoint URLs. The SDK will try to obtain the endpoint URLS |
941
+ | `wellKnownEndpoint` | Optional (Required if `baseUrl` or `endpoints` is not provided) | `string` | `"/oauth2/token/.well-known/openid-configuration"` | The URL of the `.well-known` endpoint. |
942
+ | `validateIDToken` | Optional | `boolean` | `true` | Allows you to enable/disable JWT ID token validation after obtaining the ID token. |
943
+ | `clockTolerance` | Optional | `number` | `60` | Allows you to configure the leeway when validating the id_token. |
941
944
 
942
945
  ### BasicUserInfo
943
946
 
944
947
  | Attribute | Type | Description |
945
- | :-------------- | :------- | :------------------------------------------------------------------------------------------------- |
948
+ |:----------------|:---------|:---------------------------------------------------------------------------------------------------|
946
949
  | `email` | `string` | The email address of the user. |
947
950
  | `username` | `string` | The username of the user. |
948
951
  | `displayName` | `string` | The display name of the user. It is the `preferred_username` in the id token payload or the `sub`. |
@@ -954,7 +957,7 @@ This table shows the extended attributes provided by the `Config` interface.
954
957
  ### SignInConfig
955
958
 
956
959
  | Method | Required/Optional | Type | Default Value | Description |
957
- | -------------------- | ----------------- | --------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
960
+ |----------------------|-------------------|-----------------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
958
961
  | `callOnlyOnRedirect` | Optional | `boolean` | `false` | Makes sure that this function is executed only after being redirected from the Single-Sign-On page. This will be useful to send a token request after the user authenticates themself with the server. |
959
962
  | `fidp` | Optional | `string` | "" | The `fidp` parameter that can be used to redirect a user directly to an IdP's sign-in page. |
960
963
  | `forceInit` | Optional | `boolean` | `false` | Forces obtaining the OIDC endpoints from the `.well-known` endpoint. A request to this endpoint is not sent if a request has already been sent. This forces a request. |
@@ -962,24 +965,23 @@ This table shows the extended attributes provided by the `Config` interface.
962
965
 
963
966
  ### OIDCEndpoints
964
967
 
965
- | Method | Type | Default Value | Description |
966
- | ----------------------- | -------- | -------------------------------------------------- | ------------------------------------------------------------------------- |
967
- | `authorizationEndpoint` | `string` | `"/oauth2/authorize"` | The authorization endpoint. |
968
- | `tokenEndpoint` | `string` | `"/oauth2/token"` | The token endpoint. |
969
- | `userinfoEndpoint` | `string` | "" | The user-info endpoint. |
970
- | `jwksUri` | `string` | `"/oauth2/jwks"` | The JWKS URI. |
971
- | `registrationEndpoint` | `string` | "" | The registration endpoint. |
972
- | `revocationEndpoint` | `string` | `"/oauth2/revoke"` | The token-revocation endpoint. |
973
- | `introspectionEndpoint` | `string` | "" | The introspection endpoint. |
974
- | `checkSessionIframe` | `string` | `"/oidc/checksession"` | The check-session endpoint. |
975
- | `endSessionEndpoint` | `string` | `"/oidc/logout"` | The end-session endpoint. |
976
- | `issuer` | `string` | "" | The issuer of the token. |
977
- | `wellKnownEndpoint` | `string` | `"/oauth2/token/.well-known/openid-configuration"` | The well-known endpoint. This is the default endpoint defined in the SDK. |
968
+ | Method | Type | Default Value | Description |
969
+ |-------------------------|----------|------------------------|--------------------------------|
970
+ | `authorizationEndpoint` | `string` | `"/oauth2/authorize"` | The authorization endpoint. |
971
+ | `tokenEndpoint` | `string` | `"/oauth2/token"` | The token endpoint. |
972
+ | `userinfoEndpoint` | `string` | "" | The user-info endpoint. |
973
+ | `jwksUri` | `string` | `"/oauth2/jwks"` | The JWKS URI. |
974
+ | `registrationEndpoint` | `string` | "" | The registration endpoint. |
975
+ | `revocationEndpoint` | `string` | `"/oauth2/revoke"` | The token-revocation endpoint. |
976
+ | `introspectionEndpoint` | `string` | "" | The introspection endpoint. |
977
+ | `checkSessionIframe` | `string` | `"/oidc/checksession"` | The check-session endpoint. |
978
+ | `endSessionEndpoint` | `string` | `"/oidc/logout"` | The end-session endpoint. |
979
+ | `issuer` | `string` | "" | The issuer of the token. |
978
980
 
979
981
  ### CustomGrantConfig
980
982
 
981
983
  | Attribute | Required/Optional | Type | Default Value | Description |
982
- | ---------------- | ----------------- | --------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
984
+ |------------------|-------------------|-----------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
983
985
  | `id` | Required | `string` | "" | Every custom-grant request should have an id. This attributes takes that id. |
984
986
  | `data` | Required | `any` | `null` | The data that should be sent in the body of the custom-grant request. You can use template tags to send session information. Refer to the [Custom Grant Template Tags](#custom-grant-template-tags) section for more details. |
985
987
  | `signInRequired` | Required | `boolean` | `false` | Specifies if the user should be sign-in or not to dispatch this custom-grant request. |
@@ -990,20 +992,20 @@ This table shows the extended attributes provided by the `Config` interface.
990
992
  #### Custom Grant Template Tags
991
993
 
992
994
  Session information can be attached to the body of a custom-grant request using template tags. This is useful when the session information is not exposed outside the SDK but you want such information to be used in custom-grant requests. The following table lists the available template tags.
993
- |Tag|Data|
994
- |--|--|
995
- |"{{token}}" | The access token.|
996
- |{{username}}" | The username.|
997
- |"{{scope}}" | The scope.|
998
- |{{clientID}}" | The client ID.|
999
- |"{{clientSecret}}" | The client secret.|
995
+ | Tag | Data |
996
+ |--------------------|--------------------|
997
+ | "{{token}}" | The access token. |
998
+ | {{username}}" | The username. |
999
+ | "{{scope}}" | The scope. |
1000
+ | {{clientID}}" | The client ID. |
1001
+ | "{{clientSecret}}" | The client secret. |
1000
1002
 
1001
1003
  #### The data attribute
1002
1004
 
1003
1005
  ### DecodedIDTokenPayload
1004
1006
 
1005
- | Attribute | Type | Description |
1006
- | ------------------ | ---------------------- | ---------------------------------------------- |
1007
+ | Attribute | Type | Description |
1008
+ |--------------------|------------------------|------------------------------------------------|
1007
1009
  | aud | `string` \| `string[]` | The audience. |
1008
1010
  | sub | `string` | The subject. This is the username of the user. |
1009
1011
  | iss | `string` | The token issuer. |
@@ -1012,32 +1014,52 @@ Session information can be attached to the body of a custom-grant request using
1012
1014
  | tenant_domain | `string` | The tenant domain to which the user belongs. |
1013
1015
 
1014
1016
  ### HTTPRequestConfig
1017
+
1015
1018
  This extends the `AxiosRequestConfig` by providing an additional attribute that is used to specify if the access token should be attached to the request or not.
1016
- |Attribute | Type | Description|
1017
- |--|--|--|
1018
- |attachToken| `boolean`| Specifies if the access token should be attached to the header of the request.|
1019
+ | Attribute | Type | Description |
1020
+ |-------------|-----------|--------------------------------------------------------------------------------|
1021
+ | attachToken | `boolean` | Specifies if the access token should be attached to the header of the request. |
1019
1022
 
1020
1023
  ### SignOutError
1021
- | Attribute | Type | Description |
1022
- | ------------------ | ---------------------- | ---------------------------------------------- |
1023
- | error | `string` | The error message. |
1024
- | error_description | `string` | The error description. |
1024
+
1025
+ | Attribute | Type | Description |
1026
+ |-------------------|----------|------------------------|
1027
+ | error | `string` | The error message. |
1028
+ | error_description | `string` | The error description. |
1025
1029
 
1026
1030
  ## Develop
1027
1031
 
1028
1032
  ### Prerequisites
1029
1033
 
1030
1034
  - `Node.js` (version 10 or above).
1031
- - `npm` package manager.
1035
+ - `yarn` package manager.
1032
1036
 
1033
1037
  ### Installing Dependencies
1034
1038
 
1035
1039
  The repository is a mono repository. The SDK repository is found in the [lib]() directory. You can install the dependencies by running the following command at the root.
1036
1040
 
1037
1041
  ```
1038
- npm run build
1042
+ yarn build
1039
1043
  ```
1040
1044
 
1045
+ ## Error Codes
1046
+
1047
+ Error code consist of four parts separated by a `-`.
1048
+
1049
+ - The first part refers to the SDK. Example: `JS` refers to this SDK.
1050
+ - The second part refers to the code file. Example: `MAIN_THREAD_CLIENT` refers to the `main-thread-client.ts` file.
1051
+ - The third part is the abbreviation of the name of the method/function that threw the error. If there are more than one method/function with the same abbreviation, then a number based on the order of declaration is appended to the abbreviation. Example: `HR` refers to the `httpRequest` method.
1052
+ - The fourth part refers to the type of error and is position. Example: `IV02` refers to an invalid argument error and the fact that this is the second error in the method/function. The following error types are available:
1053
+
1054
+ | Error Code | Description |
1055
+ |:-----------|:--------------|
1056
+ | `NE` | Network Error |
1057
+ | `HE` | Http Error |
1058
+ | `IV` | Invalid |
1059
+ | `NF` | Not Found |
1060
+ | `TO` | Timeout |
1061
+ | `SE` | Server Error |
1062
+
1041
1063
  ## Contribute
1042
1064
 
1043
1065
  Please read [Contributing to the Code Base](http://wso2.github.io/) for details on our code of conduct, and the process for submitting pull requests to us.