@zuplo/cli 6.71.23 → 6.71.26

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 (128) hide show
  1. package/node_modules/@fastify/fast-json-stringify-compiler/.github/dependabot.yml +42 -2
  2. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/ci.yml +6 -1
  3. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/lock-threads.yml +19 -0
  4. package/node_modules/@fastify/fast-json-stringify-compiler/LICENSE +1 -1
  5. package/node_modules/@fastify/fast-json-stringify-compiler/README.md +1 -1
  6. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.gitattributes +2 -0
  7. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/dependabot.yml +13 -0
  8. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/ci.yml +33 -0
  9. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
  10. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/LICENSE +22 -0
  11. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/README.md +742 -0
  12. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-branch.js +116 -0
  13. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +339 -0
  14. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-thread.js +33 -0
  15. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench.js +391 -0
  16. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/build/build-schema-validator.js +26 -0
  17. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/eslint.config.js +9 -0
  18. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/example.js +81 -0
  19. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/server.js +42 -0
  20. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/index.js +1308 -0
  21. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/location.js +24 -0
  22. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/merge-schemas.js +9 -0
  23. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/schema-validator.js +1134 -0
  24. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/serializer.js +141 -0
  25. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/standalone.js +34 -0
  26. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/validator.js +96 -0
  27. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/package.json +89 -0
  28. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/additionalProperties.test.js +332 -0
  29. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/allof.test.js +751 -0
  30. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/any.test.js +231 -0
  31. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/anyof.test.js +812 -0
  32. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/array.test.js +688 -0
  33. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/asNumber.test.js +13 -0
  34. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/basic.test.js +400 -0
  35. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/bigint.test.js +76 -0
  36. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/clean-cache.test.js +47 -0
  37. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/const.test.js +314 -0
  38. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/date.test.js +639 -0
  39. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/debug-mode.test.js +130 -0
  40. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/defaults.test.js +376 -0
  41. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/enum.test.js +37 -0
  42. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fix-604.test.js +25 -0
  43. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fixtures/.keep +0 -0
  44. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/if-then-else.test.js +540 -0
  45. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/inferType.test.js +92 -0
  46. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/infinity.test.js +55 -0
  47. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/integer.test.js +194 -0
  48. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/invalidSchema.test.js +38 -0
  49. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-479.test.js +57 -0
  50. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-793.test.js +107 -0
  51. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-794.test.js +177 -0
  52. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
  53. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -0
  54. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md +10 -0
  55. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4/required.json +54 -0
  56. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js +12 -0
  57. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6/required.json +70 -0
  58. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js +12 -0
  59. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7/required.json +70 -0
  60. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js +12 -0
  61. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js +31 -0
  62. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/missing-values.test.js +88 -0
  63. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/multi-type-serializer.test.js +19 -0
  64. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nestedObjects.test.js +63 -0
  65. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nullable.test.js +543 -0
  66. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/oneof.test.js +510 -0
  67. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/patternProperties.test.js +168 -0
  68. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/recursion.test.js +245 -0
  69. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.json +12 -0
  70. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.test.js +2077 -0
  71. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/regex.test.js +32 -0
  72. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/required.test.js +204 -0
  73. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/requiresAjv.test.js +50 -0
  74. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize.test.js +141 -0
  75. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize2.test.js +18 -0
  76. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize3.test.js +17 -0
  77. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize4.test.js +16 -0
  78. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize5.test.js +16 -0
  79. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize6.test.js +22 -0
  80. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize7.test.js +68 -0
  81. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/side-effect.test.js +196 -0
  82. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/standalone-mode.test.js +219 -0
  83. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/string.test.js +84 -0
  84. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/surrogate.test.js +67 -0
  85. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/toJSON.test.js +203 -0
  86. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typebox.test.js +36 -0
  87. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typesArray.test.js +550 -0
  88. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/unknownFormats.test.js +27 -0
  89. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/webpack.test.js +50 -0
  90. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.d.ts +219 -0
  91. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.tst.ts +259 -0
  92. package/node_modules/@fastify/fast-json-stringify-compiler/package.json +6 -11
  93. package/node_modules/@fastify/fast-json-stringify-compiler/types/{index.test-d.ts → index.tst.ts} +34 -32
  94. package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
  95. package/node_modules/@protobufjs/utf8/index.js +29 -18
  96. package/node_modules/@protobufjs/utf8/package.json +2 -2
  97. package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
  98. package/node_modules/@zuplo/core/package.json +1 -1
  99. package/node_modules/@zuplo/graphql/package.json +1 -1
  100. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  101. package/node_modules/@zuplo/otel/package.json +1 -1
  102. package/node_modules/@zuplo/runtime/out/esm/{chunk-5CYWMN74.js → chunk-D3O7C43P.js} +98 -97
  103. package/node_modules/@zuplo/runtime/out/esm/chunk-D3O7C43P.js.map +1 -0
  104. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  105. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  106. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  107. package/node_modules/@zuplo/runtime/out/types/index.d.ts +172 -0
  108. package/node_modules/@zuplo/runtime/package.json +1 -1
  109. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
  110. package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  111. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
  112. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  113. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
  114. package/node_modules/hono/dist/cjs/utils/body.js +12 -4
  115. package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  116. package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  117. package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
  118. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  119. package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  120. package/node_modules/hono/dist/utils/body.js +12 -4
  121. package/node_modules/hono/dist/utils/buffer.js +2 -1
  122. package/node_modules/hono/dist/validator/validator.js +3 -3
  123. package/node_modules/hono/package.json +8 -7
  124. package/package.json +6 -6
  125. package/node_modules/@fastify/fast-json-stringify-compiler/.eslintrc +0 -1
  126. package/node_modules/@zuplo/runtime/out/esm/chunk-5CYWMN74.js.map +0 -1
  127. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  128. /package/node_modules/@zuplo/runtime/out/esm/{chunk-5CYWMN74.js.LEGAL.txt → chunk-D3O7C43P.js.LEGAL.txt} +0 -0
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const validator = require('is-my-json-valid')
5
+ const build = require('..')
6
+
7
+ test('object with RexExp', (t) => {
8
+ t.plan(3)
9
+
10
+ const schema = {
11
+ title: 'object with RegExp',
12
+ type: 'object',
13
+ properties: {
14
+ reg: {
15
+ type: 'string'
16
+ }
17
+ }
18
+ }
19
+
20
+ const obj = {
21
+ reg: /"([^"]|\\")*"/
22
+ }
23
+
24
+ const stringify = build(schema)
25
+ const validate = validator(schema)
26
+ const output = stringify(obj)
27
+
28
+ t.assert.doesNotThrow(() => JSON.parse(output))
29
+
30
+ t.assert.equal(obj.reg.source, new RegExp(JSON.parse(output).reg).source)
31
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
32
+ })
@@ -0,0 +1,204 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('object with required field', (t) => {
7
+ t.plan(2)
8
+
9
+ const schema = {
10
+ title: 'object with required field',
11
+ type: 'object',
12
+ properties: {
13
+ str: {
14
+ type: 'string'
15
+ },
16
+ num: {
17
+ type: 'integer'
18
+ }
19
+ },
20
+ required: ['str']
21
+ }
22
+ const stringify = build(schema)
23
+
24
+ t.assert.doesNotThrow(() => {
25
+ stringify({
26
+ str: 'string'
27
+ })
28
+ })
29
+
30
+ t.assert.throws(() => {
31
+ stringify({
32
+ num: 42
33
+ })
34
+ }, { message: '"str" is required!' })
35
+ })
36
+
37
+ test('object with required field not in properties schema', (t) => {
38
+ t.plan(2)
39
+
40
+ const schema = {
41
+ title: 'object with required field',
42
+ type: 'object',
43
+ properties: {
44
+ num: {
45
+ type: 'integer'
46
+ }
47
+ },
48
+ required: ['str']
49
+ }
50
+ const stringify = build(schema)
51
+
52
+ t.assert.throws(() => {
53
+ stringify({})
54
+ }, { message: '"str" is required!' })
55
+
56
+ t.assert.throws(() => {
57
+ stringify({
58
+ num: 42
59
+ })
60
+ }, { message: '"str" is required!' })
61
+ })
62
+
63
+ test('object with required field not in properties schema with additional properties true', (t) => {
64
+ t.plan(2)
65
+
66
+ const schema = {
67
+ title: 'object with required field',
68
+ type: 'object',
69
+ properties: {
70
+ num: {
71
+ type: 'integer'
72
+ }
73
+ },
74
+ additionalProperties: true,
75
+ required: ['str']
76
+ }
77
+ const stringify = build(schema)
78
+
79
+ t.assert.throws(() => {
80
+ stringify({})
81
+ }, { message: '"str" is required!' })
82
+
83
+ t.assert.throws(() => {
84
+ stringify({
85
+ num: 42
86
+ })
87
+ }, { message: '"str" is required!' })
88
+ })
89
+
90
+ test('object with multiple required field not in properties schema', (t) => {
91
+ t.plan(3)
92
+
93
+ const schema = {
94
+ title: 'object with required field',
95
+ type: 'object',
96
+ properties: {
97
+ num: {
98
+ type: 'integer'
99
+ }
100
+ },
101
+ additionalProperties: true,
102
+ required: ['num', 'key1', 'key2']
103
+ }
104
+ const stringify = build(schema)
105
+
106
+ t.assert.throws(() => {
107
+ stringify({})
108
+ }, { message: '"key1" is required!' })
109
+
110
+ t.assert.throws(() => {
111
+ stringify({
112
+ key1: 42,
113
+ key2: 42
114
+ })
115
+ }, { message: '"num" is required!' })
116
+
117
+ t.assert.throws(() => {
118
+ stringify({
119
+ num: 42,
120
+ key1: 'some'
121
+ })
122
+ }, { message: '"key2" is required!' })
123
+ })
124
+
125
+ test('object with required bool', (t) => {
126
+ t.plan(2)
127
+
128
+ const schema = {
129
+ title: 'object with required field',
130
+ type: 'object',
131
+ properties: {
132
+ num: {
133
+ type: 'integer'
134
+ }
135
+ },
136
+ additionalProperties: true,
137
+ required: ['bool']
138
+ }
139
+ const stringify = build(schema)
140
+
141
+ t.assert.throws(() => {
142
+ stringify({})
143
+ }, { message: '"bool" is required!' })
144
+
145
+ t.assert.doesNotThrow(() => {
146
+ stringify({
147
+ bool: false
148
+ })
149
+ })
150
+ })
151
+
152
+ test('required nullable', (t) => {
153
+ t.plan(1)
154
+
155
+ const schema = {
156
+ title: 'object with required field',
157
+ type: 'object',
158
+ properties: {
159
+ num: {
160
+ type: ['integer']
161
+ }
162
+ },
163
+ additionalProperties: true,
164
+ required: ['null']
165
+ }
166
+ const stringify = build(schema)
167
+
168
+ t.assert.doesNotThrow(() => {
169
+ stringify({
170
+ null: null
171
+ })
172
+ })
173
+ })
174
+
175
+ test('required numbers', (t) => {
176
+ t.plan(2)
177
+
178
+ const schema = {
179
+ title: 'object with required field',
180
+ type: 'object',
181
+ properties: {
182
+ str: {
183
+ type: 'string'
184
+ },
185
+ num: {
186
+ type: 'integer'
187
+ }
188
+ },
189
+ required: ['num']
190
+ }
191
+ const stringify = build(schema)
192
+
193
+ t.assert.doesNotThrow(() => {
194
+ stringify({
195
+ num: 42
196
+ })
197
+ })
198
+
199
+ t.assert.throws(() => {
200
+ stringify({
201
+ num: 'aaa'
202
+ })
203
+ }, { message: 'The value "aaa" cannot be converted to an integer.' })
204
+ })
@@ -0,0 +1,50 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('nested ref requires ajv', async t => {
7
+ t.test('nested ref requires ajv', async t => {
8
+ const schemaA = {
9
+ $id: 'urn:schema:a',
10
+ definitions: {
11
+ foo: { anyOf: [{ type: 'string' }, { type: 'null' }] }
12
+ }
13
+ }
14
+
15
+ const schemaB = {
16
+ $id: 'urn:schema:b',
17
+ type: 'object',
18
+ properties: {
19
+ results: {
20
+ type: 'object',
21
+ properties: {
22
+ items: {
23
+ type: 'object',
24
+ properties: {
25
+ bar: {
26
+ type: 'array',
27
+ items: { $ref: 'urn:schema:a#/definitions/foo' }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ const stringify = build(schemaB, {
37
+ schema: {
38
+ [schemaA.$id]: schemaA
39
+ }
40
+ })
41
+ const result = stringify({
42
+ results: {
43
+ items: {
44
+ bar: ['baz']
45
+ }
46
+ }
47
+ })
48
+ t.assert.equal(result, '{"results":{"items":{"bar":["baz"]}}}')
49
+ })
50
+ })
@@ -0,0 +1,141 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ const stringify = build({
7
+ title: 'Example Schema',
8
+ type: 'object',
9
+ properties: {
10
+ firstName: {
11
+ type: 'string'
12
+ },
13
+ lastName: {
14
+ type: 'string'
15
+ },
16
+ age: {
17
+ description: 'Age in years"',
18
+ type: 'integer'
19
+ },
20
+ [(() => "phra'&& process.exit(1) ||'phra")()]: {},
21
+ now: {
22
+ type: 'string'
23
+ },
24
+ reg: {
25
+ type: 'string',
26
+ default: 'a\'&& process.exit(1) ||\''
27
+ },
28
+ obj: {
29
+ type: 'object',
30
+ properties: {
31
+ bool: {
32
+ type: 'boolean'
33
+ }
34
+ }
35
+ },
36
+ '"\'w00t': {
37
+ type: 'string',
38
+ default: '"\'w00t'
39
+ },
40
+ arr: {
41
+ type: 'array',
42
+ items: {
43
+ type: 'object',
44
+ properties: {
45
+ 'phra\' && process.exit(1)//': {
46
+ type: 'number'
47
+ },
48
+ str: {
49
+ type: 'string'
50
+ }
51
+ }
52
+ }
53
+ }
54
+ },
55
+ required: ['now'],
56
+ patternProperties: {
57
+ '.*foo$': {
58
+ type: 'string'
59
+ },
60
+ test: {
61
+ type: 'number'
62
+ },
63
+ 'phra\'/ && process.exit(1) && /\'': {
64
+ type: 'number'
65
+ },
66
+ '"\'w00t.*////': {
67
+ type: 'number'
68
+ }
69
+ },
70
+ additionalProperties: {
71
+ type: 'string'
72
+ }
73
+ })
74
+
75
+ const obj = {
76
+ firstName: 'Matteo',
77
+ lastName: 'Collina',
78
+ age: 32,
79
+ now: new Date(),
80
+ foo: 'hello"',
81
+ bar: "world'",
82
+ 'fuzz"': 42,
83
+ "me'": 42,
84
+ numfoo: 42,
85
+ test: 42,
86
+ strtest: '23',
87
+ arr: [{ 'phra\' && process.exit(1)//': 42 }],
88
+ obj: { bool: true },
89
+ notmatch: 'valar morghulis',
90
+ notmatchobj: { a: true },
91
+ notmatchnum: 42
92
+ }
93
+
94
+ test('sanitize', t => {
95
+ const json = stringify(obj)
96
+ t.assert.doesNotThrow(() => JSON.parse(json))
97
+
98
+ const stringify2 = build({
99
+ title: 'Example Schema',
100
+ type: 'object',
101
+ patternProperties: {
102
+ '"\'w00t.*////': {
103
+ type: 'number'
104
+ }
105
+ }
106
+ })
107
+
108
+ t.assert.deepStrictEqual(JSON.parse(stringify2({
109
+ '"\'phra////': 42,
110
+ asd: 42
111
+ })), {
112
+ })
113
+
114
+ const stringify3 = build({
115
+ title: 'Example Schema',
116
+ type: 'object',
117
+ properties: {
118
+ "\"phra\\'&&(console.log(42))//||'phra": {}
119
+ }
120
+ })
121
+
122
+ // this verifies the escaping
123
+ JSON.parse(stringify3({
124
+ '"phra\'&&(console.log(42))//||\'phra': 42
125
+ }))
126
+
127
+ const stringify4 = build({
128
+ title: 'Example Schema',
129
+ type: 'object',
130
+ properties: {
131
+ '"\\\\\\\\\'w00t': {
132
+ type: 'string',
133
+ default: '"\'w00t'
134
+ }
135
+ }
136
+ })
137
+
138
+ t.assert.deepStrictEqual(JSON.parse(stringify4({})), {
139
+ '"\\\\\\\\\'w00t': '"\'w00t'
140
+ })
141
+ })
@@ -0,0 +1,18 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('sanitize 2', t => {
7
+ const payload = '(throw "pwoned")'
8
+
9
+ const stringify = build({
10
+ properties: {
11
+ [`*///\\\\\\']);${payload};{/*`]: {
12
+ type: 'number'
13
+ }
14
+ }
15
+ })
16
+
17
+ t.assert.doesNotThrow(() => stringify({}))
18
+ })
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('sanitize 3', t => {
7
+ t.assert.throws(() => {
8
+ build({
9
+ $defs: {
10
+ type: 'foooo"bar'
11
+ },
12
+ patternProperties: {
13
+ x: { $ref: '#/$defs' }
14
+ }
15
+ })
16
+ }, { message: 'foooo"bar unsupported' })
17
+ })
@@ -0,0 +1,16 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('sanitize 4', t => {
7
+ const payload = '(throw "pwoned")'
8
+
9
+ const stringify = build({
10
+ required: [`"];${payload}//`]
11
+ })
12
+
13
+ t.assert.throws(() => {
14
+ stringify({})
15
+ }, { message: '""];(throw "pwoned")//" is required!' })
16
+ })
@@ -0,0 +1,16 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('sanitize 5', t => {
7
+ const payload = '(throw "pwoned")'
8
+
9
+ t.assert.throws(() => {
10
+ build({
11
+ patternProperties: {
12
+ '*': { type: `*/${payload}){//` }
13
+ }
14
+ })
15
+ }, { message: 'schema is invalid: data/patternProperties must match format "regex"' })
16
+ })
@@ -0,0 +1,22 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('sanitize 6', t => {
7
+ const payload = '(throw "pwoned")'
8
+
9
+ const stringify = build({
10
+ type: 'object',
11
+ properties: {
12
+ '/*': { type: 'object' },
13
+ x: {
14
+ type: 'object',
15
+ properties: {
16
+ a: { type: 'string', default: `*/}${payload};{//` }
17
+ }
18
+ }
19
+ }
20
+ })
21
+ t.assert.doesNotThrow(() => { stringify({}) })
22
+ })
@@ -0,0 +1,68 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('required property containing single quote, contains property', (t) => {
7
+ t.plan(1)
8
+
9
+ const stringify = build({
10
+ type: 'object',
11
+ properties: {
12
+ '\'': { type: 'string' }
13
+ },
14
+ required: [
15
+ '\''
16
+ ]
17
+ })
18
+
19
+ t.assert.throws(() => stringify({}), new Error('"\'" is required!'))
20
+ })
21
+
22
+ test('required property containing double quote, contains property', (t) => {
23
+ t.plan(1)
24
+
25
+ const stringify = build({
26
+ type: 'object',
27
+ properties: {
28
+ '"': { type: 'string' }
29
+ },
30
+ required: [
31
+ '"'
32
+ ]
33
+ })
34
+
35
+ t.assert.throws(() => stringify({}), new Error('""" is required!'))
36
+ })
37
+
38
+ test('required property containing single quote, does not contain property', (t) => {
39
+ t.plan(1)
40
+
41
+ const stringify = build({
42
+ type: 'object',
43
+ properties: {
44
+ a: { type: 'string' }
45
+ },
46
+ required: [
47
+ '\''
48
+ ]
49
+ })
50
+
51
+ t.assert.throws(() => stringify({}), new Error('"\'" is required!'))
52
+ })
53
+
54
+ test('required property containing double quote, does not contain property', (t) => {
55
+ t.plan(1)
56
+
57
+ const stringify = build({
58
+ type: 'object',
59
+ properties: {
60
+ a: { type: 'string' }
61
+ },
62
+ required: [
63
+ '"'
64
+ ]
65
+ })
66
+
67
+ t.assert.throws(() => stringify({}), new Error('""" is required!'))
68
+ })