create-brainerce-store 1.28.20 → 1.28.21

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.
@@ -1,45 +1,60 @@
1
- const ALLOWED_PAYMENT_HOSTS: readonly string[] = [
2
- 'checkout.stripe.com',
3
- 'js.stripe.com',
4
- 'hooks.stripe.com',
5
- 'www.paypal.com',
6
- 'www.sandbox.paypal.com',
7
- 'secure.cardcom.solutions',
8
- 'meshulam.co.il',
9
- 'grow.link',
10
- 'grow.security',
11
- 'creditguard.co.il',
12
- ];
13
-
14
- export function isAllowedPaymentUrl(url: string): boolean {
15
- if (!url || typeof url !== 'string') return false;
16
-
17
- let parsed: URL;
18
- try {
19
- parsed = new URL(url);
20
- } catch {
21
- return false;
22
- }
23
-
24
- if (parsed.protocol !== 'https:') return false;
25
-
26
- const hostname = parsed.hostname.toLowerCase();
27
- return ALLOWED_PAYMENT_HOSTS.some((host) => hostname === host || hostname.endsWith('.' + host));
28
- }
29
-
30
- export function safePaymentRedirect(url: string): void {
31
- if (!isAllowedPaymentUrl(url)) {
32
- throw new Error('Payment redirect URL is not in the allowlist');
33
- }
34
- if (typeof window !== 'undefined') {
35
- window.location.href = url;
36
- }
37
- }
38
-
39
- // CUID format used by Prisma for Checkout.id — c + 24 lowercase alphanumeric chars.
40
- // Allow a small range to tolerate cuid2 (slightly different length).
41
- const CHECKOUT_ID_RE = /^c[a-z0-9]{20,30}$/;
42
-
43
- export function isValidCheckoutId(id: unknown): id is string {
44
- return typeof id === 'string' && CHECKOUT_ID_RE.test(id);
45
- }
1
+ const ALLOWED_PAYMENT_HOSTS: readonly string[] = [
2
+ 'checkout.stripe.com',
3
+ 'js.stripe.com',
4
+ 'hooks.stripe.com',
5
+ 'www.paypal.com',
6
+ 'www.sandbox.paypal.com',
7
+ 'secure.cardcom.solutions',
8
+ 'meshulam.co.il',
9
+ 'grow.link',
10
+ 'grow.security',
11
+ 'creditguard.co.il',
12
+ // Brainerce-hosted payment embeds (cardcom-payments /embed/:lpCode etc.).
13
+ // These are platform-owned iframe shells that wrap provider-specific flows
14
+ // and relay postMessage events back to the storefront.
15
+ 'brainerce.com',
16
+ ];
17
+
18
+ export function isAllowedPaymentUrl(url: string): boolean {
19
+ if (!url || typeof url !== 'string') return false;
20
+
21
+ let parsed: URL;
22
+ try {
23
+ parsed = new URL(url);
24
+ } catch {
25
+ return false;
26
+ }
27
+
28
+ const hostname = parsed.hostname.toLowerCase();
29
+
30
+ // Dev-only: allow http://localhost|127.0.0.1 so the local storefront can
31
+ // iframe the local backend's embed proxy. Stripped in production builds.
32
+ if (
33
+ process.env.NODE_ENV !== 'production' &&
34
+ parsed.protocol === 'http:' &&
35
+ (hostname === 'localhost' || hostname === '127.0.0.1')
36
+ ) {
37
+ return true;
38
+ }
39
+
40
+ if (parsed.protocol !== 'https:') return false;
41
+
42
+ return ALLOWED_PAYMENT_HOSTS.some((host) => hostname === host || hostname.endsWith('.' + host));
43
+ }
44
+
45
+ export function safePaymentRedirect(url: string): void {
46
+ if (!isAllowedPaymentUrl(url)) {
47
+ throw new Error('Payment redirect URL is not in the allowlist');
48
+ }
49
+ if (typeof window !== 'undefined') {
50
+ window.location.href = url;
51
+ }
52
+ }
53
+
54
+ // CUID format used by Prisma for Checkout.id — c + 24 lowercase alphanumeric chars.
55
+ // Allow a small range to tolerate cuid2 (slightly different length).
56
+ const CHECKOUT_ID_RE = /^c[a-z0-9]{20,30}$/;
57
+
58
+ export function isValidCheckoutId(id: unknown): id is string {
59
+ return typeof id === 'string' && CHECKOUT_ID_RE.test(id);
60
+ }
@@ -32,7 +32,7 @@ function buildCsp(nonce: string): string {
32
32
  "style-src 'self' 'unsafe-inline' https://cdn.meshulam.co.il",
33
33
  "img-src 'self' data: blob: https:",
34
34
  "font-src 'self' data:",
35
- "frame-src 'self' https://meshulam.co.il https://*.meshulam.co.il https://grow.link https://*.grow.link https://grow.security https://*.grow.security https://creditguard.co.il https://*.creditguard.co.il https://js.stripe.com https://hooks.stripe.com https://pay.google.com https://secure.cardcom.solutions https://checkout.stripe.com https://www.paypal.com https://www.sandbox.paypal.com",
35
+ "frame-src 'self' https://meshulam.co.il https://*.meshulam.co.il https://grow.link https://*.grow.link https://grow.security https://*.grow.security https://creditguard.co.il https://*.creditguard.co.il https://js.stripe.com https://hooks.stripe.com https://pay.google.com https://secure.cardcom.solutions https://checkout.stripe.com https://www.paypal.com https://www.sandbox.paypal.com https://*.brainerce.com",
36
36
  "connect-src 'self' https://*.meshulam.co.il https://grow.link https://*.grow.link https://*.grow.security https://pay.google.com https://*.stripe.com https://*.creditguard.co.il",
37
37
  "worker-src 'self' blob:",
38
38
  // 'self' (not 'none') so iframe-based payment providers (e.g. Cardcom)
@@ -149,7 +149,7 @@ function buildCsp(nonce: string): string {
149
149
  "style-src 'self' 'unsafe-inline' https://cdn.meshulam.co.il",
150
150
  "img-src 'self' data: blob: https:",
151
151
  "font-src 'self' data:",
152
- "frame-src 'self' https://meshulam.co.il https://*.meshulam.co.il https://grow.link https://*.grow.link https://grow.security https://*.grow.security https://creditguard.co.il https://*.creditguard.co.il https://js.stripe.com https://hooks.stripe.com https://pay.google.com https://secure.cardcom.solutions https://checkout.stripe.com https://www.paypal.com https://www.sandbox.paypal.com",
152
+ "frame-src 'self' https://meshulam.co.il https://*.meshulam.co.il https://grow.link https://*.grow.link https://grow.security https://*.grow.security https://creditguard.co.il https://*.creditguard.co.il https://js.stripe.com https://hooks.stripe.com https://pay.google.com https://secure.cardcom.solutions https://checkout.stripe.com https://www.paypal.com https://www.sandbox.paypal.com https://*.brainerce.com",
153
153
  "connect-src 'self' https://*.meshulam.co.il https://grow.link https://*.grow.link https://*.grow.security https://pay.google.com https://*.stripe.com https://*.creditguard.co.il",
154
154
  "worker-src 'self' blob:",
155
155
  // 'self' (not 'none') so iframe-based payment providers (e.g. Cardcom)
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node