@asgardeo/react 0.5.8 → 0.5.10
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/dist/AsgardeoReactClient.d.ts +4 -1
- package/dist/__temp__/api.d.ts +2 -2
- package/dist/cjs/index.js +82 -70
- package/dist/cjs/index.js.map +2 -2
- package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +20 -1
- package/dist/index.js +82 -70
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
import { Context } from 'react';
|
|
19
|
-
import { Organization } from '@asgardeo/browser';
|
|
19
|
+
import { HttpRequestConfig, HttpResponse, Organization } from '@asgardeo/browser';
|
|
20
20
|
import AsgardeoReactClient from '../../AsgardeoReactClient';
|
|
21
21
|
/**
|
|
22
22
|
* Props interface of {@link AsgardeoContext}
|
|
@@ -58,6 +58,25 @@ export type AsgardeoContextProps = {
|
|
|
58
58
|
signUp: any;
|
|
59
59
|
user: any;
|
|
60
60
|
organization: Organization;
|
|
61
|
+
/**
|
|
62
|
+
* HTTP request function to make API calls.
|
|
63
|
+
* @param requestConfig - Configuration for the HTTP request.
|
|
64
|
+
* @returns A promise that resolves to the HTTP response.
|
|
65
|
+
*/
|
|
66
|
+
http: {
|
|
67
|
+
/**
|
|
68
|
+
* Makes an HTTP request using the provided configuration.
|
|
69
|
+
* @param requestConfig - Configuration for the HTTP request.
|
|
70
|
+
* @returns A promise that resolves to the HTTP response.
|
|
71
|
+
*/
|
|
72
|
+
request: (requestConfig?: HttpRequestConfig) => Promise<HttpResponse<any>>;
|
|
73
|
+
/**
|
|
74
|
+
* Makes multiple HTTP requests based on the provided configuration.
|
|
75
|
+
* @param requestConfigs - Set of configurations for the HTTP requests.
|
|
76
|
+
* @returns A promise that resolves to an array of HTTP responses.
|
|
77
|
+
*/
|
|
78
|
+
requestAll: (requestConfigs?: HttpRequestConfig[]) => Promise<HttpResponse<any>[]>;
|
|
79
|
+
};
|
|
61
80
|
};
|
|
62
81
|
/**
|
|
63
82
|
* Context object for managing the Authentication flow builder core context.
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,11 @@ var AsgardeoContext = createContext({
|
|
|
27
27
|
signInSilently: null,
|
|
28
28
|
signOut: null,
|
|
29
29
|
signUp: null,
|
|
30
|
-
user: null
|
|
30
|
+
user: null,
|
|
31
|
+
http: {
|
|
32
|
+
request: () => null,
|
|
33
|
+
requestAll: () => null
|
|
34
|
+
}
|
|
31
35
|
});
|
|
32
36
|
AsgardeoContext.displayName = "AsgardeoContext";
|
|
33
37
|
var AsgardeoContext_default = AsgardeoContext;
|
|
@@ -198,7 +202,7 @@ var _AuthAPI = class _AuthAPI {
|
|
|
198
202
|
* @return {Promise<Response | SignInResponse>} - A Promise that resolves with
|
|
199
203
|
* the value returned by the custom grant request.
|
|
200
204
|
*/
|
|
201
|
-
exchangeToken(config, callback
|
|
205
|
+
exchangeToken(config, callback) {
|
|
202
206
|
return this._client.exchangeToken(config).then((response) => {
|
|
203
207
|
if (!response) {
|
|
204
208
|
return null;
|
|
@@ -210,7 +214,6 @@ var _AuthAPI = class _AuthAPI {
|
|
|
210
214
|
isSignedIn: true,
|
|
211
215
|
isLoading: false
|
|
212
216
|
});
|
|
213
|
-
dispatch({ ...response, isSignedIn: true, isLoading: false });
|
|
214
217
|
}
|
|
215
218
|
callback && callback(response);
|
|
216
219
|
return response;
|
|
@@ -277,8 +280,8 @@ var _AuthAPI = class _AuthAPI {
|
|
|
277
280
|
*
|
|
278
281
|
* @return {Promise<string>} - A Promise that resolves with the access token.
|
|
279
282
|
*/
|
|
280
|
-
async getAccessToken() {
|
|
281
|
-
return this._client.getAccessToken();
|
|
283
|
+
async getAccessToken(sessionId) {
|
|
284
|
+
return this._client.getAccessToken(sessionId);
|
|
282
285
|
}
|
|
283
286
|
/**
|
|
284
287
|
* This method return a Promise that resolves with the idp access token.
|
|
@@ -623,7 +626,6 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
|
|
|
623
626
|
return this.withLoading(async () => {
|
|
624
627
|
try {
|
|
625
628
|
const configData = await this.asgardeo.getConfigData();
|
|
626
|
-
const scopes = configData?.scopes;
|
|
627
629
|
if (!organization.id) {
|
|
628
630
|
throw new AsgardeoRuntimeError(
|
|
629
631
|
"Organization ID is required for switching organizations",
|
|
@@ -645,12 +647,8 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
|
|
|
645
647
|
returnsSession: true,
|
|
646
648
|
signInRequired: true
|
|
647
649
|
};
|
|
648
|
-
return await this.asgardeo.exchangeToken(
|
|
649
|
-
|
|
650
|
-
(user) => {
|
|
651
|
-
},
|
|
652
|
-
() => null
|
|
653
|
-
);
|
|
650
|
+
return await this.asgardeo.exchangeToken(exchangeConfig, (user) => {
|
|
651
|
+
});
|
|
654
652
|
} catch (error) {
|
|
655
653
|
throw new AsgardeoRuntimeError(
|
|
656
654
|
`Failed to switch organization: ${error.message || error}`,
|
|
@@ -723,6 +721,15 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
|
|
|
723
721
|
"The signUp method with SignUpOptions is not implemented in the React client."
|
|
724
722
|
);
|
|
725
723
|
}
|
|
724
|
+
async request(requestConfig) {
|
|
725
|
+
return this.asgardeo.httpRequest(requestConfig);
|
|
726
|
+
}
|
|
727
|
+
async requestAll(requestConfigs) {
|
|
728
|
+
return this.asgardeo.httpRequestAll(requestConfigs);
|
|
729
|
+
}
|
|
730
|
+
async getAccessToken(sessionId) {
|
|
731
|
+
return this.asgardeo.getAccessToken(sessionId);
|
|
732
|
+
}
|
|
726
733
|
};
|
|
727
734
|
var AsgardeoReactClient_default = AsgardeoReactClient;
|
|
728
735
|
|
|
@@ -1565,19 +1572,6 @@ var AsgardeoProvider = ({
|
|
|
1565
1572
|
setIsLoadingSync(asgardeo.isLoading());
|
|
1566
1573
|
}
|
|
1567
1574
|
};
|
|
1568
|
-
const signUp = async (payload) => {
|
|
1569
|
-
try {
|
|
1570
|
-
return await asgardeo.signUp(payload);
|
|
1571
|
-
} catch (error) {
|
|
1572
|
-
throw new AsgardeoRuntimeError3(
|
|
1573
|
-
`Error while signing up: ${error.message || error}`,
|
|
1574
|
-
"asgardeo-signUp-Error",
|
|
1575
|
-
"react",
|
|
1576
|
-
"An error occurred while trying to sign up."
|
|
1577
|
-
);
|
|
1578
|
-
}
|
|
1579
|
-
};
|
|
1580
|
-
const signOut = async (options, afterSignOut) => asgardeo.signOut(options, afterSignOut);
|
|
1581
1575
|
const switchOrganization = async (organization) => {
|
|
1582
1576
|
try {
|
|
1583
1577
|
setIsLoadingSync(true);
|
|
@@ -1610,57 +1604,75 @@ var AsgardeoProvider = ({
|
|
|
1610
1604
|
flattenedProfile: generateFlattenedUserProfile2(payload, prev?.schemas)
|
|
1611
1605
|
}));
|
|
1612
1606
|
};
|
|
1613
|
-
|
|
1614
|
-
|
|
1607
|
+
const value = useMemo6(
|
|
1608
|
+
() => ({
|
|
1609
|
+
applicationId,
|
|
1610
|
+
organizationHandle: config?.organizationHandle,
|
|
1611
|
+
signInUrl,
|
|
1612
|
+
signUpUrl,
|
|
1613
|
+
afterSignInUrl,
|
|
1614
|
+
baseUrl,
|
|
1615
|
+
getAccessToken: asgardeo.getAccessToken.bind(asgardeo),
|
|
1616
|
+
isInitialized: isInitializedSync,
|
|
1617
|
+
isLoading: isLoadingSync,
|
|
1618
|
+
isSignedIn: isSignedInSync,
|
|
1619
|
+
organization: currentOrganization,
|
|
1620
|
+
signIn,
|
|
1621
|
+
signInSilently,
|
|
1622
|
+
signOut: asgardeo.signOut.bind(asgardeo),
|
|
1623
|
+
signUp: asgardeo.signUp.bind(asgardeo),
|
|
1624
|
+
user,
|
|
1625
|
+
http: {
|
|
1626
|
+
request: asgardeo.request.bind(asgardeo),
|
|
1627
|
+
requestAll: asgardeo.requestAll.bind(asgardeo)
|
|
1628
|
+
}
|
|
1629
|
+
}),
|
|
1630
|
+
[
|
|
1631
|
+
applicationId,
|
|
1632
|
+
config?.organizationHandle,
|
|
1633
|
+
signInUrl,
|
|
1634
|
+
signUpUrl,
|
|
1635
|
+
afterSignInUrl,
|
|
1636
|
+
baseUrl,
|
|
1637
|
+
isInitializedSync,
|
|
1638
|
+
isLoadingSync,
|
|
1639
|
+
isSignedInSync,
|
|
1640
|
+
currentOrganization,
|
|
1641
|
+
signIn,
|
|
1642
|
+
signInSilently,
|
|
1643
|
+
user,
|
|
1644
|
+
asgardeo
|
|
1645
|
+
]
|
|
1646
|
+
);
|
|
1647
|
+
return /* @__PURE__ */ jsx7(AsgardeoContext_default.Provider, { value, children: /* @__PURE__ */ jsx7(I18nProvider_default, { preferences: preferences?.i18n, children: /* @__PURE__ */ jsx7(
|
|
1648
|
+
BrandingProvider_default,
|
|
1615
1649
|
{
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
isInitialized: isInitializedSync,
|
|
1624
|
-
isLoading: isLoadingSync,
|
|
1625
|
-
isSignedIn: isSignedInSync,
|
|
1626
|
-
organization: currentOrganization,
|
|
1627
|
-
signIn,
|
|
1628
|
-
signInSilently,
|
|
1629
|
-
signOut,
|
|
1630
|
-
signUp,
|
|
1631
|
-
user
|
|
1632
|
-
},
|
|
1633
|
-
children: /* @__PURE__ */ jsx7(I18nProvider_default, { preferences: preferences?.i18n, children: /* @__PURE__ */ jsx7(
|
|
1634
|
-
BrandingProvider_default,
|
|
1650
|
+
brandingPreference,
|
|
1651
|
+
isLoading: isBrandingLoading,
|
|
1652
|
+
error: brandingError,
|
|
1653
|
+
enabled: preferences?.theme?.inheritFromBranding !== false,
|
|
1654
|
+
refetch: refetchBranding,
|
|
1655
|
+
children: /* @__PURE__ */ jsx7(
|
|
1656
|
+
ThemeProvider_default,
|
|
1635
1657
|
{
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
children: /* @__PURE__ */ jsx7(
|
|
1642
|
-
ThemeProvider_default,
|
|
1658
|
+
inheritFromBranding: preferences?.theme?.inheritFromBranding,
|
|
1659
|
+
theme: preferences?.theme?.overrides,
|
|
1660
|
+
mode: isDarkMode ? "dark" : "light",
|
|
1661
|
+
children: /* @__PURE__ */ jsx7(FlowProvider_default, { children: /* @__PURE__ */ jsx7(UserProvider_default, { profile: userProfile, onUpdateProfile: handleProfileUpdate, children: /* @__PURE__ */ jsx7(
|
|
1662
|
+
OrganizationProvider_default,
|
|
1643
1663
|
{
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
getAllOrganizations: async () => await asgardeo.getAllOrganizations(),
|
|
1651
|
-
myOrganizations,
|
|
1652
|
-
currentOrganization,
|
|
1653
|
-
onOrganizationSwitch: switchOrganization,
|
|
1654
|
-
revalidateMyOrganizations: async () => await asgardeo.getMyOrganizations(),
|
|
1655
|
-
children
|
|
1656
|
-
}
|
|
1657
|
-
) }) })
|
|
1664
|
+
getAllOrganizations: async () => await asgardeo.getAllOrganizations(),
|
|
1665
|
+
myOrganizations,
|
|
1666
|
+
currentOrganization,
|
|
1667
|
+
onOrganizationSwitch: switchOrganization,
|
|
1668
|
+
revalidateMyOrganizations: async () => await asgardeo.getMyOrganizations(),
|
|
1669
|
+
children
|
|
1658
1670
|
}
|
|
1659
|
-
)
|
|
1671
|
+
) }) })
|
|
1660
1672
|
}
|
|
1661
|
-
)
|
|
1673
|
+
)
|
|
1662
1674
|
}
|
|
1663
|
-
);
|
|
1675
|
+
) }) });
|
|
1664
1676
|
};
|
|
1665
1677
|
var AsgardeoProvider_default = AsgardeoProvider;
|
|
1666
1678
|
|