@asgardeo/react 0.9.2 → 0.10.0

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.
@@ -99,6 +99,13 @@ export type AsgardeoContextProps = {
99
99
  * @returns A promise that resolves to the decoded ID token payload.
100
100
  */
101
101
  getDecodedIdToken: () => Promise<IdToken>;
102
+ /**
103
+ * Function to retrieve the ID token.
104
+ * This function retrieves the ID token and returns it.
105
+ *
106
+ * @returns A promise that resolves to the ID token.
107
+ */
108
+ getIdToken: () => Promise<string>;
102
109
  /**
103
110
  * Retrieves the access token stored in the storage.
104
111
  * This function retrieves the access token and returns it.
package/dist/index.js CHANGED
@@ -39,6 +39,7 @@ var AsgardeoContext = createContext({
39
39
  },
40
40
  signInOptions: {},
41
41
  getDecodedIdToken: null,
42
+ getIdToken: null,
42
43
  getAccessToken: null,
43
44
  exchangeToken: null,
44
45
  storage: "sessionStorage",
@@ -75,17 +76,26 @@ import {
75
76
  Hooks
76
77
  } from "@asgardeo/browser";
77
78
  var _AuthAPI = class _AuthAPI {
78
- constructor(spaClient) {
79
+ constructor(spaClient, instanceId = 0) {
79
80
  __publicField(this, "_authState", _AuthAPI.DEFAULT_STATE);
80
81
  __publicField(this, "_client");
82
+ __publicField(this, "_instanceId");
81
83
  __publicField(this, "_isLoading");
82
- this._client = spaClient ?? AsgardeoSPAClient.getInstance();
84
+ this._instanceId = instanceId;
85
+ this._client = spaClient ?? AsgardeoSPAClient.getInstance(instanceId);
83
86
  this.getState = this.getState.bind(this);
84
87
  this.init = this.init.bind(this);
85
88
  this.signIn = this.signIn.bind(this);
86
89
  this.signOut = this.signOut.bind(this);
87
90
  this.updateState = this.updateState.bind(this);
88
91
  }
92
+ /**
93
+ * Get the instance ID for this AuthAPI instance.
94
+ * @returns The instance ID used for multi-auth context support.
95
+ */
96
+ getInstanceId() {
97
+ return this._instanceId;
98
+ }
89
99
  _setIsLoading(isLoading) {
90
100
  this._isLoading = isLoading;
91
101
  }
@@ -542,11 +552,24 @@ var getAllOrganizations_default = getAllOrganizations;
542
552
 
543
553
  // src/AsgardeoReactClient.ts
544
554
  var AsgardeoReactClient = class extends AsgardeoBrowserClient {
545
- constructor() {
555
+ /**
556
+ * Creates a new AsgardeoReactClient instance.
557
+ * @param instanceId - Optional instance ID for multi-auth context support. Defaults to 0 for backward compatibility.
558
+ */
559
+ constructor(instanceId = 0) {
546
560
  super();
547
561
  __publicField(this, "asgardeo");
548
562
  __publicField(this, "_isLoading", false);
549
- this.asgardeo = new api_default();
563
+ __publicField(this, "_instanceId");
564
+ this._instanceId = instanceId;
565
+ this.asgardeo = new api_default(void 0, instanceId);
566
+ }
567
+ /**
568
+ * Get the instance ID for this client.
569
+ * @returns The instance ID used for multi-auth context support.
570
+ */
571
+ getInstanceId() {
572
+ return this._instanceId;
550
573
  }
551
574
  /**
552
575
  * Set the loading state of the client
@@ -615,6 +638,11 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
615
638
  async getDecodedIdToken(sessionId) {
616
639
  return this.asgardeo.getDecodedIdToken(sessionId);
617
640
  }
641
+ async getIdToken() {
642
+ return this.withLoading(async () => {
643
+ return this.asgardeo.getIdToken();
644
+ });
645
+ }
618
646
  async getUserProfile(options) {
619
647
  return this.withLoading(async () => {
620
648
  try {
@@ -1504,10 +1532,11 @@ var AsgardeoProvider = ({
1504
1532
  applicationId,
1505
1533
  signInOptions,
1506
1534
  syncSession,
1535
+ instanceId = 0,
1507
1536
  ...rest
1508
1537
  }) => {
1509
1538
  const reRenderCheckRef = useRef(false);
1510
- const asgardeo = useMemo6(() => new AsgardeoReactClient_default(), []);
1539
+ const asgardeo = useMemo6(() => new AsgardeoReactClient_default(instanceId), [instanceId]);
1511
1540
  const { hasAuthParams } = useBrowserUrl_default();
1512
1541
  const [user, setUser] = useState7(null);
1513
1542
  const [currentOrganization, setCurrentOrganization] = useState7(null);
@@ -1822,6 +1851,9 @@ var AsgardeoProvider = ({
1822
1851
  const getDecodedIdToken = useCallback7(async () => {
1823
1852
  return await asgardeo.getDecodedIdToken();
1824
1853
  }, [asgardeo]);
1854
+ const getIdToken = useCallback7(async () => {
1855
+ return await asgardeo.getIdToken();
1856
+ }, [asgardeo]);
1825
1857
  const getAccessToken = useCallback7(async () => {
1826
1858
  return await asgardeo.getAccessToken();
1827
1859
  }, [asgardeo]);
@@ -1893,6 +1925,7 @@ var AsgardeoProvider = ({
1893
1925
  reInitialize,
1894
1926
  signInOptions,
1895
1927
  getDecodedIdToken,
1928
+ getIdToken,
1896
1929
  exchangeToken,
1897
1930
  syncSession,
1898
1931
  platform: config?.platform,