@asgardeo/react 0.5.9 → 0.5.11
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 +3 -1
- package/dist/__temp__/api.d.ts +2 -2
- package/dist/cjs/index.js +80 -79
- package/dist/cjs/index.js.map +2 -2
- package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +16 -4
- package/dist/index.js +80 -79
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
|
@@ -58,6 +58,8 @@ declare class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactC
|
|
|
58
58
|
signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
|
|
59
59
|
signUp(options?: SignUpOptions): Promise<void>;
|
|
60
60
|
signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
|
|
61
|
-
|
|
61
|
+
request(requestConfig?: HttpRequestConfig): Promise<HttpResponse<any>>;
|
|
62
|
+
requestAll(requestConfigs?: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
|
|
63
|
+
getAccessToken(sessionId?: string): Promise<string>;
|
|
62
64
|
}
|
|
63
65
|
export default AsgardeoReactClient;
|
package/dist/__temp__/api.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ declare class AuthAPI {
|
|
|
110
110
|
* @return {Promise<Response | SignInResponse>} - A Promise that resolves with
|
|
111
111
|
* the value returned by the custom grant request.
|
|
112
112
|
*/
|
|
113
|
-
exchangeToken(config: SPACustomGrantConfig, callback: (response: User | Response) => void
|
|
113
|
+
exchangeToken(config: SPACustomGrantConfig, callback: (response: User | Response) => void): Promise<User | Response>;
|
|
114
114
|
/**
|
|
115
115
|
* This method ends a user session. The access token is revoked and the session information is destroyed.
|
|
116
116
|
*
|
|
@@ -156,7 +156,7 @@ declare class AuthAPI {
|
|
|
156
156
|
*
|
|
157
157
|
* @return {Promise<string>} - A Promise that resolves with the access token.
|
|
158
158
|
*/
|
|
159
|
-
getAccessToken(): Promise<string>;
|
|
159
|
+
getAccessToken(sessionId?: string): Promise<string>;
|
|
160
160
|
/**
|
|
161
161
|
* This method return a Promise that resolves with the idp access token.
|
|
162
162
|
*
|
package/dist/cjs/index.js
CHANGED
|
@@ -172,7 +172,10 @@ var AsgardeoContext = (0, import_react.createContext)({
|
|
|
172
172
|
signOut: null,
|
|
173
173
|
signUp: null,
|
|
174
174
|
user: null,
|
|
175
|
-
|
|
175
|
+
http: {
|
|
176
|
+
request: () => null,
|
|
177
|
+
requestAll: () => null
|
|
178
|
+
}
|
|
176
179
|
});
|
|
177
180
|
AsgardeoContext.displayName = "AsgardeoContext";
|
|
178
181
|
var AsgardeoContext_default = AsgardeoContext;
|
|
@@ -330,7 +333,7 @@ var _AuthAPI = class _AuthAPI {
|
|
|
330
333
|
* @return {Promise<Response | SignInResponse>} - A Promise that resolves with
|
|
331
334
|
* the value returned by the custom grant request.
|
|
332
335
|
*/
|
|
333
|
-
exchangeToken(config, callback
|
|
336
|
+
exchangeToken(config, callback) {
|
|
334
337
|
return this._client.exchangeToken(config).then((response) => {
|
|
335
338
|
if (!response) {
|
|
336
339
|
return null;
|
|
@@ -342,7 +345,6 @@ var _AuthAPI = class _AuthAPI {
|
|
|
342
345
|
isSignedIn: true,
|
|
343
346
|
isLoading: false
|
|
344
347
|
});
|
|
345
|
-
dispatch({ ...response, isSignedIn: true, isLoading: false });
|
|
346
348
|
}
|
|
347
349
|
callback && callback(response);
|
|
348
350
|
return response;
|
|
@@ -409,8 +411,8 @@ var _AuthAPI = class _AuthAPI {
|
|
|
409
411
|
*
|
|
410
412
|
* @return {Promise<string>} - A Promise that resolves with the access token.
|
|
411
413
|
*/
|
|
412
|
-
async getAccessToken() {
|
|
413
|
-
return this._client.getAccessToken();
|
|
414
|
+
async getAccessToken(sessionId) {
|
|
415
|
+
return this._client.getAccessToken(sessionId);
|
|
414
416
|
}
|
|
415
417
|
/**
|
|
416
418
|
* This method return a Promise that resolves with the idp access token.
|
|
@@ -743,7 +745,6 @@ var AsgardeoReactClient = class extends import_browser6.AsgardeoBrowserClient {
|
|
|
743
745
|
return this.withLoading(async () => {
|
|
744
746
|
try {
|
|
745
747
|
const configData = await this.asgardeo.getConfigData();
|
|
746
|
-
const scopes = configData?.scopes;
|
|
747
748
|
if (!organization.id) {
|
|
748
749
|
throw new import_browser6.AsgardeoRuntimeError(
|
|
749
750
|
"Organization ID is required for switching organizations",
|
|
@@ -765,12 +766,8 @@ var AsgardeoReactClient = class extends import_browser6.AsgardeoBrowserClient {
|
|
|
765
766
|
returnsSession: true,
|
|
766
767
|
signInRequired: true
|
|
767
768
|
};
|
|
768
|
-
return await this.asgardeo.exchangeToken(
|
|
769
|
-
|
|
770
|
-
(user) => {
|
|
771
|
-
},
|
|
772
|
-
() => null
|
|
773
|
-
);
|
|
769
|
+
return await this.asgardeo.exchangeToken(exchangeConfig, (user) => {
|
|
770
|
+
});
|
|
774
771
|
} catch (error) {
|
|
775
772
|
throw new import_browser6.AsgardeoRuntimeError(
|
|
776
773
|
`Failed to switch organization: ${error.message || error}`,
|
|
@@ -843,11 +840,14 @@ var AsgardeoReactClient = class extends import_browser6.AsgardeoBrowserClient {
|
|
|
843
840
|
"The signUp method with SignUpOptions is not implemented in the React client."
|
|
844
841
|
);
|
|
845
842
|
}
|
|
846
|
-
async
|
|
847
|
-
return this.asgardeo.httpRequest(
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
843
|
+
async request(requestConfig) {
|
|
844
|
+
return this.asgardeo.httpRequest(requestConfig);
|
|
845
|
+
}
|
|
846
|
+
async requestAll(requestConfigs) {
|
|
847
|
+
return this.asgardeo.httpRequestAll(requestConfigs);
|
|
848
|
+
}
|
|
849
|
+
async getAccessToken(sessionId) {
|
|
850
|
+
return this.asgardeo.getAccessToken(sessionId);
|
|
851
851
|
}
|
|
852
852
|
};
|
|
853
853
|
var AsgardeoReactClient_default = AsgardeoReactClient;
|
|
@@ -1684,19 +1684,6 @@ var AsgardeoProvider = ({
|
|
|
1684
1684
|
setIsLoadingSync(asgardeo.isLoading());
|
|
1685
1685
|
}
|
|
1686
1686
|
};
|
|
1687
|
-
const signUp = async (payload) => {
|
|
1688
|
-
try {
|
|
1689
|
-
return await asgardeo.signUp(payload);
|
|
1690
|
-
} catch (error) {
|
|
1691
|
-
throw new import_browser13.AsgardeoRuntimeError(
|
|
1692
|
-
`Error while signing up: ${error.message || error}`,
|
|
1693
|
-
"asgardeo-signUp-Error",
|
|
1694
|
-
"react",
|
|
1695
|
-
"An error occurred while trying to sign up."
|
|
1696
|
-
);
|
|
1697
|
-
}
|
|
1698
|
-
};
|
|
1699
|
-
const signOut = async (options, afterSignOut) => asgardeo.signOut(options, afterSignOut);
|
|
1700
1687
|
const switchOrganization = async (organization) => {
|
|
1701
1688
|
try {
|
|
1702
1689
|
setIsLoadingSync(true);
|
|
@@ -1729,61 +1716,75 @@ var AsgardeoProvider = ({
|
|
|
1729
1716
|
flattenedProfile: (0, import_browser13.generateFlattenedUserProfile)(payload, prev?.schemas)
|
|
1730
1717
|
}));
|
|
1731
1718
|
};
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1719
|
+
const value = (0, import_react15.useMemo)(
|
|
1720
|
+
() => ({
|
|
1721
|
+
applicationId,
|
|
1722
|
+
organizationHandle: config?.organizationHandle,
|
|
1723
|
+
signInUrl,
|
|
1724
|
+
signUpUrl,
|
|
1725
|
+
afterSignInUrl,
|
|
1726
|
+
baseUrl,
|
|
1727
|
+
getAccessToken: asgardeo.getAccessToken.bind(asgardeo),
|
|
1728
|
+
isInitialized: isInitializedSync,
|
|
1729
|
+
isLoading: isLoadingSync,
|
|
1730
|
+
isSignedIn: isSignedInSync,
|
|
1731
|
+
organization: currentOrganization,
|
|
1732
|
+
signIn,
|
|
1733
|
+
signInSilently,
|
|
1734
|
+
signOut: asgardeo.signOut.bind(asgardeo),
|
|
1735
|
+
signUp: asgardeo.signUp.bind(asgardeo),
|
|
1736
|
+
user,
|
|
1737
|
+
http: {
|
|
1738
|
+
request: asgardeo.request.bind(asgardeo),
|
|
1739
|
+
requestAll: asgardeo.requestAll.bind(asgardeo)
|
|
1740
|
+
}
|
|
1741
|
+
}),
|
|
1742
|
+
[
|
|
1743
|
+
applicationId,
|
|
1744
|
+
config?.organizationHandle,
|
|
1745
|
+
signInUrl,
|
|
1746
|
+
signUpUrl,
|
|
1747
|
+
afterSignInUrl,
|
|
1748
|
+
baseUrl,
|
|
1749
|
+
isInitializedSync,
|
|
1750
|
+
isLoadingSync,
|
|
1751
|
+
isSignedInSync,
|
|
1752
|
+
currentOrganization,
|
|
1753
|
+
signIn,
|
|
1754
|
+
signInSilently,
|
|
1755
|
+
user,
|
|
1756
|
+
asgardeo
|
|
1757
|
+
]
|
|
1758
|
+
);
|
|
1759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AsgardeoContext_default.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(I18nProvider_default, { preferences: preferences?.i18n, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1760
|
+
BrandingProvider_default,
|
|
1737
1761
|
{
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
isInitialized: isInitializedSync,
|
|
1746
|
-
isLoading: isLoadingSync,
|
|
1747
|
-
isSignedIn: isSignedInSync,
|
|
1748
|
-
organization: currentOrganization,
|
|
1749
|
-
signIn,
|
|
1750
|
-
signInSilently,
|
|
1751
|
-
signOut,
|
|
1752
|
-
signUp,
|
|
1753
|
-
user,
|
|
1754
|
-
fetch
|
|
1755
|
-
},
|
|
1756
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(I18nProvider_default, { preferences: preferences?.i18n, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1757
|
-
BrandingProvider_default,
|
|
1762
|
+
brandingPreference,
|
|
1763
|
+
isLoading: isBrandingLoading,
|
|
1764
|
+
error: brandingError,
|
|
1765
|
+
enabled: preferences?.theme?.inheritFromBranding !== false,
|
|
1766
|
+
refetch: refetchBranding,
|
|
1767
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1768
|
+
ThemeProvider_default,
|
|
1758
1769
|
{
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1765
|
-
ThemeProvider_default,
|
|
1770
|
+
inheritFromBranding: preferences?.theme?.inheritFromBranding,
|
|
1771
|
+
theme: preferences?.theme?.overrides,
|
|
1772
|
+
mode: isDarkMode ? "dark" : "light",
|
|
1773
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FlowProvider_default, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(UserProvider_default, { profile: userProfile, onUpdateProfile: handleProfileUpdate, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1774
|
+
OrganizationProvider_default,
|
|
1766
1775
|
{
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
getAllOrganizations: async () => await asgardeo.getAllOrganizations(),
|
|
1774
|
-
myOrganizations,
|
|
1775
|
-
currentOrganization,
|
|
1776
|
-
onOrganizationSwitch: switchOrganization,
|
|
1777
|
-
revalidateMyOrganizations: async () => await asgardeo.getMyOrganizations(),
|
|
1778
|
-
children
|
|
1779
|
-
}
|
|
1780
|
-
) }) })
|
|
1776
|
+
getAllOrganizations: async () => await asgardeo.getAllOrganizations(),
|
|
1777
|
+
myOrganizations,
|
|
1778
|
+
currentOrganization,
|
|
1779
|
+
onOrganizationSwitch: switchOrganization,
|
|
1780
|
+
revalidateMyOrganizations: async () => await asgardeo.getMyOrganizations(),
|
|
1781
|
+
children
|
|
1781
1782
|
}
|
|
1782
|
-
)
|
|
1783
|
+
) }) })
|
|
1783
1784
|
}
|
|
1784
|
-
)
|
|
1785
|
+
)
|
|
1785
1786
|
}
|
|
1786
|
-
);
|
|
1787
|
+
) }) });
|
|
1787
1788
|
};
|
|
1788
1789
|
var AsgardeoProvider_default = AsgardeoProvider;
|
|
1789
1790
|
|