@coincircuit/checkout 0.2.1 → 0.2.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.
@@ -44,6 +44,19 @@ function createMessageListener(allowedOrigin, handlers) {
44
44
 
45
45
  // src/utils.ts
46
46
  var DEFAULT_BASE_URL = "https://checkout.coincircuit.io";
47
+ var ALLOWED_BASE_URLS = [
48
+ "https://checkout.coincircuit.io",
49
+ "https://sandbox-checkout.coincircuit.io"
50
+ ];
51
+ function validateBaseUrl(url) {
52
+ const normalized = url.replace(/\/+$/, "");
53
+ if (!ALLOWED_BASE_URLS.includes(normalized)) {
54
+ throw new Error(
55
+ `CoinCircuitCheckout: invalid baseUrl "${url}". Must be one of: ${ALLOWED_BASE_URLS.join(", ")}`
56
+ );
57
+ }
58
+ return normalized;
59
+ }
47
60
  function buildCheckoutUrl(baseUrl, reference, theme) {
48
61
  const url = new URL(`/pay/${encodeURIComponent(reference)}`, baseUrl);
49
62
  url.searchParams.set("embed", "true");
@@ -246,7 +259,7 @@ var CoinCircuitCheckout = class {
246
259
  removeMessageListener = null;
247
260
  loadTimeout = null;
248
261
  constructor(config = {}) {
249
- this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
262
+ this.baseUrl = config.baseUrl ? validateBaseUrl(config.baseUrl) : DEFAULT_BASE_URL;
250
263
  this.origin = extractOrigin(this.baseUrl);
251
264
  this.publicKey = config.publicKey;
252
265
  }
package/dist/index.cjs CHANGED
@@ -75,6 +75,19 @@ function createMessageListener(allowedOrigin, handlers) {
75
75
 
76
76
  // src/utils.ts
77
77
  var DEFAULT_BASE_URL = "https://checkout.coincircuit.io";
78
+ var ALLOWED_BASE_URLS = [
79
+ "https://checkout.coincircuit.io",
80
+ "https://sandbox-checkout.coincircuit.io"
81
+ ];
82
+ function validateBaseUrl(url) {
83
+ const normalized = url.replace(/\/+$/, "");
84
+ if (!ALLOWED_BASE_URLS.includes(normalized)) {
85
+ throw new Error(
86
+ `CoinCircuitCheckout: invalid baseUrl "${url}". Must be one of: ${ALLOWED_BASE_URLS.join(", ")}`
87
+ );
88
+ }
89
+ return normalized;
90
+ }
78
91
  function buildCheckoutUrl(baseUrl, reference, theme) {
79
92
  const url = new URL(`/pay/${encodeURIComponent(reference)}`, baseUrl);
80
93
  url.searchParams.set("embed", "true");
@@ -277,7 +290,7 @@ var CoinCircuitCheckout = class {
277
290
  removeMessageListener = null;
278
291
  loadTimeout = null;
279
292
  constructor(config = {}) {
280
- this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
293
+ this.baseUrl = config.baseUrl ? validateBaseUrl(config.baseUrl) : DEFAULT_BASE_URL;
281
294
  this.origin = extractOrigin(this.baseUrl);
282
295
  this.publicKey = config.publicKey;
283
296
  }
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  buildCheckoutUrl,
6
6
  createMessageListener,
7
7
  extractOrigin
8
- } from "./chunk-NLDQKWTU.js";
8
+ } from "./chunk-DG6Y255K.js";
9
9
  export {
10
10
  CHECKOUT_MESSAGE_TYPES,
11
11
  CoinCircuitCheckout,
package/dist/react.cjs CHANGED
@@ -71,6 +71,19 @@ function createMessageListener(allowedOrigin, handlers) {
71
71
 
72
72
  // src/utils.ts
73
73
  var DEFAULT_BASE_URL = "https://checkout.coincircuit.io";
74
+ var ALLOWED_BASE_URLS = [
75
+ "https://checkout.coincircuit.io",
76
+ "https://sandbox-checkout.coincircuit.io"
77
+ ];
78
+ function validateBaseUrl(url) {
79
+ const normalized = url.replace(/\/+$/, "");
80
+ if (!ALLOWED_BASE_URLS.includes(normalized)) {
81
+ throw new Error(
82
+ `CoinCircuitCheckout: invalid baseUrl "${url}". Must be one of: ${ALLOWED_BASE_URLS.join(", ")}`
83
+ );
84
+ }
85
+ return normalized;
86
+ }
74
87
  function buildCheckoutUrl(baseUrl, reference, theme) {
75
88
  const url = new URL(`/pay/${encodeURIComponent(reference)}`, baseUrl);
76
89
  url.searchParams.set("embed", "true");
@@ -273,7 +286,7 @@ var CoinCircuitCheckout = class {
273
286
  removeMessageListener = null;
274
287
  loadTimeout = null;
275
288
  constructor(config = {}) {
276
- this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
289
+ this.baseUrl = config.baseUrl ? validateBaseUrl(config.baseUrl) : DEFAULT_BASE_URL;
277
290
  this.origin = extractOrigin(this.baseUrl);
278
291
  this.publicKey = config.publicKey;
279
292
  }
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CoinCircuitCheckout
3
- } from "./chunk-NLDQKWTU.js";
3
+ } from "./chunk-DG6Y255K.js";
4
4
 
5
5
  // src/react.ts
6
6
  import { useRef, useCallback, useEffect, createElement } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coincircuit/checkout",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Embed CoinCircuit checkout in your site via iframe, with vanilla JS and React support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",