@asgardeo/react 0.6.12 → 0.6.14
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 +4 -116
- package/dist/cjs/index.js +21 -8
- package/dist/cjs/index.js.map +2 -2
- package/dist/contexts/Asgardeo/AsgardeoContext.d.ts +1 -1
- package/dist/contexts/Organization/OrganizationProvider.d.ts +2 -2
- package/dist/index.js +21 -8
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
|
@@ -122,7 +122,7 @@ export type AsgardeoContextProps = {
|
|
|
122
122
|
* @returns Promise resolving to boolean indicating success.
|
|
123
123
|
*/
|
|
124
124
|
reInitialize: (config: Partial<AsgardeoReactConfig>) => Promise<boolean>;
|
|
125
|
-
} & Pick<AsgardeoReactConfig, 'storage' | 'platform'> & Pick<AsgardeoReactClient, 'clearSession'>;
|
|
125
|
+
} & Pick<AsgardeoReactConfig, 'storage' | 'platform'> & Pick<AsgardeoReactClient, 'clearSession' | 'switchOrganization'>;
|
|
126
126
|
/**
|
|
127
127
|
* Context object for managing the Authentication flow builder core context.
|
|
128
128
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { Organization, AllOrganizationsApiResponse, CreateOrganizationPayload } from '@asgardeo/browser';
|
|
18
|
+
import { Organization, AllOrganizationsApiResponse, CreateOrganizationPayload, TokenResponse } from '@asgardeo/browser';
|
|
19
19
|
import { FC, PropsWithChildren } from 'react';
|
|
20
20
|
/**
|
|
21
21
|
* Props interface of {@link OrganizationProvider}
|
|
@@ -48,7 +48,7 @@ export interface OrganizationProviderProps {
|
|
|
48
48
|
/**
|
|
49
49
|
* Callback function called when switching organizations
|
|
50
50
|
*/
|
|
51
|
-
onOrganizationSwitch?: (organization: Organization) => Promise<
|
|
51
|
+
onOrganizationSwitch?: (organization: Organization) => Promise<TokenResponse | Response>;
|
|
52
52
|
/**
|
|
53
53
|
* Refetch the my organizations list.
|
|
54
54
|
* @returns
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ var AsgardeoContext = createContext({
|
|
|
42
42
|
getAccessToken: null,
|
|
43
43
|
exchangeToken: null,
|
|
44
44
|
storage: "sessionStorage",
|
|
45
|
+
switchOrganization: null,
|
|
45
46
|
reInitialize: null,
|
|
46
47
|
platform: void 0
|
|
47
48
|
});
|
|
@@ -1555,8 +1556,12 @@ var AsgardeoProvider = ({
|
|
|
1555
1556
|
);
|
|
1556
1557
|
}
|
|
1557
1558
|
} catch (error) {
|
|
1558
|
-
|
|
1559
|
-
|
|
1559
|
+
throw new AsgardeoRuntimeError3(
|
|
1560
|
+
`Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,
|
|
1561
|
+
"asgardeo-signIn-Error",
|
|
1562
|
+
"react",
|
|
1563
|
+
"An error occurred while trying to sign in."
|
|
1564
|
+
);
|
|
1560
1565
|
}
|
|
1561
1566
|
} else {
|
|
1562
1567
|
}
|
|
@@ -1717,7 +1722,12 @@ var AsgardeoProvider = ({
|
|
|
1717
1722
|
}
|
|
1718
1723
|
return response;
|
|
1719
1724
|
} catch (error) {
|
|
1720
|
-
throw new
|
|
1725
|
+
throw new AsgardeoRuntimeError3(
|
|
1726
|
+
`Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,
|
|
1727
|
+
"asgardeo-signIn-Error",
|
|
1728
|
+
"react",
|
|
1729
|
+
"An error occurred while trying to sign in."
|
|
1730
|
+
);
|
|
1721
1731
|
} finally {
|
|
1722
1732
|
if (!isV2FlowRequest) {
|
|
1723
1733
|
setIsUpdatingSession(false);
|
|
@@ -1736,7 +1746,7 @@ var AsgardeoProvider = ({
|
|
|
1736
1746
|
return response;
|
|
1737
1747
|
} catch (error) {
|
|
1738
1748
|
throw new AsgardeoRuntimeError3(
|
|
1739
|
-
`Error while signing in silently: ${error.message
|
|
1749
|
+
`Error while signing in silently: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,
|
|
1740
1750
|
"asgardeo-signInSilently-Error",
|
|
1741
1751
|
"react",
|
|
1742
1752
|
"An error occurred while trying to sign in silently."
|
|
@@ -1750,13 +1760,14 @@ var AsgardeoProvider = ({
|
|
|
1750
1760
|
try {
|
|
1751
1761
|
setIsUpdatingSession(true);
|
|
1752
1762
|
setIsLoadingSync(true);
|
|
1753
|
-
await asgardeo.switchOrganization(organization);
|
|
1763
|
+
const response = await asgardeo.switchOrganization(organization);
|
|
1754
1764
|
if (await asgardeo.isSignedIn()) {
|
|
1755
1765
|
await updateSession();
|
|
1756
1766
|
}
|
|
1767
|
+
return response;
|
|
1757
1768
|
} catch (error) {
|
|
1758
1769
|
throw new AsgardeoRuntimeError3(
|
|
1759
|
-
`Failed to switch organization: ${error.message
|
|
1770
|
+
`Failed to switch organization: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,
|
|
1760
1771
|
"asgardeo-switchOrganization-Error",
|
|
1761
1772
|
"react",
|
|
1762
1773
|
"An error occurred while switching to the specified organization."
|
|
@@ -1802,7 +1813,8 @@ var AsgardeoProvider = ({
|
|
|
1802
1813
|
getDecodedIdToken: asgardeo.getDecodedIdToken.bind(asgardeo),
|
|
1803
1814
|
exchangeToken: asgardeo.exchangeToken.bind(asgardeo),
|
|
1804
1815
|
syncSession,
|
|
1805
|
-
platform: config?.platform
|
|
1816
|
+
platform: config?.platform,
|
|
1817
|
+
switchOrganization
|
|
1806
1818
|
}),
|
|
1807
1819
|
[
|
|
1808
1820
|
applicationId,
|
|
@@ -1820,7 +1832,8 @@ var AsgardeoProvider = ({
|
|
|
1820
1832
|
user,
|
|
1821
1833
|
asgardeo,
|
|
1822
1834
|
signInOptions,
|
|
1823
|
-
syncSession
|
|
1835
|
+
syncSession,
|
|
1836
|
+
switchOrganization
|
|
1824
1837
|
]
|
|
1825
1838
|
);
|
|
1826
1839
|
return /* @__PURE__ */ jsx7(AsgardeoContext_default.Provider, { value, children: /* @__PURE__ */ jsx7(I18nProvider_default, { preferences: preferences?.i18n, children: /* @__PURE__ */ jsx7(
|