@arokodev/cli 0.1.0-alpha.5 → 0.1.0-alpha.8

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 (167) hide show
  1. package/node_modules/@pairmesh/client/dist/build-info.generated.d.ts +12 -12
  2. package/node_modules/@pairmesh/client/dist/build-info.generated.js +6 -6
  3. package/node_modules/@pairmesh/client/dist/connectivity/relay/hosted-server.js +1 -1
  4. package/node_modules/@pairmesh/client/dist/session/schemas.d.ts +10 -10
  5. package/node_modules/@pairmesh/client/dist/session/schemas.d.ts.map +1 -1
  6. package/node_modules/@pairmesh/client/package.json +5 -5
  7. package/node_modules/@pairmesh/coordination/package.json +5 -5
  8. package/node_modules/@pairmesh/mcp/package.json +5 -5
  9. package/node_modules/@pairmesh/permissions/package.json +2 -2
  10. package/node_modules/@pairmesh/protocol/dist/action.d.ts +1 -1
  11. package/node_modules/@pairmesh/protocol/dist/inspection-execution.d.ts +1 -1
  12. package/node_modules/@pairmesh/protocol/dist/inspection-thread.d.ts +1 -1
  13. package/node_modules/@pairmesh/protocol/dist/inspection-thread.d.ts.map +1 -1
  14. package/node_modules/@pairmesh/protocol/dist/inspection.d.ts +2 -2
  15. package/node_modules/@pairmesh/protocol/dist/pairing.d.ts +1 -1
  16. package/node_modules/@pairmesh/protocol/dist/progress-event.d.ts +1 -1
  17. package/node_modules/@pairmesh/protocol/dist/progress-event.d.ts.map +1 -1
  18. package/node_modules/@pairmesh/protocol/package.json +2 -2
  19. package/node_modules/@pairmesh/shared/package.json +1 -1
  20. package/node_modules/body-parser/README.md +17 -13
  21. package/node_modules/body-parser/lib/read.js +74 -57
  22. package/node_modules/body-parser/lib/types/json.js +11 -11
  23. package/node_modules/body-parser/lib/types/urlencoded.js +5 -5
  24. package/node_modules/body-parser/lib/utils.js +0 -15
  25. package/node_modules/body-parser/package.json +7 -12
  26. package/node_modules/encodeurl/README.md +14 -0
  27. package/node_modules/encodeurl/index.js +9 -11
  28. package/node_modules/encodeurl/package.json +13 -6
  29. package/node_modules/jose/README.md +2 -2
  30. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +5 -4
  31. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -4
  32. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +5 -4
  33. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +5 -5
  34. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +5 -4
  35. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +5 -5
  36. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +5 -4
  37. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +5 -5
  38. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +5 -4
  39. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +6 -5
  40. package/node_modules/jose/dist/types/jws/general/sign.d.ts +9 -6
  41. package/node_modules/jose/dist/types/jws/general/verify.d.ts +7 -5
  42. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +10 -6
  43. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +1 -1
  44. package/node_modules/jose/dist/types/jwt/sign.d.ts +1 -1
  45. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +3 -1
  46. package/node_modules/jose/dist/types/jwt/verify.d.ts +6 -5
  47. package/node_modules/jose/dist/types/key/export.d.ts +1 -1
  48. package/node_modules/jose/dist/types/key/generate_secret.d.ts +1 -1
  49. package/node_modules/jose/dist/types/key/import.d.ts +2 -2
  50. package/node_modules/jose/dist/types/types.d.ts +173 -107
  51. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +3 -2
  52. package/node_modules/jose/dist/types/util/errors.d.ts +1 -1
  53. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
  54. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +3 -3
  55. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +8 -8
  56. package/node_modules/jose/dist/webapi/jwks/local.js +2 -1
  57. package/node_modules/jose/dist/webapi/jwks/remote.js +6 -4
  58. package/node_modules/jose/dist/webapi/jws/general/sign.js +3 -3
  59. package/node_modules/jose/dist/webapi/jws/general/verify.js +5 -11
  60. package/node_modules/jose/dist/webapi/jwt/encrypt.js +6 -9
  61. package/node_modules/jose/dist/webapi/jwt/sign.js +2 -2
  62. package/node_modules/jose/dist/webapi/jwt/unsecured.js +3 -3
  63. package/node_modules/jose/dist/webapi/key/generate_secret.js +4 -4
  64. package/node_modules/jose/dist/webapi/lib/asn1.js +2 -2
  65. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +4 -4
  66. package/node_modules/jose/dist/webapi/lib/content_encryption.js +8 -8
  67. package/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
  68. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +26 -23
  69. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +5 -5
  70. package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +2 -2
  71. package/node_modules/jose/dist/webapi/lib/jws_sign.js +11 -11
  72. package/node_modules/jose/dist/webapi/lib/jws_verify.js +19 -16
  73. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +48 -44
  74. package/node_modules/jose/dist/webapi/lib/key.js +6 -4
  75. package/node_modules/jose/dist/webapi/lib/key_management.js +17 -18
  76. package/node_modules/jose/dist/webapi/lib/validate.js +10 -10
  77. package/node_modules/jose/dist/webapi/util/decode_jwt.js +12 -12
  78. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +5 -5
  79. package/node_modules/jose/package.json +1 -1
  80. package/node_modules/object-inspect/CHANGELOG.md +31 -0
  81. package/node_modules/object-inspect/index.js +326 -24
  82. package/node_modules/object-inspect/package.json +22 -13
  83. package/node_modules/object-inspect/readme.markdown +4 -1
  84. package/node_modules/object-inspect/stringWidth.js +68 -0
  85. package/node_modules/object-inspect/stringWidthRanges.js +38 -0
  86. package/node_modules/on-finished/index.js +14 -2
  87. package/node_modules/on-finished/package.json +11 -7
  88. package/node_modules/qs/.editorconfig +1 -1
  89. package/node_modules/qs/.github/THREAT_MODEL.md +4 -2
  90. package/node_modules/qs/CHANGELOG.md +103 -14
  91. package/node_modules/qs/README.md +90 -9
  92. package/node_modules/qs/dist/qs.js +19 -19
  93. package/node_modules/qs/eslint.config.mjs +61 -50
  94. package/node_modules/qs/lib/formats.js +7 -2
  95. package/node_modules/qs/lib/parse.js +121 -12
  96. package/node_modules/qs/lib/stringify.js +9 -7
  97. package/node_modules/qs/lib/utils.js +158 -15
  98. package/node_modules/qs/package.json +8 -8
  99. package/node_modules/qs/test/parse.js +509 -2
  100. package/node_modules/qs/test/stringify.js +485 -33
  101. package/node_modules/qs/test/utils.js +245 -3
  102. package/node_modules/router/HISTORY.md +67 -52
  103. package/node_modules/router/README.md +222 -2
  104. package/node_modules/router/index.d.ts +188 -0
  105. package/node_modules/router/index.js +86 -50
  106. package/node_modules/router/lib/layer.js +154 -47
  107. package/node_modules/router/lib/param.js +47 -0
  108. package/node_modules/router/lib/route.d.ts +118 -0
  109. package/node_modules/router/lib/route.js +14 -8
  110. package/node_modules/router/lib/symbols.js +4 -0
  111. package/node_modules/router/lib/tracing.js +173 -0
  112. package/node_modules/router/package.json +24 -9
  113. package/node_modules/ws/README.md +22 -31
  114. package/node_modules/ws/lib/buffer-util.js +13 -2
  115. package/node_modules/ws/lib/receiver.js +8 -0
  116. package/node_modules/ws/lib/sender.js +4 -1
  117. package/node_modules/ws/lib/websocket-server.js +3 -0
  118. package/node_modules/ws/lib/websocket.js +66 -16
  119. package/node_modules/ws/package.json +1 -1
  120. package/node_modules/zod/package.json +1 -1
  121. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  122. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  123. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  124. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  125. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  126. package/node_modules/zod/src/v4/core/util.ts +13 -0
  127. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  128. package/node_modules/zod/v4/core/compile.cjs +8 -0
  129. package/node_modules/zod/v4/core/compile.js +8 -0
  130. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  131. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  132. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  133. package/node_modules/zod/v4/core/schemas.js +30 -0
  134. package/node_modules/zod/v4/core/util.cjs +15 -0
  135. package/node_modules/zod/v4/core/util.d.cts +2 -0
  136. package/node_modules/zod/v4/core/util.d.ts +2 -0
  137. package/node_modules/zod/v4/core/util.js +14 -0
  138. package/node_modules/zod/v4/core/versions.cjs +1 -1
  139. package/node_modules/zod/v4/core/versions.js +1 -1
  140. package/package.json +7 -7
  141. package/node_modules/object-inspect/.eslintrc +0 -53
  142. package/node_modules/object-inspect/.nycrc +0 -13
  143. package/node_modules/object-inspect/example/all.js +0 -23
  144. package/node_modules/object-inspect/example/circular.js +0 -6
  145. package/node_modules/object-inspect/example/fn.js +0 -5
  146. package/node_modules/object-inspect/example/inspect.js +0 -10
  147. package/node_modules/object-inspect/test/bigint.js +0 -58
  148. package/node_modules/object-inspect/test/browser/dom.js +0 -15
  149. package/node_modules/object-inspect/test/circular.js +0 -16
  150. package/node_modules/object-inspect/test/deep.js +0 -12
  151. package/node_modules/object-inspect/test/element.js +0 -53
  152. package/node_modules/object-inspect/test/err.js +0 -48
  153. package/node_modules/object-inspect/test/fakes.js +0 -29
  154. package/node_modules/object-inspect/test/fn.js +0 -76
  155. package/node_modules/object-inspect/test/global.js +0 -17
  156. package/node_modules/object-inspect/test/has.js +0 -15
  157. package/node_modules/object-inspect/test/holes.js +0 -15
  158. package/node_modules/object-inspect/test/indent-option.js +0 -271
  159. package/node_modules/object-inspect/test/inspect.js +0 -139
  160. package/node_modules/object-inspect/test/lowbyte.js +0 -12
  161. package/node_modules/object-inspect/test/number.js +0 -58
  162. package/node_modules/object-inspect/test/quoteStyle.js +0 -26
  163. package/node_modules/object-inspect/test/toStringTag.js +0 -40
  164. package/node_modules/object-inspect/test/undef.js +0 -12
  165. package/node_modules/object-inspect/test/values.js +0 -261
  166. package/node_modules/object-inspect/test-core-js.js +0 -26
  167. package/node_modules/on-finished/HISTORY.md +0 -98
