@asgardeo/auth-spa 0.4.1 → 0.4.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/README.md +13 -21
- package/dist/asgardeo-spa.production.esm.js +1 -1
- package/dist/asgardeo-spa.production.esm.js.map +1 -1
- package/dist/asgardeo-spa.production.js +1 -1
- package/dist/asgardeo-spa.production.js.map +1 -1
- package/dist/asgardeo-spa.production.min.js +1 -1
- package/dist/asgardeo-spa.production.min.js.map +1 -1
- package/dist/polyfilled/asgardeo-spa.production.esm.js +1 -1
- package/dist/polyfilled/asgardeo-spa.production.esm.js.map +1 -1
- package/dist/polyfilled/asgardeo-spa.production.js +1 -1
- package/dist/polyfilled/asgardeo-spa.production.js.map +1 -1
- package/dist/polyfilled/asgardeo-spa.production.min.js +1 -1
- package/dist/polyfilled/asgardeo-spa.production.min.js.map +1 -1
- package/dist/src/helpers/session-management-helper.d.ts.map +1 -1
- package/dist/src/helpers/session-management-helper.js +0 -1
- package/dist/src/helpers/session-management-helper.js.map +1 -1
- package/dist/src/models/http-client.d.ts +6 -3
- package/dist/src/models/http-client.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/helpers/session-management-helper.ts +0 -1
- package/src/models/http-client.ts +7 -4
package/README.md
CHANGED
|
@@ -241,7 +241,7 @@ An instance of the `AsgardeoSPAClient`.
|
|
|
241
241
|
|
|
242
242
|
This returns a static instance of the `AsgardeoSPAClient`. The SDK allows you to create multiple instances of the `AsgardeoSPAClient`. To do so, you can pass an `id` into the `getInstance` method. If no instance has been created for the provided `id`, a new instance will be created and returned by this method. If an instance exists, then that instance will be returned. If no `id` is provided, the default instance will be returned. This allows the SDK to talk to multiple identity providers through the same app.
|
|
243
243
|
|
|
244
|
-
Creating a static instance affords the developers the flexibility of using multiple files to implement the authentication logic. That is, you can have the sign in logic implemented on one page and the sign
|
|
244
|
+
Creating a static instance affords the developers the flexibility of using multiple files to implement the authentication logic. That is, you can have the sign in logic implemented on one page and the sign-out logic on another.
|
|
245
245
|
|
|
246
246
|
#### Example
|
|
247
247
|
|
|
@@ -270,7 +270,7 @@ initialize(config?: `AuthClientConfig<Config>`): Promise<void>;
|
|
|
270
270
|
|
|
271
271
|
#### Description
|
|
272
272
|
|
|
273
|
-
The `initialize` method is used to
|
|
273
|
+
The `initialize` method is used to initialize the client. This _MUST_ be called soon after instantiating the `AsgardeoSPAClient` and before calling another methods.
|
|
274
274
|
|
|
275
275
|
This method takes a `config` object as the only argument. The attributes of the `config` object is as follows.
|
|
276
276
|
|
|
@@ -335,7 +335,7 @@ signIn(config?: SignInConfig, authorizationCode?: string, sessionState?: string)
|
|
|
335
335
|
|
|
336
336
|
#### Description
|
|
337
337
|
|
|
338
|
-
As the name implies, this method is used to sign-in users. This method will have to be called twice to implement the two phases of the authentication process. The first phase generates
|
|
338
|
+
As the name implies, this method is used to sign-in users. This method will have to be called twice to implement the two phases of the authentication process. The first phase generates the authorization URl and takes the user to the single-sign-on page of the Asgardeo, while second phase triggers the token request to complete the authentication process. So, this method should be called when initiating authentication and when the user is redirected back to the app after authentication themselves with the server.
|
|
339
339
|
|
|
340
340
|
The `sign-in` hook is used to fire a callback function after signing in is successful. Check the [on()](#on) section for more information.
|
|
341
341
|
|
|
@@ -418,6 +418,7 @@ httpRequest(config: HttpRequestConfig): Promise<HttpResponse>;
|
|
|
418
418
|
|--------------------------|-----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------|
|
|
419
419
|
| `attachToken` | `boolean` | `true` | If set to `true`, the token will be attached to the request header. |
|
|
420
420
|
| `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. |
|
|
421
|
+
| `shouldAttachIDPAccessToken` | `boolean` | `false` | If set to `true`, the IDP access token will be attached to the the request `Authorization` header. |
|
|
421
422
|
|
|
422
423
|
#### Returns
|
|
423
424
|
|
|
@@ -425,7 +426,7 @@ A Promise that resolves with the response.
|
|
|
425
426
|
|
|
426
427
|
#### Description
|
|
427
428
|
|
|
428
|
-
This method is used to send http requests to the Asgardeo. The developer doesn't need to manually attach the access token since this method does it automatically.
|
|
429
|
+
This method is used to send http requests to the Asgardeo authenticated endpoints. The developer doesn't need to manually attach the access token since this method does it automatically.
|
|
429
430
|
|
|
430
431
|
If the `storage` type is set to `sessionStorage` or `localStorage`, the developer may choose to implement their own ways of sending http requests by obtaining the access token from the relevant storage medium and attaching it to the header. However, if the `storage` is set to `webWorker`, this is the _ONLY_ way http requests can be sent.
|
|
431
432
|
|
|
@@ -652,7 +653,7 @@ A Promise that resolves with the access token.
|
|
|
652
653
|
|
|
653
654
|
#### Description
|
|
654
655
|
|
|
655
|
-
This returns a promise that resolves with the access token. The promise resolves successfully only if the storage type is set to a type other than `webWorker`. Otherwise an error is thrown.
|
|
656
|
+
This returns a promise that resolves with the access token. The promise resolves successfully only if the storage type is set to a type other than `webWorker`. Otherwise, an error is thrown.
|
|
656
657
|
|
|
657
658
|
#### Example
|
|
658
659
|
|
|
@@ -678,7 +679,7 @@ A Promise that resolves with the idp access token.
|
|
|
678
679
|
|
|
679
680
|
#### Description
|
|
680
681
|
|
|
681
|
-
This returns a promise that resolves with the idp access token. The promise resolves successfully only if the storage type is set to a type other than `webWorker`. Otherwise an error is thrown.
|
|
682
|
+
This returns a promise that resolves with the idp access token. The promise resolves successfully only if the storage type is set to a type other than `webWorker`. Otherwise, an error is thrown.
|
|
682
683
|
|
|
683
684
|
#### Example
|
|
684
685
|
|
|
@@ -704,7 +705,7 @@ A Promise that resolves with the data layer object.
|
|
|
704
705
|
|
|
705
706
|
#### Description
|
|
706
707
|
|
|
707
|
-
This returns a promise that resolves with the data layer object. The promise resolves successfully only if the storage type is set to a type other than `webWorker`. Otherwise an error is thrown.
|
|
708
|
+
This returns a promise that resolves with the data layer object. The promise resolves successfully only if the storage type is set to a type other than `webWorker`. Otherwise, an error is thrown.
|
|
708
709
|
|
|
709
710
|
#### Example
|
|
710
711
|
|
|
@@ -757,22 +758,12 @@ A Promise that resolves with the [`BasicUserInfo`](#BasicUserInfo) object.
|
|
|
757
758
|
|
|
758
759
|
#### Description
|
|
759
760
|
|
|
760
|
-
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
|
|
761
|
-
|
|
762
|
-
This method also returns a Promise that resolves with an object containing the attributes mentioned in the table below.
|
|
763
|
-
| Attribute | Description |
|
|
764
|
-
|------------------|-------------------------------------|
|
|
765
|
-
| `"accessToken"` | The new access token |
|
|
766
|
-
| `"expiresIn"` | The expiry time in seconds |
|
|
767
|
-
| `"idToken"` | The ID token |
|
|
768
|
-
| `"refreshToken"` | The refresh token |
|
|
769
|
-
| `"scope"` | The scope of the access token |
|
|
770
|
-
| `"tokenType"` | The type of the token. E.g.: Bearer |
|
|
761
|
+
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 is not required to 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.
|
|
771
762
|
|
|
772
763
|
#### Example
|
|
773
764
|
|
|
774
765
|
```TypeScript
|
|
775
|
-
auth.
|
|
766
|
+
auth.refreshAccessToken().then((response)=>{
|
|
776
767
|
// console.log(response);
|
|
777
768
|
}).catch((error)=>{
|
|
778
769
|
// console.error(error);
|
|
@@ -966,7 +957,7 @@ const hasParams: boolean = SPAUtils.hasAuthSearchParamsInURL();
|
|
|
966
957
|
|
|
967
958
|
When the `responseMode` is set to `form_post`, the authorization code is sent in the body of a `POST` request as opposed to in the URL. So, the Single Page Application should have a backend to receive the authorization code and send it back to the Single Page Application.
|
|
968
959
|
|
|
969
|
-
The backend can then inject the authorization code into a
|
|
960
|
+
The backend can then inject the authorization code into a JavaScript variable while rendering the webpage in the server side. But this results in the authorization code getting printed in the HTML of the page creating a **threat vector**.
|
|
970
961
|
|
|
971
962
|
To address this issue, we recommend storing the authorization code in a server session variable and providing the Single Page Application a separate API endpoint to request the authorization code. The server, when the request is received, can then respond with the authorization code from the server session.
|
|
972
963
|
|
|
@@ -1003,7 +994,7 @@ This table shows the extended attributes provided by the `Config` interface.
|
|
|
1003
994
|
| `requestTimeout` | Optional | `number` | 60000 (seconds) | Specifies in seconds how long a request to the web worker should wait before being timed out. |
|
|
1004
995
|
| `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`. |
|
|
1005
996
|
| `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. |
|
|
1006
|
-
| `enableOIDCSessionManagement` | Optional | `boolean` | false | Flag to enable OIDC Session Management
|
|
997
|
+
| `enableOIDCSessionManagement` | Optional | `boolean` | false | Flag to enable OIDC Session Management. Set this flag to `true` to add single logout capabilities into your application. |
|
|
1007
998
|
|
|
1008
999
|
#### The AuthClientConfig Interface
|
|
1009
1000
|
|
|
@@ -1075,6 +1066,7 @@ This table shows the extended attributes provided by the `Config` interface.
|
|
|
1075
1066
|
#### Custom Grant Template Tags
|
|
1076
1067
|
|
|
1077
1068
|
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.
|
|
1069
|
+
|
|
1078
1070
|
| Tag | Data |
|
|
1079
1071
|
|--------------------|--------------------|
|
|
1080
1072
|
| "{{token}}" | The access token. |
|