@trpc/server 11.0.0-rc.817 → 11.0.0-rc.819

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 +1 @@
1
- {"version":3,"file":"getPlanner.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/getPlanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EAClC,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,WAAW,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAExE,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,iCAAiC,CAAC;AActC;;IAEI;AACJ,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI,MAAM,SAAS,oBAAoB,GACtE,qBAAqB,GACrB,MAAM,SAAS,sBAAsB,GACnC,iCAAiC,GACjC,KAAK,CAAC;AA6IZ,wBAAgB,UAAU,CAAC,MAAM,SAAS,WAAW,EAAE,KAAK,EAAE,MAAM;;;yBAtI7C,QAAQ;EA0K9B"}
1
+ {"version":3,"file":"getPlanner.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws-lambda/getPlanner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,iCAAiC,EAClC,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,WAAW,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAExE,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,iCAAiC,CAAC;AActC;;IAEI;AACJ,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI,MAAM,SAAS,oBAAoB,GACtE,qBAAqB,GACrB,MAAM,SAAS,sBAAsB,GACnC,iCAAiC,GACjC,KAAK,CAAC;AA4IZ,wBAAgB,UAAU,CAAC,MAAM,SAAS,WAAW,EAAE,KAAK,EAAE,MAAM;;;yBArI7C,QAAQ;EAyK9B"}
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var split = require('../../vendor/cookie-es/set-cookie/split.js');
4
+
3
5
  function determinePayloadFormat(event) {
4
6
  // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
5
7
  // According to AWS support, version is is extracted from the version property in the event.
@@ -13,7 +15,7 @@ function determinePayloadFormat(event) {
13
15
  }
14
16
  function getHeadersAndCookiesFromResponse(response) {
15
17
  const headers = Object.fromEntries(response.headers.entries());
16
- const cookies = response.headers.getSetCookie().flatMap((value)=>value.split(',')).map((cookie)=>cookie.trim());
18
+ const cookies = split.splitSetCookieString(response.headers.getSetCookie()).map((cookie)=>cookie.trim());
17
19
  delete headers['set-cookie'];
18
20
  return {
19
21
  headers,
@@ -1,3 +1,5 @@
1
+ import { splitSetCookieString } from '../../vendor/cookie-es/set-cookie/split.mjs';
2
+
1
3
  function determinePayloadFormat(event) {
2
4
  // https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
3
5
  // According to AWS support, version is is extracted from the version property in the event.
@@ -11,7 +13,7 @@ function determinePayloadFormat(event) {
11
13
  }
12
14
  function getHeadersAndCookiesFromResponse(response) {
13
15
  const headers = Object.fromEntries(response.headers.entries());
14
- const cookies = response.headers.getSetCookie().flatMap((value)=>value.split(',')).map((cookie)=>cookie.trim());
16
+ const cookies = splitSetCookieString(response.headers.getSetCookie()).map((cookie)=>cookie.trim());
15
17
  delete headers['set-cookie'];
16
18
  return {
17
19
  headers,
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 199060,
3
- "bundleOrigSize": 230855,
4
- "bundleReduction": 13.77,
2
+ "bundleSize": 201851,
3
+ "bundleOrigSize": 233664,
4
+ "bundleReduction": 13.61,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
@@ -14,7 +14,7 @@
14
14
  "dependents": [
15
15
  "/src/unstable-core-do-not-import.ts"
16
16
  ],
17
- "percent": 10.59,
17
+ "percent": 10.45,
18
18
  "reduction": 0
19
19
  },
20
20
  {
@@ -30,7 +30,7 @@
30
30
  "dependents": [
31
31
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
32
32
  ],
33
- "percent": 10.12,
33
+ "percent": 9.98,
34
34
  "reduction": 0
35
35
  },
36
36
  {
@@ -47,7 +47,7 @@
47
47
  "/src/unstable-core-do-not-import.ts",
48
48
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
49
49
  ],
50
- "percent": 10.02,
50
+ "percent": 9.88,
51
51
  "reduction": 0
52
52
  },
53
53
  {
@@ -64,7 +64,7 @@
64
64
  "/src/unstable-core-do-not-import.ts",
65
65
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
66
66
  ],
67
- "percent": 6.51,
67
+ "percent": 6.42,
68
68
  "reduction": 0
69
69
  },
70
70
  {
@@ -77,7 +77,7 @@
77
77
  ],
78
78
  "removedExports": [],
79
79
  "dependents": [],
80
- "percent": 6.11,
80
+ "percent": 6.02,
81
81
  "reduction": 11.62
82
82
  },
83
83
  {
@@ -98,7 +98,7 @@
98
98
  "/src/unstable-core-do-not-import/initTRPC.ts",
99
99
  "/src/unstable-core-do-not-import/http/contentType.ts"
100
100
  ],
101
- "percent": 5.11,
101
+ "percent": 5.04,
102
102
  "reduction": 29.51
103
103
  },
104
104
  {
@@ -112,7 +112,7 @@
112
112
  "dependents": [
113
113
  "/src/unstable-core-do-not-import/stream/jsonl.ts"
114
114
  ],
115
- "percent": 4.08,
115
+ "percent": 4.02,
116
116
  "reduction": 0
117
117
  },
118
118
  {
@@ -127,7 +127,7 @@
127
127
  "/src/unstable-core-do-not-import.ts",
128
128
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
129
129
  ],
130
- "percent": 3.96,
130
+ "percent": 3.9,
131
131
  "reduction": 0.83
132
132
  },