@@ -17,7 +17,7 @@ const iconv = require('iconv-lite')
17
17
  const onFinished = require('on-finished')
18
18
  const zlib = require('node:zlib')
19
19
  const hasBody = require('type-is').hasBody
20
- const { getCharset } = require('./utils')
20
+ const contentType = require('content-type')
21
21
 
22
22
  /**
23
23
  * Module exports.
@@ -25,6 +25,12 @@ const { getCharset } = require('./utils')
25
25
 
26
26
  module.exports = read
27
27
 
28
+ /**
29
+ * @const
30
+ * whether current node version has zstandard support
31
+ */
32
+ const hasZstandardSupport = 'createZstdDecompress' in zlib
33
+
28
34
  /**
29
35
  * Read a request into a buffer and parse.
30
36
  *
@@ -79,38 +85,53 @@ function read (req, res, next, parse, debug, options) {
79
85
  }
80
86
 
81
87
  let length
82
- const opts = options
83
88
  let stream
84
89
 
85
- // read options
86
- const verify = opts.verify
90
+ const verify = options.verify
91
+
92
+ // assert charset is supported before creating the decompression stream, so an
93
+ // unsupported charset cannot leave a decoder piped with no error listener
94
+ if (verify && encoding !== null && !iconv.encodingExists(encoding)) {
95
+ return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
96
+ charset: encoding.toLowerCase(),
97
+ type: 'charset.unsupported'
98
+ }))
99
+ }
87
100
 
88
101
  try {
102
+ const contentEncoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
103
+
104
+ debug('content-encoding "%s"', contentEncoding)
105
+
106
+ if (options.inflate === false && contentEncoding !== 'identity') {
107
+ throw createError(415, 'content encoding unsupported', {
108
+ encoding: contentEncoding,
109
+ type: 'encoding.unsupported'
110
+ })
111
+ }
112
+
89
113
  // get the content stream
90
- stream = contentstream(req, debug, opts.inflate)
91
- length = stream.length
92
- stream.length = undefined
114
+ if (contentEncoding === 'identity') {
115
+ length = req.headers['content-length']
116
+ stream = req
117
+ } else {
118
+ stream = createDecompressionStream(contentEncoding, debug)
119
+ req.pipe(stream)
120
+ }
93
121
  } catch (err) {
94
122
  return next(err)
95
123
  }
96
124
 
97
125
  // set raw-body options
98
- opts.length = length
99
- opts.encoding = verify
100
- ? null
101
- : encoding
102
-
103
- // assert charset is supported
104
- if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
105
- return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
106
- charset: encoding.toLowerCase(),
107
- type: 'charset.unsupported'
108
- }))
126
+ const rawBodyOptions = {
127
+ length,
128
+ encoding: verify ? null : encoding,
129
+ limit: options.limit
109
130
  }
110
131
 
111
132
  // read body
112
133
  debug('read body')
113
- getBody(stream, opts, function (error, body) {
134
+ getBody(stream, rawBodyOptions, function (error, body) {
114
135
  if (error) {
115
136
  let _error
116
137
 
@@ -138,6 +159,17 @@ function read (req, res, next, parse, debug, options) {
138
159
  return
139
160
  }
140
161
 
162
+ // detach and destroy the decompression stream to
163
+ // avoid decompression errors on the finished stream
164
+ if (stream !== req) {
165
+ req.unpipe(stream)
166
+ stream.on('error', () => {})
167
+ stream.destroy()
168
+
169
+ // consume any remaining bytes so the HTTP request can finish
170
+ req.resume()
171
+ }
172
+
141
173
  // verify
142
174
  if (verify) {
143
175
  try {
@@ -145,7 +177,7 @@ function read (req, res, next, parse, debug, options) {
145
177
  verify(req, res, body, encoding)
146
178
  } catch (err) {
147
179
  next(createError(403, err, {
148
- body: body,
180
+ body,
149
181
  type: err.type || 'entity.verify.failed'
150
182
  }))
151
183
  return
@@ -172,38 +204,6 @@ function read (req, res, next, parse, debug, options) {
172
204
  })
173
205
  }
174
206
 
175
- /**
176
- * Get the content stream of the request.
177
- *
178
- * @param {Object} req
179
- * @param {Function} debug
180
- * @param {boolean} inflate
181
- * @returns {Object}
182
- * @private
183
- */
184
- function contentstream (req, debug, inflate) {
185
- const encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
186
- const length = req.headers['content-length']
187
-
188
- debug('content-encoding "%s"', encoding)
189
-
190
- if (inflate === false && encoding !== 'identity') {
191
- throw createError(415, 'content encoding unsupported', {
192
- encoding: encoding,
193
- type: 'encoding.unsupported'
194
- })
195
- }
196
-
197
- if (encoding === 'identity') {
198
- req.length = length
199
- return req
200
- }
201
-
202
- const stream = createDecompressionStream(encoding, debug)
203
- req.pipe(stream)
204
- return stream
205
- }
206
-
207
207
  /**
208
208
  * Create a decompression stream for the given encoding.
209
209
  * @param {string} encoding
@@ -222,12 +222,16 @@ function createDecompressionStream (encoding, debug) {
222
222
  case 'br':
223
223
  debug('brotli decompress body')
224
224
  return zlib.createBrotliDecompress()
225
- default:
226
- throw createError(415, 'unsupported content encoding "' + encoding + '"', {
227
- encoding: encoding,
228
- type: 'encoding.unsupported'
229
- })
225
+ case 'zstd':
226
+ if (hasZstandardSupport) {
227
+ debug('zstd decompress body')
228
+ return zlib.createZstdDecompress()
229
+ }
230
230
  }
231
+ throw createError(415, 'unsupported content encoding "' + encoding + '"', {
232
+ encoding,
233
+ type: 'encoding.unsupported'
234
+ })
231
235
  }
232
236
 
233
237
  /**
@@ -245,3 +249,16 @@ function dump (req, callback) {
245
249
  req.resume()
246
250
  }
247
251
  }
252
+
253
+ /**
254
+ * Get the charset of a request.
255
+ *
256
+ * @param {Object} req
257
+ * @returns {string | undefined}
258
+ * @private
259
+ */
260
+ function getCharset (req) {
261
+ const header = req.headers['content-type']
262
+ if (!header) return undefined
263
+ return contentType.parse(header).parameters.charset?.toLowerCase()
264
+ }
@@ -23,7 +23,7 @@ const { normalizeOptions } = require('../utils')
23
23
  module.exports = json
