platform-types 1.10.690 → 1.10.691
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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isStorefrontLiteralKey = exports.STOREFRONT_WEB_LITERAL_KEYS = void 0;
|
|
3
|
+
exports.isAllowedStorefrontLiteralValue = exports.isStorefrontLiteralKey = exports.STOREFRONT_WEB_LITERAL_KEYS = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Every storefront `WEB` literal key a shop may override, in code-unit order.
|
|
6
6
|
*
|
|
@@ -1113,3 +1113,23 @@ const STOREFRONT_WEB_LITERAL_KEY_SET = new Set(exports.STOREFRONT_WEB_LITERAL_KE
|
|
|
1113
1113
|
/** Whether a shop may override `key` — membership in {@link STOREFRONT_WEB_LITERAL_KEYS}. */
|
|
1114
1114
|
const isStorefrontLiteralKey = (key) => STOREFRONT_WEB_LITERAL_KEY_SET.has(key);
|
|
1115
1115
|
exports.isStorefrontLiteralKey = isStorefrontLiteralKey;
|
|
1116
|
+
/** Keys whose value is a storefront route the storefront renders as a link target. */
|
|
1117
|
+
const STOREFRONT_NAVIGATE_LITERAL_PREFIX = 'NAVIGATE_';
|
|
1118
|
+
/**
|
|
1119
|
+
* A same-origin path: a leading `/`, a second character that is neither `/` nor `\`
|
|
1120
|
+
* (`//host` and `/\host` are protocol-relative to a browser), and no whitespace or
|
|
1121
|
+
* backslash anywhere — a browser strips tab and newline before parsing, so `/\t/host`
|
|
1122
|
+
* becomes `//host`. A value with a scheme cannot start with `/`.
|
|
1123
|
+
*
|
|
1124
|
+
* The storefront is to apply this identical pattern in `src/app/slices/literals.ts`
|
|
1125
|
+
* `resolveLayer` (its change is pending there); keep the two the same.
|
|
1126
|
+
*/
|
|
1127
|
+
const STOREFRONT_SAME_ORIGIN_PATH_RE = /^\/(?![/\\])[^\s\\]*$/;
|
|
1128
|
+
/**
|
|
1129
|
+
* Whether `value` may be stored, published or served for `key`. A `NAVIGATE_*` key is
|
|
1130
|
+
* rendered as a link, so it must be a same-origin path — otherwise an override could
|
|
1131
|
+
* send a shop's customers to an off-site look-alike login page. Every other key is
|
|
1132
|
+
* unconstrained here (key membership, well-formedness and length are checked apart).
|
|
1133
|
+
*/
|
|
1134
|
+
const isAllowedStorefrontLiteralValue = (key, value) => !key.startsWith(STOREFRONT_NAVIGATE_LITERAL_PREFIX) || STOREFRONT_SAME_ORIGIN_PATH_RE.test(value);
|
|
1135
|
+
exports.isAllowedStorefrontLiteralValue = isAllowedStorefrontLiteralValue;
|
|
@@ -21,3 +21,10 @@
|
|
|
21
21
|
export declare const STOREFRONT_WEB_LITERAL_KEYS: readonly string[];
|
|
22
22
|
/** Whether a shop may override `key` — membership in {@link STOREFRONT_WEB_LITERAL_KEYS}. */
|
|
23
23
|
export declare const isStorefrontLiteralKey: (key: string) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether `value` may be stored, published or served for `key`. A `NAVIGATE_*` key is
|
|
26
|
+
* rendered as a link, so it must be a same-origin path — otherwise an override could
|
|
27
|
+
* send a shop's customers to an off-site look-alike login page. Every other key is
|
|
28
|
+
* unconstrained here (key membership, well-formedness and length are checked apart).
|
|
29
|
+
*/
|
|
30
|
+
export declare const isAllowedStorefrontLiteralValue: (key: string, value: string) => boolean;
|
|
@@ -1109,3 +1109,22 @@ export const STOREFRONT_WEB_LITERAL_KEYS = Object.freeze([
|
|
|
1109
1109
|
const STOREFRONT_WEB_LITERAL_KEY_SET = new Set(STOREFRONT_WEB_LITERAL_KEYS);
|
|
1110
1110
|
/** Whether a shop may override `key` — membership in {@link STOREFRONT_WEB_LITERAL_KEYS}. */
|
|
1111
1111
|
export const isStorefrontLiteralKey = (key) => STOREFRONT_WEB_LITERAL_KEY_SET.has(key);
|
|
1112
|
+
/** Keys whose value is a storefront route the storefront renders as a link target. */
|
|
1113
|
+
const STOREFRONT_NAVIGATE_LITERAL_PREFIX = 'NAVIGATE_';
|
|
1114
|
+
/**
|
|
1115
|
+
* A same-origin path: a leading `/`, a second character that is neither `/` nor `\`
|
|
1116
|
+
* (`//host` and `/\host` are protocol-relative to a browser), and no whitespace or
|
|
1117
|
+
* backslash anywhere — a browser strips tab and newline before parsing, so `/\t/host`
|
|
1118
|
+
* becomes `//host`. A value with a scheme cannot start with `/`.
|
|
1119
|
+
*
|
|
1120
|
+
* The storefront is to apply this identical pattern in `src/app/slices/literals.ts`
|
|
1121
|
+
* `resolveLayer` (its change is pending there); keep the two the same.
|
|
1122
|
+
*/
|
|
1123
|
+
const STOREFRONT_SAME_ORIGIN_PATH_RE = /^\/(?![/\\])[^\s\\]*$/;
|
|
1124
|
+
/**
|
|
1125
|
+
* Whether `value` may be stored, published or served for `key`. A `NAVIGATE_*` key is
|
|
1126
|
+
* rendered as a link, so it must be a same-origin path — otherwise an override could
|
|
1127
|
+
* send a shop's customers to an off-site look-alike login page. Every other key is
|
|
1128
|
+
* unconstrained here (key membership, well-formedness and length are checked apart).
|
|
1129
|
+
*/
|
|
1130
|
+
export const isAllowedStorefrontLiteralValue = (key, value) => !key.startsWith(STOREFRONT_NAVIGATE_LITERAL_PREFIX) || STOREFRONT_SAME_ORIGIN_PATH_RE.test(value);
|