133
133
  {
@@ -142,7 +142,7 @@
142
142
  "/src/unstable-core-do-not-import.ts",
143
143
  "/src/unstable-core-do-not-import/initTRPC.ts"
144
144
  ],
145
- "percent": 2.93,
145
+ "percent": 2.89,
146
146
  "reduction": 64.88
147
147
  },
148
148
  {
@@ -162,13 +162,13 @@
162
162
  "/src/unstable-core-do-not-import/stream/sse.ts",
163
163
  "/src/unstable-core-do-not-import/stream/utils/withPing.ts"
164
164
  ],
165
- "percent": 2.87,
165
+ "percent": 2.83,
166
166
  "reduction": 0
167
167
  },
168
168
  {
169
169
  "id": "/src/adapters/aws-lambda/getPlanner.ts",
170
- "size": 5414,
171
- "origSize": 6118,
170
+ "size": 5407,
171
+ "origSize": 6177,
172
172
  "renderedExports": [
173
173
  "getPlanner"
174
174
  ],
@@ -176,8 +176,8 @@
176
176
  "dependents": [
177
177
  "/src/adapters/aws-lambda/index.ts"
178
178
  ],
179
- "percent": 2.72,
180
- "reduction": 11.51
179
+ "percent": 2.68,
180
+ "reduction": 12.47
181
181
  },
182
182
  {
183
183
  "id": "/src/observable/observable.ts",
@@ -196,7 +196,7 @@
196
196
  "/src/observable/operators.ts",
197
197
  "/src/observable/behaviorSubject.ts"
198
198
  ],
199
- "percent": 2.43,
199
+ "percent": 2.4,
200
200
  "reduction": 0
201
201
  },
202
202
  {
@@ -212,7 +212,7 @@
212
212
  "/src/unstable-core-do-not-import/stream/jsonl.ts",
213
213
  "/src/unstable-core-do-not-import/stream/sse.ts"
214
214
  ],
215
- "percent": 2.23,
215
+ "percent": 2.2,
216
216
  "reduction": 0
217
217
  },
218
218
  {
@@ -228,7 +228,7 @@
228
228
  "/src/adapters/node-http/index.ts",
229
229
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
230
230
  ],
231
- "percent": 2.03,
231
+ "percent": 2.01,
232
232
  "reduction": 6.81
233
233
  },
234
234
  {
@@ -246,7 +246,7 @@
246
246
  "dependents": [
247
247
  "/src/observable/index.ts"
248
248
  ],
249
- "percent": 1.96,
249
+ "percent": 1.94,
250
250
  "reduction": 1.66
251
251
  },
