@salesforce/storefront-next-runtime 0.4.2 → 1.0.0-alpha.1

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.
Files changed (87) hide show
  1. package/README.md +9 -3
  2. package/dist/ComponentContext.js +199 -4
  3. package/dist/ComponentContext.js.map +1 -1
  4. package/dist/DesignComponent.js +2 -2
  5. package/dist/DesignRegion.js +2 -2
  6. package/dist/RegionContext.js +9 -0
  7. package/dist/RegionContext.js.map +1 -0
  8. package/dist/component.types.d.ts +1 -1
  9. package/dist/config.d.ts +34 -221
  10. package/dist/config.d.ts.map +1 -1
  11. package/dist/config.js +35 -116
  12. package/dist/config.js.map +1 -1
  13. package/dist/data-store.d.ts +185 -15
  14. package/dist/data-store.d.ts.map +1 -1
  15. package/dist/data-store.js +412 -10
  16. package/dist/data-store.js.map +1 -1
  17. package/dist/defaults.d.ts +106 -0
  18. package/dist/defaults.d.ts.map +1 -0
  19. package/dist/defaults.js +67 -0
  20. package/dist/defaults.js.map +1 -0
  21. package/dist/design-data.d.ts +238 -356
  22. package/dist/design-data.d.ts.map +1 -1
  23. package/dist/design-data.js +459 -30
  24. package/dist/design-data.js.map +1 -1
  25. package/dist/design-mode.d.ts +3 -2
  26. package/dist/design-mode.d.ts.map +1 -1
  27. package/dist/design-react-core.d.ts +5 -15
  28. package/dist/design-react-core.d.ts.map +1 -1
  29. package/dist/design-react-core.js +2 -2
  30. package/dist/design-react.d.ts +2 -2
  31. package/dist/design.d.ts +2 -2
  32. package/dist/events.d.ts +32 -6
  33. package/dist/events.d.ts.map +1 -1
  34. package/dist/i18n-client.d.ts.map +1 -1
  35. package/dist/i18n-client.js.map +1 -1
  36. package/dist/i18n.d.ts +1 -2
  37. package/dist/i18n.d.ts.map +1 -1
  38. package/dist/modeDetection.js +0 -18
  39. package/dist/modeDetection.js.map +1 -1
  40. package/dist/scapi.d.ts +2185 -466
  41. package/dist/scapi.d.ts.map +1 -1
  42. package/dist/scapi.js +1 -1
  43. package/dist/scapi.js.map +1 -1
  44. package/dist/schema.d.ts +17 -15
  45. package/dist/schema.d.ts.map +1 -1
  46. package/dist/security-react.d.ts +34 -0
  47. package/dist/security-react.d.ts.map +1 -0
  48. package/dist/security-react.js +21 -0
  49. package/dist/security-react.js.map +1 -0
  50. package/dist/security.d.ts +61 -0
  51. package/dist/security.d.ts.map +1 -0
  52. package/dist/security.js +304 -0
  53. package/dist/security.js.map +1 -0
  54. package/dist/site-context.d.ts +43 -27
  55. package/dist/site-context.d.ts.map +1 -1
  56. package/dist/site-context.js +2 -2
  57. package/dist/site-context2.js +41 -31
  58. package/dist/site-context2.js.map +1 -1
  59. package/dist/types.d.ts +19 -3
  60. package/dist/types.d.ts.map +1 -1
  61. package/dist/types2.d.ts +89 -63
  62. package/dist/types2.d.ts.map +1 -1
  63. package/dist/types3.d.ts +1 -35
  64. package/dist/types3.d.ts.map +1 -1
  65. package/package.json +15 -20
  66. package/dist/DesignFrame.js +0 -204
  67. package/dist/DesignFrame.js.map +0 -1
  68. package/dist/custom-global-preferences.d.ts +0 -20
  69. package/dist/custom-global-preferences.d.ts.map +0 -1
  70. package/dist/custom-global-preferences.js +0 -31
  71. package/dist/custom-global-preferences.js.map +0 -1
  72. package/dist/custom-site-preferences.d.ts +0 -20
  73. package/dist/custom-site-preferences.d.ts.map +0 -1
  74. package/dist/custom-site-preferences.js +0 -31
  75. package/dist/custom-site-preferences.js.map +0 -1
  76. package/dist/data-store-custom-global-preferences.d.ts +0 -2
  77. package/dist/data-store-custom-global-preferences.js +0 -6
  78. package/dist/data-store-custom-site-preferences.d.ts +0 -2
  79. package/dist/data-store-custom-site-preferences.js +0 -6
  80. package/dist/data-store-gcp-preferences.d.ts +0 -2
  81. package/dist/data-store-gcp-preferences.js +0 -6
  82. package/dist/gcp-preferences.d.ts +0 -52
  83. package/dist/gcp-preferences.d.ts.map +0 -1
  84. package/dist/gcp-preferences.js +0 -64
  85. package/dist/gcp-preferences.js.map +0 -1
  86. package/dist/utils.js +0 -90
  87. package/dist/utils.js.map +0 -1
