@agnostack/next-shopify 1.15.0-beta.8 → 1.15.0
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 +196 -0
- package/README.md +9 -8
- package/dist/lib/handlers/api/auth.js +15 -11
- package/dist/lib/handlers/api/auth.js.map +1 -1
- package/dist/lib/handlers/api/billing.js +13 -9
- package/dist/lib/handlers/api/billing.js.map +1 -1
- package/dist/lib/handlers/api/callback.js +37 -33
- package/dist/lib/handlers/api/callback.js.map +1 -1
- package/dist/lib/handlers/api/index.js +25 -7
- package/dist/lib/handlers/api/index.js.map +1 -1
- package/dist/lib/handlers/api/uninstall.js +12 -8
- package/dist/lib/handlers/api/uninstall.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/appInstallation.js +11 -7
- package/dist/lib/handlers/api/verifiable/appInstallation.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/graph.js +26 -22
- package/dist/lib/handlers/api/verifiable/graph.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/index.js +21 -5
- package/dist/lib/handlers/api/verifiable/index.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/proxy.js +39 -32
- package/dist/lib/handlers/api/verifiable/proxy.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/rest.js +23 -19
- package/dist/lib/handlers/api/verifiable/rest.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/token.js +27 -23
- package/dist/lib/handlers/api/verifiable/token.js.map +1 -1
- package/dist/lib/handlers/api/webhook.js +13 -9
- package/dist/lib/handlers/api/webhook.js.map +1 -1
- package/dist/lib/handlers/index.js +18 -2
- package/dist/lib/handlers/index.js.map +1 -1
- package/dist/lib/handlers/ssr/index.js +18 -2
- package/dist/lib/handlers/ssr/index.js.map +1 -1
- package/dist/lib/handlers/ssr/protect.js +24 -17
- package/dist/lib/handlers/ssr/protect.js.map +1 -1
- package/dist/lib/handlers/ssr/wrap.js +10 -6
- package/dist/lib/handlers/ssr/wrap.js.map +1 -1
- package/dist/lib/index.js +23 -4
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/utils/billing.js +23 -18
- package/dist/lib/utils/billing.js.map +1 -1
- package/dist/lib/utils/crypto.js +25 -15
- package/dist/lib/utils/crypto.js.map +1 -1
- package/dist/lib/utils/firebase.js +29 -17
- package/dist/lib/utils/firebase.js.map +1 -1
- package/dist/lib/utils/headers.js +13 -6
- package/dist/lib/utils/headers.js.map +1 -1
- package/dist/lib/utils/index.js +24 -8
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/session.js +64 -59
- package/dist/lib/utils/session.js.map +1 -1
- package/dist/lib/utils/shopify-api-js/oauth.js +23 -16
- package/dist/lib/utils/shopify-api-js/oauth.js.map +1 -1
- package/dist/lib/utils/shopify.js +37 -25
- package/dist/lib/utils/shopify.js.map +1 -1
- package/dist/lib/utils/token.js +15 -11
- package/dist/lib/utils/token.js.map +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +18 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/withShopify.js +83 -77
- package/dist/plugins/withShopify.js.map +1 -1
- package/dist/react/hooks/index.js +17 -1
- package/dist/react/hooks/index.js.map +1 -1
- package/dist/react/hooks/useVerification.d.ts +1 -1
- package/dist/react/hooks/useVerification.js +23 -7
- package/dist/react/hooks/useVerification.js.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +18 -1
- package/dist/react/index.js.map +1 -1
- package/dist/runtime/index.js +17 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/shared/WebCrypto.d.ts +55 -0
- package/dist/shared/WebCrypto.d.ts.map +1 -0
- package/dist/shared/WebCrypto.js +342 -0
- package/dist/shared/WebCrypto.js.map +1 -0
- package/dist/shared/constants.js +15 -11
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/datetime.js +110 -83
- package/dist/shared/datetime.js.map +1 -1
- package/dist/shared/display.js +231 -151
- package/dist/shared/display.js.map +1 -1
- package/dist/shared/errors.js +12 -5
- package/dist/shared/errors.js.map +1 -1
- package/dist/shared/graph.js +14 -11
- package/dist/shared/graph.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +32 -11
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/match.js +25 -17
- package/dist/shared/match.js.map +1 -1
- package/dist/shared/request.js +19 -13
- package/dist/shared/request.js.map +1 -1
- package/dist/shared/shopify.js +31 -21
- package/dist/shared/shopify.js.map +1 -1
- package/dist/shared/uuid.js +8 -3
- package/dist/shared/uuid.js.map +1 -1
- package/dist/shared/verification.d.ts +12 -5
- package/dist/shared/verification.d.ts.map +1 -1
- package/dist/shared/verification.js +34 -22
- package/dist/shared/verification.js.map +1 -1
- package/dist/umd/verification/index.js +1234 -0
- package/dist/umd/verification/index.js.map +1 -0
- package/dist/umd/verification/plugins/index.d.ts +3 -0
- package/dist/umd/{plugins → verification/plugins}/index.d.ts.map +1 -1
- package/dist/umd/{react → verification/react}/hooks/useVerification.d.ts +1 -1
- package/dist/umd/verification/react/index.d.ts +3 -0
- package/dist/umd/verification/react/index.d.ts.map +1 -0
- package/dist/umd/verification/shared/WebCrypto.d.ts +55 -0
- package/dist/umd/verification/shared/WebCrypto.d.ts.map +1 -0
- package/dist/umd/{shared → verification/shared}/index.d.ts +1 -1
- package/dist/umd/{shared → verification/shared}/index.d.ts.map +1 -1
- package/dist/umd/{shared → verification/shared}/verification.d.ts +12 -5
- package/dist/umd/{shared → verification/shared}/verification.d.ts.map +1 -1
- package/dist/umd/verification/verification/index.d.ts +4 -0
- package/dist/umd/verification/{index.d.ts.map → verification/index.d.ts.map} +1 -1
- package/dist/umd/verification/{utils → verification/utils}/rawbody.d.ts.map +1 -1
- package/dist/umd/verification/verification/verification.d.ts +10 -0
- package/dist/umd/verification/{verification.d.ts.map → verification/verification.d.ts.map} +1 -1
- package/dist/verification/index.d.ts +2 -0
- package/dist/verification/index.d.ts.map +1 -1
- package/dist/verification/index.js +19 -1
- package/dist/verification/index.js.map +1 -1
- package/dist/verification/utils/errors.js +5 -1
- package/dist/verification/utils/errors.js.map +1 -1
- package/dist/verification/utils/index.js +18 -2
- package/dist/verification/utils/index.js.map +1 -1
- package/dist/verification/utils/rawbody.d.ts.map +1 -1
- package/dist/verification/utils/rawbody.js +39 -36
- package/dist/verification/utils/rawbody.js.map +1 -1
- package/dist/verification/verification.d.ts +3 -1
- package/dist/verification/verification.d.ts.map +1 -1
- package/dist/verification/verification.js +71 -61
- package/dist/verification/verification.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 +15 -14
- package/dist/shared/subtlecrypto.d.ts +0 -41
- package/dist/shared/subtlecrypto.d.ts.map +0 -1
- package/dist/shared/subtlecrypto.js +0 -256
- package/dist/shared/subtlecrypto.js.map +0 -1
- package/dist/umd/plugins/index.d.ts +0 -2
- package/dist/umd/react/index.d.ts +0 -2
- package/dist/umd/react/index.d.ts.map +0 -1
- package/dist/umd/shared/subtlecrypto.d.ts +0 -41
- package/dist/umd/shared/subtlecrypto.d.ts.map +0 -1
- package/dist/umd/verification/index.d.ts +0 -2
- package/dist/umd/verification/verification.d.ts +0 -8
- package/dist/umd/verification.js +0 -641
- package/dist/umd/verification.js.map +0 -1
- /package/dist/umd/{lib → verification/lib}/handlers/api/auth.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/auth.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/billing.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/billing.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/callback.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/callback.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/index.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/index.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/types.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/types.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/uninstall.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/uninstall.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/appInstallation.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/appInstallation.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/graph.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/graph.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/index.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/index.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/proxy.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/proxy.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/rest.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/rest.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/token.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/verifiable/token.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/webhook.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/api/webhook.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/index.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/index.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/ssr/index.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/ssr/index.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/ssr/protect.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/ssr/protect.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/ssr/types.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/ssr/types.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/ssr/wrap.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/ssr/wrap.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/types.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/handlers/types.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/index.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/index.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/types.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/types.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/billing.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/billing.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/crypto.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/crypto.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/firebase.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/firebase.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/headers.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/headers.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/index.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/index.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/session.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/session.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/shopify-api-js/oauth.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/shopify-api-js/oauth.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/shopify.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/shopify.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/token.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/token.d.ts.map +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/types.d.ts +0 -0
- /package/dist/umd/{lib → verification/lib}/utils/types.d.ts.map +0 -0
- /package/dist/umd/{plugins → verification/plugins}/types.d.ts +0 -0
- /package/dist/umd/{plugins → verification/plugins}/types.d.ts.map +0 -0
- /package/dist/umd/{plugins → verification/plugins}/withShopify.d.ts +0 -0
- /package/dist/umd/{plugins → verification/plugins}/withShopify.d.ts.map +0 -0
- /package/dist/umd/{react → verification/react}/hooks/index.d.ts +0 -0
- /package/dist/umd/{react → verification/react}/hooks/index.d.ts.map +0 -0
- /package/dist/umd/{react → verification/react}/hooks/useVerification.d.ts.map +0 -0
- /package/dist/umd/{react → verification/react}/types.d.ts +0 -0
- /package/dist/umd/{react → verification/react}/types.d.ts.map +0 -0
- /package/dist/umd/{runtime → verification/runtime}/index.d.ts +0 -0
- /package/dist/umd/{runtime → verification/runtime}/index.d.ts.map +0 -0
- /package/dist/umd/{runtime → verification/runtime}/types.d.ts +0 -0
- /package/dist/umd/{runtime → verification/runtime}/types.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/constants.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/constants.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/datetime.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/datetime.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/display.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/display.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/errors.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/errors.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/graph.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/graph.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/match.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/match.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/request.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/request.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/shopify.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/shopify.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/types.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/types.d.ts.map +0 -0
- /package/dist/umd/{shared → verification/shared}/uuid.d.ts +0 -0
- /package/dist/umd/{shared → verification/shared}/uuid.d.ts.map +0 -0
- /package/dist/umd/verification/{types.d.ts → verification/types.d.ts} +0 -0
- /package/dist/umd/verification/{types.d.ts.map → verification/types.d.ts.map} +0 -0
- /package/dist/umd/verification/{utils → verification/utils}/errors.d.ts +0 -0
- /package/dist/umd/verification/{utils → verification/utils}/errors.d.ts.map +0 -0
- /package/dist/umd/verification/{utils → verification/utils}/index.d.ts +0 -0
- /package/dist/umd/verification/{utils → verification/utils}/index.d.ts.map +0 -0
- /package/dist/umd/verification/{utils → verification/utils}/rawbody.d.ts +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18,12 +19,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
19
|
}
|
|
19
20
|
return t;
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.handleRest = void 0;
|
|
24
|
+
const shopify_api_1 = require("@shopify/shopify-api");
|
|
25
|
+
const utils_1 = require("../../../utils");
|
|
26
|
+
const shared_1 = require("../../../../shared");
|
|
27
|
+
const verification_1 = require("../../../../verification");
|
|
28
|
+
const handleRest = (serverRuntimeConfig) => {
|
|
29
|
+
const _getVerificationHelpers = (0, verification_1.getVerificationHelpers)(serverRuntimeConfig);
|
|
27
30
|
return (req, res, _params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
31
|
let requestBody;
|
|
29
32
|
let processResponse;
|
|
@@ -31,7 +34,7 @@ export const handleRest = (serverRuntimeConfig) => {
|
|
|
31
34
|
({ requestBody, processResponse } = yield _getVerificationHelpers(req));
|
|
32
35
|
}
|
|
33
36
|
catch (error) {
|
|
34
|
-
if (error instanceof VerificationError) {
|
|
37
|
+
if (error instanceof verification_1.VerificationError) {
|
|
35
38
|
return res.status(error.code).json(Object.assign({ message: error.message }, error.data));
|
|
36
39
|
}
|
|
37
40
|
return res.status(403).json({ message: 'Verification error' });
|
|
@@ -39,7 +42,7 @@ export const handleRest = (serverRuntimeConfig) => {
|
|
|
39
42
|
const { query: _query, method: _method } = req;
|
|
40
43
|
const { shop } = _query !== null && _query !== void 0 ? _query : {};
|
|
41
44
|
const _a = _params !== null && _params !== void 0 ? _params : {}, { path, isOnline, method: methodParam, query: queryParam, body: bodyParam, transform = (_data) => _data } = _a, params = __rest(_a, ["path", "isOnline", "method", "query", "body", "transform"]);
|
|
42
|
-
if (stringEmpty(shop) || stringEmpty(path)) {
|
|
45
|
+
if ((0, shared_1.stringEmpty)(shop) || (0, shared_1.stringEmpty)(path)) {
|
|
43
46
|
return {
|
|
44
47
|
statusCode: 400,
|
|
45
48
|
message: 'Invalid arguments',
|
|
@@ -51,17 +54,17 @@ export const handleRest = (serverRuntimeConfig) => {
|
|
|
51
54
|
let headers = {};
|
|
52
55
|
try {
|
|
53
56
|
let queryData = queryParam !== null && queryParam !== void 0 ? queryParam : _query;
|
|
54
|
-
if (isType(queryData, 'string')) {
|
|
55
|
-
queryData = querystringToObject(queryData);
|
|
57
|
+
if ((0, shared_1.isType)(queryData, 'string')) {
|
|
58
|
+
queryData = (0, shared_1.querystringToObject)(queryData);
|
|
56
59
|
}
|
|
57
|
-
const _b = ensureObject(queryData), { apiVersion } = _b, query = __rest(_b, ["apiVersion"]);
|
|
58
|
-
const body = safeParse(bodyParam !== null && bodyParam !== void 0 ? bodyParam : requestBody);
|
|
59
|
-
const method = ensureString(methodParam !== null && methodParam !== void 0 ? methodParam : _method).toLowerCase();
|
|
60
|
-
const { getVerifiedClients } = yield getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
60
|
+
const _b = (0, shared_1.ensureObject)(queryData), { apiVersion } = _b, query = __rest(_b, ["apiVersion"]);
|
|
61
|
+
const body = (0, shared_1.safeParse)(bodyParam !== null && bodyParam !== void 0 ? bodyParam : requestBody);
|
|
62
|
+
const method = (0, shared_1.ensureString)(methodParam !== null && methodParam !== void 0 ? methodParam : _method).toLowerCase();
|
|
63
|
+
const { getVerifiedClients } = yield (0, utils_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
|
|
61
64
|
const { Rest } = yield getVerifiedClients({ req, res, shop, apiVersion, isOnline });
|
|
62
65
|
response = yield Rest[method](Object.assign({ path,
|
|
63
66
|
query,
|
|
64
|
-
body, type: DataType.JSON }, params));
|
|
67
|
+
body, type: shopify_api_1.DataType.JSON }, params));
|
|
65
68
|
statusCode = 200;
|
|
66
69
|
}
|
|
67
70
|
catch (error) {
|
|
@@ -69,15 +72,15 @@ export const handleRest = (serverRuntimeConfig) => {
|
|
|
69
72
|
statusCode = 500;
|
|
70
73
|
// TODO: clean up to share between rest and graph (pr at least keep in sync)
|
|
71
74
|
switch (true) {
|
|
72
|
-
case error instanceof ShopifyAuthenticationError: {
|
|
75
|
+
case error instanceof shared_1.ShopifyAuthenticationError: {
|
|
73
76
|
console.error(`${message}. Authentication Error.`, error);
|
|
74
|
-
const errorResponse = getAuthErrorResponse(serverRuntimeConfig, { error, shop });
|
|
77
|
+
const errorResponse = (0, utils_1.getAuthErrorResponse)(serverRuntimeConfig, { error, shop });
|
|
75
78
|
statusCode = errorResponse.statusCode;
|
|
76
79
|
message = errorResponse.message;
|
|
77
80
|
headers = errorResponse.headers;
|
|
78
81
|
break;
|
|
79
82
|
}
|
|
80
|
-
case error instanceof BillingError: {
|
|
83
|
+
case error instanceof shopify_api_1.BillingError: {
|
|
81
84
|
console.error(`${message}. Billing Error - ${error.message}.`, error.errorData);
|
|
82
85
|
statusCode = 402;
|
|
83
86
|
if (error === null || error === void 0 ? void 0 : error.message) {
|
|
@@ -99,7 +102,7 @@ export const handleRest = (serverRuntimeConfig) => {
|
|
|
99
102
|
return res.status(statusCode).json(transformedResponse);
|
|
100
103
|
}
|
|
101
104
|
// HMMMMM???
|
|
102
|
-
if ((params === null || params === void 0 ? void 0 : params.type) && ![DataType.GraphQL, DataType.JSON].includes(params.type)) {
|
|
105
|
+
if ((params === null || params === void 0 ? void 0 : params.type) && ![shopify_api_1.DataType.GraphQL, shopify_api_1.DataType.JSON].includes(params.type)) {
|
|
103
106
|
const transformedResponse = yield processResponse(response);
|
|
104
107
|
return res.status(statusCode).send(transformedResponse);
|
|
105
108
|
}
|
|
@@ -111,4 +114,5 @@ export const handleRest = (serverRuntimeConfig) => {
|
|
|
111
114
|
return res.status(statusCode).json(transformedResponse);
|
|
112
115
|
});
|
|
113
116
|
};
|
|
117
|
+
exports.handleRest = handleRest;
|
|
114
118
|
//# sourceMappingURL=rest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/rest.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/rest.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA6D;AAE7D,0CAAwE;AACxE,+C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xD;QAED,YAAY;QACZ,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,CAAC,CAAC,sBAAQ,CAAC,OAAO,EAAE,sBAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5E,MAAM,mBAAmB,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAA;YAC3D,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;SACxD;QAED,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAA,EAAE;YACnB,MAAM,mBAAmB,GAAG,MAAM,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;YAC9D,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;SACxD;QAED,MAAM,mBAAmB,GAAG,MAAM,eAAe,CAC/C,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CACzB,CAAA;QACD,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IACzD,CAAC,CAAA,CAAA;AACH,CAAC,CAAA;AAtHY,QAAA,UAAU,cAsHtB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18,17 +19,19 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
19
|
}
|
|
19
20
|
return t;
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.handleSessionToken = void 0;
|
|
24
|
+
const js_base64_1 = require("js-base64");
|
|
25
|
+
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
26
|
+
const uuid_1 = require("uuid");
|
|
27
|
+
const utils_1 = require("../../../utils");
|
|
28
|
+
const shared_1 = require("../../../../shared");
|
|
29
|
+
const verification_1 = require("../../../../verification");
|
|
27
30
|
// NOTE: typically handling: "/api/token"
|
|
28
|
-
|
|
31
|
+
const handleSessionToken = (serverRuntimeConfig, _a = {}) => {
|
|
29
32
|
var { signingSecret: _signingSecret } = _a, signingData = __rest(_a, ["signingSecret"]);
|
|
30
33
|
const { APP_CONFIG } = serverRuntimeConfig !== null && serverRuntimeConfig !== void 0 ? serverRuntimeConfig : {};
|
|
31
|
-
const _getVerificationHelpers = getVerificationHelpers(serverRuntimeConfig);
|
|
34
|
+
const _getVerificationHelpers = (0, verification_1.getVerificationHelpers)(serverRuntimeConfig);
|
|
32
35
|
return (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
36
|
var _b, _c;
|
|
34
37
|
const { host } = (_b = req.query) !== null && _b !== void 0 ? _b : {};
|
|
@@ -36,7 +39,7 @@ export const handleSessionToken = (serverRuntimeConfig, _a = {}) => {
|
|
|
36
39
|
// TODO: pass along providerSetId??
|
|
37
40
|
'x-client-id': clientId, 'x-shop-domain': shopDomain, 'x-shopify-shop-domain': shopifyShopDomain, 'x-shopify-shop': shop = shopifyShopDomain !== null && shopifyShopDomain !== void 0 ? shopifyShopDomain : shopDomain } = _d, headers = __rest(_d, ['x-shopify-app-installation-id', 'x-shopify-app-id', 'x-app-installation-id', 'x-app-id', 'x-client-id', 'x-shop-domain', 'x-shopify-shop-domain', 'x-shopify-shop']);
|
|
38
41
|
// TODO: un-btoa the host and check??
|
|
39
|
-
if (stringEmpty(shop) || stringEmpty(host)) {
|
|
42
|
+
if ((0, shared_1.stringEmpty)(shop) || (0, shared_1.stringEmpty)(host)) {
|
|
40
43
|
return res.status(412).json({ message: 'Missing required param' });
|
|
41
44
|
}
|
|
42
45
|
let requestBody;
|
|
@@ -45,29 +48,29 @@ export const handleSessionToken = (serverRuntimeConfig, _a = {}) => {
|
|
|
45
48
|
({ requestBody, processResponse } = yield _getVerificationHelpers(req));
|
|
46
49
|
}
|
|
47
50
|
catch (error) {
|
|
48
|
-
if (error instanceof VerificationError) {
|
|
51
|
+
if (error instanceof verification_1.VerificationError) {
|
|
49
52
|
return res.status(error.code).json(Object.assign({ message: error.message }, error.data));
|
|
50
53
|
}
|
|
51
54
|
return res.status(403).json({ message: 'Verification error' });
|
|
52
55
|
}
|
|
53
56
|
try {
|
|
54
57
|
const appClaims = Object.entries(headers).reduce((_appClaims, [headerKey, headerValue]) => (Object.assign(Object.assign({}, _appClaims), headerKey.startsWith('x-shopify-app-metafield-') && {
|
|
55
|
-
[snakecase(headerKey.replace('x-shopify-app-metafield-', ''))]: headerValue,
|
|
56
|
-
})), Object.assign(Object.assign({}, appId && { app_id: normalizeShopifyId(appId).id }), appInstallationId && { installation_id: normalizeShopifyId(appInstallationId).id }));
|
|
58
|
+
[(0, shared_1.snakecase)(headerKey.replace('x-shopify-app-metafield-', ''))]: headerValue,
|
|
59
|
+
})), Object.assign(Object.assign({}, appId && { app_id: (0, shared_1.normalizeShopifyId)(appId).id }), appInstallationId && { installation_id: (0, shared_1.normalizeShopifyId)(appInstallationId).id }));
|
|
57
60
|
const _e = requestBody !== null && requestBody !== void 0 ? requestBody : {}, { sub, aud: _aud } = _e, body = __rest(_e, ["sub", "aud"]);
|
|
58
|
-
const aud = [clientId, _aud, APP_CONFIG.apiKey].find(stringNotEmpty);
|
|
61
|
+
const aud = [clientId, _aud, APP_CONFIG.apiKey].find(shared_1.stringNotEmpty);
|
|
59
62
|
let { dest, iss, sid, jti } = body, tokenBody = __rest(body, ["dest", "iss", "sid", "jti"]);
|
|
60
|
-
if (stringEmpty(dest)) {
|
|
63
|
+
if ((0, shared_1.stringEmpty)(dest)) {
|
|
61
64
|
dest = shop;
|
|
62
65
|
}
|
|
63
|
-
if (stringEmpty(iss)) {
|
|
64
|
-
iss = decode(host);
|
|
66
|
+
if ((0, shared_1.stringEmpty)(iss)) {
|
|
67
|
+
iss = (0, js_base64_1.decode)(host);
|
|
65
68
|
}
|
|
66
|
-
if (stringEmpty(sid)) {
|
|
67
|
-
sid =
|
|
69
|
+
if ((0, shared_1.stringEmpty)(sid)) {
|
|
70
|
+
sid = (0, uuid_1.v4)();
|
|
68
71
|
}
|
|
69
|
-
if (stringEmpty(jti)) {
|
|
70
|
-
jti =
|
|
72
|
+
if ((0, shared_1.stringEmpty)(jti)) {
|
|
73
|
+
jti = (0, uuid_1.v4)();
|
|
71
74
|
sid = `${sid}.${jti}`;
|
|
72
75
|
}
|
|
73
76
|
const payload = Object.assign(Object.assign(Object.assign({ shop,
|
|
@@ -78,9 +81,9 @@ export const handleSessionToken = (serverRuntimeConfig, _a = {}) => {
|
|
|
78
81
|
sid,
|
|
79
82
|
aud }, sub && { sub }), appClaims), tokenBody);
|
|
80
83
|
// NOTE: signingSecret should only be sent in here from the /api/token/zendesk endpoint
|
|
81
|
-
const signingSecret = _signingSecret || generateHMAC(objectToSortedString(payload), APP_CONFIG.apiSecretKey);
|
|
82
|
-
const token = sign(payload, signingSecret, signingData);
|
|
83
|
-
if (stringEmpty(token)) {
|
|
84
|
+
const signingSecret = _signingSecret || (0, utils_1.generateHMAC)((0, shared_1.objectToSortedString)(payload), APP_CONFIG.apiSecretKey);
|
|
85
|
+
const token = (0, jsonwebtoken_1.sign)(payload, signingSecret, signingData);
|
|
86
|
+
if ((0, shared_1.stringEmpty)(token)) {
|
|
84
87
|
throw new Error('Error signing token');
|
|
85
88
|
}
|
|
86
89
|
const response = yield processResponse({ token });
|
|
@@ -92,4 +95,5 @@ export const handleSessionToken = (serverRuntimeConfig, _a = {}) => {
|
|
|
92
95
|
}
|
|
93
96
|
});
|
|
94
97
|
};
|
|
98
|
+
exports.handleSessionToken = handleSessionToken;
|
|
95
99
|
//# sourceMappingURL=token.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/token.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/token.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAkC;AAClC,+CAAmC;AACnC,+BAAmC;AAEnC,0CAA6C;AAC7C,+CAM2B;AAC3B,2DAAoF;AAEpF,yCAAyC;AAClC,MAAM,kBAAkB,GAAG,CAAC,mBAAmB,EAAE,KAAoD,EAAE,EAAE,EAAE;QAA1D,EAAE,aAAa,EAAE,cAAc,OAAuB,EAAlB,WAAW,cAA/C,iBAAiD,CAAF;IACrG,MAAM,EAAE,UAAU,EAAE,GAAG,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,EAAE,CAAA;IAChD,MAAM,uBAAuB,GAAG,IAAA,qCAAsB,EAAC,mBAAmB,CAAC,CAAA;IAE3E,OAAO,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;;QACxB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAA,GAAG,CAAC,KAAK,mCAAI,EAAE,CAAA;QAChC,MAAM,KAWF,MAAA,GAAG,CAAC,OAAO,mCAAI,EAAE,EAXf,EACJ,+BAA+B,EAAE,wBAAwB,EACzD,kBAAkB,EAAE,YAAY,EAChC,uBAAuB,EAAE,iBAAiB,GAAG,wBAAwB,EACrE,UAAU,EAAE,KAAK,GAAG,YAAY;QAChC,mCAAmC;QACnC,aAAa,EAAE,QAAQ,EACvB,eAAe,EAAE,UAAU,EAC3B,uBAAuB,EAAE,iBAAiB,EAC1C,gBAAgB,EAAE,IAAI,GAAG,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,UAAU,OAErC,EADhB,OAAO,cAVN,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CAAA;YAEvD,IAAI,IAAA,oBAAW,EAAC,KAAK,CAAC,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;aACvC;YAED,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;YAEjD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;SACtC;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAA;YACtD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC,CAAA;SAC3E;IACH,CAAC,CAAA,CAAA;AACH,CAAC,CAAA;AA/GY,QAAA,kBAAkB,sBA+G9B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18,24 +19,26 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
19
|
}
|
|
19
20
|
return t;
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.handleWebhookEvent = void 0;
|
|
24
|
+
const utils_1 = require("../../utils");
|
|
25
|
+
const verification_1 = require("../../../verification");
|
|
26
|
+
const shared_1 = require("../../../shared");
|
|
24
27
|
// NOTE: typically handling: "/api/webhooks/event" or "/api/webhooks/event/{appId}" or "/api/webhooks/event?appId={appId}"
|
|
25
|
-
|
|
28
|
+
const handleWebhookEvent = (serverRuntimeConfig, config) => (req, res, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
29
|
var _a;
|
|
27
30
|
const { ORIGIN_SAFELIST } = serverRuntimeConfig;
|
|
28
31
|
try {
|
|
29
32
|
const _b = (_a = req.headers) !== null && _a !== void 0 ? _a : {}, { 'x-shop-domain': shopDomain, 'x-shopify-shop-domain': shopifyShopDomain, 'x-shopify-shop': shop = shopifyShopDomain !== null && shopifyShopDomain !== void 0 ? shopifyShopDomain : shopDomain } = _b, _headers = __rest(_b, ['x-shop-domain', 'x-shopify-shop-domain', 'x-shopify-shop']);
|
|
30
|
-
if (stringEmpty(shop)) {
|
|
33
|
+
if ((0, shared_1.stringEmpty)(shop)) {
|
|
31
34
|
return res.status(200).json({ handler: 'webhook', error: 'Missing shop' });
|
|
32
35
|
}
|
|
33
|
-
if (!matchHostname(shop, ORIGIN_SAFELIST)) {
|
|
36
|
+
if (!(0, shared_1.matchHostname)(shop, ORIGIN_SAFELIST)) {
|
|
34
37
|
return res.status(200).json({ handler: 'webhook', error: 'Shop is not safelisted' });
|
|
35
38
|
}
|
|
36
|
-
const { shopify } = yield getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
39
|
+
const { shopify } = yield (0, utils_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
|
|
37
40
|
// TODO: explore getVerificationHelpers?
|
|
38
|
-
const rawBody = yield ensureRawBody(req);
|
|
41
|
+
const rawBody = yield (0, verification_1.ensureRawBody)(req);
|
|
39
42
|
const _c = (serverRuntimeConfig.SHOPIFY_RUN_MODE === 'cli') ? {
|
|
40
43
|
valid: true,
|
|
41
44
|
topic: _headers['x-shopify-topic'],
|
|
@@ -53,7 +56,7 @@ export const handleWebhookEvent = (serverRuntimeConfig, config) => (req, res, da
|
|
|
53
56
|
const { topic, domain, webhookId, apiVersion, rawBody: eventRawBody } = message;
|
|
54
57
|
const eventBody = JSON.parse(eventRawBody);
|
|
55
58
|
// NOTE: this callback signature matches the built in callback option PLUS data
|
|
56
|
-
const topicHandlePromises = ensureArray(config === null || config === void 0 ? void 0 : config[convertEventTopic(topic)]).map((handler) => handler({
|
|
59
|
+
const topicHandlePromises = (0, shared_1.ensureArray)(config === null || config === void 0 ? void 0 : config[(0, shared_1.convertEventTopic)(topic)]).map((handler) => handler({
|
|
57
60
|
apiVersion,
|
|
58
61
|
webhookId,
|
|
59
62
|
topic,
|
|
@@ -87,4 +90,5 @@ export const handleWebhookEvent = (serverRuntimeConfig, config) => (req, res, da
|
|
|
87
90
|
return res.status(200).json({ handler: 'webhook', error: 'Error handling webhook' });
|
|
88
91
|
}
|
|
89
92
|
});
|
|
93
|
+
exports.handleWebhookEvent = handleWebhookEvent;
|
|
90
94
|
//# sourceMappingURL=webhook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../../../src/lib/handlers/api/webhook.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../../../src/lib/handlers/api/webhook.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA+C;AAC/C,wDAAqD;AACrD,4CAKwB;AAExB,0HAA0H;AACnH,MAAM,kBAAkB,GAAG,CAAC,mBAAmB,EAAE,MAAM,EAAE,EAAE,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;;IAC1F,MAAM,EAAE,eAAe,EAAE,GAAG,mBAAmB,CAAA;IAC/C,IAAI;QACF,MAAM,KAKF,MAAA,GAAG,CAAC,OAAO,mCAAI,EAAE,EALf,EACJ,eAAe,EAAE,UAAU,EAC3B,uBAAuB,EAAE,iBAAiB,EAC1C,gBAAgB,EAAE,IAAI,GAAG,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,UAAU,OAErC,EADhB,QAAQ,cAJP,4DAKL,CAAoB,CAAA;QAErB,IAAI,IAAA,oBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI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E,CAAC,CAAA;aAC3E;SACF;QAED,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAA;QACnD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,4BAA4B,EAAE,OAAO,EAAE,CAAC,CAAA;KAClG;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAA;QAC9C,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAA;KACrF;AACH,CAAC,CAAA,CAAA;AAvFY,QAAA,kBAAkB,sBAuF9B"}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api"), exports);
|
|
18
|
+
__exportStar(require("./ssr"), exports);
|
|
3
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/handlers/index.js"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/handlers/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AACrB,wCAAqB"}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./protect"), exports);
|
|
18
|
+
__exportStar(require("./wrap"), exports);
|
|
3
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/handlers/ssr/index.js"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/handlers/ssr/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,yCAAsB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,41 +8,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.protectRoute = void 0;
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const utils_1 = require("../../utils");
|
|
18
|
+
const shared_1 = require("../../../shared");
|
|
19
|
+
const protectRoute = (serverRuntimeConfig, props) => ({ req, res, query, locale, } = {}, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
20
|
var _a, _b, _c, _d;
|
|
15
21
|
const { PAGE_PATHS, API_PATHS } = serverRuntimeConfig;
|
|
16
22
|
const shop = (_a = query === null || query === void 0 ? void 0 : query.shop) !== null && _a !== void 0 ? _a : (_b = req.query) === null || _b === void 0 ? void 0 : _b.shop;
|
|
17
23
|
const embedded = (_c = query === null || query === void 0 ? void 0 : query.embedded) !== null && _c !== void 0 ? _c : (_d = req.query) === null || _d === void 0 ? void 0 : _d.embedded;
|
|
18
|
-
if (stringEmpty(shop)) {
|
|
24
|
+
if ((0, shared_1.stringEmpty)(shop)) {
|
|
19
25
|
return {
|
|
20
26
|
redirect: {
|
|
21
|
-
destination: `${PAGE_PATHS[PAGE_ROUTE_NAMES.ERROR]}?code=no_shop_provided&type=protectRoute`,
|
|
27
|
+
destination: `${PAGE_PATHS[shared_1.PAGE_ROUTE_NAMES.ERROR]}?code=no_shop_provided&type=protectRoute`,
|
|
22
28
|
permanent: false,
|
|
23
29
|
},
|
|
24
30
|
};
|
|
25
31
|
}
|
|
26
32
|
// NOTE: this should handle running in next to test non-shopify functionality
|
|
27
|
-
const shouldBypassProtect = allowLocalBypass(serverRuntimeConfig);
|
|
33
|
+
const shouldBypassProtect = (0, utils_1.allowLocalBypass)(serverRuntimeConfig);
|
|
28
34
|
if (shouldBypassProtect) {
|
|
29
|
-
console.info(`${
|
|
35
|
+
console.info(`${chalk_1.default.yellowBright('next-shopify')} - [${chalk_1.default.bold('protectRoute')}]: ${`Bypassing local protect - should ONLY happen when running in next to test non-shopify functionality!`}`);
|
|
30
36
|
return {
|
|
31
|
-
props: cleanObject(Object.assign(Object.assign({ locale }, props), data)),
|
|
37
|
+
props: (0, shared_1.cleanObject)(Object.assign(Object.assign({ locale }, props), data)),
|
|
32
38
|
};
|
|
33
39
|
}
|
|
34
|
-
const { shopify, findSessionIds, loadSession } = yield getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
40
|
+
const { shopify, findSessionIds, loadSession } = yield (0, utils_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
|
|
35
41
|
if (shopify === null || shopify === void 0 ? void 0 : shopify.config) {
|
|
36
|
-
res.setHeader('Content-Security-Policy', getSecurityHeader(shop, shopify.config));
|
|
42
|
+
res.setHeader('Content-Security-Policy', (0, utils_1.getSecurityHeader)(shop, shopify.config));
|
|
37
43
|
}
|
|
38
44
|
const existingSessionIds = yield findSessionIds(shop);
|
|
39
|
-
if (arrayEmpty(existingSessionIds)) {
|
|
45
|
+
if ((0, shared_1.arrayEmpty)(existingSessionIds)) {
|
|
40
46
|
// TODO: explore objectToQuerystring
|
|
41
47
|
const queryParams = new URLSearchParams(Object.assign(Object.assign({}, query), { shop })).toString();
|
|
42
48
|
return {
|
|
43
49
|
redirect: {
|
|
44
|
-
destination: `${API_PATHS[API_ROUTE_NAMES.AUTH_ONLINE]}?${queryParams}`,
|
|
50
|
+
destination: `${API_PATHS[shared_1.API_ROUTE_NAMES.AUTH_ONLINE]}?${queryParams}`,
|
|
45
51
|
permanent: false,
|
|
46
52
|
},
|
|
47
53
|
};
|
|
@@ -62,12 +68,12 @@ export const protectRoute = (serverRuntimeConfig, props) => ({ req, res, query,
|
|
|
62
68
|
};
|
|
63
69
|
}
|
|
64
70
|
catch (error) {
|
|
65
|
-
if (error instanceof ShopifyAuthenticationError) {
|
|
71
|
+
if (error instanceof shared_1.ShopifyAuthenticationError) {
|
|
66
72
|
// TODO: explore objectToQuerystring
|
|
67
|
-
const queryParams = new URLSearchParams(Object.assign(Object.assign({}, query), { shop, reAuth: (error instanceof ShopifySessionAuthenticationError) })).toString();
|
|
73
|
+
const queryParams = new URLSearchParams(Object.assign(Object.assign({}, query), { shop, reAuth: (error instanceof shared_1.ShopifySessionAuthenticationError) })).toString();
|
|
68
74
|
return {
|
|
69
75
|
redirect: {
|
|
70
|
-
destination: `${API_PATHS[API_ROUTE_NAMES.AUTH_ONLINE]}?${queryParams}`,
|
|
76
|
+
destination: `${API_PATHS[shared_1.API_ROUTE_NAMES.AUTH_ONLINE]}?${queryParams}`,
|
|
71
77
|
permanent: false,
|
|
72
78
|
},
|
|
73
79
|
};
|
|
@@ -77,7 +83,8 @@ export const protectRoute = (serverRuntimeConfig, props) => ({ req, res, query,
|
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
return {
|
|
80
|
-
props: cleanObject(Object.assign(Object.assign({ locale }, props), data)),
|
|
86
|
+
props: (0, shared_1.cleanObject)(Object.assign(Object.assign({ locale }, props), data)),
|
|
81
87
|
};
|
|
82
88
|
});
|
|
89
|
+
exports.protectRoute = protectRoute;
|
|
83
90
|
//# sourceMappingURL=protect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protect.js","sourceRoot":"","sources":["../../../../src/lib/handlers/ssr/protect.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"protect.js","sourceRoot":"","sources":["../../../../src/lib/handlers/ssr/protect.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAyB;AAEzB,uCAIoB;AACpB,4CAQwB;AAEjB,MAAM,YAAY,GAAG,CAAC,mBAAmB,EAAE,KAAK,EAAE,EAAE,CAAC,CAAO,EACjE,GAAG,EACH,GAAG,EACH,KAAK,EACL,MAAM,GACP,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE;;IACd,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,mBAAmB,CAAA;IACrD,MAAM,IAAI,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,mCAAI,MAAA,GAAG,CAAC,KAAK,0CAAE,IAAI,CAAA;IAC3C,MAAM,QAAQ,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,mCAAI,MAAA,GAAG,CAAC,KAAK,0CAAE,QAAQ,CAAA;IAEvD,IAAI,IAAA,oBAAW,EAAC,IAAI,CAAC,EAAE;QACrB,OAAO;YACL,QAAQ,EAAE;gBACR,WAAW,EAAE,GAAG,UAAU,CAAC,yBAAgB,CAAC,KAAK,CAAC,0CAA0C;gBAC5F,SAAS,EAAE,KAAK;aACjB;SACF,CAAA;KACF;IAED,6EAA6E;IAC7E,MAAM,mBAAmB,GAAG,IAAA,wBAAgB,EAAC,mBAAmB,CAAC,CAAA;IACjE,IAAI,mBAAmB,EAAE;QACvB,OAAO,CAAC,IAAI,CAAC,GAAG,eAAK,CAAC,YAAY,CAAC,cAAc,CAAC,OAAO,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC,MACjF,sGACF,EAAE,CAAC,CAAA;QAEH,OAAO;YACL,KAAK,EAAE,IAAA,oBAAW,gCAChB,MAAM,IACH,KAAK,GACL,IAAI,EACP;SACH,CAAA;KACF;IAED,MAAM,EAAE,OAA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,EAAE,CAAA;gBAEb,OAAO;oBACL,QAAQ,EAAE;wBACR,WAAW,EAAE,GAAG,SAAS,CAAC,wBAAe,CAAC,WAAW,CAAC,IAAI,WAAW,EAAE;wBACvE,SAAS,EAAE,KAAK;qBACjB;iBACF,CAAA;aACF;YACD,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAA;YAE/C,MAAM,KAAK,CAAA;SACZ;KACF;IAED,OAAO;QACL,KAAK,EAAE,IAAA,oBAAW,gCAChB,MAAM,IACH,KAAK,GACL,IAAI,EACP;KACH,CAAA;AACH,CAAC,CAAA,CAAA;AAlGY,QAAA,YAAY,gBAkGxB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,17 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.wrapRoute = void 0;
|
|
13
|
+
const shared_1 = require("../../../shared");
|
|
14
|
+
const utils_1 = require("../../utils");
|
|
15
|
+
const wrapRoute = (serverRuntimeConfig, props) => ({ req, res, query, locale, } = {}, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
16
|
var _a, _b;
|
|
14
17
|
const shop = (_a = query === null || query === void 0 ? void 0 : query.shop) !== null && _a !== void 0 ? _a : (_b = req.query) === null || _b === void 0 ? void 0 : _b.shop;
|
|
15
|
-
const shopify = getInitializedShopify(serverRuntimeConfig);
|
|
18
|
+
const shopify = (0, utils_1.getInitializedShopify)(serverRuntimeConfig);
|
|
16
19
|
if (shopify === null || shopify === void 0 ? void 0 : shopify.config) {
|
|
17
|
-
res.setHeader('Content-Security-Policy', getSecurityHeader(shop, shopify.config));
|
|
20
|
+
res.setHeader('Content-Security-Policy', (0, utils_1.getSecurityHeader)(shop, shopify.config));
|
|
18
21
|
}
|
|
19
22
|
return {
|
|
20
|
-
props: cleanObject(Object.assign(Object.assign({ locale }, props), data)),
|
|
23
|
+
props: (0, shared_1.cleanObject)(Object.assign(Object.assign({ locale }, props), data)),
|
|
21
24
|
};
|
|
22
25
|
});
|
|
26
|
+
exports.wrapRoute = wrapRoute;
|
|
23
27
|
//# sourceMappingURL=wrap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../../../src/lib/handlers/ssr/wrap.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../../../src/lib/handlers/ssr/wrap.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA6C;AAC7C,uCAAsE;AAE/D,MAAM,SAAS,GAAG,CAAC,mBAAmB,EAAE,KAAK,EAAE,EAAE,CAAC,CAAO,EAC9D,GAAG,EACH,GAAG,EACH,KAAK,EACL,MAAM,GACP,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE;;IACd,MAAM,IAAI,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,mCAAI,MAAA,GAAG,CAAC,KAAK,0CAAE,IAAI,CAAA;IAE3C,MAAM,OAAO,GAAG,IAAA,6BAAqB,EAAC,mBAAmB,CAAC,CAAA;IAC1D,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,EAAE;QACnB,GAAG,CAAC,SAAS,CAAC,yBAAyB,EAAE,IAAA,yBAAiB,EAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;KAClF;IAED,OAAO;QACL,KAAK,EAAE,IAAA,oBAAW,gCAChB,MAAM,IACH,KAAK,GACL,IAAI,EACP;KACH,CAAA;AACH,CAAC,CAAA,CAAA;AApBY,QAAA,SAAS,aAoBrB"}
|
package/dist/lib/index.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.prepareHeaders = exports.getShopifyHelpers = void 0;
|
|
18
|
+
__exportStar(require("../shared"), exports);
|
|
19
|
+
__exportStar(require("../verification"), exports);
|
|
20
|
+
__exportStar(require("./handlers"), exports);
|
|
21
|
+
var utils_1 = require("./utils");
|
|
22
|
+
Object.defineProperty(exports, "getShopifyHelpers", { enumerable: true, get: function () { return utils_1.getShopifyHelpers; } });
|
|
23
|
+
Object.defineProperty(exports, "prepareHeaders", { enumerable: true, get: function () { return utils_1.prepareHeaders; } });
|
|
5
24
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,
|
|
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"}
|