@orpc/openapi-client 1.6.4 → 1.6.6

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.
@@ -1,7 +1,7 @@
1
1
  import { ClientContext } from '@orpc/client';
2
2
  import { LinkFetchClientOptions } from '@orpc/client/fetch';
3
3
  import { AnyContractRouter } from '@orpc/contract';
4
- import { f as StandardOpenAPILinkOptions, g as StandardOpenAPILink } from '../../shared/openapi-client.Bc2pHPqD.mjs';
4
+ import { g as StandardOpenAPILinkOptions, h as StandardOpenAPILink } from '../../shared/openapi-client.f2unmElJ.mjs';
5
5
  import '@orpc/client/standard';
6
6
  import '@orpc/shared';
7
7
  import '@orpc/standard-server';
@@ -1,7 +1,7 @@
1
1
  import { ClientContext } from '@orpc/client';
2
2
  import { LinkFetchClientOptions } from '@orpc/client/fetch';
3
3
  import { AnyContractRouter } from '@orpc/contract';
4
- import { f as StandardOpenAPILinkOptions, g as StandardOpenAPILink } from '../../shared/openapi-client.Bc2pHPqD.js';
4
+ import { g as StandardOpenAPILinkOptions, h as StandardOpenAPILink } from '../../shared/openapi-client.f2unmElJ.js';
5
5
  import '@orpc/client/standard';
6
6
  import '@orpc/shared';
7
7
  import '@orpc/standard-server';
@@ -1,7 +1,7 @@
1
1
  import { LinkFetchClient } from '@orpc/client/fetch';
2
2
  import '@orpc/shared';
3
3
  import '@orpc/contract';
4
- import { b as StandardOpenAPILink } from '../../shared/openapi-client.Bix5hHnT.mjs';
4
+ import { b as StandardOpenAPILink } from '../../shared/openapi-client.D3eD5ojB.mjs';
5
5
  import '@orpc/client';
6
6
  import '@orpc/client/standard';
7
7
  import '@orpc/standard-server';
@@ -1,4 +1,4 @@
1
- export { S as StandardBracketNotationSerialized, a as StandardBracketNotationSerializer, c as StandardOpenAPICustomJsonSerializer, b as StandardOpenAPIJsonSerialized, e as StandardOpenAPIJsonSerializer, d as StandardOpenAPIJsonSerializerOptions, g as StandardOpenAPILink, f as StandardOpenAPILinkOptions, j as StandardOpenAPISerializeOptions, k as StandardOpenAPISerializer, i as StandardOpenapiLinkCodec, h as StandardOpenapiLinkCodecOptions } from '../../shared/openapi-client.Bc2pHPqD.mjs';
1
+ export { S as StandardBracketNotationSerialized, b as StandardBracketNotationSerializer, a as StandardBracketNotationSerializerOptions, d as StandardOpenAPICustomJsonSerializer, c as StandardOpenAPIJsonSerialized, f as StandardOpenAPIJsonSerializer, e as StandardOpenAPIJsonSerializerOptions, h as StandardOpenAPILink, g as StandardOpenAPILinkOptions, k as StandardOpenAPISerializeOptions, l as StandardOpenAPISerializer, j as StandardOpenapiLinkCodec, i as StandardOpenapiLinkCodecOptions } from '../../shared/openapi-client.f2unmElJ.mjs';
2
2
  import { HTTPPath } from '@orpc/client';
3
3
  import '@orpc/client/standard';
4
4
  import '@orpc/contract';
