@zuplo/cli 6.72.0 → 6.72.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.
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/dependabot.yml +42 -2
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/README.md +5 -5
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/index.js +4 -7
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/package.json +3 -3
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/additionalProperties.test.js +47 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/const.test.js +20 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/patternProperties.test.js +24 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/.gitattributes +2 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/.github/dependabot.yml +53 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/.github/workflows/ci.yml +154 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/.github/workflows/lock-threads.yml +19 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/LICENSE +30 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/README.md +152 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/benchmark.mjs +159 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/encoder.mjs +54 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/equal.mjs +51 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/non-simple-domain.mjs +22 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/package.json +17 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/string-array-to-hex-stripped.mjs +24 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/benchmark/ws-is-secure.mjs +65 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/eslint.config.js +6 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/index.js +405 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/lib/schemes.js +267 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/lib/utils.js +585 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/package.json +68 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/ajv.test.js +43 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/equal.test.js +168 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/fixtures/uri-js-parse.json +501 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/fixtures/uri-js-serialize.json +120 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/parse.test.js +325 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/resolve.test.js +87 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/rfc-3986.test.js +90 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/scheme-normalization.test.js +16 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/security-normalization.test.js +39 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/security-utf8-encoding.test.js +0 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/security.test.js +161 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/serialize.test.js +151 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/uri-js-compatibility.test.js +33 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/uri-js.test.js +912 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/util.test.js +47 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/tsconfig.json +10 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/types/index.d.ts +51 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/types/index.tst.ts +15 -0
- package/node_modules/@posthog/core/dist/index.d.ts +3 -0
- package/node_modules/@posthog/core/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/index.js +133 -93
- package/node_modules/@posthog/core/dist/index.mjs +2 -1
- package/node_modules/@posthog/core/dist/metrics/index.d.ts +61 -0
- package/node_modules/@posthog/core/dist/metrics/index.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/metrics/index.js +326 -0
- package/node_modules/@posthog/core/dist/metrics/index.mjs +283 -0
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.d.ts +41 -0
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.js +117 -0
- package/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs +68 -0
- package/node_modules/@posthog/core/dist/metrics/types.d.ts +69 -0
- package/node_modules/@posthog/core/dist/metrics/types.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/metrics/types.js +18 -0
- package/node_modules/@posthog/core/dist/metrics/types.mjs +0 -0
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +2 -0
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.js +16 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +16 -1
- package/node_modules/@posthog/core/package.json +2 -2
- package/node_modules/@posthog/core/src/index.ts +20 -0
- package/node_modules/@posthog/core/src/metrics/index.spec.ts +459 -0
- package/node_modules/@posthog/core/src/metrics/index.ts +414 -0
- package/node_modules/@posthog/core/src/metrics/metrics-utils.ts +100 -0
- package/node_modules/@posthog/core/src/metrics/types.ts +89 -0
- package/node_modules/@posthog/core/src/posthog-core-stateless.ts +26 -0
- package/node_modules/@posthog/types/dist/capture-metric.d.ts +122 -0
- package/node_modules/@posthog/types/dist/capture-metric.d.ts.map +1 -0
- package/node_modules/@posthog/types/dist/capture-metric.js +36 -0
- package/node_modules/@posthog/types/dist/capture-metric.mjs +2 -0
- package/node_modules/@posthog/types/dist/index.d.ts +3 -1
- package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/index.js +19 -1
- package/node_modules/@posthog/types/dist/index.mjs +2 -0
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +60 -0
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/capture-metric.ts +133 -0
- package/node_modules/@posthog/types/src/index.ts +17 -0
- package/node_modules/@posthog/types/src/posthog-config.ts +62 -0
- 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-FAOWNDMK.js → chunk-IC7XGD5C.js} +93 -93
- package/node_modules/@zuplo/runtime/out/esm/chunk-IC7XGD5C.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/types/index.d.ts +830 -6
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +6 -6
- package/node_modules/@zuplo/runtime/out/esm/chunk-FAOWNDMK.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-FAOWNDMK.js.LEGAL.txt → chunk-IC7XGD5C.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/** @type {(value: string) => boolean} */
|
|
4
|
+
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu)
|
|
5
|
+
|
|
6
|
+
/** @type {(value: string) => boolean} */
|
|
7
|
+
const isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u)
|
|
8
|
+
|
|
9
|
+
/** @type {(value: string) => boolean} */
|
|
10
|
+
const isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu)
|
|
11
|
+
|
|
12
|
+
/** @type {(value: string) => boolean} */
|
|
13
|
+
const isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu)
|
|
14
|
+
|
|
15
|
+
/** @type {(value: string) => boolean} */
|
|
16
|
+
const isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu)
|
|
17
|
+
|
|
18
|
+
/** @type {(value: string) => boolean} */
|
|
19
|
+
const isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/?]$/iu)
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {Array<string>} input
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
function stringArrayToHexStripped (input) {
|
|
26
|
+
let acc = ''
|
|
27
|
+
let code = 0
|
|
28
|
+
let i = 0
|
|
29
|
+
|
|
30
|
+
for (i = 0; i < input.length; i++) {
|
|
31
|
+
code = input[i].charCodeAt(0)
|
|
32
|
+
if (code === 48) {
|
|
33
|
+
continue
|
|
34
|
+
}
|
|
35
|
+
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {
|
|
36
|
+
return ''
|
|
37
|
+
}
|
|
38
|
+
acc += input[i]
|
|
39
|
+
break
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (i += 1; i < input.length; i++) {
|
|
43
|
+
code = input[i].charCodeAt(0)
|
|
44
|
+
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102))) {
|
|
45
|
+
return ''
|
|
46
|
+
}
|
|
47
|
+
acc += input[i]
|
|
48
|
+
}
|
|
49
|
+
return acc
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @typedef {Object} GetIPV6Result
|
|
54
|
+
* @property {boolean} error - Indicates if there was an error parsing the IPv6 address.
|
|
55
|
+
* @property {string} address - The parsed IPv6 address.
|
|
56
|
+
* @property {string} [zone] - The zone identifier, if present.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {string} value
|
|
61
|
+
* @returns {boolean}
|
|
62
|
+
*/
|
|
63
|
+
const nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u)
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param {Array<string>} buffer
|
|
67
|
+
* @returns {boolean}
|
|
68
|
+
*/
|
|
69
|
+
function consumeIsZone (buffer) {
|
|
70
|
+
buffer.length = 0
|
|
71
|
+
return true
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {Array<string>} buffer
|
|
76
|
+
* @param {Array<string>} address
|
|
77
|
+
* @param {GetIPV6Result} output
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
function consumeHextets (buffer, address, output) {
|
|
81
|
+
if (buffer.length) {
|
|
82
|
+
const hex = stringArrayToHexStripped(buffer)
|
|
83
|
+
if (hex !== '') {
|
|
84
|
+
address.push(hex)
|
|
85
|
+
} else {
|
|
86
|
+
output.error = true
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
buffer.length = 0
|
|
90
|
+
}
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @param {string} input
|
|
96
|
+
* @returns {GetIPV6Result}
|
|
97
|
+
*/
|
|
98
|
+
function getIPV6 (input) {
|
|
99
|
+
let tokenCount = 0
|
|
100
|
+
const output = { error: false, address: '', zone: '' }
|
|
101
|
+
/** @type {Array<string>} */
|
|
102
|
+
const address = []
|
|
103
|
+
/** @type {Array<string>} */
|
|
104
|
+
const buffer = []
|
|
105
|
+
let endipv6Encountered = false
|
|
106
|
+
let endIpv6 = false
|
|
107
|
+
|
|
108
|
+
let consume = consumeHextets
|
|
109
|
+
|
|
110
|
+
for (let i = 0; i < input.length; i++) {
|
|
111
|
+
const cursor = input[i]
|
|
112
|
+
if (cursor === '[' || cursor === ']') { continue }
|
|
113
|
+
if (cursor === ':') {
|
|
114
|
+
if (endipv6Encountered === true) {
|
|
115
|
+
endIpv6 = true
|
|
116
|
+
}
|
|
117
|
+
if (!consume(buffer, address, output)) { break }
|
|
118
|
+
if (++tokenCount > 7) {
|
|
119
|
+
// not valid
|
|
120
|
+
output.error = true
|
|
121
|
+
break
|
|
122
|
+
}
|
|
123
|
+
if (i > 0 && input[i - 1] === ':') {
|
|
124
|
+
endipv6Encountered = true
|
|
125
|
+
}
|
|
126
|
+
address.push(':')
|
|
127
|
+
continue
|
|
128
|
+
} else if (cursor === '%') {
|
|
129
|
+
if (!consume(buffer, address, output)) { break }
|
|
130
|
+
// switch to zone detection
|
|
131
|
+
consume = consumeIsZone
|
|
132
|
+
} else {
|
|
133
|
+
buffer.push(cursor)
|
|
134
|
+
continue
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (buffer.length) {
|
|
138
|
+
if (consume === consumeIsZone) {
|
|
139
|
+
output.zone = buffer.join('')
|
|
140
|
+
} else if (endIpv6) {
|
|
141
|
+
address.push(buffer.join(''))
|
|
142
|
+
} else {
|
|
143
|
+
address.push(stringArrayToHexStripped(buffer))
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
output.address = address.join('')
|
|
147
|
+
return output
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @typedef {Object} NormalizeIPv6Result
|
|
152
|
+
* @property {string} host - The normalized host.
|
|
153
|
+
* @property {string} [escapedHost] - The escaped host.
|
|
154
|
+
* @property {boolean} isIPV6 - Indicates if the host is an IPv6 address.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {string} host
|
|
159
|
+
* @returns {NormalizeIPv6Result}
|
|
160
|
+
*/
|
|
161
|
+
function normalizeIPv6 (host) {
|
|
162
|
+
if (findToken(host, ':') < 2) { return { host, isIPV6: false } }
|
|
163
|
+
const ipv6 = getIPV6(host)
|
|
164
|
+
|
|
165
|
+
if (!ipv6.error) {
|
|
166
|
+
let newHost = ipv6.address
|
|
167
|
+
let escapedHost = ipv6.address
|
|
168
|
+
if (ipv6.zone) {
|
|
169
|
+
newHost += '%' + ipv6.zone
|
|
170
|
+
escapedHost += '%25' + ipv6.zone
|
|
171
|
+
}
|
|
172
|
+
return { host: newHost, isIPV6: true, escapedHost }
|
|
173
|
+
} else {
|
|
174
|
+
return { host, isIPV6: false }
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @param {string} str
|
|
180
|
+
* @param {string} token
|
|
181
|
+
* @returns {number}
|
|
182
|
+
*/
|
|
183
|
+
function findToken (str, token) {
|
|
184
|
+
let ind = 0
|
|
185
|
+
for (let i = 0; i < str.length; i++) {
|
|
186
|
+
if (str[i] === token) ind++
|
|
187
|
+
}
|
|
188
|
+
return ind
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @param {string} path
|
|
193
|
+
* @returns {string}
|
|
194
|
+
*
|
|
195
|
+
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
|
|
196
|
+
*/
|
|
197
|
+
function removeDotSegments (path) {
|
|
198
|
+
let input = path
|
|
199
|
+
const output = []
|
|
200
|
+
let nextSlash = -1
|
|
201
|
+
let len = 0
|
|
202
|
+
|
|
203
|
+
// eslint-disable-next-line no-cond-assign
|
|
204
|
+
while (len = input.length) {
|
|
205
|
+
if (len === 1) {
|
|
206
|
+
if (input === '.') {
|
|
207
|
+
break
|
|
208
|
+
} else if (input === '/') {
|
|
209
|
+
output.push('/')
|
|
210
|
+
break
|
|
211
|
+
} else {
|
|
212
|
+
output.push(input)
|
|
213
|
+
break
|
|
214
|
+
}
|
|
215
|
+
} else if (len === 2) {
|
|
216
|
+
if (input[0] === '.') {
|
|
217
|
+
if (input[1] === '.') {
|
|
218
|
+
break
|
|
219
|
+
} else if (input[1] === '/') {
|
|
220
|
+
input = input.slice(2)
|
|
221
|
+
continue
|
|
222
|
+
}
|
|
223
|
+
} else if (input[0] === '/') {
|
|
224
|
+
if (input[1] === '.') {
|
|
225
|
+
output.push('/')
|
|
226
|
+
break
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
} else if (len === 3) {
|
|
230
|
+
if (input === '/..') {
|
|
231
|
+
if (output.length !== 0) {
|
|
232
|
+
output.pop()
|
|
233
|
+
}
|
|
234
|
+
output.push('/')
|
|
235
|
+
break
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (input[0] === '.') {
|
|
239
|
+
if (input[1] === '.') {
|
|
240
|
+
if (input[2] === '/') {
|
|
241
|
+
input = input.slice(3)
|
|
242
|
+
continue
|
|
243
|
+
}
|
|
244
|
+
} else if (input[1] === '/') {
|
|
245
|
+
input = input.slice(2)
|
|
246
|
+
continue
|
|
247
|
+
}
|
|
248
|
+
} else if (input[0] === '/') {
|
|
249
|
+
if (input[1] === '.') {
|
|
250
|
+
if (input[2] === '/') {
|
|
251
|
+
input = input.slice(2)
|
|
252
|
+
continue
|
|
253
|
+
} else if (input[2] === '.') {
|
|
254
|
+
if (input[3] === '/') {
|
|
255
|
+
input = input.slice(3)
|
|
256
|
+
if (output.length !== 0) {
|
|
257
|
+
output.pop()
|
|
258
|
+
}
|
|
259
|
+
continue
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Rule 2E: Move normal path segment to output
|
|
266
|
+
if ((nextSlash = input.indexOf('/', 1)) === -1) {
|
|
267
|
+
output.push(input)
|
|
268
|
+
break
|
|
269
|
+
} else {
|
|
270
|
+
output.push(input.slice(0, nextSlash))
|
|
271
|
+
input = input.slice(nextSlash)
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return output.join('')
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Re-escape RFC 3986 gen-delims that must not appear literally in the host.
|
|
280
|
+
* After the URI regex parses, these characters cannot be literal in the host
|
|
281
|
+
* field, so any that appear after decoding came from percent-encoding and
|
|
282
|
+
* must be restored to prevent authority structure changes.
|
|
283
|
+
*
|
|
284
|
+
* @param {string} host
|
|
285
|
+
* @param {boolean} isIP - true for IPv4/IPv6 hosts (skip colon re-escaping)
|
|
286
|
+
* @returns {string}
|
|
287
|
+
*/
|
|
288
|
+
const HOST_DELIMS = { '@': '%40', '/': '%2F', '?': '%3F', '#': '%23', ':': '%3A' }
|
|
289
|
+
const HOST_DELIM_RE = /[@/?#:]/g
|
|
290
|
+
const HOST_DELIM_NO_COLON_RE = /[@/?#]/g
|
|
291
|
+
|
|
292
|
+
function reescapeHostDelimiters (host, isIP) {
|
|
293
|
+
const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE
|
|
294
|
+
re.lastIndex = 0
|
|
295
|
+
return host.replace(re, (ch) => HOST_DELIMS[ch])
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Normalizes percent escapes and optionally decodes only unreserved ASCII bytes.
|
|
300
|
+
* Reserved delimiters such as `%2F` and `%2E` stay escaped.
|
|
301
|
+
*
|
|
302
|
+
* @param {string} input
|
|
303
|
+
* @param {boolean} [decodeUnreserved=false]
|
|
304
|
+
* @returns {string}
|
|
305
|
+
*/
|
|
306
|
+
function normalizePercentEncoding (input, decodeUnreserved = false) {
|
|
307
|
+
if (input.indexOf('%') === -1) {
|
|
308
|
+
return input
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
let output = ''
|
|
312
|
+
|
|
313
|
+
for (let i = 0; i < input.length; i++) {
|
|
314
|
+
if (input[i] === '%' && i + 2 < input.length) {
|
|
315
|
+
const hex = input.slice(i + 1, i + 3)
|
|
316
|
+
if (isHexPair(hex)) {
|
|
317
|
+
const normalizedHex = hex.toUpperCase()
|
|
318
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16))
|
|
319
|
+
|
|
320
|
+
if (decodeUnreserved && isUnreserved(decoded)) {
|
|
321
|
+
output += decoded
|
|
322
|
+
} else {
|
|
323
|
+
output += '%' + normalizedHex
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
i += 2
|
|
327
|
+
continue
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
output += input[i]
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return output
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** Pre-built `%XX` strings for every byte. Avoids per-call hex math/concat. */
|
|
338
|
+
const BYTE_HEX = new Array(256)
|
|
339
|
+
{
|
|
340
|
+
const HEX_DIGITS = '0123456789ABCDEF'
|
|
341
|
+
for (let i = 0; i < 256; i++) {
|
|
342
|
+
BYTE_HEX[i] = '%' + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 0xF]
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Mirrors the pass-through set of the deprecated `escape()` global:
|
|
348
|
+
* `A-Z a-z 0-9 * + - . / @ _`. Keeps drop-in semantics for ASCII input.
|
|
349
|
+
*
|
|
350
|
+
* @param {number} cp
|
|
351
|
+
* @returns {boolean}
|
|
352
|
+
*/
|
|
353
|
+
function isEscapeSafe (cp) {
|
|
354
|
+
return (
|
|
355
|
+
(cp >= 0x30 && cp <= 0x39) ||
|
|
356
|
+
(cp >= 0x41 && cp <= 0x5A) ||
|
|
357
|
+
(cp >= 0x61 && cp <= 0x7A) ||
|
|
358
|
+
cp === 0x2A || cp === 0x2B || cp === 0x2D || cp === 0x2E ||
|
|
359
|
+
cp === 0x2F || cp === 0x40 || cp === 0x5F
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* RFC 3986 percent-encode a non-ASCII Unicode code point as UTF-8 bytes.
|
|
365
|
+
* Caller handles the ASCII branch inline for speed.
|
|
366
|
+
*
|
|
367
|
+
* @param {number} cp - Unicode code point (>= 0x80, <= 0x10FFFF)
|
|
368
|
+
* @returns {string}
|
|
369
|
+
*/
|
|
370
|
+
function percentEncodeNonAscii (cp) {
|
|
371
|
+
if (cp < 0x800) {
|
|
372
|
+
return BYTE_HEX[0xC0 | (cp >> 6)] +
|
|
373
|
+
BYTE_HEX[0x80 | (cp & 0x3F)]
|
|
374
|
+
}
|
|
375
|
+
if (cp < 0x10000) {
|
|
376
|
+
return BYTE_HEX[0xE0 | (cp >> 12)] +
|
|
377
|
+
BYTE_HEX[0x80 | ((cp >> 6) & 0x3F)] +
|
|
378
|
+
BYTE_HEX[0x80 | (cp & 0x3F)]
|
|
379
|
+
}
|
|
380
|
+
return BYTE_HEX[0xF0 | (cp >> 18)] +
|
|
381
|
+
BYTE_HEX[0x80 | ((cp >> 12) & 0x3F)] +
|
|
382
|
+
BYTE_HEX[0x80 | ((cp >> 6) & 0x3F)] +
|
|
383
|
+
BYTE_HEX[0x80 | (cp & 0x3F)]
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Normalizes path data without turning reserved escapes into live path syntax.
|
|
388
|
+
* Valid escapes are uppercased, raw unsafe characters are escaped, and only
|
|
389
|
+
* unreserved bytes that are not `.` are decoded.
|
|
390
|
+
*
|
|
391
|
+
* @param {string} input
|
|
392
|
+
* @returns {string}
|
|
393
|
+
*/
|
|
394
|
+
function normalizePathEncoding (input) {
|
|
395
|
+
let output = ''
|
|
396
|
+
|
|
397
|
+
for (let i = 0; i < input.length; i++) {
|
|
398
|
+
const ch = input[i]
|
|
399
|
+
if (ch === '%' && i + 2 < input.length) {
|
|
400
|
+
const hex = input.slice(i + 1, i + 3)
|
|
401
|
+
if (isHexPair(hex)) {
|
|
402
|
+
const normalizedHex = hex.toUpperCase()
|
|
403
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16))
|
|
404
|
+
|
|
405
|
+
if (decoded !== '.' && isUnreserved(decoded)) {
|
|
406
|
+
output += decoded
|
|
407
|
+
} else {
|
|
408
|
+
output += '%' + normalizedHex
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
i += 2
|
|
412
|
+
continue
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (isPathCharacter(ch)) {
|
|
417
|
+
output += ch
|
|
418
|
+
} else {
|
|
419
|
+
const code = input.charCodeAt(i)
|
|
420
|
+
if (code < 0x80) {
|
|
421
|
+
output += isEscapeSafe(code) ? ch : BYTE_HEX[code]
|
|
422
|
+
} else if (code < 0xD800 || code > 0xDFFF) {
|
|
423
|
+
output += percentEncodeNonAscii(code)
|
|
424
|
+
} else if (code <= 0xDBFF && i + 1 < input.length) {
|
|
425
|
+
const low = input.charCodeAt(i + 1)
|
|
426
|
+
if (low >= 0xDC00 && low <= 0xDFFF) {
|
|
427
|
+
output += percentEncodeNonAscii(0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00))
|
|
428
|
+
i++
|
|
429
|
+
} else {
|
|
430
|
+
output += percentEncodeNonAscii(0xFFFD)
|
|
431
|
+
}
|
|
432
|
+
} else {
|
|
433
|
+
output += percentEncodeNonAscii(0xFFFD)
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return output
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Normalizes the percent-encoding of a query or fragment component.
|
|
443
|
+
*
|
|
444
|
+
* Like `normalizePathEncoding`, but uses the query/fragment character set
|
|
445
|
+
* (which additionally allows `?`) and decodes `.` since it has no dot-segment
|
|
446
|
+
* meaning outside of a path.
|
|
447
|
+
*
|
|
448
|
+
* @param {string} input
|
|
449
|
+
* @returns {string}
|
|
450
|
+
*/
|
|
451
|
+
function normalizeQueryFragmentEncoding (input) {
|
|
452
|
+
let output = ''
|
|
453
|
+
|
|
454
|
+
for (let i = 0; i < input.length; i++) {
|
|
455
|
+
const ch = input[i]
|
|
456
|
+
if (ch === '%' && i + 2 < input.length) {
|
|
457
|
+
const hex = input.slice(i + 1, i + 3)
|
|
458
|
+
if (isHexPair(hex)) {
|
|
459
|
+
const normalizedHex = hex.toUpperCase()
|
|
460
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16))
|
|
461
|
+
|
|
462
|
+
if (isUnreserved(decoded)) {
|
|
463
|
+
output += decoded
|
|
464
|
+
} else {
|
|
465
|
+
output += '%' + normalizedHex
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
i += 2
|
|
469
|
+
continue
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (isQueryFragmentCharacter(ch)) {
|
|
474
|
+
output += ch
|
|
475
|
+
} else {
|
|
476
|
+
const code = input.charCodeAt(i)
|
|
477
|
+
if (code < 0x80) {
|
|
478
|
+
output += isEscapeSafe(code) ? ch : BYTE_HEX[code]
|
|
479
|
+
} else if (code < 0xD800 || code > 0xDFFF) {
|
|
480
|
+
output += percentEncodeNonAscii(code)
|
|
481
|
+
} else if (code <= 0xDBFF && i + 1 < input.length) {
|
|
482
|
+
const low = input.charCodeAt(i + 1)
|
|
483
|
+
if (low >= 0xDC00 && low <= 0xDFFF) {
|
|
484
|
+
output += percentEncodeNonAscii(0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00))
|
|
485
|
+
i++
|
|
486
|
+
} else {
|
|
487
|
+
output += percentEncodeNonAscii(0xFFFD)
|
|
488
|
+
}
|
|
489
|
+
} else {
|
|
490
|
+
output += percentEncodeNonAscii(0xFFFD)
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return output
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Escapes a component while preserving existing valid percent escapes.
|
|
500
|
+
*
|
|
501
|
+
* @param {string} input
|
|
502
|
+
* @returns {string}
|
|
503
|
+
*/
|
|
504
|
+
function escapePreservingEscapes (input) {
|
|
505
|
+
let output = ''
|
|
506
|
+
|
|
507
|
+
for (let i = 0; i < input.length; i++) {
|
|
508
|
+
const ch = input[i]
|
|
509
|
+
if (ch === '%' && i + 2 < input.length) {
|
|
510
|
+
const hex = input.slice(i + 1, i + 3)
|
|
511
|
+
if (isHexPair(hex)) {
|
|
512
|
+
output += '%' + hex.toUpperCase()
|
|
513
|
+
i += 2
|
|
514
|
+
continue
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
const code = input.charCodeAt(i)
|
|
519
|
+
if (code < 0x80) {
|
|
520
|
+
output += isEscapeSafe(code) ? ch : BYTE_HEX[code]
|
|
521
|
+
} else if (code < 0xD800 || code > 0xDFFF) {
|
|
522
|
+
output += percentEncodeNonAscii(code)
|
|
523
|
+
} else if (code <= 0xDBFF && i + 1 < input.length) {
|
|
524
|
+
const low = input.charCodeAt(i + 1)
|
|
525
|
+
if (low >= 0xDC00 && low <= 0xDFFF) {
|
|
526
|
+
output += percentEncodeNonAscii(0x10000 + ((code - 0xD800) << 10) + (low - 0xDC00))
|
|
527
|
+
i++
|
|
528
|
+
} else {
|
|
529
|
+
output += percentEncodeNonAscii(0xFFFD)
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
output += percentEncodeNonAscii(0xFFFD)
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
return output
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* @param {import('../types/index').URIComponent} component
|
|
541
|
+
* @returns {string|undefined}
|
|
542
|
+
*/
|
|
543
|
+
function recomposeAuthority (component) {
|
|
544
|
+
const uriTokens = []
|
|
545
|
+
|
|
546
|
+
if (component.userinfo !== undefined) {
|
|
547
|
+
uriTokens.push(component.userinfo)
|
|
548
|
+
uriTokens.push('@')
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (component.host !== undefined) {
|
|
552
|
+
let host = unescape(component.host)
|
|
553
|
+
if (!isIPv4(host)) {
|
|
554
|
+
const ipV6res = normalizeIPv6(host)
|
|
555
|
+
if (ipV6res.isIPV6 === true) {
|
|
556
|
+
host = `[${ipV6res.escapedHost}]`
|
|
557
|
+
} else {
|
|
558
|
+
host = reescapeHostDelimiters(host, false)
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
uriTokens.push(host)
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (typeof component.port === 'number' || typeof component.port === 'string') {
|
|
565
|
+
uriTokens.push(':')
|
|
566
|
+
uriTokens.push(String(component.port))
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
return uriTokens.length ? uriTokens.join('') : undefined
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
module.exports = {
|
|
573
|
+
nonSimpleDomain,
|
|
574
|
+
recomposeAuthority,
|
|
575
|
+
reescapeHostDelimiters,
|
|
576
|
+
normalizePercentEncoding,
|
|
577
|
+
normalizePathEncoding,
|
|
578
|
+
normalizeQueryFragmentEncoding,
|
|
579
|
+
escapePreservingEscapes,
|
|
580
|
+
removeDotSegments,
|
|
581
|
+
isIPv4,
|
|
582
|
+
isUUID,
|
|
583
|
+
normalizeIPv6,
|
|
584
|
+
stringArrayToHexStripped
|
|
585
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fast-uri",
|
|
3
|
+
"description": "Dependency-free RFC 3986 URI toolbox",
|
|
4
|
+
"version": "4.1.0",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
|
+
"license": "BSD-3-Clause",
|
|
9
|
+
"author": "Vincent Le Goff <vince.legoff@gmail.com> (https://github.com/zekth)",
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "Matteo Collina",
|
|
13
|
+
"email": "hello@matteocollina.com"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "Gürgün Dayıoğlu",
|
|
17
|
+
"email": "hey@gurgun.day",
|
|
18
|
+
"url": "https://heyhey.to/G"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "Aras Abbasi",
|
|
22
|
+
"email": "aras.abbasi@gmail.com"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Frazer Smith",
|
|
26
|
+
"email": "frazer.dev@icloud.com",
|
|
27
|
+
"url": "https://github.com/fdawgs"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/fastify/fast-uri.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/fastify/fast-uri/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/fastify/fast-uri",
|
|
38
|
+
"funding": [
|
|
39
|
+
{
|
|
40
|
+
"type": "github",
|
|
41
|
+
"url": "https://github.com/sponsors/fastify"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "opencollective",
|
|
45
|
+
"url": "https://opencollective.com/fastify"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"lint": "eslint",
|
|
50
|
+
"lint:fix": "eslint --fix",
|
|
51
|
+
"test": "npm run test:unit",
|
|
52
|
+
"test:browser:chromium": "playwright-test ./test/* --runner tape --browser=chromium",
|
|
53
|
+
"test:browser:firefox": "playwright-test ./test/* --runner tape --browser=firefox",
|
|
54
|
+
"test:browser:webkit": "playwright-test ./test/* --runner tape --browser=webkit",
|
|
55
|
+
"test:browser": "npm run test:browser:chromium && npm run test:browser:firefox && npm run test:browser:webkit",
|
|
56
|
+
"test:unit": "tape test/**/*.js",
|
|
57
|
+
"test:unit:dev": "npm run test:unit -- --coverage-report=html",
|
|
58
|
+
"test:typescript": "tstyche"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"ajv": "^8.16.0",
|
|
62
|
+
"eslint": "^9.17.0",
|
|
63
|
+
"neostandard": "^0.13.0",
|
|
64
|
+
"playwright-test": "^14.1.12",
|
|
65
|
+
"tape": "^5.8.1",
|
|
66
|
+
"tstyche": "^7.0.0"
|
|
67
|
+
}
|
|
68
|
+
}
|
package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-uri/test/ajv.test.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const test = require('tape')
|
|
4
|
+
const fastURI = require('..')
|
|
5
|
+
|
|
6
|
+
const AJV = require('ajv')
|
|
7
|
+
|
|
8
|
+
const ajv = new AJV({
|
|
9
|
+
uriResolver: fastURI // comment this line to see it works with uri-js
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('ajv', t => {
|
|
13
|
+
t.plan(1)
|
|
14
|
+
const schema = {
|
|
15
|
+
$ref: '#/definitions/Record%3Cstring%2CPerson%3E',
|
|
16
|
+
definitions: {
|
|
17
|
+
Person: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
firstName: {
|
|
21
|
+
type: 'string'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
'Record<string,Person>': {
|
|
26
|
+
type: 'object',
|
|
27
|
+
additionalProperties: {
|
|
28
|
+
$ref: '#/definitions/Person'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const data = {
|
|
35
|
+
joe: {
|
|
36
|
+
firstName: 'Joe'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const validate = ajv.compile(schema)
|
|
42
|
+
t.ok(validate(data))
|
|
43
|
+
})
|