@agnostack/next-shopify 1.15.0-beta.21 → 1.15.0-beta.23
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 +16 -0
- package/README.md +9 -8
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +0 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/shared/WebCrypto.d.ts.map +1 -1
- package/dist/shared/WebCrypto.js +0 -6
- package/dist/shared/WebCrypto.js.map +1 -1
- package/dist/umd/lib/index.d.ts +0 -1
- package/dist/umd/lib/index.d.ts.map +1 -1
- package/dist/umd/shared/WebCrypto.d.ts.map +1 -1
- package/dist/umd/verification/utils/rawbody.d.ts.map +1 -1
- package/dist/umd/verification.js +342 -18
- package/dist/umd/verification.js.map +1 -1
- package/dist/verification/utils/rawbody.d.ts.map +1 -1
- package/dist/verification/utils/rawbody.js +26 -29
- package/dist/verification/utils/rawbody.js.map +1 -1
- package/node_modules/bytes/History.md +97 -0
- package/node_modules/bytes/LICENSE +23 -0
- package/node_modules/bytes/Readme.md +152 -0
- package/node_modules/bytes/index.js +170 -0
- package/node_modules/bytes/package.json +42 -0
- package/node_modules/depd/History.md +103 -0
- package/node_modules/depd/LICENSE +22 -0
- package/node_modules/depd/Readme.md +280 -0
- package/node_modules/depd/index.js +538 -0
- package/node_modules/depd/lib/browser/index.js +77 -0
- package/node_modules/depd/package.json +45 -0
- package/node_modules/http-errors/HISTORY.md +180 -0
- package/node_modules/http-errors/LICENSE +23 -0
- package/node_modules/http-errors/README.md +169 -0
- package/node_modules/http-errors/index.js +289 -0
- package/node_modules/http-errors/package.json +50 -0
- package/node_modules/iconv-lite/Changelog.md +162 -0
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +156 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
- package/node_modules/iconv-lite/encodings/index.js +22 -0
- package/node_modules/iconv-lite/encodings/internal.js +188 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +174 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +177 -0
- package/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/node_modules/iconv-lite/lib/extend-node.js +217 -0
- package/node_modules/iconv-lite/lib/index.d.ts +24 -0
- package/node_modules/iconv-lite/lib/index.js +153 -0
- package/node_modules/iconv-lite/lib/streams.js +121 -0
- package/node_modules/iconv-lite/package.json +46 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/raw-body/HISTORY.md +308 -0
- package/node_modules/raw-body/LICENSE +22 -0
- package/node_modules/raw-body/README.md +223 -0
- package/node_modules/raw-body/SECURITY.md +24 -0
- package/node_modules/raw-body/index.d.ts +87 -0
- package/node_modules/raw-body/index.js +336 -0
- package/node_modules/raw-body/package.json +49 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/setprototypeof/LICENSE +13 -0
- package/node_modules/setprototypeof/README.md +31 -0
- package/node_modules/setprototypeof/index.d.ts +2 -0
- package/node_modules/setprototypeof/index.js +17 -0
- package/node_modules/setprototypeof/package.json +38 -0
- package/node_modules/setprototypeof/test/index.js +24 -0
- package/node_modules/statuses/HISTORY.md +82 -0
- package/node_modules/statuses/LICENSE +23 -0
- package/node_modules/statuses/README.md +136 -0
- package/node_modules/statuses/codes.json +65 -0
- package/node_modules/statuses/index.js +146 -0
- package/node_modules/statuses/package.json +49 -0
- package/node_modules/toidentifier/HISTORY.md +9 -0
- package/node_modules/toidentifier/LICENSE +21 -0
- package/node_modules/toidentifier/README.md +61 -0
- package/node_modules/toidentifier/index.js +32 -0
- package/node_modules/toidentifier/package.json +38 -0
- package/node_modules/unpipe/HISTORY.md +4 -0
- package/node_modules/unpipe/LICENSE +22 -0
- package/node_modules/unpipe/README.md +43 -0
- package/node_modules/unpipe/index.js +69 -0
- package/node_modules/unpipe/package.json +27 -0
- package/package.json +11 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# [1.15.0-beta.23](https://github.com/agnostack/next-shopify/compare/v1.15.0-beta.22...v1.15.0-beta.23) (2023-12-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* wip ([c549241](https://github.com/agnostack/next-shopify/commit/c54924137d9ed48dfd1ae669bee56cea3c538463))
|
|
7
|
+
* wip ([b66479e](https://github.com/agnostack/next-shopify/commit/b66479efd9d31349c02384ae0220a99a1730b5ee))
|
|
8
|
+
* wip ([791a349](https://github.com/agnostack/next-shopify/commit/791a34942430f9ee44c31277f24537dc62ad182e))
|
|
9
|
+
|
|
10
|
+
# [1.15.0-beta.22](https://github.com/agnostack/next-shopify/compare/v1.15.0-beta.21...v1.15.0-beta.22) (2023-12-08)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* wip ([3909ac9](https://github.com/agnostack/next-shopify/commit/3909ac901df8adf3150509603f03c3a17a49c176))
|
|
16
|
+
|
|
1
17
|
# [1.15.0-beta.21](https://github.com/agnostack/next-shopify/compare/v1.15.0-beta.20...v1.15.0-beta.21) (2023-12-08)
|
|
2
18
|
|
|
3
19
|
|
package/README.md
CHANGED
|
@@ -11,11 +11,11 @@ yarn add @agnostack/next-shopify
|
|
|
11
11
|
|
|
12
12
|
Inside of `next.config.js`, add the following:
|
|
13
13
|
```js
|
|
14
|
-
const {
|
|
14
|
+
const { withShopify } = require('@agnostack/next-shopify')
|
|
15
15
|
|
|
16
16
|
const manifestTemplate = require('./manifestTemplate.json')
|
|
17
17
|
|
|
18
|
-
const nextConfig =
|
|
18
|
+
const nextConfig = withShopify({
|
|
19
19
|
zendesk: { manifestTemplate },
|
|
20
20
|
})
|
|
21
21
|
|
|
@@ -24,11 +24,11 @@ const nextConfig = withZendeskCLI({
|
|
|
24
24
|
Also, create an api route (`pages/api/apps.js`) containing the following:
|
|
25
25
|
```js
|
|
26
26
|
import getConfig from 'next/config'
|
|
27
|
-
import {
|
|
27
|
+
import { withShopify } from '@agnostack/next-shopify'
|
|
28
28
|
|
|
29
29
|
const { serverRuntimeConfig } = getConfig() ?? {}
|
|
30
30
|
|
|
31
|
-
export default
|
|
31
|
+
export default withShopify(serverRuntimeConfig)
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
|
|
@@ -36,12 +36,13 @@ export default zendeskCLIHandler(serverRuntimeConfig)
|
|
|
36
36
|
|
|
37
37
|
Inside of `next.config.js`, add the following:
|
|
38
38
|
```js
|
|
39
|
-
const { withPlugins
|
|
39
|
+
const { withPlugins } = require('@agnostack/next-plugins')
|
|
40
|
+
const { withShopify } = require('@agnostack/next-shopify')
|
|
40
41
|
|
|
41
42
|
const manifest = require('./manifest.json')
|
|
42
43
|
|
|
43
44
|
const nextPlugins = [{
|
|
44
|
-
[
|
|
45
|
+
[withShopify]: {
|
|
45
46
|
manifestTemplate: manifest,
|
|
46
47
|
/* NOTE: add optionale below
|
|
47
48
|
apiRoute: '/api/my-custom-api-json-route', // (defaults to /api/apps)
|
|
@@ -81,11 +82,11 @@ const nextConfig = withPlugins({
|
|
|
81
82
|
Also, create an api route (`pages/api/apps.js`) containing the following:
|
|
82
83
|
```js
|
|
83
84
|
import getConfig from 'next/config'
|
|
84
|
-
import {
|
|
85
|
+
import { withShopify } from '@agnostack/next-shopify'
|
|
85
86
|
|
|
86
87
|
const { publicRuntimeConfig } = getConfig() ?? {}
|
|
87
88
|
|
|
88
|
-
export default
|
|
89
|
+
export default withShopify(publicRuntimeConfig)
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACf,MAAM,SAAS,CAAA"}
|
package/dist/lib/index.js
CHANGED
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.prepareHeaders = exports.getShopifyHelpers = void 0;
|
|
18
18
|
__exportStar(require("../shared"), exports);
|
|
19
19
|
__exportStar(require("../verification"), exports);
|
|
20
|
-
__exportStar(require("../plugins"), exports);
|
|
21
20
|
__exportStar(require("./handlers"), exports);
|
|
22
21
|
var utils_1 = require("./utils");
|
|
23
22
|
Object.defineProperty(exports, "getShopifyHelpers", { enumerable: true, get: function () { return utils_1.getShopifyHelpers; } });
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,kDAA+B;AAC/B,6CAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,kDAA+B;AAC/B,6CAA0B;AAC1B,iCAGgB;AAFd,0GAAA,iBAAiB,OAAA;AACjB,uGAAA,cAAc,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebCrypto.d.ts","sourceRoot":"","sources":["../../src/shared/WebCrypto.js"],"names":[],"mappings":";AAIA;IACE;;;OAGC;IAFC,aAAsB;IACtB,WAAkB;IAGpB,kBAEC;IAED,6BAoBC;IAED,+
|
|
1
|
+
{"version":3,"file":"WebCrypto.d.ts","sourceRoot":"","sources":["../../src/shared/WebCrypto.js"],"names":[],"mappings":";AAIA;IACE;;;OAGC;IAFC,aAAsB;IACtB,WAAkB;IAGpB,kBAEC;IAED,6BAoBC;IAED,+BAgBC;IAED,+BAgBC;IAED,mDAiBC;IAED,sCAMC;IAED,mCAQC;IAED,oDAIC;IAED,oCAMC;IAED,gDAMC;IAED,gCAYC;IAED,yCAiBC;IAED;;;;;;MAmBC;IAED,yEAiBC;IAED,iFAIC;IAED,0CAKC;IAED,iEAkBC;IAED,8CAUC;IAED,kDAUC;IAED;;;qBAoBC;IAED;;;qBAqBC;IAED;;;;;;;;;OAaC;IAED,sFAuBC;IAED,qEAuBC;CACF"}
|
package/dist/shared/WebCrypto.js
CHANGED
|
@@ -71,16 +71,13 @@ class WebCrypto {
|
|
|
71
71
|
var _a;
|
|
72
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
73
|
if ((_a = this._util) === null || _a === void 0 ? void 0 : _a.TextDecoder) {
|
|
74
|
-
console.info('Using this._util.TextDecoder');
|
|
75
74
|
return this._util.TextDecoder;
|
|
76
75
|
}
|
|
77
76
|
if ((0, browser_monads_ts_1.exists)(browser_monads_ts_1.window) && typeof (browser_monads_ts_1.window === null || browser_monads_ts_1.window === void 0 ? void 0 : browser_monads_ts_1.window.TextDecoder) === 'function') {
|
|
78
|
-
console.info('Using window.TextDecoder');
|
|
79
77
|
return browser_monads_ts_1.window.TextDecoder;
|
|
80
78
|
}
|
|
81
79
|
try {
|
|
82
80
|
const TextDecoder = (yield Promise.resolve().then(() => __importStar(require('util')))).TextDecoder;
|
|
83
|
-
console.info('Using imported util.TextDecoder');
|
|
84
81
|
return TextDecoder;
|
|
85
82
|
}
|
|
86
83
|
catch (error) {
|
|
@@ -93,16 +90,13 @@ class WebCrypto {
|
|
|
93
90
|
var _a;
|
|
94
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
92
|
if ((_a = this._util) === null || _a === void 0 ? void 0 : _a.TextEncoder) {
|
|
96
|
-
console.info('Using this._util.TextEncoder');
|
|
97
93
|
return this._util.TextEncoder;
|
|
98
94
|
}
|
|
99
95
|
if ((0, browser_monads_ts_1.exists)(browser_monads_ts_1.window) && typeof (browser_monads_ts_1.window === null || browser_monads_ts_1.window === void 0 ? void 0 : browser_monads_ts_1.window.TextEncoder) === 'function') {
|
|
100
|
-
console.info('Using window.TextEncoder');
|
|
101
96
|
return browser_monads_ts_1.window.TextEncoder;
|
|
102
97
|
}
|
|
103
98
|
try {
|
|
104
99
|
const TextEncoder = (yield Promise.resolve().then(() => __importStar(require('util')))).TextEncoder;
|
|
105
|
-
console.info('Using imported util.TextEncoder');
|
|
106
100
|
return TextEncoder;
|
|
107
101
|
}
|
|
108
102
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebCrypto.js","sourceRoot":"","sources":["../../src/shared/WebCrypto.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAkD;AAElD,uCAAkE;AAElE,MAAM,SAAS;IACb,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;QAC/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,IAAI,MAAM;;QACR,OAAO,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,CAAA;IAC7B,CAAC;IAEK,YAAY;;;YAChB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI;oBACF,IAAI,CAAC,OAAO,GAAG,CAAC,wDAAa,sBAAsB,GAAC,CAAC,CAAC,OAAO,CAAA;iBAC9D;gBAAC,OAAO,OAAO,EAAE;oBAChB,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAA;oBAC9E,IAAI;wBACF,IAAI,CAAC,OAAO,GAAG,CAAC,wDAAa,QAAQ,GAAC,CAAC,CAAC,OAAO,CAAA;qBAChD;oBAAC,OAAO,KAAK,EAAE;wBACd,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAA;wBAC7C,MAAM,KAAK,CAAA;qBACZ;iBACF;aACF;YAED,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,CAAA,EAAE;gBACzB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;aAClD;YAED,OAAO,IAAI,CAAC,OAAO,CAAA;;KACpB;IAEK,cAAc;;;YAClB,IAAI,MAAA,IAAI,CAAC,KAAK,0CAAE,WAAW,EAAE;gBAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"WebCrypto.js","sourceRoot":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AAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;YAC3C,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;YACnE,OAAO,gBAAgB,CAAA;QACzB,CAAC;KAAA;CACF;AAED,kBAAe,SAAS,CAAA"}
|
package/dist/umd/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACf,MAAM,SAAS,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebCrypto.d.ts","sourceRoot":"","sources":["../../src/shared/WebCrypto.js"],"names":[],"mappings":";AAIA;IACE;;;OAGC;IAFC,aAAsB;IACtB,WAAkB;IAGpB,kBAEC;IAED,6BAoBC;IAED,+
|
|
1
|
+
{"version":3,"file":"WebCrypto.d.ts","sourceRoot":"","sources":["../../src/shared/WebCrypto.js"],"names":[],"mappings":";AAIA;IACE;;;OAGC;IAFC,aAAsB;IACtB,WAAkB;IAGpB,kBAEC;IAED,6BAoBC;IAED,+BAgBC;IAED,+BAgBC;IAED,mDAiBC;IAED,sCAMC;IAED,mCAQC;IAED,oDAIC;IAED,oCAMC;IAED,gDAMC;IAED,gCAYC;IAED,yCAiBC;IAED;;;;;;MAmBC;IAED,yEAiBC;IAED,iFAIC;IAED,0CAKC;IAED,iEAkBC;IAED,8CAUC;IAED,kDAUC;IAED;;;qBAoBC;IAED;;;qBAqBC;IAED;;;;;;;;;OAaC;IAED,sFAuBC;IAED,qEAuBC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rawbody.d.ts","sourceRoot":"","sources":["../../../src/verification/utils/rawbody.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rawbody.d.ts","sourceRoot":"","sources":["../../../src/verification/utils/rawbody.js"],"names":[],"mappings":"AAYO,sDAON"}
|
package/dist/umd/verification.js
CHANGED
|
@@ -238,29 +238,20 @@
|
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
// import getRawBody from 'raw-body'
|
|
242
|
-
// import * as getRawBody from 'raw-body'
|
|
243
|
-
|
|
244
241
|
const getChunkedRawBody = async (readable) => {
|
|
245
242
|
if (readable?.rawBody) {
|
|
246
243
|
return readable.rawBody
|
|
247
244
|
}
|
|
248
245
|
|
|
249
|
-
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
for await (const chunk of chunkedBody) {
|
|
253
|
-
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
254
|
-
}
|
|
246
|
+
// TODO: move to req.text() after next 13.5: https://github.com/vercel/next.js/discussions/13405
|
|
247
|
+
const getRawBody = await Promise.resolve().then(function () { return index; });
|
|
255
248
|
|
|
256
|
-
return
|
|
249
|
+
return getRawBody(readable)
|
|
257
250
|
};
|
|
258
251
|
|
|
259
252
|
// TODO: explore returning mutated request object adding on req.rawBody??
|
|
260
|
-
// TODO: move to req.text() after next 13.5: https://github.com/vercel/next.js/discussions/13405
|
|
261
253
|
const ensureRawBody = async (req) => (
|
|
262
254
|
getChunkedRawBody(req)
|
|
263
|
-
// getRawBody(req)
|
|
264
255
|
.then((_rawBody) => _rawBody.toString())
|
|
265
256
|
.catch((error) => {
|
|
266
257
|
console.error(`Error getting raw body for '${req?.url}'`, error);
|
|
@@ -448,18 +439,15 @@
|
|
|
448
439
|
|
|
449
440
|
async getTextDecoder() {
|
|
450
441
|
if (this._util?.TextDecoder) {
|
|
451
|
-
console.info('Using this._util.TextDecoder');
|
|
452
442
|
return this._util.TextDecoder
|
|
453
443
|
}
|
|
454
444
|
|
|
455
445
|
if (exists(window) && typeof window?.TextDecoder === 'function') {
|
|
456
|
-
console.info('Using window.TextDecoder');
|
|
457
446
|
return window.TextDecoder
|
|
458
447
|
}
|
|
459
448
|
|
|
460
449
|
try {
|
|
461
450
|
const TextDecoder = (await import('util')).TextDecoder;
|
|
462
|
-
console.info('Using imported util.TextDecoder');
|
|
463
451
|
return TextDecoder
|
|
464
452
|
} catch (error) {
|
|
465
453
|
console.error('Failed to import utils.TextDecoder', error);
|
|
@@ -469,18 +457,15 @@
|
|
|
469
457
|
|
|
470
458
|
async getTextEncoder() {
|
|
471
459
|
if (this._util?.TextEncoder) {
|
|
472
|
-
console.info('Using this._util.TextEncoder');
|
|
473
460
|
return this._util.TextEncoder
|
|
474
461
|
}
|
|
475
462
|
|
|
476
463
|
if (exists(window) && typeof window?.TextEncoder === 'function') {
|
|
477
|
-
console.info('Using window.TextEncoder');
|
|
478
464
|
return window.TextEncoder
|
|
479
465
|
}
|
|
480
466
|
|
|
481
467
|
try {
|
|
482
468
|
const TextEncoder = (await import('util')).TextEncoder;
|
|
483
|
-
console.info('Using imported util.TextEncoder');
|
|
484
469
|
return TextEncoder
|
|
485
470
|
} catch (error) {
|
|
486
471
|
console.error('Failed to import utils.TextEncoder', error);
|
|
@@ -883,6 +868,345 @@
|
|
|
883
868
|
}
|
|
884
869
|
};
|
|
885
870
|
|
|
871
|
+
/*!
|
|
872
|
+
* raw-body
|
|
873
|
+
* Copyright(c) 2013-2014 Jonathan Ong
|
|
874
|
+
* Copyright(c) 2014-2022 Douglas Christopher Wilson
|
|
875
|
+
* MIT Licensed
|
|
876
|
+
*/
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Module dependencies.
|
|
880
|
+
* @private
|
|
881
|
+
*/
|
|
882
|
+
|
|
883
|
+
var asyncHooks = tryRequireAsyncHooks();
|
|
884
|
+
var bytes = require('bytes');
|
|
885
|
+
var createError = require('http-errors');
|
|
886
|
+
var iconv = require('iconv-lite');
|
|
887
|
+
var unpipe = require('unpipe');
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Module exports.
|
|
891
|
+
* @public
|
|
892
|
+
*/
|
|
893
|
+
|
|
894
|
+
module.exports = getRawBody;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Module variables.
|
|
898
|
+
* @private
|
|
899
|
+
*/
|
|
900
|
+
|
|
901
|
+
var ICONV_ENCODING_MESSAGE_REGEXP = /^Encoding not recognized: /;
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Get the decoder for a given encoding.
|
|
905
|
+
*
|
|
906
|
+
* @param {string} encoding
|
|
907
|
+
* @private
|
|
908
|
+
*/
|
|
909
|
+
|
|
910
|
+
function getDecoder (encoding) {
|
|
911
|
+
if (!encoding) return null
|
|
912
|
+
|
|
913
|
+
try {
|
|
914
|
+
return iconv.getDecoder(encoding)
|
|
915
|
+
} catch (e) {
|
|
916
|
+
// error getting decoder
|
|
917
|
+
if (!ICONV_ENCODING_MESSAGE_REGEXP.test(e.message)) throw e
|
|
918
|
+
|
|
919
|
+
// the encoding was not found
|
|
920
|
+
throw createError(415, 'specified encoding unsupported', {
|
|
921
|
+
encoding: encoding,
|
|
922
|
+
type: 'encoding.unsupported'
|
|
923
|
+
})
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Get the raw body of a stream (typically HTTP).
|
|
929
|
+
*
|
|
930
|
+
* @param {object} stream
|
|
931
|
+
* @param {object|string|function} [options]
|
|
932
|
+
* @param {function} [callback]
|
|
933
|
+
* @public
|
|
934
|
+
*/
|
|
935
|
+
|
|
936
|
+
function getRawBody (stream, options, callback) {
|
|
937
|
+
var done = callback;
|
|
938
|
+
var opts = options || {};
|
|
939
|
+
|
|
940
|
+
// light validation
|
|
941
|
+
if (stream === undefined) {
|
|
942
|
+
throw new TypeError('argument stream is required')
|
|
943
|
+
} else if (typeof stream !== 'object' || stream === null || typeof stream.on !== 'function') {
|
|
944
|
+
throw new TypeError('argument stream must be a stream')
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
if (options === true || typeof options === 'string') {
|
|
948
|
+
// short cut for encoding
|
|
949
|
+
opts = {
|
|
950
|
+
encoding: options
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
if (typeof options === 'function') {
|
|
955
|
+
done = options;
|
|
956
|
+
opts = {};
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// validate callback is a function, if provided
|
|
960
|
+
if (done !== undefined && typeof done !== 'function') {
|
|
961
|
+
throw new TypeError('argument callback must be a function')
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// require the callback without promises
|
|
965
|
+
if (!done && !global.Promise) {
|
|
966
|
+
throw new TypeError('argument callback is required')
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// get encoding
|
|
970
|
+
var encoding = opts.encoding !== true
|
|
971
|
+
? opts.encoding
|
|
972
|
+
: 'utf-8';
|
|
973
|
+
|
|
974
|
+
// convert the limit to an integer
|
|
975
|
+
var limit = bytes.parse(opts.limit);
|
|
976
|
+
|
|
977
|
+
// convert the expected length to an integer
|
|
978
|
+
var length = opts.length != null && !isNaN(opts.length)
|
|
979
|
+
? parseInt(opts.length, 10)
|
|
980
|
+
: null;
|
|
981
|
+
|
|
982
|
+
if (done) {
|
|
983
|
+
// classic callback style
|
|
984
|
+
return readStream(stream, encoding, length, limit, wrap(done))
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
return new Promise(function executor (resolve, reject) {
|
|
988
|
+
readStream(stream, encoding, length, limit, function onRead (err, buf) {
|
|
989
|
+
if (err) return reject(err)
|
|
990
|
+
resolve(buf);
|
|
991
|
+
});
|
|
992
|
+
})
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Halt a stream.
|
|
997
|
+
*
|
|
998
|
+
* @param {Object} stream
|
|
999
|
+
* @private
|
|
1000
|
+
*/
|
|
1001
|
+
|
|
1002
|
+
function halt (stream) {
|
|
1003
|
+
// unpipe everything from the stream
|
|
1004
|
+
unpipe(stream);
|
|
1005
|
+
|
|
1006
|
+
// pause stream
|
|
1007
|
+
if (typeof stream.pause === 'function') {
|
|
1008
|
+
stream.pause();
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Read the data from the stream.
|
|
1014
|
+
*
|
|
1015
|
+
* @param {object} stream
|
|
1016
|
+
* @param {string} encoding
|
|
1017
|
+
* @param {number} length
|
|
1018
|
+
* @param {number} limit
|
|
1019
|
+
* @param {function} callback
|
|
1020
|
+
* @public
|
|
1021
|
+
*/
|
|
1022
|
+
|
|
1023
|
+
function readStream (stream, encoding, length, limit, callback) {
|
|
1024
|
+
var complete = false;
|
|
1025
|
+
var sync = true;
|
|
1026
|
+
|
|
1027
|
+
// check the length and limit options.
|
|
1028
|
+
// note: we intentionally leave the stream paused,
|
|
1029
|
+
// so users should handle the stream themselves.
|
|
1030
|
+
if (limit !== null && length !== null && length > limit) {
|
|
1031
|
+
return done(createError(413, 'request entity too large', {
|
|
1032
|
+
expected: length,
|
|
1033
|
+
length: length,
|
|
1034
|
+
limit: limit,
|
|
1035
|
+
type: 'entity.too.large'
|
|
1036
|
+
}))
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// streams1: assert request encoding is buffer.
|
|
1040
|
+
// streams2+: assert the stream encoding is buffer.
|
|
1041
|
+
// stream._decoder: streams1
|
|
1042
|
+
// state.encoding: streams2
|
|
1043
|
+
// state.decoder: streams2, specifically < 0.10.6
|
|
1044
|
+
var state = stream._readableState;
|
|
1045
|
+
if (stream._decoder || (state && (state.encoding || state.decoder))) {
|
|
1046
|
+
// developer error
|
|
1047
|
+
return done(createError(500, 'stream encoding should not be set', {
|
|
1048
|
+
type: 'stream.encoding.set'
|
|
1049
|
+
}))
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
if (typeof stream.readable !== 'undefined' && !stream.readable) {
|
|
1053
|
+
return done(createError(500, 'stream is not readable', {
|
|
1054
|
+
type: 'stream.not.readable'
|
|
1055
|
+
}))
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
var received = 0;
|
|
1059
|
+
var decoder;
|
|
1060
|
+
|
|
1061
|
+
try {
|
|
1062
|
+
decoder = getDecoder(encoding);
|
|
1063
|
+
} catch (err) {
|
|
1064
|
+
return done(err)
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
var buffer = decoder
|
|
1068
|
+
? ''
|
|
1069
|
+
: [];
|
|
1070
|
+
|
|
1071
|
+
// attach listeners
|
|
1072
|
+
stream.on('aborted', onAborted);
|
|
1073
|
+
stream.on('close', cleanup);
|
|
1074
|
+
stream.on('data', onData);
|
|
1075
|
+
stream.on('end', onEnd);
|
|
1076
|
+
stream.on('error', onEnd);
|
|
1077
|
+
|
|
1078
|
+
// mark sync section complete
|
|
1079
|
+
sync = false;
|
|
1080
|
+
|
|
1081
|
+
function done () {
|
|
1082
|
+
var args = new Array(arguments.length);
|
|
1083
|
+
|
|
1084
|
+
// copy arguments
|
|
1085
|
+
for (var i = 0; i < args.length; i++) {
|
|
1086
|
+
args[i] = arguments[i];
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
// mark complete
|
|
1090
|
+
complete = true;
|
|
1091
|
+
|
|
1092
|
+
if (sync) {
|
|
1093
|
+
process.nextTick(invokeCallback);
|
|
1094
|
+
} else {
|
|
1095
|
+
invokeCallback();
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
function invokeCallback () {
|
|
1099
|
+
cleanup();
|
|
1100
|
+
|
|
1101
|
+
if (args[0]) {
|
|
1102
|
+
// halt the stream on error
|
|
1103
|
+
halt(stream);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
callback.apply(null, args);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
function onAborted () {
|
|
1111
|
+
if (complete) return
|
|
1112
|
+
|
|
1113
|
+
done(createError(400, 'request aborted', {
|
|
1114
|
+
code: 'ECONNABORTED',
|
|
1115
|
+
expected: length,
|
|
1116
|
+
length: length,
|
|
1117
|
+
received: received,
|
|
1118
|
+
type: 'request.aborted'
|
|
1119
|
+
}));
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
function onData (chunk) {
|
|
1123
|
+
if (complete) return
|
|
1124
|
+
|
|
1125
|
+
received += chunk.length;
|
|
1126
|
+
|
|
1127
|
+
if (limit !== null && received > limit) {
|
|
1128
|
+
done(createError(413, 'request entity too large', {
|
|
1129
|
+
limit: limit,
|
|
1130
|
+
received: received,
|
|
1131
|
+
type: 'entity.too.large'
|
|
1132
|
+
}));
|
|
1133
|
+
} else if (decoder) {
|
|
1134
|
+
buffer += decoder.write(chunk);
|
|
1135
|
+
} else {
|
|
1136
|
+
buffer.push(chunk);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
function onEnd (err) {
|
|
1141
|
+
if (complete) return
|
|
1142
|
+
if (err) return done(err)
|
|
1143
|
+
|
|
1144
|
+
if (length !== null && received !== length) {
|
|
1145
|
+
done(createError(400, 'request size did not match content length', {
|
|
1146
|
+
expected: length,
|
|
1147
|
+
length: length,
|
|
1148
|
+
received: received,
|
|
1149
|
+
type: 'request.size.invalid'
|
|
1150
|
+
}));
|
|
1151
|
+
} else {
|
|
1152
|
+
var string = decoder
|
|
1153
|
+
? buffer + (decoder.end() || '')
|
|
1154
|
+
: Buffer.concat(buffer);
|
|
1155
|
+
done(null, string);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
function cleanup () {
|
|
1160
|
+
buffer = null;
|
|
1161
|
+
|
|
1162
|
+
stream.removeListener('aborted', onAborted);
|
|
1163
|
+
stream.removeListener('data', onData);
|
|
1164
|
+
stream.removeListener('end', onEnd);
|
|
1165
|
+
stream.removeListener('error', onEnd);
|
|
1166
|
+
stream.removeListener('close', cleanup);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* Try to require async_hooks
|
|
1172
|
+
* @private
|
|
1173
|
+
*/
|
|
1174
|
+
|
|
1175
|
+
function tryRequireAsyncHooks () {
|
|
1176
|
+
try {
|
|
1177
|
+
return require('async_hooks')
|
|
1178
|
+
} catch (e) {
|
|
1179
|
+
return {}
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Wrap function with async resource, if possible.
|
|
1185
|
+
* AsyncResource.bind static method backported.
|
|
1186
|
+
* @private
|
|
1187
|
+
*/
|
|
1188
|
+
|
|
1189
|
+
function wrap (fn) {
|
|
1190
|
+
var res;
|
|
1191
|
+
|
|
1192
|
+
// create anonymous resource
|
|
1193
|
+
if (asyncHooks.AsyncResource) {
|
|
1194
|
+
res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn');
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
// incompatible node.js
|
|
1198
|
+
if (!res || !res.runInAsyncScope) {
|
|
1199
|
+
return fn
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
// return bound function
|
|
1203
|
+
return res.runInAsyncScope.bind(res, fn, null)
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
1207
|
+
__proto__: null
|
|
1208
|
+
});
|
|
1209
|
+
|
|
886
1210
|
exports.API_ROUTE_NAMES = API_ROUTE_NAMES;
|
|
887
1211
|
exports.API_WEBHOOK_TOPICS = API_WEBHOOK_TOPICS;
|
|
888
1212
|
exports.AUTH_TYPES = AUTH_TYPES;
|