cdk-common 2.0.899 → 2.0.901

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 (99) hide show
  1. package/.jsii +8 -2
  2. package/API.md +5 -0
  3. package/lib/main.js +1 -1
  4. package/lib/managed-policies.d.ts +2 -1
  5. package/lib/managed-policies.js +2 -1
  6. package/node_modules/fast-uri/.gitattributes +2 -0
  7. package/node_modules/fast-uri/.github/.stale.yml +21 -0
  8. package/node_modules/fast-uri/.github/dependabot.yml +13 -0
  9. package/node_modules/fast-uri/.github/tests_checker.yml +8 -0
  10. package/node_modules/fast-uri/.github/workflows/ci.yml +23 -0
  11. package/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +20 -0
  12. package/node_modules/fast-uri/.taprc +3 -0
  13. package/node_modules/fast-uri/LICENSE +30 -0
  14. package/node_modules/fast-uri/README.md +125 -0
  15. package/node_modules/fast-uri/benchmark.js +105 -0
  16. package/node_modules/fast-uri/index.js +309 -0
  17. package/node_modules/fast-uri/lib/schemes.js +188 -0
  18. package/node_modules/fast-uri/lib/scopedChars.js +30 -0
  19. package/node_modules/fast-uri/lib/utils.js +242 -0
  20. package/node_modules/fast-uri/package.json +39 -0
  21. package/node_modules/fast-uri/test/.gitkeep +0 -0
  22. package/node_modules/fast-uri/test/ajv.test.js +39 -0
  23. package/node_modules/fast-uri/test/compatibility.test.js +130 -0
  24. package/node_modules/fast-uri/test/equal.test.js +104 -0
  25. package/node_modules/fast-uri/test/parse.test.js +319 -0
  26. package/node_modules/fast-uri/test/resolve.test.js +76 -0
  27. package/node_modules/fast-uri/test/serialize.test.js +144 -0
  28. package/node_modules/fast-uri/test/uri-js.test.js +940 -0
  29. package/node_modules/fast-uri/test/util.test.js +24 -0
  30. package/node_modules/fast-uri/types/index.d.ts +53 -0
  31. package/node_modules/fast-uri/types/index.test-d.ts +17 -0
  32. package/node_modules/table/node_modules/ajv/dist/compile/codegen/code.js +1 -0
  33. package/node_modules/table/node_modules/ajv/dist/compile/codegen/code.js.map +1 -1
  34. package/node_modules/table/node_modules/ajv/dist/compile/index.js.map +1 -1
  35. package/node_modules/table/node_modules/ajv/dist/compile/resolve.d.ts +2 -2
  36. package/node_modules/table/node_modules/ajv/dist/compile/resolve.js.map +1 -1
  37. package/node_modules/table/node_modules/ajv/dist/runtime/uri.d.ts +1 -1
  38. package/node_modules/table/node_modules/ajv/dist/runtime/uri.js +1 -1
  39. package/node_modules/table/node_modules/ajv/dist/runtime/uri.js.map +1 -1
  40. package/node_modules/table/node_modules/ajv/dist/types/index.d.ts +3 -3
  41. package/node_modules/table/node_modules/ajv/dist/types/json-schema.d.ts +10 -10
  42. package/node_modules/table/node_modules/ajv/lib/compile/codegen/code.ts +1 -0
  43. package/node_modules/table/node_modules/ajv/lib/compile/index.ts +2 -2
  44. package/node_modules/table/node_modules/ajv/lib/compile/resolve.ts +2 -2
  45. package/node_modules/table/node_modules/ajv/lib/runtime/uri.ts +1 -1
  46. package/node_modules/table/node_modules/ajv/lib/types/index.ts +3 -3
  47. package/node_modules/table/node_modules/ajv/lib/types/json-schema.ts +10 -10
  48. package/node_modules/table/node_modules/ajv/package.json +5 -5
  49. package/package.json +1 -1
  50. package/node_modules/punycode/LICENSE-MIT.txt +0 -20
  51. package/node_modules/punycode/README.md +0 -148
  52. package/node_modules/punycode/package.json +0 -58
  53. package/node_modules/punycode/punycode.es6.js +0 -444
  54. package/node_modules/punycode/punycode.js +0 -443
  55. package/node_modules/uri-js/LICENSE +0 -11
  56. package/node_modules/uri-js/README.md +0 -203
  57. package/node_modules/uri-js/dist/es5/uri.all.d.ts +0 -59
  58. package/node_modules/uri-js/dist/es5/uri.all.js +0 -1443
  59. package/node_modules/uri-js/dist/es5/uri.all.js.map +0 -1
  60. package/node_modules/uri-js/dist/es5/uri.all.min.d.ts +0 -59
  61. package/node_modules/uri-js/dist/es5/uri.all.min.js +0 -3
  62. package/node_modules/uri-js/dist/es5/uri.all.min.js.map +0 -1
  63. package/node_modules/uri-js/dist/esnext/index.d.ts +0 -1
  64. package/node_modules/uri-js/dist/esnext/index.js +0 -17
  65. package/node_modules/uri-js/dist/esnext/index.js.map +0 -1
  66. package/node_modules/uri-js/dist/esnext/regexps-iri.d.ts +0 -3
  67. package/node_modules/uri-js/dist/esnext/regexps-iri.js +0 -3
  68. package/node_modules/uri-js/dist/esnext/regexps-iri.js.map +0 -1
  69. package/node_modules/uri-js/dist/esnext/regexps-uri.d.ts +0 -4
  70. package/node_modules/uri-js/dist/esnext/regexps-uri.js +0 -42
  71. package/node_modules/uri-js/dist/esnext/regexps-uri.js.map +0 -1
  72. package/node_modules/uri-js/dist/esnext/schemes/http.d.ts +0 -3
  73. package/node_modules/uri-js/dist/esnext/schemes/http.js +0 -28
  74. package/node_modules/uri-js/dist/esnext/schemes/http.js.map +0 -1
  75. package/node_modules/uri-js/dist/esnext/schemes/https.d.ts +0 -3
  76. package/node_modules/uri-js/dist/esnext/schemes/https.js +0 -9
  77. package/node_modules/uri-js/dist/esnext/schemes/https.js.map +0 -1
  78. package/node_modules/uri-js/dist/esnext/schemes/mailto.d.ts +0 -12
  79. package/node_modules/uri-js/dist/esnext/schemes/mailto.js +0 -148
  80. package/node_modules/uri-js/dist/esnext/schemes/mailto.js.map +0 -1
  81. package/node_modules/uri-js/dist/esnext/schemes/urn-uuid.d.ts +0 -7
  82. package/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js +0 -23
  83. package/node_modules/uri-js/dist/esnext/schemes/urn-uuid.js.map +0 -1
  84. package/node_modules/uri-js/dist/esnext/schemes/urn.d.ts +0 -10
  85. package/node_modules/uri-js/dist/esnext/schemes/urn.js +0 -49
  86. package/node_modules/uri-js/dist/esnext/schemes/urn.js.map +0 -1
  87. package/node_modules/uri-js/dist/esnext/schemes/ws.d.ts +0 -7
  88. package/node_modules/uri-js/dist/esnext/schemes/ws.js +0 -41
  89. package/node_modules/uri-js/dist/esnext/schemes/ws.js.map +0 -1
  90. package/node_modules/uri-js/dist/esnext/schemes/wss.d.ts +0 -3
  91. package/node_modules/uri-js/dist/esnext/schemes/wss.js +0 -9
  92. package/node_modules/uri-js/dist/esnext/schemes/wss.js.map +0 -1
  93. package/node_modules/uri-js/dist/esnext/uri.d.ts +0 -59
  94. package/node_modules/uri-js/dist/esnext/uri.js +0 -480
  95. package/node_modules/uri-js/dist/esnext/uri.js.map +0 -1
  96. package/node_modules/uri-js/dist/esnext/util.d.ts +0 -6
  97. package/node_modules/uri-js/dist/esnext/util.js +0 -36
  98. package/node_modules/uri-js/dist/esnext/util.js.map +0 -1
  99. package/node_modules/uri-js/package.json +0 -77
