@agnostack/next-shopify 4.0.0-canary.8 → 4.0.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 +98 -0
- package/dist/esm/lib/handlers/api/billing.js +3 -2
- package/dist/esm/lib/handlers/api/callback.js +4 -3
- package/dist/esm/lib/handlers/api/uninstall.js +3 -2
- package/dist/esm/lib/handlers/api/verifiable/appInstallation.js +3 -2
- package/dist/esm/lib/handlers/api/verifiable/graph.js +3 -2
- package/dist/esm/lib/handlers/api/verifiable/proxy.js +3 -2
- package/dist/esm/lib/handlers/api/webhook.js +3 -2
- package/dist/esm/lib/handlers/ssr/protect.js +3 -2
- package/dist/esm/lib/index.js +0 -1
- package/dist/esm/lib/utils/session.js +18 -22
- package/dist/esm/shared/index.js +2 -0
- package/dist/esm/shared/storage.js +35 -0
- package/dist/esm/shared/types.js +3 -0
- package/dist/lib/handlers/api/billing.d.ts +1 -1
- package/dist/lib/handlers/api/billing.js +3 -2
- package/dist/lib/handlers/api/callback.d.ts +1 -1
- package/dist/lib/handlers/api/callback.js +4 -3
- package/dist/lib/handlers/api/uninstall.d.ts +1 -1
- package/dist/lib/handlers/api/uninstall.js +3 -2
- package/dist/lib/handlers/api/verifiable/appInstallation.d.ts +1 -1
- package/dist/lib/handlers/api/verifiable/appInstallation.js +3 -2
- package/dist/lib/handlers/api/verifiable/graph.d.ts +1 -1
- package/dist/lib/handlers/api/verifiable/graph.js +3 -2
- package/dist/lib/handlers/api/verifiable/proxy.d.ts +1 -1
- package/dist/lib/handlers/api/verifiable/proxy.js +3 -2
- package/dist/lib/handlers/api/webhook.d.ts +1 -1
- package/dist/lib/handlers/api/webhook.js +3 -2
- package/dist/lib/handlers/ssr/protect.d.ts +1 -1
- package/dist/lib/handlers/ssr/protect.js +3 -2
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +0 -1
- package/dist/lib/utils/session.d.ts +2 -4
- package/dist/lib/utils/session.js +18 -22
- package/dist/lib/utils/types.d.ts +20 -16
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +2 -0
- package/dist/shared/storage.d.ts +2 -0
- package/dist/shared/storage.js +39 -0
- package/dist/shared/types.d.ts +72 -1
- package/dist/shared/types.js +2 -0
- package/package.json +4 -31
- package/dist/esm/storage/firestore/index.js +0 -77
- package/dist/esm/storage/index.js +0 -54
- package/dist/storage/firestore/index.d.ts +0 -4
- package/dist/storage/firestore/index.js +0 -81
- package/dist/storage/index.d.ts +0 -61
- package/dist/storage/index.js +0 -58
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
+
# [4.0.0](https://github.com/agnostack/next-shopify/compare/v3.3.0...v4.0.0) (2026-10-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
* feat!: require a storage implementation rather than bundling one ([a13f021](https://github.com/agnostack/next-shopify/commit/a13f02143b0836a35e0506443ec9fdbf674518db))
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* add dev copies of the required peers so checkJs can resolve them ([6c7fdd2](https://github.com/agnostack/next-shopify/commit/6c7fdd2ce0f6094bc0477b48cea39be189bc1329))
|
|
10
|
+
* add pnpm-lock.yaml ([bfc803a](https://github.com/agnostack/next-shopify/commit/bfc803a3e758d72e13a1f201cff266f43a28665d))
|
|
11
|
+
* address the review notes on the checkjs stack ([52dca8d](https://github.com/agnostack/next-shopify/commit/52dca8d006f6d7f192982d5a91c5b814041127ec))
|
|
12
|
+
* align .gitignore with the shared template ([5968bf1](https://github.com/agnostack/next-shopify/commit/5968bf193a32cd0c4f3f45f6d71694b8f872961c))
|
|
13
|
+
* build and test against firebase-admin 14.4.0 ([cf75069](https://github.com/agnostack/next-shopify/commit/cf75069fab599ab29d8e2d95068c91044c7ae191))
|
|
14
|
+
* bump cookies to 0.9.1 ([6e7554c](https://github.com/agnostack/next-shopify/commit/6e7554c3bd85bc57f9bffcafecd7c65564d06160))
|
|
15
|
+
* bump isbot to 5.2.2 and import it by name ([30c1228](https://github.com/agnostack/next-shopify/commit/30c12288f1754809d25a4c9db2334d09c487db08))
|
|
16
|
+
* bump js-base64 to 3.9.3 ([7543e32](https://github.com/agnostack/next-shopify/commit/7543e3220f5b9d265a1ee205caff08d0ef0cf1ae))
|
|
17
|
+
* bump jwt-decode to 4.0.0 ([bc5df03](https://github.com/agnostack/next-shopify/commit/bc5df03761dc691566833ea9fa5e1e93622befb1))
|
|
18
|
+
* bump minimatch to 10.2.6 ([8aa0dc6](https://github.com/agnostack/next-shopify/commit/8aa0dc61678a778522409e2659baa490728d8e2b))
|
|
19
|
+
* bump nextjs-cors to 2.2.1 ([173860d](https://github.com/agnostack/next-shopify/commit/173860dd166f8e7eaade280f5480dcd207f637a6))
|
|
20
|
+
* bump uuid to 11.1.1 and drop its stub typings ([fa02d50](https://github.com/agnostack/next-shopify/commit/fa02d50b52540577a7191fb9b5e02dcba63213c9))
|
|
21
|
+
* cap the firebase-admin peer below 14 ([42b2b32](https://github.com/agnostack/next-shopify/commit/42b2b3259184e623418209704bfd82c86a56481a)), closes [firebase/firebase-admin-node#3164](https://github.com/firebase/firebase-admin-node/issues/3164)
|
|
22
|
+
* compare ArrayBuffer hashes by their byte length ([1b08a62](https://github.com/agnostack/next-shopify/commit/1b08a623fceea251b1721c39fa9907c77b22bb7f))
|
|
23
|
+
* compile the CommonJS sources for the node that can require esm ([f30407a](https://github.com/agnostack/next-shopify/commit/f30407a77e4344d9d6a410b921a9b17edfc891c5))
|
|
24
|
+
* declare typescript as 5.x like the rest of the toolchain ([a1e7ee3](https://github.com/agnostack/next-shopify/commit/a1e7ee38f8bd189265f1590811236ddb29b839af))
|
|
25
|
+
* decode zstd in the proxy response adapter and fail closed on unknown encodings ([cdcd8a5](https://github.com/agnostack/next-shopify/commit/cdcd8a559e9ff772bdcd4e42ce46a3ebf6fca92c))
|
|
26
|
+
* drop jsonwebtoken ([5abb88c](https://github.com/agnostack/next-shopify/commit/5abb88c466e967134ca785c005067566150d4965))
|
|
27
|
+
* fail clearly when the shopify api is bypassed instead of with a TypeError ([d7e647e](https://github.com/agnostack/next-shopify/commit/d7e647e0fd75ffb4e5a09b203768720f6460b153))
|
|
28
|
+
* float firebase-admin to 14.x ([5784493](https://github.com/agnostack/next-shopify/commit/5784493cdbcb3130f54299b364d61f29b0179bdb))
|
|
29
|
+
* float the http-proxy devDependency to 1.18.x ([825819b](https://github.com/agnostack/next-shopify/commit/825819b0e39e8d3b4ef62fec9dfc8ff8a90a924b))
|
|
30
|
+
* give the dual export subpaths a default condition ([10c2c90](https://github.com/agnostack/next-shopify/commit/10c2c9024ccab238444249551d32aeda9520be21))
|
|
31
|
+
* give the test workflow read-only permissions and cancel superseded runs ([2b26326](https://github.com/agnostack/next-shopify/commit/2b26326d78b6bc7c02eac948009e24191dd6274f))
|
|
32
|
+
* hand isbot a string for the User-Agent lookup ([2b42b4c](https://github.com/agnostack/next-shopify/commit/2b42b4c588af3ed0358904e3fffeed2e8401a010))
|
|
33
|
+
* import jsonwebtoken as a default so the esm build links under native node ([3db30d9](https://github.com/agnostack/next-shopify/commit/3db30d9b9d8a6882de7ff714e93b2fc3df3eece2))
|
|
34
|
+
* inflate proxied responses in the adapter so corrupt bodies fail closed ([3056b5d](https://github.com/agnostack/next-shopify/commit/3056b5df9a351368725111feeed7d7371e652e56))
|
|
35
|
+
* keep the storage contract and its implementations in one tree ([2b380e7](https://github.com/agnostack/next-shopify/commit/2b380e789d41385d56f2c4464917db32e888beb1))
|
|
36
|
+
* keep the storage contract in shared and the storage folder for implementations ([e862a11](https://github.com/agnostack/next-shopify/commit/e862a1129b71668fcae431b164ba66e1e51906e7))
|
|
37
|
+
* mark the version-signalling peers optional ([87b2c6d](https://github.com/agnostack/next-shopify/commit/87b2c6de6d7cdd89b9a9b60be56c7955fa85e3df))
|
|
38
|
+
* move both workflows to checkout v6, pnpm/action-setup v6 and setup-node v5 ([46669e7](https://github.com/agnostack/next-shopify/commit/46669e73fd17862726970d622c232486df5eaac5))
|
|
39
|
+
* move the session handler to the modular firebase-admin imports ([0ef15fc](https://github.com/agnostack/next-shopify/commit/0ef15fc7a26a8a6989ca0ec5831d762504e5a89f))
|
|
40
|
+
* move vitest to 4.x ([2b0b7de](https://github.com/agnostack/next-shopify/commit/2b0b7de7b70120cda4b1051a89a1848137e1e377))
|
|
41
|
+
* name getShopifyHelpers' return type so its declaration is emitted ([e871d98](https://github.com/agnostack/next-shopify/commit/e871d987d0ad93d8c8e9442a512067e2ba531bb3))
|
|
42
|
+
* notes and a GitHub release on every publishing branch, changelog only on stable releases ([2c9ad23](https://github.com/agnostack/next-shopify/commit/2c9ad2356a0c3f834bac8423d900078513d0eca0))
|
|
43
|
+
* queue overlapping release runs instead of cancelling them ([d75f9dc](https://github.com/agnostack/next-shopify/commit/d75f9dc0c246e3388b28ef4c4a1429140e8248dd))
|
|
44
|
+
* raise the next and react peer floors to the versions the app runs ([1efb9c9](https://github.com/agnostack/next-shopify/commit/1efb9c95a2c41e6b97a89e1c76610de4a3df7039))
|
|
45
|
+
* read the proxied content-encoding case-insensitively and treat identity as none ([d2e0351](https://github.com/agnostack/next-shopify/commit/d2e03513e93212a95f2cb1c0b6d3173285f5dd0a))
|
|
46
|
+
* reflow the checkJs JSDoc into multi-line blocks and drop the inline parameter casts ([73e855e](https://github.com/agnostack/next-shopify/commit/73e855ea290b13b6eccee5afbd066269f077dcff))
|
|
47
|
+
* replace node-http-proxy-json with a typed responseInterceptor adapter ([45bd502](https://github.com/agnostack/next-shopify/commit/45bd502bf98fb1ddfe057d05e35f6deae123143c))
|
|
48
|
+
* reset the proxied response immediately when the upstream aborts mid-body ([c14225e](https://github.com/agnostack/next-shopify/commit/c14225e10767c1781617d8e4e7d499b2e63d8ab7))
|
|
49
|
+
* resolve modules with node16 and split the tsconfigs ([9b87dd2](https://github.com/agnostack/next-shopify/commit/9b87dd2316c16f0c3272f4b1b57e72233b599e52))
|
|
50
|
+
* run semantic-release through pnpm exec so package keywords are not masked ([39cd371](https://github.com/agnostack/next-shopify/commit/39cd371007223b2bb1bda10c99a907f8ad91b486))
|
|
51
|
+
* satisfy the typecheck and pin the stored document paths ([83b2691](https://github.com/agnostack/next-shopify/commit/83b2691ddaf0b2e5f6b4fe0309a12bd6c56115ee))
|
|
52
|
+
* sign extension session tokens with jose ([0c3b0c0](https://github.com/agnostack/next-shopify/commit/0c3b0c00e017a42d25867032a78c18ada7881d15))
|
|
53
|
+
* skip CI on the release commit ([c277847](https://github.com/agnostack/next-shopify/commit/c277847f20d97eef849a9438945727e898d964e1))
|
|
54
|
+
* standardize version ([6fe44c5](https://github.com/agnostack/next-shopify/commit/6fe44c5ead19be5740ecd6ca58ddad82426f8ed3))
|
|
55
|
+
* standardize version ([4218665](https://github.com/agnostack/next-shopify/commit/42186651b7604a8438a4a01fedb940f5efae4f73))
|
|
56
|
+
* suffix relative imports so the esm build links under native node ([c73827e](https://github.com/agnostack/next-shopify/commit/c73827eea42044c980d11330abe3a5ee6a3a9893))
|
|
57
|
+
* take unknown in ensureStorage, since that is what it is deciding ([5a8a3f8](https://github.com/agnostack/next-shopify/commit/5a8a3f88fd18c5654e0928ab9c69626cd7ec2356))
|
|
58
|
+
* throw a clear error when CryptoHandler is used before it is initialized ([db17f06](https://github.com/agnostack/next-shopify/commit/db17f06ccc489feaa0af7cd5347f2f96cd09d078))
|
|
59
|
+
* type state as the consumer's own data rather than as opaque ([ca13e28](https://github.com/agnostack/next-shopify/commit/ca13e28f1e7f91a8c39c74f516e998c7848f8d0f))
|
|
60
|
+
* type the public helpers surface so it stops discarding the contract ([77088dd](https://github.com/agnostack/next-shopify/commit/77088dd4718a7de119c9446ba52df8648f47a388))
|
|
61
|
+
* type the storage contract so an implementation cannot read what it stores ([06c05bf](https://github.com/agnostack/next-shopify/commit/06c05bf80af1d5b1c2cc3fa8c4d0195e533daf33))
|
|
62
|
+
* type-check the js sources ([61f0783](https://github.com/agnostack/next-shopify/commit/61f0783e7e0108af8304b80a9d6391856afa40c3))
|
|
63
|
+
* verify extension session tokens with jose ([b436d11](https://github.com/agnostack/next-shopify/commit/b436d11b75f09470a98667130937a69753531ed4))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### chore
|
|
67
|
+
|
|
68
|
+
* modernize the toolchain to node 22, pnpm, eslint 9 and vitest ([0cc5cd4](https://github.com/agnostack/next-shopify/commit/0cc5cd4648ae2d173d192018ae204836b064bac8))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
### Features
|
|
72
|
+
|
|
73
|
+
* add ESM output and /esm + /shared subpath exports ([52c7c15](https://github.com/agnostack/next-shopify/commit/52c7c1530eaee759c3a02adb663f3d68d6bffe47))
|
|
74
|
+
* declare a session-storage contract and accept an implementation ([9f22481](https://github.com/agnostack/next-shopify/commit/9f22481f4cc65e6edfe908a0505a7daecab75ea3))
|
|
75
|
+
* enable npm trusted publishing with the token as fallback ([e72f5d2](https://github.com/agnostack/next-shopify/commit/e72f5d241e38569814b870c10fb0e499ff82baac))
|
|
76
|
+
* preview the release a labelled PR would cut ([746674c](https://github.com/agnostack/next-shopify/commit/746674c46d52136e706d7559c6daa5334eb6d88b)), closes [#67](https://github.com/agnostack/next-shopify/issues/67)
|
|
77
|
+
* replaced getAPIConfig with API_CONFIG page config literal ([d452ee9](https://github.com/agnostack/next-shopify/commit/d452ee90232a392fc4056ca11451a49a35736e00))
|
|
78
|
+
* thread the storage contract through every handler factory ([e3dfa32](https://github.com/agnostack/next-shopify/commit/e3dfa32a00358bb5bb78236f0d96dec1acebcd0a)), closes [#204](https://github.com/agnostack/next-shopify/issues/204)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### BREAKING CHANGES
|
|
82
|
+
|
|
83
|
+
* getShopifyHelpers no longer falls back to a bundled firestore
|
|
84
|
+
store. Every consumer must pass `storage`; omitting it now throws at composition
|
|
85
|
+
instead of silently writing sessions to a store this package chose. The
|
|
86
|
+
./storage/firestore export and the firebase-admin peer are removed with it.
|
|
87
|
+
|
|
88
|
+
Also recorded here because 4.0.0-canary.9 shipped it under a `fix:` type: the
|
|
89
|
+
./storage export was retired in favour of ./shared, which carries the contract,
|
|
90
|
+
its types and ensureStorage.
|
|
91
|
+
|
|
92
|
+
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
|
93
|
+
* requires node >=22.
|
|
94
|
+
|
|
95
|
+
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
96
|
+
* getAPIConfig has been removed — calling it in `export const config` is a fatal build error under next 15's static analyzer. Use the named re-export:
|
|
97
|
+
`export { API_CONFIG as config } from '@agnostack/next-shopify/lib'`
|
|
98
|
+
|
|
1
99
|
# [3.3.0](https://github.com/agnostack/next-shopify/compare/v3.2.2...v3.3.0) (2025-08-20)
|
|
2
100
|
|
|
3
101
|
|
|
@@ -21,8 +21,9 @@ const TERMINAL_STATUSES = [
|
|
|
21
21
|
/**
|
|
22
22
|
* @param {any} [serverRuntimeConfig]
|
|
23
23
|
* @param {any} [data]
|
|
24
|
+
* @param {import('../../../shared/index.js').StorageOptions} [options]
|
|
24
25
|
*/
|
|
25
|
-
export const handleAppBilling = (serverRuntimeConfig, data) => {
|
|
26
|
+
export const handleAppBilling = (serverRuntimeConfig, data, options) => {
|
|
26
27
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
27
28
|
/**
|
|
28
29
|
* @param {any} req
|
|
@@ -45,7 +46,7 @@ export const handleAppBilling = (serverRuntimeConfig, data) => {
|
|
|
45
46
|
if (stringEmpty(shop)) {
|
|
46
47
|
return handleResponse({ handler: 'billing', error: 'Missing shop' });
|
|
47
48
|
}
|
|
48
|
-
const helpers = await getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
49
|
+
const helpers = await getShopifyHelpers(serverRuntimeConfig, { shop }, options);
|
|
49
50
|
if (!helpers.shopify) {
|
|
50
51
|
throw new Error('Shopify API is not initialized');
|
|
51
52
|
}
|
|
@@ -11,8 +11,9 @@ import { isTrue, appendQuery, stringEmpty, ensureArray, ensureString, stringNotE
|
|
|
11
11
|
/**
|
|
12
12
|
* @param {any} [serverRuntimeConfig]
|
|
13
13
|
* @param {any} [data]
|
|
14
|
+
* @param {import('../../../shared/index.js').StorageOptions} [options]
|
|
14
15
|
*/
|
|
15
|
-
export const handleCallback = (serverRuntimeConfig, data) => {
|
|
16
|
+
export const handleCallback = (serverRuntimeConfig, data, options) => {
|
|
16
17
|
const { API_PATHS, PAGE_PATHS, PAYMENT_CONFIG, } = serverRuntimeConfig;
|
|
17
18
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
18
19
|
const prepareWebhookHandlers = getPrepareWebhookHandlers(serverRuntimeConfig);
|
|
@@ -44,7 +45,7 @@ export const handleCallback = (serverRuntimeConfig, data) => {
|
|
|
44
45
|
let redirectUrl = `${errorPath}?code=invalid_callback_response`;
|
|
45
46
|
let shopify;
|
|
46
47
|
try {
|
|
47
|
-
const helpers = await getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
48
|
+
const helpers = await getShopifyHelpers(serverRuntimeConfig, { shop }, options);
|
|
48
49
|
if (!helpers.shopify) {
|
|
49
50
|
throw new Error('Shopify API is not initialized');
|
|
50
51
|
}
|
|
@@ -88,7 +89,7 @@ export const handleCallback = (serverRuntimeConfig, data) => {
|
|
|
88
89
|
// NOTE: handleEnsureBilling handles calling encryptStoreSession for offline session when shouldCheckBilling
|
|
89
90
|
const confirmationUrl = await handleEnsureBilling(session, { reAuth });
|
|
90
91
|
if (stringNotEmpty(confirmationUrl)) {
|
|
91
|
-
redirectUrl = confirmationUrl
|
|
92
|
+
redirectUrl = `${confirmationUrl}`;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
// NOTE confirm that state can be appended to the confirmationUrl,
|
|
@@ -16,8 +16,9 @@ import { stringEmpty, arrayNotEmpty, } from '../../../shared/index.js';
|
|
|
16
16
|
/**
|
|
17
17
|
* @param {any} [serverRuntimeConfig]
|
|
18
18
|
* @param {any} [data]
|
|
19
|
+
* @param {import('../../../shared/index.js').StorageOptions} [options]
|
|
19
20
|
*/
|
|
20
|
-
export const handleAppUninstalled = (serverRuntimeConfig, data) => {
|
|
21
|
+
export const handleAppUninstalled = (serverRuntimeConfig, data, options) => {
|
|
21
22
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
22
23
|
/**
|
|
23
24
|
* @param {any} req
|
|
@@ -40,7 +41,7 @@ export const handleAppUninstalled = (serverRuntimeConfig, data) => {
|
|
|
40
41
|
if (stringEmpty(shop)) {
|
|
41
42
|
return handleResponse({ handler: 'uninstall', error: 'Missing shop' });
|
|
42
43
|
}
|
|
43
|
-
const { shopify, findSessionIds, deleteSessions } = await getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
44
|
+
const { shopify, findSessionIds, deleteSessions } = await getShopifyHelpers(serverRuntimeConfig, { shop }, options);
|
|
44
45
|
if (!shopify) {
|
|
45
46
|
throw new Error('Shopify API is not initialized');
|
|
46
47
|
}
|
|
@@ -4,9 +4,10 @@ import { handleGraph } from './graph.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* @param {any} [serverRuntimeConfig]
|
|
6
6
|
* @param {any} [data]
|
|
7
|
+
* @param {import('../../../../shared/index.js').StorageOptions} [options]
|
|
7
8
|
*/
|
|
8
|
-
export const handleLoadAppInstallation = (serverRuntimeConfig, data) => {
|
|
9
|
-
const _handleGraph = handleGraph(serverRuntimeConfig, data);
|
|
9
|
+
export const handleLoadAppInstallation = (serverRuntimeConfig, data, options) => {
|
|
10
|
+
const _handleGraph = handleGraph(serverRuntimeConfig, data, options);
|
|
10
11
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
11
12
|
/**
|
|
12
13
|
* @param {any} req
|
|
@@ -16,8 +16,9 @@ import { isType, safeParse, stringEmpty, ensureString, ensureObject, ensureArray
|
|
|
16
16
|
/**
|
|
17
17
|
* @param {any} [serverRuntimeConfig]
|
|
18
18
|
* @param {any} [data]
|
|
19
|
+
* @param {import('../../../../shared/index.js').StorageOptions} [options]
|
|
19
20
|
*/
|
|
20
|
-
export const handleGraph = (serverRuntimeConfig, data) => {
|
|
21
|
+
export const handleGraph = (serverRuntimeConfig, data, options) => {
|
|
21
22
|
const _getVerificationHelpers = getVerificationHelpers(serverRuntimeConfig);
|
|
22
23
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
23
24
|
/**
|
|
@@ -62,7 +63,7 @@ export const handleGraph = (serverRuntimeConfig, data) => {
|
|
|
62
63
|
let headers;
|
|
63
64
|
let message = 'Error handling query call';
|
|
64
65
|
try {
|
|
65
|
-
const helpers = await getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
66
|
+
const helpers = await getShopifyHelpers(serverRuntimeConfig, { shop }, options);
|
|
66
67
|
if (!helpers.shopify) {
|
|
67
68
|
throw new Error('Shopify API is not initialized');
|
|
68
69
|
}
|
|
@@ -28,11 +28,12 @@ const verifyAppProxySignature = (signature, verifiable, hmacSecret) => {
|
|
|
28
28
|
/**
|
|
29
29
|
* @param {any} [serverRuntimeConfig]
|
|
30
30
|
* @param {any} [data]
|
|
31
|
+
* @param {import('../../../../shared/index.js').StorageOptions} [options]
|
|
31
32
|
*/
|
|
32
|
-
export const handleProxy = (serverRuntimeConfig, data) => {
|
|
33
|
+
export const handleProxy = (serverRuntimeConfig, data, options) => {
|
|
33
34
|
const { generateReplacements, returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
34
35
|
const { API_BASE_PATH, API_URLS, API_PATHS, APP_CONFIG, APP_BASE_URL, TARGET_SAFELIST, ORIGIN_SAFELIST, } = serverRuntimeConfig;
|
|
35
|
-
const _prepareHeaders = prepareHeaders(serverRuntimeConfig);
|
|
36
|
+
const _prepareHeaders = prepareHeaders(serverRuntimeConfig, options);
|
|
36
37
|
const _getVerificationHelpers = getVerificationHelpers(serverRuntimeConfig);
|
|
37
38
|
const _getVerifiedSessionData = getVerifiedSessionData(serverRuntimeConfig);
|
|
38
39
|
/**
|
|
@@ -16,8 +16,9 @@ import { matchHostname, ensureArray, splitCommas, safeParse, stringEmpty, conver
|
|
|
16
16
|
/**
|
|
17
17
|
* @param {any} [serverRuntimeConfig]
|
|
18
18
|
* @param {any} [data]
|
|
19
|
+
* @param {import('../../../shared/index.js').StorageOptions} [options]
|
|
19
20
|
*/
|
|
20
|
-
export const handleWebhookEvent = (serverRuntimeConfig, data) => {
|
|
21
|
+
export const handleWebhookEvent = (serverRuntimeConfig, data, options) => {
|
|
21
22
|
const { ORIGIN_SAFELIST, WEBHOOK_TOPIC_BLOCKLIST } = serverRuntimeConfig;
|
|
22
23
|
const _a = data !== null && data !== void 0 ? data : {}, { returnResponse = true } = _a, config = __rest(_a, ["returnResponse"]);
|
|
23
24
|
/**
|
|
@@ -45,7 +46,7 @@ export const handleWebhookEvent = (serverRuntimeConfig, data) => {
|
|
|
45
46
|
if (!matchHostname(shop, ORIGIN_SAFELIST)) {
|
|
46
47
|
return handleResponse({ handler: 'webhook', error: 'Shop is not safelisted' });
|
|
47
48
|
}
|
|
48
|
-
const { shopify } = await getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
49
|
+
const { shopify } = await getShopifyHelpers(serverRuntimeConfig, { shop }, options);
|
|
49
50
|
if (!shopify) {
|
|
50
51
|
throw new Error('Shopify API is not initialized');
|
|
51
52
|
}
|
|
@@ -26,8 +26,9 @@ const processRedirect = (url, params, permanent = false) => ({
|
|
|
26
26
|
/**
|
|
27
27
|
* @param {any} [serverRuntimeConfig]
|
|
28
28
|
* @param {any} [_props]
|
|
29
|
+
* @param {import('../../../shared/index.js').StorageOptions} [options]
|
|
29
30
|
*/
|
|
30
|
-
export const protectRoute = (serverRuntimeConfig, _props) => {
|
|
31
|
+
export const protectRoute = (serverRuntimeConfig, _props, options) => {
|
|
31
32
|
const { PAGE_PATHS, API_PATHS, APP_CONFIG, PAYMENT_CONFIG } = serverRuntimeConfig;
|
|
32
33
|
const { isSessionTokenEnabled } = APP_CONFIG;
|
|
33
34
|
const exitPath = PAGE_PATHS[PAGE_ROUTE_NAMES.EXIT];
|
|
@@ -47,7 +48,7 @@ export const protectRoute = (serverRuntimeConfig, _props) => {
|
|
|
47
48
|
console.info(`${chalk.yellowBright('next-shopify')} - [${chalk.bold('protectRoute')}]: ${`Bypassing local protect - should ONLY happen when running in next to test non-shopify functionality!`}`);
|
|
48
49
|
return { props };
|
|
49
50
|
}
|
|
50
|
-
const helpers = await getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
51
|
+
const helpers = await getShopifyHelpers(serverRuntimeConfig, { shop }, options);
|
|
51
52
|
// NOTE: unreachable — allowLocalBypass returned above, and getInitializedShopify makes the same call
|
|
52
53
|
if (!helpers.shopify) {
|
|
53
54
|
throw new Error('Shopify API is not initialized');
|
package/dist/esm/lib/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { Base64 } from 'js-base64';
|
|
13
13
|
import { HttpResponseError, RequestedTokenType } from '@shopify/shopify-api';
|
|
14
14
|
import { isTrue, isString, isNumericOnly, ensureString, ensureArray, cleanObject, objectEmpty, stringEmpty, ensureObject, isTokenExpired, stringNotEmpty, objectNotEmpty, stringEmptyOnly, removeLeadingSlash, ShopifyAuthenticationError, ShopifySessionAuthenticationError, ShopifySessionMissingError, ShopifySessionInvalidError, SESSION_TOKEN_PARAM, APP_QUERY, TRANSFORM, } from '../../shared/index.js';
|
|
15
|
-
import { ensureStorage } from '../../
|
|
15
|
+
import { ensureStorage } from '../../shared/index.js';
|
|
16
16
|
import { ensureBilling } from './billing.js';
|
|
17
17
|
import { replaceHeaders } from './headers.js';
|
|
18
18
|
import { getInitializedShopify } from './shopify.js';
|
|
@@ -74,39 +74,26 @@ const prepareSessionPayload = (session) => {
|
|
|
74
74
|
const _b = _onlineAccessInfo !== null && _onlineAccessInfo !== void 0 ? _onlineAccessInfo : {}, { associated_user } = _b, onlineAccessInfo = __rest(_b, ["associated_user"]);
|
|
75
75
|
return Object.assign({ onlineAccessInfo }, sessionData);
|
|
76
76
|
};
|
|
77
|
-
// NOTE: imported lazily so an app that supplies its own storage never loads firebase-admin,
|
|
78
|
-
// even though it is still the default. PR 4 removes this branch and the peer with it.
|
|
79
|
-
/**
|
|
80
|
-
* @param {any} firebaseConfig
|
|
81
|
-
* @param {any} options
|
|
82
|
-
*/
|
|
83
|
-
const createDefaultStorage = async (firebaseConfig, options) => {
|
|
84
|
-
const { createFirestoreStorage } = await import('../../storage/firestore/index.js');
|
|
85
|
-
return createFirestoreStorage(firebaseConfig, options);
|
|
86
|
-
};
|
|
87
77
|
// TODO: move to curry??
|
|
88
78
|
/**
|
|
89
79
|
* @param {any} [serverRuntimeConfig]
|
|
90
80
|
* @param {any} [config]
|
|
91
|
-
* @param {
|
|
92
|
-
* `storage`
|
|
93
|
-
*
|
|
81
|
+
* @param {import('../../shared/index.js').StorageOptions} options
|
|
82
|
+
* ⚠️ `storage` is REQUIRED. There is no bundled implementation to fall back to, so omitting it
|
|
83
|
+
* throws here rather than quietly writing sessions somewhere this app does not own.
|
|
94
84
|
* @returns {Promise<import('./types.js').ShopifyHelpers>}
|
|
95
85
|
*/
|
|
96
86
|
export const getShopifyHelpers = async (serverRuntimeConfig, config, { storage: _storage } = {}) => {
|
|
97
87
|
var _a, _b;
|
|
98
88
|
const shopify = getInitializedShopify(serverRuntimeConfig);
|
|
99
|
-
const {
|
|
89
|
+
const { SHOPIFY_RUN_MODE, SESSION_CONFIG, PAYMENT_CONFIG, } = serverRuntimeConfig;
|
|
100
90
|
const { shop } = config !== null && config !== void 0 ? config : {};
|
|
101
91
|
const isReviewMode = isTrue((SHOPIFY_RUN_MODE === 'review') &&
|
|
102
92
|
(PAYMENT_CONFIG === null || PAYMENT_CONFIG === void 0 ? void 0 : PAYMENT_CONFIG.required));
|
|
103
93
|
// TODO: should this use our helper instead (and/or as a fallback)??
|
|
104
94
|
const shopId = (_b = (_a = shopify === null || shopify === void 0 ? void 0 : shopify.utils) === null || _a === void 0 ? void 0 : _a.sanitizeShop) === null || _b === void 0 ? void 0 : _b.call(_a, shop);
|
|
105
95
|
const cryptoHandler = CryptoHandler.getInstance(SESSION_CONFIG);
|
|
106
|
-
const storage = ensureStorage(_storage
|
|
107
|
-
collection: FB_ROOT_COLLECTION,
|
|
108
|
-
configurationId: APP_ID,
|
|
109
|
-
}));
|
|
96
|
+
const storage = ensureStorage(_storage);
|
|
110
97
|
// NOTE: this should handle running in next to test non-shopify functionality
|
|
111
98
|
if (!shopify) {
|
|
112
99
|
return {
|
|
@@ -232,6 +219,9 @@ export const getShopifyHelpers = async (serverRuntimeConfig, config, { storage:
|
|
|
232
219
|
rawRequest: req,
|
|
233
220
|
rawResponse: res,
|
|
234
221
|
});
|
|
222
|
+
// NOTE: the core is the only thing allowed to interpret a stored session. The contract types
|
|
223
|
+
// these payloads as `unknown` so an implementation cannot read them, which makes this the one
|
|
224
|
+
// deliberate exception rather than a hole left open for everyone.
|
|
235
225
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
236
226
|
const _c = (_b = (await storage.loadSession(shopId, sessionId))) !== null && _b !== void 0 ? _b : {}, { accessToken: encryptedOnlineAccessToken } = _c, storedOnlineSession = __rest(_c, ["accessToken"]);
|
|
237
227
|
let session = storedOnlineSession;
|
|
@@ -259,6 +249,9 @@ export const getShopifyHelpers = async (serverRuntimeConfig, config, { storage:
|
|
|
259
249
|
const verifyOfflineSession = async () => {
|
|
260
250
|
var _a;
|
|
261
251
|
const sessionId = shopify.session.getOfflineId(shop);
|
|
252
|
+
// NOTE: the core is the only thing allowed to interpret a stored session. The contract types
|
|
253
|
+
// these payloads as `unknown` so an implementation cannot read them, which makes this the one
|
|
254
|
+
// deliberate exception rather than a hole left open for everyone.
|
|
262
255
|
const _b = (_a = (await storage.loadSession(shopId, sessionId))) !== null && _a !== void 0 ? _a : {}, { accessToken: encryptedOfflineAccessToken } = _b, offlineSession = __rest(_b, ["accessToken"]);
|
|
263
256
|
return {
|
|
264
257
|
sessionId,
|
|
@@ -443,14 +436,17 @@ const extendAppHeaders = (headers, appData) => {
|
|
|
443
436
|
[`x-shopify-app-metafield-${metafieldKey}`]: value,
|
|
444
437
|
})), headers);
|
|
445
438
|
};
|
|
446
|
-
/**
|
|
447
|
-
|
|
439
|
+
/**
|
|
440
|
+
* @param {any} [serverRuntimeConfig]
|
|
441
|
+
* @param {import('../../shared/index.js').StorageOptions} [options]
|
|
442
|
+
*/
|
|
443
|
+
export const prepareHeaders = (serverRuntimeConfig, options) => async ({ generateReplacements, appData, shop, appId, headers: _headers, } = /** @type {any} */ ({})) => {
|
|
448
444
|
const headers = cleanObject(_headers, false, stringEmptyOnly);
|
|
449
445
|
if (objectEmpty(headers) || !generateReplacements) {
|
|
450
446
|
return headers;
|
|
451
447
|
}
|
|
452
448
|
if (!appData) {
|
|
453
|
-
const { loadAppData } = await getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
449
|
+
const { loadAppData } = await getShopifyHelpers(serverRuntimeConfig, { shop }, options);
|
|
454
450
|
appData = await loadAppData({ appId }); // NOTE: this handles even if no appId
|
|
455
451
|
}
|
|
456
452
|
if (!appData) {
|
package/dist/esm/shared/index.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ensureArray } from './display.js';
|
|
2
|
+
export const STORAGE_METHODS = [
|
|
3
|
+
'loadState',
|
|
4
|
+
'storeState',
|
|
5
|
+
'deleteState',
|
|
6
|
+
'loadSession',
|
|
7
|
+
'updateSession',
|
|
8
|
+
'deleteSessions',
|
|
9
|
+
'findSessionIds'
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* Fails at composition rather than at the first OAuth round-trip. Nothing automated covers the
|
|
13
|
+
* Shopify auth flow, so a missing method would otherwise surface as a runtime TypeError in a
|
|
14
|
+
* callback that needs a real dev store to reach.
|
|
15
|
+
*
|
|
16
|
+
* ⚠️ Takes `unknown` on purpose. Whether this is a SessionStorage is what the function decides,
|
|
17
|
+
* so the argument cannot be typed as one, and `any` would let the body use it before checking.
|
|
18
|
+
*
|
|
19
|
+
* @param {unknown} storage
|
|
20
|
+
* @returns {import('./types.js').SessionStorage}
|
|
21
|
+
*/
|
|
22
|
+
export const ensureStorage = (storage) => {
|
|
23
|
+
const candidate = /** @type {Record<string, unknown> | null | undefined} */ (storage);
|
|
24
|
+
// ⚠️ the upgrade path, called out separately: this package used to bundle a firestore store and
|
|
25
|
+
// fall back to it. Listing all seven methods as missing would be true and would not explain why.
|
|
26
|
+
if (!candidate) {
|
|
27
|
+
throw new Error('No session storage supplied. Pass one as `storage` - this package no longer bundles a default.');
|
|
28
|
+
}
|
|
29
|
+
const missing = ensureArray(STORAGE_METHODS).filter((method) => (typeof (candidate === null || candidate === void 0 ? void 0 : candidate[method]) !== 'function'));
|
|
30
|
+
if (missing.length) {
|
|
31
|
+
throw new Error(`Invalid session storage, missing: ${missing.join(', ')}`);
|
|
32
|
+
}
|
|
33
|
+
// the one place the assertion is earned: every method is present, so it is a SessionStorage
|
|
34
|
+
return /** @type {import('./types.js').SessionStorage} */ (storage);
|
|
35
|
+
};
|
package/dist/esm/shared/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function handleAppBilling(serverRuntimeConfig?: any, data?: any): (req: any, res: any) => Promise<any>;
|
|
1
|
+
export function handleAppBilling(serverRuntimeConfig?: any, data?: any, options?: import("../../../shared/index.js").StorageOptions): (req: any, res: any) => Promise<any>;
|
|
@@ -24,8 +24,9 @@ const TERMINAL_STATUSES = [
|
|
|
24
24
|
/**
|
|
25
25
|
* @param {any} [serverRuntimeConfig]
|
|
26
26
|
* @param {any} [data]
|
|
27
|
+
* @param {import('../../../shared/index.js').StorageOptions} [options]
|
|
27
28
|
*/
|
|
28
|
-
const handleAppBilling = (serverRuntimeConfig, data) => {
|
|
29
|
+
const handleAppBilling = (serverRuntimeConfig, data, options) => {
|
|
29
30
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
30
31
|
/**
|
|
31
32
|
* @param {any} req
|
|
@@ -48,7 +49,7 @@ const handleAppBilling = (serverRuntimeConfig, data) => {
|
|
|
48
49
|
if ((0, index_js_2.stringEmpty)(shop)) {
|
|
49
50
|
return handleResponse({ handler: 'billing', error: 'Missing shop' });
|
|
50
51
|
}
|
|
51
|
-
const helpers = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
|
|
52
|
+
const helpers = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop }, options);
|
|
52
53
|
if (!helpers.shopify) {
|
|
53
54
|
throw new Error('Shopify API is not initialized');
|
|
54
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function handleCallback(serverRuntimeConfig?: any, data?: any): (req: any, res: any, params: any) => Promise<any>;
|
|
1
|
+
export function handleCallback(serverRuntimeConfig?: any, data?: any, options?: import("../../../shared/index.js").StorageOptions): (req: any, res: any, params: any) => Promise<any>;
|
|
@@ -14,8 +14,9 @@ const index_js_2 = require("../../../shared/index.js");
|
|
|
14
14
|
/**
|
|
15
15
|
* @param {any} [serverRuntimeConfig]
|
|
16
16
|
* @param {any} [data]
|
|
17
|
+
* @param {import('../../../shared/index.js').StorageOptions} [options]
|
|
17
18
|
*/
|
|
18
|
-
const handleCallback = (serverRuntimeConfig, data) => {
|
|
19
|
+
const handleCallback = (serverRuntimeConfig, data, options) => {
|
|
19
20
|
const { API_PATHS, PAGE_PATHS, PAYMENT_CONFIG, } = serverRuntimeConfig;
|
|
20
21
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
21
22
|
const prepareWebhookHandlers = (0, index_js_1.getPrepareWebhookHandlers)(serverRuntimeConfig);
|
|
@@ -47,7 +48,7 @@ const handleCallback = (serverRuntimeConfig, data) => {
|
|
|
47
48
|
let redirectUrl = `${errorPath}?code=invalid_callback_response`;
|
|
48
49
|
let shopify;
|
|
49
50
|
try {
|
|
50
|
-
const helpers = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
|
|
51
|
+
const helpers = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop }, options);
|
|
51
52
|
if (!helpers.shopify) {
|
|
52
53
|
throw new Error('Shopify API is not initialized');
|
|
53
54
|
}
|
|
@@ -91,7 +92,7 @@ const handleCallback = (serverRuntimeConfig, data) => {
|
|
|
91
92
|
// NOTE: handleEnsureBilling handles calling encryptStoreSession for offline session when shouldCheckBilling
|
|
92
93
|
const confirmationUrl = await handleEnsureBilling(session, { reAuth });
|
|
93
94
|
if ((0, index_js_2.stringNotEmpty)(confirmationUrl)) {
|
|
94
|
-
redirectUrl = confirmationUrl
|
|
95
|
+
redirectUrl = `${confirmationUrl}`;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
// NOTE confirm that state can be appended to the confirmationUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function handleAppUninstalled(serverRuntimeConfig?: any, data?: any): (req: any, res: any) => Promise<any>;
|
|
1
|
+
export function handleAppUninstalled(serverRuntimeConfig?: any, data?: any, options?: import("../../../shared/index.js").StorageOptions): (req: any, res: any) => Promise<any>;
|
|
@@ -19,8 +19,9 @@ const index_js_2 = require("../../../shared/index.js");
|
|
|
19
19
|
/**
|
|
20
20
|
* @param {any} [serverRuntimeConfig]
|
|
21
21
|
* @param {any} [data]
|
|
22
|
+
* @param {import('../../../shared/index.js').StorageOptions} [options]
|
|
22
23
|
*/
|
|
23
|
-
const handleAppUninstalled = (serverRuntimeConfig, data) => {
|
|
24
|
+
const handleAppUninstalled = (serverRuntimeConfig, data, options) => {
|
|
24
25
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
25
26
|
/**
|
|
26
27
|
* @param {any} req
|
|
@@ -43,7 +44,7 @@ const handleAppUninstalled = (serverRuntimeConfig, data) => {
|
|
|
43
44
|
if ((0, index_js_2.stringEmpty)(shop)) {
|
|
44
45
|
return handleResponse({ handler: 'uninstall', error: 'Missing shop' });
|
|
45
46
|
}
|
|
46
|
-
const { shopify, findSessionIds, deleteSessions } = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
|
|
47
|
+
const { shopify, findSessionIds, deleteSessions } = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop }, options);
|
|
47
48
|
if (!shopify) {
|
|
48
49
|
throw new Error('Shopify API is not initialized');
|
|
49
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function handleLoadAppInstallation(serverRuntimeConfig?: any, data?: any): (req: any, res: any, params: any) => Promise<any>;
|
|
1
|
+
export function handleLoadAppInstallation(serverRuntimeConfig?: any, data?: any, options?: import("../../../../shared/index.js").StorageOptions): (req: any, res: any, params: any) => Promise<any>;
|
|
@@ -7,9 +7,10 @@ const graph_js_1 = require("./graph.js");
|
|
|
7
7
|
/**
|
|
8
8
|
* @param {any} [serverRuntimeConfig]
|
|
9
9
|
* @param {any} [data]
|
|
10
|
+
* @param {import('../../../../shared/index.js').StorageOptions} [options]
|
|
10
11
|
*/
|
|
11
|
-
const handleLoadAppInstallation = (serverRuntimeConfig, data) => {
|
|
12
|
-
const _handleGraph = (0, graph_js_1.handleGraph)(serverRuntimeConfig, data);
|
|
12
|
+
const handleLoadAppInstallation = (serverRuntimeConfig, data, options) => {
|
|
13
|
+
const _handleGraph = (0, graph_js_1.handleGraph)(serverRuntimeConfig, data, options);
|
|
13
14
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
14
15
|
/**
|
|
15
16
|
* @param {any} req
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function handleGraph(serverRuntimeConfig?: any, data?: any): (req: any, res: any, params: any) => Promise<any>;
|
|
1
|
+
export function handleGraph(serverRuntimeConfig?: any, data?: any, options?: import("../../../../shared/index.js").StorageOptions): (req: any, res: any, params: any) => Promise<any>;
|
|
@@ -19,8 +19,9 @@ const index_js_2 = require("../../../../shared/index.js");
|
|
|
19
19
|
/**
|
|
20
20
|
* @param {any} [serverRuntimeConfig]
|
|
21
21
|
* @param {any} [data]
|
|
22
|
+
* @param {import('../../../../shared/index.js').StorageOptions} [options]
|
|
22
23
|
*/
|
|
23
|
-
const handleGraph = (serverRuntimeConfig, data) => {
|
|
24
|
+
const handleGraph = (serverRuntimeConfig, data, options) => {
|
|
24
25
|
const _getVerificationHelpers = (0, verifyd_1.getVerificationHelpers)(serverRuntimeConfig);
|
|
25
26
|
const { returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
26
27
|
/**
|
|
@@ -65,7 +66,7 @@ const handleGraph = (serverRuntimeConfig, data) => {
|
|
|
65
66
|
let headers;
|
|
66
67
|
let message = 'Error handling query call';
|
|
67
68
|
try {
|
|
68
|
-
const helpers = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
|
|
69
|
+
const helpers = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop }, options);
|
|
69
70
|
if (!helpers.shopify) {
|
|
70
71
|
throw new Error('Shopify API is not initialized');
|
|
71
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function handleProxy(serverRuntimeConfig?: any, data?: any): (req: any, res: any, params: any) => Promise<any>;
|
|
1
|
+
export function handleProxy(serverRuntimeConfig?: any, data?: any, options?: import("../../../../shared/index.js").StorageOptions): (req: any, res: any, params: any) => Promise<any>;
|
|
@@ -34,11 +34,12 @@ const verifyAppProxySignature = (signature, verifiable, hmacSecret) => {
|
|
|
34
34
|
/**
|
|
35
35
|
* @param {any} [serverRuntimeConfig]
|
|
36
36
|
* @param {any} [data]
|
|
37
|
+
* @param {import('../../../../shared/index.js').StorageOptions} [options]
|
|
37
38
|
*/
|
|
38
|
-
const handleProxy = (serverRuntimeConfig, data) => {
|
|
39
|
+
const handleProxy = (serverRuntimeConfig, data, options) => {
|
|
39
40
|
const { generateReplacements, returnResponse = true } = data !== null && data !== void 0 ? data : {};
|
|
40
41
|
const { API_BASE_PATH, API_URLS, API_PATHS, APP_CONFIG, APP_BASE_URL, TARGET_SAFELIST, ORIGIN_SAFELIST, } = serverRuntimeConfig;
|
|
41
|
-
const _prepareHeaders = (0, index_js_1.prepareHeaders)(serverRuntimeConfig);
|
|
42
|
+
const _prepareHeaders = (0, index_js_1.prepareHeaders)(serverRuntimeConfig, options);
|
|
42
43
|
const _getVerificationHelpers = (0, verifyd_1.getVerificationHelpers)(serverRuntimeConfig);
|
|
43
44
|
const _getVerifiedSessionData = (0, index_js_1.getVerifiedSessionData)(serverRuntimeConfig);
|
|
44
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function handleWebhookEvent(serverRuntimeConfig?: any, data?: any): (req: any, res: any, data: any) => Promise<any>;
|
|
1
|
+
export function handleWebhookEvent(serverRuntimeConfig?: any, data?: any, options?: import("../../../shared/index.js").StorageOptions): (req: any, res: any, data: any) => Promise<any>;
|
|
@@ -19,8 +19,9 @@ const index_js_2 = require("../../../shared/index.js");
|
|
|
19
19
|
/**
|
|
20
20
|
* @param {any} [serverRuntimeConfig]
|
|
21
21
|
* @param {any} [data]
|
|
22
|
+
* @param {import('../../../shared/index.js').StorageOptions} [options]
|
|
22
23
|
*/
|
|
23
|
-
const handleWebhookEvent = (serverRuntimeConfig, data) => {
|
|
24
|
+
const handleWebhookEvent = (serverRuntimeConfig, data, options) => {
|
|
24
25
|
const { ORIGIN_SAFELIST, WEBHOOK_TOPIC_BLOCKLIST } = serverRuntimeConfig;
|
|
25
26
|
const _a = data !== null && data !== void 0 ? data : {}, { returnResponse = true } = _a, config = __rest(_a, ["returnResponse"]);
|
|
26
27
|
/**
|
|
@@ -48,7 +49,7 @@ const handleWebhookEvent = (serverRuntimeConfig, data) => {
|
|
|
48
49
|
if (!(0, index_js_2.matchHostname)(shop, ORIGIN_SAFELIST)) {
|
|
49
50
|
return handleResponse({ handler: 'webhook', error: 'Shop is not safelisted' });
|
|
50
51
|
}
|
|
51
|
-
const { shopify } = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
|
|
52
|
+
const { shopify } = await (0, index_js_1.getShopifyHelpers)(serverRuntimeConfig, { shop }, options);
|
|
52
53
|
if (!shopify) {
|
|
53
54
|
throw new Error('Shopify API is not initialized');
|
|
54
55
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function protectRoute(serverRuntimeConfig?: any, _props?: any): ({ req, res, query, locale, resolvedUrl, }: any | undefined, data: any) => Promise<{
|
|
1
|
+
export function protectRoute(serverRuntimeConfig?: any, _props?: any, options?: import("../../../shared/index.js").StorageOptions): ({ req, res, query, locale, resolvedUrl, }: any | undefined, data: any) => Promise<{
|
|
2
2
|
redirect: {
|
|
3
3
|
destination: string;
|
|
4
4
|
permanent: any;
|