@@ -1,4 +1,4 @@
1
- export { S as StandardBracketNotationSerialized, a as StandardBracketNotationSerializer, c as StandardOpenAPICustomJsonSerializer, b as StandardOpenAPIJsonSerialized, e as StandardOpenAPIJsonSerializer, d as StandardOpenAPIJsonSerializerOptions, g as StandardOpenAPILink, f as StandardOpenAPILinkOptions, j as StandardOpenAPISerializeOptions, k as StandardOpenAPISerializer, i as StandardOpenapiLinkCodec, h as StandardOpenapiLinkCodecOptions } from '../../shared/openapi-client.Bc2pHPqD.js';
1
+ export { S as StandardBracketNotationSerialized, b as StandardBracketNotationSerializer, a as StandardBracketNotationSerializerOptions, d as StandardOpenAPICustomJsonSerializer, c as StandardOpenAPIJsonSerialized, f as StandardOpenAPIJsonSerializer, e as StandardOpenAPIJsonSerializerOptions, h as StandardOpenAPILink, g as StandardOpenAPILinkOptions, k as StandardOpenAPISerializeOptions, l as StandardOpenAPISerializer, j as StandardOpenapiLinkCodec, i as StandardOpenapiLinkCodecOptions } from '../../shared/openapi-client.f2unmElJ.js';
2
2
  import { HTTPPath } from '@orpc/client';
3
3
  import '@orpc/client/standard';
4
4
  import '@orpc/contract';
@@ -1,5 +1,5 @@
1
- import { S as StandardBracketNotationSerializer } from '../../shared/openapi-client.Bix5hHnT.mjs';
2
- export { a as StandardOpenAPIJsonSerializer, b as StandardOpenAPILink, d as StandardOpenAPISerializer, c as StandardOpenapiLinkCodec, g as getDynamicParams, s as standardizeHTTPPath } from '../../shared/openapi-client.Bix5hHnT.mjs';
1
+ import { S as StandardBracketNotationSerializer } from '../../shared/openapi-client.D3eD5ojB.mjs';
2
+ export { a as StandardOpenAPIJsonSerializer, b as StandardOpenAPILink, d as StandardOpenAPISerializer, c as StandardOpenapiLinkCodec, g as getDynamicParams, s as standardizeHTTPPath } from '../../shared/openapi-client.D3eD5ojB.mjs';
3
3
  import { isSchemaIssue } from '@orpc/contract';
4
4
  import { isTypescriptObject } from '@orpc/shared';
5
5
  import '@orpc/client/standard';
@@ -5,6 +5,10 @@ import { isContractProcedure, fallbackContractConfig, ORPCError } from '@orpc/co
5
5
  import { mergeStandardHeaders, ErrorEvent } from '@orpc/standard-server';
6
6
 
