@ashlr/hub 3.2.7 → 3.3.2

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 (192) hide show
  1. package/CHANGELOG.md +314 -2
  2. package/README.md +54 -38
  3. package/dist/build-identity.json +2 -2
  4. package/dist/cli/audit.js +18 -0
  5. package/dist/cli/audit.js.map +1 -1
  6. package/dist/cli/backlog.d.ts +0 -5
  7. package/dist/cli/backlog.js +18 -0
  8. package/dist/cli/backlog.js.map +1 -1
  9. package/dist/cli/comms.js +20 -0
  10. package/dist/cli/comms.js.map +1 -1
  11. package/dist/cli/completions.d.ts +6 -1
  12. package/dist/cli/completions.js +33 -10
  13. package/dist/cli/completions.js.map +1 -1
  14. package/dist/cli/daemon.js +10 -3
  15. package/dist/cli/daemon.js.map +1 -1
  16. package/dist/cli/dashboard.js +5 -4
  17. package/dist/cli/dashboard.js.map +1 -1
  18. package/dist/cli/demo.d.ts +0 -27
  19. package/dist/cli/demo.js +17 -0
  20. package/dist/cli/demo.js.map +1 -1
  21. package/dist/cli/help.js +22 -9
  22. package/dist/cli/help.js.map +1 -1
  23. package/dist/cli/inbox.d.ts +14 -2
  24. package/dist/cli/inbox.js +137 -23
  25. package/dist/cli/inbox.js.map +1 -1
  26. package/dist/cli/onboard.d.ts +0 -13
  27. package/dist/cli/onboard.js +20 -0
  28. package/dist/cli/onboard.js.map +1 -1
  29. package/dist/cli/resources.js +15 -0
  30. package/dist/cli/resources.js.map +1 -1
  31. package/dist/cli/run.js +1 -1
  32. package/dist/cli/run.js.map +1 -1
  33. package/dist/cli/sandbox.js +43 -0
  34. package/dist/cli/sandbox.js.map +1 -1
  35. package/dist/cli/serve.js +7 -3
  36. package/dist/cli/serve.js.map +1 -1
  37. package/dist/cli/setup.d.ts +5 -3
  38. package/dist/cli/setup.js +14 -7
  39. package/dist/cli/setup.js.map +1 -1
  40. package/dist/cli/tui.d.ts +0 -6
  41. package/dist/cli/tui.js +14 -0
  42. package/dist/cli/tui.js.map +1 -1
  43. package/dist/cli/update.js +3 -1
  44. package/dist/cli/update.js.map +1 -1
  45. package/dist/core/config.js +70 -0
  46. package/dist/core/config.js.map +1 -1
  47. package/dist/core/daemon/loop.js +83 -3
  48. package/dist/core/daemon/loop.js.map +1 -1
  49. package/dist/core/daemon/runtime-activation-resident-start-protocol.d.ts +141 -0
  50. package/dist/core/daemon/runtime-activation-resident-start-protocol.js +462 -0
  51. package/dist/core/daemon/runtime-activation-resident-start-protocol.js.map +1 -0
  52. package/dist/core/daemon/runtime-activation-resident-start-runtime.d.ts +27 -0
  53. package/dist/core/daemon/runtime-activation-resident-start-runtime.js +28 -0
  54. package/dist/core/daemon/runtime-activation-resident-start-runtime.js.map +1 -0
  55. package/dist/core/daemon/runtime-activation-stopped-consumer.d.ts +139 -0
  56. package/dist/core/daemon/runtime-activation-stopped-consumer.js +995 -0
  57. package/dist/core/daemon/runtime-activation-stopped-consumer.js.map +1 -0
  58. package/dist/core/daemon/runtime-activation-stopped-runtime.d.ts +36 -0
  59. package/dist/core/daemon/runtime-activation-stopped-runtime.js +134 -0
  60. package/dist/core/daemon/runtime-activation-stopped-runtime.js.map +1 -0
  61. package/dist/core/daemon/runtime-activation-transaction.d.ts +41 -17
  62. package/dist/core/daemon/runtime-activation-transaction.js +80 -11
  63. package/dist/core/daemon/runtime-activation-transaction.js.map +1 -1
  64. package/dist/core/daemon/runtime-release-dependency-inventory.js +1 -0
  65. package/dist/core/daemon/runtime-release-dependency-inventory.js.map +1 -1
  66. package/dist/core/daemon/service-install-authority.d.ts +1 -1
  67. package/dist/core/daemon/service-install-authority.js +4 -2
  68. package/dist/core/daemon/service-install-authority.js.map +1 -1
  69. package/dist/core/dashboard.d.ts +10 -0
  70. package/dist/core/dashboard.js +103 -28
  71. package/dist/core/dashboard.js.map +1 -1
  72. package/dist/core/effective-config.js +7 -0
  73. package/dist/core/effective-config.js.map +1 -1
  74. package/dist/core/fleet/automerge-pass.js +57 -73
  75. package/dist/core/fleet/automerge-pass.js.map +1 -1
  76. package/dist/core/fleet/decisions-ledger.js +36 -13
  77. package/dist/core/fleet/decisions-ledger.js.map +1 -1
  78. package/dist/core/fleet/external-skill-git-capture.js +9 -1
  79. package/dist/core/fleet/external-skill-git-capture.js.map +1 -1
  80. package/dist/core/fleet/judge-decision-metadata.d.ts +8 -1
  81. package/dist/core/fleet/judge-decision-metadata.js +14 -1
  82. package/dist/core/fleet/judge-decision-metadata.js.map +1 -1
  83. package/dist/core/fleet/judge-trace.js +2 -1
  84. package/dist/core/fleet/judge-trace.js.map +1 -1
  85. package/dist/core/fleet/manager.d.ts +21 -1
  86. package/dist/core/fleet/manager.js +137 -41
  87. package/dist/core/fleet/manager.js.map +1 -1
  88. package/dist/core/fleet/post-merge-credit-label.d.ts +10 -0
  89. package/dist/core/fleet/post-merge-credit-label.js +13 -0
  90. package/dist/core/fleet/post-merge-credit-label.js.map +1 -0
  91. package/dist/core/fleet/post-merge-credit.d.ts +119 -12
  92. package/dist/core/fleet/post-merge-credit.js +353 -14
  93. package/dist/core/fleet/post-merge-credit.js.map +1 -1
  94. package/dist/core/fleet/self-improve.d.ts +38 -5
  95. package/dist/core/fleet/self-improve.js +201 -12
  96. package/dist/core/fleet/self-improve.js.map +1 -1
  97. package/dist/core/fleet/skill-library.d.ts +21 -2
  98. package/dist/core/fleet/skill-library.js +54 -12
  99. package/dist/core/fleet/skill-library.js.map +1 -1
  100. package/dist/core/fleet/worked-ledger.d.ts +22 -0
  101. package/dist/core/fleet/worked-ledger.js +32 -0
  102. package/dist/core/fleet/worked-ledger.js.map +1 -1
  103. package/dist/core/goals/store.js +60 -6
  104. package/dist/core/goals/store.js.map +1 -1
  105. package/dist/core/inbox/apply.js +2 -1
  106. package/dist/core/inbox/apply.js.map +1 -1
  107. package/dist/core/inbox/merge.d.ts +10 -1
  108. package/dist/core/inbox/merge.js +97 -18
  109. package/dist/core/inbox/merge.js.map +1 -1
  110. package/dist/core/integrations/github.d.ts +2 -0
  111. package/dist/core/integrations/github.js +2 -1
  112. package/dist/core/integrations/github.js.map +1 -1
  113. package/dist/core/learn/reflect.d.ts +42 -4
  114. package/dist/core/learn/reflect.js +66 -5
  115. package/dist/core/learn/reflect.js.map +1 -1
  116. package/dist/core/onboard.d.ts +2 -0
  117. package/dist/core/onboard.js +9 -3
  118. package/dist/core/onboard.js.map +1 -1
  119. package/dist/core/run/engines.d.ts +8 -0
  120. package/dist/core/run/engines.js +9 -1
  121. package/dist/core/run/engines.js.map +1 -1
  122. package/dist/core/run/learned-router.js +28 -3
  123. package/dist/core/run/learned-router.js.map +1 -1
  124. package/dist/core/run/orchestrator.d.ts +7 -2
  125. package/dist/core/run/orchestrator.js +88 -60
  126. package/dist/core/run/orchestrator.js.map +1 -1
  127. package/dist/core/swarm/rollback.d.ts +11 -0
  128. package/dist/core/swarm/rollback.js +54 -0
  129. package/dist/core/swarm/rollback.js.map +1 -1
  130. package/dist/core/swarm/runner.js +94 -8
  131. package/dist/core/swarm/runner.js.map +1 -1
  132. package/dist/core/types.d.ts +103 -3
  133. package/dist/core/types.js.map +1 -1
  134. package/dist/core/web/api.d.ts +6 -0
  135. package/dist/core/web/api.js +174 -18
  136. package/dist/core/web/api.js.map +1 -1
  137. package/dist/core/web/control.d.ts +20 -0
  138. package/dist/core/web/control.js +44 -32
  139. package/dist/core/web/control.js.map +1 -1
  140. package/dist/core/web/fleet-status-cache.d.ts +68 -0
  141. package/dist/core/web/fleet-status-cache.js +120 -0
  142. package/dist/core/web/fleet-status-cache.js.map +1 -0
  143. package/dist/core/web/public/app.js +5 -1
  144. package/dist/core/web/public/next/assets/index-CDHQraxS.css +1 -0
  145. package/dist/core/web/public/next/assets/index-zVKD9krw.js +69 -0
  146. package/dist/core/web/public/next/assets/index-zVKD9krw.js.map +1 -0
  147. package/dist/core/web/public/next/index.html +15 -0
  148. package/dist/core/web/read-session-revocations.d.ts +26 -0
  149. package/dist/core/web/read-session-revocations.js +48 -0
  150. package/dist/core/web/read-session-revocations.js.map +1 -0
  151. package/dist/core/web/server.js +73 -27
  152. package/dist/core/web/server.js.map +1 -1
  153. package/dist/core/web/static.d.ts +1 -1
  154. package/dist/core/web/static.js +54 -20
  155. package/dist/core/web/static.js.map +1 -1
  156. package/dist/release-dependency-inventory.json +1 -1
  157. package/docs/RUNTIME_ACTIVATION_AUTHORITY.md +115 -21
  158. package/docs/contracts/CONTRACT-M521.md +102 -0
  159. package/node_modules/fast-uri/index.js +201 -48
  160. package/node_modules/fast-uri/lib/schemes.js +9 -4
  161. package/node_modules/fast-uri/lib/utils.js +388 -91
  162. package/node_modules/fast-uri/package.json +1 -1
  163. package/node_modules/fast-uri/test/component-safe-serialization.test.js +105 -0
  164. package/node_modules/fast-uri/test/equal.test.js +31 -3
  165. package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +2 -0
  166. package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
  167. package/node_modules/fast-uri/test/ipv6-validation.test.js +90 -0
  168. package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
  169. package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
  170. package/node_modules/fast-uri/test/parse.test.js +7 -3
  171. package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
  172. package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
  173. package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
  174. package/node_modules/fast-uri/test/security-normalization.test.js +101 -0
  175. package/node_modules/fast-uri/test/security.test.js +75 -3
  176. package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
  177. package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
  178. package/node_modules/qs/.github/THREAT_MODEL.md +3 -3
  179. package/node_modules/qs/CHANGELOG.md +26 -0
  180. package/node_modules/qs/README.md +19 -1
  181. package/node_modules/qs/dist/qs.js +25 -25
  182. package/node_modules/qs/eslint.config.mjs +1 -1
  183. package/node_modules/qs/lib/parse.js +16 -6
  184. package/node_modules/qs/lib/stringify.js +23 -8
  185. package/node_modules/qs/lib/utils.js +57 -11
  186. package/node_modules/qs/package.json +8 -7
  187. package/node_modules/qs/test/parse.js +419 -0
  188. package/node_modules/qs/test/stringify.js +317 -0
  189. package/node_modules/qs/test/utils.js +206 -0
  190. package/package.json +24 -6
  191. package/schema/config.schema.json +800 -5
  192. package/node_modules/which/CHANGELOG.md +0 -166