252
252
  {
@@ -260,9 +260,23 @@
260
260
  "dependents": [
261
261
  "/src/adapters/next-app-dir.ts"
262
262
  ],
263
- "percent": 1.63,
263
+ "percent": 1.61,
264
264
  "reduction": 22.52
265
265
  },
266
+ {
267
+ "id": "/src/vendor/cookie-es/set-cookie/split.ts",
268
+ "size": 2798,
269
+ "origSize": 2750,
270
+ "renderedExports": [
271
+ "splitSetCookieString"
272
+ ],
273
+ "removedExports": [],
274
+ "dependents": [
275
+ "/src/adapters/aws-lambda/getPlanner.ts"
276
+ ],
277
+ "percent": 1.39,
278
+ "reduction": 0
279
+ },
266
280
  {
267
281
  "id": "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
268
282
  "size": 2742,
@@ -275,7 +289,7 @@
275
289
  "dependents": [
276
290
  "/src/adapters/node-http/index.ts"
277
291
  ],
278
- "percent": 1.38,
292
+ "percent": 1.36,
279
293
  "reduction": 16.3
280
294
  },
281
295
  {
@@ -295,7 +309,7 @@
295
309
  "/src/unstable-core-do-not-import/router.ts",
296
310
  "/src/unstable-core-do-not-import/initTRPC.ts"
297
311
  ],
298
- "percent": 1.38,
312
+ "percent": 1.36,
299
313
  "reduction": 45.98
300
314
  },
301
315
  {
@@ -309,7 +323,7 @@
309
323
  "dependents": [
310
324
  "/src/unstable-core-do-not-import.ts"
311
325
  ],
312
- "percent": 1.34,
326
+ "percent": 1.32,
313
327
  "reduction": 40.81
314
328
  },
315
329
  {
@@ -329,7 +343,7 @@
329
343
  "/src/unstable-core-do-not-import/initTRPC.ts",
330
344
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
331
345
  ],
332
- "percent": 1.32,
346
+ "percent": 1.3,
333
347
  "reduction": 55.79
334
348
  },
335
349
  {
@@ -367,7 +381,7 @@
367
381
  "/src/unstable-core-do-not-import/stream/jsonl.ts",
368
382
  "/src/unstable-core-do-not-import/stream/sse.ts"
369
383
  ],
370
- "percent": 1.24,
384
+ "percent": 1.22,
371
385
  "reduction": 17.51
372
386
  },
373
387
  {
@@ -390,7 +404,7 @@
390
404
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
391
405
  "/src/unstable-core-do-not-import/stream/sse.ts"
392
406
  ],
393
- "percent": 1.22,
407
+ "percent": 1.2,
394
408
  "reduction": 0
395
409
  },
396
410
  {
@@ -406,7 +420,7 @@
406
420
  "/src/unstable-core-do-not-import.ts",
407
421
  "/src/unstable-core-do-not-import/router.ts"
408
422
  ],
409
- "percent": 1.16,
423
+ "percent": 1.14,
410
424
  "reduction": 0
411
425
  },
412
426
  {
@@ -420,7 +434,7 @@
420
434
  "dependents": [
421
435
  "/src/adapters/fetch/index.ts"
422
436
  ],
423
- "percent": 1.13,
437
+ "percent": 1.11,
424
438
  "reduction": 2.48
425
439
  },
426
440
  {
@@ -435,7 +449,7 @@
435
449
  "/src/adapters/next-app-dir.ts",
436
450
  "/src/adapters/next-app-dir/nextAppDirCaller.ts"
437
451
  ],
438
- "percent": 1.07,
452
+ "percent": 1.05,
439
453
  "reduction": 5.4
440
454
  },
441
455
  {
@@ -456,7 +470,7 @@
456
470
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
457
471
  "/src/unstable-core-do-not-import/error/getErrorShape.ts"
458
472
  ],
459
- "percent": 1.05,
473
+ "percent": 1.03,
460
474
  "reduction": 18.54
