@commercengine/storefront-sdk 0.12.3 → 0.12.4

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.d.mts CHANGED
@@ -4647,7 +4647,6 @@ interface components {
4647
4647
  payment_method_type: "UPI";
4648
4648
  /** @constant */
4649
4649
  payment_method: "UPI_PAY";
4650
- upi_app: string;
4651
4650
  };
4652
4651
  /** JuspayUpiPaymentMethod */
4653
4652
  JuspayUpiPaymentMethod: {
@@ -4933,6 +4932,7 @@ interface components {
4933
4932
  /** OrderDetail */
4934
4933
  OrderDetail: components["schemas"]["Order"] & {
4935
4934
  payments?: components["schemas"]["OrderPayment"][];
4935
+ shipments?: components["schemas"]["OrderShipment"][];
4936
4936
  };
4937
4937
  OrderItem: {
4938
4938
  product_id: string;
@@ -782,98 +782,33 @@ Object.defineProperty(exports, '__esModule', { value: true });
782
782
  }
783
783
  }
784
784
 
785
- //#endregion
786
- //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/lib/buffer_utils.js
787
- const encoder = new TextEncoder();
788
- const decoder = new TextDecoder();
789
- const MAX_INT32 = 2 ** 32;
790
-
791
- //#endregion
792
- //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/lib/base64.js
793
- function decodeBase64(encoded) {
794
- if (Uint8Array.fromBase64) return Uint8Array.fromBase64(encoded);
795
- const binary = atob(encoded);
796
- const bytes = new Uint8Array(binary.length);
797
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
798
- return bytes;
799
- }
800
-
801
- //#endregion
802
- //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/util/base64url.js
803
- function decode(input) {
804
- if (Uint8Array.fromBase64) return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), { alphabet: "base64url" });
805
- let encoded = input;
806
- if (encoded instanceof Uint8Array) encoded = decoder.decode(encoded);
807
- encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
808
- try {
809
- return decodeBase64(encoded);
810
- } catch {
811
- throw new TypeError("The input to be decoded is not correctly encoded.");
812
- }
813
- }
814
-
815
- //#endregion
816
- //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/util/errors.js
817
- var JOSEError = class extends Error {
818
- static code = "ERR_JOSE_GENERIC";
819
- code = "ERR_JOSE_GENERIC";
820
- constructor(message, options) {
821
- super(message, options);
822
- this.name = this.constructor.name;
823
- Error.captureStackTrace?.(this, this.constructor);
824
- }
825
- };
826
- var JWTInvalid = class extends JOSEError {
827
- static code = "ERR_JWT_INVALID";
828
- code = "ERR_JWT_INVALID";
829
- };
830
- var JWKSMultipleMatchingKeys = class extends JOSEError {
831
- [Symbol.asyncIterator];
832
- static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
833
- code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
834
- constructor(message = "multiple matching keys found in the JSON Web Key Set", options) {
835
- super(message, options);
836
- }
837
- };
838
-
839
- //#endregion
840
- //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/lib/is_object.js
841
- const isObjectLike = (value) => typeof value === "object" && value !== null;
842
- function isObject(input) {
843
- if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") return false;
844
- if (Object.getPrototypeOf(input) === null) return true;
845
- let proto = input;
846
- while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
847
- return Object.getPrototypeOf(input) === proto;
848
- }
849
-
850
- //#endregion
851
- //#region ../../node_modules/.pnpm/jose@6.1.3/node_modules/jose/dist/webapi/util/decode_jwt.js
852
- function decodeJwt(jwt) {
853
- if (typeof jwt !== "string") throw new JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");
854
- const { 1: payload, length } = jwt.split(".");
855
- if (length === 5) throw new JWTInvalid("Only JWTs using Compact JWS serialization can be decoded");
856
- if (length !== 3) throw new JWTInvalid("Invalid JWT");
857
- if (!payload) throw new JWTInvalid("JWTs must contain a payload");
858
- let decoded;
859
- try {
860
- decoded = decode(payload);
861
- } catch {
862
- throw new JWTInvalid("Failed to base64url decode the payload");
863
- }
864
- let result;
865
- try {
866
- result = JSON.parse(decoder.decode(decoded));
867
- } catch {
868
- throw new JWTInvalid("Failed to parse the decoded payload as JSON");
869
- }
870
- if (!isObject(result)) throw new JWTInvalid("Invalid JWT Claims Set");
871
- return result;
872
- }
873
-
874
785
  //#endregion
