@markee_team/sdk 0.1.0-alpha.2 → 0.1.0-alpha.20

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/README.md CHANGED
@@ -1,13 +1,15 @@
1
- # @markee_team/sdk
1
+ # Markee SDK
2
2
 
3
3
  An ESM JavaScript SDK with a self-contained, Shadow DOM modal and an optional React entry point. The SDK knows the Markee API endpoint; the host only supplies its placement and, optionally, its current wallet provider. No Alchemy, Redis, Privy, or bridge-provider key belongs in the consuming app.
4
4
 
5
- This is an experimental `0.1.0-alpha.2` release for wallet-funded For Sale and For Rent flows. Hosted card checkout and incoming cross-chain funding are not included.
5
+ Embed a Markee leaderboard in your app with wallet-funded For Sale and For Rent flows, automatic strategy detection, and a configurable theme. Eligible Base For Sale boards can also offer Markee-hosted card checkout when enabled by Markee. Incoming cross-chain funding is not included.
6
6
 
7
- Install the alpha:
7
+ The package also includes a standalone **Markee sign button**. It shows the board's current winner, follows Markee's moderation decisions, and opens the payment modal when clicked.
8
+
9
+ ## Installation
8
10
 
9
11
  ```sh
10
- npm install @markee_team/sdk@alpha
12
+ npm install @markee_team/sdk@latest
11
13
  ```
12
14
 
13
15
  Use React 18 or 19 for the optional React entry point. The plain JavaScript entry point does not require React. Both TypeScript bundler and NodeNext resolution are supported.
@@ -19,6 +21,31 @@ npm ci --prefix packages/sdk
19
21
  npm run build --prefix packages/sdk
20
22
  ```
21
23
 
24
+ ## Create and connect your leaderboard
25
+
26
+ The SDK connects to an existing leaderboard; installing it does not create one.
27
+
28
+ 1. Open [Create a Markee](https://www.markee.xyz/create-a-markee) and complete the leaderboard setup on Markee. Choose For Sale or For Rent there. If you already have a leaderboard, use it instead.
29
+ 2. Copy the resulting Markee page link: `https://www.markee.xyz/markee/<address>`.
30
+ 3. Extract the `0x…` address from that link and use it in the SDK placement: `{ kind: 'board', chainId: 8453, address: yourLeaderboardAddress }`.
31
+ 4. Open the modal to display your leaderboard. If using a coding assistant, give it the Markee page link along with the LLM implementation prompt below.
32
+
33
+ The SDK reads the leaderboard's strategy from Markee and automatically renders the appropriate For Sale or For Rent flow. You do not configure a strategy in your app.
34
+
35
+ ## Automatic site verification
36
+
37
+ Pass your public page URL or domain as `siteUrl` to `MarkeeModal` or `createMarkee`, for example `siteUrl="https://your-app.example"`. The React component registers the site when mounted, even while closed; the JavaScript modal registers when opened. No API key is required. Use `onSiteVerification` to inspect success or setup errors; verification does not block browsing or payments.
38
+
39
+ Markee fetches the public page and verifies that its HTML contains the matching board marker before adding it to **Served on**. The React component renders this marker for server-rendered apps. For client-rendered apps such as Vite, include it in the deployed `index.html` (replace the address with your board):
40
+
41
+ ```html
42
+ <span hidden data-markee-address="0xYOUR_BOARD_ADDRESS"></span>
43
+ ```
44
+
45
+ The marker must be present in the HTML returned by the server, not only injected by JavaScript. The supplied URL must use HTTPS, match the app's origin, and return the final HTML page without redirects. Localhost and private-network sites cannot be publicly verified. Registration currently supports Base boards. It verifies the board's presence, not legal domain ownership.
46
+
47
+ For an explicit retry after deployment, call `new MarkeeClient().verifySite(placement, siteUrl)`. The endpoint is `POST /api/sdk/v1/sites/verify` with `{ placement, siteUrl }`. Unverified sites are never added to the verified list.
48
+
22
49
  ## Plain JavaScript
23
50
 
24
51
  ```ts
@@ -44,7 +71,7 @@ markee.open({
44
71
  // markee.close();
45
72
  ```