461
475
  },
462
476
  {
@@ -471,7 +485,7 @@
471
485
  "dependents": [
472
486
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
473
487
  ],
474
- "percent": 1.02,
488
+ "percent": 1,
475
489
  "reduction": 3.8
476
490
  },
477
491
  {
@@ -485,7 +499,7 @@
485
499
  "dependents": [
486
500
  "/src/adapters/fastify/index.ts"
487
501
  ],
488
- "percent": 0.89,
502
+ "percent": 0.88,
489
503
  "reduction": 30.2
490
504
  },
491
505
  {
@@ -505,7 +519,7 @@
505
519
  "/src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts",
506
520
  "/src/unstable-core-do-not-import/stream/utils/timerResource.ts"
507
521
  ],
508
- "percent": 0.88,
522
+ "percent": 0.87,
509
523
  "reduction": 4.41
510
524
  },
511
525
  {
@@ -517,7 +531,7 @@
517
531
  ],
518
532
  "removedExports": [],
519
533
  "dependents": [],
520
- "percent": 0.85,
534
+ "percent": 0.84,
521
535
  "reduction": 19.62
522
536
  },
523
537
  {
@@ -530,7 +544,7 @@
530
544
  ],
531
545
  "removedExports": [],
532
546
  "dependents": [],
533
- "percent": 0.81,
547
+ "percent": 0.8,
534
548
  "reduction": 17.81
535
549
  },
536
550
  {
@@ -545,7 +559,7 @@
545
559
  "/src/unstable-core-do-not-import.ts",
546
560
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
547
561
  ],
548
- "percent": 0.81,
562
+ "percent": 0.8,
549
563
  "reduction": 54.01
550
564
  },
551
565
  {
@@ -557,7 +571,7 @@
557
571
  ],
558
572
  "removedExports": [],
559
573
  "dependents": [],
560
- "percent": 0.67,
574
+ "percent": 0.66,
561
575
  "reduction": 35.1
562
576
  },
563
577
  {
@@ -574,7 +588,7 @@
574
588
  "/src/adapters/next-app-dir/nextAppDirCaller.ts",
575
589
  "/src/adapters/next-app-dir/rethrowNextErrors.ts"
576
590
  ],
577
- "percent": 0.67,
591
+ "percent": 0.66,
578
592
  "reduction": 0
579
593
  },
580
594
  {
@@ -589,7 +603,7 @@
589
603
  "/src/adapters/fastify/index.ts",
590
604
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
591
605
  ],
592
- "percent": 0.58,
606
+ "percent": 0.57,
593
607
  "reduction": 47.55
594
608
  },
595
609
  {
@@ -633,7 +647,7 @@
633
647
  "dependents": [
634
648
  "/src/observable/index.ts"
635
649
  ],
636
- "percent": 0.49,
650
+ "percent": 0.48,
637
651
  "reduction": 32.89
638
652
  },
639
653
  {
@@ -647,7 +661,7 @@
647
661
  ],
648
662
  "removedExports": [],
649
663
  "dependents": [],
650
- "percent": 0.48,
664
+ "percent": 0.47,
651
665
  "reduction": 69.13
652
666
  },
653
667
  {
@@ -659,7 +673,7 @@
659
673
  ],
660
674
  "removedExports": [],
661
675
  "dependents": [],
662
- "percent": 0.45,
676
+ "percent": 0.44,
663
677
  "reduction": 34
664
678
  },
665
679
  {
@@ -703,7 +717,7 @@
703
717
  "/src/unstable-core-do-not-import.ts",
704
718
  "/src/unstable-core-do-not-import/parser.ts"
705
719
  ],
706
- "percent": 0.35,
720
+ "percent": 0.34,
707
721
  "reduction": 0
708
722
  },
709
723
  {
@@ -718,7 +732,7 @@
718
732
  "/src/unstable-core-do-not-import/stream/jsonl.ts",
719
733
  "/src/unstable-core-do-not-import/stream/sse.ts"
720
734
  ],