875
786
  //#region src/lib/jwt-utils.ts
876
787
  /**
788
+ * Decode a JWT token payload without signature verification.
789
+ * This is a lightweight replacement for jose's decodeJwt.
790
+ *
791
+ * @param token - The JWT token to decode
792
+ * @returns The decoded payload
793
+ * @throws Error if the token is malformed
794
+ */
795
+ function decodeJwt(token) {
796
+ if (typeof token !== "string") throw new Error("Invalid token: must be a string");
797
+ const parts = token.split(".");
798
+ if (parts.length !== 3) throw new Error("Invalid token: must have 3 parts");
799
+ const base64Url = parts[1];
800
+ if (!base64Url) throw new Error("Invalid token: missing payload");
801
+ let base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
802
+ const padding = base64.length % 4;
803
+ if (padding) base64 += "=".repeat(4 - padding);
804
+ const binaryStr = atob(base64);
805
+ const bytes = new Uint8Array(binaryStr.length);
806
+ for (let i = 0; i < binaryStr.length; i++) bytes[i] = binaryStr.charCodeAt(i);
807
+ const payload = JSON.parse(new TextDecoder().decode(bytes));
808
+ if (typeof payload !== "object" || payload === null) throw new Error("Invalid token: payload must be an object");
809
+ return payload;
810
+ }
811
+ /**
877
812
  * Decode and extract user information from a JWT token
878
813
  *
879
814
  * @param token - The JWT token to decode
@@ -891,7 +826,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
891
826
  lastName: payload.last_name,
892
827
  storeId: payload.store_id,
893
828
  isLoggedIn: payload.is_logged_in,
894
- isAnonymous: !payload.is_logged_in,
829
+ isAnonymous: payload.is_anonymous,
895
830
  customerId: payload.customer_id,
896
831
  customerGroupId: payload.customer_group_id,
897
832
  anonymousId: payload.anonymous_id,
@@ -946,7 +881,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
946
881
  * @returns True if user is anonymous, false otherwise
947
882
  */
948
883
  function isUserAnonymous(token) {
949
- return extractUserInfoFromToken(token)?.isAnonymous || true;
884
+ return extractUserInfoFromToken(token)?.isAnonymous ?? true;
950
885
  }
951
886
 
952
887
  //#endregion
@@ -966,15 +901,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
966
901
  "/auth/register/phone",
967
902
  "/auth/register/email",
968
903
  "/auth/verify-otp",
969
- "/auth/refresh-token"
904
+ "/auth/refresh-token",
905
+ "/auth/logout"
970
906
  ].some((endpoint) => pathname.endsWith(endpoint));
971
907
  }
972
- /**
973
- * Check if a URL path is the logout endpoint
974
- */
975
- function isLogoutEndpoint(pathname) {
976
- return pathname.endsWith("/auth/logout");
977
- }
978
908
 
979
909
  //#endregion
980
910
  //#region src/lib/middleware.ts
@@ -1224,10 +1154,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
1224
1154
  } catch (error) {
1225
1155
  console.warn("Failed to extract tokens from response:", error);
1226
1156
  }
1227
- else if (isLogoutEndpoint(pathname)) {
1228
- await config.tokenStorage.clearTokens();
1229
- config.onTokensCleared?.();
1230
- }
1231
1157
  }
1232
1158
  if (response.status === 401 && !isAnonymousAuthEndpoint(pathname)) {
1233
1159
  const currentToken = await config.tokenStorage.getAccessToken();