46
73
 
47
- Without a wallet adapter, browsing works without a wallet. On a connect click the modal discovers installed wallets using EIP-6963, with an EIP-1193 fallback. Multiple discovered wallets are offered for explicit selection. An adapter always takes precedence over injected discovery. Hosted login/card checkout is not part of milestones 1–4.
74
+ Without a wallet adapter, browsing works without a wallet. On a connect click the modal discovers installed wallets using EIP-6963, with an EIP-1193 fallback. Multiple discovered wallets are offered for explicit selection. An adapter always takes precedence over injected discovery. Eligible boards also offer hosted login and card checkout when enabled by Markee; the host app does not need its own wallet integration.
48
75
 
49
76
  ## React
50
77
 
@@ -61,9 +88,24 @@ import { MarkeeModal } from '@markee_team/sdk/react';
61
88
 
62
89
  See [`examples/connectkit`](https://github.com/1Hive/markee/tree/feature/markee-sdk/examples/connectkit) for a complete adapter. Its connection promise resolves only once ConnectKit has selected a provider and rejects when the picker is dismissed. The SDK does not install a second wallet context.
63
90
 
91
+ ## Embed the current Markee sign
92
+
93
+ ```tsx
94
+ import { MarkeeSign } from '@markee_team/sdk/react';
95
+
96
+ const placement = { kind: 'board', chainId: 8453, address: '0x2768BC6e90266248BD8bCF5401C36D8049CdF671' } as const;
97
+ <MarkeeSign placement={placement} theme={{ mode: 'dark' }} />;
98
+ ```
99
+
100
+ `MarkeeSign` is a compact, clickable sign with the winner's message, view count, and a suggested monthly rate on For Rent boards. By default, clicking it opens the SDK modal. Pass `onOpen={() => setOpen(true)}` to open your own controlled `MarkeeModal` instead, or `showAction={false}` to render a non-clickable sign. The sign and modal accept separate `theme` values. No app-side moderation database, RPC key, or moderation provider is needed. To render from plain JavaScript, call `createMarkeeSign(containerElement, { placement })`; its return value has `refresh()`, `setTheme()`, and `destroy()`.
101
+
102
+ The sign fades in the real MARKEE logo behind the message on hover and keyboard focus, following the Gardens sign treatment. It selects the light or dark logo with the sign's theme, including system-mode changes. Set `theme={{ mode: 'dark', sign: { hoverLogo: false } }}` to disable the watermark. `sign.hoverBackground` remains available for an optional hover surface color; otherwise the sign keeps its normal surface. These options apply only to the sign, so the modal can use its own theme.
103
+
104
+ The SDK snapshot API reads **board moderation flags** from Markee's database. A flagged winner is blurred with a notice. The sign does not offer a reveal action or count a view for flagged content. If moderation data cannot be loaded, it withholds the message until the status is known. Visible, unflagged signs record one view per message. The sign refreshes every 30 seconds while mounted and can be refreshed on demand. Markee-only site flags intentionally apply only on markee.xyz; they do not censor a partner's embedded sign. Moderators still manage flags on Markee; moderation writes invalidate SDK snapshots so embedded signs can pick up changes on their next refresh.
105
+
64
106
  ## Modal layout
65
107
 
66
- Both strategies follow Gardens' For Rent modal: a compact, 512px panel with a fixed header/footer, a collapsible leaderboard, the selected message or editor, and a prominent amount card. The leaderboard pins your loaded messages and offers inline funding selection. Your active rental message is selected when available; otherwise an owned message or the creation form is shown.
108
+ Both strategies use a consistent, compact 512px panel with a fixed header/footer, a collapsible leaderboard, the selected message or editor, and a prominent amount card. The leaderboard pins your loaded messages and offers inline funding selection. Your active rental message is selected when available; otherwise an owned message or the creation form is shown.
67
109
 
68
110
  For Sale uses the same arrangement with a one-time ETH amount. For Rent uses an ETHx monthly rate and links to Deposit manager. Wallet balances, rewards, refunds, edits, and community treasury actions remain accessible without top-level tabs. The footer holds the review/confirmation actions and Stop streaming when applicable.
69
111
 
@@ -79,7 +121,9 @@ import { createMarkee, type MarkeeTheme } from '@markee_team/sdk';
79
121
  const theme: MarkeeTheme = {
80
122
  mode: 'system',
81
123
  fontFamily: '"DM Sans", system-ui, sans-serif',
82
- radius: 12,
124
+ radius: 16,
125
+ cardRadius: 12,
126
+ controlRadius: 8,
83
127
  colors: {
84
128
  primary: '#743a84',
85
129
  primaryText: '#ffffff',
@@ -101,8 +145,12 @@ Theme changes update styles in place: drafts, focus, scroll, wallet sessions, an
101
145
  | --- | --- |
102
146
  | `mode` | `light`, `dark`, or `system` |
103
147
  | `fontFamily` | CSS font stack; the app supplies any custom font |
104
- | `radius` | Panel radius in pixels, 0–48 (default 22); card and control corners scale with it |
148
+ | `radius` | Panel radius in pixels, 0–48 (default 22) |
149
+ | `cardRadius` | Card radius in pixels, 0–48; defaults to 64% of panel radius |
150
+ | `controlRadius` | Button and input radius in pixels, 0–48; defaults to 45% of panel radius |
105
151
  | `colors` | Partial overrides for the semantic tokens below |
152
+ | `sign.hoverLogo` | Show the theme-matched MARKEE logo on hover/focus (default `true`) |
153
+ | `sign.hoverBackground` | Optional sign hover surface color; defaults to the normal surface |
106
154
 
107
155
  Color tokens: `background`, `surface`, `text`, `muted`, `border`, `inputBackground`, `inputText`, `primary`, `primaryText`, `accent`, `accentText`, `accentSurface`, `accentSurfaceText`, `accentBorder`, `selected`, `selectedText`, `info`, `infoText`, `error`, `errorText`, `success`, `successText`, `link`, `focusRing`, and `overlay`. Set foreground/background pairs together and check your brand's contrast in both modes. Overrides apply over either selected palette; omitted values use that palette's defaults. Invalid CSS color/font values fall back to defaults.
108
156
 
@@ -135,49 +183,127 @@ Community activation supports the current council Safe, a current Safe owner, or
135
183
  - The modal renders escaped text, uses isolated CSS, and supports keyboard focus, Escape, mobile sizing and reduced motion. A host CSP must permit the SDK's inline styles and connections to its configured Markee API. No external font or image is needed by the modal.
136
184
  - API failures are explicit. Without moderation data, message text is withheld. No mock balances or fabricated rewards are returned by production handlers.
137
185
 
138
- Backend configuration, endpoint details, and verification evidence: [`docs/sdk/implementation.md`](https://github.com/1Hive/markee/blob/feature/markee-sdk/docs/sdk/implementation.md).
186
+ Backend configuration and API reference: [`docs/sdk/implementation.md`](https://github.com/1Hive/markee/blob/feature/markee-sdk/docs/sdk/implementation.md).
139
187
 
140
188
  ## API endpoint
141
189
 
142
- No API URL configuration is required. This alpha uses the Markee staging API at `https://markee-git-feature-markee-sdk-1hive.vercel.app/api/sdk/v1`. For local development or testing only, pass an optional `apiUrl` override to `createMarkee`, `MarkeeClient`, or the React modal. The current default is also exported as `DEFAULT_MARKEE_API_URL`.
190
+ No API URL or Markee API key is required. The SDK connects to the Markee-hosted API and centralizes on-chain reads, metadata, and transaction preparation. For local development or testing, pass an optional `apiUrl` override to `createMarkee`, `MarkeeClient`, or the React modal. The endpoint used by your installed release is exported as `DEFAULT_MARKEE_API_URL`.
143
191
 
144
192
  ## LLM implementation prompt
145
193
 
146
- Copy this prompt into your coding assistant. These are existing Base demo boards; replace the placements with your own when integrating your product.
194
+ Copy this prompt into your coding assistant. It gathers missing requirements before implementing the integration.
147
195
 
148
196
  ```text
149
- Integrate @markee_team/sdk@0.1.0-alpha.2 into this app. Inspect the app first and
150
- follow its existing framework, styling, and wallet patterns.
151
-
152
- - Install @markee_team/sdk@0.1.0-alpha.2. The SDK knows its API endpoint. Do not
153
- request an API URL, build an API proxy, or add RPC/database/provider keys.
154
- - For React 18/19, import MarkeeModal from @markee_team/sdk/react in a client
155
- component and supply open, onClose, and placement. For other apps, import
156
- createMarkee from @markee_team/sdk, call createMarkee(), then open({ placement }).
157
- Close the instance on teardown. Reuse the built-in modal UI.
158
- - Add buttons for these existing demo placements:
159
- For Sale: { kind: 'board', chainId: 8453,
160
- address: '0x2768BC6e90266248BD8bCF5401C36D8049CdF671' }
161
- For Rent: { kind: 'board', chainId: 8453,
162
- address: '0x82cbe3BdFC4e01940D186Ac5EA151355647DE0d3' }
163
- - Wallet integration is optional. Reuse the app's selected EIP-1193 provider via
164
- wallet.getProvider(): Promise<provider | null> and optional
165
- wallet.connect(): Promise<provider>. For ConnectKit/wagmi, use the active
166
- connector's provider, resolve connect after selection, and reject cancellation.
167
- Do not create a second wallet context or silently select another injected wallet.
168
- If there is no existing wallet integration, omit wallet for SDK wallet discovery.
169
- - Match the app using theme: mode ('light', 'dark', 'system'), fontFamily, radius,
170
- and semantic colors such as primary and primaryText. Preserve the built-in
171
- layout and its isolated Shadow DOM styles.
172
- - Optionally handle onEvent and show success only for a confirmed event. Let the
173
- SDK handle payment review, chain switching, submission, and verification.
174
- Do not advertise card checkout or incoming bridging: this alpha lacks those
175
- features. The demo boards use real Base funds.
176
- - Run typecheck/build and verify both modals load without API configuration,
177
- open/close correctly, and match the theme. Verify host wallet reuse if available.
178
- Do not sign or submit transactions during automated verification. Report changed
179
- files, checks, and remaining limitations.
180
-
181
- This alpha automatically uses Markee's temporary staging backend. Read the installed
182
- package README for exact types and configuration details.
197
+ Integrate @markee_team/sdk@latest into this app. Inspect the codebase first and
198
+ follow its existing framework, styling, and wallet patterns. Read the installed
199
+ package README and types for current capabilities.
200
+
201
+ Before implementing, ask me to create my leaderboard on Markee at
202
+ https://www.markee.xyz/create-a-markee, then provide its resulting Markee page link.
203
+ If I already have a leaderboard, ask for that link instead; do not create a duplicate.
204
+ Example link format:
205
+ https://www.markee.xyz/markee/0x6ceBC87DE40519Fa52fc40a1d49f16FF968bb439
206
+ Never silently substitute a demo board. Wait for my link before wiring the placement.
207
+
208
+ Extract the board address from the /markee/<address> path. Validate the Markee URL
209
+ and the address (0x followed by 40 hexadecimal characters). Markee website boards
210
+ currently use Base, chain ID 8453. Verify the board through the SDK snapshot API;
211
+ if verification fails, explain the error and ask for a corrected link.
212
+
213
+ Do not ask me to choose For Sale or For Rent in the host app. That choice is made
214
+ when creating the leaderboard on Markee. The API returns strategy and the SDK
215
+ adapts the modal automatically. Do not add a strategy prop, toggle, or hardcoded mode.
216
+
217
+ Ask only the remaining unanswered requirements in one concise group:
218
+ - Where should Markee appear, what opens the modal, and what should the button say?
219
+ - Should it reuse the app's existing wallet, use SDK wallet discovery, or use
220
+ Markee-hosted card checkout without an app wallet (For Sale on Base only)? Inspect
221
+ existing connectors first; do not add a second wallet context or install a new
222
+ connector without agreement.
223
+ - Should the modal match the app theme or use specific colors, font, radius, and
224
+ light/dark/system mode?
225
+ - What public domain/page will host this integration? Use it as siteUrl for
226
+ automatic verification. For Vite/client rendering, add the board marker to the
227
+ static HTML as documented; do not claim localhost is verified.
228
+ - What should happen after a confirmed transaction: notification, refresh,
229
+ navigation, or callback? Are there additional mobile/accessibility requirements?
230
+
231
+ Then implement the agreed scope:
232
+ 1. Install @markee_team/sdk@latest. No API URL or Markee API key is required.
233
+ Do not create an API proxy or add RPC/database credentials.
234
+ 2. Use placement = { kind: 'board', chainId: 8453, address: extractedAddress }.
235
+ Use new MarkeeClient().snapshot(placement) to verify the board and read strategy,
236
+ name, minimum, and other metadata. The modal performs its own snapshot loading;
237
+ do not recreate that loading or strategy logic in the host app.
238
+ 3. For React, use MarkeeModal from @markee_team/sdk/react in a client component
239
+ with open, onClose, and placement. Otherwise use createMarkee() from
240
+ @markee_team/sdk, then open({ placement }); close it on teardown.
241
+ 4. If a host wallet exists, pass its selected EIP-1193 provider through the wallet
242
+ adapter. For ConnectKit/wagmi use the active connector. Resolve connect after
243
+ selection, reject cancellation, and do not silently switch wallet providers.
244
+ Otherwise omit wallet. Without a connected app account, the modal shows only
245
+ Pay, opening Markee-hosted checkout for supported boards. Do not install
246
+ Privy or collect card details in the host app.
247
+ 5. Apply theme options while preserving the built-in modal layout. Handle onEvent
248
+ if needed; show success only for a confirmed event. Let the SDK manage review,
249
+ network switching, submission, and verification.
250
+ 6. Verify build/types, loading of the supplied board, automatic strategy selection,
251
+ open/close behavior, theme, and wallet reuse. Do not sign or send transactions
252
+ during automated verification. Report changed files, checks, and limitations.
253
+
254
+ Check the installed release's supported features before promising functionality.
255
+ Wallet-funded flows are supported. Hosted card checkout requires Markee's backend
256
+ capability to be enabled; do not promise availability when it is disabled. Incoming
257
+ bridging is not available. Transactions and card funding use real funds.
183
258
  ```
259
+
260
+ ## Pay by card without an app wallet
261
+
262
+ Without a connected app wallet, the modal shows **Pay** as its only payment action
263
+ and hides wallet balances and wallet-management sections. For Sale boards on Base
264
+ with MARKEE rewards support this flow
265
+ when the Markee backend enables hosted checkout. No Privy provider, payment keys or
266
+ API configuration is needed in the integrating app. Omit the `wallet` adapter.
267
+
268
+ The SDK opens Markee, where the user signs in, receives a Privy embedded wallet,
269
+ funds it through Stripe (Base USDC converted to ETH) or MoonPay (Base ETH), and confirms
270
+ the Markee payment. The contract sends MARKEE directly to that user's paying
271
+ wallet. The host receives `onEvent({ type: 'confirmed', hash })` only after
272
+ server-side receipt verification. Card funding alone is not a successful payment.
273
+
274
+ The checkout can resume after closing or refreshing. If a wallet submission has an
275
+ unknown result, it asks the user to check the existing transaction instead of
276
+ sending again. On browsers that block popups, it navigates to Markee in the same
277
+ tab. Reopen Pay after returning to recover the confirmed result.
278
+
279
+ Card availability, fees, minimum purchase amounts and identity checks depend on
280
+ the funding provider and user eligibility. Any unused USDC or ETH remains in the
281
+ user's wallet. Conversion uses a capped approval and maximum 1% slippage, with
282
+ wallet confirmation and Markee-sponsored conversion gas. For Rent, incoming
283
+ bridging and automatic rewards forwarding to a different wallet are outside this
284
+ checkout flow. If hosted checkout is unavailable, Pay is disabled with an
285
+ availability message; the modal does not fall back to asking for a wallet.
286
+
287
+ ### Reuse a Markee login
288
+
289
+ Pay opens a temporary browser tab on Markee, where the existing Privy session is
290
+ restored before showing sign-in. The SDK does not copy login tokens into the host
291
+ app. The tab closes after the host verifies the payment. If tabs are blocked,
292
+ checkout falls back to a same-tab redirect. To always redirect, pass
293
+ `checkoutWindow: 'redirect'` (`checkoutWindow="redirect"` in React).
294
+
295
+ Session reuse requires the same exact Markee origin and Privy app ID. A login on
296
+ `www.markee.xyz` is not a login on a Vercel preview domain. Markee can set
297
+ `MARKEE_CHECKOUT_ORIGIN=https://www.markee.xyz` on its API deployment **after** the
298
+ checkout route is deployed there. Both deployments must use the same checkout KV,
299
+ signing secret, supported configuration and Privy app. Omit this setting to keep
300
+ checkout on the API origin. Integrators do not configure an API or checkout URL.
301
+ Existing pending checkout sessions retain their original destination.
302
+
303
+ ### Pay in Markee availability
304
+
305
+ The SDK checks the Markee API before offering hosted payment. Markee controls this
306
+ feature with the server-only `FLAG_SDK_PAY_IN_MARKEE` environment variable, which
307
+ defaults to false. Only `true`, together with the required checkout configuration,
308
+ enables it. Integrating apps do not need to provide a flag or API key. Connected
309
+ wallet payments remain available independently.
@@ -0,0 +1,7 @@
1
+ import { type MarkeeClient } from './client.js';
2
+ import type { Action, CheckoutSession, CheckoutStatus, Placement, TransactionResult } from './types.js';
3
+ export declare function savedCheckout(client: MarkeeClient, placement: Placement): CheckoutSession | null;
4
+ export declare function checkoutStatus(client: MarkeeClient, session: CheckoutSession): Promise<CheckoutStatus>;
5
+ export declare function forgetCheckout(client: MarkeeClient, placement: Placement): void;
6
+ /** Call directly from a click handler to preserve popup permission. */
7
+ export declare function openHostedCheckout(client: MarkeeClient, placement: Placement, action: Action): Promise<TransactionResult>;
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { Action, Address, AdminOperation, AdminResult, Authorization, BridgeStatus, ClaimQuote, EIP1193Provider, Hex, Placement, PreparedAction, SDKOptions, Snapshot, TransactionResult } from './types.js';
2
- /** Markee-hosted API for the alpha release. */
3
- export declare const DEFAULT_MARKEE_API_URL = "https://markee-git-feature-markee-sdk-1hive.vercel.app/api/sdk/v1";
1
+ import type { Action, Address, AdminOperation, AdminResult, Authorization, BridgeStatus, ClaimQuote, EIP1193Provider, Hex, Placement, PreparedAction, SDKOptions, Snapshot, SiteVerification, TransactionResult } from './types.js';
2
+ /** Markee-hosted API used by integrations unless overridden for local development. */
3
+ export declare const DEFAULT_MARKEE_API_URL = "https://2staging.markee.xyz/api/sdk/v1";
4
4
  export declare class MarkeeError extends Error {
5
5
  code: string;
6
6
  status?: number | undefined;
@@ -38,6 +38,9 @@ export declare class MarkeeClient {
38
38
  provider(): Promise<EIP1193Provider | null>;
39
39
  account(): Promise<Address | null>;
40
40
  connect(selected?: EIP1193Provider): Promise<Address>;
41
+ verifySite(placement: Placement, siteUrl: string): Promise<SiteVerification>;
42
+ private siteRequests;
43
+ registerSite(placement: Placement): void;
41
44
  snapshot(placement: Placement, account?: Address | null, offset?: number, signal?: AbortSignal): Promise<Snapshot>;
42
45
  prepare(placement: Placement, action: Action): Promise<PreparedAction>;
43
46
  private ensureWallet;
package/dist/index.d.ts CHANGED
@@ -4,3 +4,6 @@ export type { PendingTransaction, DiscoveredWallet } from './client.js';
4
4
  export { createMarkee, MarkeeModal } from './modal.js';
5
5
  export type { ModalOptions } from './modal.js';
6
6
  export { parseEth, formatEth } from './amount.js';
7
+ export { openHostedCheckout, checkoutStatus, savedCheckout } from './checkout.js';
8
+ export { createMarkeeSign, signContent } from './sign.js';
9
+ export type { MarkeeSignOptions } from './sign.js';