721
- "percent": 0.33,
735
+ "percent": 0.32,
722
736
  "reduction": 1.36
723
737
  },
724
738
  {
@@ -781,7 +795,7 @@
781
795
  "/src/unstable-core-do-not-import/stream/jsonl.ts",
782
796
  "/src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts"
783
797
  ],
784
- "percent": 0.16,
798
+ "percent": 0.15,
785
799
  "reduction": 27.12
786
800
  },
787
801
  {
@@ -911,8 +925,8 @@
911
925
  "dependents": [
912
926
  "/src/adapters/express.ts",
913
927
  "/src/adapters/next.ts",
914
- "/src/adapters/ws.ts",
915
928
  "/src/adapters/standalone.ts",
929
+ "/src/adapters/ws.ts",
916
930
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
917
931
  "/src/adapters/next-app-dir/nextAppDirCaller.ts",
918
932
  "/src/adapters/node-http/writeResponse.ts"
@@ -971,13 +985,13 @@
971
985
  "dependents": [
972
986
  "/src/adapters/express.ts",
973
987
  "/src/adapters/next.ts",
974
- "/src/adapters/ws.ts",
975
988
  "/src/adapters/standalone.ts",
989
+ "/src/adapters/ws.ts",
976
990
  "/src/adapters/fastify/fastifyRequestHandler.ts"
977
991
  ],
978
992
  "percent": 0,
979
993
  "reduction": 100
980
994
  }
981
995
  ],
982
- "moduleCount": 63
996
+ "moduleCount": 64
983
997
  }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Based on https://github.com/unjs/cookie-es/tree/v1.2.2
