@asgardeo/react 0.5.20 → 0.5.22
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.
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
import { Context } from 'react';
|
|
19
|
-
import { HttpRequestConfig, HttpResponse, IdToken, Organization, SignInOptions } from '@asgardeo/browser';
|
|
19
|
+
import { HttpRequestConfig, HttpResponse, IdToken, Organization, SignInOptions, TokenExchangeRequestConfig, TokenResponse } from '@asgardeo/browser';
|
|
20
20
|
import AsgardeoReactClient from '../../AsgardeoReactClient';
|
|
21
21
|
/**
|
|
22
22
|
* Props interface of {@link AsgardeoContext}
|
|
@@ -95,6 +95,19 @@ export type AsgardeoContextProps = {
|
|
|
95
95
|
* @returns A promise that resolves to the decoded ID token payload.
|
|
96
96
|
*/
|
|
97
97
|
getDecodedIdToken?: () => Promise<IdToken>;
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves the access token stored in the storage.
|
|
100
|
+
* This function retrieves the access token and returns it.
|
|
101
|
+
* @remarks This does not work in the `webWorker` or any other worker environment.
|
|
102
|
+
* @returns A promise that resolves to the access token.
|
|
103
|
+
*/
|
|
104
|
+
getAccessToken?: () => Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Swaps the current access token with a new one based on the provided configuration (with a grant type).
|
|
107
|
+
* @param config - Configuration for the token exchange request.
|
|
108
|
+
* @returns A promise that resolves to the token response or the raw response.
|
|
109
|
+
*/
|
|
110
|
+
exchangeToken?: (config: TokenExchangeRequestConfig) => Promise<TokenResponse | Response>;
|
|
98
111
|
};
|
|
99
112
|
/**
|
|
100
113
|
* Context object for managing the Authentication flow builder core context.
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,9 @@ var AsgardeoContext = createContext({
|
|
|
33
33
|
requestAll: () => null
|
|
34
34
|
},
|
|
35
35
|
signInOptions: {},
|
|
36
|
-
getDecodedIdToken: null
|
|
36
|
+
getDecodedIdToken: null,
|
|
37
|
+
getAccessToken: null,
|
|
38
|
+
exchangeToken: null
|
|
37
39
|
});
|
|
38
40
|
AsgardeoContext.displayName = "AsgardeoContext";
|
|
39
41
|
var AsgardeoContext_default = AsgardeoContext;
|
|
@@ -679,6 +681,12 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
|
|
|
679
681
|
getConfiguration() {
|
|
680
682
|
return this.asgardeo.getConfigData();
|
|
681
683
|
}
|
|
684
|
+
async exchangeToken(config, sessionId) {
|
|
685
|
+
return this.withLoading(async () => {
|
|
686
|
+
return this.asgardeo.exchangeToken(config, (user) => {
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
}
|
|
682
690
|
async signIn(...args) {
|
|
683
691
|
return this.withLoading(async () => {
|
|
684
692
|
const arg1 = args[0];
|
|
@@ -1671,6 +1679,7 @@ var AsgardeoProvider = ({
|
|
|
1671
1679
|
},
|
|
1672
1680
|
signInOptions,
|
|
1673
1681
|
getDecodedIdToken: asgardeo.getDecodedIdToken.bind(asgardeo),
|
|
1682
|
+
exchangeToken: asgardeo.exchangeToken.bind(asgardeo),
|
|
1674
1683
|
syncSession
|
|
1675
1684
|
}),
|
|
1676
1685
|
[
|