24
24
 
25
25
  /**
26
- * RegExp to match the first non-space in a string.
26
+ * RegExp to match the first non-whitespace character in a string.
27
27
  *
28
28
  * Allowed whitespace is defined in RFC 7159:
29
29
  *
@@ -33,7 +33,7 @@ module.exports = json
33
33
  * %x0A / ; Line feed or New line
34
34
  * %x0D ) ; Carriage return
35
35
  */
36
- const FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/ // eslint-disable-line no-control-regex
36
+ const FIRST_NON_WHITESPACE_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d]|$)/ // eslint-disable-line no-control-regex
37
37
 
38
38
  const JSON_SYNTAX_CHAR = '#'
39
39
  const JSON_SYNTAX_REGEXP = /#+/g
@@ -80,10 +80,12 @@ function createJsonParser (options) {
80
80
  return {}
81
81
  }
82
82
 
83
- const first = firstchar(body)
84
- if (first !== '{' && first !== '[') {
85
- debug('strict violation')
86
- throw createStrictSyntaxError(body, first)
83
+ if (body[0] !== '{' && body[0] !== '[') {
84
+ const first = firstNonWhitespaceChar(body)
85
+ if (first !== '{' && first !== '[') {
86
+ debug('strict violation')
87
+ throw createStrictSyntaxError(body, first)
88
+ }
87
89
  }
88
90
 
89
91
  try {
@@ -152,12 +154,10 @@ function createStrictSyntaxError (str, char) {
152
154
  * @returns {string|undefined}
153
155
  * @private
154
156
  */
155
- function firstchar (str) {
156
- const match = FIRST_CHAR_REGEXP.exec(str)
157
+ function firstNonWhitespaceChar (str) {
158
+ const match = FIRST_NON_WHITESPACE_REGEXP.exec(str)
157
159
 
158
- return match
159
- ? match[1]
160
- : undefined
160
+ return match && match[1] ? match[1] : undefined
161
161
  }
162
162
 
163
163
  /**
@@ -98,12 +98,12 @@ function createQueryParser (options) {
98
98
  try {
99
99
  return qs.parse(body, {
100
100
  allowPrototypes: true,
101
- arrayLimit: arrayLimit,
102
- depth: depth,
103
- charsetSentinel: charsetSentinel,
104
- interpretNumericEntities: interpretNumericEntities,
101
+ arrayLimit,
102
+ depth,
103
+ charsetSentinel,
104
+ interpretNumericEntities,
105
105
  charset: encoding,
106
- parameterLimit: parameterLimit,
106
+ parameterLimit,
107
107
  strictDepth: true
108
108
  })
109
109
  } catch (err) {
@@ -5,31 +5,16 @@
5
5
  */
6
6
 
7
7
  const bytes = require('bytes')
8
- const contentType = require('content-type')
9
8
  const typeis = require('type-is')
10
9
 
11
10
  /**
12
11
  * Module exports.
13
12
  */
14
13
  module.exports = {
15
- getCharset,
16
14
  normalizeOptions,
17
15
  passthrough
18
16
  }
19
17
 
20
- /**
21
- * Get the charset of a request.
22
- *
23
- * @param {Object} req
24
- * @returns {string | undefined}
25
- * @private
26
- */
27
- function getCharset (req) {
28
- const header = req.headers['content-type']
29
- if (!header) return undefined
30
- return contentType.parse(header).parameters.charset?.toLowerCase()
31
- }
32
-
33
18
  /**
34
19
  * Get the simple type checker.
35
20
  *
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "body-parser",
3
3
  "description": "Node.js body parsing middleware",
4
- "version": "2.3.0",
4
+ "version": "2.4.0",
5
5
  "contributors": [
6
6
  "Douglas Christopher Wilson <doug@somethingdoug.com>",
7
7
  "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
@@ -27,26 +27,21 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "bytes": "^3.1.2",
30
- "content-type": "^2.0.0",
30
+ "content-type": "^2.1.0",
31
31
  "debug": "^4.4.3",
32
32
  "http-errors": "^2.0.1",
33
- "iconv-lite": "^0.7.2",
33
+ "iconv-lite": "^0.7.3",
34
34
  "on-finished": "^2.4.1",
35
- "qs": "^6.15.2",
35
+ "qs": "^6.16.1",
36
36
  "raw-body": "^3.0.2",
37
37
  "type-is": "^2.1.0"
38
38
  },
39
39
  "devDependencies": {
40
- "eslint": "^8.57.1",
41
- "eslint-config-standard": "^14.1.1",
42
- "eslint-plugin-import": "^2.32.0",
43
- "eslint-plugin-markdown": "^3.0.1",
44
- "eslint-plugin-node": "^11.1.0",
45
- "eslint-plugin-promise": "^6.6.0",
46
- "eslint-plugin-standard": "^4.1.0",
40
+ "eslint": "^9.39.5",
47
41
  "mocha": "^11.7.6",
42
+ "neostandard": "^0.13.0",
48
43
  "nyc": "^17.1.0",
49
- "supertest": "^7.2.2"
44
+ "supertest": "7.3.0"
50
45
  },
51
46
  "files": [
52
47
  "lib/",
@@ -1,5 +1,10 @@
1
1
  # Encode URL
2
2
 
3
+ [![NPM Version][npm-image]][npm-url]
4
+ [![NPM Downloads][downloads-image]][downloads-url]
5
+ [![Build Status][ci-image]][ci-url]
6
+ [![Test Coverage][coveralls-image]][coveralls-url]
7
+
3
8
  Encode a URL to a percent-encoded form, excluding already-encoded sequences.
4
9
 
5
10
  ## Installation
@@ -107,3 +112,12 @@ $ npm run lint
107
112
  ## License
108
113
 
109
114
  [MIT](LICENSE)
115
+
116
+ [npm-image]: https://img.shields.io/npm/v/encodeurl
117
+ [npm-url]: https://npmjs.org/package/encodeurl
118
+ [downloads-image]: https://img.shields.io/npm/dm/encodeurl
119
+ [downloads-url]: https://npmcharts.com/compare/encodeurl?minimal=true
120
+ [ci-image]: https://img.shields.io/github/actions/workflow/status/pillarjs/encodeurl/ci.yml?branch=master
121
+ [ci-url]: https://github.com/pillarjs/encodeurl/actions/workflows/ci.yml
122
+ [coveralls-image]: https://img.shields.io/coverallsCoverage/github/pillarjs/encodeurl?branch=master
123
+ [coveralls-url]: https://coveralls.io/r/pillarjs/encodeurl?branch=master
@@ -16,24 +16,20 @@ module.exports = encodeUrl
16
16
  /**
17
17
  * RegExp to match non-URL code points, *after* encoding (i.e. not including "%")
18
18
  * and including invalid escape sequences.
19
+ * Group up to 1024 character and percent runs per replacement to reduce calls
20
+ * to encodeURI while bounding RegExp stack use. Character runs stay intact so
21
+ * surrogate pairs are never split between replacements.
19
22
  * @private
20
23
  */
21
24
 
22
- var ENCODE_CHARS_REGEXP = /(?:[^\x21\x23-\x3B\x3D\x3F-\x5F\x61-\x7A\x7C\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g
25
+ var ENCODE_CHARS_REGEXP = /(?:[^\x21\x23-\x3B\x3D\x3F-\x5F\x61-\x7A\x7C\x7E]+|%+(?![0-9A-Fa-f]{2})){1,1024}/g
23
26
 
24
27
  /**
25
- * RegExp to match unmatched surrogate pair.
28
+ * RegExp to match surrogate pairs and unpaired surrogates.
26
29
  * @private
27
30
  */
28
31
 
29
- var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g
30
-
31
- /**
32
- * String to replace unmatched surrogate pair with.
33
- * @private
34
- */
35
-
36
- var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2'
32
+ var SURROGATE_REGEXP = /([\uD800-\uDBFF][\uDC00-\uDFFF])|[\uD800-\uDFFF]/g
37
33
 
38
34
  /**
39
35
  * Encode a URL to a percent-encoded form, excluding already-encoded sequences.
@@ -55,6 +51,8 @@ var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2'
55
51
 
56
52
  function encodeUrl (url) {
57
53
  return String(url)
58
- .replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE)
54
+ .replace(SURROGATE_REGEXP, function (_, pair) {
55
+ return pair || '\uFFFD'
56
+ })
59
57
  .replace(ENCODE_CHARS_REGEXP, encodeURI)
60
58
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "encodeurl",
3
3
  "description": "Encode a URL to a percent-encoded form, excluding already-encoded sequences",
4
- "version": "2.0.0",
4
+ "version": "2.0.3",
5
5
  "contributors": [
6
6
  "Douglas Christopher Wilson <doug@somethingdoug.com>"
7
7
  ],
@@ -12,6 +12,13 @@
12
12
  "url"
13
13
  ],
14
14
  "repository": "pillarjs/encodeurl",
15
+ "publishConfig": {
16
+ "tag": "latest-2.x"
17
+ },
18
+ "funding": {
19
+ "type": "opencollective",
20
+ "url": "https://opencollective.com/express"
21
+ },
15
22
  "devDependencies": {
16
23
  "eslint": "5.11.1",
17
24
  "eslint-config-standard": "12.0.0",
@@ -19,8 +26,8 @@
19
26
  "eslint-plugin-node": "7.0.1",
20
27
  "eslint-plugin-promise": "4.0.1",
21
28
  "eslint-plugin-standard": "4.0.0",
22
- "istanbul": "0.4.5",
23
- "mocha": "2.5.3"
29
+ "mocha": "~11.7.0",
30
+ "nyc": "~17.1.0"
24
31
  },
25
32
  "files": [
26
33
  "LICENSE",
@@ -33,8 +40,8 @@
33
40
  },
34
41
  "scripts": {
35
42
  "lint": "eslint .",
36
- "test": "mocha --reporter spec --bail --check-leaks test/",
37
- "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
38
- "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
43
+ "test": "mocha --check-leaks --reporter spec",
44
+ "test-ci": "nyc --reporter=lcov --reporter=text npm test",
45
+ "test-cov": "nyc --reporter=html --reporter=text npm test"
39
46
  }
40
47
  }
@@ -70,7 +70,7 @@ The `jose` module supports importing, exporting, and generating keys and secrets
70
70
 
71
71
  ### JSON Web Signature (JWS)
72
72
 
73
- The `jose` module supports signing and verification of JWS messages with arbitrary payloads in Compact, Flattened JSON, and General JSON serialization syntaxes.
73
+ The `jose` module supports digital signature and MAC computation and validation over arbitrary JWS Payloads using the JWS Compact Serialization and the flattened and general JWS JSON Serialization syntaxes ([RFC 7515, Section 7](https://www.rfc-editor.org/info/rfc7515/#section-7)).
74
74
 
75
75
  - Signing - [Compact](docs/jws/compact/sign/classes/CompactSign.md), [Flattened JSON](docs/jws/flattened/sign/classes/FlattenedSign.md), [General JSON](docs/jws/general/sign/classes/GeneralSign.md)
76
76
  - Verification - [Compact](docs/jws/compact/verify/functions/compactVerify.md), [Flattened JSON](docs/jws/flattened/verify/functions/flattenedVerify.md), [General JSON](docs/jws/general/verify/functions/generalVerify.md)
@@ -81,7 +81,7 @@ The `jose` module supports signing and verification of JWS messages with arbitra
81
81
 
82
82
  ### JSON Web Encryption (JWE)
83
83
 
84
- The `jose` module supports encryption and decryption of JWE messages with arbitrary plaintext in Compact, Flattened JSON, and General JSON serialization syntaxes.
84
+ The `jose` module supports encryption and authenticated decryption of arbitrary plaintext using the JWE Compact Serialization and the flattened and general JWE JSON Serialization syntaxes ([RFC 7516, Section 7](https://www.rfc-editor.org/info/rfc7516/#section-7)).
85
85
 
86
86
  - Encryption - [Compact](docs/jwe/compact/encrypt/classes/CompactEncrypt.md), [Flattened JSON](docs/jwe/flattened/encrypt/classes/FlattenedEncrypt.md), [General JSON](docs/jwe/general/encrypt/classes/GeneralEncrypt.md)
87
87
  - Decryption - [Compact](docs/jwe/compact/decrypt/functions/compactDecrypt.md), [Flattened JSON](docs/jwe/flattened/decrypt/functions/flattenedDecrypt.md), [General JSON](docs/jwe/general/decrypt/functions/generalDecrypt.md)
@@ -3,21 +3,22 @@ import type * as t from '../../types.d.ts';
3
3
  export interface CompactDecryptGetKey<KeyType extends t.CryptoKey | Uint8Array = t.CryptoKey | Uint8Array> extends t.GetKeyFunction<t.CompactJWEHeaderParameters, t.FlattenedJWE, KeyType | t.KeyObject | t.JWK> {
4
4
  }
5
5
  /**
6
- * Decrypts a Compact JWE.
6
+ * Authenticates and decrypts a JWE Compact Serialization.
7
7
  *
8
8
  * @param key Private key or shared secret. See
9
9
  * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
10
10
  */
11
11
  export declare function compactDecrypt(jwe: string | Uint8Array, key: t.KeyInput, options?: t.DecryptOptions): Promise<t.CompactDecryptResult>;
12
12
  /**
13
- * Decrypts a Compact JWE with a dynamically resolved key, included in the result.
13
+ * Authenticates and decrypts a JWE Compact Serialization with a dynamically resolved key, included
14
+ * in the result.
14
15
  *
15
16
  * @param getKey Resolves a private key or shared secret from unverified token data.
16
17
  */
17
18
  export declare function compactDecrypt<KeyType extends t.CryptoKey | Uint8Array = t.CryptoKey | Uint8Array>(jwe: string | Uint8Array, getKey: CompactDecryptGetKey<KeyType>, options?: t.DecryptOptions): Promise<t.CompactDecryptResult & t.ResolvedKey<KeyType>>;
18
19
  /**
19
- * Decrypts a Compact JWE with a key or key resolver. The result includes `key` only when a resolver
20
- * is used.
20
+ * Authenticates and decrypts a JWE Compact Serialization with a key or key resolver. The result
21
+ * includes `key` only when a resolver is used.
21
22
  *
22
23
  * @param key Private key or shared secret, or a function resolving one.
23
24
  */
@@ -1,9 +1,9 @@
1
1
  import type * as t from '../../types.d.ts';
2
- /** Builds and encrypts Compact JWE strings. */
2
+ /** Produces JWE Compact Serialization using authenticated encryption. */
3
3
  export declare class CompactEncrypt {
4
4
  #private;
5
5
  /**
6
- * Creates a Compact JWE encryptor.
6
+ * Creates an encryptor for JWE Compact Serialization.
7
7
  *
8
8
  * @param plaintext Binary representation of the plaintext to encrypt.
9
9
  */
@@ -26,12 +26,12 @@ export declare class CompactEncrypt {
26
26
  setProtectedHeader(protectedHeader: t.CompactJWEHeaderParameters): this;
27
27
  /**
28
28
  * Sets key management inputs such as ECDH-ES "apu"/"apv" or PBES2 "p2c". Use this method instead
29
- * of header setters; the resulting parameters are added to the JOSE header. May only be called
29
+ * of header setters; the resulting parameters are added to the JOSE Header. May only be called
30
30
  * once.
31
31
  */
32
32
  setKeyManagementParameters(parameters: t.JWEKeyManagementHeaderParameters): this;
33
33
  /**
34
- * Encrypts the plaintext as a Compact JWE.
34
+ * Encrypts the plaintext and returns the JWE Compact Serialization.
35
35
  *
36
36
  * @param key Public key or shared secret. See
37
37
  * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
@@ -3,21 +3,22 @@ import type * as t from '../../types.d.ts';
3
3
  export interface FlattenedDecryptGetKey<KeyType extends t.CryptoKey | Uint8Array = t.CryptoKey | Uint8Array> extends t.GetKeyFunction<t.JWEHeaderParameters | undefined, t.FlattenedJWE, KeyType | t.KeyObject | t.JWK> {
4
4
  }
5
5
  /**
6
- * Decrypts a Flattened JWE.
6
+ * Authenticates and decrypts a flattened JWE JSON Serialization.
7
7
  *
8
8
  * @param key Private key or shared secret. See
9
9
  * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
10
10
  */
11
11
  export declare function flattenedDecrypt(jwe: t.FlattenedJWE, key: t.KeyInput, options?: t.DecryptOptions): Promise<t.FlattenedDecryptResult>;
12
12
  /**
13
- * Decrypts a Flattened JWE with a dynamically resolved key, included in the result.
13
+ * Authenticates and decrypts a flattened JWE JSON Serialization with a dynamically resolved key,
14
+ * included in the result.
14
15
  *
15
16
  * @param getKey Resolves a private key or shared secret from unverified token data.
16
17
  */
17
18
  export declare function flattenedDecrypt<KeyType extends t.CryptoKey | Uint8Array = t.CryptoKey | Uint8Array>(jwe: t.FlattenedJWE, getKey: FlattenedDecryptGetKey<KeyType>, options?: t.DecryptOptions): Promise<t.FlattenedDecryptResult & t.ResolvedKey<KeyType>>;
18
19
  /**
19
- * Decrypts a Flattened JWE with a key or key resolver. The result includes `key` only when a
20
- * resolver is used.
20
+ * Authenticates and decrypts a flattened JWE JSON Serialization with a key or key resolver. The
21
+ * result includes `key` only when a resolver is used.
21
22
  *
22
23
  * @param key Private key or shared secret, or a function resolving one.
23
24
  */
@@ -1,16 +1,16 @@
1
1
  import type * as t from '../../types.d.ts';
2
- /** Builds and encrypts Flattened JWE objects. */
2
+ /** Produces flattened JWE JSON Serialization using authenticated encryption. */
3
3
  export declare class FlattenedEncrypt {
4
4
  #private;
5
5
  /**
6
- * Creates a Flattened JWE encryptor.
6
+ * Creates an encryptor for flattened JWE JSON Serialization.
7
7
  *
8
8
  * @param plaintext Binary representation of the plaintext to encrypt.
9
9
  */
10
10
  constructor(plaintext: Uint8Array);
11
11
  /**
12
12
  * Sets key management inputs such as ECDH-ES "apu"/"apv" or PBES2 "p2c". Use this method instead
13
- * of header setters; the resulting parameters are added to the JOSE header. May only be called
13
+ * of header setters; the resulting parameters are added to the JOSE Header. May only be called
14
14
  * once.
15
15
  */
16
16
  setKeyManagementParameters(parameters: t.JWEKeyManagementHeaderParameters): this;
@@ -20,7 +20,7 @@ export declare class FlattenedEncrypt {
20
20
  setSharedUnprotectedHeader(sharedUnprotectedHeader: t.JWEHeaderParameters): this;
21
21
  /** Sets the JWE Per-Recipient Unprotected Header. May only be called once. */
22
22
  setUnprotectedHeader(unprotectedHeader: t.JWEHeaderParameters): this;
23
- /** Sets additional data to authenticate without encrypting it. */
23
+ /** Sets the JWE AAD, which is integrity protected but not encrypted. */
24
24
  setAdditionalAuthenticatedData(aad: Uint8Array): this;
25
25
  /**
26
26
  * Sets a content encryption key instead of generating a random one for the JWE "enc" algorithm.
@@ -37,7 +37,7 @@ export declare class FlattenedEncrypt {
37
37
  */
38
38
  setInitializationVector(iv: Uint8Array): this;
39
39
  /**
40
- * Encrypts the plaintext as a Flattened JWE.
40
+ * Encrypts the plaintext and returns the flattened JWE JSON Serialization.
41
41
  *
42
42
  * @param key Public key or shared secret. See
43
43
  * {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
@@ -3,7 +3,7 @@ import type * as t from '../../types.d.ts';
3
3
  export interface GeneralDecryptGetKey<KeyType extends t.CryptoKey | Uint8Array = t.CryptoKey | Uint8Array> extends t.GetKeyFunction<t.JWEHeaderParameters | undefined, t.FlattenedJWE, KeyType | t.KeyObject | t.JWK> {
4
4
  }
5
5
  /**
6
- * Decrypts a General JWE.
6
+ * Authenticates and decrypts a general JWE JSON Serialization.
7
7
  *
8
8
  * > Note: Returns plaintext and headers from the first recipient that decrypts successfully. Other
9
9
  * > recipients may be inspected to enforce serialization rules, but their headers are not included in
@@ -14,14 +14,15 @@ export interface GeneralDecryptGetKey<KeyType extends t.CryptoKey | Uint8Array =
14
14
  */
15
15
  export declare function generalDecrypt(jwe: t.GeneralJWE, key: t.KeyInput, options?: t.DecryptOptions): Promise<t.GeneralDecryptResult>;
16
16
  /**
17
- * Decrypts a General JWE with a dynamically resolved key, included in the result.
17
+ * Authenticates and decrypts a general JWE JSON Serialization with a dynamically resolved key,
18
+ * included in the result.
18
19
  *
19
20
  * @param getKey Resolves a private key or shared secret from unverified token data.
20
21
  */
21
22
  export declare function generalDecrypt<KeyType extends t.CryptoKey | Uint8Array = t.CryptoKey | Uint8Array>(jwe: t.GeneralJWE, getKey: GeneralDecryptGetKey<KeyType>, options?: t.DecryptOptions): Promise<t.GeneralDecryptResult & t.ResolvedKey<KeyType>>;
22
23
  /**
23
- * Decrypts a General JWE with a key or key resolver. The result includes `key` only when a resolver
24
- * is used.
24
+ * Authenticates and decrypts a general JWE JSON Serialization with a key or key resolver. The
25
+ * result includes `key` only when a resolver is used.
25
26
  *
26
27
  * @param key Private key or shared secret, or a function resolving one.
27
28
  */
@@ -5,7 +5,7 @@ export interface Recipient {
5
5
  setUnprotectedHeader(unprotectedHeader: t.JWEHeaderParameters): Recipient;
6
6
  /**
7
7
  * Sets key management inputs such as ECDH-ES "apu"/"apv" or PBES2 "p2c". Use this method instead
8
- * of header setters; the resulting parameters are added to the JOSE header. May only be called
8
+ * of header setters; the resulting parameters are added to the JOSE Header. May only be called
9
9
  * once.
10
10
  */
11
11
  setKeyManagementParameters(parameters: t.JWEKeyManagementHeaderParameters): Recipient;
@@ -24,11 +24,11 @@ export interface Recipient {
24
24
  /** Returns the enclosing {@link GeneralEncrypt} instance. */
25
25
  done(): GeneralEncrypt;
26
26
  }
27
- /** Builds and encrypts General JWE objects. */
27
+ /** Produces general JWE JSON Serialization using authenticated encryption. */
28
28
  export declare class GeneralEncrypt {
29
29
  #private;
30
30
  /**
31
- * Creates a General JWE encryptor.
31
+ * Creates an encryptor for general JWE JSON Serialization.
32
32
  *
33
33
  * @param plaintext Binary representation of the plaintext to encrypt.
34
34
  */
@@ -44,8 +44,8 @@ export declare class GeneralEncrypt {
44
44
  setProtectedHeader(protectedHeader: t.JWEHeaderParameters): this;
45
45
  /** Sets the JWE Shared Unprotected Header. May only be called once. */
46
46
  setSharedUnprotectedHeader(sharedUnprotectedHeader: t.JWEHeaderParameters): this;
47
- /** Sets additional data to authenticate without encrypting it. */
47
+ /** Sets the JWE AAD, which is integrity protected but not encrypted. */
48
48
  setAdditionalAuthenticatedData(aad: Uint8Array): this;
49
- /** Encrypts the plaintext as a General JWE. */
49
+ /** Encrypts the plaintext and returns the general JWE JSON Serialization. */
50
50
  encrypt(): Promise<t.GeneralJWE>;
51
51
  }