@zuplo/cli 7.1.9 → 7.2.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/node_modules/@hono/node-server/dist/index.cjs +151 -9
- package/node_modules/@hono/node-server/dist/index.mjs +151 -9
- package/node_modules/@hono/node-server/package.json +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/encrypt.d.ts +4 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/types.d.ts +4 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/general/encrypt.js +7 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +6 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/encrypt.d.ts +4 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/types.d.ts +4 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/encrypt.js +7 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +6 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +24 -3
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.js +30 -9
- package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +28 -10
- package/node_modules/@posthog/core/dist/posthog-core.d.ts +3 -3
- package/node_modules/@posthog/core/dist/posthog-core.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core.js +1 -0
- package/node_modules/@posthog/core/dist/posthog-core.mjs +1 -0
- package/node_modules/@posthog/core/dist/types.d.ts +2 -1
- package/node_modules/@posthog/core/dist/types.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/types.js +1 -0
- package/node_modules/@posthog/core/dist/types.mjs +1 -0
- package/node_modules/@posthog/core/package.json +2 -2
- package/node_modules/@posthog/core/src/posthog-core-stateless.ts +42 -10
- package/node_modules/@posthog/core/src/posthog-core.ts +4 -3
- package/node_modules/@posthog/core/src/types.ts +2 -1
- package/node_modules/@posthog/types/dist/capture.d.ts +1 -1
- package/node_modules/@posthog/types/dist/index.d.ts +1 -1
- package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +54 -5
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/posthog.d.ts +3 -3
- package/node_modules/@posthog/types/dist/posthog.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/segment.d.ts +11 -2
- package/node_modules/@posthog/types/dist/segment.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/capture.ts +1 -1
- package/node_modules/@posthog/types/src/index.ts +1 -0
- package/node_modules/@posthog/types/src/posthog-config.ts +64 -6
- package/node_modules/@posthog/types/src/posthog.ts +3 -3
- package/node_modules/@posthog/types/src/segment.ts +11 -2
- package/node_modules/@zuplo/core/customer.cli.minified.js +1 -1
- package/node_modules/@zuplo/core/index.minified.js +1 -1
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-4VE55TG3.js +26 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-4VE55TG3.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-FP5XLKCX.js +409 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-FP5XLKCX.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +299 -20
- package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +1 -0
- package/node_modules/@zuplo/runtime/out/types/mcp/messages/index.d.ts +1 -0
- package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +1 -0
- package/node_modules/@zuplo/runtime/out/types/mocks/index.d.ts +1 -0
- package/node_modules/@zuplo/runtime/out/types/sdks/aws/index.d.ts +1 -0
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/ansi-regex/index.js +3 -2
- package/node_modules/ansi-regex/package.json +1 -1
- package/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/default-browser/package.json +1 -1
- package/node_modules/default-browser/windows.js +3 -1
- package/node_modules/hono/dist/cjs/client/client.js +3 -3
- package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +15 -12
- package/node_modules/hono/dist/cjs/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/cjs/utils/url.js +2 -2
- package/node_modules/hono/dist/client/client.js +3 -3
- package/node_modules/hono/dist/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/middleware/cors/index.js +15 -12
- package/node_modules/hono/dist/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
- package/node_modules/hono/dist/utils/url.js +2 -2
- package/node_modules/hono/package.json +1 -1
- package/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/package.json +6 -6
- package/node_modules/@zuplo/runtime/out/esm/chunk-MXYNCB5D.js +0 -382
- package/node_modules/@zuplo/runtime/out/esm/chunk-MXYNCB5D.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-RAZK5G27.js +0 -26
- package/node_modules/@zuplo/runtime/out/esm/chunk-RAZK5G27.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-MXYNCB5D.js.LEGAL.txt → chunk-FP5XLKCX.js.LEGAL.txt} +0 -0
|
@@ -52,16 +52,17 @@ function format(obj) {
|
|
|
52
52
|
* Parse a `Content-Type` header.
|
|
53
53
|
*/
|
|
54
54
|
function parse(header, options) {
|
|
55
|
+
const stopChar = options?.comma === true ? COMMA : 65536; // Sentinel for "no stop char".
|
|
55
56
|
const len = header.length;
|
|
56
|
-
let index = skipOWS(header, 0, len);
|
|
57
|
+
let index = skipOWS(header, options?.start ?? 0, len);
|
|
57
58
|
const valueStart = index;
|
|
58
|
-
index = skipValue(header, index, len);
|
|
59
|
+
index = skipValue(header, index, len, stopChar);
|
|
59
60
|
const valueEnd = trailingOWS(header, valueStart, index);
|
|
60
61
|
const type = header.slice(valueStart, valueEnd).toLowerCase();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return
|
|
62
|
+
if (options?.parameters === false) {
|
|
63
|
+
return { type, index, parameters: new NullObject() };
|
|
64
|
+
}
|
|
65
|
+
return parseParameters(header, type, index, len, stopChar);
|
|
65
66
|
}
|
|
66
67
|
const SP = 32; // " "
|
|
67
68
|
const HTAB = 9; // "\t"
|
|
@@ -69,16 +70,21 @@ const SEMI = 59; // ";"
|
|
|
69
70
|
const EQ = 61; // "="
|
|
70
71
|
const DQUOTE = 34; // '"'
|
|
71
72
|
const BSLASH = 92; // "\\"
|
|
73
|
+
const COMMA = 44; // ","
|
|
72
74
|
/**
|
|
73
75
|
* Parses the parameters of a `Content-Type` header starting at the given index.
|
|
74
76
|
*/
|
|
75
|
-
function parseParameters(header, index, len) {
|
|
77
|
+
function parseParameters(header, type, index, len, stopChar) {
|
|
76
78
|
const parameters = new NullObject();
|
|
77
79
|
parameter: while (index < len) {
|
|
80
|
+
if (header.charCodeAt(index) === stopChar)
|
|
81
|
+
break;
|
|
78
82
|
index = skipOWS(header, index + 1 /* Skip over ; */, len);
|
|
79
83
|
const keyStart = index;
|
|
80
84
|
while (index < len) {
|
|
81
85
|
const code = header.charCodeAt(index);
|
|
86
|
+
if (code === stopChar)
|
|
87
|
+
break parameter;
|
|
82
88
|
if (code === SEMI)
|
|
83
89
|
continue parameter;
|
|
84
90
|
if (code === EQ) {
|
|
@@ -91,7 +97,7 @@ function parseParameters(header, index, len) {
|
|
|
91
97
|
while (index < len) {
|
|
92
98
|
const code = header.charCodeAt(index++);
|
|
93
99
|
if (code === DQUOTE) {
|
|
94
|
-
index = skipValue(header, index, len);
|
|
100
|
+
index = skipValue(header, index, len, stopChar);
|
|
95
101
|
if (parameters[key] === undefined)
|
|
96
102
|
parameters[key] = value;
|
|
97
103
|
break;
|
|
@@ -105,7 +111,7 @@ function parseParameters(header, index, len) {
|
|
|
105
111
|
continue parameter;
|
|
106
112
|
}
|
|
107
113
|
const valueStart = index;
|
|
108
|
-
index = skipValue(header, index, len);
|
|
114
|
+
index = skipValue(header, index, len, stopChar);
|
|
109
115
|
if (parameters[key] === undefined) {
|
|
110
116
|
const valueEnd = trailingOWS(header, valueStart, index);
|
|
111
117
|
parameters[key] = header.slice(valueStart, valueEnd);
|
|
@@ -115,15 +121,15 @@ function parseParameters(header, index, len) {
|
|
|
115
121
|
index++;
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
|
-
return parameters;
|
|
124
|
+
return { type, index, parameters };
|
|
119
125
|
}
|
|
120
126
|
/**
|
|
121
|
-
* Skip over characters until a semicolon.
|
|
127
|
+
* Skip over characters until a semicolon or other exit character.
|
|
122
128
|
*/
|
|
123
|
-
function skipValue(str, index, len) {
|
|
129
|
+
function skipValue(str, index, len, stopChar) {
|
|
124
130
|
while (index < len) {
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
131
|
+
const code = str.charCodeAt(index);
|
|
132
|
+
if (code === SEMI || code === stopChar)
|
|
127
133
|
break;
|
|
128
134
|
index++;
|
|
129
135
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAwCH,wBAoBC;AAYD,sBAcC;AApFD,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAC5D,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;GAEG;AACH,MAAM,YAAY,GAAG,QAAQ,CAAC;AAE9B;;;;;;GAM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AS,OAAO,CAAC,GAAW;IAC1B,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC;IAE3E,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * content-type\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nconst TEXT_REGEXP = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]*$/;\nconst TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4\n */\nconst QUOTE_REGEXP = /[\\\\\"]/g;\n\n/**\n * RegExp to match type in RFC 9110 sec 8.3.1\n *\n * media-type = type \"/\" subtype\n * type = token\n * subtype = token\n */\nconst TYPE_REGEXP =\n /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.\n */\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\n/**\n * The content type object contains a type string and optional parameters.\n */\nexport interface ContentType {\n type: string;\n parameters: Record<string, string>;\n}\n\n/**\n * Format an object into a `Content-Type` header.\n */\nexport function format(obj: Partial<ContentType>): string {\n const { type, parameters } = obj;\n\n if (!type || !TYPE_REGEXP.test(type)) {\n throw new TypeError(`Invalid type: ${type}`);\n }\n\n let result = type;\n\n if (parameters) {\n for (const param of Object.keys(parameters)) {\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError(`Invalid parameter name: ${param}`);\n }\n\n result += `; ${param}=${qstring(parameters[param])}`;\n }\n }\n\n return result;\n}\n\n/**\n * Options for parsing a `Content-Type` header.\n */\nexport interface ParseOptions {\n parameters?: boolean;\n}\n\n/**\n * Parse a `Content-Type` header.\n */\nexport function parse(header: string, options?: ParseOptions): ContentType {\n const len = header.length;\n let index = skipOWS(header, 0, len);\n\n const valueStart = index;\n index = skipValue(header, index, len);\n const valueEnd = trailingOWS(header, valueStart, index);\n const type = header.slice(valueStart, valueEnd).toLowerCase();\n const parameters =\n options?.parameters === false\n ? new NullObject()\n : parseParameters(header, index, len);\n\n return { type, parameters };\n}\n\nconst SP = 32; // \" \"\nconst HTAB = 9; // \"\\t\"\nconst SEMI = 59; // \";\"\nconst EQ = 61; // \"=\"\nconst DQUOTE = 34; // '\"'\nconst BSLASH = 92; // \"\\\\\"\n\n/**\n * Parses the parameters of a `Content-Type` header starting at the given index.\n */\nfunction parseParameters(\n header: string,\n index: number,\n len: number,\n): Record<string, string> {\n const parameters: Record<string, string> = new NullObject();\n\n parameter: while (index < len) {\n index = skipOWS(header, index + 1 /* Skip over ; */, len);\n\n const keyStart = index;\n\n while (index < len) {\n const code = header.charCodeAt(index);\n if (code === SEMI) continue parameter;\n\n if (code === EQ) {\n const keyEnd = trailingOWS(header, keyStart, index);\n const key = header.slice(keyStart, keyEnd).toLowerCase();\n\n index = skipOWS(header, index + 1, len);\n\n if (index < len && header.charCodeAt(index) === DQUOTE) {\n index++;\n\n let value = \"\";\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = skipValue(header, index, len);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === BSLASH && index < len) {\n value += header[index++];\n continue;\n }\n\n value += String.fromCharCode(code);\n }\n\n continue parameter;\n }\n\n const valueStart = index;\n index = skipValue(header, index, len);\n\n if (parameters[key] === undefined) {\n const valueEnd = trailingOWS(header, valueStart, index);\n parameters[key] = header.slice(valueStart, valueEnd);\n }\n\n continue parameter;\n }\n\n index++;\n }\n }\n\n return parameters;\n}\n\n/**\n * Skip over characters until a semicolon.\n */\nfunction skipValue(str: string, index: number, len: number): number {\n while (index < len) {\n const char = str.charCodeAt(index);\n if (char === SEMI) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip optional whitespace (OWS) in an HTTP header value.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction skipOWS(header: string, index: number, len: number): number {\n while (index < len) {\n const char = header.charCodeAt(index);\n if (char !== SP && char !== HTAB) break;\n index++;\n }\n return index;\n}\n\n/**\n * Trim optional whitespace (OWS) from the end of a substring.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction trailingOWS(header: string, start: number, end: number): number {\n while (end > start) {\n const char = header.charCodeAt(end - 1);\n if (char !== SP && char !== HTAB) break;\n end--;\n }\n return end;\n}\n\n/**\n * Serialize a parameter value.\n */\nfunction qstring(str: string): string {\n if (TOKEN_REGEXP.test(str)) return str;\n if (TEXT_REGEXP.test(str)) return `\"${str.replace(QUOTE_REGEXP, \"\\\\$&\")}\"`;\n\n throw new TypeError(`Invalid parameter value: ${str}`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAyCH,wBAoBC;AA+BD,sBAeC;AAzGD,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAC5D,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;GAEG;AACH,MAAM,YAAY,GAAG,QAAQ,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,GACf,4DAA4D,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE;IACvC,MAAM,CAAC,GAAG,cAAa,CAAC,CAAC;IACzB,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,CAAC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GAAG,GAAG,KAAK,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACxC,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM;QACxC,GAAG,EAAE,CAAC;IACR,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,GAAW;IAC1B,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACvC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC;IAE3E,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * content-type\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nconst TEXT_REGEXP = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]*$/;\nconst TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4\n */\nconst QUOTE_REGEXP = /[\\\\\"]/g;\n\n/**\n * RegExp to match type in RFC 9110 sec 8.3.1\n *\n * media-type = type \"/\" subtype\n * type = token\n * subtype = token\n */\nconst TYPE_REGEXP =\n /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.\n */\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\n/**\n * The content type object contains a type string and optional parameters.\n */\nexport interface ContentType {\n type: string;\n index: number;\n parameters: Record<string, string>;\n}\n\n/**\n * Format an object into a `Content-Type` header.\n */\nexport function format(obj: Partial<ContentType>): string {\n const { type, parameters } = obj;\n\n if (!type || !TYPE_REGEXP.test(type)) {\n throw new TypeError(`Invalid type: ${type}`);\n }\n\n let result = type;\n\n if (parameters) {\n for (const param of Object.keys(parameters)) {\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError(`Invalid parameter name: ${param}`);\n }\n\n result += `; ${param}=${qstring(parameters[param])}`;\n }\n }\n\n return result;\n}\n\n/**\n * Options for parsing a `Content-Type` header.\n */\nexport interface ParseOptions {\n /**\n * Exit early on the first semicolon, returning only the type.\n * This is useful for parsing the MIME from `Content-Type` headers.\n *\n * @default false\n */\n parameters?: boolean;\n /**\n * Exits early on a comma, returning the first value and parameters.\n * This is useful for parsing `Accept` headers.\n *\n * @default false\n */\n comma?: boolean;\n /**\n * The index to start parsing from.\n *\n * @default 0\n */\n start?: number;\n}\n\n/**\n * Parse a `Content-Type` header.\n */\nexport function parse(header: string, options?: ParseOptions): ContentType {\n const stopChar = options?.comma === true ? COMMA : 65_536; // Sentinel for \"no stop char\".\n const len = header.length;\n let index = skipOWS(header, options?.start ?? 0, len);\n\n const valueStart = index;\n index = skipValue(header, index, len, stopChar);\n const valueEnd = trailingOWS(header, valueStart, index);\n const type = header.slice(valueStart, valueEnd).toLowerCase();\n\n if (options?.parameters === false) {\n return { type, index, parameters: new NullObject() };\n }\n\n return parseParameters(header, type, index, len, stopChar);\n}\n\nconst SP = 32; // \" \"\nconst HTAB = 9; // \"\\t\"\nconst SEMI = 59; // \";\"\nconst EQ = 61; // \"=\"\nconst DQUOTE = 34; // '\"'\nconst BSLASH = 92; // \"\\\\\"\nconst COMMA = 44; // \",\"\n\n/**\n * Parses the parameters of a `Content-Type` header starting at the given index.\n */\nfunction parseParameters(\n header: string,\n type: string,\n index: number,\n len: number,\n stopChar: number,\n): ContentType {\n const parameters: Record<string, string> = new NullObject();\n\n parameter: while (index < len) {\n if (header.charCodeAt(index) === stopChar) break;\n\n index = skipOWS(header, index + 1 /* Skip over ; */, len);\n\n const keyStart = index;\n\n while (index < len) {\n const code = header.charCodeAt(index);\n if (code === stopChar) break parameter;\n\n if (code === SEMI) continue parameter;\n\n if (code === EQ) {\n const keyEnd = trailingOWS(header, keyStart, index);\n const key = header.slice(keyStart, keyEnd).toLowerCase();\n\n index = skipOWS(header, index + 1, len);\n\n if (index < len && header.charCodeAt(index) === DQUOTE) {\n index++;\n\n let value = \"\";\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = skipValue(header, index, len, stopChar);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === BSLASH && index < len) {\n value += header[index++];\n continue;\n }\n\n value += String.fromCharCode(code);\n }\n\n continue parameter;\n }\n\n const valueStart = index;\n index = skipValue(header, index, len, stopChar);\n\n if (parameters[key] === undefined) {\n const valueEnd = trailingOWS(header, valueStart, index);\n parameters[key] = header.slice(valueStart, valueEnd);\n }\n\n continue parameter;\n }\n\n index++;\n }\n }\n\n return { type, index, parameters };\n}\n\n/**\n * Skip over characters until a semicolon or other exit character.\n */\nfunction skipValue(\n str: string,\n index: number,\n len: number,\n stopChar: number,\n): number {\n while (index < len) {\n const code = str.charCodeAt(index);\n if (code === SEMI || code === stopChar) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip optional whitespace (OWS) in an HTTP header value.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction skipOWS(header: string, index: number, len: number): number {\n while (index < len) {\n const char = header.charCodeAt(index);\n if (char !== SP && char !== HTAB) break;\n index++;\n }\n return index;\n}\n\n/**\n * Trim optional whitespace (OWS) from the end of a substring.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction trailingOWS(header: string, start: number, end: number): number {\n while (end > start) {\n const char = header.charCodeAt(end - 1);\n if (char !== SP && char !== HTAB) break;\n end--;\n }\n return end;\n}\n\n/**\n * Serialize a parameter value.\n */\nfunction qstring(str: string): string {\n if (TOKEN_REGEXP.test(str)) return str;\n if (TEXT_REGEXP.test(str)) return `\"${str.replace(QUOTE_REGEXP, \"\\\\$&\")}\"`;\n\n throw new TypeError(`Invalid parameter value: ${str}`);\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import {promisify} from 'node:util';
|
|
2
3
|
import {execFile} from 'node:child_process';
|
|
3
4
|
|
|
@@ -31,7 +32,8 @@ export const _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserPro
|
|
|
31
32
|
export class UnknownBrowserError extends Error {}
|
|
32
33
|
|
|
33
34
|
export default async function defaultBrowser(_execFileAsync = execFileAsync) {
|
|
34
|
-
const
|
|
35
|
+
const regPath = `${process.env.SYSTEMROOT ?? process.env.windir ?? 'C:\\Windows'}\\System32\\reg.exe`;
|
|
36
|
+
const {stdout} = await _execFileAsync(regPath, [
|
|
35
37
|
'QUERY',
|
|
36
38
|
' HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice',
|
|
37
39
|
'/v',
|
|
@@ -74,7 +74,7 @@ class ClientRequestImpl {
|
|
|
74
74
|
}
|
|
75
75
|
this.rBody = form;
|
|
76
76
|
}
|
|
77
|
-
if (args.json) {
|
|
77
|
+
if (args.json !== void 0) {
|
|
78
78
|
this.rBody = JSON.stringify(args.json);
|
|
79
79
|
this.cType = "application/json";
|
|
80
80
|
}
|
|
@@ -90,9 +90,9 @@ class ClientRequestImpl {
|
|
|
90
90
|
if (args?.cookie) {
|
|
91
91
|
const cookies = [];
|
|
92
92
|
for (const [key, value] of Object.entries(args.cookie)) {
|
|
93
|
-
cookies.push((0, import_cookie.serialize)(key, value
|
|
93
|
+
cookies.push((0, import_cookie.serialize)(key, value));
|
|
94
94
|
}
|
|
95
|
-
headerValues["Cookie"] = cookies.join("
|
|
95
|
+
headerValues["Cookie"] = cookies.join("; ");
|
|
96
96
|
}
|
|
97
97
|
if (this.cType) {
|
|
98
98
|
headerValues["Content-Type"] = this.cType;
|
|
@@ -101,7 +101,7 @@ const documentMetadataTag = (tag, children, props, sort) => {
|
|
|
101
101
|
const string = new import_base.JSXNode(tag, restProps, (0, import_children.toArray)(children || [])).toString();
|
|
102
102
|
if (string instanceof Promise) {
|
|
103
103
|
return string.then(
|
|
104
|
-
(resString) => (0, import_html.raw)(
|
|
104
|
+
(resString) => (0, import_html.raw)(resString, [
|
|
105
105
|
...resString.callbacks || [],
|
|
106
106
|
insertIntoHead(tag, resString, restProps, precedence)
|
|
107
107
|
])
|
|
@@ -28,6 +28,8 @@ const cors = (options) => {
|
|
|
28
28
|
exposeHeaders: [],
|
|
29
29
|
...options
|
|
30
30
|
};
|
|
31
|
+
const exposeHeadersStr = opts.exposeHeaders?.length ? opts.exposeHeaders.join(",") : void 0;
|
|
32
|
+
const allowHeadersStr = opts.allowHeaders?.length ? opts.allowHeaders.join(",") : void 0;
|
|
31
33
|
const findAllowOrigin = ((optsOrigin) => {
|
|
32
34
|
if (typeof optsOrigin === "string") {
|
|
33
35
|
if (optsOrigin === "*") {
|
|
@@ -43,11 +45,12 @@ const cors = (options) => {
|
|
|
43
45
|
})(opts.origin);
|
|
44
46
|
const findAllowMethods = ((optsAllowMethods) => {
|
|
45
47
|
if (typeof optsAllowMethods === "function") {
|
|
46
|
-
return optsAllowMethods;
|
|
48
|
+
return async (origin, c) => (await optsAllowMethods(origin, c)).join(",");
|
|
47
49
|
} else if (Array.isArray(optsAllowMethods)) {
|
|
48
|
-
|
|
50
|
+
const methodsStr = optsAllowMethods.join(",");
|
|
51
|
+
return () => methodsStr;
|
|
49
52
|
} else {
|
|
50
|
-
return () =>
|
|
53
|
+
return () => "";
|
|
51
54
|
}
|
|
52
55
|
})(opts.allowMethods);
|
|
53
56
|
return async function cors2(c, next) {
|
|
@@ -61,8 +64,8 @@ const cors = (options) => {
|
|
|
61
64
|
if (opts.credentials) {
|
|
62
65
|
set("Access-Control-Allow-Credentials", "true");
|
|
63
66
|
}
|
|
64
|
-
if (
|
|
65
|
-
set("Access-Control-Expose-Headers",
|
|
67
|
+
if (exposeHeadersStr) {
|
|
68
|
+
set("Access-Control-Expose-Headers", exposeHeadersStr);
|
|
66
69
|
}
|
|
67
70
|
if (c.req.method === "OPTIONS") {
|
|
68
71
|
if (opts.origin !== "*") {
|
|
@@ -72,18 +75,18 @@ const cors = (options) => {
|
|
|
72
75
|
set("Access-Control-Max-Age", opts.maxAge.toString());
|
|
73
76
|
}
|
|
74
77
|
const allowMethods = await findAllowMethods(c.req.header("origin") || "", c);
|
|
75
|
-
if (allowMethods
|
|
76
|
-
set("Access-Control-Allow-Methods", allowMethods
|
|
78
|
+
if (allowMethods) {
|
|
79
|
+
set("Access-Control-Allow-Methods", allowMethods);
|
|
77
80
|
}
|
|
78
|
-
let
|
|
79
|
-
if (!
|
|
81
|
+
let headersStr = allowHeadersStr;
|
|
82
|
+
if (!headersStr) {
|
|
80
83
|
const requestHeaders = c.req.header("Access-Control-Request-Headers");
|
|
81
84
|
if (requestHeaders) {
|
|
82
|
-
|
|
85
|
+
headersStr = requestHeaders.split(",").map((h) => h.trim()).join(",");
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
|
-
if (
|
|
86
|
-
set("Access-Control-Allow-Headers",
|
|
88
|
+
if (headersStr) {
|
|
89
|
+
set("Access-Control-Allow-Headers", headersStr);
|
|
87
90
|
c.res.headers.append("Vary", "Access-Control-Request-Headers");
|
|
88
91
|
}
|
|
89
92
|
c.res.headers.delete("Content-Length");
|
|
@@ -31,18 +31,64 @@ const mergeBuffers = (buffer1, buffer2) => {
|
|
|
31
31
|
merged.set(buffer2, buffer1.byteLength);
|
|
32
32
|
return merged;
|
|
33
33
|
};
|
|
34
|
+
const CHUNK_SIZE = 256 * 1024;
|
|
34
35
|
const generateDigest = async (stream, generator) => {
|
|
35
36
|
if (!stream) {
|
|
36
37
|
return null;
|
|
37
38
|
}
|
|
38
39
|
let result = void 0;
|
|
40
|
+
let chunk;
|
|
41
|
+
let chunkLength = 0;
|
|
42
|
+
const digest = async (body) => {
|
|
43
|
+
result = await generator(mergeBuffers(result, body));
|
|
44
|
+
};
|
|
39
45
|
const reader = stream.getReader();
|
|
40
46
|
for (; ; ) {
|
|
41
47
|
const { value, done } = await reader.read();
|
|
42
48
|
if (done) {
|
|
43
49
|
break;
|
|
44
50
|
}
|
|
45
|
-
|
|
51
|
+
let offset = 0;
|
|
52
|
+
while (offset < value.byteLength) {
|
|
53
|
+
const remaining = value.byteLength - offset;
|
|
54
|
+
if (chunkLength === 0 && remaining >= CHUNK_SIZE) {
|
|
55
|
+
await digest(value.subarray(offset, offset + CHUNK_SIZE));
|
|
56
|
+
offset += CHUNK_SIZE;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const requiredLength = chunkLength + remaining;
|
|
60
|
+
if (requiredLength < CHUNK_SIZE) {
|
|
61
|
+
if (!chunk) {
|
|
62
|
+
chunk = value.subarray(offset);
|
|
63
|
+
} else {
|
|
64
|
+
if (chunk.byteLength < requiredLength) {
|
|
65
|
+
const nextChunk = new Uint8Array(
|
|
66
|
+
new ArrayBuffer(Math.min(CHUNK_SIZE, Math.max(requiredLength, chunk.byteLength * 2)))
|
|
67
|
+
);
|
|
68
|
+
nextChunk.set(chunk.subarray(0, chunkLength));
|
|
69
|
+
chunk = nextChunk;
|
|
70
|
+
}
|
|
71
|
+
chunk.set(value.subarray(offset), chunkLength);
|
|
72
|
+
}
|
|
73
|
+
chunkLength = requiredLength;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const length = CHUNK_SIZE - chunkLength;
|
|
77
|
+
if (chunk?.byteLength !== CHUNK_SIZE) {
|
|
78
|
+
const nextChunk = new Uint8Array(new ArrayBuffer(CHUNK_SIZE));
|
|
79
|
+
if (chunk) {
|
|
80
|
+
nextChunk.set(chunk.subarray(0, chunkLength));
|
|
81
|
+
}
|
|
82
|
+
chunk = nextChunk;
|
|
83
|
+
}
|
|
84
|
+
chunk.set(value.subarray(offset, offset + length), chunkLength);
|
|
85
|
+
await digest(chunk);
|
|
86
|
+
chunkLength = 0;
|
|
87
|
+
offset += length;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (chunk && chunkLength > 0) {
|
|
91
|
+
await digest(chunk.subarray(0, chunkLength));
|
|
46
92
|
}
|
|
47
93
|
if (!result) {
|
|
48
94
|
return null;
|
|
@@ -159,14 +159,17 @@ function getPermissionsPolicyDirectives(policy) {
|
|
|
159
159
|
return Object.entries(policy).map(([directive, value]) => {
|
|
160
160
|
const kebabDirective = camelToKebab(directive);
|
|
161
161
|
if (typeof value === "boolean") {
|
|
162
|
-
return `${kebabDirective}=${value ? "*" : "
|
|
162
|
+
return `${kebabDirective}=${value ? "*" : "()"}`;
|
|
163
163
|
}
|
|
164
164
|
if (Array.isArray(value)) {
|
|
165
165
|
if (value.length === 0) {
|
|
166
166
|
return `${kebabDirective}=()`;
|
|
167
167
|
}
|
|
168
|
-
if (value.length === 1 &&
|
|
169
|
-
return `${kebabDirective}
|
|
168
|
+
if (value.length === 1 && value[0] === "*") {
|
|
169
|
+
return `${kebabDirective}=*`;
|
|
170
|
+
}
|
|
171
|
+
if (value.length === 1 && value[0] === "none") {
|
|
172
|
+
return `${kebabDirective}=()`;
|
|
170
173
|
}
|
|
171
174
|
const allowlist = value.map((item) => ["self", "src"].includes(item) ? item : `"${item}"`);
|
|
172
175
|
return `${kebabDirective}=(${allowlist.join(" ")})`;
|
|
@@ -142,13 +142,13 @@ const checkOptionalParameter = (path) => {
|
|
|
142
142
|
if (segment !== "" && !/\:/.test(segment)) {
|
|
143
143
|
basePath += "/" + segment;
|
|
144
144
|
} else if (/\:/.test(segment)) {
|
|
145
|
-
if (
|
|
145
|
+
if (segment.charCodeAt(segment.length - 1) === 63) {
|
|
146
146
|
if (results.length === 0 && basePath === "") {
|
|
147
147
|
results.push("/");
|
|
148
148
|
} else {
|
|
149
149
|
results.push(basePath);
|
|
150
150
|
}
|
|
151
|
-
const optionalSegment = segment.
|
|
151
|
+
const optionalSegment = segment.slice(0, -1);
|
|
152
152
|
basePath += "/" + optionalSegment;
|
|
153
153
|
results.push(basePath);
|
|
154
154
|
} else {
|
|
@@ -60,7 +60,7 @@ var ClientRequestImpl = class {
|
|
|
60
60
|
}
|
|
61
61
|
this.rBody = form;
|
|
62
62
|
}
|
|
63
|
-
if (args.json) {
|
|
63
|
+
if (args.json !== void 0) {
|
|
64
64
|
this.rBody = JSON.stringify(args.json);
|
|
65
65
|
this.cType = "application/json";
|
|
66
66
|
}
|
|
@@ -76,9 +76,9 @@ var ClientRequestImpl = class {
|
|
|
76
76
|
if (args?.cookie) {
|
|
77
77
|
const cookies = [];
|
|
78
78
|
for (const [key, value] of Object.entries(args.cookie)) {
|
|
79
|
-
cookies.push(serialize(key, value
|
|
79
|
+
cookies.push(serialize(key, value));
|
|
80
80
|
}
|
|
81
|
-
headerValues["Cookie"] = cookies.join("
|
|
81
|
+
headerValues["Cookie"] = cookies.join("; ");
|
|
82
82
|
}
|
|
83
83
|
if (this.cType) {
|
|
84
84
|
headerValues["Content-Type"] = this.cType;
|
|
@@ -78,7 +78,7 @@ var documentMetadataTag = (tag, children, props, sort) => {
|
|
|
78
78
|
const string = new JSXNode(tag, restProps, toArray(children || [])).toString();
|
|
79
79
|
if (string instanceof Promise) {
|
|
80
80
|
return string.then(
|
|
81
|
-
(resString) => raw(
|
|
81
|
+
(resString) => raw(resString, [
|
|
82
82
|
...resString.callbacks || [],
|
|
83
83
|
insertIntoHead(tag, resString, restProps, precedence)
|
|
84
84
|
])
|
|
@@ -7,6 +7,8 @@ var cors = (options) => {
|
|
|
7
7
|
exposeHeaders: [],
|
|
8
8
|
...options
|
|
9
9
|
};
|
|
10
|
+
const exposeHeadersStr = opts.exposeHeaders?.length ? opts.exposeHeaders.join(",") : void 0;
|
|
11
|
+
const allowHeadersStr = opts.allowHeaders?.length ? opts.allowHeaders.join(",") : void 0;
|
|
10
12
|
const findAllowOrigin = ((optsOrigin) => {
|
|
11
13
|
if (typeof optsOrigin === "string") {
|
|
12
14
|
if (optsOrigin === "*") {
|
|
@@ -22,11 +24,12 @@ var cors = (options) => {
|
|
|
22
24
|
})(opts.origin);
|
|
23
25
|
const findAllowMethods = ((optsAllowMethods) => {
|
|
24
26
|
if (typeof optsAllowMethods === "function") {
|
|
25
|
-
return optsAllowMethods;
|
|
27
|
+
return async (origin, c) => (await optsAllowMethods(origin, c)).join(",");
|
|
26
28
|
} else if (Array.isArray(optsAllowMethods)) {
|
|
27
|
-
|
|
29
|
+
const methodsStr = optsAllowMethods.join(",");
|
|
30
|
+
return () => methodsStr;
|
|
28
31
|
} else {
|
|
29
|
-
return () =>
|
|
32
|
+
return () => "";
|
|
30
33
|
}
|
|
31
34
|
})(opts.allowMethods);
|
|
32
35
|
return async function cors2(c, next) {
|
|
@@ -40,8 +43,8 @@ var cors = (options) => {
|
|
|
40
43
|
if (opts.credentials) {
|
|
41
44
|
set("Access-Control-Allow-Credentials", "true");
|
|
42
45
|
}
|
|
43
|
-
if (
|
|
44
|
-
set("Access-Control-Expose-Headers",
|
|
46
|
+
if (exposeHeadersStr) {
|
|
47
|
+
set("Access-Control-Expose-Headers", exposeHeadersStr);
|
|
45
48
|
}
|
|
46
49
|
if (c.req.method === "OPTIONS") {
|
|
47
50
|
if (opts.origin !== "*") {
|
|
@@ -51,18 +54,18 @@ var cors = (options) => {
|
|
|
51
54
|
set("Access-Control-Max-Age", opts.maxAge.toString());
|
|
52
55
|
}
|
|
53
56
|
const allowMethods = await findAllowMethods(c.req.header("origin") || "", c);
|
|
54
|
-
if (allowMethods
|
|
55
|
-
set("Access-Control-Allow-Methods", allowMethods
|
|
57
|
+
if (allowMethods) {
|
|
58
|
+
set("Access-Control-Allow-Methods", allowMethods);
|
|
56
59
|
}
|
|
57
|
-
let
|
|
58
|
-
if (!
|
|
60
|
+
let headersStr = allowHeadersStr;
|
|
61
|
+
if (!headersStr) {
|
|
59
62
|
const requestHeaders = c.req.header("Access-Control-Request-Headers");
|
|
60
63
|
if (requestHeaders) {
|
|
61
|
-
|
|
64
|
+
headersStr = requestHeaders.split(",").map((h) => h.trim()).join(",");
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
|
-
if (
|
|
65
|
-
set("Access-Control-Allow-Headers",
|
|
67
|
+
if (headersStr) {
|
|
68
|
+
set("Access-Control-Allow-Headers", headersStr);
|
|
66
69
|
c.res.headers.append("Vary", "Access-Control-Request-Headers");
|
|
67
70
|
}
|
|
68
71
|
c.res.headers.delete("Content-Length");
|
|
@@ -10,18 +10,64 @@ var mergeBuffers = (buffer1, buffer2) => {
|
|
|
10
10
|
merged.set(buffer2, buffer1.byteLength);
|
|
11
11
|
return merged;
|
|
12
12
|
};
|
|
13
|
+
var CHUNK_SIZE = 256 * 1024;
|
|
13
14
|
var generateDigest = async (stream, generator) => {
|
|
14
15
|
if (!stream) {
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
18
|
let result = void 0;
|
|
19
|
+
let chunk;
|
|
20
|
+
let chunkLength = 0;
|
|
21
|
+
const digest = async (body) => {
|
|
22
|
+
result = await generator(mergeBuffers(result, body));
|
|
23
|
+
};
|
|
18
24
|
const reader = stream.getReader();
|
|
19
25
|
for (; ; ) {
|
|
20
26
|
const { value, done } = await reader.read();
|
|
21
27
|
if (done) {
|
|
22
28
|
break;
|
|
23
29
|
}
|
|
24
|
-
|
|
30
|
+
let offset = 0;
|
|
31
|
+
while (offset < value.byteLength) {
|
|
32
|
+
const remaining = value.byteLength - offset;
|
|
33
|
+
if (chunkLength === 0 && remaining >= CHUNK_SIZE) {
|
|
34
|
+
await digest(value.subarray(offset, offset + CHUNK_SIZE));
|
|
35
|
+
offset += CHUNK_SIZE;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const requiredLength = chunkLength + remaining;
|
|
39
|
+
if (requiredLength < CHUNK_SIZE) {
|
|
40
|
+
if (!chunk) {
|
|
41
|
+
chunk = value.subarray(offset);
|
|
42
|
+
} else {
|
|
43
|
+
if (chunk.byteLength < requiredLength) {
|
|
44
|
+
const nextChunk = new Uint8Array(
|
|
45
|
+
new ArrayBuffer(Math.min(CHUNK_SIZE, Math.max(requiredLength, chunk.byteLength * 2)))
|
|
46
|
+
);
|
|
47
|
+
nextChunk.set(chunk.subarray(0, chunkLength));
|
|
48
|
+
chunk = nextChunk;
|
|
49
|
+
}
|
|
50
|
+
chunk.set(value.subarray(offset), chunkLength);
|
|
51
|
+
}
|
|
52
|
+
chunkLength = requiredLength;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
const length = CHUNK_SIZE - chunkLength;
|
|
56
|
+
if (chunk?.byteLength !== CHUNK_SIZE) {
|
|
57
|
+
const nextChunk = new Uint8Array(new ArrayBuffer(CHUNK_SIZE));
|
|
58
|
+
if (chunk) {
|
|
59
|
+
nextChunk.set(chunk.subarray(0, chunkLength));
|
|
60
|
+
}
|
|
61
|
+
chunk = nextChunk;
|
|
62
|
+
}
|
|
63
|
+
chunk.set(value.subarray(offset, offset + length), chunkLength);
|
|
64
|
+
await digest(chunk);
|
|
65
|
+
chunkLength = 0;
|
|
66
|
+
offset += length;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (chunk && chunkLength > 0) {
|
|
70
|
+
await digest(chunk.subarray(0, chunkLength));
|
|
25
71
|
}
|
|
26
72
|
if (!result) {
|
|
27
73
|
return null;
|
|
@@ -137,14 +137,17 @@ function getPermissionsPolicyDirectives(policy) {
|
|
|
137
137
|
return Object.entries(policy).map(([directive, value]) => {
|
|
138
138
|
const kebabDirective = camelToKebab(directive);
|
|
139
139
|
if (typeof value === "boolean") {
|
|
140
|
-
return `${kebabDirective}=${value ? "*" : "
|
|
140
|
+
return `${kebabDirective}=${value ? "*" : "()"}`;
|
|
141
141
|
}
|
|
142
142
|
if (Array.isArray(value)) {
|
|
143
143
|
if (value.length === 0) {
|
|
144
144
|
return `${kebabDirective}=()`;
|
|
145
145
|
}
|
|
146
|
-
if (value.length === 1 &&
|
|
147
|
-
return `${kebabDirective}
|
|
146
|
+
if (value.length === 1 && value[0] === "*") {
|
|
147
|
+
return `${kebabDirective}=*`;
|
|
148
|
+
}
|
|
149
|
+
if (value.length === 1 && value[0] === "none") {
|
|
150
|
+
return `${kebabDirective}=()`;
|
|
148
151
|
}
|
|
149
152
|
const allowlist = value.map((item) => ["self", "src"].includes(item) ? item : `"${item}"`);
|
|
150
153
|
return `${kebabDirective}=(${allowlist.join(" ")})`;
|
|
@@ -2,13 +2,13 @@ export type PermissionsPolicyDirective = StandardizedFeatures | ProposedFeatures
|
|
|
2
2
|
/**
|
|
3
3
|
* These features have been declared in a published version of the respective specification.
|
|
4
4
|
*/
|
|
5
|
-
type StandardizedFeatures = 'accelerometer' | 'ambientLightSensor' | 'attributionReporting' | 'autoplay' | 'battery' | 'bluetooth' | 'camera' | 'chUa' | 'chUaArch' | 'chUaBitness' | 'chUaFullVersion' | 'chUaFullVersionList' | 'chUaMobile' | 'chUaModel' | 'chUaPlatform' | 'chUaPlatformVersion' | 'chUaWow64' | 'computePressure' | 'crossOriginIsolated' | 'directSockets' | 'displayCapture' | 'encryptedMedia' | 'executionWhileNotRendered' | 'executionWhileOutOfViewport' | 'fullscreen' | 'geolocation' | 'gyroscope' | 'hid' | 'identityCredentialsGet' | 'idleDetection' | 'keyboardMap' | 'magnetometer' | 'microphone' | 'midi' | 'navigationOverride' | 'payment' | 'pictureInPicture' | 'publickeyCredentialsGet' | 'screenWakeLock' | 'serial' | 'storageAccess' | 'syncXhr' | 'usb' | 'webShare' | 'windowManagement' | 'xrSpatialTracking';
|
|
5
|
+
type StandardizedFeatures = 'accelerometer' | 'ambientLightSensor' | 'attributionReporting' | 'autoplay' | 'battery' | 'bluetooth' | 'camera' | 'chUa' | 'chUaArch' | 'chUaBitness' | 'chUaFullVersion' | 'chUaFullVersionList' | 'chUaHighEntropyValues' | 'chUaMobile' | 'chUaModel' | 'chUaPlatform' | 'chUaPlatformVersion' | 'chUaWow64' | 'computePressure' | 'crossOriginIsolated' | 'directSockets' | 'displayCapture' | 'encryptedMedia' | 'executionWhileNotRendered' | 'executionWhileOutOfViewport' | 'fullscreen' | 'geolocation' | 'gyroscope' | 'hid' | 'identityCredentialsGet' | 'idleDetection' | 'keyboardMap' | 'magnetometer' | 'mediasession' | 'microphone' | 'midi' | 'navigationOverride' | 'otpCredentials' | 'payment' | 'pictureInPicture' | 'publickeyCredentialsGet' | 'screenWakeLock' | 'serial' | 'storageAccess' | 'syncXhr' | 'tools' | 'usb' | 'webShare' | 'windowManagement' | 'xrSpatialTracking';
|
|
6
6
|
/**
|
|
7
7
|
* These features have been proposed, but the definitions have not yet been integrated into their respective specs.
|
|
8
8
|
*/
|
|
9
|
-
type ProposedFeatures = 'clipboardRead' | 'clipboardWrite' | 'gamepad' | 'sharedAutofill' | 'speakerSelection';
|
|
9
|
+
type ProposedFeatures = 'autofill' | 'clipboardRead' | 'clipboardWrite' | 'deferredFetch' | 'gamepad' | 'languageDetector' | 'languageModel' | 'manualText' | 'rewriter' | 'sharedAutofill' | 'speakerSelection' | 'summarizer' | 'translator' | 'writer';
|
|
10
10
|
/**
|
|
11
11
|
* These features generally have an explainer only, but may be available for experimentation by web developers.
|
|
12
12
|
*/
|
|
13
|
-
type ExperimentalFeatures = 'allScreensCapture' | 'browsingTopics' | 'capturedSurfaceControl' | 'conversionMeasurement' | 'digitalCredentialsGet' | 'focusWithoutUserActivation' | 'joinAdInterestGroup' | 'localFonts' | 'runAdAuction' | 'smartCard' | 'syncScript' | 'trustTokenRedemption' | 'unload' | 'verticalScroll';
|
|
13
|
+
type ExperimentalFeatures = 'allScreensCapture' | 'browsingTopics' | 'capturedSurfaceControl' | 'conversionMeasurement' | 'digitalCredentialsCreate' | 'digitalCredentialsGet' | 'focusWithoutUserActivation' | 'joinAdInterestGroup' | 'localFonts' | 'monetization' | 'runAdAuction' | 'smartCard' | 'syncScript' | 'trustTokenRedemption' | 'unload' | 'verticalScroll';
|
|
14
14
|
export {};
|
|
@@ -108,13 +108,13 @@ var checkOptionalParameter = (path) => {
|
|
|
108
108
|
if (segment !== "" && !/\:/.test(segment)) {
|
|
109
109
|
basePath += "/" + segment;
|
|
110
110
|
} else if (/\:/.test(segment)) {
|
|
111
|
-
if (
|
|
111
|
+
if (segment.charCodeAt(segment.length - 1) === 63) {
|
|
112
112
|
if (results.length === 0 && basePath === "") {
|
|
113
113
|
results.push("/");
|
|
114
114
|
} else {
|
|
115
115
|
results.push(basePath);
|
|
116
116
|
}
|
|
117
|
-
const optionalSegment = segment.
|
|
117
|
+
const optionalSegment = segment.slice(0, -1);
|
|
118
118
|
basePath += "/" + optionalSegment;
|
|
119
119
|
results.push(basePath);
|
|
120
120
|
} else {
|
|
@@ -36,6 +36,8 @@ The parser is lenient and does not error. You should validate `type` and `parame
|
|
|
36
36
|
#### Options
|
|
37
37
|
|
|
38
38
|
- `parameters` (default: `true`): Set to `false` to skip parameters.
|
|
39
|
+
- `comma` (default: `false`): Set to `true` to stop on a comma. This can be used to parse the media range in an `Accept` header.
|
|
40
|
+
- `start` (default: `0`): Set index to start parsing from.
|
|
39
41
|
|
|
40
42
|
### contentType.format(obj)
|
|
41
43
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export interface ContentType {
|
|
10
10
|
type: string;
|
|
11
|
+
index: number;
|
|
11
12
|
parameters: Record<string, string>;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
@@ -18,7 +19,26 @@ export declare function format(obj: Partial<ContentType>): string;
|
|
|
18
19
|
* Options for parsing a `Content-Type` header.
|
|
19
20
|
*/
|
|
20
21
|
export interface ParseOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Exit early on the first semicolon, returning only the type.
|
|
24
|
+
* This is useful for parsing the MIME from `Content-Type` headers.
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
21
28
|
parameters?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Exits early on a comma, returning the first value and parameters.
|
|
31
|
+
* This is useful for parsing `Accept` headers.
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
comma?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The index to start parsing from.
|
|
38
|
+
*
|
|
39
|
+
* @default 0
|
|
40
|
+
*/
|
|
41
|
+
start?: number;
|
|
22
42
|
}
|
|
23
43
|
/**
|
|
24
44
|
* Parse a `Content-Type` header.
|