@fanfare-io/fanfare-sdk-shopify 0.2.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @fanfare-io/fanfare-sdk-shopify
2
+
3
+ The Shopify storefront surface for the Fanfare SDK: the product→experience
4
+ resolver, the checkout verifier, and the `experienceIds` metafield primitives.
5
+ It builds on the framework-free storefront-adapter contract published from
6
+ `@fanfare-io/fanfare-sdk-core/storefront`.
7
+
8
+ ## Entry points
9
+
10
+ | Import | Runtime | Contents |
11
+ | --------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12
+ | `@fanfare-io/fanfare-sdk-shopify` | isomorphic | `createShopifyExperienceResolver`, `shopifyCheckoutVerifier`, `FANFARE_PRODUCT_METAFIELD`, `parseExperienceIds`, `parseFirstExperienceId`, and a re-export of core's `./storefront` vocabulary |
13
+ | `@fanfare-io/fanfare-sdk-shopify/react` | client | `FanfareAdapterProvider`, `useFanfareAdapter`, `FanfareAdapterValue` (`"use client"`) |
14
+
15
+ The root entry imports zero React, so a server-only consumer (Hydrogen/Oxygen
16
+ loader, Next/Remix server component) installs and uses it without React. React
17
+ is an optional peer dependency, needed only for the `/react` subpath.
18
+
19
+ ## Placeholder seams (final-shaped signatures)
20
+
21
+ Two seam bodies are honest local placeholders today; their **signatures are
22
+ final** and the wiring lands behind them with no surface change:
23
+
24
+ - **`createShopifyExperienceResolver(config)`** — `resolve(product)` resolves
25
+ from a config-supplied static `metafieldValues` map (handle → raw metafield
26
+ value) so the parser path is exercised end-to-end without a network. The live
27
+ Storefront-API read of the reified `app--<fanfareAppId>--product` /
28
+ `experienceIds` metafield is the only change that lands later.
29
+ - **`shopifyCheckoutVerifier`** — `verify(grant)` enforces only client-side grant
30
+ expiry today. The ENG-913 server-validatable handoff (mint at claim, redeem +
31
+ validate at checkout entry) slots in behind the same `verify(grant)`
32
+ signature. `verify` is **total**: it resolves for every grant and never
33
+ rejects, so a future throwing redeem path must be wrapped into a denied result.
34
+
35
+ No exported identifier says mock/demo.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @fanfare-io/fanfare-sdk-shopify — the real Shopify storefront surface.
3
+ *
4
+ * ISOMORPHIC (SSR-safe) root barrel: the product→experience resolver, the
5
+ * checkout verifier, and the `experienceIds` metafield primitives. Imports zero
6
+ * React, so a server-only consumer (Hydrogen/Oxygen loader, Next/Remix server
7
+ * component) installs and uses this package without React. The React provider /
8
+ * hooks live in `@fanfare-io/fanfare-sdk-shopify/react`.
9
+ *
10
+ * The resolver/verifier bodies are honest local placeholders pending the live
11
+ * Storefront-API metafield read and the ENG-913 handoff (see the JSDoc on
12
+ * createShopifyExperienceResolver / shopifyCheckoutVerifier) — their signatures
13
+ * are final and the wiring lands behind them with no surface change.
14
+ */
15
+ export { FANFARE_PRODUCT_METAFIELD, parseExperienceIds, parseFirstExperienceId } from './metafield';
16
+ export { createShopifyExperienceResolver } from './resolver';
17
+ export type { ShopifyExperienceResolverConfig } from './resolver';
18
+ export { shopifyCheckoutVerifier } from './verifier';
19
+ export { ACCESS_STATUSES, snapshotToAccessStatus } from '@fanfare-io/fanfare-sdk-core/storefront';
20
+ export type { AccessStatus, CheckoutAccess, CheckoutVerifier, ExperienceResolver, GrantRecord, VerificationResult, } from '@fanfare-io/fanfare-sdk-core/storefront';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{FANFARE_PRODUCT_METAFIELD as r,parseExperienceIds as o,parseFirstExperienceId as e}from"./metafield.js";import{createShopifyExperienceResolver as f}from"./resolver.js";import{shopifyCheckoutVerifier as m}from"./verifier.js";import{ACCESS_STATUSES as i,snapshotToAccessStatus as t}from"@fanfare-io/fanfare-sdk-core/storefront";export{i as ACCESS_STATUSES,r as FANFARE_PRODUCT_METAFIELD,f as createShopifyExperienceResolver,o as parseExperienceIds,e as parseFirstExperienceId,m as shopifyCheckoutVerifier,t as snapshotToAccessStatus};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The experienceIds product metafield. The Fanfare app DEFINES it under the
3
+ * reserved namespace `$app:product`, which Shopify rewrites at runtime to
4
+ * `app--<numericAppId>--product`. A headless Storefront-API caller must use the
5
+ * reified namespace — the literal form returns null. The numeric app id is not
6
+ * storefront-readable and is provisioned out-of-band.
7
+ *
8
+ * PLACEHOLDER NOTE: the reified-namespace read against the live Storefront API is
9
+ * wired by createShopifyExperienceResolver; the constant and parser below are the
10
+ * stable, final-shaped primitives that read does not change.
11
+ */
12
+ export declare const FANFARE_PRODUCT_METAFIELD: {
13
+ readonly key: "experienceIds";
14
+ readonly type: "list.single_line_text_field";
15
+ readonly appRelativeNamespace: "$app:product";
16
+ };
17
+ /**
18
+ * Parse the raw metafield value into an ordered experience-id list. PURE and
19
+ * SSR-safe, TOTAL (never throws):
20
+ * - JSON array of strings → that array, order preserved
21
+ * - array containing any non-string entry → [] (the platform contract is a
22
+ * list of single-line text fields; a structurally mixed array is unusable)
23
+ * - non-array / pre-migration scalar / malformed JSON → []
24
+ * - absent / empty → []
25
+ */
26
+ export declare function parseExperienceIds(metafieldValue: string | null | undefined): string[];
27
+ /**
28
+ * Convenience: first id wins, or null. The platform single-experience contract.
29
+ * `parseFirstExperienceId(v) === parseExperienceIds(v)[0] ?? null`.
30
+ */
31
+ export declare function parseFirstExperienceId(metafieldValue: string | null | undefined): string | null;
@@ -0,0 +1 @@
1
+ const e={key:"experienceIds",type:"list.single_line_text_field",appRelativeNamespace:"$app:product"};function r(e){if(null==e)return[];const r=e.trim();if(""===r)return[];let t;try{t=JSON.parse(r)}catch{return[]}return Array.isArray(t)&&t.every(e=>"string"==typeof e)?t:[]}function t(e){return r(e)[0]??null}export{e as FANFARE_PRODUCT_METAFIELD,r as parseExperienceIds,t as parseFirstExperienceId};
@@ -0,0 +1,26 @@
1
+ import { ReactNode } from 'react';
2
+ import { JourneySnapshot } from '@fanfare-io/fanfare-sdk-core/experiences';
3
+ import { AccessStatus, CheckoutVerifier, GrantRecord } from '@fanfare-io/fanfare-sdk-core/storefront';
4
+ export interface FanfareAdapterValue {
5
+ /** Latest journey snapshot (reported by whatever drives the journey). */
6
+ snapshot: JourneySnapshot | null;
7
+ status: AccessStatus;
8
+ /** Grant recorded when the shopper cleared the drop (survives reloads). */
9
+ grant: GrantRecord | null;
10
+ reportSnapshot(snapshot: JourneySnapshot): void;
11
+ recordGrant(grant: GrantRecord): void;
12
+ clearGrant(): void;
13
+ verifier: CheckoutVerifier;
14
+ }
15
+ export declare function FanfareAdapterProvider({ verifier, legacyStorageKeys, children, }: {
16
+ verifier?: CheckoutVerifier;
17
+ /**
18
+ * Prior sessionStorage keys to hydrate a grant from one time, on mount, when
19
+ * the current key is empty. Lets a drop-in replacement of a bespoke adapter
20
+ * preserve already-recorded grants. The matched legacy entry is migrated to
21
+ * the current key and removed. Defaults to none.
22
+ */
23
+ legacyStorageKeys?: readonly string[];
24
+ children: ReactNode;
25
+ }): import("react/jsx-runtime").JSX.Element;
26
+ export declare function useFanfareAdapter(): FanfareAdapterValue;
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import{jsx as r}from"react/jsx-runtime";import{useState as e,useCallback as t,useMemo as n,createContext as o,useContext as i}from"react";import{snapshotToAccessStatus as s}from"@fanfare-io/fanfare-sdk-core/storefront";import{shopifyCheckoutVerifier as a}from"../verifier.js";const u="storefront_adapter_grant",f=o(null);function l(r){if(null===r)return null;try{return JSON.parse(r)}catch{return null}}function c({verifier:o=a,legacyStorageKeys:i=[],children:c}){const[d,m]=e(null),[w,g]=e(()=>function(r){if("undefined"==typeof window)return null;try{const e=l(window.sessionStorage.getItem(u));if(null!==e)return e;for(const t of r){if(t===u)continue;const r=window.sessionStorage.getItem(t),e=l(r);if(null!==e)return window.sessionStorage.setItem(u,r),window.sessionStorage.removeItem(t),e}return null}catch{return null}}(i)),p=t(r=>{m(r)},[]),S=t(r=>{g(r);try{window.sessionStorage.setItem(u,JSON.stringify(r))}catch{}},[]),h=t(()=>{g(null);try{window.sessionStorage.removeItem(u);for(const r of i)r!==u&&window.sessionStorage.removeItem(r)}catch{}},[i]),v=n(()=>({snapshot:d,status:s(d),grant:w,reportSnapshot:p,recordGrant:S,clearGrant:h,verifier:o}),[d,w,p,S,h,o]);/* @__PURE__ */
3
+ return r(f.Provider,{value:v,children:c})}function d(){const r=i(f);if(null===r)throw new Error("useFanfareAdapter must be used within FanfareAdapterProvider");return r}export{c as FanfareAdapterProvider,d as useFanfareAdapter};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * React bindings for the Shopify storefront adapter. Carries the React peer dep
3
+ * and the `"use client"` boundary; the isomorphic resolver/verifier/metafield
4
+ * surface lives at the package root (`@fanfare-io/fanfare-sdk-shopify`).
5
+ */
6
+ export { FanfareAdapterProvider, useFanfareAdapter } from './adapter-context';
7
+ export type { FanfareAdapterValue } from './adapter-context';
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{FanfareAdapterProvider as t,useFanfareAdapter as o}from"./adapter-context.js";export{t as FanfareAdapterProvider,o as useFanfareAdapter};
@@ -0,0 +1,43 @@
1
+ import { ExperienceResolver } from '@fanfare-io/fanfare-sdk-core/storefront';
2
+ export interface ShopifyExperienceResolverConfig {
3
+ /** Shop domain, e.g. "shop.myshopify.com". */
4
+ shopDomain: string;
5
+ /** Storefront API version, e.g. "2024-10". */
6
+ apiVersion: string;
7
+ /** PUBLIC Storefront-API access token (experienceIds is PUBLIC_READ). */
8
+ storefrontAccessToken: string;
9
+ /** Numeric Shopify app id, provisioned out-of-band; reifies the namespace. */
10
+ fanfareAppId: string;
11
+ /**
12
+ * PLACEHOLDER-ONLY static map of product `handle` → raw `experienceIds`
13
+ * metafield value. The placeholder body resolves `resolve(product)` from this
14
+ * map via `parseFirstExperienceId`, so the contract + parser path is exercised
15
+ * end-to-end without a network. The live Storefront-API read of the reified
16
+ * `app--<fanfareAppId>--product` / `experienceIds` metafield replaces this map
17
+ * (the only body change that lands later) — `resolve(product)`'s signature does
18
+ * NOT change. Omit it once the live read is wired.
19
+ */
20
+ metafieldValues?: Record<string, string>;
21
+ /**
22
+ * RESERVED — not read by the placeholder body. The live Storefront-API read
23
+ * will use this injectable (SSR/test seam) and default to `globalThis.fetch`.
24
+ * Until that read lands, supplying it is a no-op: the placeholder resolves
25
+ * from `metafieldValues` and never performs a network call. A contract test
26
+ * pins this (a supplied `fetchImpl` is never invoked).
27
+ */
28
+ fetchImpl?: typeof fetch;
29
+ }
30
+ /**
31
+ * Build a Shopify ExperienceResolver. `resolve(product)` returns the experience
32
+ * id carried by the product's `experienceIds` metafield (first id wins), or null
33
+ * when the product is not covered.
34
+ *
35
+ * PLACEHOLDER (no signature impact): the body currently resolves from the
36
+ * in-config static `metafieldValues` map (handle → raw metafield value) via
37
+ * `parseFirstExperienceId`, so the contract and parser path are exercised
38
+ * end-to-end without a network. Wiring the live Storefront-API read of the
39
+ * reified `app--<fanfareAppId>--product` / `experienceIds` metafield is the only
40
+ * change that lands later — the returned resolver's `resolve(product)` signature
41
+ * does NOT change. See ENG-931 metafield-wiring TODO.
42
+ */
43
+ export declare function createShopifyExperienceResolver(config: ShopifyExperienceResolverConfig): ExperienceResolver;
@@ -0,0 +1 @@
1
+ import{parseFirstExperienceId as e}from"./metafield.js";function r(r){if(!r.shopDomain||""===r.shopDomain.trim())throw new Error("createShopifyExperienceResolver: shopDomain is required");if(!r.apiVersion||""===r.apiVersion.trim())throw new Error("createShopifyExperienceResolver: apiVersion is required");if(!r.storefrontAccessToken||""===r.storefrontAccessToken.trim())throw new Error("createShopifyExperienceResolver: storefrontAccessToken is required");if(!r.fanfareAppId||!/^\d+$/.test(r.fanfareAppId))throw new Error("createShopifyExperienceResolver: fanfareAppId must be a non-empty numeric string");r.fanfareAppId,r.fetchImpl;const o=r.metafieldValues??{};return{resolve(r){const i=o[r.handle];return e(i)}}}export{r as createShopifyExperienceResolver};
@@ -0,0 +1,21 @@
1
+ import { CheckoutVerifier } from '@fanfare-io/fanfare-sdk-core/storefront';
2
+ /**
3
+ * Shopify checkout verifier. Called at checkout entry with the grant the adapter
4
+ * recorded when the shopper cleared the drop.
5
+ *
6
+ * TOTAL: resolves for every grant — never rejects (the checkout gate consumes it
7
+ * with `.then()` only, so a thrown failure would strand the gate in "checking" or
8
+ * surface as an unhandled rejection). An expired grant resolves
9
+ * { ok:false, reason:"grant_expired" }; any unexpected throw is caught and
10
+ * resolves { ok:false, reason:"verify_failed" }.
11
+ *
12
+ * PLACEHOLDER (no signature impact): the body currently enforces only client-side
13
+ * expiry (rejects an expired grant, accepts an unexpired one). The ENG-913
14
+ * server-validatable handoff — mint at claim, redeem + validate at checkout entry
15
+ * — slots in behind this exact `verify(grant)` signature later; callers do not
16
+ * change. The ENG-913 body redeems `grant.token` (the minted handoff token,
17
+ * marked by `grant.handoffToken === true`) via core's `processHandoffToken`, which
18
+ * THROWS on invalid/expired/replayed — the verifier MUST catch that and return
19
+ * { ok:false, reason } so the contract stays total. See ENG-913.
20
+ */
21
+ export declare const shopifyCheckoutVerifier: CheckoutVerifier;
@@ -0,0 +1 @@
1
+ const e={async verify(e){try{return void 0!==e.expiresAt&&Date.now()>e.expiresAt?{ok:!1,reason:"grant_expired"}:{ok:!0}}catch{return{ok:!1,reason:"verify_failed"}}}};export{e as shopifyCheckoutVerifier};
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@fanfare-io/fanfare-sdk-shopify",
3
+ "version": "0.2.0",
4
+ "description": "Shopify storefront adapter for Fanfare SDK: product→experience resolver, checkout verifier, and experienceIds metafield primitives",
5
+ "publishConfig": {
6
+ "registry": "https://registry.npmjs.org",
7
+ "access": "public"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/fanfare-io/fanfare-sdk.git"
12
+ },
13
+ "homepage": "https://docs.fanfare.io/sdk/shopify/quickstart",
14
+ "bugs": {
15
+ "url": "https://github.com/fanfare-io/fanfare-sdk/issues"
16
+ },
17
+ "type": "module",
18
+ "files": [
19
+ "dist/",
20
+ "!dist/**/*.map",
21
+ "!dist/**/*.tsbuildinfo",
22
+ "!dist/stats.html",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "./react": {
34
+ "types": "./dist/react/index.d.ts",
35
+ "import": "./dist/react/index.js"
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
39
+ "peerDependencies": {
40
+ "react": "^18.0.0 || ^19.1.1",
41
+ "react-dom": "^18.0.0 || ^19.1.1",
42
+ "@fanfare-io/fanfare-sdk-core": "0.2.0"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "react": {
46
+ "optional": true
47
+ },
48
+ "react-dom": {
49
+ "optional": true
50
+ }
51
+ },
52
+ "devDependencies": {
53
+ "@types/react": "^19.1.12",
54
+ "@types/react-dom": "^19.1.9",
55
+ "@vitejs/plugin-react": "^5.0.2",
56
+ "jsdom": "^26.1.0",
57
+ "prettier": "^3.5.3",
58
+ "prettier-plugin-organize-imports": "^4.1.0",
59
+ "react": "^19.1.1",
60
+ "react-dom": "^19.1.1",
61
+ "rimraf": "^6.0.1",
62
+ "typescript": "^5.9.2",
63
+ "vite": "^7.3.1",
64
+ "vite-plugin-dts": "^4.5.4",
65
+ "vite-tsconfig-paths": "^5.1.4",
66
+ "vitest": "^3.2.4",
67
+ "@fanfare-io/fanfare-sdk-core": "0.2.0"
68
+ },
69
+ "sideEffects": false,
70
+ "keywords": [
71
+ "fanfare",
72
+ "shopify",
73
+ "storefront",
74
+ "ecommerce",
75
+ "sdk",
76
+ "headless"
77
+ ],
78
+ "license": "Apache-2.0",
79
+ "scripts": {
80
+ "build": "vite build",
81
+ "build:deps": "vite build --emptyOutDir false",
82
+ "build:incremental": "vite build --emptyOutDir false",
83
+ "build:dist": "rimraf dist && vite build",
84
+ "build:strict": "pnpm typecheck && pnpm build",
85
+ "dev": "vite build --watch",
86
+ "fmt": "prettier src --write",
87
+ "lint": "oxlint src",
88
+ "lint:fix": "oxlint --fix src",
89
+ "prebuild": "rimraf dist",
90
+ "build:test-deps": "pnpm -F @fanfare-io/fanfare-sdk-core run build:incremental",
91
+ "test": "pnpm build:test-deps && vitest run",
92
+ "test:watch": "vitest",
93
+ "test:unit": "pnpm build:test-deps && vitest run .unit.test.ts --passWithNoTests",
94
+ "test:contract": "pnpm build:test-deps && vitest run .contract.test.ts --passWithNoTests",
95
+ "typecheck": "tsc --noEmit"
96
+ }
97
+ }