@sommpicks/sommpicks-shopify 24.12.8 → 24.12.9
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/.eslintrc.js +26 -0
- package/dist/Logger.d.ts +1 -0
- package/dist/Logger.d.ts.map +1 -0
- package/dist/Logger.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/indexBuild.d.ts +1 -0
- package/dist/services/CacheWrapper.d.ts +1 -0
- package/dist/services/CacheWrapper.d.ts.map +1 -0
- package/dist/services/CacheWrapper.js.map +1 -1
- package/dist/services/CountryCodeService.d.ts +1 -0
- package/dist/services/CountryCodeService.d.ts.map +1 -0
- package/dist/services/CountryCodeService.js.map +1 -1
- package/dist/shopify/ShopifyAppService.d.ts +1 -0
- package/dist/shopify/ShopifyAppService.d.ts.map +1 -0
- package/dist/shopify/ShopifyAppService.js.map +1 -1
- package/dist/shopify/ShopifyAssetService.d.ts +1 -0
- package/dist/shopify/ShopifyAssetService.d.ts.map +1 -0
- package/dist/shopify/ShopifyAssetService.js.map +1 -1
- package/dist/shopify/ShopifyBillingService.d.ts +1 -0
- package/dist/shopify/ShopifyBillingService.d.ts.map +1 -0
- package/dist/shopify/ShopifyBillingService.js.map +1 -1
- package/dist/shopify/ShopifyCartTrasnformationService.d.ts +1 -0
- package/dist/shopify/ShopifyCartTrasnformationService.d.ts.map +1 -0
- package/dist/shopify/ShopifyCartTrasnformationService.js.map +1 -1
- package/dist/shopify/ShopifyCollectionService.d.ts +1 -0
- package/dist/shopify/ShopifyCollectionService.d.ts.map +1 -0
- package/dist/shopify/ShopifyCollectionService.js.map +1 -1
- package/dist/shopify/ShopifyCustomerService.d.ts +1 -0
- package/dist/shopify/ShopifyCustomerService.d.ts.map +1 -0
- package/dist/shopify/ShopifyCustomerService.js.map +1 -1
- package/dist/shopify/ShopifyDeliveryCustomisationService.d.ts +1 -0
- package/dist/shopify/ShopifyDeliveryCustomisationService.d.ts.map +1 -0
- package/dist/shopify/ShopifyDeliveryCustomisationService.js.map +1 -1
- package/dist/shopify/ShopifyDiscountService.d.ts +1 -0
- package/dist/shopify/ShopifyDiscountService.d.ts.map +1 -0
- package/dist/shopify/ShopifyDiscountService.js.map +1 -1
- package/dist/shopify/ShopifyDraftOrderService.d.ts +1 -0
- package/dist/shopify/ShopifyDraftOrderService.d.ts.map +1 -0
- package/dist/shopify/ShopifyDraftOrderService.js.map +1 -1
- package/dist/shopify/ShopifyFulfillmentService.d.ts +1 -0
- package/dist/shopify/ShopifyFulfillmentService.d.ts.map +1 -0
- package/dist/shopify/ShopifyFulfillmentService.js.map +1 -1
- package/dist/shopify/ShopifyFunctionsProductDiscountsService.d.ts +1 -0
- package/dist/shopify/ShopifyFunctionsProductDiscountsService.d.ts.map +1 -0
- package/dist/shopify/ShopifyFunctionsProductDiscountsService.js.map +1 -1
- package/dist/shopify/ShopifyInventoryService.d.ts +1 -0
- package/dist/shopify/ShopifyInventoryService.d.ts.map +1 -0
- package/dist/shopify/ShopifyInventoryService.js.map +1 -1
- package/dist/shopify/ShopifyLocationService.d.ts +1 -0
- package/dist/shopify/ShopifyLocationService.d.ts.map +1 -0
- package/dist/shopify/ShopifyLocationService.js.map +1 -1
- package/dist/shopify/ShopifyOrderRefundsService.d.ts +1 -0
- package/dist/shopify/ShopifyOrderRefundsService.d.ts.map +1 -0
- package/dist/shopify/ShopifyOrderRefundsService.js.map +1 -1
- package/dist/shopify/ShopifyOrderRiskService.d.ts +1 -0
- package/dist/shopify/ShopifyOrderRiskService.d.ts.map +1 -0
- package/dist/shopify/ShopifyOrderRiskService.js.map +1 -1
- package/dist/shopify/ShopifyOrderService.d.ts +1 -0
- package/dist/shopify/ShopifyOrderService.d.ts.map +1 -0
- package/dist/shopify/ShopifyOrderService.js.map +1 -1
- package/dist/shopify/ShopifyPageService.d.ts +1 -0
- package/dist/shopify/ShopifyPageService.d.ts.map +1 -0
- package/dist/shopify/ShopifyPageService.js.map +1 -1
- package/dist/shopify/ShopifyProductService.d.ts +1 -0
- package/dist/shopify/ShopifyProductService.d.ts.map +1 -0
- package/dist/shopify/ShopifyProductService.js.map +1 -1
- package/dist/shopify/ShopifyShippingZonesService.d.ts +1 -0
- package/dist/shopify/ShopifyShippingZonesService.d.ts.map +1 -0
- package/dist/shopify/ShopifyShippingZonesService.js.map +1 -1
- package/dist/shopify/ShopifyShopService.d.ts +1 -0
- package/dist/shopify/ShopifyShopService.d.ts.map +1 -0
- package/dist/shopify/ShopifyShopService.js.map +1 -1
- package/dist/shopify/ShopifyTemplateService.d.ts +1 -0
- package/dist/shopify/ShopifyTemplateService.d.ts.map +1 -0
- package/dist/shopify/ShopifyTemplateService.js.map +1 -1
- package/dist/shopify/ShopifyThemeService.d.ts +1 -0
- package/dist/shopify/ShopifyThemeService.d.ts.map +1 -0
- package/dist/shopify/ShopifyThemeService.js.map +1 -1
- package/dist/shopify/ShopifyUtils.d.ts +1 -0
- package/dist/shopify/ShopifyUtils.d.ts.map +1 -0
- package/dist/shopify/ShopifyUtils.js.map +1 -1
- package/dist/shopify/ShopifyWebhookService.d.ts +1 -0
- package/dist/shopify/ShopifyWebhookService.d.ts.map +1 -0
- package/dist/shopify/ShopifyWebhookService.js.map +1 -1
- package/dist/shopify/base/APIVersion.d.ts +1 -0
- package/dist/shopify/base/APIVersion.d.ts.map +1 -0
- package/dist/shopify/base/APIVersion.js.map +1 -1
- package/dist/shopify/base/AbstractService.d.ts +1 -0
- package/dist/shopify/base/AbstractService.d.ts.map +1 -0
- package/dist/shopify/base/AbstractService.js.map +1 -1
- package/dist/shopify/base/ErrorHelper.d.ts +1 -0
- package/dist/shopify/base/ErrorHelper.d.ts.map +1 -0
- package/dist/shopify/base/ErrorHelper.js.map +1 -1
- package/dist/shopify/errors/InspiraShopifyCustomError.d.ts +1 -0
- package/dist/shopify/errors/InspiraShopifyCustomError.d.ts.map +1 -0
- package/dist/shopify/errors/InspiraShopifyCustomError.js.map +1 -1
- package/dist/shopify/errors/InspiraShopifyError.d.ts +1 -0
- package/dist/shopify/errors/InspiraShopifyError.d.ts.map +1 -0
- package/dist/shopify/errors/InspiraShopifyError.js.map +1 -1
- package/dist/shopify/errors/InspiraShopifyUnableToReserveInventoryError.d.ts +1 -0
- package/dist/shopify/errors/InspiraShopifyUnableToReserveInventoryError.d.ts.map +1 -0
- package/dist/shopify/errors/InspiraShopifyUnableToReserveInventoryError.js.map +1 -1
- package/dist/shopify/helpers/ShopifyProductServiceHelper.d.ts +1 -0
- package/dist/shopify/helpers/ShopifyProductServiceHelper.d.ts.map +1 -0
- package/dist/shopify/helpers/ShopifyProductServiceHelper.js.map +1 -1
- package/dist/shopify/product/ShopifyProductCountService.d.ts +1 -0
- package/dist/shopify/product/ShopifyProductCountService.d.ts.map +1 -0
- package/dist/shopify/product/ShopifyProductCountService.js.map +1 -1
- package/dist/shopify/product/ShopifyProductListService.d.ts +1 -0
- package/dist/shopify/product/ShopifyProductListService.d.ts.map +1 -0
- package/dist/shopify/product/ShopifyProductListService.js.map +1 -1
- package/dist/shopify/product/ShopifyProductMetafieldsService.d.ts +1 -0
- package/dist/shopify/product/ShopifyProductMetafieldsService.d.ts.map +1 -0
- package/dist/shopify/product/ShopifyProductMetafieldsService.js.map +1 -1
- package/dist/shopify/product/ShopifyProductPublicationsService.d.ts +1 -0
- package/dist/shopify/product/ShopifyProductPublicationsService.d.ts.map +1 -0
- package/dist/shopify/product/ShopifyProductPublicationsService.js.map +1 -1
- package/dist/shopify/product/ShopifyVariantService.d.ts +1 -0
- package/dist/shopify/product/ShopifyVariantService.d.ts.map +1 -0
- package/dist/shopify/product/ShopifyVariantService.js.map +1 -1
- package/dist/shopify/router/ShopifyMandatoryRouter.d.ts +1 -0
- package/dist/shopify/router/ShopifyMandatoryRouter.d.ts.map +1 -0
- package/dist/shopify/router/ShopifyMandatoryRouter.js.map +1 -1
- package/dist/shopify/router/ShopifyRouter.d.ts +1 -0
- package/dist/shopify/router/ShopifyRouter.d.ts.map +1 -0
- package/dist/shopify/router/ShopifyRouter.js +62 -3
- package/dist/shopify/router/ShopifyRouter.js.map +1 -1
- package/dist/shopify/router/ShopifyRouterBis.d.ts +1 -0
- package/dist/shopify/router/ShopifyRouterBis.d.ts.map +1 -0
- package/dist/shopify/router/ShopifyRouterBis.js.map +1 -1
- package/dist/shopify/router/ShopifyRouterBisBis.d.ts +1 -0
- package/dist/shopify/router/ShopifyRouterBisBis.d.ts.map +1 -0
- package/dist/shopify/router/ShopifyRouterBisBis.js.map +1 -1
- package/dist/shopify/router/ShopifyRouterBisBisBis.d.ts +1 -0
- package/dist/shopify/router/ShopifyRouterBisBisBis.d.ts.map +1 -0
- package/dist/shopify/router/ShopifyRouterBisBisBis.js.map +1 -1
- package/dist/shopify/router/ShopifyRouterBisBisBisBis.d.ts +1 -0
- package/dist/shopify/router/ShopifyRouterBisBisBisBis.d.ts.map +1 -0
- package/dist/shopify/router/ShopifyRouterBisBisBisBis.js.map +1 -1
- package/dist/shopify/router/WebhookSkipMiddleware.d.ts +1 -0
- package/dist/shopify/router/WebhookSkipMiddleware.d.ts.map +1 -0
- package/dist/shopify/router/WebhookSkipMiddleware.js.map +1 -1
- package/dist/shopify/router/services/CryptoService.d.ts +2 -0
- package/dist/shopify/router/services/CryptoService.d.ts.map +1 -0
- package/dist/shopify/router/services/CryptoService.js.map +1 -1
- package/dist/shopify/router/services/HmacValidator.d.ts +1 -0
- package/dist/shopify/router/services/HmacValidator.d.ts.map +1 -0
- package/dist/shopify/router/services/HmacValidator.js.map +1 -1
- package/dist/shopify/router/services/OauthService.d.ts +1 -0
- package/dist/shopify/router/services/OauthService.d.ts.map +1 -0
- package/dist/shopify/router/services/OauthService.js.map +1 -1
- package/dist/shopify/router/services/RestUtils.d.ts +1 -0
- package/dist/shopify/router/services/RestUtils.d.ts.map +1 -0
- package/dist/shopify/router/services/RestUtils.js.map +1 -1
- package/dist/shopify/router/services/rateLimiter/MemoryStores.d.ts +1 -0
- package/dist/shopify/router/services/rateLimiter/MemoryStores.d.ts.map +1 -0
- package/dist/shopify/router/services/rateLimiter/MemoryStores.js.map +1 -1
- package/dist/shopify/router/services/rateLimiter/StoreRateLimiter.d.ts +1 -0
- package/dist/shopify/router/services/rateLimiter/StoreRateLimiter.d.ts.map +1 -0
- package/dist/shopify/router/services/rateLimiter/StoreRateLimiter.js.map +1 -1
- package/dist/test/router/ShopifyRouter.test.d.ts +1 -0
- package/dist/test/router/ShopifyRouter.test.d.ts.map +1 -0
- package/dist/test/router/ShopifyRouter.test.js.map +1 -1
- package/dist/test/router/WebhookSkipMiddleware.test.d.ts +1 -0
- package/dist/test/router/WebhookSkipMiddleware.test.d.ts.map +1 -0
- package/dist/test/router/WebhookSkipMiddleware.test.js.map +1 -1
- package/dist/test/router/services/HmacValidator.test.d.ts +1 -0
- package/dist/test/router/services/HmacValidator.test.d.ts.map +1 -0
- package/dist/test/router/services/HmacValidator.test.js.map +1 -1
- package/dist/test/router/services/RestUtils.test.d.ts +1 -0
- package/dist/test/router/services/RestUtils.test.d.ts.map +1 -0
- package/dist/test/router/services/RestUtils.test.js.map +1 -1
- package/dist/test/router/services/rateLimiter/StoreRateLimiter.test.d.ts +1 -0
- package/dist/test/router/services/rateLimiter/StoreRateLimiter.test.d.ts.map +1 -0
- package/dist/test/router/services/rateLimiter/StoreRateLimiter.test.js.map +1 -1
- package/dist/test/services/CacheWrapper.test.d.ts +1 -0
- package/dist/test/services/CacheWrapper.test.d.ts.map +1 -0
- package/dist/test/services/CacheWrapper.test.js.map +1 -1
- package/dist/test/shopify/ShopifyOrderService.test.d.ts +1 -0
- package/dist/test/shopify/ShopifyOrderService.test.d.ts.map +1 -0
- package/dist/test/shopify/ShopifyOrderService.test.js.map +1 -1
- package/dist/test/shopify/ShopifyProductService.test.d.ts +1 -0
- package/dist/test/shopify/ShopifyProductService.test.d.ts.map +1 -0
- package/dist/test/shopify/ShopifyProductService.test.js.map +1 -1
- package/dist/test/shopify/ShopifyWebhookService.test.d.ts +1 -0
- package/dist/test/shopify/ShopifyWebhookService.test.d.ts.map +1 -0
- package/dist/test/shopify/ShopifyWebhookService.test.js.map +1 -1
- package/package.json +8 -1
- package/shopify/router/ShopifyRouter.ts +62 -4
- package/tsconfig.json +2 -0
|
@@ -13,13 +13,23 @@ export class ShopifyRouter {
|
|
|
13
13
|
|
|
14
14
|
constructor( private shop_secret: string, private shop_key: string, private appBaseUrl: string, private endpointUri: string, private getScopes: (shop: string) => string | Promise<string>, private callback: (accessToken: string, shop: string, host: string, expresResponse: Response, secFetchDest: boolean, error: any) => void) {
|
|
15
15
|
this.cryptoService = new CryptoService();
|
|
16
|
-
Logger.info(`cryptoservice: ${this.cryptoService}`);
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
public buildRoutes(): express.Router {
|
|
20
19
|
//initial call to /shopify
|
|
21
20
|
router.get('/', async (req,res,next) => {
|
|
22
21
|
Logger.info(`ShopifyRouter - request: ${req}`);
|
|
22
|
+
try {
|
|
23
|
+
if (process && process.env && process.env.SP_ROUTER_DEBUG === '1') {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.info('[sommpicks-shopify][ShopifyRouter][/shopify request]', {
|
|
26
|
+
method: req.method,
|
|
27
|
+
path: (req as any).path,
|
|
28
|
+
query: (req as any).query,
|
|
29
|
+
headers: { 'sec-fetch-dest': (req as any).headers?.['sec-fetch-dest'] }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
} catch { /* ignore debug logging errors */ }
|
|
23
33
|
const scopes = await this.getScopes(req.query.shop as string);
|
|
24
34
|
Logger.info(`ShopifyRouter - scopes: ${scopes}`);
|
|
25
35
|
res.locals.scopes = scopes;
|
|
@@ -27,6 +37,20 @@ export class ShopifyRouter {
|
|
|
27
37
|
}, this.installRoute);
|
|
28
38
|
// endpoint when merchant accepts the installation
|
|
29
39
|
router.get('/callback', this.callBackRoute);
|
|
40
|
+
router.get('/auth/callback', this.callBackRoute);
|
|
41
|
+
Logger.info('build routes was hit!');
|
|
42
|
+
try {
|
|
43
|
+
if (process && process.env && process.env.SP_ROUTER_DEBUG === '1') {
|
|
44
|
+
const r: any = router as any;
|
|
45
|
+
const routes = Array.isArray(r?.stack)
|
|
46
|
+
? r.stack
|
|
47
|
+
.filter((l: any) => l && l.route)
|
|
48
|
+
.map((l: any) => ({ path: l.route.path, methods: Object.keys(l.route.methods || {}) }))
|
|
49
|
+
: [];
|
|
50
|
+
// eslint-disable-next-line no-console
|
|
51
|
+
console.info('[sommpicks-shopify][ShopifyRouter][routes]', routes);
|
|
52
|
+
}
|
|
53
|
+
} catch { /* ignore debug logging errors */ }
|
|
30
54
|
return router;
|
|
31
55
|
}
|
|
32
56
|
|
|
@@ -37,13 +61,18 @@ export class ShopifyRouter {
|
|
|
37
61
|
const hmac = expresRequest.query.hmac as string;
|
|
38
62
|
const code = expresRequest.query.code as string;
|
|
39
63
|
const host = expresRequest.query.host as string;
|
|
64
|
+
Logger.info('we are using the updated version');
|
|
65
|
+
console.log('we are console logging the updated version');
|
|
40
66
|
Logger.info(`ShopifyRouter - callBackRoute From shopify ${code}`);
|
|
41
67
|
if (shop && hmac && code) {
|
|
42
68
|
const map = Object.assign({}, expresRequest.query);
|
|
43
69
|
delete map['signature'];
|
|
44
70
|
delete map['hmac'];
|
|
45
71
|
const secFetchDest = req.headers['sec-fetch-dest'];
|
|
46
|
-
const
|
|
72
|
+
const sortedKeys = Object.keys(map).sort();
|
|
73
|
+
const sortedMap: any = {};
|
|
74
|
+
sortedKeys.forEach(key => sortedMap[key] = map[key]);
|
|
75
|
+
const message = querystring.stringify(sortedMap);
|
|
47
76
|
|
|
48
77
|
const hashEquals = this.cryptoService.checkHash(this.cryptoService.generateHash(message, this.shop_secret), hmac);
|
|
49
78
|
if (!hashEquals) { expresResponse.status(401).send('HMAC validation failed'); return; }
|
|
@@ -85,13 +114,42 @@ export class ShopifyRouter {
|
|
|
85
114
|
private installUrl(shop: string, scopes: string): string {
|
|
86
115
|
// this URL is used to install the app. you can get it and run it on the browser, it should install the app
|
|
87
116
|
Logger.info(`installURL shop: ${shop}`);
|
|
88
|
-
|
|
117
|
+
// Explicitly request offline (permanent) access tokens
|
|
118
|
+
return `https://${shop}/admin/oauth/authorize?client_id=${this.shop_key}&scope=${scopes}&redirect_uri=${this.redirectUri()}&access_mode=offline`;
|
|
89
119
|
}
|
|
90
120
|
|
|
91
121
|
private redirectUri(): string {
|
|
92
|
-
// the callback for when the merchant has approved the
|
|
122
|
+
// the callback for when the merchant has approved the request
|
|
93
123
|
return `${this.appBaseUrl}${this.endpointUri}/callback`;
|
|
94
124
|
}
|
|
95
125
|
}
|
|
96
126
|
|
|
127
|
+
// Debug export and router shape when enabled via env
|
|
128
|
+
try {
|
|
129
|
+
if (process && process.env && process.env.SP_ROUTER_DEBUG === '1') {
|
|
130
|
+
const exportMeta = {
|
|
131
|
+
classType: typeof ShopifyRouter,
|
|
132
|
+
className: (ShopifyRouter as any)?.name,
|
|
133
|
+
prototypeMethods: Object.getOwnPropertyNames((ShopifyRouter as any)?.prototype || {}).filter(m => m !== 'constructor')
|
|
134
|
+
};
|
|
135
|
+
// eslint-disable-next-line no-console
|
|
136
|
+
console.info('[sommpicks-shopify][ShopifyRouter][export-meta]', exportMeta);
|
|
137
|
+
|
|
138
|
+
const r: any = router as any;
|
|
139
|
+
const routerMeta = {
|
|
140
|
+
type: typeof router,
|
|
141
|
+
isMiddleware: typeof router === 'function',
|
|
142
|
+
keys: Object.keys(r || {}),
|
|
143
|
+
stackLength: Array.isArray(r?.stack) ? r.stack.length : undefined,
|
|
144
|
+
props: {
|
|
145
|
+
caseSensitive: r?.caseSensitive,
|
|
146
|
+
mergeParams: r?.mergeParams,
|
|
147
|
+
strict: r?.strict
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
// eslint-disable-next-line no-console
|
|
151
|
+
console.info('[sommpicks-shopify][ShopifyRouter][express-router-meta]', routerMeta);
|
|
152
|
+
}
|
|
153
|
+
} catch { /* ignore debug logging errors */ }
|
|
154
|
+
|
|
97
155
|
export default ShopifyRouter;
|