@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.
Files changed (48) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/dist/esm/lib/handlers/api/billing.js +3 -2
  3. package/dist/esm/lib/handlers/api/callback.js +4 -3
  4. package/dist/esm/lib/handlers/api/uninstall.js +3 -2
  5. package/dist/esm/lib/handlers/api/verifiable/appInstallation.js +3 -2
  6. package/dist/esm/lib/handlers/api/verifiable/graph.js +3 -2
  7. package/dist/esm/lib/handlers/api/verifiable/proxy.js +3 -2
  8. package/dist/esm/lib/handlers/api/webhook.js +3 -2
  9. package/dist/esm/lib/handlers/ssr/protect.js +3 -2
  10. package/dist/esm/lib/index.js +0 -1
  11. package/dist/esm/lib/utils/session.js +18 -22
  12. package/dist/esm/shared/index.js +2 -0
  13. package/dist/esm/shared/storage.js +35 -0
  14. package/dist/esm/shared/types.js +3 -0
  15. package/dist/lib/handlers/api/billing.d.ts +1 -1
  16. package/dist/lib/handlers/api/billing.js +3 -2
  17. package/dist/lib/handlers/api/callback.d.ts +1 -1
  18. package/dist/lib/handlers/api/callback.js +4 -3
  19. package/dist/lib/handlers/api/uninstall.d.ts +1 -1
  20. package/dist/lib/handlers/api/uninstall.js +3 -2
  21. package/dist/lib/handlers/api/verifiable/appInstallation.d.ts +1 -1
  22. package/dist/lib/handlers/api/verifiable/appInstallation.js +3 -2
  23. package/dist/lib/handlers/api/verifiable/graph.d.ts +1 -1
  24. package/dist/lib/handlers/api/verifiable/graph.js +3 -2
  25. package/dist/lib/handlers/api/verifiable/proxy.d.ts +1 -1
  26. package/dist/lib/handlers/api/verifiable/proxy.js +3 -2
  27. package/dist/lib/handlers/api/webhook.d.ts +1 -1
  28. package/dist/lib/handlers/api/webhook.js +3 -2
  29. package/dist/lib/handlers/ssr/protect.d.ts +1 -1
  30. package/dist/lib/handlers/ssr/protect.js +3 -2
  31. package/dist/lib/index.d.ts +0 -1
  32. package/dist/lib/index.js +0 -1
  33. package/dist/lib/utils/session.d.ts +2 -4
  34. package/dist/lib/utils/session.js +18 -22
  35. package/dist/lib/utils/types.d.ts +20 -16
  36. package/dist/shared/index.d.ts +2 -0
  37. package/dist/shared/index.js +2 -0
  38. package/dist/shared/storage.d.ts +2 -0
  39. package/dist/shared/storage.js +39 -0
  40. package/dist/shared/types.d.ts +72 -1
  41. package/dist/shared/types.js +2 -0
  42. package/package.json +4 -31
  43. package/dist/esm/storage/firestore/index.js +0 -77
  44. package/dist/esm/storage/index.js +0 -54
  45. package/dist/storage/firestore/index.d.ts +0 -4
  46. package/dist/storage/firestore/index.js +0 -81
  47. package/dist/storage/index.d.ts +0 -61
  48. package/dist/storage/index.js +0 -58
