@agnostack/next-shopify 1.15.0-beta.6 → 1.15.0-beta.7
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.
- package/CHANGELOG.md +7 -0
- package/dist/umd/verification.js +18 -362
- package/dist/umd/verification.js.map +1 -1
- package/dist/verification/utils/rawbody.js +29 -12
- package/dist/verification/utils/rawbody.js.map +1 -1
- package/package.json +2 -6
- package/node_modules/browser-monads-ts/LICENSE +0 -21
- package/node_modules/browser-monads-ts/README.md +0 -46
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.cjs.js +0 -2
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.cjs.js.map +0 -1
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.es.js +0 -12
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.es.js.map +0 -1
- package/node_modules/browser-monads-ts/dist/index.d.ts +0 -5
- package/node_modules/browser-monads-ts/dist/index.d.ts.map +0 -1
- package/node_modules/browser-monads-ts/package.json +0 -79
- package/node_modules/bytes/History.md +0 -97
- package/node_modules/bytes/LICENSE +0 -23
- package/node_modules/bytes/Readme.md +0 -152
- package/node_modules/bytes/index.js +0 -170
- package/node_modules/bytes/package.json +0 -42
- package/node_modules/depd/History.md +0 -103
- package/node_modules/depd/LICENSE +0 -22
- package/node_modules/depd/Readme.md +0 -280
- package/node_modules/depd/index.js +0 -538
- package/node_modules/depd/lib/browser/index.js +0 -77
- package/node_modules/depd/package.json +0 -45
- package/node_modules/http-errors/HISTORY.md +0 -180
- package/node_modules/http-errors/LICENSE +0 -23
- package/node_modules/http-errors/README.md +0 -169
- package/node_modules/http-errors/index.js +0 -289
- package/node_modules/http-errors/package.json +0 -50
- package/node_modules/iconv-lite/Changelog.md +0 -162
- package/node_modules/iconv-lite/LICENSE +0 -21
- package/node_modules/iconv-lite/README.md +0 -156
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -555
- package/node_modules/iconv-lite/encodings/dbcs-data.js +0 -176
- package/node_modules/iconv-lite/encodings/index.js +0 -22
- package/node_modules/iconv-lite/encodings/internal.js +0 -188
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
- package/node_modules/iconv-lite/encodings/sbcs-data.js +0 -174
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
- package/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
- package/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
- package/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -55
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
- package/node_modules/iconv-lite/encodings/utf16.js +0 -177
- package/node_modules/iconv-lite/encodings/utf7.js +0 -290
- package/node_modules/iconv-lite/lib/bom-handling.js +0 -52
- package/node_modules/iconv-lite/lib/extend-node.js +0 -217
- package/node_modules/iconv-lite/lib/index.d.ts +0 -24
- package/node_modules/iconv-lite/lib/index.js +0 -153
- package/node_modules/iconv-lite/lib/streams.js +0 -121
- package/node_modules/iconv-lite/package.json +0 -46
- package/node_modules/inherits/LICENSE +0 -16
- package/node_modules/inherits/README.md +0 -42
- package/node_modules/inherits/inherits.js +0 -9
- package/node_modules/inherits/inherits_browser.js +0 -27
- package/node_modules/inherits/package.json +0 -29
- package/node_modules/nothing-mock/LICENSE +0 -21
- package/node_modules/nothing-mock/README.md +0 -266
- package/node_modules/nothing-mock/dist/nothing-mock.es.js +0 -2
- package/node_modules/nothing-mock/dist/nothing-mock.es.js.map +0 -1
- package/node_modules/nothing-mock/dist/nothing-mock.js +0 -2
- package/node_modules/nothing-mock/dist/nothing-mock.js.map +0 -1
- package/node_modules/nothing-mock/dist/nothing-mock.modern.js +0 -2
- package/node_modules/nothing-mock/dist/nothing-mock.modern.js.map +0 -1
- package/node_modules/nothing-mock/dist/nothing-mock.umd.js +0 -2
- package/node_modules/nothing-mock/dist/nothing-mock.umd.js.map +0 -1
- package/node_modules/nothing-mock/index.d.ts +0 -6
- package/node_modules/nothing-mock/package.json +0 -29
- package/node_modules/nothing-mock/src/index.js +0 -15
- package/node_modules/raw-body/HISTORY.md +0 -308
- package/node_modules/raw-body/LICENSE +0 -22
- package/node_modules/raw-body/README.md +0 -223
- package/node_modules/raw-body/SECURITY.md +0 -24
- package/node_modules/raw-body/index.d.ts +0 -87
- package/node_modules/raw-body/index.js +0 -336
- package/node_modules/raw-body/package.json +0 -49
- package/node_modules/safer-buffer/LICENSE +0 -21
- package/node_modules/safer-buffer/Porting-Buffer.md +0 -268
- package/node_modules/safer-buffer/Readme.md +0 -156
- package/node_modules/safer-buffer/dangerous.js +0 -58
- package/node_modules/safer-buffer/package.json +0 -34
- package/node_modules/safer-buffer/safer.js +0 -77
- package/node_modules/safer-buffer/tests.js +0 -406
- package/node_modules/setprototypeof/LICENSE +0 -13
- package/node_modules/setprototypeof/README.md +0 -31
- package/node_modules/setprototypeof/index.d.ts +0 -2
- package/node_modules/setprototypeof/index.js +0 -17
- package/node_modules/setprototypeof/package.json +0 -38
- package/node_modules/setprototypeof/test/index.js +0 -24
- package/node_modules/statuses/HISTORY.md +0 -82
- package/node_modules/statuses/LICENSE +0 -23
- package/node_modules/statuses/README.md +0 -136
- package/node_modules/statuses/codes.json +0 -65
- package/node_modules/statuses/index.js +0 -146
- package/node_modules/statuses/package.json +0 -49
- package/node_modules/toidentifier/HISTORY.md +0 -9
- package/node_modules/toidentifier/LICENSE +0 -21
- package/node_modules/toidentifier/README.md +0 -61
- package/node_modules/toidentifier/index.js +0 -32
- package/node_modules/toidentifier/package.json +0 -38
- package/node_modules/unpipe/HISTORY.md +0 -4
- package/node_modules/unpipe/LICENSE +0 -22
- package/node_modules/unpipe/README.md +0 -43
- package/node_modules/unpipe/index.js +0 -69
- package/node_modules/unpipe/package.json +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.15.0-beta.7](https://github.com/agnostack/next-shopify/compare/v1.15.0-beta.6...v1.15.0-beta.7) (2023-12-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* removed dep on raw-body ([761931c](https://github.com/agnostack/next-shopify/commit/761931c0c76be995d7217f96874ab7eaf642a659))
|
|
7
|
+
|
|
1
8
|
# [1.15.0-beta.6](https://github.com/agnostack/next-shopify/compare/v1.15.0-beta.5...v1.15.0-beta.6) (2023-12-08)
|
|
2
9
|
|
|
3
10
|
|
package/dist/umd/verification.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@agnostack/next-shopify/umd-verification"] = {}));
|
|
5
|
-
})(this, (function (exports) { 'use strict';
|
|
6
|
-
|
|
7
|
-
var n,r=((n=function(){return r}).toString=n.toLocaleString=n[Symbol.toPrimitive]=function(){return ""},n.valueOf=function(){return !1},new Proxy(Object.freeze(n),{get:function(n,t){return n.hasOwnProperty(t)?n[t]:r}})),u=function(n){return n===r};
|
|
8
|
-
|
|
9
|
-
let win = global.window;
|
|
10
|
-
let exists = (variable) => !u(variable);
|
|
11
|
-
let window = typeof win !== "undefined" ? win : r;
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('browser-monads-ts')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'browser-monads-ts'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@agnostack/next-shopify/umd-verification"] = {}, global["browser-monads-ts"]));
|
|
5
|
+
})(this, (function (exports, browserMonadsTs) { 'use strict';
|
|
12
6
|
|
|
13
7
|
/* eslint-disable no-use-before-define */
|
|
14
8
|
|
|
@@ -121,8 +115,8 @@
|
|
|
121
115
|
};
|
|
122
116
|
|
|
123
117
|
const getTextDecoder = async () => {
|
|
124
|
-
if (exists(window) && (typeof window?.TextDecoder === 'function')) {
|
|
125
|
-
return window.TextDecoder
|
|
118
|
+
if (browserMonadsTs.exists(browserMonadsTs.window) && (typeof browserMonadsTs.window?.TextDecoder === 'function')) {
|
|
119
|
+
return browserMonadsTs.window.TextDecoder
|
|
126
120
|
}
|
|
127
121
|
|
|
128
122
|
try {
|
|
@@ -135,8 +129,8 @@
|
|
|
135
129
|
};
|
|
136
130
|
|
|
137
131
|
const getTextEncoder = async () => {
|
|
138
|
-
if (exists(window) && (typeof window?.TextEncoder === 'function')) {
|
|
139
|
-
return window.TextEncoder
|
|
132
|
+
if (browserMonadsTs.exists(browserMonadsTs.window) && (typeof browserMonadsTs.window?.TextEncoder === 'function')) {
|
|
133
|
+
return browserMonadsTs.window.TextEncoder
|
|
140
134
|
}
|
|
141
135
|
|
|
142
136
|
try {
|
|
@@ -504,362 +498,24 @@
|
|
|
504
498
|
}
|
|
505
499
|
}
|
|
506
500
|
|
|
507
|
-
/*!
|
|
508
|
-
* raw-body
|
|
509
|
-
* Copyright(c) 2013-2014 Jonathan Ong
|
|
510
|
-
* Copyright(c) 2014-2022 Douglas Christopher Wilson
|
|
511
|
-
* MIT Licensed
|
|
512
|
-
*/
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* Module dependencies.
|
|
516
|
-
* @private
|
|
517
|
-
*/
|
|
518
|
-
|
|
519
|
-
var asyncHooks = tryRequireAsyncHooks();
|
|
520
|
-
var bytes = require('bytes');
|
|
521
|
-
var createError = require('http-errors');
|
|
522
|
-
var iconv = require('iconv-lite');
|
|
523
|
-
var unpipe = require('unpipe');
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Module exports.
|
|
527
|
-
* @public
|
|
528
|
-
*/
|
|
529
|
-
|
|
530
|
-
module.exports = getRawBody;
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* Module variables.
|
|
534
|
-
* @private
|
|
535
|
-
*/
|
|
536
|
-
|
|
537
|
-
var ICONV_ENCODING_MESSAGE_REGEXP = /^Encoding not recognized: /;
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Get the decoder for a given encoding.
|
|
541
|
-
*
|
|
542
|
-
* @param {string} encoding
|
|
543
|
-
* @private
|
|
544
|
-
*/
|
|
545
|
-
|
|
546
|
-
function getDecoder (encoding) {
|
|
547
|
-
if (!encoding) return null
|
|
548
|
-
|
|
549
|
-
try {
|
|
550
|
-
return iconv.getDecoder(encoding)
|
|
551
|
-
} catch (e) {
|
|
552
|
-
// error getting decoder
|
|
553
|
-
if (!ICONV_ENCODING_MESSAGE_REGEXP.test(e.message)) throw e
|
|
554
|
-
|
|
555
|
-
// the encoding was not found
|
|
556
|
-
throw createError(415, 'specified encoding unsupported', {
|
|
557
|
-
encoding: encoding,
|
|
558
|
-
type: 'encoding.unsupported'
|
|
559
|
-
})
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* Get the raw body of a stream (typically HTTP).
|
|
565
|
-
*
|
|
566
|
-
* @param {object} stream
|
|
567
|
-
* @param {object|string|function} [options]
|
|
568
|
-
* @param {function} [callback]
|
|
569
|
-
* @public
|
|
570
|
-
*/
|
|
571
|
-
|
|
572
|
-
function getRawBody (stream, options, callback) {
|
|
573
|
-
var done = callback;
|
|
574
|
-
var opts = options || {};
|
|
575
|
-
|
|
576
|
-
// light validation
|
|
577
|
-
if (stream === undefined) {
|
|
578
|
-
throw new TypeError('argument stream is required')
|
|
579
|
-
} else if (typeof stream !== 'object' || stream === null || typeof stream.on !== 'function') {
|
|
580
|
-
throw new TypeError('argument stream must be a stream')
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
if (options === true || typeof options === 'string') {
|
|
584
|
-
// short cut for encoding
|
|
585
|
-
opts = {
|
|
586
|
-
encoding: options
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
if (typeof options === 'function') {
|
|
591
|
-
done = options;
|
|
592
|
-
opts = {};
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
// validate callback is a function, if provided
|
|
596
|
-
if (done !== undefined && typeof done !== 'function') {
|
|
597
|
-
throw new TypeError('argument callback must be a function')
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
// require the callback without promises
|
|
601
|
-
if (!done && !global.Promise) {
|
|
602
|
-
throw new TypeError('argument callback is required')
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
// get encoding
|
|
606
|
-
var encoding = opts.encoding !== true
|
|
607
|
-
? opts.encoding
|
|
608
|
-
: 'utf-8';
|
|
609
|
-
|
|
610
|
-
// convert the limit to an integer
|
|
611
|
-
var limit = bytes.parse(opts.limit);
|
|
612
|
-
|
|
613
|
-
// convert the expected length to an integer
|
|
614
|
-
var length = opts.length != null && !isNaN(opts.length)
|
|
615
|
-
? parseInt(opts.length, 10)
|
|
616
|
-
: null;
|
|
617
|
-
|
|
618
|
-
if (done) {
|
|
619
|
-
// classic callback style
|
|
620
|
-
return readStream(stream, encoding, length, limit, wrap(done))
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
return new Promise(function executor (resolve, reject) {
|
|
624
|
-
readStream(stream, encoding, length, limit, function onRead (err, buf) {
|
|
625
|
-
if (err) return reject(err)
|
|
626
|
-
resolve(buf);
|
|
627
|
-
});
|
|
628
|
-
})
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* Halt a stream.
|
|
633
|
-
*
|
|
634
|
-
* @param {Object} stream
|
|
635
|
-
* @private
|
|
636
|
-
*/
|
|
637
|
-
|
|
638
|
-
function halt (stream) {
|
|
639
|
-
// unpipe everything from the stream
|
|
640
|
-
unpipe(stream);
|
|
641
|
-
|
|
642
|
-
// pause stream
|
|
643
|
-
if (typeof stream.pause === 'function') {
|
|
644
|
-
stream.pause();
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* Read the data from the stream.
|
|
650
|
-
*
|
|
651
|
-
* @param {object} stream
|
|
652
|
-
* @param {string} encoding
|
|
653
|
-
* @param {number} length
|
|
654
|
-
* @param {number} limit
|
|
655
|
-
* @param {function} callback
|
|
656
|
-
* @public
|
|
657
|
-
*/
|
|
658
|
-
|
|
659
|
-
function readStream (stream, encoding, length, limit, callback) {
|
|
660
|
-
var complete = false;
|
|
661
|
-
var sync = true;
|
|
662
|
-
|
|
663
|
-
// check the length and limit options.
|
|
664
|
-
// note: we intentionally leave the stream paused,
|
|
665
|
-
// so users should handle the stream themselves.
|
|
666
|
-
if (limit !== null && length !== null && length > limit) {
|
|
667
|
-
return done(createError(413, 'request entity too large', {
|
|
668
|
-
expected: length,
|
|
669
|
-
length: length,
|
|
670
|
-
limit: limit,
|
|
671
|
-
type: 'entity.too.large'
|
|
672
|
-
}))
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
// streams1: assert request encoding is buffer.
|
|
676
|
-
// streams2+: assert the stream encoding is buffer.
|
|
677
|
-
// stream._decoder: streams1
|
|
678
|
-
// state.encoding: streams2
|
|
679
|
-
// state.decoder: streams2, specifically < 0.10.6
|
|
680
|
-
var state = stream._readableState;
|
|
681
|
-
if (stream._decoder || (state && (state.encoding || state.decoder))) {
|
|
682
|
-
// developer error
|
|
683
|
-
return done(createError(500, 'stream encoding should not be set', {
|
|
684
|
-
type: 'stream.encoding.set'
|
|
685
|
-
}))
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
if (typeof stream.readable !== 'undefined' && !stream.readable) {
|
|
689
|
-
return done(createError(500, 'stream is not readable', {
|
|
690
|
-
type: 'stream.not.readable'
|
|
691
|
-
}))
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
var received = 0;
|
|
695
|
-
var decoder;
|
|
696
|
-
|
|
697
|
-
try {
|
|
698
|
-
decoder = getDecoder(encoding);
|
|
699
|
-
} catch (err) {
|
|
700
|
-
return done(err)
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
var buffer = decoder
|
|
704
|
-
? ''
|
|
705
|
-
: [];
|
|
706
|
-
|
|
707
|
-
// attach listeners
|
|
708
|
-
stream.on('aborted', onAborted);
|
|
709
|
-
stream.on('close', cleanup);
|
|
710
|
-
stream.on('data', onData);
|
|
711
|
-
stream.on('end', onEnd);
|
|
712
|
-
stream.on('error', onEnd);
|
|
713
|
-
|
|
714
|
-
// mark sync section complete
|
|
715
|
-
sync = false;
|
|
716
|
-
|
|
717
|
-
function done () {
|
|
718
|
-
var args = new Array(arguments.length);
|
|
719
|
-
|
|
720
|
-
// copy arguments
|
|
721
|
-
for (var i = 0; i < args.length; i++) {
|
|
722
|
-
args[i] = arguments[i];
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
// mark complete
|
|
726
|
-
complete = true;
|
|
727
|
-
|
|
728
|
-
if (sync) {
|
|
729
|
-
process.nextTick(invokeCallback);
|
|
730
|
-
} else {
|
|
731
|
-
invokeCallback();
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
function invokeCallback () {
|
|
735
|
-
cleanup();
|
|
736
|
-
|
|
737
|
-
if (args[0]) {
|
|
738
|
-
// halt the stream on error
|
|
739
|
-
halt(stream);
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
callback.apply(null, args);
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
function onAborted () {
|
|
747
|
-
if (complete) return
|
|
748
|
-
|
|
749
|
-
done(createError(400, 'request aborted', {
|
|
750
|
-
code: 'ECONNABORTED',
|
|
751
|
-
expected: length,
|
|
752
|
-
length: length,
|
|
753
|
-
received: received,
|
|
754
|
-
type: 'request.aborted'
|
|
755
|
-
}));
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
function onData (chunk) {
|
|
759
|
-
if (complete) return
|
|
760
|
-
|
|
761
|
-
received += chunk.length;
|
|
762
|
-
|
|
763
|
-
if (limit !== null && received > limit) {
|
|
764
|
-
done(createError(413, 'request entity too large', {
|
|
765
|
-
limit: limit,
|
|
766
|
-
received: received,
|
|
767
|
-
type: 'entity.too.large'
|
|
768
|
-
}));
|
|
769
|
-
} else if (decoder) {
|
|
770
|
-
buffer += decoder.write(chunk);
|
|
771
|
-
} else {
|
|
772
|
-
buffer.push(chunk);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
function onEnd (err) {
|
|
777
|
-
if (complete) return
|
|
778
|
-
if (err) return done(err)
|
|
779
|
-
|
|
780
|
-
if (length !== null && received !== length) {
|
|
781
|
-
done(createError(400, 'request size did not match content length', {
|
|
782
|
-
expected: length,
|
|
783
|
-
length: length,
|
|
784
|
-
received: received,
|
|
785
|
-
type: 'request.size.invalid'
|
|
786
|
-
}));
|
|
787
|
-
} else {
|
|
788
|
-
var string = decoder
|
|
789
|
-
? buffer + (decoder.end() || '')
|
|
790
|
-
: Buffer.concat(buffer);
|
|
791
|
-
done(null, string);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
function cleanup () {
|
|
796
|
-
buffer = null;
|
|
797
|
-
|
|
798
|
-
stream.removeListener('aborted', onAborted);
|
|
799
|
-
stream.removeListener('data', onData);
|
|
800
|
-
stream.removeListener('end', onEnd);
|
|
801
|
-
stream.removeListener('error', onEnd);
|
|
802
|
-
stream.removeListener('close', cleanup);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
* Try to require async_hooks
|
|
808
|
-
* @private
|
|
809
|
-
*/
|
|
810
|
-
|
|
811
|
-
function tryRequireAsyncHooks () {
|
|
812
|
-
try {
|
|
813
|
-
return require('async_hooks')
|
|
814
|
-
} catch (e) {
|
|
815
|
-
return {}
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
/**
|
|
820
|
-
* Wrap function with async resource, if possible.
|
|
821
|
-
* AsyncResource.bind static method backported.
|
|
822
|
-
* @private
|
|
823
|
-
*/
|
|
824
|
-
|
|
825
|
-
function wrap (fn) {
|
|
826
|
-
var res;
|
|
827
|
-
|
|
828
|
-
// create anonymous resource
|
|
829
|
-
if (asyncHooks.AsyncResource) {
|
|
830
|
-
res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn');
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
// incompatible node.js
|
|
834
|
-
if (!res || !res.runInAsyncScope) {
|
|
835
|
-
return fn
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
// return bound function
|
|
839
|
-
return res.runInAsyncScope.bind(res, fn, null)
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
var getRawBody$1 = /*#__PURE__*/Object.freeze({
|
|
843
|
-
__proto__: null
|
|
844
|
-
});
|
|
845
|
-
|
|
846
501
|
// import getRawBody from 'raw-body'
|
|
502
|
+
// import * as getRawBody from 'raw-body'
|
|
847
503
|
|
|
848
|
-
|
|
849
|
-
|
|
504
|
+
const getChunkedRawBody = async (readable) => {
|
|
505
|
+
const chunks = [];
|
|
850
506
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
507
|
+
for await (const chunk of readable) {
|
|
508
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
509
|
+
}
|
|
854
510
|
|
|
855
|
-
|
|
856
|
-
|
|
511
|
+
return Buffer.concat(chunks)
|
|
512
|
+
};
|
|
857
513
|
|
|
858
514
|
// TODO: explore returning mutated request object adding on req.rawBody??
|
|
859
515
|
// TODO: move to req.text() after next 13.5: https://github.com/vercel/next.js/discussions/13405
|
|
860
516
|
const ensureRawBody = async (req) => (
|
|
861
|
-
|
|
862
|
-
getRawBody
|
|
517
|
+
getChunkedRawBody(req)
|
|
518
|
+
// getRawBody(req)
|
|
863
519
|
.then((_rawBody) => _rawBody.toString())
|
|
864
520
|
.catch((error) => {
|
|
865
521
|
// NOTE: this is intended to ensure if getRawBody is called 2x w/in a route that it returns the already streamed body
|