@asgardeo/react 0.6.13 → 0.6.15

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.
@@ -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<void>;
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
  });
@@ -1759,10 +1760,11 @@ var AsgardeoProvider = ({
1759
1760
  try {
1760
1761
  setIsUpdatingSession(true);
1761
1762
  setIsLoadingSync(true);
1762
- await asgardeo.switchOrganization(organization);
1763
+ const response = await asgardeo.switchOrganization(organization);
1763
1764
  if (await asgardeo.isSignedIn()) {
1764
1765
  await updateSession();
1765
1766
  }
1767
+ return response;
1766
1768
  } catch (error) {
1767
1769
  throw new AsgardeoRuntimeError3(
1768
1770
  `Failed to switch organization: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,
@@ -1811,7 +1813,8 @@ var AsgardeoProvider = ({
1811
1813
  getDecodedIdToken: asgardeo.getDecodedIdToken.bind(asgardeo),
1812
1814
  exchangeToken: asgardeo.exchangeToken.bind(asgardeo),
1813
1815
  syncSession,
1814
- platform: config?.platform
1816
+ platform: config?.platform,
1817
+ switchOrganization
1815
1818
  }),
1816
1819
  [
1817
1820
  applicationId,
@@ -1829,7 +1832,8 @@ var AsgardeoProvider = ({
1829
1832
  user,
1830
1833
  asgardeo,
1831
1834
  signInOptions,
1832
- syncSession
1835
+ syncSession,
1836
+ switchOrganization
1833
1837
  ]
1834
1838
  );
1835
1839
  return /* @__PURE__ */ jsx7(AsgardeoContext_default.Provider, { value, children: /* @__PURE__ */ jsx7(I18nProvider_default, { preferences: preferences?.i18n, children: /* @__PURE__ */ jsx7(