@agnostack/next-shopify 1.13.4 → 1.13.5-alpha.1
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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.13.5-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.13.4...v1.13.5-alpha.1) (2023-11-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* wip ([6bc1e78](https://github.com/agnostack/next-shopify/commit/6bc1e78c764fde2673669c80ad525f733f413d7f))
|
|
7
|
+
|
|
1
8
|
## [1.13.4](https://github.com/agnostack/next-shopify/compare/v1.13.3...v1.13.4) (2023-11-29)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -537,29 +544,6 @@
|
|
|
537
544
|
* updated for old headers ([acdc756](https://github.com/agnostack/next-shopify/commit/acdc756e31f87a30b8ab3e74544668cc5ac8bde3))
|
|
538
545
|
* updated for old headerss ([ff0db89](https://github.com/agnostack/next-shopify/commit/ff0db899dade86c24bb17b8a61c7a8a4024b85a0))
|
|
539
546
|
|
|
540
|
-
## [1.13.3-beta.3](https://github.com/agnostack/next-shopify/compare/v1.13.3-beta.2...v1.13.3-beta.3) (2023-11-26)
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
### Bug Fixes
|
|
544
|
-
|
|
545
|
-
* updated for old headers ([acdc756](https://github.com/agnostack/next-shopify/commit/acdc756e31f87a30b8ab3e74544668cc5ac8bde3))
|
|
546
|
-
* updated for old headerss ([ff0db89](https://github.com/agnostack/next-shopify/commit/ff0db899dade86c24bb17b8a61c7a8a4024b85a0))
|
|
547
|
-
|
|
548
|
-
## [1.13.3-beta.2](https://github.com/agnostack/next-shopify/compare/v1.13.3-beta.1...v1.13.3-beta.2) (2023-11-22)
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
### Bug Fixes
|
|
552
|
-
|
|
553
|
-
* exposed subtle crypto ([2a915d5](https://github.com/agnostack/next-shopify/commit/2a915d58914ae8ce54149dc81899caf8e9bc4ec1))
|
|
554
|
-
|
|
555
|
-
## [1.13.3-beta.1](https://github.com/agnostack/next-shopify/compare/v1.13.2...v1.13.3-beta.1) (2023-11-22)
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
### Bug Fixes
|
|
559
|
-
|
|
560
|
-
* exposed subtle crypto ([3f9f0ab](https://github.com/agnostack/next-shopify/commit/3f9f0ab48a75317c6d9d7dd2251cc9d51f222da4))
|
|
561
|
-
* exposed subtle crypto ([c68c1cc](https://github.com/agnostack/next-shopify/commit/c68c1cc0e0ea35dea83272db9c812f6c09e46201))
|
|
562
|
-
|
|
563
547
|
## [1.13.2](https://github.com/agnostack/next-shopify/compare/v1.13.1...v1.13.2) (2023-11-22)
|
|
564
548
|
|
|
565
549
|
|
|
@@ -577,7 +561,6 @@
|
|
|
577
561
|
* wip ([d1e3b84](https://github.com/agnostack/next-shopify/commit/d1e3b847764dc9341404c5ecd37428bfde2f26ec))
|
|
578
562
|
* wip ([e10a3a6](https://github.com/agnostack/next-shopify/commit/e10a3a67e4d3fe5bbb743a968730847b4479eb89))
|
|
579
563
|
* wip ([860ac69](https://github.com/agnostack/next-shopify/commit/860ac69b07e173f5098169673cf3e64c34aac52c))
|
|
580
|
-
|
|
581
564
|
## [1.13.1](https://github.com/agnostack/next-shopify/compare/v1.13.0...v1.13.1) (2023-11-17)
|
|
582
565
|
|
|
583
566
|
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export function handleSessionToken(serverRuntimeConfig: any,
|
|
1
|
+
export function handleSessionToken(serverRuntimeConfig: any, { signingSecret, ...signingData }?: {
|
|
2
|
+
signingSecret: any;
|
|
3
|
+
}): (req: any, res: any) => Promise<any>;
|
|
2
4
|
//# sourceMappingURL=token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/lib/handlers/api/token.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/lib/handlers/api/token.js"],"names":[],"mappings":"AAeO;;yCAuGN"}
|
|
@@ -9,39 +9,31 @@ const uuid_1 = require("uuid");
|
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
const shared_1 = require("../../../shared");
|
|
11
11
|
// NOTE: typically handling: "/api/token"
|
|
12
|
-
const handleSessionToken = (serverRuntimeConfig,
|
|
13
|
-
|
|
12
|
+
const handleSessionToken = (serverRuntimeConfig, _a = {}) => {
|
|
13
|
+
var { signingSecret } = _a, signingData = tslib_1.__rest(_a, ["signingSecret"]);
|
|
14
|
+
const { APP_CONFIG } = serverRuntimeConfig !== null && serverRuntimeConfig !== void 0 ? serverRuntimeConfig : {};
|
|
14
15
|
return (req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
var
|
|
16
|
-
const { host } = (
|
|
17
|
-
const
|
|
16
|
+
var _b, _c;
|
|
17
|
+
const { host } = (_b = req.query) !== null && _b !== void 0 ? _b : {};
|
|
18
|
+
const _d = (_c = req.headers) !== null && _c !== void 0 ? _c : {}, { 'x-shopify-app-installation-id': shopifyAppInstallationId, 'x-shopify-app-id': shopifyAppId, 'x-app-installation-id': appInstallationId = shopifyAppInstallationId,
|
|
18
19
|
// TODO: pass along providerSetId??
|
|
19
|
-
'x-app-id': appId = shopifyAppId, 'x-
|
|
20
|
-
'x-shop-domain': shopDomain, 'x-shopify-shop-domain': shopifyShopDomain, 'x-shopify-shop': shop = shopifyShopDomain !== null && shopifyShopDomain !== void 0 ? shopifyShopDomain : shopDomain } =
|
|
20
|
+
'x-app-id': appId = shopifyAppId, 'x-client-id': clientId, // NOTE: this is the Client in ZD token for messenger auth // NOTE/TODO: keyPairs.messenger need to move to app metafields instead
|
|
21
|
+
'x-shop-domain': shopDomain, 'x-shopify-shop-domain': shopifyShopDomain, 'x-shopify-shop': shop = shopifyShopDomain !== null && shopifyShopDomain !== void 0 ? shopifyShopDomain : shopDomain } = _d, headers = tslib_1.__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']);
|
|
21
22
|
try {
|
|
22
23
|
// TODO: un-btoa the host and check??
|
|
23
24
|
if ((0, shared_1.stringEmpty)(shop) || (0, shared_1.stringEmpty)(host)) {
|
|
24
25
|
return res.status(412).json({ message: 'Missing required param' });
|
|
25
26
|
}
|
|
26
|
-
// HMMMMMMM: not sure about this aud/kid
|
|
27
|
-
let aud = keyId; // NOTE: Client ID of the receiving app
|
|
28
27
|
// NOTE raw request body is required for shopify's validation
|
|
29
28
|
const _rawBody = yield (0, raw_body_1.default)(req);
|
|
30
29
|
const rawBody = _rawBody.toString();
|
|
31
30
|
const parsedBody = JSON.parse(rawBody || '{}'); // NOTE: parsedBody should be encrypted when isVerifiable
|
|
32
31
|
let decryptedBody = parsedBody;
|
|
33
|
-
// NOTE/TODO: keyPairs.messenger need to move to app metafields instead
|
|
34
|
-
let signingSecret;
|
|
35
|
-
if (keyId && (keyPairs === null || keyPairs === void 0 ? void 0 : keyPairs.messenger) && (keyId == keyPairs.messenger)) {
|
|
36
|
-
signingData = Object.assign(Object.assign({}, signingData), { header: {
|
|
37
|
-
kid: keyPairs.messenger.publicKey,
|
|
38
|
-
} });
|
|
39
|
-
signingSecret = keyPairs.messenger.privateKey;
|
|
40
|
-
}
|
|
41
32
|
const appClaims = Object.entries(headers).reduce((_appClaims, [headerKey, headerValue]) => (Object.assign(Object.assign({}, _appClaims), headerKey.startsWith('x-shopify-app-metafield-') && {
|
|
42
33
|
[(0, shared_1.snakecase)(headerKey.replace('x-shopify-app-metafield-', ''))]: headerValue,
|
|
43
34
|
})), Object.assign(Object.assign({}, appId && { app_id: (0, shared_1.normalizeShopifyId)(appId).id }), appInstallationId && { installation_id: (0, shared_1.normalizeShopifyId)(appInstallationId).id }));
|
|
44
|
-
const
|
|
35
|
+
const _e = decryptedBody !== null && decryptedBody !== void 0 ? decryptedBody : {}, { sub, aud: _aud } = _e, body = tslib_1.__rest(_e, ["sub", "aud"]);
|
|
36
|
+
const aud = [clientId, _aud, APP_CONFIG.apiKey].find(shared_1.stringNotEmpty);
|
|
45
37
|
let { dest, iss, sid, jti } = body, tokenBody = tslib_1.__rest(body, ["dest", "iss", "sid", "jti"]);
|
|
46
38
|
if ((0, shared_1.stringEmpty)(dest)) {
|
|
47
39
|
dest = shop;
|
|
@@ -56,9 +48,6 @@ const handleSessionToken = (serverRuntimeConfig, signingData) => {
|
|
|
56
48
|
jti = (0, uuid_1.v4)();
|
|
57
49
|
sid = `${sid}.${jti}`;
|
|
58
50
|
}
|
|
59
|
-
if ((0, shared_1.stringEmpty)(aud)) {
|
|
60
|
-
aud = _aud || APP_CONFIG.apiKey;
|
|
61
|
-
}
|
|
62
51
|
const payload = Object.assign(Object.assign(Object.assign({ shop,
|
|
63
52
|
host,
|
|
64
53
|
iss,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../../src/lib/handlers/api/token.js"],"names":[],"mappings":";;;;AAAA,gEAAiC;AACjC,yCAAkC;AAClC,+CAAmC;AACnC,+BAAmC;AAEnC,uCAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../../src/lib/handlers/api/token.js"],"names":[],"mappings":";;;;AAAA,gEAAiC;AACjC,yCAAkC;AAClC,+CAAmC;AACnC,+BAAmC;AAEnC,uCAA0C;AAC1C,4CAMwB;AAExB,yCAAyC;AAClC,MAAM,kBAAkB,GAAG,CAAC,mBAAmB,EAAE,KAAoC,EAAE,EAAE,EAAE;QAA1C,EAAE,aAAa,OAAuB,EAAlB,WAAW,sBAA/B,iBAAiC,CAAF;IACrF,MAAM,EAAE,UAAU,EAAE,GAAG,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB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,IAAI;gBACJ,GAAG;gBACH,IAAI;gBACJ,GAAG;gBACH,GAAG;gBACH,GAAG,IACA,GAAG,IAAI,EAAE,GAAG,EAAE,GACd,SAAS,GACT,SAAS,CACb,CAAA;YAED,IAAI,IAAA,oBAAW,EAAC,aAAa,CAAC,EAAE;gBAC9B,aAAa,GAAG,IAAA,oBAAY,EAAC,IAAA,6BAAoB,EAAC,OAAO,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAA;aACrF;YAED,MAAM,KAAK,GAAG,IAAA,mBAAI,EAAC,OAAO,EAAE,aAAa,EAAE,WAAW,CAAC,CAAA;YAEvD,IAAI,IAAA,oBAAW,EAAC,KAAK,CAAC,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;aACvC;YAED,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;SACvC;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;AAvGY,QAAA,kBAAkB,sBAuG9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agnostack/next-shopify",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.5-alpha.1",
|
|
4
4
|
"author": "agnoStack Dev <developers@agnostack.com> (https://agnostack.com)",
|
|
5
5
|
"owner": "agnoStack",
|
|
6
6
|
"description": "Please contact agnoStack via info@agnostack.com for any questions",
|