7
7
  class StandardBracketNotationSerializer {
8
+ maxArrayIndex;
9
+ constructor(options = {}) {
10
+ this.maxArrayIndex = options.maxBracketNotationArrayIndex ?? 9999;
11
+ }
8
12
  serialize(data, segments = [], result = []) {
9
13
  if (Array.isArray(data)) {
10
14
  data.forEach((item, i) => {
@@ -34,7 +38,7 @@ class StandardBracketNotationSerializer {
34
38
  currentRef[nextSegment] = [];
35
39
  }
36
40
  if (i !== segments.length - 1) {
37
- if (Array.isArray(currentRef[nextSegment]) && !isValidArrayIndex(segment)) {
41
+ if (Array.isArray(currentRef[nextSegment]) && !isValidArrayIndex(segment, this.maxArrayIndex)) {
38
42
  if (arrayPushStyles.has(currentRef[nextSegment])) {
39
43
  arrayPushStyles.delete(currentRef[nextSegment]);
40
44
  currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
@@ -52,7 +56,7 @@ class StandardBracketNotationSerializer {
52
56
  if (arrayPushStyles.has(currentRef[nextSegment])) {
53
57
  arrayPushStyles.delete(currentRef[nextSegment]);
54
58
  currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
55
- } else if (!isValidArrayIndex(segment)) {
59
+ } else if (!isValidArrayIndex(segment, this.maxArrayIndex)) {
56
60
  currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
57
61
  }
58
62
  }
@@ -127,8 +131,8 @@ class StandardBracketNotationSerializer {
127
131
  return inBrackets || segments.length === 0 ? [path] : segments;
128
132
  }
129
133
  }
130
- function isValidArrayIndex(value) {
131
- return /^0$|^[1-9]\d*$/.test(value);
134
+ function isValidArrayIndex(value, maxIndex) {
135
+ return /^0$|^[1-9]\d*$/.test(value) && Number(value) <= maxIndex;
132
136
  }
133
137
  function arrayToObject(array) {
134
138
  const obj = new NullProtoObj();
@@ -424,7 +428,7 @@ class StandardOpenAPISerializer {
424
428
  class StandardOpenAPILink extends StandardLink {
425
429
  constructor(contract, linkClient, options) {
426
430
  const jsonSerializer = new StandardOpenAPIJsonSerializer(options);
427
- const bracketNotationSerializer = new StandardBracketNotationSerializer();
431
+ const bracketNotationSerializer = new StandardBracketNotationSerializer({ maxBracketNotationArrayIndex: 4294967294 });
428
432
  const serializer = new StandardOpenAPISerializer(jsonSerializer, bracketNotationSerializer);
429
433
  const linkCodec = new StandardOpenapiLinkCodec(contract, serializer, options);
430
434
  super(linkCodec, linkClient, options);
@@ -5,7 +5,25 @@ import { Segment, Value, Promisable } from '@orpc/shared';
5
5
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
6
6
 
7
7
  type StandardBracketNotationSerialized = [string, unknown][];
8
+ interface StandardBracketNotationSerializerOptions {
9
+ /**
10
+ * Maximum allowed array index for bracket notation deserialization.
11
+ *
12
+ * This helps protect against memory exhaustion attacks where malicious input
13
+ * uses extremely large array indices (e.g., `?arr[4294967296]=value`).
14
+ *
15
+ * While bracket notation creates sparse arrays that handle large indices efficiently,
16
+ * downstream code might inadvertently convert these sparse arrays to dense arrays,
17
+ * potentially creating millions of undefined elements and causing memory issues.
18
+ *
19
+ * @note Only applies to deserialization.
20
+ * @default 9_999 (array with 10,000 elements)
21
+ */
22
+ maxBracketNotationArrayIndex?: number;
23
+ }
8
24
  declare class StandardBracketNotationSerializer {
25
+ private readonly maxArrayIndex;
26
+ constructor(options?: StandardBracketNotationSerializerOptions);
9
27
  serialize(data: unknown, segments?: Segment[], result?: StandardBracketNotationSerialized): StandardBracketNotationSerialized;
10
28
  deserialize(serialized: StandardBracketNotationSerialized): Record<string, unknown> | unknown[];
11
29
  stringifyPath(segments: readonly Segment[]): string;
@@ -75,5 +93,5 @@ declare class StandardOpenAPILink<T extends ClientContext> extends StandardLink<
75
93
  constructor(contract: AnyContractRouter, linkClient: StandardLinkClient<T>, options: StandardOpenAPILinkOptions<T>);
76
94
  }
77
95
 
78
- export { StandardBracketNotationSerializer as a, StandardOpenAPIJsonSerializer as e, StandardOpenAPILink as g, StandardOpenapiLinkCodec as i, StandardOpenAPISerializer as k };
79
- export type { StandardBracketNotationSerialized as S, StandardOpenAPIJsonSerialized as b, StandardOpenAPICustomJsonSerializer as c, StandardOpenAPIJsonSerializerOptions as d, StandardOpenAPILinkOptions as f, StandardOpenapiLinkCodecOptions as h, StandardOpenAPISerializeOptions as j };
96
+ export { StandardBracketNotationSerializer as b, StandardOpenAPIJsonSerializer as f, StandardOpenAPILink as h, StandardOpenapiLinkCodec as j, StandardOpenAPISerializer as l };
97
+ export type { StandardBracketNotationSerialized as S, StandardBracketNotationSerializerOptions as a, StandardOpenAPIJsonSerialized as c, StandardOpenAPICustomJsonSerializer as d, StandardOpenAPIJsonSerializerOptions as e, StandardOpenAPILinkOptions as g, StandardOpenapiLinkCodecOptions as i, StandardOpenAPISerializeOptions as k };
@@ -5,7 +5,25 @@ import { Segment, Value, Promisable } from '@orpc/shared';
5
5
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
6
6
 
7
7
  type StandardBracketNotationSerialized = [string, unknown][];
8
+ interface StandardBracketNotationSerializerOptions {
9
+ /**
10
+ * Maximum allowed array index for bracket notation deserialization.
11
+ *
12
+ * This helps protect against memory exhaustion attacks where malicious input
13
+ * uses extremely large array indices (e.g., `?arr[4294967296]=value`).
14
+ *
15
+ * While bracket notation creates sparse arrays that handle large indices efficiently,
16
+ * downstream code might inadvertently convert these sparse arrays to dense arrays,
17
+ * potentially creating millions of undefined elements and causing memory issues.
18
+ *
19
+ * @note Only applies to deserialization.
20
+ * @default 9_999 (array with 10,000 elements)
21
+ */
22
+ maxBracketNotationArrayIndex?: number;
23
+ }
8
24
  declare class StandardBracketNotationSerializer {
25
+ private readonly maxArrayIndex;
26
+ constructor(options?: StandardBracketNotationSerializerOptions);
9
27
  serialize(data: unknown, segments?: Segment[], result?: StandardBracketNotationSerialized): StandardBracketNotationSerialized;
10
28
  deserialize(serialized: StandardBracketNotationSerialized): Record<string, unknown> | unknown[];
11
29
  stringifyPath(segments: readonly Segment[]): string;
@@ -75,5 +93,5 @@ declare class StandardOpenAPILink<T extends ClientContext> extends StandardLink<
75
93
  constructor(contract: AnyContractRouter, linkClient: StandardLinkClient<T>, options: StandardOpenAPILinkOptions<T>);
76
94
  }
77
95
 
78
- export { StandardBracketNotationSerializer as a, StandardOpenAPIJsonSerializer as e, StandardOpenAPILink as g, StandardOpenapiLinkCodec as i, StandardOpenAPISerializer as k };
79
- export type { StandardBracketNotationSerialized as S, StandardOpenAPIJsonSerialized as b, StandardOpenAPICustomJsonSerializer as c, StandardOpenAPIJsonSerializerOptions as d, StandardOpenAPILinkOptions as f, StandardOpenapiLinkCodecOptions as h, StandardOpenAPISerializeOptions as j };
96
+ export { StandardBracketNotationSerializer as b, StandardOpenAPIJsonSerializer as f, StandardOpenAPILink as h, StandardOpenapiLinkCodec as j, StandardOpenAPISerializer as l };
97
+ export type { StandardBracketNotationSerialized as S, StandardBracketNotationSerializerOptions as a, StandardOpenAPIJsonSerialized as c, StandardOpenAPICustomJsonSerializer as d, StandardOpenAPIJsonSerializerOptions as e, StandardOpenAPILinkOptions as g, StandardOpenapiLinkCodecOptions as i, StandardOpenAPISerializeOptions as k };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/openapi-client",
3
3
  "type": "module",
4
- "version": "1.6.4",
4
+ "version": "1.6.6",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -34,13 +34,13 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@orpc/client": "1.6.4",
38
- "@orpc/contract": "1.6.4",
39
- "@orpc/shared": "1.6.4",
40
- "@orpc/standard-server": "1.6.4"
37
+ "@orpc/client": "1.6.6",
38
+ "@orpc/standard-server": "1.6.6",
39
+ "@orpc/shared": "1.6.6",
40
+ "@orpc/contract": "1.6.6"
41
41
  },
42
42
  "devDependencies": {
43
- "@orpc/server": "1.6.4"
43
+ "@orpc/server": "1.6.6"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "unbuild",