3
+ * MIT License
4
+ *
5
+ * Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io>
6
+ * Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser
7
+ * Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/)
8
+ *
9
+ * @see https://github.com/unjs/cookie-es/blob/main/src/set-cookie/split.ts
10
+ */
11
+ /**
12
+ * Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
13
+ * that are within a single set-cookie field-value, such as in the Expires portion.
14
+ *
15
+ * See https://tools.ietf.org/html/rfc2616#section-4.2
16
+ */
17
+ export declare function splitSetCookieString(cookiesString: string | string[]): string[];
18
+ //# sourceMappingURL=split.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../../../src/vendor/cookie-es/set-cookie/split.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAC/B,MAAM,EAAE,CAuEV"}
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Based on https://github.com/unjs/cookie-es/tree/v1.2.2
5
+ * MIT License
6
+ *
7
+ * Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io>
8
+ * Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser
9
+ * Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/)
10
+ *
11
+ * @see https://github.com/unjs/cookie-es/blob/main/src/set-cookie/split.ts
12
+ */ /**
13
+ * Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
14
+ * that are within a single set-cookie field-value, such as in the Expires portion.
15
+ *
16
+ * See https://tools.ietf.org/html/rfc2616#section-4.2
17
+ */ function splitSetCookieString(cookiesString) {
18
+ if (Array.isArray(cookiesString)) {
19
+ return cookiesString.flatMap((c)=>splitSetCookieString(c));
20
+ }
21
+ if (typeof cookiesString !== "string") {
22
+ return [];
23
+ }
24
+ const cookiesStrings = [];
25
+ let pos = 0;
26
+ let start;
27
+ let ch;
28
+ let lastComma;
29
+ let nextStart;
30
+ let cookiesSeparatorFound;
31
+ const skipWhitespace = ()=>{
32
+ while(pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))){
33
+ pos += 1;
34
+ }
35
+ return pos < cookiesString.length;
36
+ };
37
+ const notSpecialChar = ()=>{
38
+ ch = cookiesString.charAt(pos);
39
+ return ch !== "=" && ch !== ";" && ch !== ",";
40
+ };
41
+ while(pos < cookiesString.length){
42
+ start = pos;
43
+ cookiesSeparatorFound = false;
44
+ while(skipWhitespace()){
45
+ ch = cookiesString.charAt(pos);
46
+ if (ch === ",") {
47
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
48
+ lastComma = pos;
49
+ pos += 1;
50
+ skipWhitespace();
51
+ nextStart = pos;
52
+ while(pos < cookiesString.length && notSpecialChar()){
53
+ pos += 1;
54
+ }
55
+ // currently special character
56
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
57
+ // we found cookies separator
58
+ cookiesSeparatorFound = true;
59
+ // pos is inside the next cookie, so back up and return it.
60
+ pos = nextStart;
61
+ cookiesStrings.push(cookiesString.slice(start, lastComma));
62
+ start = pos;
63
+ } else {
64
+ // in param ',' or param separator ';',
65
+ // we continue from that comma
66
+ pos = lastComma + 1;
67
+ }
68
+ } else {
69
+ pos += 1;
70
+ }
71
+ }
72
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
73
+ cookiesStrings.push(cookiesString.slice(start));
74
+ }
75
+ }
76
+ return cookiesStrings;
77
+ }
78
+
79
+ exports.splitSetCookieString = splitSetCookieString;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Based on https://github.com/unjs/cookie-es/tree/v1.2.2
3
+ * MIT License
4
+ *
5
+ * Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io>
6
+ * Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser
7
+ * Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/)
8
+ *
9
+ * @see https://github.com/unjs/cookie-es/blob/main/src/set-cookie/split.ts
10
+ */ /**
11
+ * Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
12
+ * that are within a single set-cookie field-value, such as in the Expires portion.
13
+ *
14
+ * See https://tools.ietf.org/html/rfc2616#section-4.2
15
+ */ function splitSetCookieString(cookiesString) {
16
+ if (Array.isArray(cookiesString)) {
17
+ return cookiesString.flatMap((c)=>splitSetCookieString(c));
18
+ }
19
+ if (typeof cookiesString !== "string") {
20
+ return [];
21
+ }
22
+ const cookiesStrings = [];
23
+ let pos = 0;
24
+ let start;
25
+ let ch;
26
+ let lastComma;
27
+ let nextStart;
28
+ let cookiesSeparatorFound;
29
+ const skipWhitespace = ()=>{
30
+ while(pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))){
31
+ pos += 1;
32
+ }
33
+ return pos < cookiesString.length;
34
+ };
35
+ const notSpecialChar = ()=>{
36
+ ch = cookiesString.charAt(pos);
37
+ return ch !== "=" && ch !== ";" && ch !== ",";
38
+ };
39
+ while(pos < cookiesString.length){
40
+ start = pos;
41
+ cookiesSeparatorFound = false;
42
+ while(skipWhitespace()){
43
+ ch = cookiesString.charAt(pos);
44
+ if (ch === ",") {
45
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
46
+ lastComma = pos;
47
+ pos += 1;
48
+ skipWhitespace();
49
+ nextStart = pos;
50
+ while(pos < cookiesString.length && notSpecialChar()){
51
+ pos += 1;
52
+ }
53
+ // currently special character
54
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
55
+ // we found cookies separator
56
+ cookiesSeparatorFound = true;
57
+ // pos is inside the next cookie, so back up and return it.
58
+ pos = nextStart;
59
+ cookiesStrings.push(cookiesString.slice(start, lastComma));
60
+ start = pos;
61
+ } else {
62
+ // in param ',' or param separator ';',
63
+ // we continue from that comma
64
+ pos = lastComma + 1;
65
+ }
66
+ } else {
67
+ pos += 1;
68
+ }
69
+ }
70
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
71
+ cookiesStrings.push(cookiesString.slice(start));
72
+ }
73
+ }
74
+ return cookiesStrings;
75
+ }
76
+
77
+ export { splitSetCookieString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.817+53ebeae30",
3
+ "version": "11.0.0-rc.819+b550ee46a",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -152,5 +152,5 @@
152
152
  "peerDependencies": {
153
153
  "typescript": ">=5.7.2"
154
154
  },
155
- "gitHead": "53ebeae30b9c9b3e0cb9bda30cb8dcff598d9077"
155
+ "gitHead": "b550ee46a02e455b9dfed610c6d32fc75475748c"
156
156
  }
