@shopify/shopify-api 3.0.0-rc.3 → 3.1.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 +19 -0
- package/dist/__tests__/fake-resource-with-custom-prefix.d.ts.map +1 -1
- package/dist/__tests__/fake-resource-with-custom-prefix.js +7 -5
- package/dist/__tests__/fake-resource.d.ts +1 -0
- package/dist/__tests__/fake-resource.d.ts.map +1 -1
- package/dist/__tests__/fake-resource.js +16 -13
- package/dist/auth/oauth/oauth.d.ts.map +1 -1
- package/dist/auth/oauth/oauth.js +12 -15
- package/dist/auth/scopes/index.js +5 -5
- package/dist/auth/session/index.d.ts +11 -1
- package/dist/auth/session/index.d.ts.map +1 -1
- package/dist/auth/session/index.js +16 -1
- package/dist/auth/session/session-utils.d.ts +7 -0
- package/dist/auth/session/session-utils.d.ts.map +1 -0
- package/dist/auth/session/session-utils.js +50 -0
- package/dist/auth/session/storage/__tests__/battery-of-tests.d.ts +3 -0
- package/dist/auth/session/storage/__tests__/battery-of-tests.d.ts.map +1 -0
- package/dist/auth/session/storage/__tests__/battery-of-tests.js +78 -0
- package/dist/auth/session/storage/__tests__/utils.d.ts +10 -0
- package/dist/auth/session/storage/__tests__/utils.d.ts.map +1 -0
- package/dist/auth/session/storage/__tests__/utils.js +87 -0
- package/dist/auth/session/storage/custom.js +4 -4
- package/dist/auth/session/storage/mongodb.d.ts +23 -0
- package/dist/auth/session/storage/mongodb.d.ts.map +1 -0
- package/dist/auth/session/storage/mongodb.js +150 -0
- package/dist/auth/session/storage/mysql.d.ts +22 -0
- package/dist/auth/session/storage/mysql.d.ts.map +1 -0
- package/dist/auth/session/storage/mysql.js +154 -0
- package/dist/auth/session/storage/postgresql.d.ts +24 -0
- package/dist/auth/session/storage/postgresql.d.ts.map +1 -0
- package/dist/auth/session/storage/postgresql.js +172 -0
- package/dist/auth/session/storage/redis.d.ts +20 -0
- package/dist/auth/session/storage/redis.d.ts.map +1 -0
- package/dist/auth/session/storage/redis.js +105 -0
- package/dist/auth/session/storage/sqlite.d.ts +19 -0
- package/dist/auth/session/storage/sqlite.d.ts.map +1 -0
- package/dist/auth/session/storage/sqlite.js +125 -0
- package/dist/base-rest-resource.d.ts +3 -1
- package/dist/base-rest-resource.d.ts.map +1 -1
- package/dist/base-rest-resource.js +31 -19
- package/dist/base-types.d.ts +1 -0
- package/dist/base-types.d.ts.map +1 -1
- package/dist/clients/graphql/graphql_client.js +1 -1
- package/dist/clients/http_client/http_client.d.ts.map +1 -1
- package/dist/clients/http_client/http_client.js +16 -20
- package/dist/clients/rest/rest_client.js +5 -3
- package/dist/context.d.ts +1 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +9 -3
- package/dist/error.js +4 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/abandoned_checkout.d.ts +2 -2
- package/dist/rest-resources/2021-07/abandoned_checkout.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/abandoned_checkout.js +2 -3
- package/dist/rest-resources/2021-07/article.d.ts +4 -1
- package/dist/rest-resources/2021-07/article.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/article.js +7 -6
- package/dist/rest-resources/2021-07/checkout.d.ts +2 -0
- package/dist/rest-resources/2021-07/checkout.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/customer.d.ts +2 -1
- package/dist/rest-resources/2021-07/customer.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/customer.js +5 -5
- package/dist/rest-resources/2021-07/draft_order.d.ts +1 -0
- package/dist/rest-resources/2021-07/draft_order.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/fulfillment.d.ts +0 -21
- package/dist/rest-resources/2021-07/fulfillment.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/fulfillment.js +1 -74
- package/dist/rest-resources/2021-07/gift_card_adjustment.js +1 -1
- package/dist/rest-resources/2021-07/index.js +2 -0
- package/dist/rest-resources/2021-07/metafield.d.ts +54 -5
- package/dist/rest-resources/2021-07/metafield.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/metafield.js +82 -22
- package/dist/rest-resources/2021-07/order.d.ts +2 -0
- package/dist/rest-resources/2021-07/order.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/variant.d.ts +1 -0
- package/dist/rest-resources/2021-07/variant.d.ts.map +1 -1
- package/dist/rest-resources/2021-07/variant.js +4 -0
- package/dist/rest-resources/2021-10/abandoned_checkout.d.ts +2 -2
- package/dist/rest-resources/2021-10/abandoned_checkout.d.ts.map +1 -1
- package/dist/rest-resources/2021-10/abandoned_checkout.js +2 -3
- package/dist/rest-resources/2021-10/article.d.ts +4 -1
- package/dist/rest-resources/2021-10/article.d.ts.map +1 -1
- package/dist/rest-resources/2021-10/article.js +7 -6
- package/dist/rest-resources/2021-10/checkout.d.ts +2 -0
- package/dist/rest-resources/2021-10/checkout.d.ts.map +1 -1
- package/dist/rest-resources/2021-10/customer.d.ts +2 -1
- package/dist/rest-resources/2021-10/customer.d.ts.map +1 -1
- package/dist/rest-resources/2021-10/customer.js +5 -5
- package/dist/rest-resources/2021-10/draft_order.d.ts +1 -0
- package/dist/rest-resources/2021-10/draft_order.d.ts.map +1 -1
- package/dist/rest-resources/2021-10/fulfillment.d.ts +0 -21
- package/dist/rest-resources/2021-10/fulfillment.d.ts.map +1 -1
- package/dist/rest-resources/2021-10/fulfillment.js +1 -74
- package/dist/rest-resources/2021-10/gift_card_adjustment.js +1 -1
- package/dist/rest-resources/2021-10/index.js +2 -0
- package/dist/rest-resources/2021-10/metafield.d.ts +54 -5
- package/dist/rest-resources/2021-10/metafield.d.ts.map +1 -1
- package/dist/rest-resources/2021-10/metafield.js +82 -22
- package/dist/rest-resources/2021-10/order.d.ts +2 -0
- package/dist/rest-resources/2021-10/order.d.ts.map +1 -1
- package/dist/rest-resources/2021-10/variant.d.ts +1 -0
- package/dist/rest-resources/2021-10/variant.d.ts.map +1 -1
- package/dist/rest-resources/2021-10/variant.js +4 -0
- package/dist/rest-resources/2022-01/abandoned_checkout.d.ts +2 -2
- package/dist/rest-resources/2022-01/abandoned_checkout.d.ts.map +1 -1
- package/dist/rest-resources/2022-01/abandoned_checkout.js +2 -3
- package/dist/rest-resources/2022-01/article.d.ts +4 -1
- package/dist/rest-resources/2022-01/article.d.ts.map +1 -1
- package/dist/rest-resources/2022-01/article.js +7 -6
- package/dist/rest-resources/2022-01/checkout.d.ts +2 -0
- package/dist/rest-resources/2022-01/checkout.d.ts.map +1 -1
- package/dist/rest-resources/2022-01/customer.d.ts +2 -1
- package/dist/rest-resources/2022-01/customer.d.ts.map +1 -1
- package/dist/rest-resources/2022-01/customer.js +5 -5
- package/dist/rest-resources/2022-01/draft_order.d.ts +1 -0
- package/dist/rest-resources/2022-01/draft_order.d.ts.map +1 -1
- package/dist/rest-resources/2022-01/fulfillment.d.ts +0 -21
- package/dist/rest-resources/2022-01/fulfillment.d.ts.map +1 -1
- package/dist/rest-resources/2022-01/fulfillment.js +1 -74
- package/dist/rest-resources/2022-01/gift_card_adjustment.js +1 -1
- package/dist/rest-resources/2022-01/index.js +2 -0
- package/dist/rest-resources/2022-01/metafield.d.ts +54 -5
- package/dist/rest-resources/2022-01/metafield.d.ts.map +1 -1
- package/dist/rest-resources/2022-01/metafield.js +82 -22
- package/dist/rest-resources/2022-01/order.d.ts +2 -0
- package/dist/rest-resources/2022-01/order.d.ts.map +1 -1
- package/dist/rest-resources/2022-01/variant.d.ts +1 -0
- package/dist/rest-resources/2022-01/variant.d.ts.map +1 -1
- package/dist/rest-resources/2022-01/variant.js +4 -0
- package/dist/rest-resources/2022-04/abandoned_checkout.d.ts +2 -2
- package/dist/rest-resources/2022-04/abandoned_checkout.d.ts.map +1 -1
- package/dist/rest-resources/2022-04/abandoned_checkout.js +2 -3
- package/dist/rest-resources/2022-04/article.d.ts +4 -1
- package/dist/rest-resources/2022-04/article.d.ts.map +1 -1
- package/dist/rest-resources/2022-04/article.js +7 -6
- package/dist/rest-resources/2022-04/checkout.d.ts +2 -0
- package/dist/rest-resources/2022-04/checkout.d.ts.map +1 -1
- package/dist/rest-resources/2022-04/customer.d.ts +5 -1
- package/dist/rest-resources/2022-04/customer.d.ts.map +1 -1
- package/dist/rest-resources/2022-04/customer.js +5 -5
- package/dist/rest-resources/2022-04/draft_order.d.ts +1 -0
- package/dist/rest-resources/2022-04/draft_order.d.ts.map +1 -1
- package/dist/rest-resources/2022-04/gift_card_adjustment.js +1 -1
- package/dist/rest-resources/2022-04/index.js +2 -0
- package/dist/rest-resources/2022-04/metafield.d.ts +54 -5
- package/dist/rest-resources/2022-04/metafield.d.ts.map +1 -1
- package/dist/rest-resources/2022-04/metafield.js +82 -22
- package/dist/rest-resources/2022-04/order.d.ts +2 -0
- package/dist/rest-resources/2022-04/order.d.ts.map +1 -1
- package/dist/rest-resources/2022-04/variant.d.ts +1 -0
- package/dist/rest-resources/2022-04/variant.d.ts.map +1 -1
- package/dist/rest-resources/2022-04/variant.js +4 -0
- package/dist/utils/decode-session-token.d.ts.map +1 -1
- package/dist/utils/decode-session-token.js +1 -5
- package/dist/utils/graphql_proxy.js +1 -1
- package/dist/utils/hmac-validator.js +2 -5
- package/dist/utils/processed-query.js +3 -3
- package/dist/utils/safe-compare.d.ts.map +1 -1
- package/dist/utils/safe-compare.js +17 -15
- package/dist/utils/setup-jest.d.ts.map +1 -1
- package/dist/utils/setup-jest.js +4 -3
- package/dist/utils/shop-validator.d.ts.map +1 -1
- package/dist/utils/shop-validator.js +1 -0
- package/dist/utils/with-session.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/webhooks/registry.d.ts +2 -1
- package/dist/webhooks/registry.d.ts.map +1 -1
- package/dist/webhooks/registry.js +39 -13
- package/package.json +12 -4
|
@@ -19,7 +19,7 @@ function withSession(_a) {
|
|
|
19
19
|
if (!req || !res) {
|
|
20
20
|
throw new ShopifyErrors.MissingRequiredArgument('Please pass in both the "request" and "response" objects.');
|
|
21
21
|
}
|
|
22
|
-
return [4 /*yield*/, load_current_session_1.default(req, res)];
|
|
22
|
+
return [4 /*yield*/, (0, load_current_session_1.default)(req, res)];
|
|
23
23
|
case 1:
|
|
24
24
|
session = _b.sent();
|
|
25
25
|
return [3 /*break*/, 4];
|
|
@@ -27,7 +27,7 @@ function withSession(_a) {
|
|
|
27
27
|
if (!shop) {
|
|
28
28
|
throw new ShopifyErrors.MissingRequiredArgument('Please pass in a value for "shop"');
|
|
29
29
|
}
|
|
30
|
-
return [4 /*yield*/, load_offline_session_1.default(shop)];
|
|
30
|
+
return [4 /*yield*/, (0, load_offline_session_1.default)(shop)];
|
|
31
31
|
case 3:
|
|
32
32
|
session = _b.sent();
|
|
33
33
|
_b.label = 4;
|
|
@@ -52,7 +52,7 @@ function withSession(_a) {
|
|
|
52
52
|
session: session,
|
|
53
53
|
}];
|
|
54
54
|
default:
|
|
55
|
-
throw new ShopifyErrors.UnsupportedClientType("\""
|
|
55
|
+
throw new ShopifyErrors.UnsupportedClientType("\"".concat(clientType, "\" is an unsupported clientType. Please use \"rest\" or \"graphql\"."));
|
|
56
56
|
}
|
|
57
57
|
return [2 /*return*/];
|
|
58
58
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SHOPIFY_API_LIBRARY_VERSION = "
|
|
1
|
+
export declare const SHOPIFY_API_LIBRARY_VERSION = "3.1.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -59,6 +59,7 @@ interface RegistryInterface {
|
|
|
59
59
|
}
|
|
60
60
|
declare function buildCheckQuery(topic: string): string;
|
|
61
61
|
declare function buildQuery(topic: string, address: string, deliveryMethod?: DeliveryMethod, webhookId?: string): string;
|
|
62
|
+
declare const gdprTopics: string[];
|
|
62
63
|
declare const WebhooksRegistry: RegistryInterface;
|
|
63
|
-
export { WebhooksRegistry, RegistryInterface, buildCheckQuery, buildQuery };
|
|
64
|
+
export { WebhooksRegistry, RegistryInterface, buildCheckQuery, buildQuery, gdprTopics, };
|
|
64
65
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/webhooks/registry.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAUxB,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,oBAAoB,EAEpB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,UAAU,gBAAgB;IACxB,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACvC;AAED,UAAU,iBAAiB;IACzB,eAAe,EAAE;QAAC,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAA;KAAC,CAAC;IAEzD;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAE/D;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE9C;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAAC;IAEvD;;OAEG;IACH,SAAS,IAAI,MAAM,EAAE,CAAC;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE5D;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAExE;;;;;OAKG;IACH,OAAO,CACL,OAAO,EAAE,IAAI,CAAC,eAAe,EAC7B,QAAQ,EAAE,IAAI,CAAC,cAAc,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;OAIG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACtC;AAiCD,iBAAS,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAuB9C;AAED,iBAAS,UAAU,CACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,cAAc,GAAE,cAAoC,EACpD,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAmDR;AAED,QAAA,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/webhooks/registry.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAUxB,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,oBAAoB,EAEpB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,UAAU,gBAAgB;IACxB,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACvC;AAED,UAAU,iBAAiB;IACzB,eAAe,EAAE;QAAC,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAAA;KAAC,CAAC;IAEzD;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAE/D;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE9C;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAAC;IAEvD;;OAEG;IACH,SAAS,IAAI,MAAM,EAAE,CAAC;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE5D;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAExE;;;;;OAKG;IACH,OAAO,CACL,OAAO,EAAE,IAAI,CAAC,eAAe,EAC7B,QAAQ,EAAE,IAAI,CAAC,cAAc,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;OAIG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACtC;AAiCD,iBAAS,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAuB9C;AAED,iBAAS,UAAU,CACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,cAAc,GAAE,cAAoC,EACpD,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAmDR;AAED,QAAA,MAAM,UAAU,EAAE,MAAM,EAIvB,CAAC;AAEF,QAAA,MAAM,gBAAgB,EAAE,iBA0PvB,CAAC;AAEF,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,UAAU,GACX,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildQuery = exports.buildCheckQuery = exports.WebhooksRegistry = void 0;
|
|
3
|
+
exports.gdprTopics = exports.buildQuery = exports.buildCheckQuery = exports.WebhooksRegistry = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var crypto_1 = require("crypto");
|
|
6
6
|
var network_1 = require("@shopify/network");
|
|
@@ -34,7 +34,7 @@ function validateDeliveryMethod(_deliveryMethod) {
|
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
36
|
function buildCheckQuery(topic) {
|
|
37
|
-
return "{\n webhookSubscriptions(first: 1, topics: "
|
|
37
|
+
return "{\n webhookSubscriptions(first: 1, topics: ".concat(topic, ") {\n edges {\n node {\n id\n endpoint {\n __typename\n ... on WebhookHttpEndpoint {\n callbackUrl\n }\n ... on WebhookEventBridgeEndpoint {\n arn\n }\n ... on WebhookPubSubEndpoint {\n pubSubProject\n pubSubTopic\n }\n }\n }\n }\n }\n }");
|
|
38
38
|
}
|
|
39
39
|
exports.buildCheckQuery = buildCheckQuery;
|
|
40
40
|
function buildQuery(topic, address, deliveryMethod, webhookId) {
|
|
@@ -43,10 +43,10 @@ function buildQuery(topic, address, deliveryMethod, webhookId) {
|
|
|
43
43
|
validateDeliveryMethod(deliveryMethod);
|
|
44
44
|
var identifier;
|
|
45
45
|
if (webhookId) {
|
|
46
|
-
identifier = "id: \""
|
|
46
|
+
identifier = "id: \"".concat(webhookId, "\"");
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
identifier = "topic: "
|
|
49
|
+
identifier = "topic: ".concat(topic);
|
|
50
50
|
}
|
|
51
51
|
var mutationName;
|
|
52
52
|
var webhookSubscriptionArgs;
|
|
@@ -57,13 +57,13 @@ function buildQuery(topic, address, deliveryMethod, webhookId) {
|
|
|
57
57
|
mutationName = webhookId
|
|
58
58
|
? 'webhookSubscriptionUpdate'
|
|
59
59
|
: 'webhookSubscriptionCreate';
|
|
60
|
-
webhookSubscriptionArgs = "{callbackUrl: \""
|
|
60
|
+
webhookSubscriptionArgs = "{callbackUrl: \"".concat(address, "\"}");
|
|
61
61
|
break;
|
|
62
62
|
case types_1.DeliveryMethod.EventBridge:
|
|
63
63
|
mutationName = webhookId
|
|
64
64
|
? 'eventBridgeWebhookSubscriptionUpdate'
|
|
65
65
|
: 'eventBridgeWebhookSubscriptionCreate';
|
|
66
|
-
webhookSubscriptionArgs = "{arn: \""
|
|
66
|
+
webhookSubscriptionArgs = "{arn: \"".concat(address, "\"}");
|
|
67
67
|
break;
|
|
68
68
|
case types_1.DeliveryMethod.PubSub:
|
|
69
69
|
mutationName = webhookId
|
|
@@ -72,12 +72,18 @@ function buildQuery(topic, address, deliveryMethod, webhookId) {
|
|
|
72
72
|
_a = tslib_1.__read(address
|
|
73
73
|
.replace(/^pubsub:\/\//, '')
|
|
74
74
|
.split(':'), 2), pubSubProject = _a[0], pubSubTopic = _a[1];
|
|
75
|
-
webhookSubscriptionArgs = "{pubSubProject: \""
|
|
75
|
+
webhookSubscriptionArgs = "{pubSubProject: \"".concat(pubSubProject, "\",\n pubSubTopic: \"").concat(pubSubTopic, "\"}");
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
|
-
return "\n mutation webhookSubscription {\n "
|
|
78
|
+
return "\n mutation webhookSubscription {\n ".concat(mutationName, "(").concat(identifier, ", webhookSubscription: ").concat(webhookSubscriptionArgs, ") {\n userErrors {\n field\n message\n }\n webhookSubscription {\n id\n }\n }\n }\n ");
|
|
79
79
|
}
|
|
80
80
|
exports.buildQuery = buildQuery;
|
|
81
|
+
var gdprTopics = [
|
|
82
|
+
'CUSTOMERS_DATA_REQUEST',
|
|
83
|
+
'CUSTOMERS_REDACT',
|
|
84
|
+
'SHOP_REDACT',
|
|
85
|
+
];
|
|
86
|
+
exports.gdprTopics = gdprTopics;
|
|
81
87
|
var WebhooksRegistry = {
|
|
82
88
|
webhookRegistry: {},
|
|
83
89
|
addHandler: function (topic, _a) {
|
|
@@ -106,10 +112,23 @@ var WebhooksRegistry = {
|
|
|
106
112
|
switch (_c.label) {
|
|
107
113
|
case 0:
|
|
108
114
|
registerReturn = {};
|
|
115
|
+
if (gdprTopics.includes(topic)) {
|
|
116
|
+
registerReturn[topic] = {
|
|
117
|
+
success: false,
|
|
118
|
+
result: {
|
|
119
|
+
errors: [
|
|
120
|
+
{
|
|
121
|
+
message: "GDPR topic '".concat(topic, "' cannot be registered here. Please set the appropriate webhook endpoint in the 'GDPR mandatory webhooks' section of 'App setup' in the Partners Dashboard"),
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
return [2 /*return*/, registerReturn];
|
|
127
|
+
}
|
|
109
128
|
validateDeliveryMethod(deliveryMethod);
|
|
110
129
|
client = new graphql_client_1.GraphqlClient(shop, accessToken);
|
|
111
130
|
address = deliveryMethod === types_1.DeliveryMethod.Http
|
|
112
|
-
? "
|
|
131
|
+
? "".concat(context_1.Context.HOST_SCHEME, "://").concat(context_1.Context.HOST_NAME).concat(path)
|
|
113
132
|
: path;
|
|
114
133
|
return [4 /*yield*/, client.query({
|
|
115
134
|
data: buildCheckQuery(topic),
|
|
@@ -117,6 +136,13 @@ var WebhooksRegistry = {
|
|
|
117
136
|
case 1:
|
|
118
137
|
checkResult = (_c.sent());
|
|
119
138
|
mustRegister = true;
|
|
139
|
+
if ('errors' in checkResult.body) {
|
|
140
|
+
registerReturn[topic] = {
|
|
141
|
+
success: false,
|
|
142
|
+
result: checkResult.body,
|
|
143
|
+
};
|
|
144
|
+
return [2 /*return*/, registerReturn];
|
|
145
|
+
}
|
|
120
146
|
if (checkResult.body.data.webhookSubscriptions.edges.length) {
|
|
121
147
|
node = checkResult.body.data.webhookSubscriptions.edges[0].node;
|
|
122
148
|
endpointAddress = '';
|
|
@@ -252,10 +278,10 @@ var WebhooksRegistry = {
|
|
|
252
278
|
if (missingHeaders.length) {
|
|
253
279
|
response.writeHead(network_1.StatusCode.BadRequest);
|
|
254
280
|
response.end();
|
|
255
|
-
return [2 /*return*/, reject(new ShopifyErrors.InvalidWebhookError("Missing one or more of the required HTTP headers to process webhooks: ["
|
|
281
|
+
return [2 /*return*/, reject(new ShopifyErrors.InvalidWebhookError("Missing one or more of the required HTTP headers to process webhooks: [".concat(missingHeaders.join(', '), "]")))];
|
|
256
282
|
}
|
|
257
283
|
headers = {};
|
|
258
|
-
generatedHash = crypto_1.createHmac('sha256', context_1.Context.API_SECRET_KEY)
|
|
284
|
+
generatedHash = (0, crypto_1.createHmac)('sha256', context_1.Context.API_SECRET_KEY)
|
|
259
285
|
.update(reqBody, 'utf8')
|
|
260
286
|
.digest('base64');
|
|
261
287
|
if (!utils_1.default.safeCompare(generatedHash, hmac)) return [3 /*break*/, 7];
|
|
@@ -280,12 +306,12 @@ var WebhooksRegistry = {
|
|
|
280
306
|
case 4: return [3 /*break*/, 6];
|
|
281
307
|
case 5:
|
|
282
308
|
statusCode = network_1.StatusCode.Forbidden;
|
|
283
|
-
responseError = new ShopifyErrors.InvalidWebhookError("No webhook is registered for topic "
|
|
309
|
+
responseError = new ShopifyErrors.InvalidWebhookError("No webhook is registered for topic ".concat(topic));
|
|
284
310
|
_a.label = 6;
|
|
285
311
|
case 6: return [3 /*break*/, 8];
|
|
286
312
|
case 7:
|
|
287
313
|
statusCode = network_1.StatusCode.Forbidden;
|
|
288
|
-
responseError = new ShopifyErrors.InvalidWebhookError("Could not validate request for topic "
|
|
314
|
+
responseError = new ShopifyErrors.InvalidWebhookError("Could not validate request for topic ".concat(topic));
|
|
289
315
|
_a.label = 8;
|
|
290
316
|
case 8:
|
|
291
317
|
response.writeHead(statusCode, headers);
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/shopify-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Shopify API Library for Node - accelerate development with support for authentication, graphql proxy, webhooks",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"prettier": "@shopify/prettier-config",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"test": "jest --testPathIgnorePatterns=src/rest-resources/__tests__",
|
|
9
|
+
"test": "jest --testPathIgnorePatterns=src/rest-resources/__tests__ --testPathIgnorePatterns=src/auth/session/storage",
|
|
10
|
+
"test_sessionstorage": "jest src/auth/session/storage",
|
|
10
11
|
"test_rest_resources": "ls src/rest-resources/__tests__ | xargs -I \"{}\" sh -c 'yarn jest --no-coverage --testPathPattern=\\\"{}\\\" || exit 255'",
|
|
11
12
|
"build": "tsc",
|
|
12
13
|
"lint": "eslint '**/*.{ts,tsx}' --max-warnings 0",
|
|
@@ -49,7 +50,12 @@
|
|
|
49
50
|
"@types/supertest": "^2.0.10",
|
|
50
51
|
"cookies": "^0.8.0",
|
|
51
52
|
"jsonwebtoken": "^8.5.1",
|
|
53
|
+
"mongodb": "^4.5.0",
|
|
54
|
+
"mysql2": "^2.3.3",
|
|
52
55
|
"node-fetch": "^2.6.1",
|
|
56
|
+
"pg": "^8.7.3",
|
|
57
|
+
"redis": "^4.0.6",
|
|
58
|
+
"sqlite3": "^5.0.2",
|
|
53
59
|
"tslib": "^2.0.3",
|
|
54
60
|
"uuid": "^8.3.1"
|
|
55
61
|
},
|
|
@@ -58,7 +64,9 @@
|
|
|
58
64
|
"@shopify/prettier-config": "^1.1.2",
|
|
59
65
|
"@types/cookies": "^0.7.5",
|
|
60
66
|
"@types/jest": "^26.0.15",
|
|
61
|
-
"@types/node": "^14.
|
|
67
|
+
"@types/node": "^14.18.12",
|
|
68
|
+
"@types/pg": "^8.6.5",
|
|
69
|
+
"@types/sqlite3": "^3.1.8",
|
|
62
70
|
"@types/uuid": "^8.3.0",
|
|
63
71
|
"eslint": "^7.30.0",
|
|
64
72
|
"eslint-plugin-prettier": "^4.0.0",
|
|
@@ -69,7 +77,7 @@
|
|
|
69
77
|
"rimraf": "^3.0.2",
|
|
70
78
|
"supertest": "^6.1.3",
|
|
71
79
|
"ts-jest": "^27.1.1",
|
|
72
|
-
"typescript": "^
|
|
80
|
+
"typescript": "^4.6.3"
|
|
73
81
|
},
|
|
74
82
|
"files": [
|
|
75
83
|
"dist/*",
|