{"_id":"@cuvara/retailer-sdk","_rev":"2-2995bde8e0fd3f1b9f193dddbf19b523","name":"@cuvara/retailer-sdk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@cuvara/retailer-sdk","version":"0.1.0","license":"SEE LICENSE IN LICENSE.md","_id":"@cuvara/retailer-sdk@0.1.0","maintainers":[{"name":"uncommonheroes","email":"it@uncommonheroes.com"}],"dist":{"shasum":"06c433f2ad06d37b16537e1c46f356bf408f7ab5","tarball":"https://registry.npmjs.org/@cuvara/retailer-sdk/-/retailer-sdk-0.1.0.tgz","fileCount":41,"integrity":"sha512-9JlAZYxJODotwS6XoI0JnIVdnIEso4VZfxZMllX5fpue4FAWdM1LW/55PanrZAbsOiAFIgVtBT0GBKMa7vWKYw==","signatures":[{"sig":"MEUCIBnkgEbrVlVG51GpK365WNLx2sdGqjTQmlUAmcVbO1D3AiEAlEFIenKLt8vxDVJGBzKbYJovhOfDPGWRD1+zuP4hzro=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":158817},"main":"./dist/cuvara-retailer-sdk.js","type":"module","types":"./dist/index.d.ts","module":"./dist/cuvara-retailer-sdk.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/cuvara-retailer-sdk.js","default":"./dist/cuvara-retailer-sdk.js","require":"./dist/cuvara-retailer-sdk.js"},"./vue":{"types":"./dist/vue/index.d.ts","import":"./dist/vue/index.js","default":"./dist/vue/index.js","require":"./dist/vue/index.js"},"./react":{"types":"./dist/react/index.d.ts","import":"./dist/react/index.js","default":"./dist/react/index.js","require":"./dist/react/index.js"},"./package.json":"./package.json"},"scripts":{"test":"vitest run","build":"vite build && vite build --config vite.iife.config.ts && tsc -p tsconfig.build.json","typecheck":"tsc -p tsconfig.json --noEmit","test:watch":"vitest"},"_npmUser":{"name":"uncommonheroes","email":"it@uncommonheroes.com"},"_npmVersion":"10.9.8","description":"Cuvara retailer SDK — Try On button and modal for product pages","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","_hasShrinkwrap":false,"devDependencies":{"vue":"^3","vite":"^6","jsdom":"^26","react":"^19","vitest":"^3","react-dom":"^19","typescript":"^5","@types/react":"^19","vite-plugin-dts":"^4","@types/react-dom":"^19"},"peerDependencies":{"vue":">=3","react":">=17","react-dom":">=17"},"peerDependenciesMeta":{"vue":{"optional":true},"react":{"optional":true},"react-dom":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/retailer-sdk_0.1.0_1787336356462_0.7366929006685352","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@cuvara/retailer-sdk","version":"0.1.1","description":"Cuvara retailer SDK — Try On button and modal for product pages","type":"module","main":"./dist/cuvara-retailer-sdk.js","module":"./dist/cuvara-retailer-sdk.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/cuvara-retailer-sdk.js","require":"./dist/cuvara-retailer-sdk.js","default":"./dist/cuvara-retailer-sdk.js"},"./react":{"types":"./dist/react/index.d.ts","import":"./dist/react/index.js","require":"./dist/react/index.js","default":"./dist/react/index.js"},"./vue":{"types":"./dist/vue/index.d.ts","import":"./dist/vue/index.js","require":"./dist/vue/index.js","default":"./dist/vue/index.js"},"./package.json":"./package.json"},"scripts":{"build":"vite build && vite build --config vite.iife.config.ts && tsc -p tsconfig.build.json","typecheck":"tsc -p tsconfig.json --noEmit","test":"vitest run","test:watch":"vitest"},"peerDependencies":{"react":">=17","react-dom":">=17","vue":">=3"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true},"vue":{"optional":true}},"devDependencies":{"@types/react":"^19","@types/react-dom":"^19","jsdom":"^26","react":"^19","react-dom":"^19","typescript":"^5","vite":"^6","vite-plugin-dts":"^4","vitest":"^3","vue":"^3"},"license":"SEE LICENSE IN LICENSE.md","sideEffects":false,"_id":"@cuvara/retailer-sdk@0.1.1","_nodeVersion":"22.23.2","_npmVersion":"10.9.8","dist":{"integrity":"sha512-IJkq/AYWgLWnX6GnqRZi/tKads5zsyfXBraofEv13vsBFVeTlUQwjmjKL2hJH10F9HqoFeU9dju9fiVwvV78eg==","shasum":"3d5f453b091203aa8133ed3ca40e930e3bb723c2","tarball":"https://registry.npmjs.org/@cuvara/retailer-sdk/-/retailer-sdk-0.1.1.tgz","fileCount":43,"unpackedSize":172598,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDL0IjwTej/sbwP/H7T1ca5eYg3R7IOinYPjCttyVYfJQIhAKg+DrZiFSR/u/Qg6vTofP1y70hRI/1Sz8dZhFaONjM5"}]},"_npmUser":{"name":"uncommonheroes","email":"it@uncommonheroes.com"},"directories":{},"maintainers":[{"name":"uncommonheroes","email":"it@uncommonheroes.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/retailer-sdk_0.1.1_1788145584439_0.7214367590356261"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-21T18:19:16.320Z","modified":"2026-08-31T03:06:24.773Z","0.1.0":"2026-08-21T18:19:16.611Z","0.1.1":"2026-08-31T03:06:24.588Z"},"license":"SEE LICENSE IN LICENSE.md","description":"Cuvara retailer SDK — Try On button and modal for product pages","maintainers":[{"name":"uncommonheroes","email":"it@uncommonheroes.com"}],"readme":"# @cuvara/retailer-sdk\n\nJavaScript SDK for embedding Cuvara Try On on retailer product pages.\n\nThe SDK confirms the product against the public retailer API, shows a **Try It On You** button only when the product is valid, and opens the Cuvara try-on experience in a modal iframe.\n\n## Install\n\n```bash\nnpm install @cuvara/retailer-sdk\n```\n\nOr load the IIFE build from your CDN / static hosting:\n\n```html\n<script src=\"https://cdn.example.com/cuvara-retailer-sdk.iife.js\"></script>\n```\n\n## Prerequisites\n\n1. Create a retailer API token (`rtk_...`) in the Cuvara admin.\n2. Catalog products with `external_id` values that match your storefront product IDs.\n3. Know your API base URL (including `/api/v1`) and Cuvara frontend URL.\n\n## Vanilla JavaScript\n\n```html\n<div id=\"cuvara-try-on\"></div>\n<script type=\"module\">\n  import { Cuvara } from '@cuvara/retailer-sdk'\n\n  Cuvara.init({\n    token: 'rtk_...',\n    apiBaseUrl: 'https://api.example.com/api/v1',\n    frontendUrl: 'https://app.example.com',\n  })\n\n  const handle = Cuvara.mount('#cuvara-try-on', {\n    externalId: 'product-sku-123',\n    onError: (error) => console.warn('[Cuvara]', error),\n  })\n\n  // handle.destroy()\n</script>\n```\n\nWith the IIFE build:\n\n```html\n<div id=\"cuvara-try-on\"></div>\n<script src=\"/cuvara-retailer-sdk.iife.js\"></script>\n<script>\n  Cuvara.init({\n    token: 'rtk_...',\n    apiBaseUrl: 'https://api.example.com/api/v1',\n    frontendUrl: 'https://app.example.com',\n  })\n  Cuvara.mount('#cuvara-try-on', {\n    externalId: 'product-sku-123',\n    onError: (error) => console.warn('[Cuvara]', error),\n  })\n</script>\n```\n\n## React\n\n```tsx\nimport { CuvaraProvider, CuvaraTryOnButton } from '@cuvara/retailer-sdk/react'\n\nexport function ProductPage({ product }) {\n  return (\n    <CuvaraProvider\n      token=\"rtk_...\"\n      apiBaseUrl=\"https://api.example.com/api/v1\"\n      frontendUrl=\"https://app.example.com\"\n    >\n      <CuvaraTryOnButton\n        externalId={product.id}\n        onError={(error) => console.warn('[Cuvara]', error)}\n      />\n    </CuvaraProvider>\n  )\n}\n```\n\n## Vue\n\n```vue\n<script setup lang=\"ts\">\nimport { CuvaraProvider, CuvaraTryOnButton } from '@cuvara/retailer-sdk/vue'\n</script>\n\n<template>\n  <CuvaraProvider\n    :token=\"token\"\n    :api-base-url=\"apiBaseUrl\"\n    :frontend-url=\"frontendUrl\"\n  >\n    <CuvaraTryOnButton\n      :external-id=\"product.id\"\n      @error=\"(error) => console.warn('[Cuvara]', error)\"\n    />\n  </CuvaraProvider>\n</template>\n```\n\n## Shopify public app / theme snippet\n\nPass the storefront product id explicitly (Liquid `product.id`, or your mapped external id):\n\n```html\n<div id=\"cuvara-try-on\"></div>\n<script src=\"https://cdn.example.com/cuvara-retailer-sdk.iife.js\"></script>\n<script>\n  Cuvara.init({\n    token: 'rtk_...',\n    apiBaseUrl: 'https://api.example.com/api/v1',\n    frontendUrl: 'https://app.example.com',\n  })\n  Cuvara.mount('#cuvara-try-on', {\n    externalId: '{{ product.id }}',\n    onError: (error) => console.warn('[Cuvara]', error),\n  })\n</script>\n```\n\n## Behavior\n\n1. `Cuvara.init` stores the retailer token and URLs.\n2. `Cuvara.mount` calls `POST /retailers/public/confirm` with `Authorization: Bearer rtk_…` and `{ external_id }`.\n3. On **200**, the Try On button is rendered into the target element. A hidden iframe loads `{frontendUrl}/retailers/embed-session` and, if the shopper already has a Cuvara session, the promo shows that account:\n   - **Guest Account** with the creation date\n   - Guest accounts that already entered a name but have not confirmed email: name (and avatar thumb if present) plus a prompt to check their inbox — they are still a Guest Account until confirmation\n   - Regular accounts with first and last name, plus an avatar thumbnail when one is active\n   - A **Logoff** control (with confirmation — stronger copy for guest accounts, which cannot be recovered and are auto-deleted after 30 days)\n4. On **401 / 403 / 404 / network error**, the target stays empty, except a region block (`This App is not supported in …`), which replaces the Try On button with that message. Failures are logged with `console.warn('[Cuvara]', error)` and the optional `onError` callback.\n5. On click, a modal iframe opens `{frontendUrl}/retailers/try-on?externalId=…`. The retailer token is passed to the iframe with `postMessage`, not the URL. Closing the modal refreshes the promo identity.\n\n### Mount options\n\n| Option | Type | Description |\n|---|---|---|\n| `externalId` | `string` | Required. Must match `Product.external_id` in Cuvara. |\n| `label` | `string` | Button label. Defaults to `Try It On You`. |\n| `className` | `string` | Extra class on the root wrapper. |\n| `onConfirm` | `(response) => void` | Fired after a successful confirm. |\n| `onError` | `(error) => void` | Fired when confirm fails. The shopper still sees no button, except for a region-unsupported message in the button area. |\n| `onOpen` / `onClose` | `() => void` | Modal lifecycle. |\n\n### Theming\n\nPass `theme` to `Cuvara.mount` (or `<CuvaraTryOnButton theme={...} />`). Values are set as CSS variables on `.cuvara-root`. Omit a key to keep the default.\n\n```js\nCuvara.mount('#try-on', {\n  externalId: 'sku-1',\n  theme: {\n    accent: '#111',\n    accentHover: '#333',\n    surface: '#f7f7f7',\n    text: '#111',\n    muted: '#6b7280',\n    border: '#f3f4f6',\n    white: '#fff',\n    fontFamily: 'Georgia, serif',\n  },\n})\n```\n\nYou can also override the same variables in CSS:\n\n```css\n.cuvara-root {\n  --cuvara-accent: #111;\n  --cuvara-accent-hover: #333;\n}\n```\n\n## Builds\n\n- `dist/cuvara-retailer-sdk.js` (ESM)\n- `dist/cuvara-retailer-sdk.iife.js` (script tag / Shopify)\n- `dist/react/index.js`, `dist/vue/index.js`\n- Type declarations under `dist/`\n","readmeFilename":"README.md"}