@@ -14,6 +14,12 @@ var hasProto = require('has-proto')();
14
14
  var qs = require('../');
15
15
  var utils = require('../lib/utils');
16
16
 
17
+ var characterizeParse = function characterizeParse(st, input, opts, expected, label) {
18
+ var result;
19
+ st.doesNotThrow(function () { result = qs.parse(input, opts); }, label + ': does not throw');
20
+ st.deepEqual(result, expected, label + ': parses to the current lenient output');
21
+ };
22
+
17
23
  test('parse()', function (t) {
18
24
  t.test('parses a simple string', function (st) {
19
25
  st.deepEqual(qs.parse('0=foo'), { 0: 'foo' });
@@ -312,6 +318,48 @@ test('parse()', function (t) {
312
318
  st.end();
313
319
  });
314
320
 
321
+ t.test('currently parses unbalanced bracket keys after a parent leniently to literal segments (issue #558)', function (st) {
322
+ characterizeParse(st, 'a[bc=v', undefined, { a: { '[bc': 'v' } }, 'unclosed group after a parent');
323
+ characterizeParse(st, 'a[=v', undefined, { a: { '[': 'v' } }, 'bare unclosed bracket after a parent');
324
+ characterizeParse(st, 'a[b][c=v', undefined, { a: { b: { '[c': 'v' } } }, 'unclosed group after a valid one');
325
+ characterizeParse(st, 'a[b]c[d=v', undefined, { a: { b: { '[d': 'v' } } }, 'unclosed group after text following a valid one');
326
+ characterizeParse(st, 'filters[customtags:Env: Prod=v', undefined, { filters: { '[customtags:Env: Prod': 'v' } }, 'the issue #558 reproduction');
327
+ characterizeParse(st, '][a=v', undefined, { ']': { '[a': 'v' } }, 'stray close bracket before an unclosed group');
328
+ characterizeParse(st, 'a][b=v', undefined, { 'a]': { '[b': 'v' } }, 'stray close bracket inside the parent');
329
+ st.end();
330
+ });
331
+
332
+ t.test('currently parses unbalanced bracket keys containing inner brackets leniently (issue #558)', function (st) {
333
+ characterizeParse(st, 'a[b[c=v', undefined, { a: { '[b[c': 'v' } }, 'unclosed group containing an inner bracket');
334
+ characterizeParse(st, 'a[b[c]=v', undefined, { a: { '[b[c]': 'v' } }, 'unbalanced group with an inner bracket and one close');
335
+ characterizeParse(st, 'a[b][c[d=v', undefined, { a: { b: { '[c[d': 'v' } } }, 'unclosed inner-bracket group after a valid one');
336
+ st.end();
337
+ });
338
+
339
+ t.test('currently parses bracket-prefixed unbalanced keys leniently (issue #558)', function (st) {
340
+ characterizeParse(st, '[abc=v', undefined, { '[abc': 'v' }, 'key starting with an unclosed bracket');
341
+ characterizeParse(st, '[[]b=v', undefined, { '[[]b': 'v' }, 'key starting with an unbalanced bracket group');
342
+ st.end();
343
+ });
344
+
345
+ t.test('lenient unbalanced-bracket handling currently depends on the depth option (issue #558)', function (st) {
346
+ characterizeParse(st, 'a[b]c[d]e[f=v', { depth: 5 }, { a: { b: { d: { '[f': 'v' } } } }, 'consumes groups up to the depth budget then keeps the unclosed remainder literal');
347
+ characterizeParse(st, 'a[b]c[d]e[f=v', { depth: 1 }, { a: { b: { '[d]e[f': 'v' } } }, 'a lower depth keeps more of the unclosed remainder literal');
348
+ characterizeParse(st, 'a[bc=v', { depth: 0 }, { 'a[bc': 'v' }, 'depth 0 keeps the entire key literal');
349
+ st.end();
350
+ });
351
+
352
+ t.test('currently parses an allowDots key with a trailing unclosed bracket leniently (issue #558)', function (st) {
353
+ characterizeParse(st, 'a.b[c=v', { allowDots: true }, { a: { b: { '[c': 'v' } } }, 'allowDots expands the dot then keeps the unclosed bracket literal');
354
+ st.end();
355
+ });
356
+
357
+ t.test('valid and stray-close bracket keys are unaffected by unbalanced-bracket handling', function (st) {
358
+ characterizeParse(st, 'a]b=v', undefined, { 'a]b': 'v' }, 'stray close bracket with no open bracket stays a flat key');
359
+ characterizeParse(st, 'a[b]extra=v', undefined, { a: { b: 'v' } }, 'text after a balanced group is ignored');
360
+ st.end();
361
+ });
362
+
315
363
  t.test('allows to specify array indices', function (st) {
316
364
  st.deepEqual(qs.parse('a[1]=c&a[0]=b&a[2]=d'), { a: ['b', 'c', 'd'] });
317
365
  st.deepEqual(qs.parse('a[1]=c&a[0]=b'), { a: ['b', 'c'] });
@@ -726,6 +774,21 @@ test('parse()', function (t) {
726
774
  st.end();
727
775
  });
728
776
 
777
+ t.test('does not crash on multi-step circular references', function (st) {
778
+ var a = {};
779
+ a.b = { c: { d: a } };
780
+
781
+ var parsed;
782
+
783
+ st.doesNotThrow(function () {
784
+ parsed = qs.parse({ foo: a });
785
+ });
786
+
787
+ st.equal('foo' in parsed, true, 'parsed has "foo" property');
788
+ st.equal(parsed.foo.b.c.d, parsed.foo, 'the multi-step cycle is preserved');
789
+ st.end();
790
+ });
791
+
729
792
  t.test('does not crash when parsing deep objects', function (st) {
730
793
  var parsed;
731
794
  var str = 'foo';
@@ -959,6 +1022,22 @@ test('parse()', function (t) {
959
1022
  st.end();
960
1023
  });
961
1024
 
1025
+ t.test('object-valued input with own `__proto__` does not mutate sub-object [[Prototype]]', function (st) {
1026
+ // JSON.parse creates own data `__proto__` properties (via CreateDataProperty),
1027
+ // which would trigger the Object.prototype.__proto__ accessor if merged via `acc[key] = value`.
1028
+ var out = qs.parse({
1029
+ 'user[name]': 'alice',
1030
+ user: JSON.parse('{"__proto__":{"isAdmin":true}}')
1031
+ }, { allowPrototypes: false });
1032
+
1033
+ st.equal(out.user.name, 'alice', 'name from bracket key is preserved');
1034
+ st.equal(out.user.isAdmin, undefined, 'attacker-controlled inherited property is not exposed');
1035
+ st.equal(Object.getPrototypeOf(out.user), Object.prototype, 'sub-object [[Prototype]] is unchanged');
1036
+ st.equal(Object.prototype.isAdmin, undefined, 'Object.prototype is not polluted');
1037
+
1038
+ st.end();
1039
+ });
1040
+
962
1041
  t.test('can return null objects', { skip: !hasProto }, function (st) {
963
1042
  var expected = {
964
1043
  __proto__: null,
@@ -1309,6 +1388,346 @@ test('parse()', function (t) {
1309
1388
  sst.end();
1310
1389
  });
1311
1390
 
1391
+ st.test('throws when cumulative comma + duplicate-key combine exceeds arrayLimit', function (sst) {
1392
+ sst['throws'](
1393
+ function () {
1394
+ qs.parse('a=1,2,3&a=4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
1395
+ },
1396
+ new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
1397
+ 'throws when comma groups within the limit cumulatively exceed it across duplicate keys'
1398
+ );
1399
+
1400
+ sst['throws'](
1401
+ function () {
1402
+ qs.parse('a=v,v,v,v,v&a=v,v,v,v,v&a=v,v,v,v,v', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
1403
+ },
1404
+ new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
1405
+ 'throws on a subsequent part once the cumulative array is already over the limit'
1406
+ );
1407
+ sst.end();
1408
+ });
1409
+
1410
+ st.test('throws when plain duplicate keys combine past arrayLimit at the boundary', function (sst) {
1411
+ sst['throws'](
1412
+ function () { qs.parse('a=x&a=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
1413
+ new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
1414
+ 'duplicate scalar keys'
1415
+ );
1416
+
1417
+ sst['throws'](
1418
+ function () { qs.parse('a[]=x&a[]=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
1419
+ new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
1420
+ 'duplicate bracket keys'
1421
+ );
1422
+ sst.end();
1423
+ });
1424
+
1425
+ st.test('throws when mixed index and key notation merge past arrayLimit', function (sst) {
1426
+ sst['throws'](
1427
+ function () { qs.parse('a=x&a[0]=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
1428
+ new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
1429
+ 'scalar then index that overflows on merge'
1430
+ );
1431
+
1432
+ sst['throws'](
1433
+ function () { qs.parse('a[0]=1&a[1]=2&a=3', { arrayLimit: 1, throwOnLimitExceeded: true }); },
1434
+ new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
1435
+ 'indexed array then scalar that overflows on merge'
1436
+ );
1437
+ sst.end();
1438
+ });
1439
+
1440
+ st.test('enforces arrayLimit on merge at the boundary, consistently with combine', function (sst) {
1441
+ sst['throws'](
1442
+ function () { qs.parse('a[0]=x&a=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
1443
+ new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
1444
+ 'a trailing scalar merged into an at-limit array throws'
1445
+ );
1446
+ sst.deepEqual(
1447
+ qs.parse('a[0]=x&a=y', { arrayLimit: 1 }),
1448
+ { a: { 0: 'x', 1: 'y' } },
1449
+ 'and converts to an overflow object without throwOnLimitExceeded'
1450
+ );
1451
+
1452
+ sst['throws'](
1453
+ function () { qs.parse('a[0]=x&a[]=y', { arrayLimit: 1, throwOnLimitExceeded: true }); },
1454
+ new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
1455
+ 'mixed index and bracket notation merged past the limit throws'
1456
+ );
1457
+ sst.deepEqual(
1458
+ qs.parse('a[0]=x&a[]=y', { arrayLimit: 1 }),
1459
+ { a: { 0: 'x', 1: 'y' } },
1460
+ 'mixed index and bracket notation converts like duplicate-bracket combine'
1461
+ );
1462
+
1463
+ sst.end();
1464
+ });
1465
+
1466
+ st.test('does not throw when cumulative comma combine stays within arrayLimit', function (sst) {
1467
+ var result = qs.parse('a=1,2,3&a=4', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
1468
+ sst.deepEqual(result, { a: ['1', '2', '3', '4'] }, 'combined array within limit is preserved');
1469
+ sst.end();
1470
+ });
1471
+
1472
+ st.test('silently combines to an overflow object when throwOnLimitExceeded is not set', function (sst) {
1473
+ var result = qs.parse('a=1,2,3&a=4,5,6', { comma: true, arrayLimit: 5 });
1474
+ sst.deepEqual(result, { a: { 0: '1', 1: '2', 2: '3', 3: '4', 4: '5', 5: '6' } }, 'converts to object without throwing');
1475
+ sst.end();
1476
+ });
1477
+
1478
+ st.test('spreads a comma group appended to an already-overflowed object', function (sst) {
1479
+ var result = qs.parse('a=1,2,3,4,5,6&a=7,8', { comma: true, arrayLimit: 5 });
1480
+ sst.deepEqual(
1481
+ result,
1482
+ { a: { 0: '1', 1: '2', 2: '3', 3: '4', 4: '5', 5: '6', 6: '7', 7: '8' } },
1483
+ 'appended comma values are flattened, not nested'
1484
+ );
1485
+ sst.end();
1486
+ });
1487
+
1488
+ st.test('keeps a `[]=` comma group as one element when appended to an already-overflowed key', function (sst) {
1489
+ var result = qs.parse('a[]=1&a[]=2&a[]=3&a[]=4,5', { comma: true, arrayLimit: 2 });
1490
+ sst.deepEqual(
1491
+ result,
1492
+ { a: { 0: '1', 1: '2', 2: '3', 3: ['4', '5'] } },
1493
+ 'nested comma group stays a single element, not double-nested'
1494
+ );
1495
+ sst.end();
1496
+ });
1497
+
1498
+ st.test('spreads every later comma group appended to an already-overflowed object', function (sst) {
1499
+ var result = qs.parse('a=1,2,3,4,5,6&a=7,8&a=9,10', { comma: true, arrayLimit: 5 });
1500
+ sst.deepEqual(
1501
+ result,
1502
+ { a: { 0: '1', 1: '2', 2: '3', 3: '4', 4: '5', 5: '6', 6: '7', 7: '8', 8: '9', 9: '10' } },
1503
+ 'each appended group is flattened in order'
1504
+ );
1505
+ sst.end();
1506
+ });
1507
+
1508
+ st.test('spreads a comma group appended to an object overflowed under the default arrayLimit', function (sst) {
1509
+ var values = [];
1510
+ for (var i = 0; i <= 20; i += 1) {
1511
+ values[values.length] = String(i);
1512
+ }
1513
+ var expected = {};
1514
+ for (var j = 0; j < values.length; j += 1) {
1515
+ expected[j] = values[j];
1516
+ }
1517
+ expected[21] = 'x';
1518
+ expected[22] = 'y';
1519
+
1520
+ var result = qs.parse('a=' + values.join(',') + '&a=x,y', { comma: true });
1521
+ sst.deepEqual(result, { a: expected }, 'appended values land at indices 21 and 22');
1522
+ sst.end();
1523
+ });
1524
+
1525
+ st.test('spreads a comma group appended to an already-overflowed object with plainObjects', function (sst) {
1526
+ var result = qs.parse('a=1,2,3,4,5,6&a=7,8', { comma: true, arrayLimit: 5, plainObjects: true });
1527
+ sst.deepEqual(
1528
+ result,
1529
+ { __proto__: null, a: { __proto__: null, 0: '1', 1: '2', 2: '3', 3: '4', 4: '5', 5: '6', 6: '7', 7: '8' } },
1530
+ 'appended comma values are flattened into the null object'
1531
+ );
1532
+ sst.end();
1533
+ });
1534
+
1535
+ st.test('still throws with throwOnLimitExceeded when a comma group is appended to an already-overflowed object', function (sst) {
1536
+ sst['throws'](
1537
+ function () {
1538
+ qs.parse('a=1,2,3,4,5,6&a=7,8', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
1539
+ },
1540
+ /Array limit exceeded/,
1541
+ 'throws before spreading the appended group'
1542
+ );
1543
+ sst.end();
1544
+ });
1545
+ st.test('does not throw for comma groups nested under bracket notation, counting each group as one element', function (sst) {
1546
+ var result = qs.parse('a[]=1,2,3&a[]=4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
1547
+ sst.deepEqual(result, { a: [['1', '2', '3'], ['4', '5', '6']] }, 'nested comma groups count as one element each');
1548
+ sst.end();
1549
+ });
1550
+
1551
+ st.test('throws before splitting when a single comma value exceeds arrayLimit', function (sst) {
1552
+ sst['throws'](
1553
+ function () {
1554
+ qs.parse('a=1,2,3,4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
1555
+ },
1556
+ new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
1557
+ 'a flat comma value over the limit throws'
1558
+ );
1559
+
1560
+ sst['throws'](
1561
+ function () {
1562
+ qs.parse('a=1,2', { comma: true, arrayLimit: 1, throwOnLimitExceeded: true });
1563
+ },
1564
+ new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
1565
+ 'singular message at arrayLimit 1'
1566
+ );
1567
+
1568
+ sst['throws'](
1569
+ function () {
1570
+ qs.parse('a[b]=1,2,3,4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
1571
+ },
1572
+ new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
1573
+ 'a non-bracket nested key comma value over the limit throws'
1574
+ );
1575
+ sst.end();
1576
+ });
1577
+
1578
+ st.test('does not throw for a single comma value within arrayLimit', function (sst) {
1579
+ sst.deepEqual(
1580
+ qs.parse('a=1,2,3', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true }),
1581
+ { a: ['1', '2', '3'] },
1582
+ 'within the limit'
1583
+ );
1584
+ sst.deepEqual(
1585
+ qs.parse('a=1,2,3,4,5', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true }),
1586
+ { a: ['1', '2', '3', '4', '5'] },
1587
+ 'exactly at the limit'
1588
+ );
1589
+ sst.end();
1590
+ });
1591
+
1592
+ st.test('throws before splitting when a bracketed comma group exceeds arrayLimit', function (sst) {
1593
+ sst['throws'](
1594
+ function () {
1595
+ qs.parse('a[]=1,2,3,4,5,6', { comma: true, arrayLimit: 5, throwOnLimitExceeded: true });
1596
+ },
1597
+ new RangeError('Array limit exceeded. Only 5 elements allowed in an array.'),
1598
+ 'the inner group is itself an array and is subject to arrayLimit'
1599
+ );
1600
+ sst.end();
1601
+ });
1602
+
1603
+ st.test('throws before splitting when a comma group under `[]=` exceeds arrayLimit', function (sst) {
1604
+ sst['throws'](
1605
+ function () {
1606
+ qs.parse('a[]=1,2,3,4', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true });
1607
+ },
1608
+ new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
1609
+ 'a bracket-push comma group over the limit throws like the flat form'
1610
+ );
1611
+
1612
+ sst['throws'](
1613
+ function () {
1614
+ qs.parse('a[]=1,2', { comma: true, arrayLimit: 1, throwOnLimitExceeded: true });
1615
+ },
1616
+ new RangeError('Array limit exceeded. Only 1 element allowed in an array.'),
1617
+ 'singular message at arrayLimit 1'
1618
+ );
1619
+
1620
+ sst['throws'](
1621
+ function () {
1622
+ qs.parse('a[b][]=1,2,3,4', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true });
1623
+ },
1624
+ new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
1625
+ 'a nested bracket-push key throws'
1626
+ );
1627
+
1628
+ sst['throws'](
1629
+ function () {
1630
+ qs.parse('a[][]=1,2,3,4', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true });
1631
+ },
1632
+ new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
1633
+ 'a doubly bracket-pushed key throws'
1634
+ );
1635
+
1636
+ sst['throws'](
1637
+ function () {
1638
+ qs.parse('a[]=5&a[]=1,2,3,4', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true });
1639
+ },
1640
+ new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
1641
+ 'an oversized group appended after a scalar throws'
1642
+ );
1643
+
1644
+ sst['throws'](
1645
+ function () {
1646
+ qs.parse('a[]=1,2,3,4&a[]=5', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true });
1647
+ },
1648
+ new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
1649
+ 'an oversized group throws even when a later part would fit'
1650
+ );
1651
+
1652
+ sst['throws'](
1653
+ function () {
1654
+ qs.parse('a[]=1,2,3,4&a[]=5', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true, duplicates: 'first' });
1655
+ },
1656
+ new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
1657
+ 'throws with duplicates: first'
1658
+ );
1659
+
1660
+ sst['throws'](
1661
+ function () {
1662
+ qs.parse('a[]=5&a[]=1,2,3,4', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true, duplicates: 'last' });
1663
+ },
1664
+ new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
1665
+ 'throws with duplicates: last'
1666
+ );
1667
+
1668
+ sst['throws'](
1669
+ function () {
1670
+ qs.parse({ a: '1,2,3,4' }, { comma: true, arrayLimit: 3, throwOnLimitExceeded: true });
1671
+ },
1672
+ new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
1673
+ 'an oversized comma value in object input throws'
1674
+ );
1675
+
1676
+ var big = 'a[]=' + new Array(1e5 + 1).join('1,') + '1';
1677
+ sst['throws'](
1678
+ function () {
1679
+ qs.parse(big, { comma: true, arrayLimit: 3, throwOnLimitExceeded: true });
1680
+ },
1681
+ new RangeError('Array limit exceeded. Only 3 elements allowed in an array.'),
1682
+ 'a very long bracket-push comma group throws'
1683
+ );
1684
+ sst.end();
1685
+ });
1686
+
1687
+ st.test('does not throw for a comma group under `[]=` within arrayLimit', function (sst) {
1688
+ sst.deepEqual(
1689
+ qs.parse('a[]=1,2,3', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true }),
1690
+ { a: [['1', '2', '3']] },
1691
+ 'an inner group exactly at the limit stays a single nested element'
1692
+ );
1693
+ sst.deepEqual(
1694
+ qs.parse('a[]=1,2,3&a[]=4,5,6&a[]=7', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true }),
1695
+ { a: [['1', '2', '3'], ['4', '5', '6'], '7'] },
1696
+ 'each group counts as one element of the outer array'
1697
+ );
1698
+ sst.deepEqual(
1699
+ qs.parse('a[b][]=1,2,3', { comma: true, arrayLimit: 3, throwOnLimitExceeded: true }),
1700
+ { a: { b: [['1', '2', '3']] } },
1701
+ 'nested bracket-push key within the limit'
1702
+ );
1703
+ sst.deepEqual(
1704
+ qs.parse({ a: '1,2,3' }, { comma: true, arrayLimit: 3, throwOnLimitExceeded: true }),
1705
+ { a: ['1', '2', '3'] },
1706
+ 'object input within the limit'
1707
+ );
1708
+ sst.end();
1709
+ });
1710
+
1711
+ st.test('keeps an oversized comma group under `[]=` as a nested array without throwOnLimitExceeded', function (sst) {
1712
+ sst.deepEqual(
1713
+ qs.parse('a[]=1,2,3,4', { comma: true, arrayLimit: 3 }),
1714
+ { a: [['1', '2', '3', '4']] },
1715
+ 'the inner group is not converted to an overflow object'
1716
+ );
1717
+ sst.end();
1718
+ });
1719
+
1720
+ st.test('throws for a bracketed comma group when arrayLimit is 0', function (sst) {
1721
+ sst['throws'](
1722
+ function () {
1723
+ qs.parse('a[]=1,2,3', { comma: true, arrayLimit: 0, throwOnLimitExceeded: true });
1724
+ },
1725
+ new RangeError('Array limit exceeded. Only 0 elements allowed in an array.'),
1726
+ 'a single bracketed element still exceeds arrayLimit 0'
1727
+ );
1728
+ sst.end();
1729
+ });
1730
+
1312
1731
  st.end();
1313
1732
  });
1314
1733