@@ -0,0 +1,106 @@
1
+ //#region src/security/types.d.ts
2
+ /**
3
+ * Copyright 2026 Salesforce, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Security response headers configuration. Plumb into the template's
19
+ * `Config` via `AppConfig.security`; the SDK fills in defaults for any
20
+ * field omitted.
21
+ *
22
+ * Setting any directive on `csp.directives` fully replaces the SDK
23
+ * default for that directive — copy from `defaultCspDirectives` to extend.
24
+ */
25
+ interface SecurityConfig {
26
+ /** Master toggle. When false, the middleware is a no-op. Default: true. */
27
+ enabled?: boolean;
28
+ /** CSP configuration. Set to false to disable CSP only. */
29
+ csp?: CspConfig | false;
30
+ /** HSTS configuration. Set to false to disable HSTS only. */
31
+ hsts?: HstsConfig | false;
32
+ /** X-Frame-Options. Set to false to disable. Default: 'SAMEORIGIN'. */
33
+ frameOptions?: 'DENY' | 'SAMEORIGIN' | false;
34
+ /** X-Content-Type-Options. Set to false to disable. Default: 'nosniff'. */
35
+ contentTypeOptions?: 'nosniff' | false;
36
+ /** Referrer-Policy. Set to false to disable. Default: 'strict-origin-when-cross-origin'. */
37
+ referrerPolicy?: ReferrerPolicyValue | false;
38
+ /** Permissions-Policy. Set to false to disable. Default: deny camera/microphone/geolocation. */
39
+ permissionsPolicy?: Record<string, string[]> | false;
40
+ }
41
+ interface CspConfig {
42
+ /** Map of CSP directive name → array of source values. Each directive fully replaces the SDK default. */
43
+ directives?: CspDirectives;
44
+ /**
45
+ * Send 'Content-Security-Policy-Report-Only' instead of 'Content-Security-Policy'.
46
+ * Logs a boot warning. For migration only — flip to false for production. Default: false.
47
+ */
48
+ reportOnly?: boolean;
49
+ }
50
+ /**
51
+ * CSP directive map. `'upgrade-insecure-requests'` is a no-value directive
52
+ * (its presence is the signal); all others take an array of source expressions.
53
+ */
54
+ type CspDirectives = Partial<Record<'default-src' | 'script-src' | 'style-src' | 'img-src' | 'font-src' | 'connect-src' | 'frame-src' | 'frame-ancestors' | 'form-action' | 'base-uri' | 'object-src' | 'manifest-src' | 'media-src' | 'worker-src' | 'child-src' | 'report-uri' | 'report-to', string[]> & {
55
+ 'upgrade-insecure-requests'?: true;
56
+ }>;
57
+ interface HstsConfig {
58
+ /** Max age in seconds. Default: 15552000 (180 days). */
59
+ maxAge?: number;
60
+ /** Default: true. */
61
+ includeSubDomains?: boolean;
62
+ /** Default: false. Setting true is a one-way decision (requires hstspreload.org submission). */
63
+ preload?: boolean;
64
+ }
65
+ type ReferrerPolicyValue = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
66
+ /**
67
+ * Fully resolved (post-merge) security config — every field non-optional.
68
+ * Used internally by the middleware after applying defaults to customer config.
69
+ */
70
+ interface ResolvedSecurityConfig {
71
+ enabled: boolean;
72
+ csp: {
73
+ directives: CspDirectives;
74
+ reportOnly: boolean;
75
+ } | false;
76
+ hsts: Required<HstsConfig> | false;
77
+ frameOptions: 'DENY' | 'SAMEORIGIN' | false;
78
+ contentTypeOptions: 'nosniff' | false;
79
+ referrerPolicy: ReferrerPolicyValue | false;
80
+ permissionsPolicy: Record<string, string[]> | false;
81
+ }
82
+ //#endregion
83
+ //#region src/security/defaults.d.ts
84
+ /**
85
+ * SDK default CSP directives. Customers extending CSP should spread this:
86
+ *
87
+ * ```ts
88
+ * import { defaultCspDirectives } from '@salesforce/storefront-next-runtime/security';
89
+ * security: {
90
+ * csp: {
91
+ * directives: {
92
+ * ...defaultCspDirectives,
93
+ * 'script-src': [...defaultCspDirectives['script-src']!, 'https://cdn.foo.com'],
94
+ * },
95
+ * },
96
+ * }
97
+ * ```
98
+ *
99
+ * The per-request nonce is appended to `script-src` at request time; it is
100
+ * NOT in this static map.
101
+ */
102
+ declare const defaultCspDirectives: CspDirectives;
103
+ declare const defaultSecurityHeaders: ResolvedSecurityConfig;
104
+ //#endregion
105
+ export { HstsConfig as a, SecurityConfig as c, CspDirectives as i, defaultSecurityHeaders as n, ReferrerPolicyValue as o, CspConfig as r, ResolvedSecurityConfig as s, defaultCspDirectives as t };
106
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","names":[],"sources":["../src/security/types.ts","../src/security/defaults.ts"],"sourcesContent":[],"mappings":";;AAwBA;;;;;;AAiBA;AAcA;AAuBA;AASA;AAcA;;;;;;;;;;AClEA;AA4BA;UDvCiB,cAAA;;;;QAIP;;SAEC;;;;;;mBAMU;;sBAEG;;UAGP,SAAA;;eAEA;;;;;;;;;;;KAYL,aAAA,GAAgB,QACxB;;;UAsBa,UAAA;;;;;;;;KASL,mBAAA;;;;;UAcK,sBAAA;;;gBAEM;;;QACb,SAAS;;;kBAGC;qBACG;;;;;;;;;ACzEvB;AA4BA;;;;;;;;;;;;cA5Ba,sBAAsB;cA4BtB,wBAAwB"}
@@ -0,0 +1,67 @@
1
+ //#region src/security/defaults.ts
2
+ /**
3
+ * SDK default CSP directives. Customers extending CSP should spread this:
4
+ *
5
+ * ```ts
6
+ * import { defaultCspDirectives } from '@salesforce/storefront-next-runtime/security';
7
+ * security: {
8
+ * csp: {
9
+ * directives: {
10
+ * ...defaultCspDirectives,
11
+ * 'script-src': [...defaultCspDirectives['script-src']!, 'https://cdn.foo.com'],
12
+ * },
13
+ * },
14
+ * }
15
+ * ```
16
+ *
17
+ * The per-request nonce is appended to `script-src` at request time; it is
18
+ * NOT in this static map.
19
+ */
20
+ const defaultCspDirectives = {
21
+ "default-src": ["'self'"],
22
+ "script-src": ["'self'", "https://challenges.cloudflare.com"],
23
+ "style-src": ["'self'", "'unsafe-inline'"],
24
+ "img-src": [
25
+ "'self'",
26
+ "data:",
27
+ "https://*.commercecloud.salesforce.com",
28
+ "https://*.demandware.net"
29
+ ],
30
+ "font-src": ["'self'", "data:"],
31
+ "connect-src": [
32
+ "'self'",
33
+ "https://*.commercecloud.salesforce.com",
34
+ "https://*.demandware.net",
35
+ "https://challenges.cloudflare.com"
36
+ ],
37
+ "frame-src": ["https://challenges.cloudflare.com"],
38
+ "frame-ancestors": ["'self'"],
39
+ "form-action": ["'self'"],
40
+ "base-uri": ["'self'"],
41
+ "object-src": ["'none'"],
42
+ "upgrade-insecure-requests": true
43
+ };
44
+ const defaultSecurityHeaders = {
45
+ enabled: true,
46
+ csp: {
47
+ directives: defaultCspDirectives,
48
+ reportOnly: false
49
+ },
50
+ hsts: {
51
+ maxAge: 15552e3,
52
+ includeSubDomains: true,
53
+ preload: false
54
+ },
55
+ frameOptions: "SAMEORIGIN",
56
+ contentTypeOptions: "nosniff",
57
+ referrerPolicy: "strict-origin-when-cross-origin",
58
+ permissionsPolicy: {
59
+ camera: [],
60
+ microphone: [],
61
+ geolocation: []
62
+ }
63
+ };
64
+
65
+ //#endregion
66
+ export { defaultSecurityHeaders as n, defaultCspDirectives as t };
67
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","names":["defaultCspDirectives: CspDirectives","defaultSecurityHeaders: ResolvedSecurityConfig"],"sources":["../src/security/defaults.ts"],"sourcesContent":["/**\n * Copyright 2026 Salesforce, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { CspDirectives, ResolvedSecurityConfig } from './types.js';\n\n/**\n * SDK default CSP directives. Customers extending CSP should spread this:\n *\n * ```ts\n * import { defaultCspDirectives } from '@salesforce/storefront-next-runtime/security';\n * security: {\n * csp: {\n * directives: {\n * ...defaultCspDirectives,\n * 'script-src': [...defaultCspDirectives['script-src']!, 'https://cdn.foo.com'],\n * },\n * },\n * }\n * ```\n *\n * The per-request nonce is appended to `script-src` at request time; it is\n * NOT in this static map.\n */\nexport const defaultCspDirectives: CspDirectives = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\", 'https://challenges.cloudflare.com'],\n // Tailwind v4 + shadcn rely on inline styles. Removing 'unsafe-inline'\n // breaks the design system out of the box.\n 'style-src': [\"'self'\", \"'unsafe-inline'\"],\n 'img-src': [\"'self'\", 'data:', 'https://*.commercecloud.salesforce.com', 'https://*.demandware.net'],\n 'font-src': [\"'self'\", 'data:'],\n 'connect-src': [\n \"'self'\",\n 'https://*.commercecloud.salesforce.com',\n 'https://*.demandware.net',\n // Browser-initiated XHR/fetch from the Cloudflare Turnstile widget after\n // its api.js loads. (The server-side siteverify call is not subject to CSP.)\n 'https://challenges.cloudflare.com',\n ],\n // Cloudflare Turnstile widget iframe.\n 'frame-src': ['https://challenges.cloudflare.com'],\n // Modern equivalent of X-Frame-Options.\n 'frame-ancestors': [\"'self'\"],\n // Restrict form submissions to same-origin. CSP3 does NOT fall back to\n // default-src for form-action; without this, forms could POST anywhere.\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n 'object-src': [\"'none'\"],\n 'upgrade-insecure-requests': true,\n};\n\nexport const defaultSecurityHeaders: ResolvedSecurityConfig = {\n enabled: true,\n csp: { directives: defaultCspDirectives, reportOnly: false },\n hsts: { maxAge: 15552000, includeSubDomains: true, preload: false },\n frameOptions: 'SAMEORIGIN',\n contentTypeOptions: 'nosniff',\n referrerPolicy: 'strict-origin-when-cross-origin',\n permissionsPolicy: { camera: [], microphone: [], geolocation: [] },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,MAAaA,uBAAsC;CAC/C,eAAe,CAAC,SAAS;CACzB,cAAc,CAAC,UAAU,oCAAoC;CAG7D,aAAa,CAAC,UAAU,kBAAkB;CAC1C,WAAW;EAAC;EAAU;EAAS;EAA0C;EAA2B;CACpG,YAAY,CAAC,UAAU,QAAQ;CAC/B,eAAe;EACX;EACA;EACA;EAGA;EACH;CAED,aAAa,CAAC,oCAAoC;CAElD,mBAAmB,CAAC,SAAS;CAG7B,eAAe,CAAC,SAAS;CACzB,YAAY,CAAC,SAAS;CACtB,cAAc,CAAC,SAAS;CACxB,6BAA6B;CAChC;AAED,MAAaC,yBAAiD;CAC1D,SAAS;CACT,KAAK;EAAE,YAAY;EAAsB,YAAY;EAAO;CAC5D,MAAM;EAAE,QAAQ;EAAU,mBAAmB;EAAM,SAAS;EAAO;CACnE,cAAc;CACd,oBAAoB;CACpB,gBAAgB;CAChB,mBAAmB;EAAE,QAAQ,EAAE;EAAE,YAAY,EAAE;EAAE,aAAa,EAAE;EAAE;CACrE"}