@asgardeo/react 0.9.3 → 0.11.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.
@@ -26,7 +26,17 @@ import { AsgardeoReactConfig } from './models/config';
26
26
  declare class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactConfig> extends AsgardeoBrowserClient<T> {
27
27
  private asgardeo;
28
28
  private _isLoading;
29
- constructor();
29
+ private _instanceId;
30
+ /**
31
+ * Creates a new AsgardeoReactClient instance.
32
+ * @param instanceId - Optional instance ID for multi-auth context support. Defaults to 0 for backward compatibility.
33
+ */
34
+ constructor(instanceId?: number);
35
+ /**
36
+ * Get the instance ID for this client.
37
+ * @returns The instance ID used for multi-auth context support.
38
+ */
39
+ getInstanceId(): number;
30
40
  /**
31
41
  * Set the loading state of the client
32
42
  * @param loading - Boolean indicating if the client is in a loading state
@@ -43,6 +53,7 @@ declare class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactC
43
53
  updateUserProfile(payload: any, userId?: string): Promise<User>;
44
54
  getUser(options?: any): Promise<User>;
45
55
  getDecodedIdToken(sessionId?: string): Promise<IdToken>;
56
+ getIdToken(): Promise<string>;
46
57
  getUserProfile(options?: any): Promise<UserProfile>;
47
58
  getMyOrganizations(options?: any, sessionId?: string): Promise<Organization[]>;
48
59
  getAllOrganizations(options?: any, sessionId?: string): Promise<AllOrganizationsApiResponse>;
@@ -21,8 +21,14 @@ declare class AuthAPI {
21
21
  static DEFAULT_STATE: AuthStateInterface;
22
22
  private _authState;
23
23
  private _client;
24
+ private _instanceId;
24
25
  private _isLoading;
25
- constructor(spaClient?: AsgardeoSPAClient);
26
+ constructor(spaClient?: AsgardeoSPAClient, instanceId?: number);
27
+ /**
28
+ * Get the instance ID for this AuthAPI instance.
29
+ * @returns The instance ID used for multi-auth context support.
30
+ */
31
+ getInstanceId(): number;
26
32
  _setIsLoading(isLoading: boolean): void;
27
33
  _getIsLoading(): boolean;
28
34
  isLoading(): boolean;
package/dist/cjs/index.js CHANGED
@@ -194,6 +194,7 @@ var AsgardeoContext = (0, import_react.createContext)({
194
194
  },
195
195
  signInOptions: {},
196
196
  getDecodedIdToken: null,
197
+ getIdToken: null,
197
198
  getAccessToken: null,
198
199
  exchangeToken: null,
199
200
  storage: "sessionStorage",
@@ -210,17 +211,26 @@ var import_browser6 = require("@asgardeo/browser");
210
211
  // src/__temp__/api.ts
211
212
  var import_browser = require("@asgardeo/browser");
212
213
  var _AuthAPI = class _AuthAPI {
213
- constructor(spaClient) {
214
+ constructor(spaClient, instanceId = 0) {
214
215
  __publicField(this, "_authState", _AuthAPI.DEFAULT_STATE);
215
216
  __publicField(this, "_client");
217
+ __publicField(this, "_instanceId");
216
218
  __publicField(this, "_isLoading");
217
- this._client = spaClient ?? import_browser.AsgardeoSPAClient.getInstance();
219
+ this._instanceId = instanceId;
220
+ this._client = spaClient ?? import_browser.AsgardeoSPAClient.getInstance(instanceId);
218
221
  this.getState = this.getState.bind(this);
219
222
  this.init = this.init.bind(this);
220
223
  this.signIn = this.signIn.bind(this);
221
224
  this.signOut = this.signOut.bind(this);
222
225
  this.updateState = this.updateState.bind(this);
223
226
  }
227
+ /**
228
+ * Get the instance ID for this AuthAPI instance.
229
+ * @returns The instance ID used for multi-auth context support.
230
+ */
231
+ getInstanceId() {
232
+ return this._instanceId;
233
+ }
224
234
  _setIsLoading(isLoading) {
225
235
  this._isLoading = isLoading;
226
236
  }
@@ -665,11 +675,24 @@ var getAllOrganizations_default = getAllOrganizations;
665
675
 
666
676
  // src/AsgardeoReactClient.ts
667
677
  var AsgardeoReactClient = class extends import_browser6.AsgardeoBrowserClient {
668
- constructor() {
678
+ /**
679
+ * Creates a new AsgardeoReactClient instance.
680
+ * @param instanceId - Optional instance ID for multi-auth context support. Defaults to 0 for backward compatibility.
681
+ */
682
+ constructor(instanceId = 0) {
669
683
  super();
670
684
  __publicField(this, "asgardeo");
671
685
  __publicField(this, "_isLoading", false);
672
- this.asgardeo = new api_default();
686
+ __publicField(this, "_instanceId");
687
+ this._instanceId = instanceId;
688
+ this.asgardeo = new api_default(void 0, instanceId);
689
+ }
690
+ /**
691
+ * Get the instance ID for this client.
692
+ * @returns The instance ID used for multi-auth context support.
693
+ */
694
+ getInstanceId() {
695
+ return this._instanceId;
673
696
  }
674
697
  /**
675
698
  * Set the loading state of the client
@@ -738,6 +761,11 @@ var AsgardeoReactClient = class extends import_browser6.AsgardeoBrowserClient {
738
761
  async getDecodedIdToken(sessionId) {
739
762
  return this.asgardeo.getDecodedIdToken(sessionId);
740
763
  }
764
+ async getIdToken() {
765
+ return this.withLoading(async () => {
766
+ return this.asgardeo.getIdToken();
767
+ });
768
+ }
741
769
  async getUserProfile(options) {
742
770
  return this.withLoading(async () => {
743
771
  try {
@@ -1619,10 +1647,11 @@ var AsgardeoProvider = ({
1619
1647
  applicationId,
1620
1648
  signInOptions,
1621
1649
  syncSession,
1650
+ instanceId = 0,
1622
1651
  ...rest
1623
1652
  }) => {
1624
1653
  const reRenderCheckRef = (0, import_react15.useRef)(false);
1625
- const asgardeo = (0, import_react15.useMemo)(() => new AsgardeoReactClient_default(), []);
1654
+ const asgardeo = (0, import_react15.useMemo)(() => new AsgardeoReactClient_default(instanceId), [instanceId]);
1626
1655
  const { hasAuthParams } = useBrowserUrl_default();
1627
1656
  const [user, setUser] = (0, import_react15.useState)(null);
1628
1657
  const [currentOrganization, setCurrentOrganization] = (0, import_react15.useState)(null);
@@ -1937,6 +1966,9 @@ var AsgardeoProvider = ({
1937
1966
  const getDecodedIdToken = (0, import_react15.useCallback)(async () => {
1938
1967
  return await asgardeo.getDecodedIdToken();
1939
1968
  }, [asgardeo]);
1969
+ const getIdToken = (0, import_react15.useCallback)(async () => {
1970
+ return await asgardeo.getIdToken();
1971
+ }, [asgardeo]);
1940
1972
  const getAccessToken = (0, import_react15.useCallback)(async () => {
1941
1973
  return await asgardeo.getAccessToken();
1942
1974
  }, [asgardeo]);
@@ -2008,6 +2040,7 @@ var AsgardeoProvider = ({
2008
2040
  reInitialize,
2009
2041
  signInOptions,
2010
2042
  getDecodedIdToken,
2043
+ getIdToken,
2011
2044
  exchangeToken,
2012
2045
  syncSession,
2013
2046
  platform: config?.platform,