@agnostack/next-shopify 1.3.2-alpha.9 → 1.4.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 +40 -49
- package/dist/{apiHandlers.d.ts → handlers/api.d.ts} +0 -0
- package/dist/{apiHandlers.js → handlers/api.js} +8 -8
- package/dist/handlers/api.js.map +1 -0
- package/dist/handlers/index.d.ts +2 -0
- package/dist/handlers/index.js +15 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/{protectRoute.d.ts → handlers/ssr.d.ts} +7 -0
- package/dist/{protectRoute.js → handlers/ssr.js} +24 -10
- package/dist/handlers/ssr.js.map +1 -0
- package/dist/helpers/auth.d.ts +14 -0
- package/dist/helpers/auth.js +25 -0
- package/dist/helpers/auth.js.map +1 -0
- package/dist/helpers/callback.d.ts +9 -0
- package/dist/helpers/callback.js +71 -0
- package/dist/helpers/callback.js.map +1 -0
- package/dist/helpers/error.d.ts +13 -0
- package/dist/helpers/error.js +18 -0
- package/dist/helpers/error.js.map +1 -0
- package/dist/helpers/graph.d.ts +7 -0
- package/dist/helpers/graph.js +76 -0
- package/dist/helpers/graph.js.map +1 -0
- package/dist/helpers/index.d.ts +6 -0
- package/dist/helpers/index.js +19 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/rest.d.ts +7 -0
- package/dist/helpers/rest.js +70 -0
- package/dist/helpers/rest.js.map +1 -0
- package/dist/helpers/uninstall.d.ts +8 -0
- package/dist/helpers/uninstall.js +28 -0
- package/dist/helpers/uninstall.js.map +1 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/utils/billing.d.ts +0 -5
- package/dist/utils/billing.js +20 -138
- package/dist/utils/billing.js.map +1 -1
- package/dist/utils/constants.d.ts +21 -0
- package/dist/utils/constants.js +97 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/firebase.d.ts +6 -12
- package/dist/utils/firebase.js +27 -29
- package/dist/utils/firebase.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/shopify-api-node/beginAuth.d.ts +9 -0
- package/dist/utils/shopify-api-node/beginAuth.js +37 -0
- package/dist/utils/shopify-api-node/beginAuth.js.map +1 -0
- package/dist/utils/shopify-api-node/index.d.ts +1 -0
- package/dist/utils/shopify-api-node/index.js +15 -0
- package/dist/utils/shopify-api-node/index.js.map +1 -0
- package/dist/utils/shopify.d.ts +1 -10
- package/dist/utils/shopify.js +16 -61
- package/dist/utils/shopify.js.map +1 -1
- package/dist/withShopify.js +3 -36
- package/dist/withShopify.js.map +1 -1
- package/package.json +1 -1
- package/dist/apiHandlers.js.map +0 -1
- package/dist/apiHelpers.d.ts +0 -70
- package/dist/apiHelpers.js +0 -251
- package/dist/apiHelpers.js.map +0 -1
- package/dist/protectRoute.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,65 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* query ([b7795ce](https://github.com/agnostack/next-shopify/commit/b7795ce72f54cd7ba608d852bb236f0e2aeffbb1))
|
|
7
|
-
|
|
8
|
-
## [1.3.2-alpha.8](https://github.com/agnostack/next-shopify/compare/v1.3.2-alpha.7...v1.3.2-alpha.8) (2022-11-17)
|
|
1
|
+
# [1.4.0](https://github.com/agnostack/next-shopify/compare/v1.3.1...v1.4.0) (2022-11-21)
|
|
9
2
|
|
|
10
3
|
|
|
11
4
|
### Bug Fixes
|
|
12
5
|
|
|
6
|
+
* add ensureSecurityHeader ([667abc1](https://github.com/agnostack/next-shopify/commit/667abc1bef3c39583c57ff41b13c5b86ba7bd722))
|
|
7
|
+
* add setData to FBSessionHandler ([36695b3](https://github.com/agnostack/next-shopify/commit/36695b3eda89126748cf5dd27604a8fe6817b4c4))
|
|
8
|
+
* add uninstall ([bb6837d](https://github.com/agnostack/next-shopify/commit/bb6837d139ae28d93ebcceceb55fccc072acf442))
|
|
9
|
+
* change cookie sameSite to none ([f20a167](https://github.com/agnostack/next-shopify/commit/f20a16709f25775d0fb79a2a551998466b806c28))
|
|
10
|
+
* cleanup ([b9719c0](https://github.com/agnostack/next-shopify/commit/b9719c07f6aed42cfd0204fb4d66558fd2081796))
|
|
11
|
+
* debug ([0e5f0e2](https://github.com/agnostack/next-shopify/commit/0e5f0e2a0ca251844dce10ca152b0efad918a243))
|
|
12
|
+
* debug ([f3724d8](https://github.com/agnostack/next-shopify/commit/f3724d864e173d1b31d3822004fd75ac28d47a0e))
|
|
13
|
+
* debug ([69170ff](https://github.com/agnostack/next-shopify/commit/69170fffdcfe84044df6ce3f575dbfbaabe4f60a))
|
|
14
|
+
* debug ([4a886a4](https://github.com/agnostack/next-shopify/commit/4a886a4bb88c675a52e40aee121d4424666ab524))
|
|
15
|
+
* debug ([069c0dd](https://github.com/agnostack/next-shopify/commit/069c0dd9526b801267ac0998e557240ddd423612))
|
|
16
|
+
* debug ([61a69ba](https://github.com/agnostack/next-shopify/commit/61a69ba063f5bfe8673c9b4fbc29bdca4647ea09))
|
|
17
|
+
* debug ([d4767a7](https://github.com/agnostack/next-shopify/commit/d4767a7e8757a8f755b41aadb525fa14423f9f02))
|
|
18
|
+
* debug ([ae1bbf6](https://github.com/agnostack/next-shopify/commit/ae1bbf68b809e5574328e6e315d49d1033d8f15f))
|
|
13
19
|
* debug ([cd9b4e6](https://github.com/agnostack/next-shopify/commit/cd9b4e6985a1fc86ab953b2441e19ba4ac4b6c99))
|
|
14
|
-
|
|
15
|
-
## [1.3.2-alpha.7](https://github.com/agnostack/next-shopify/compare/v1.3.2-alpha.6...v1.3.2-alpha.7) (2022-11-16)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
20
|
-
* update shopify version ([c5fece0](https://github.com/agnostack/next-shopify/commit/c5fece029cd870ce1a502343a707c6c42b7051c4))
|
|
21
|
-
|
|
22
|
-
## [1.3.2-alpha.6](https://github.com/agnostack/next-shopify/compare/v1.3.2-alpha.5...v1.3.2-alpha.6) (2022-11-16)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Bug Fixes
|
|
26
|
-
|
|
27
20
|
* debug ([34899ff](https://github.com/agnostack/next-shopify/commit/34899ff59cc2d9826de31508051cfe9c9a6269f5))
|
|
28
|
-
|
|
29
|
-
## [1.3.2-alpha.5](https://github.com/agnostack/next-shopify/compare/v1.3.2-alpha.4...v1.3.2-alpha.5) (2022-11-16)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
21
|
* debug ([f8e415f](https://github.com/agnostack/next-shopify/commit/f8e415f1cd34743b5e26603065addb87d1a3fa54))
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Bug Fixes
|
|
40
|
-
|
|
22
|
+
* debug routes ([987e28c](https://github.com/agnostack/next-shopify/commit/987e28c4989f004364b182cd7065be48e53e81b4))
|
|
23
|
+
* debug routes ([cefaf73](https://github.com/agnostack/next-shopify/commit/cefaf731a34f758545574339509a8196e84a87bf))
|
|
41
24
|
* debugging ([1f6b379](https://github.com/agnostack/next-shopify/commit/1f6b379204bda2616b32d08efedb1a87f2855c75))
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
* file cleanup ([4d7d26a](https://github.com/agnostack/next-shopify/commit/4d7d26a65d5c9d92a89a0f26c13c99af9462bdf3))
|
|
26
|
+
* file cleanup ([dfe8efb](https://github.com/agnostack/next-shopify/commit/dfe8efb34ef8a6ef37ccd38aa6d69c258c14282e))
|
|
27
|
+
* fix import path ([05317aa](https://github.com/agnostack/next-shopify/commit/05317aab6868a6428d5d141d0f69cd22b1667a11))
|
|
28
|
+
* headers ([d039f3c](https://github.com/agnostack/next-shopify/commit/d039f3caf53d884bc7104427084d5ee536c43523))
|
|
29
|
+
* make it stop ([394182e](https://github.com/agnostack/next-shopify/commit/394182e9f9ebbd4826ac7a173b3fff0b18046cba))
|
|
30
|
+
* modfy wrapRoute ([3ae2f72](https://github.com/agnostack/next-shopify/commit/3ae2f72db314d0b6b37af2fbd91916fa1e0a83aa))
|
|
31
|
+
* modify clear cookie approach ([c0a0dc5](https://github.com/agnostack/next-shopify/commit/c0a0dc5ef3e5c08bc8a663f937c232825ee8df0f))
|
|
32
|
+
* modify header rules ([fc0b4a3](https://github.com/agnostack/next-shopify/commit/fc0b4a3900a8b2556fbcf68fabd874f4df21c00f))
|
|
33
|
+
* modify header rules ([53983bb](https://github.com/agnostack/next-shopify/commit/53983bb7b888a55c96de6e0c3f6f9dd6930be98c))
|
|
34
|
+
* modify headers ([4848edf](https://github.com/agnostack/next-shopify/commit/4848edf4b275f1ab08aaec54f4a792d4c53d6e15))
|
|
35
|
+
* query ([b7795ce](https://github.com/agnostack/next-shopify/commit/b7795ce72f54cd7ba608d852bb236f0e2aeffbb1))
|
|
48
36
|
* refactor hasActivePayment ([7bb350e](https://github.com/agnostack/next-shopify/commit/7bb350e50a9f84aa84907c4fa8c6cba1e8dd2544))
|
|
49
|
-
|
|
50
|
-
## [1.3.2-alpha.2](https://github.com/agnostack/next-shopify/compare/v1.3.2-alpha.1...v1.3.2-alpha.2) (2022-11-16)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
### Bug Fixes
|
|
54
|
-
|
|
55
37
|
* refactor hasActivePayment ([aa303c9](https://github.com/agnostack/next-shopify/commit/aa303c9a28e24e2939acf1378b8e324d22720669))
|
|
56
|
-
|
|
57
|
-
|
|
38
|
+
* rename ([f99a48f](https://github.com/agnostack/next-shopify/commit/f99a48f5a064cc5fe12e3492c99dcb18fa62b6c0))
|
|
39
|
+
* rename ([992f2dd](https://github.com/agnostack/next-shopify/commit/992f2dde10bf92f8e8eec2c337f15ccf7f52e93e))
|
|
40
|
+
* return from wrapRoute ([d3a4b28](https://github.com/agnostack/next-shopify/commit/d3a4b28ea1e0002321cd5bdd6756bc67dd25a7a9))
|
|
41
|
+
* return from wrapRoute ([0423342](https://github.com/agnostack/next-shopify/commit/0423342eee38103af98c4fb9ca317aaf865ec288))
|
|
42
|
+
* revert ([182fef5](https://github.com/agnostack/next-shopify/commit/182fef5a837219e0a6b8babff9b4ac2e309020df))
|
|
43
|
+
* revert sameSite lax ([ca1b6dd](https://github.com/agnostack/next-shopify/commit/ca1b6ddc895b812768090074a39b39f6848b4b7e))
|
|
44
|
+
* the never ending debugging process ([09eb418](https://github.com/agnostack/next-shopify/commit/09eb418be5c10f644eb2c485aa6339e1c8c687a3))
|
|
45
|
+
* update shopify version ([c5fece0](https://github.com/agnostack/next-shopify/commit/c5fece029cd870ce1a502343a707c6c42b7051c4))
|
|
46
|
+
* updated to add logs ([6500277](https://github.com/agnostack/next-shopify/commit/65002779ac3870791a0ec230d11a770b8fd0f0e3))
|
|
47
|
+
* use rest with version ([b2f6320](https://github.com/agnostack/next-shopify/commit/b2f6320ef51d69554d5ae6193b878d656528da0d))
|
|
48
|
+
* use sameSite lax ([28a5fed](https://github.com/agnostack/next-shopify/commit/28a5fed2e512049c66ede168911c089d0e092bb8))
|
|
58
49
|
|
|
59
50
|
|
|
60
|
-
###
|
|
51
|
+
### Features
|
|
61
52
|
|
|
62
|
-
*
|
|
53
|
+
* revamped Firebase calls ([33a56c1](https://github.com/agnostack/next-shopify/commit/33a56c1a0a6b972b5523d3cbe911e14c3df415d2))
|
|
63
54
|
|
|
64
55
|
## [1.3.1](https://github.com/agnostack/next-shopify/compare/v1.3.0...v1.3.1) (2022-11-15)
|
|
65
56
|
|
|
File without changes
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handleAppUninstalled = exports.handleCallback = exports.handleAuth = exports.handleGraph = exports.handleRest = void 0;
|
|
4
4
|
// NOTE: api routes do NOT work in `next export`
|
|
5
5
|
const shopify_api_1 = require("@shopify/shopify-api");
|
|
6
|
-
const
|
|
7
|
-
const utils_1 = require("
|
|
6
|
+
const helpers_1 = require("../helpers");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
8
|
const handleRest = (serverRuntimeConfig) => async (req, res, params) => {
|
|
9
9
|
const { PAGE_PATHS } = serverRuntimeConfig;
|
|
10
|
-
const { message, response, headers, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_rest_response`, } = await
|
|
10
|
+
const { message, response, headers, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_rest_response`, } = await helpers_1.restHelper({
|
|
11
11
|
req,
|
|
12
12
|
res,
|
|
13
13
|
params,
|
|
@@ -35,7 +35,7 @@ exports.handleRest = handleRest;
|
|
|
35
35
|
const handleGraph = (serverRuntimeConfig) => async (req, res, params) => {
|
|
36
36
|
var _a, _b;
|
|
37
37
|
const { PAGE_PATHS } = serverRuntimeConfig;
|
|
38
|
-
const { message, response, headers, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_query_response`, } = await
|
|
38
|
+
const { message, response, headers, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_query_response`, } = await helpers_1.graphHelper({
|
|
39
39
|
req,
|
|
40
40
|
res,
|
|
41
41
|
params,
|
|
@@ -56,7 +56,7 @@ exports.handleGraph = handleGraph;
|
|
|
56
56
|
// NOTE: typically handling: "/api/auth"
|
|
57
57
|
const handleAuth = (serverRuntimeConfig) => async (req, res) => {
|
|
58
58
|
const { PAGE_PATHS } = serverRuntimeConfig;
|
|
59
|
-
const { message, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_auth_response`, } = await
|
|
59
|
+
const { message, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_auth_response`, } = await helpers_1.authHelper({ req, res, serverRuntimeConfig });
|
|
60
60
|
if (statusCode >= 300 && statusCode < 400) {
|
|
61
61
|
return res.redirect(statusCode, redirectUrl);
|
|
62
62
|
}
|
|
@@ -66,7 +66,7 @@ exports.handleAuth = handleAuth;
|
|
|
66
66
|
// NOTE: typically handling: "/api/auth/callback"
|
|
67
67
|
const handleCallback = (serverRuntimeConfig) => async (req, res) => {
|
|
68
68
|
const { PAGE_PATHS } = serverRuntimeConfig;
|
|
69
|
-
const { message, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_callback_response`, } = await
|
|
69
|
+
const { message, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_callback_response`, } = await helpers_1.callbackHelper({ req, res, serverRuntimeConfig });
|
|
70
70
|
if (statusCode >= 300 && statusCode < 400) {
|
|
71
71
|
return res.redirect(statusCode, redirectUrl);
|
|
72
72
|
}
|
|
@@ -76,11 +76,11 @@ exports.handleCallback = handleCallback;
|
|
|
76
76
|
// NOTE: typically handling: "/api/webhooks/app/uninstalled"
|
|
77
77
|
const handleAppUninstalled = (serverRuntimeConfig) => async (req, res) => {
|
|
78
78
|
const { PAGE_PATHS } = serverRuntimeConfig;
|
|
79
|
-
const { message, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_uninstall_response`, } = await
|
|
79
|
+
const { message, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_uninstall_response`, } = await helpers_1.uninstallHelper({ req, serverRuntimeConfig });
|
|
80
80
|
if (statusCode >= 300 && statusCode < 400) {
|
|
81
81
|
return res.redirect(statusCode, redirectUrl);
|
|
82
82
|
}
|
|
83
83
|
return res.status(statusCode).send(message);
|
|
84
84
|
};
|
|
85
85
|
exports.handleAppUninstalled = handleAppUninstalled;
|
|
86
|
-
//# sourceMappingURL=
|
|
86
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/handlers/api.js"],"names":[],"mappings":";;;AAAA,gDAAgD;AAChD,sDAA+C;AAE/C,wCAMmB;AACnB,oCAAyD;AAElD,MAAM,UAAU,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;IAC5E,MAAM,EAAE,UAAU,EAAE,GAAG,mBAAmB,CAAA;IAC1C,MAAM,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,UAAU,GAAG,GAAG,EAChB,WAAW,GAAG,GAAG,UAAU,CAAC,wBAAgB,CAAC,KAAK,CAAC,wBAAwB,GAC5E,GAAG,MAAM,oBAAU,CAAC;QACnB,GAAG;QACH,GAAG;QACH,MAAM;QACN,mBAAmB;KACpB,CAAC,CAAA;IAEF,MAAM,CAAC,OAAO,CAAC,oBAAY,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC7D,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;IAEF,6BAA6B;IAC7B,IAAI,UAAU,IAAI,GAAG,IAAI,UAAU,GAAG,GAAG,EAAE;QACzC,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;KAC7C;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;KAC5C;IAED,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,CAAC,CAAC,s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AG,GAAG,EAChB,WAAW,GAAG,GAAG,UAAU,CAAC,wBAAgB,CAAC,KAAK,CAAC,4BAA4B,GAChF,GAAG,MAAM,wBAAc,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,mBAAmB,EAAE,CAAC,CAAA;IAE3D,IAAI,UAAU,IAAI,GAAG,IAAI,UAAU,GAAG,GAAG,EAAE;QACzC,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;KAC7C;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC7C,CAAC,CAAA;AAbY,QAAA,cAAc,kBAa1B;AAED,4DAA4D;AACrD,MAAM,oBAAoB,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;IAC9E,MAAM,EAAE,UAAU,EAAE,GAAG,mBAAmB,CAAA;IAC1C,MAAM,EACJ,OAAO,EACP,UAAU,GAAG,GAAG,EAChB,WAAW,GAAG,GAAG,UAAU,CAAC,wBAAgB,CAAC,KAAK,CAAC,6BAA6B,GACjF,GAAG,MAAM,yBAAe,CAAC,EAAE,GAAG,EAAE,mBAAmB,EAAE,CAAC,CAAA;IAEvD,IAAI,UAAU,IAAI,GAAG,IAAI,UAAU,GAAG,GAAG,EAAE;QACzC,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;KAC7C;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC7C,CAAC,CAAA;AAbY,QAAA,oBAAoB,wBAahC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./api"), exports);
|
|
14
|
+
__exportStar(require("./ssr"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAqB;AACrB,wCAAqB"}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.protectRoute = void 0;
|
|
4
|
-
const utils_1 = require("
|
|
3
|
+
exports.protectRoute = exports.wrapRoute = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const getSecurityHeader = ({ shop } = {}) => (utils_1.stringNotEmpty(shop)
|
|
6
|
+
? `frame-ancestors self https://admin.shopify.com https://${shop};`
|
|
7
|
+
: "frame-ancestors 'none';");
|
|
8
|
+
const wrapRoute = () => ({ res, query, locale } = {}, data) => {
|
|
9
|
+
res.setHeader('Content-Security-Policy', getSecurityHeader(query));
|
|
10
|
+
return {
|
|
11
|
+
props: Object.assign({ locale }, data),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.wrapRoute = wrapRoute;
|
|
5
15
|
const protectRoute = (props) => async ({ req, res, query, locale } = {}, data) => {
|
|
6
16
|
var _a, _b, _c, _d, _e, _f;
|
|
7
17
|
const { PAGE_PATHS } = props;
|
|
8
18
|
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;
|
|
9
19
|
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;
|
|
20
|
+
res.setHeader('Content-Security-Policy', getSecurityHeader(query));
|
|
10
21
|
if (!shop) {
|
|
22
|
+
const noshopurl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?code=no_shop_provided&type=protectRoute`;
|
|
11
23
|
return {
|
|
12
24
|
redirect: {
|
|
13
|
-
destination:
|
|
25
|
+
destination: noshopurl,
|
|
14
26
|
permanent: false,
|
|
15
27
|
},
|
|
16
28
|
};
|
|
@@ -18,21 +30,23 @@ const protectRoute = (props) => async ({ req, res, query, locale } = {}, data) =
|
|
|
18
30
|
const shopify = utils_1.getInitializedShopify(props, shop);
|
|
19
31
|
const shopSessions = await ((_f = (_e = shopify.Context.SESSION_STORAGE) === null || _e === void 0 ? void 0 : _e.findSessionsByShop) === null || _f === void 0 ? void 0 : _f.call(_e, shop));
|
|
20
32
|
if (utils_1.arrayEmpty(shopSessions)) {
|
|
33
|
+
const emptySessionUrl = utils_1.getRedirectUrl(props, {
|
|
34
|
+
req,
|
|
35
|
+
res,
|
|
36
|
+
query,
|
|
37
|
+
});
|
|
21
38
|
return {
|
|
22
39
|
redirect: {
|
|
23
|
-
destination:
|
|
24
|
-
req,
|
|
25
|
-
res,
|
|
26
|
-
query,
|
|
27
|
-
}),
|
|
40
|
+
destination: emptySessionUrl,
|
|
28
41
|
permanent: false,
|
|
29
42
|
},
|
|
30
43
|
};
|
|
31
44
|
}
|
|
32
45
|
if (embedded !== '1') {
|
|
46
|
+
const embeddedappUrl = shopify.Utils.getEmbeddedAppUrl(req);
|
|
33
47
|
return {
|
|
34
48
|
redirect: {
|
|
35
|
-
destination:
|
|
49
|
+
destination: embeddedappUrl,
|
|
36
50
|
permanent: false,
|
|
37
51
|
},
|
|
38
52
|
};
|
|
@@ -42,4 +56,4 @@ const protectRoute = (props) => async ({ req, res, query, locale } = {}, data) =
|
|
|
42
56
|
};
|
|
43
57
|
};
|
|
44
58
|
exports.protectRoute = protectRoute;
|
|
45
|
-
//# sourceMappingURL=
|
|
59
|
+
//# sourceMappingURL=ssr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr.js","sourceRoot":"","sources":["../../src/handlers/ssr.js"],"names":[],"mappings":";;;AAAA,oCAMiB;AAEjB,MAAM,iBAAiB,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAC3C,sBAAc,CAAC,IAAI,CAAC;IAClB,CAAC,CAAC,0DAA0D,IAAI,GAAG;IACnE,CAAC,CAAC,yBAAyB,CAC9B,CAAA;AAEM,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE;IACnE,GAAG,CAAC,SAAS,CAAC,yBAAyB,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAA;IAElE,OAAO;QACL,KAAK,kBACH,MAAM,IACH,IAAI,CACR;KACF,CAAA;AACH,CAAC,CAAA;AATY,QAAA,SAAS,aASrB;AAEM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE;;IACtF,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAA;IAC5B,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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ntimeConfig }: {
|
|
3
|
+
req: any;
|
|
4
|
+
res: any;
|
|
5
|
+
serverRuntimeConfig: any;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
statusCode: number;
|
|
8
|
+
redirectUrl: string;
|
|
9
|
+
message?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
statusCode: number;
|
|
12
|
+
message: string;
|
|
13
|
+
redirectUrl?: undefined;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const authHelper = async ({ req, res, serverRuntimeConfig }) => {
|
|
5
|
+
try {
|
|
6
|
+
const authredurectUrl = utils_1.getRedirectUrl(serverRuntimeConfig, {
|
|
7
|
+
req,
|
|
8
|
+
res,
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
statusCode: 302,
|
|
12
|
+
redirectUrl: authredurectUrl,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
const errorMessage = 'Error handling auth route';
|
|
17
|
+
console.error(errorMessage, error);
|
|
18
|
+
return {
|
|
19
|
+
statusCode: 500,
|
|
20
|
+
message: errorMessage,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.default = authHelper;
|
|
25
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/helpers/auth.js"],"names":[],"mappings":";;AAAA,oCAAyC;AAEzC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,mBAAmB,EAAE,EAAE,EAAE;IAC7D,IAAI;QACF,MAAM,eAAe,GAAG,sBAAc,CAAC,mBAAmB,EAAE;YAC1D,GAAG;YACH,GAAG;SACJ,CAAC,CAAA;QAEF,OAAO;YACL,UAAU,EAAE,GAAG;YACf,WAAW,EAAE,eAAe;SAC7B,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,YAAY,GAAG,2BAA2B,CAAA;QAChD,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;QAElC,OAAO;YACL,UAAU,EAAE,GAAG;YACf,OAAO,EAAE,YAAY;SACtB,CAAA;KACF;AACH,CAAC,CAAA;AAED,kBAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const shopify_api_1 = require("@shopify/shopify-api");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const callbackHelper = async ({ req, res, serverRuntimeConfig }) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const { PAGE_PATHS, APP_WEBHOOKS, PAYMENT_CONFIG } = serverRuntimeConfig;
|
|
8
|
+
const { shop, host } = req.query;
|
|
9
|
+
if (!shop || !host) {
|
|
10
|
+
return {
|
|
11
|
+
statusCode: 303,
|
|
12
|
+
redirectUrl: `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?code=invalid_callback`,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let redirectUrl;
|
|
16
|
+
try {
|
|
17
|
+
const shopify = utils_1.getInitializedShopify(serverRuntimeConfig, shop);
|
|
18
|
+
const session = await shopify.Auth.validateAuthCallback(req, res, req.query);
|
|
19
|
+
await utils_1.registerWebhooks(serverRuntimeConfig, APP_WEBHOOKS, session);
|
|
20
|
+
// TODO: explore objectToQuerystring
|
|
21
|
+
const embeddedURL = shopify_api_1.Shopify.Utils.getEmbeddedAppUrl(req);
|
|
22
|
+
redirectUrl = `${embeddedURL}?${new URLSearchParams(req.query).toString()}`;
|
|
23
|
+
if (PAYMENT_CONFIG === null || PAYMENT_CONFIG === void 0 ? void 0 : PAYMENT_CONFIG.required) {
|
|
24
|
+
const billingManager = new utils_1.BillingManager(session, serverRuntimeConfig);
|
|
25
|
+
const confirmationUrl = await billingManager.ensureBilling();
|
|
26
|
+
if (utils_1.stringNotEmpty(confirmationUrl)) {
|
|
27
|
+
redirectUrl = confirmationUrl;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const errorMessage = 'Error handling callback route';
|
|
33
|
+
switch (true) {
|
|
34
|
+
case error instanceof shopify_api_1.Shopify.Errors.CookieNotFound:
|
|
35
|
+
case error instanceof shopify_api_1.Shopify.Errors.SessionNotFound: {
|
|
36
|
+
console.error(`${errorMessage}. Cookie/Session Error`, error);
|
|
37
|
+
redirectUrl = utils_1.getRedirectUrl(serverRuntimeConfig, {
|
|
38
|
+
req,
|
|
39
|
+
res,
|
|
40
|
+
});
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case error instanceof shopify_api_1.Shopify.Errors.BillingError: {
|
|
44
|
+
console.error(`${errorMessage}. Billing Error ${error.message}`, error.errorData);
|
|
45
|
+
redirectUrl = '/error?code=billing_error';
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case error instanceof shopify_api_1.Shopify.Errors.GraphqlQueryError: {
|
|
49
|
+
const errorMessages = utils_1.ensureArray((_a = error.response) === null || _a === void 0 ? void 0 : _a.errors).map(({ message }) => utils_1.ensureString(message));
|
|
50
|
+
console.error(`${errorMessage}. GraphqlQuery Error ${errorMessages.join('. ')}`);
|
|
51
|
+
redirectUrl = '/error?code=query_error';
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case error instanceof shopify_api_1.Shopify.Errors.InvalidOAuthError: {
|
|
55
|
+
console.error(`${errorMessage}. InvalidOAuth Error`, error);
|
|
56
|
+
redirectUrl = '/error?code=oauth_error';
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
default: {
|
|
60
|
+
console.error(errorMessage, error);
|
|
61
|
+
redirectUrl = '/error?code=callback_error';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
statusCode: 302,
|
|
67
|
+
redirectUrl,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
exports.default = callbackHelper;
|
|
71
|
+
//# sourceMappingURL=callback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callback.js","sourceRoot":"","sources":["../../src/helpers/callback.js"],"names":[],"mappings":";;AAAA,sDAA8C;AAE9C,oCASiB;AAEjB,MAAM,cAAc,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,mBAAmB,EAAE,EAAE,EAAE;;IACjE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,mBAAmB,CAAA;IACxE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,KAAK,CAAA;IAEhC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE;QAClB,OAAO;YACL,UAAU,EAAE,GAAG;YACf,WAAW,EAAE,GAAG,UAAU,CAAC,wBAAgB,CAAC,KAAK,CAAC,wBAAwB;SAC3E,CAAA;KACF;IAED,IAAI,WAAW,CAAA;IAEf,IAAI;QACF,MAAM,OAAO,GAAG,6BAAqB,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAA;QAEhE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;QAE5E,MAAM,wBAAgB,CAAC,mBAAmB,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;QAElE,oCAAoC;QACpC,MAAM,WAAW,GAAG,qBAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;QACxD,WAAW,GAAG,GAAG,WAAW,IAAI,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EA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AwB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAChF,WAAW,GAAG,yBAAyB,CAAA;gBACvC,MAAK;aACN;YAED,KAAK,KAAK,YAAY,qBAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;gBACtD,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,sBAAsB,EAAE,KAAK,CAAC,CAAA;gBAC3D,WAAW,GAAG,yBAAyB,CAAA;gBACvC,MAAK;aACN;YAED,OAAO,CAAC,CAAC;gBACP,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;gBAClC,WAAW,GAAG,4BAA4B,CAAA;aAC3C;SACF;KACF;IAED,OAAO;QACL,UAAU,EAAE,GAAG;QACf,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default authenticationErrorHelper;
|
|
2
|
+
declare function authenticationErrorHelper({ error, shop, serverRuntimeConfig }: {
|
|
3
|
+
error: any;
|
|
4
|
+
shop: any;
|
|
5
|
+
serverRuntimeConfig: any;
|
|
6
|
+
}): {
|
|
7
|
+
statusCode: number;
|
|
8
|
+
message: any;
|
|
9
|
+
headers: {
|
|
10
|
+
'X-Shopify-API-Request-Failure-Reauthorize': string;
|
|
11
|
+
'X-Shopify-API-Request-Failure-Reauthorize-Url': any;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const authenticationErrorHelper = ({ error, shop, serverRuntimeConfig }) => {
|
|
5
|
+
const { message, data } = error;
|
|
6
|
+
const { API_URLS } = serverRuntimeConfig;
|
|
7
|
+
const reauthorizationUrl = (data === null || data === void 0 ? void 0 : data.redirectUrl) || `${API_URLS[utils_1.API_ROUTE_NAMES.AUTH]}?shop=${shop}`;
|
|
8
|
+
return {
|
|
9
|
+
statusCode: 403,
|
|
10
|
+
message,
|
|
11
|
+
headers: {
|
|
12
|
+
'X-Shopify-API-Request-Failure-Reauthorize': '1',
|
|
13
|
+
'X-Shopify-API-Request-Failure-Reauthorize-Url': reauthorizationUrl,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.default = authenticationErrorHelper;
|
|
18
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/helpers/error.js"],"names":[],"mappings":";;AAAA,oCAA0C;AAE1C,MAAM,yBAAyB,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,EAAE;IACzE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,mBAAmB,CAAA;IACxC,MAAM,kBAAkB,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,KAAI,GAAG,QAAQ,CAAC,uBAAe,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAA;IAEhG,OAAO;QACL,UAAU,EAAE,GAAG;QACf,OAAO;QACP,OAAO,EAAE;YACP,2CAA2C,EAAE,GAAG;YAChD,+CAA+C,EAAE,kBAAkB;SACpE;KACF,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const shopify_api_1 = require("@shopify/shopify-api");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
16
|
+
const error_1 = require("./error");
|
|
17
|
+
const graphHelper = async ({ req, res, params: _params, serverRuntimeConfig }) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const { body, query: _query } = req;
|
|
20
|
+
const { shop } = _query !== null && _query !== void 0 ? _query : {};
|
|
21
|
+
const _b = _params !== null && _params !== void 0 ? _params : {}, { data: dataParam, query: queryParam } = _b, params = __rest(_b, ["data", "query"]);
|
|
22
|
+
let query = queryParam !== null && queryParam !== void 0 ? queryParam : _query;
|
|
23
|
+
const data = dataParam !== null && dataParam !== void 0 ? dataParam : JSON.parse(body !== null && body !== void 0 ? body : {});
|
|
24
|
+
if (utils_1.isType(query, 'string')) {
|
|
25
|
+
query = utils_1.querystringToObject(query);
|
|
26
|
+
}
|
|
27
|
+
if (!shop || !data) {
|
|
28
|
+
return {
|
|
29
|
+
statusCode: 400,
|
|
30
|
+
message: 'Invalid arguments',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const session = await utils_1.getVerifiedSession({ req, res, shop, serverRuntimeConfig });
|
|
35
|
+
const client = new shopify_api_1.Shopify.Clients.Graphql(shop, session === null || session === void 0 ? void 0 : session.accessToken);
|
|
36
|
+
const payload = Object.assign(Object.assign({ data }, query && { query }), params);
|
|
37
|
+
const response = await client.query(payload);
|
|
38
|
+
return {
|
|
39
|
+
statusCode: 200,
|
|
40
|
+
response,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
const errorMessage = 'Error handling query call';
|
|
45
|
+
switch (true) {
|
|
46
|
+
case error instanceof utils_1.ShopifyAuthenticationError: {
|
|
47
|
+
console.error(`${errorMessage}. Authentication Error`, error);
|
|
48
|
+
return error_1.authenticationErrorHelper({ error, shop, serverRuntimeConfig });
|
|
49
|
+
}
|
|
50
|
+
case error instanceof shopify_api_1.Shopify.Errors.BillingError: {
|
|
51
|
+
console.error(`${errorMessage}. Billing Error - ${error.message}`, error.errorData);
|
|
52
|
+
return {
|
|
53
|
+
statusCode: 500,
|
|
54
|
+
message: errorMessage,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
case error instanceof shopify_api_1.Shopify.Errors.GraphqlQueryError: {
|
|
58
|
+
const errorMessages = utils_1.ensureArray((_a = error.response) === null || _a === void 0 ? void 0 : _a.errors).map(({ message }) => utils_1.ensureString(message));
|
|
59
|
+
console.error(`${errorMessage}. ${errorMessages.join('. ')}`);
|
|
60
|
+
return {
|
|
61
|
+
statusCode: 500,
|
|
62
|
+
message: errorMessage,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
default: {
|
|
66
|
+
console.error(errorMessage, error);
|
|
67
|
+
return {
|
|
68
|
+
statusCode: 500,
|
|
69
|
+
message: errorMessage,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.default = graphHelper;
|
|
76
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/helpers/graph.js"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sDAA8C;AAE9C,oCAOiB;AACjB,mCAAmD;AAEnD,MAAM,WAAW,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE;;IAC/E,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,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+
export { default as authenticationErrorHelper } from "./error";
|
|
3
|
+
export { default as callbackHelper } from "./callback";
|
|
4
|
+
export { default as graphHelper } from "./graph";
|
|
5
|
+
export { default as restHelper } from "./rest";
|
|
6
|
+
export { default as uninstallHelper } from "./uninstall";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.uninstallHelper = exports.restHelper = exports.graphHelper = exports.callbackHelper = exports.authenticationErrorHelper = exports.authHelper = void 0;
|
|
7
|
+
var auth_1 = require("./auth");
|
|
8
|
+
Object.defineProperty(exports, "authHelper", { enumerable: true, get: function () { return __importDefault(auth_1).default; } });
|
|
9
|
+
var error_1 = require("./error");
|
|
10
|
+
Object.defineProperty(exports, "authenticationErrorHelper", { enumerable: true, get: function () { return __importDefault(error_1).default; } });
|
|
11
|
+
var callback_1 = require("./callback");
|
|
12
|
+
Object.defineProperty(exports, "callbackHelper", { enumerable: true, get: function () { return __importDefault(callback_1).default; } });
|
|
13
|
+
var graph_1 = require("./graph");
|
|
14
|
+
Object.defineProperty(exports, "graphHelper", { enumerable: true, get: function () { return __importDefault(graph_1).default; } });
|
|
15
|
+
var rest_1 = require("./rest");
|
|
16
|
+
Object.defineProperty(exports, "restHelper", { enumerable: true, get: function () { return __importDefault(rest_1).default; } });
|
|
17
|
+
var uninstall_1 = require("./uninstall");
|
|
18
|
+
Object.defineProperty(exports, "uninstallHelper", { enumerable: true, get: function () { return __importDefault(uninstall_1).default; } });
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.js"],"names":[],"mappings":";;;;;;AAAA,+BAA8C;AAArC,mHAAA,OAAO,OAAc;AAC9B,iCAA8D;AAArD,mIAAA,OAAO,OAA6B;AAC7C,uCAAsD;AAA7C,2HAAA,OAAO,OAAkB;AAClC,iCAAgD;AAAvC,qHAAA,OAAO,OAAe;AAC/B,+BAA8C;AAArC,mHAAA,OAAO,OAAc;AAC9B,yCAAwD;AAA/C,6HAAA,OAAO,OAAmB"}
|