@commercengine/storefront-sdk 0.12.3 → 0.12.5
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 +18 -7
- package/dist/index.iife.js +28 -102
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +28 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.d.mts
CHANGED
|
@@ -3465,6 +3465,14 @@ interface components {
|
|
|
3465
3465
|
coupon_savings: number;
|
|
3466
3466
|
other_savings: number;
|
|
3467
3467
|
total_savings: number;
|
|
3468
|
+
/**
|
|
3469
|
+
* @description Status of the cart.
|
|
3470
|
+
* @default not-ready-for-payment
|
|
3471
|
+
* @enum {string}
|
|
3472
|
+
*/
|
|
3473
|
+
status: "not-ready-for-payment" | "ready-for-payment";
|
|
3474
|
+
/** @description Error message if the cart is not ready for payment. */
|
|
3475
|
+
status_error_message: string | null;
|
|
3468
3476
|
};
|
|
3469
3477
|
/** CartBasedFulfillmentCheck */
|
|
3470
3478
|
CartBasedFulfillmentCheck: {
|
|
@@ -3826,6 +3834,7 @@ interface components {
|
|
|
3826
3834
|
/** @example ₹ */
|
|
3827
3835
|
symbol: string;
|
|
3828
3836
|
};
|
|
3837
|
+
/** CustomerAddress */
|
|
3829
3838
|
CustomerAddress: {
|
|
3830
3839
|
/** @description null value for guest checkout. */
|
|
3831
3840
|
id?: string | null;
|
|
@@ -3844,17 +3853,17 @@ interface components {
|
|
|
3844
3853
|
state: string;
|
|
3845
3854
|
/** @constant */
|
|
3846
3855
|
country: "India";
|
|
3847
|
-
/**
|
|
3848
|
-
* @description Tax Identification Number (TIN/VAT/GSTIN) specific to the country of operation.
|
|
3849
|
-
* @example 123456789
|
|
3850
|
-
* @example GB123456789
|
|
3851
|
-
* @example IN27AAEPM0111C1ZQ
|
|
3852
|
-
*/
|
|
3856
|
+
/** @description Tax Identification Number (TIN/VAT/GSTIN) specific to the country of operation. */
|
|
3853
3857
|
tax_identification_number: string | null;
|
|
3854
3858
|
/** @description Use in billing & shipping details only. */
|
|
3855
3859
|
business_name: string | null;
|
|
3856
3860
|
readonly is_phone_verified: boolean;
|
|
3857
3861
|
readonly is_email_verified: boolean;
|
|
3862
|
+
/**
|
|
3863
|
+
* @description Nickname for the address.
|
|
3864
|
+
* @default null
|
|
3865
|
+
*/
|
|
3866
|
+
nickname: string | null;
|
|
3858
3867
|
} | null;
|
|
3859
3868
|
/** CustomerDetail */
|
|
3860
3869
|
CustomerDetail: {
|
|
@@ -4017,6 +4026,8 @@ interface components {
|
|
|
4017
4026
|
/** DeliveryOption */
|
|
4018
4027
|
DeliveryOption: {
|
|
4019
4028
|
is_serviceable: boolean;
|
|
4029
|
+
/** @description free shipping threshold of delivery option */
|
|
4030
|
+
free_shipping_threshold: number | null;
|
|
4020
4031
|
shipments: {
|
|
4021
4032
|
id: string;
|
|
4022
4033
|
items: components["schemas"]["ShipmentItem"][];
|
|
@@ -4647,7 +4658,6 @@ interface components {
|
|
|
4647
4658
|
payment_method_type: "UPI";
|
|
4648
4659
|
/** @constant */
|
|
4649
4660
|
payment_method: "UPI_PAY";
|
|
4650
|
-
upi_app: string;
|
|
4651
4661
|
};
|
|
4652
4662
|
/** JuspayUpiPaymentMethod */
|
|
4653
4663
|
JuspayUpiPaymentMethod: {
|
|
@@ -4933,6 +4943,7 @@ interface components {
|
|
|
4933
4943
|
/** OrderDetail */
|
|
4934
4944
|
OrderDetail: components["schemas"]["Order"] & {
|
|
4935
4945
|
payments?: components["schemas"]["OrderPayment"][];
|
|
4946
|
+
shipments?: components["schemas"]["OrderShipment"][];
|
|
4936
4947
|
};
|
|
4937
4948
|
OrderItem: {
|
|
4938
4949
|
product_id: string;
|
package/dist/index.iife.js
CHANGED
|
@@ -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:
|
|
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
|
|
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();
|