@commercengine/pos 0.3.11 → 0.4.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.
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import createClient from "openapi-fetch";
2
- import { decodeJwt } from "jose";
3
2
 
4
3
  //#region ../sdk-core/dist/index.mjs
5
4
  /**
@@ -415,6 +414,30 @@ function getPathnameFromUrl(url) {
415
414
  //#endregion
416
415
  //#region src/lib/utils/jwt.ts
417
416
  /**
417
+ * Decode a JWT token payload without signature verification.
418
+ * This is a lightweight replacement for jose's decodeJwt.
419
+ *
420
+ * @param token - The JWT token to decode
421
+ * @returns The decoded payload
422
+ * @throws Error if the token is malformed
423
+ */
424
+ function decodeJwt(token) {
425
+ if (typeof token !== "string") throw new Error("Invalid token: must be a string");
426
+ const parts = token.split(".");
427
+ if (parts.length !== 3) throw new Error("Invalid token: must have 3 parts");
428
+ const base64Url = parts[1];
429
+ if (!base64Url) throw new Error("Invalid token: missing payload");
430
+ let base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
431
+ const padding = base64.length % 4;
432
+ if (padding) base64 += "=".repeat(4 - padding);
433
+ const binaryStr = atob(base64);
434
+ const bytes = new Uint8Array(binaryStr.length);
435
+ for (let i = 0; i < binaryStr.length; i++) bytes[i] = binaryStr.charCodeAt(i);
436
+ const payload = JSON.parse(new TextDecoder().decode(bytes));
437
+ if (typeof payload !== "object" || payload === null) throw new Error("Invalid token: payload must be an object");
438
+ return payload;
439
+ }
440
+ /**
418
441
  * Decode and extract user information from a JWT token
419
442
  *
420
443
  * @param token - The JWT token to decode
@@ -786,11 +809,11 @@ function createDefaultPosAuthMiddleware(options) {
786
809
  /**
787
810
  * Environment configuration for POS API
788
811
  */
789
- let Environment = /* @__PURE__ */ function(Environment$1) {
790
- Environment$1["Development"] = "dev";
791
- Environment$1["Staging"] = "staging";
792
- Environment$1["Production"] = "production";
793
- return Environment$1;
812
+ let Environment = /* @__PURE__ */ function(Environment) {
813
+ Environment["Development"] = "dev";
814
+ Environment["Staging"] = "staging";
815
+ Environment["Production"] = "production";
816
+ return Environment;
794
817
  }({});
795
818
  /**
796
819
  * Build the base URL for POS API requests
@@ -1827,23 +1850,6 @@ var PosClient = class extends PosAPIClient {
1827
1850
  return this.executeRequest(() => this.storefrontClient.POST("/pos/orders", { body }));
1828
1851
  }
1829
1852
  /**
1830
- * List payment options
1831
- * @returns Promise with list of payment options
1832
- * @example
1833
- * ```typescript
1834
- * const { data, error } = await pos.listPaymentOptions();
1835
- *
1836
- * if (error) {
1837
- * console.error("Failed to list payment options:", error.message);
1838
- * } else {
1839
- * console.log("Payment options:", data.payment_options);
1840
- * }
1841
- * ```
1842
- */
1843
- async listPaymentOptions() {
1844
- return this.executeRequest(() => this.client.GET("/pos/payments/payment-options"));
1845
- }
1846
- /**
1847
1853
  * Get payment status
1848
1854
  * @param pathParams - Order number
1849
1855
  * @returns Promise with payment status
@@ -2734,7 +2740,7 @@ var PosClient = class extends PosAPIClient {
2734
2740
  * ```
2735
2741
  */
2736
2742
  async checkInventory(pathParams) {
2737
- return this.executeRequest(() => this.client.GET("/pos/shipping/shipments/{order_number}/check-inventory", { params: { path: pathParams } }));
2743
+ return this.executeRequest(() => this.adminClient.GET("/pos/orders/{order_number}/check-inventory", { params: { path: pathParams } }));
2738
2744
  }
2739
2745
  /**
2740
2746
  * Refund shortfall for order (Admin)
@@ -3048,8 +3054,7 @@ var PosSDK = class {
3048
3054
  return getTenantIdFromToken(token);
3049
3055
  }
3050
3056
  };
3051
- var src_default = PosSDK;
3052
3057
 
3053
3058
  //#endregion
3054
- export { BrowserTokenStorage, Environment, MemoryTokenStorage, PosAPIClient, PosClient, PosSDK, ResponseUtils, src_default as default };
3059
+ export { BrowserTokenStorage, Environment, MemoryTokenStorage, PosAPIClient, PosClient, PosSDK, PosSDK as default, ResponseUtils };
3055
3060
  //# sourceMappingURL=index.mjs.map