@commercengine/storefront-sdk 0.12.2 → 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
@@ -4286,17 +4286,21 @@ interface components {
4286
4286
  expiry_month?: string;
4287
4287
  token_supported_gateways?: string[];
4288
4288
  card_fingerprint?: string;
4289
- cvv_less_details?: {
4289
+ cvv_less_details?: ({
4290
4290
  gateway?: string;
4291
4291
  gateway_reference_ids?: string[];
4292
- }[];
4292
+ } & {
4293
+ [key: string]: unknown;
4294
+ })[];
4293
4295
  cvv_less_supported_gateways?: string[];
4294
4296
  provision_token_id?: string;
4295
4297
  card_isin?: string;
4296
4298
  expiry_year?: string;
4299
+ } & {
4300
+ [key: string]: unknown;
4297
4301
  };
4298
4302
  extended_card_type: string;
4299
- tokens?: {
4303
+ tokens?: ({
4300
4304
  tokenization_status?: string;
4301
4305
  last_four_digits?: string;
4302
4306
  provider_category?: string;
@@ -4309,7 +4313,9 @@ interface components {
4309
4313
  provision_token_id?: string;
4310
4314
  card_isin?: string;
4311
4315
  expiry_year?: string;
4312
- }[];
4316
+ } & {
4317
+ [key: string]: unknown;
4318
+ })[];
4313
4319
  nickname: string;
4314
4320
  provider_category: string;
4315
4321
  vault_provider: string;
@@ -4336,10 +4342,13 @@ interface components {
4336
4342
  name_on_card: string;
4337
4343
  country_code: string;
4338
4344
  atm_pin_auth_support?: boolean;
4345
+ direct_otp_support?: boolean;
4339
4346
  card_number: string;
4340
4347
  card_isin: string;
4341
4348
  card_brand: string;
4342
4349
  card_issuer_country: string;
4350
+ } & {
4351
+ [key: string]: unknown;
4343
4352
  };
4344
4353
  /** JuspayCardPaymentMethod */
4345
4354
  JuspayCardPaymentMethod: {
@@ -4545,6 +4554,7 @@ interface components {
4545
4554
  };
4546
4555
  /** JusPayNewCard */
4547
4556
  JusPayNewCard: components["schemas"]["JusPayExpressCheckoutCommonField"] & {
4557
+ /** @description Whether to save the card to the locker. If true, the card will be saved to the locker and can be used for future payments as per RBI regulations. */
4548
4558
  save_to_locker: boolean;
4549
4559
  /** @constant */
4550
4560
  payment_method_type: "CARD";
@@ -4637,7 +4647,6 @@ interface components {
4637
4647
  payment_method_type: "UPI";
4638
4648
  /** @constant */
4639
4649
  payment_method: "UPI_PAY";
4640
- upi_app: string;
4641
4650
  };
4642
4651
  /** JuspayUpiPaymentMethod */
4643
4652
  JuspayUpiPaymentMethod: {
@@ -4923,6 +4932,7 @@ interface components {
4923
4932
  /** OrderDetail */
4924
4933
  OrderDetail: components["schemas"]["Order"] & {
4925
4934
  payments?: components["schemas"]["OrderPayment"][];
4935
+ shipments?: components["schemas"]["OrderShipment"][];
4926
4936
  };
4927
4937
  OrderItem: {
4928
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();