@@ -4,6 +4,7 @@ import type {
4
4
  APIGatewayProxyResult,
5
5
  APIGatewayProxyStructuredResultV2,
6
6
  } from 'aws-lambda';
7
+ import { splitSetCookieString } from '../../vendor/cookie-es/set-cookie/split';
7
8
 
8
9
  export type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
9
10
 
@@ -43,10 +44,9 @@ interface Processor<TEvent extends LambdaEvent> {
43
44
  function getHeadersAndCookiesFromResponse(response: Response) {
44
45
  const headers = Object.fromEntries(response.headers.entries());
45
46
 
46
- const cookies: string[] = response.headers
47
- .getSetCookie()
48
- .flatMap((value) => value.split(','))
49
- .map((cookie) => cookie.trim());
47
+ const cookies: string[] = splitSetCookieString(
48
+ response.headers.getSetCookie(),
49
+ ).map((cookie) => cookie.trim());
50
50
 
51
51
  delete headers['set-cookie'];
52
52
 
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Based on https://github.com/unjs/cookie-es/tree/v1.2.2
3
+ * MIT License
4
+ *
5
+ * Cookie-es copyright (c) Pooya Parsa <pooya@pi0.io>
6
+ * Set-Cookie parsing based on https://github.com/nfriedly/set-cookie-parser
7
+ * Copyright (c) 2015 Nathan Friedly <nathan@nfriedly.com> (http://nfriedly.com/)
8
+ *
9
+ * @see https://github.com/unjs/cookie-es/blob/main/src/set-cookie/split.ts
10
+ */
11
+
12
+ /**
13
+ * Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
14
+ * that are within a single set-cookie field-value, such as in the Expires portion.
15
+ *
16
+ * See https://tools.ietf.org/html/rfc2616#section-4.2
17
+ */
18
+ export function splitSetCookieString(
19
+ cookiesString: string | string[],
20
+ ): string[] {
21
+ if (Array.isArray(cookiesString)) {
22
+ return cookiesString.flatMap((c) => splitSetCookieString(c));
23
+ }
24
+
25
+ if (typeof cookiesString !== "string") {
26
+ return [];
27
+ }
28
+
29
+ const cookiesStrings: string[] = [];
30
+ let pos: number = 0;
31
+ let start: number;
32
+ let ch: string;
33
+ let lastComma: number;
34
+ let nextStart: number;
35
+ let cookiesSeparatorFound: boolean;
36
+
37
+ const skipWhitespace = () => {
38
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
39
+ pos += 1;
40
+ }
41
+ return pos < cookiesString.length;
42
+ };
43
+
44
+ const notSpecialChar = () => {
45
+ ch = cookiesString.charAt(pos);
46
+ return ch !== "=" && ch !== ";" && ch !== ",";
47
+ };
48
+
49
+ while (pos < cookiesString.length) {
50
+ start = pos;
51
+ cookiesSeparatorFound = false;
52
+
53
+ while (skipWhitespace()) {
54
+ ch = cookiesString.charAt(pos);
55
+ if (ch === ",") {
56
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
57
+ lastComma = pos;
58
+ pos += 1;
59
+
60
+ skipWhitespace();
61
+ nextStart = pos;
62
+
63
+ while (pos < cookiesString.length && notSpecialChar()) {
64
+ pos += 1;
65
+ }
66
+
67
+ // currently special character
68
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
69
+ // we found cookies separator
70
+ cookiesSeparatorFound = true;
71
+ // pos is inside the next cookie, so back up and return it.
72
+ pos = nextStart;
73
+ cookiesStrings.push(cookiesString.slice(start, lastComma));
74
+ start = pos;
75
+ } else {
76
+ // in param ',' or param separator ';',
77
+ // we continue from that comma
78
+ pos = lastComma + 1;
79
+ }
80
+ } else {
81
+ pos += 1;
82
+ }
83
+ }
84
+
85
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
86
+ cookiesStrings.push(cookiesString.slice(start));
87
+ }
88
+ }
89
+
90
+ return cookiesStrings;
91
+ }