@asgardeo/react 0.9.1 → 0.9.2

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/index.js CHANGED
@@ -65,7 +65,8 @@ import {
65
65
  getRedirectBasedSignUpUrl,
66
66
  Platform,
67
67
  isEmpty,
68
- executeEmbeddedSignUpFlowV2
68
+ executeEmbeddedSignUpFlowV2,
69
+ EmbeddedSignInFlowStatusV2
69
70
  } from "@asgardeo/browser";
70
71
 
71
72
  // src/__temp__/api.ts
@@ -118,6 +119,9 @@ var _AuthAPI = class _AuthAPI {
118
119
  async getConfigData() {
119
120
  return this._client.getConfigData();
120
121
  }
122
+ async getStorageManager() {
123
+ return this._client.getStorageManager();
124
+ }
121
125
  /**
122
126
  * Method to get the configuration data.
123
127
  *
@@ -266,6 +270,15 @@ var _AuthAPI = class _AuthAPI {
266
270
  async getHttpClient() {
267
271
  return this._client.getHttpClient();
268
272
  }
273
+ /**
274
+ * This method decodes a JWT token payload and returns it.
275
+ *
276
+ * @param token - The token to decode.
277
+ * @returns The decoded token payload.
278
+ */
279
+ async decodeJwtToken(token) {
280
+ return this._client.decodeJwtToken(token);
281
+ }
269
282
  /**
270
283
  * This method decodes the payload of the id token and returns it.
271
284
  *
@@ -752,12 +765,26 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
752
765
  const authId = authIdFromUrl || authIdFromStorage;
753
766
  const baseUrlFromStorage = sessionStorage.getItem("asgardeo_base_url");
754
767
  const baseUrl = config?.baseUrl || baseUrlFromStorage;
755
- return executeEmbeddedSignInFlowV2({
768
+ const response = await executeEmbeddedSignInFlowV2({
756
769
  payload: arg1,
757
770
  url: arg2?.url,
758
771
  baseUrl,
759
772
  authId
760
773
  });
774
+ if (isV2Platform && response && typeof response === "object" && response["flowStatus"] === EmbeddedSignInFlowStatusV2.Complete && response["assertion"]) {
775
+ const decodedAssertion = await this.decodeJwtToken(response["assertion"]);
776
+ const createdAt = decodedAssertion.iat ? decodedAssertion.iat * 1e3 : Date.now();
777
+ const expiresIn = decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;
778
+ await this.setSession({
779
+ access_token: response["assertion"],
780
+ id_token: response["assertion"],
781
+ token_type: "Bearer",
782
+ expires_in: expiresIn,
783
+ created_at: createdAt,
784
+ scope: decodedAssertion.scope
785
+ });
786
+ }
787
+ return response;
761
788
  }
762
789
  if (typeof arg1 === "object" && "flowId" in arg1 && typeof arg2 === "object" && "url" in arg2) {
763
790
  return executeEmbeddedSignInFlow({
@@ -821,6 +848,12 @@ var AsgardeoReactClient = class extends AsgardeoBrowserClient {
821
848
  clearSession(sessionId) {
822
849
  this.asgardeo.clearSession(sessionId);
823
850
  }
851
+ async setSession(sessionData, sessionId) {
852
+ return await (await this.asgardeo.getStorageManager()).setSessionData(sessionData, sessionId);
853
+ }
854
+ decodeJwtToken(token) {
855
+ return this.asgardeo.decodeJwtToken(token);
856
+ }
824
857
  };
825
858
  var AsgardeoReactClient_default = AsgardeoReactClient;
826
859
 
@@ -7533,7 +7566,6 @@ var BaseSignInContent2 = ({
7533
7566
  setIsSubmitting(true);
7534
7567
  setApiError(null);
7535
7568
  clearMessages();
7536
- console.log("Submitting component:", component, "with data:", data);
7537
7569
  try {
7538
7570
  const filteredInputs = {};
7539
7571
  if (data) {
@@ -7692,7 +7724,7 @@ import { useState as useState16, useEffect as useEffect13, useRef as useRef4 } f
7692
7724
  import {
7693
7725
  AsgardeoRuntimeError as AsgardeoRuntimeError9,
7694
7726
  EmbeddedFlowType,
7695
- EmbeddedSignInFlowStatusV2,
7727
+ EmbeddedSignInFlowStatusV2 as EmbeddedSignInFlowStatusV22,
7696
7728
  EmbeddedSignInFlowTypeV2
7697
7729
  } from "@asgardeo/browser";
7698
7730
 
@@ -8044,7 +8076,7 @@ var SignIn = ({ className, size = "medium", onSuccess, onError, variant, childre
8044
8076
  const { flowId, components: components2, ...rest } = normalizeFlowResponse(response, t, {
8045
8077
  resolveTranslations: !children
8046
8078
  });
8047
- if (response.flowStatus === EmbeddedSignInFlowStatusV2.Error) {
8079
+ if (response.flowStatus === EmbeddedSignInFlowStatusV22.Error) {
8048
8080
  clearFlowState();
8049
8081
  const failureReason = response?.failureReason;
8050
8082
  const errorMessage = failureReason || "Authentication flow failed. Please try again.";
@@ -8053,7 +8085,7 @@ var SignIn = ({ className, size = "medium", onSuccess, onError, variant, childre
8053
8085
  cleanupFlowUrlParams();
8054
8086
  throw err;
8055
8087
  }
8056
- if (response.flowStatus === EmbeddedSignInFlowStatusV2.Complete) {
8088
+ if (response.flowStatus === EmbeddedSignInFlowStatusV22.Complete) {
8057
8089
  const redirectUrl = response?.redirectUrl || response?.redirect_uri;
8058
8090
  const finalRedirectUrl = redirectUrl || afterSignInUrl;
8059
8091
  setIsSubmitting(false);
@@ -15413,7 +15445,7 @@ import {
15413
15445
  EmbeddedFlowActionVariantV2,
15414
15446
  EmbeddedFlowTextVariantV2,
15415
15447
  EmbeddedFlowEventTypeV2,
15416
- EmbeddedSignInFlowStatusV2 as EmbeddedSignInFlowStatusV22,
15448
+ EmbeddedSignInFlowStatusV2 as EmbeddedSignInFlowStatusV23,
15417
15449
  EmbeddedSignInFlowTypeV2 as EmbeddedSignInFlowTypeV22
15418
15450
  } from "@asgardeo/browser";
15419
15451
  export {
@@ -15461,7 +15493,7 @@ export {
15461
15493
  EmbeddedFlowComponentTypeV2 as EmbeddedFlowComponentType,
15462
15494
  EmbeddedFlowEventTypeV2 as EmbeddedFlowEventType,
15463
15495
  EmbeddedFlowTextVariantV2 as EmbeddedFlowTextVariant,
15464
- EmbeddedSignInFlowStatusV22 as EmbeddedSignInFlowStatus,
15496
+ EmbeddedSignInFlowStatusV23 as EmbeddedSignInFlowStatus,
15465
15497
  EmbeddedSignInFlowTypeV22 as EmbeddedSignInFlowType,
15466
15498
  Eye_default as Eye,
15467
15499
  EyeOff_default as EyeOff,