@@ -0,0 +1,188 @@
1
+ 'use strict'
2
+
3
+ const UUID_REG = /^[\da-f]{8}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{12}$/iu
4
+ const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu
5
+
6
+ function isSecure (wsComponents) {
7
+ return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === 'wss'
8
+ }
9
+
10
+ function httpParse (components) {
11
+ if (!components.host) {
12
+ components.error = components.error || 'HTTP URIs must have a host.'
13
+ }
14
+
15
+ return components
16
+ }
17
+
18
+ function httpSerialize (components) {
19
+ const secure = String(components.scheme).toLowerCase() === 'https'
20
+
21
+ // normalize the default port
22
+ if (components.port === (secure ? 443 : 80) || components.port === '') {
23
+ components.port = undefined
24
+ }
25
+
26
+ // normalize the empty path
27
+ if (!components.path) {
28
+ components.path = '/'
29
+ }
30
+
31
+ // NOTE: We do not parse query strings for HTTP URIs
32
+ // as WWW Form Url Encoded query strings are part of the HTML4+ spec,
33
+ // and not the HTTP spec.
34
+
35
+ return components
36
+ }
37
+
38
+ function wsParse (wsComponents) {
39
+ // indicate if the secure flag is set
40
+ wsComponents.secure = isSecure(wsComponents)
41
+
42
+ // construct resouce name
43
+ wsComponents.resourceName = (wsComponents.path || '/') + (wsComponents.query ? '?' + wsComponents.query : '')
44
+ wsComponents.path = undefined
45
+ wsComponents.query = undefined
46
+
47
+ return wsComponents
48
+ }
49
+
50
+ function wsSerialize (wsComponents) {
51
+ // normalize the default port
52
+ if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === '') {
53
+ wsComponents.port = undefined
54
+ }
55
+
56
+ // ensure scheme matches secure flag
57
+ if (typeof wsComponents.secure === 'boolean') {
58
+ wsComponents.scheme = (wsComponents.secure ? 'wss' : 'ws')
59
+ wsComponents.secure = undefined
60
+ }
61
+
62
+ // reconstruct path from resource name
63
+ if (wsComponents.resourceName) {
64
+ const [path, query] = wsComponents.resourceName.split('?')
65
+ wsComponents.path = (path && path !== '/' ? path : undefined)
66
+ wsComponents.query = query
67
+ wsComponents.resourceName = undefined
68
+ }
69
+
70
+ // forbid fragment component
71
+ wsComponents.fragment = undefined
72
+
73
+ return wsComponents
74
+ }
75
+
76
+ function urnParse (urnComponents, options) {
77
+ if (!urnComponents.path) {
78
+ urnComponents.error = 'URN can not be parsed'
79
+ return urnComponents
80
+ }
81
+ const matches = urnComponents.path.match(URN_REG)
82
+ if (matches) {
83
+ const scheme = options.scheme || urnComponents.scheme || 'urn'
84
+ urnComponents.nid = matches[1].toLowerCase()
85
+ urnComponents.nss = matches[2]
86
+ const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`
87
+ const schemeHandler = SCHEMES[urnScheme]
88
+ urnComponents.path = undefined
89
+
90
+ if (schemeHandler) {
91
+ urnComponents = schemeHandler.parse(urnComponents, options)
92
+ }
93
+ } else {
94
+ urnComponents.error = urnComponents.error || 'URN can not be parsed.'
95
+ }
96
+
97
+ return urnComponents
98
+ }
99
+
100
+ function urnSerialize (urnComponents, options) {
101
+ const scheme = options.scheme || urnComponents.scheme || 'urn'
102
+ const nid = urnComponents.nid.toLowerCase()
103
+ const urnScheme = `${scheme}:${options.nid || nid}`
104
+ const schemeHandler = SCHEMES[urnScheme]
105
+
106
+ if (schemeHandler) {
107
+ urnComponents = schemeHandler.serialize(urnComponents, options)
108
+ }
109
+
110
+ const uriComponents = urnComponents
111
+ const nss = urnComponents.nss
112
+ uriComponents.path = `${nid || options.nid}:${nss}`
113
+
114
+ options.skipEscape = true
115
+ return uriComponents
116
+ }
117
+
118
+ function urnuuidParse (urnComponents, options) {
119
+ const uuidComponents = urnComponents
120
+ uuidComponents.uuid = uuidComponents.nss
121
+ uuidComponents.nss = undefined
122
+
123
+ if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) {
124
+ uuidComponents.error = uuidComponents.error || 'UUID is not valid.'
125
+ }
126
+
127
+ return uuidComponents
128
+ }
129
+
130
+ function urnuuidSerialize (uuidComponents) {
131
+ const urnComponents = uuidComponents
132
+ // normalize UUID
133
+ urnComponents.nss = (uuidComponents.uuid || '').toLowerCase()
134
+ return urnComponents
135
+ }
136
+
137
+ const http = {
138
+ scheme: 'http',
139
+ domainHost: true,
140
+ parse: httpParse,
141
+ serialize: httpSerialize
142
+ }
143
+
144
+ const https = {
145
+ scheme: 'https',
146
+ domainHost: http.domainHost,
147
+ parse: httpParse,
148
+ serialize: httpSerialize
149
+ }
150
+
151
+ const ws = {
152
+ scheme: 'ws',
153
+ domainHost: true,
154
+ parse: wsParse,
155
+ serialize: wsSerialize
156
+ }
157
+
158
+ const wss = {
159
+ scheme: 'wss',
160
+ domainHost: ws.domainHost,
161
+ parse: ws.parse,
162
+ serialize: ws.serialize
163
+ }
164
+
165
+ const urn = {
166
+ scheme: 'urn',
167
+ parse: urnParse,
168
+ serialize: urnSerialize,
169
+ skipNormalize: true
170
+ }
171
+
172
+ const urnuuid = {
173
+ scheme: 'urn:uuid',
174
+ parse: urnuuidParse,
175
+ serialize: urnuuidSerialize,
176
+ skipNormalize: true
177
+ }
178
+
179
+ const SCHEMES = {
180
+ http,
181
+ https,
182
+ ws,
183
+ wss,
184
+ urn,
185
+ 'urn:uuid': urnuuid
186
+ }
187
+
188
+ module.exports = SCHEMES
@@ -0,0 +1,30 @@
1
+ 'use strict'
2
+
3
+ const HEX = {
4
+ 0: 0,
5
+ 1: 1,
6
+ 2: 2,
7
+ 3: 3,
8
+ 4: 4,
9
+ 5: 5,
10
+ 6: 6,
11
+ 7: 7,
12
+ 8: 8,
13
+ 9: 9,
14
+ a: 10,
15
+ A: 10,
16
+ b: 11,
17
+ B: 11,
18
+ c: 12,
19
+ C: 12,
20
+ d: 13,
21
+ D: 13,
22
+ e: 14,
23
+ E: 14,
24
+ f: 15,
25
+ F: 15
26
+ }
27
+
28
+ module.exports = {
29
+ HEX
30
+ }
@@ -0,0 +1,242 @@
1
+ 'use strict'
2
+
3
+ const { HEX } = require('./scopedChars')
4
+
5
+ function normalizeIPv4 (host) {
6
+ if (findToken(host, '.') < 3) { return { host, isIPV4: false } }
7
+ const matches = host.match(/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/u) || []
8
+ const [address] = matches
9
+ if (address) {
10
+ return { host: stripLeadingZeros(address, '.'), isIPV4: true }
11
+ } else {
12
+ return { host, isIPV4: false }
13
+ }
14
+ }
15
+
16
+ /**
17
+ * @param {string[]} input
18
+ * @param {boolean} [keepZero=false]
19
+ * @returns {string|undefined}
20
+ */
21
+ function stringArrayToHexStripped (input, keepZero = false) {
22
+ let acc = ''
23
+ let strip = true
24
+ for (const c of input) {
25
+ if (HEX[c] === undefined) return undefined
26
+ if (c !== '0' && strip === true) strip = false
27
+ if (!strip) acc += c
28
+ }
29
+ if (keepZero && acc.length === 0) acc = '0'
30
+ return acc
31
+ }
32
+
33
+ function getIPV6 (input) {
34
+ let tokenCount = 0
35
+ const output = { error: false, address: '', zone: '' }
36
+ const address = []
37
+ const buffer = []
38
+ let isZone = false
39
+ let endipv6Encountered = false
40
+ let endIpv6 = false
41
+
42
+ function consume () {
43
+ if (buffer.length) {
44
+ if (isZone === false) {
45
+ const hex = stringArrayToHexStripped(buffer)
46
+ if (hex !== undefined) {
47
+ address.push(hex)
48
+ } else {
49
+ output.error = true
50
+ return false
51
+ }
52
+ }
53
+ buffer.length = 0
54
+ }
55
+ return true
56
+ }
57
+
58
+ for (let i = 0; i < input.length; i++) {
59
+ const cursor = input[i]
60
+ if (cursor === '[' || cursor === ']') { continue }
61
+ if (cursor === ':') {
62
+ if (endipv6Encountered === true) {
63
+ endIpv6 = true
64
+ }
65
+ if (!consume()) { break }
66
+ tokenCount++
67
+ address.push(':')
68
+ if (tokenCount > 7) {
69
+ // not valid
70
+ output.error = true
71
+ break
72
+ }
73
+ if (i - 1 >= 0 && input[i - 1] === ':') {
74
+ endipv6Encountered = true
75
+ }
76
+ continue
77
+ } else if (cursor === '%') {
78
+ if (!consume()) { break }
79
+ // switch to zone detection
80
+ isZone = true
81
+ } else {
82
+ buffer.push(cursor)
83
+ continue
84
+ }
85
+ }
86
+ if (buffer.length) {
87
+ if (isZone) {
88
+ output.zone = buffer.join('')
89
+ } else if (endIpv6) {
90
+ address.push(buffer.join(''))
91
+ } else {
92
+ address.push(stringArrayToHexStripped(buffer))
93
+ }
94
+ }
95
+ output.address = address.join('')
96
+ return output
97
+ }
98
+
99
+ function normalizeIPv6 (host, opts = {}) {
100
+ if (findToken(host, ':') < 2) { return { host, isIPV6: false } }
101
+ const ipv6 = getIPV6(host)
102
+
103
+ if (!ipv6.error) {
104
+ let newHost = ipv6.address
105
+ let escapedHost = ipv6.address
106
+ if (ipv6.zone) {
107
+ newHost += '%' + ipv6.zone
108
+ escapedHost += '%25' + ipv6.zone
109
+ }
110
+ return { host: newHost, escapedHost, isIPV6: true }
111
+ } else {
112
+ return { host, isIPV6: false }
113
+ }
114
+ }
115
+
116
+ function stripLeadingZeros (str, token) {
117
+ let out = ''
118
+ let skip = true
119
+ const l = str.length
120
+ for (let i = 0; i < l; i++) {
121
+ const c = str[i]
122
+ if (c === '0' && skip) {
123
+ if ((i + 1 <= l && str[i + 1] === token) || i + 1 === l) {
124
+ out += c
125
+ skip = false
126
+ }
127
+ } else {
128
+ if (c === token) {
129
+ skip = true
130
+ } else {
131
+ skip = false
132
+ }
133
+ out += c
134
+ }
135
+ }
136
+ return out
137
+ }
138
+
139
+ function findToken (str, token) {
140
+ let ind = 0
141
+ for (let i = 0; i < str.length; i++) {
142
+ if (str[i] === token) ind++
143
+ }
144
+ return ind
145
+ }
146
+
147
+ const RDS1 = /^\.\.?\//u
148
+ const RDS2 = /^\/\.(?:\/|$)/u
149
+ const RDS3 = /^\/\.\.(?:\/|$)/u
150
+ const RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u
151
+
152
+ function removeDotSegments (input) {
153
+ const output = []
154
+
155
+ while (input.length) {
156
+ if (input.match(RDS1)) {
157
+ input = input.replace(RDS1, '')
158
+ } else if (input.match(RDS2)) {
159
+ input = input.replace(RDS2, '/')
160
+ } else if (input.match(RDS3)) {
161
+ input = input.replace(RDS3, '/')
162
+ output.pop()
163
+ } else if (input === '.' || input === '..') {
164
+ input = ''
165
+ } else {
166
+ const im = input.match(RDS5)
167
+ if (im) {
168
+ const s = im[0]
169
+ input = input.slice(s.length)
170
+ output.push(s)
171
+ } else {
172
+ throw new Error('Unexpected dot segment condition')
173
+ }
174
+ }
175
+ }
176
+ return output.join('')
177
+ }
178
+
179
+ function normalizeComponentEncoding (components, esc) {
180
+ const func = esc !== true ? escape : unescape
181
+ if (components.scheme !== undefined) {
182
+ components.scheme = func(components.scheme)
183
+ }
184
+ if (components.userinfo !== undefined) {
185
+ components.userinfo = func(components.userinfo)
186
+ }
187
+ if (components.host !== undefined) {
188
+ components.host = func(components.host)
189
+ }
190
+ if (components.path !== undefined) {
191
+ components.path = func(components.path)
192
+ }
193
+ if (components.query !== undefined) {
194
+ components.query = func(components.query)
195
+ }
196
+ if (components.fragment !== undefined) {
197
+ components.fragment = func(components.fragment)
198
+ }
199
+ return components
200
+ }
201
+
202
+ function recomposeAuthority (components, options) {
203
+ const uriTokens = []
204
+
205
+ if (components.userinfo !== undefined) {
206
+ uriTokens.push(components.userinfo)
207
+ uriTokens.push('@')
208
+ }
209
+
210
+ if (components.host !== undefined) {
211
+ let host = unescape(components.host)
212
+ const ipV4res = normalizeIPv4(host)
213
+
214
+ if (ipV4res.isIPV4) {
215
+ host = ipV4res.host
216
+ } else {
217
+ const ipV6res = normalizeIPv6(ipV4res.host, { isIPV4: false })
218
+ if (ipV6res.isIPV6 === true) {
219
+ host = `[${ipV6res.escapedHost}]`
220
+ } else {
221
+ host = components.host
222
+ }
223
+ }
224
+ uriTokens.push(host)
225
+ }
226
+
227
+ if (typeof components.port === 'number' || typeof components.port === 'string') {
228
+ uriTokens.push(':')
229
+ uriTokens.push(String(components.port))
230
+ }
231
+
232
+ return uriTokens.length ? uriTokens.join('') : undefined
233
+ };
234
+
235
+ module.exports = {
236
+ recomposeAuthority,
237
+ normalizeComponentEncoding,
238
+ removeDotSegments,
239
+ normalizeIPv4,
240
+ normalizeIPv6,
241
+ stringArrayToHexStripped
242
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "fast-uri",
3
+ "description": "Dependency free RFC 3986 URI toolbox",
4
+ "version": "3.0.1",
5
+ "main": "index.js",
6
+ "type": "commonjs",
7
+ "types": "types/index.d.ts",
8
+ "license": "MIT",
9
+ "author": "Vincent Le Goff <vince.legoff@gmail.com> (https://github.com/zekth)",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/fastify/fast-uri.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/fastify/fast-uri/issues"
16
+ },
17
+ "homepage": "https://github.com/fastify/fast-uri",
18
+ "scripts": {
19
+ "bench": "node benchmark.js",
20
+ "lint": "standard | snazzy",
21
+ "lint:fix": "standard --fix",
22
+ "test": "npm run lint && npm run test:unit && npm run test:typescript",
23
+ "test:ci": "npm run lint && npm run test:unit -- --coverage-report=lcovonly && npm run test:typescript",
24
+ "test:unit": "tap",
25
+ "test:unit:dev": "npm run test:unit -- --coverage-report=html",
26
+ "test:typescript": "tsd"
27
+ },
28
+ "devDependencies": {
29
+ "@fastify/pre-commit": "^2.1.0",
30
+ "ajv": "^8.16.0",
31
+ "benchmark": "^2.1.4",
32
+ "coveralls": "^3.1.1",
33
+ "snazzy": "^9.0.0",
34
+ "standard": "^17.1.0",
35
+ "tap": "^18.7.2",
36
+ "tsd": "^0.31.0",
37
+ "uri-js": "^4.4.1"
38
+ }
39
+ }
File without changes
@@ -0,0 +1,39 @@
1
+ const AJV = require('ajv')
2
+ const fastUri = require('../')
3
+ const ajv = new AJV({
4
+ uriResolver: fastUri // comment this line to see it works with uri-js
5
+ })
6
+ const { test } = require('tap')
7
+
8
+ test('ajv', t => {
9
+ t.plan(1)
10
+ const schema = {
11
+ $ref: '#/definitions/Record%3Cstring%2CPerson%3E',
12
+ definitions: {
13
+ Person: {
14
+ type: 'object',
15
+ properties: {
16
+ firstName: {
17
+ type: 'string'
18
+ }
19
+ }
20
+ },
21
+ 'Record<string,Person>': {
22
+ type: 'object',
23
+ additionalProperties: {
24
+ $ref: '#/definitions/Person'
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ const data = {
31
+ joe: {
32
+ firstName: 'Joe'
33
+ }
34
+
35
+ }
36
+
37
+ const validate = ajv.compile(schema)
38
+ t.ok(validate(data))
39
+ })
@@ -0,0 +1,130 @@
1
+ 'use strict'
2
+
3
+ const tap = require('tap')
4
+ const test = tap.test
5
+ const fastifyURI = require('../')
6
+ const urijs = require('uri-js')
7
+
8
+ test('compatibility Parse', (t) => {
9
+ const toParse = [
10
+ '//www.g.com/error\n/bleh/bleh',
11
+ 'https://fastify.org',
12
+ '/definitions/Record%3Cstring%2CPerson%3E',
13
+ '//10.10.10.10',
14
+ // '//10.10.000.10', <-- not a valid URI per URI spec: https://datatracker.ietf.org/doc/html/rfc5954#section-4.1
15
+ '//[2001:db8::7%en0]',
16
+ '//[2001:dbZ::1]:80',
17
+ '//[2001:db8::1]:80',
18
+ '//[2001:db8::001]:80',
19
+ 'uri://user:pass@example.com:123/one/two.three?q1=a1&q2=a2#body',
20
+ 'http://user:pass@example.com:123/one/space in.url?q1=a1&q2=a2#body',
21
+ '//[::ffff:129.144.52.38]',
22
+ 'uri://10.10.10.10.example.com/en/process',
23
+ '//[2606:2800:220:1:248:1893:25c8:1946]/test',
24
+ 'ws://example.com/chat',
25
+ 'ws://example.com/foo?bar=baz',
26
+ 'wss://example.com/?bar=baz',
27
+ 'wss://example.com/chat',
28
+ 'wss://example.com/foo?bar=baz',
29
+ 'wss://example.com/?bar=baz',
30
+ 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
31
+ 'urn:uuid:notauuid-7dec-11d0-a765-00a0c91e6bf6',
32
+ 'urn:example:%D0%B0123,z456',
33
+ '//[2606:2800:220:1:248:1893:25c8:1946:43209]',
34
+ 'http://foo.bar',
35
+ 'http://',
36
+ '#/$defs/stringMap',
37
+ '#/$defs/string%20Map',
38
+ '#/$defs/string Map',
39
+ '//?json=%7B%22foo%22%3A%22bar%22%7D'
40
+ // 'mailto:chris@example.com'-203845,
41
+ // 'mailto:infobot@example.com?subject=current-issue',
42
+ // 'mailto:infobot@example.com?body=send%20current-issue',
43
+ // 'mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index',
44
+ // 'mailto:list@example.org?In-Reply-To=%3C3469A91.D10AF4C@example.com%3E',
45
+ // 'mailto:majordomo@example.com?body=subscribe%20bamboo-l',
46
+ // 'mailto:joe@example.com?cc=bob@example.com&body=hello',
47
+ // 'mailto:gorby%25kremvax@example.com',
48
+ // 'mailto:unlikely%3Faddress@example.com?blat=foop',
49
+ // 'mailto:Mike%26family@example.org',
50
+ // 'mailto:%22not%40me%22@example.org',
51
+ // 'mailto:%22oh%5C%5Cno%22@example.org',
52
+ // 'mailto:%22%5C%5C%5C%22it\'s%5C%20ugly%5C%5C%5C%22%22@example.org',
53
+ // 'mailto:user@example.org?subject=caf%C3%A9',
54
+ // 'mailto:user@example.org?subject=%3D%3Futf-8%3FQ%3Fcaf%3DC3%3DA9%3F%3D',
55
+ // 'mailto:user@example.org?subject=%3D%3Fiso-8859-1%3FQ%3Fcaf%3DE9%3F%3D',
56
+ // 'mailto:user@example.org?subject=caf%C3%A9&body=caf%C3%A9',
57
+ // 'mailto:user@%E7%B4%8D%E8%B1%86.example.org?subject=Test&body=NATTO'
58
+ ]
59
+ toParse.forEach((x) => {
60
+ t.same(fastifyURI.parse(x), urijs.parse(x), 'Compatibility parse: ' + x)
61
+ })
62
+ t.end()
63
+ })
64
+
65
+ test('compatibility serialize', (t) => {
66
+ const toSerialize = [
67
+ { host: '10.10.10.10.example.com' },
68
+ { host: '2001:db8::7' },
69
+ { host: '::ffff:129.144.52.38' },
70
+ { host: '2606:2800:220:1:248:1893:25c8:1946' },
71
+ { host: '10.10.10.10.example.com' },
72
+ { host: '10.10.10.10' },
73
+ { path: '?query' },
74
+ { path: 'foo:bar' },
75
+ { path: '//path' },
76
+ {
77
+ scheme: 'uri',
78
+ host: 'example.com',
79
+ port: '9000'
80
+ },
81
+ {
82
+ scheme: 'uri',
83
+ userinfo: 'foo:bar',
84
+ host: 'example.com',
85
+ port: 1,
86
+ path: 'path',
87
+ query: 'query',
88
+ fragment: 'fragment'
89
+ },
90
+ {
91
+ scheme: '',
92
+ userinfo: '',
93
+ host: '',
94
+ port: 0,
95
+ path: '',
96
+ query: '',
97
+ fragment: ''
98
+ },
99
+ {
100
+ scheme: undefined,
101
+ userinfo: undefined,
102
+ host: undefined,
103
+ port: undefined,
104
+ path: undefined,
105
+ query: undefined,
106
+ fragment: undefined
107
+ },
108
+ { host: 'fe80::a%en1' },
109
+ { host: 'fe80::a%25en1' },
110
+ {
111
+ scheme: 'ws',
112
+ host: 'example.com',
113
+ resourceName: '/foo?bar',
114
+ secure: true
115
+ },
116
+ {
117
+ scheme: 'scheme',
118
+ path: 'with:colon'
119
+ }
120
+ ]
121
+ toSerialize.forEach((x) => {
122
+ const r = JSON.stringify(x)
123
+ t.same(
124
+ fastifyURI.serialize(x),
125
+ urijs.serialize(x),
126
+ 'Compatibility serialize: ' + JSON.stringify(r)
127
+ )
128
+ })
129
+ t.end()
130
+ })