@@ -1,61 +0,0 @@
1
- /**
2
- * Shop and session ids are nullable: `sanitizeShop` returns null for anything it does not
3
- * recognise, and the core forwards that rather than guarding.
4
- *
5
- * @typedef {string | null | undefined} ShopId
6
- */
7
- /**
8
- * What the session layer needs from a store. Two entities, sessions and state, both scoped to a
9
- * shop. Nothing here is Firestore-specific: `@agnostack/next-shopify/firestore` is one
10
- * implementation, and an app can supply its own.
11
- *
12
- * ⚠️ Values arrive ALREADY ENCRYPTED and already stripped of anything that must not be persisted.
13
- * An implementation stores and returns what it is handed - it must not inspect, reshape or
14
- * re-encrypt, or the core's crypto and DPA guarantees stop holding.
15
- *
16
- * ⚠️ `findSessionIds` returns `[]` rather than erroring for an unknown shop - that is what an
17
- * initial install looks like.
18
- *
19
- * @typedef {object} SessionStorage
20
- * @property {(shopId: ShopId, sessionId: ShopId) => Promise<any>} loadSession
21
- * @property {(shopId: ShopId, session: any) => Promise<any>} updateSession
22
- * MERGES into the stored session. The core writes partial sessions, so a replacing write
23
- * would silently drop fields it did not send.
24
- * @property {(shopId: ShopId, sessionIds: any) => Promise<any>} deleteSessions
25
- * @property {(shopId: ShopId) => Promise<string[]>} findSessionIds
26
- * @property {(shop: ShopId) => Promise<any>} loadState
27
- * @property {(shop: ShopId, state: any) => Promise<any>} storeState
28
- * @property {(shop: ShopId) => Promise<any>} deleteState
29
- */
30
- export const STORAGE_METHODS: string[];
31
- export function ensureStorage(storage: any): SessionStorage;
32
- /**
33
- * Shop and session ids are nullable: `sanitizeShop` returns null for anything it does not
34
- * recognise, and the core forwards that rather than guarding.
35
- */
36
- export type ShopId = string | null | undefined;
37
- /**
38
- * What the session layer needs from a store. Two entities, sessions and state, both scoped to a
39
- * shop. Nothing here is Firestore-specific: `@agnostack/next-shopify/firestore` is one
40
- * implementation, and an app can supply its own.
41
- *
42
- * ⚠️ Values arrive ALREADY ENCRYPTED and already stripped of anything that must not be persisted.
43
- * An implementation stores and returns what it is handed - it must not inspect, reshape or
44
- * re-encrypt, or the core's crypto and DPA guarantees stop holding.
45
- *
46
- * ⚠️ `findSessionIds` returns `[]` rather than erroring for an unknown shop - that is what an
47
- * initial install looks like.
48
- */
49
- export type SessionStorage = {
50
- loadSession: (shopId: ShopId, sessionId: ShopId) => Promise<any>;
51
- /**
52
- * MERGES into the stored session. The core writes partial sessions, so a replacing write
53
- * would silently drop fields it did not send.
54
- */
55
- updateSession: (shopId: ShopId, session: any) => Promise<any>;
56
- deleteSessions: (shopId: ShopId, sessionIds: any) => Promise<any>;
57
- findSessionIds: (shopId: ShopId) => Promise<string[]>;
58
- loadState: (shop: ShopId) => Promise<any>;
59
- storeState: (shop: ShopId, state: any) => Promise<any>;
60
- deleteState: (shop: ShopId) => Promise<any>;
61
- };
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureStorage = exports.STORAGE_METHODS = void 0;
4
- const index_js_1 = require("../shared/index.js");
5
- /**
6
- * Shop and session ids are nullable: `sanitizeShop` returns null for anything it does not
7
- * recognise, and the core forwards that rather than guarding.
8
- *
9
- * @typedef {string | null | undefined} ShopId
10
- */
11
- /**
12
- * What the session layer needs from a store. Two entities, sessions and state, both scoped to a
13
- * shop. Nothing here is Firestore-specific: `@agnostack/next-shopify/firestore` is one
14
- * implementation, and an app can supply its own.
15
- *
16
- * ⚠️ Values arrive ALREADY ENCRYPTED and already stripped of anything that must not be persisted.
17
- * An implementation stores and returns what it is handed - it must not inspect, reshape or
18
- * re-encrypt, or the core's crypto and DPA guarantees stop holding.
19
- *
20
- * ⚠️ `findSessionIds` returns `[]` rather than erroring for an unknown shop - that is what an
21
- * initial install looks like.
22
- *
23
- * @typedef {object} SessionStorage
24
- * @property {(shopId: ShopId, sessionId: ShopId) => Promise<any>} loadSession
25
- * @property {(shopId: ShopId, session: any) => Promise<any>} updateSession
26
- * MERGES into the stored session. The core writes partial sessions, so a replacing write
27
- * would silently drop fields it did not send.
28
- * @property {(shopId: ShopId, sessionIds: any) => Promise<any>} deleteSessions
29
- * @property {(shopId: ShopId) => Promise<string[]>} findSessionIds
30
- * @property {(shop: ShopId) => Promise<any>} loadState
31
- * @property {(shop: ShopId, state: any) => Promise<any>} storeState
32
- * @property {(shop: ShopId) => Promise<any>} deleteState
33
- */
34
- exports.STORAGE_METHODS = [
35
- 'loadState',
36
- 'storeState',
37
- 'deleteState',
38
- 'loadSession',
39
- 'updateSession',
40
- 'deleteSessions',
41
- 'findSessionIds'
42
- ];
43
- /**
44
- * Fails at composition rather than at the first OAuth round-trip. Nothing automated covers the
45
- * Shopify auth flow, so a missing method would otherwise surface as a runtime TypeError in a
46
- * callback that needs a real dev store to reach.
47
- *
48
- * @param {any} storage
49
- * @returns {SessionStorage}
50
- */
51
- const ensureStorage = (storage) => {
52
- const missing = (0, index_js_1.ensureArray)(exports.STORAGE_METHODS).filter((method) => (typeof (storage === null || storage === void 0 ? void 0 : storage[method]) !== 'function'));
53
- if (missing.length) {
54
- throw new Error(`Invalid session storage, missing: ${missing.join(', ')}`);
55
- }
56
- return storage;
57
- };
58
- exports.ensureStorage = ensureStorage;