{"_id":"@affinity-health/elements","_rev":"5-3aee18d96bc3743abefb7f655c1732b5","name":"@affinity-health/elements","dist-tags":{"next":"0.2.0","latest":"1.1.1"},"versions":{"0.1.0":{"name":"@affinity-health/elements","version":"0.1.0","keywords":["affinity","healthcare","prescribing","typescript"],"author":{"name":"Affinity Health"},"license":"MIT","_id":"@affinity-health/elements@0.1.0","maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"homepage":"https://docs.joinaffinityai.com/api/platform-elements","bugs":{"url":"https://github.com/affinity-health/affinity-elements/issues"},"dist":{"shasum":"ebfedcaa43fe6b44a25f6b1c432cc0af30385b82","tarball":"https://registry.npmjs.org/@affinity-health/elements/-/elements-0.1.0.tgz","fileCount":17,"integrity":"sha512-3N624b8SwklVMbzWxG2czY0c0o8cfO16jceY9jKv2kbYDhCVvi3LgkjmGIwWzhGNPQD5AVAKjsici1IfbvpbtA==","signatures":[{"sig":"MEYCIQCYuPe37DAyOFMd4u7ahQlGiTqOBGrD1+5Q7RYMShTBAQIhAMUHFmZ36OdIDCMcaB3dJ4RhsXew1197W5oxIXL9nZCo","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44190},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./react":{"import":{"types":"./dist/react.d.mts","default":"./dist/react.mjs"},"require":{"types":"./dist/react.d.cts","default":"./dist/react.cjs"}},"./package.json":"./package.json"},"gitHead":"b5a313e9ce2cf4db4b12d301eed063f0fcb4b84b","scripts":{"test":"vp test","build":"vp pack","check":"vp check","verify":"bun run check && bun run test && bun run build && bun run package:check","package:check":"node scripts/check-package.mjs","prepublishOnly":"bun run verify"},"_npmUser":{"name":"dawsson","email":"hello@dawson.gg"},"overrides":{"vite":"npm:@voidzero-dev/vite-plus-core@0.2.5"},"repository":{"url":"git+https://github.com/affinity-health/affinity-elements.git","type":"git"},"_npmVersion":"11.17.0","description":"Secure embedded clinical components for the Affinity platform API.","directories":{},"sideEffects":false,"_nodeVersion":"26.5.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"bun@1.3.14","devDependencies":{"react":"19.1.1","vitest":"4.1.10","react-dom":"19.1.1","vite-plus":"0.2.5","typescript":"7.0.2","@types/react":"19.1.16","@types/react-dom":"19.1.9"},"peerDependencies":{"react":">=18.3 <20"},"peerDependenciesMeta":{"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/elements_0.1.0_1785348640861_0.11717404089260941","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@affinity-health/elements","version":"0.2.0","keywords":["affinity","healthcare","prescribing","typescript"],"author":{"name":"Affinity Health"},"license":"MIT","_id":"@affinity-health/elements@0.2.0","maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"homepage":"https://docs.joinaffinityai.com/api/platform-elements","bugs":{"url":"https://github.com/affinity-health/affinity-elements/issues"},"dist":{"shasum":"d4b34258f3d76957b6fb7e3c74cbc14d3950e27c","tarball":"https://registry.npmjs.org/@affinity-health/elements/-/elements-0.2.0.tgz","fileCount":21,"integrity":"sha512-4tVCb+jIiZfGE2KKRhSIYa+Lb9iWXgVaC2i6Fdw05wt0A3Xz+aUgNUg/CR0/TutzFbkICWlQJqoQ2WS8ZIAxfQ==","signatures":[{"sig":"MEUCIQCkHSK7ZZsgo5vnodtaX3jSJQekD/GMleCpyN6FBHNSfQIgWptkl9vB7uGj15V582SwIcebSPV74fJaD4fYk/OwFqc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@affinity-health%2felements@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":51516},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./react":{"import":{"types":"./dist/react.d.mts","default":"./dist/react.mjs"},"require":{"types":"./dist/react.d.cts","default":"./dist/react.cjs"}},"./package.json":"./package.json"},"gitHead":"4d911daafbfd3ac3e70605a4016fc5b921fdca4c","scripts":{"test":"vp test","build":"vp pack","check":"vp check","verify":"bun run check && bun run test && bun run build && bun run package:check","package:check":"node scripts/check-package.mjs","prepublishOnly":"bun run verify"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8eb4920d-926e-4179-b665-554a77d9b030"}},"overrides":{"vite":"npm:@voidzero-dev/vite-plus-core@0.2.5"},"repository":{"url":"git+https://github.com/affinity-health/affinity-elements.git","type":"git"},"_npmVersion":"11.16.0","description":"Secure embedded clinical components for the Affinity platform API.","directories":{},"sideEffects":false,"_nodeVersion":"24.18.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"bun@1.3.14","readmeFilename":"README.md","devDependencies":{"react":"19.1.1","vitest":"4.1.10","react-dom":"19.1.1","vite-plus":"0.2.5","typescript":"7.0.2","@types/react":"19.1.16","@types/react-dom":"19.1.9"},"peerDependencies":{"react":">=18.3 <20"},"peerDependenciesMeta":{"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/elements_0.2.0_1785514524548_0.7905445841990293","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@affinity-health/elements","version":"1.0.0","keywords":["affinity","healthcare","prescribing","typescript"],"author":{"name":"Affinity Health"},"license":"MIT","_id":"@affinity-health/elements@1.0.0","maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"homepage":"https://docs.joinaffinityai.com/api/platform-elements","bugs":{"url":"https://github.com/affinity-health/affinity-elements/issues"},"dist":{"shasum":"0b63cf6fc5f390507a1efd95ddbf563190230655","tarball":"https://registry.npmjs.org/@affinity-health/elements/-/elements-1.0.0.tgz","fileCount":21,"integrity":"sha512-9o4esgcUKir2Ln1Efm0boXDsyQ6A44TUyIWpBpfjGbQTlNlGael0rkM4DAsDzkBOBntsdmotpOa/fCsbJY1K9Q==","signatures":[{"sig":"MEUCIAbBN5FqW2sz+OyJlfGyprtN7GMbDU3HnROdfuan+wK2AiEArXzdwz9MOVyr4Ow8NtVe69Wj4YOeCp6Jfq06dS8OCz8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@affinity-health%2felements@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":51787},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./react":{"import":{"types":"./dist/react.d.mts","default":"./dist/react.mjs"},"require":{"types":"./dist/react.d.cts","default":"./dist/react.cjs"}},"./package.json":"./package.json"},"gitHead":"55e432e80772578e03415688cbb5dff247ebccfb","scripts":{"test":"vp test","build":"vp pack","check":"vp check","verify":"bun run check && bun run test && bun run build && bun run package:check","package:check":"node scripts/check-package.mjs","prepublishOnly":"bun run verify"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8eb4920d-926e-4179-b665-554a77d9b030"}},"overrides":{"vite":"npm:@voidzero-dev/vite-plus-core@0.2.5"},"repository":{"url":"git+https://github.com/affinity-health/affinity-elements.git","type":"git"},"_npmVersion":"11.16.0","description":"Secure embedded clinical components for the Affinity platform API.","directories":{},"sideEffects":false,"_nodeVersion":"24.18.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"bun@1.3.14","devDependencies":{"react":"19.1.1","vitest":"4.1.10","react-dom":"19.1.1","vite-plus":"0.2.5","typescript":"7.0.2","@types/react":"19.1.16","@types/react-dom":"19.1.9"},"peerDependencies":{"react":">=18.3 <20"},"peerDependenciesMeta":{"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/elements_1.0.0_1785515636046_0.28426694446882017","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@affinity-health/elements","version":"1.1.0","keywords":["affinity","healthcare","prescribing","typescript"],"author":{"name":"Affinity Health"},"license":"MIT","_id":"@affinity-health/elements@1.1.0","maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"homepage":"https://docs.joinaffinityai.com/api/platform-elements","bugs":{"url":"https://github.com/affinity-health/affinity-elements/issues"},"dist":{"shasum":"c726255c93e708849e0a647d4d54f417674d536d","tarball":"https://registry.npmjs.org/@affinity-health/elements/-/elements-1.1.0.tgz","fileCount":21,"integrity":"sha512-Lry6T8T8w59Z+vBNGRlPC0/9S+lrbakQsFUTpECmdwxx43Te5j5ITO3GbvYpqrky2UoxwBvLuC/U8iYCSccovA==","signatures":[{"sig":"MEUCIFS6OI4jnuuwWMgtYjk652HkCn1YiE8zMUXCG54mmnkzAiEA3c2zoE64M/T0RFz8dgVEaE1CdntxZ4188MrELhjF9AU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@affinity-health%2felements@1.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":53115},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./react":{"import":{"types":"./dist/react.d.mts","default":"./dist/react.mjs"},"require":{"types":"./dist/react.d.cts","default":"./dist/react.cjs"}},"./package.json":"./package.json"},"gitHead":"a27f1ce4916d6dd8390dea04a07a863262dcfafd","scripts":{"test":"vp test","build":"vp pack","check":"vp check","verify":"bun run check && bun run test && bun run build && bun run package:check","package:check":"node scripts/check-package.mjs","prepublishOnly":"bun run verify"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8eb4920d-926e-4179-b665-554a77d9b030"}},"overrides":{"vite":"npm:@voidzero-dev/vite-plus-core@0.2.5"},"repository":{"url":"git+https://github.com/affinity-health/affinity-elements.git","type":"git"},"_npmVersion":"11.16.0","description":"Secure embedded clinical components for the Affinity platform API.","directories":{},"sideEffects":false,"_nodeVersion":"24.18.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"bun@1.3.14","devDependencies":{"react":"19.1.1","vitest":"4.1.10","react-dom":"19.1.1","vite-plus":"0.2.5","typescript":"7.0.2","@types/react":"19.1.16","@types/react-dom":"19.1.9"},"peerDependencies":{"react":">=18.3 <20"},"peerDependenciesMeta":{"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/elements_1.1.0_1785628311518_0.26944765832405726","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@affinity-health/elements","version":"1.1.1","description":"Secure embedded clinical components for the Affinity platform API.","keywords":["affinity","healthcare","prescribing","typescript"],"homepage":"https://docs.joinaffinityai.com/api/platform-elements","bugs":{"url":"https://github.com/affinity-health/affinity-elements/issues"},"license":"MIT","author":{"name":"Affinity Health"},"repository":{"type":"git","url":"git+https://github.com/affinity-health/affinity-elements.git"},"type":"module","sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.mts","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./react":{"import":{"types":"./dist/react.d.mts","default":"./dist/react.mjs"},"require":{"types":"./dist/react.d.cts","default":"./dist/react.cjs"}},"./package.json":"./package.json"},"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"vp check","test":"vp test","verify":"bun run check && bun run test && bun run build && bun run package:check","package:check":"node scripts/check-package.mjs","prepublishOnly":"bun run verify"},"devDependencies":{"@types/react":"19.1.16","@types/react-dom":"19.1.9","react":"19.1.1","react-dom":"19.1.1","typescript":"7.0.2","vite-plus":"0.2.5","vitest":"4.1.10"},"peerDependencies":{"react":">=18.3 <20"},"peerDependenciesMeta":{"react":{"optional":true}},"overrides":{"vite":"npm:@voidzero-dev/vite-plus-core@0.2.5"},"engines":{"node":">=20"},"packageManager":"bun@1.3.14","gitHead":"2117d4c4b732a09d4ebb624045f58c5115a6530b","_id":"@affinity-health/elements@1.1.1","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-w/z5375s9LegYlglVOTa2/uQdbWZ0QObcrVrFNFFuDE6hxB9b2y9+2JxnypLuNPrtVwSUJ5xoSD6QZeursrdVQ==","shasum":"4be0bfbdcef950b5a2b660f2f72a07ae86d6f818","tarball":"https://registry.npmjs.org/@affinity-health/elements/-/elements-1.1.1.tgz","fileCount":21,"unpackedSize":54283,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@affinity-health%2felements@1.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDqXeAEFB0Mszxo7jU4V6NEV7iV0mT5Prl18F2ncnlD1gIgVQ+xsVYxO4942PJeNjDiD2OXAKmr7m3isDhKiIl4WF8="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8eb4920d-926e-4179-b665-554a77d9b030"}},"directories":{},"maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/elements_1.1.1_1785631141268_0.02845714176889169"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-29T18:10:40.690Z","modified":"2026-08-02T00:39:01.699Z","0.1.0":"2026-07-29T18:10:41.086Z","0.2.0":"2026-07-31T16:15:24.749Z","1.0.0":"2026-07-31T16:33:56.181Z","1.1.0":"2026-08-01T23:51:51.658Z","1.1.1":"2026-08-02T00:39:01.412Z"},"bugs":{"url":"https://github.com/affinity-health/affinity-elements/issues"},"author":{"name":"Affinity Health"},"license":"MIT","homepage":"https://docs.joinaffinityai.com/api/platform-elements","keywords":["affinity","healthcare","prescribing","typescript"],"repository":{"type":"git","url":"git+https://github.com/affinity-health/affinity-elements.git"},"description":"Secure embedded clinical components for the Affinity platform API.","maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"readme":"# Affinity Elements\n\nAffinity Elements renders secure Affinity clinical workflows inside a platform application.\n\nThe platform authenticates its user. The platform backend creates a short-lived component session.\nThe browser receives only the single-use component client secret.\n\n## Install\n\n```bash\nbun add @affinity-health/elements\n```\n\n## Before you start\n\nYour platform backend must:\n\n1. Authenticate the current user.\n2. Resolve the Affinity user, practice, and verified provider mapping.\n3. Call `POST /v1/component-sessions`.\n4. Return only `clientSecret` to the intended browser.\n\nNever put an Affinity API key in browser or mobile code.\n\n## JavaScript\n\n```ts\nimport { initializeAffinity } from \"@affinity-health/elements\";\n\nconst affinity = initializeAffinity({\n  fetchClientSecret: async () => {\n    const response = await fetch(\"/api/affinity/component-session\", {\n      credentials: \"include\",\n      method: \"POST\",\n    });\n\n    if (!response.ok) {\n      throw new Error(\"Could not create an Affinity component session\");\n    }\n\n    const session = await response.json();\n    return session.clientSecret;\n  },\n});\n\nconst composer = affinity.create(\"prescription-composer\");\nconst mounted = composer.mount(\"#affinity-prescription-composer\", {\n  onLoadError(error) {\n    console.error(error);\n  },\n  onReady() {\n    console.log(\"Affinity is ready\");\n  },\n  onEvent(event) {\n    if (event.type === \"order.submitted\") {\n      console.log(event.orderId, event.fulfillmentIds);\n    }\n  },\n});\n\n// Call mounted.destroy() when the owning view is removed.\n```\n\n## React\n\n```tsx\nimport { AffinityProvider, PrescriptionComposer } from \"@affinity-health/elements/react\";\n\nexport function Prescribe() {\n  return (\n    <AffinityProvider fetchClientSecret={fetchClientSecret}>\n      <PrescriptionComposer\n        onLoadError={(error) => {\n          console.error(error);\n        }}\n        onReady={() => {\n          console.log(\"Affinity is ready\");\n        }}\n        onOrderDraftCreated={({ orderId, prescriptionIds }) => {\n          console.log(orderId, prescriptionIds);\n        }}\n        onOrderSigned={({ orderId, prescriptionIds }) => {\n          console.log(orderId, prescriptionIds);\n        }}\n        onOrderSubmitted={({ orderId, fulfillmentIds }) => {\n          console.log(orderId, fulfillmentIds);\n        }}\n      />\n    </AffinityProvider>\n  );\n}\n```\n\nKeep `fetchClientSecret` stable in React. Use `useCallback` when the function depends on component\nstate.\n\n## Staging\n\nSet the staging Connect URL while you test a staging integration:\n\n```ts\nconst affinity = initializeAffinity({\n  connectUrl: \"https://connect-staging.joinaffinityai.com\",\n  fetchClientSecret,\n});\n```\n\nThe default URL is `https://connect.joinaffinityai.com`.\n\n## Appearance\n\nUse approved appearance variables:\n\n```ts\nconst affinity = initializeAffinity({\n  appearance: {\n    theme: \"light\",\n    variables: {\n      borderRadius: \"10px\",\n      colorBackground: \"#ffffff\",\n      colorBorder: \"#d8dee8\",\n      colorPrimary: \"#2563eb\",\n      colorPrimaryText: \"#ffffff\",\n      colorText: \"#172033\",\n      fontFamily: \"Inter, ui-sans-serif, system-ui, sans-serif\",\n    },\n  },\n  fetchClientSecret,\n});\n```\n\nAffinity controls the clinical layout, behavior, accessibility, and security. The package does not\naccept arbitrary CSS, selectors, scripts, or remote font URLs.\n\n## Events\n\nThe prescription composer sends patient-order events:\n\n| Event                 | Payload                      | Meaning                                                                  |\n| --------------------- | ---------------------------- | ------------------------------------------------------------------------ |\n| `order.draft_created` | `orderId`, `prescriptionIds` | Affinity created one patient order and its unsigned prescription drafts. |\n| `order.signed`        | `orderId`, `prescriptionIds` | The provider signed every prescription in the order inside Affinity.     |\n| `order.submitted`     | `orderId`, `fulfillmentIds`  | Affinity submitted one pharmacy fulfillment for each prescription.       |\n\nArrays preserve the complete order membership. Do not assume an order contains one prescription or\none fulfillment. Use browser events for interface updates. Use signed webhooks and the Order API\nfor authoritative state.\n\nDestroy the mounted component when its owning view unmounts. Create a new component session before\nthe next mount. Client secrets are single-use and cannot refresh or reconnect a previous iframe.\n\n## Security\n\n- Add the exact parent origin to the matching platform mode settings.\n- Create a new component session immediately before you mount the element.\n- Do not put a client secret in a URL, log, analytics event, or persistent storage.\n- Do not send clinical fields or keystrokes through parent-window messages.\n\nSee the [Affinity platform documentation](https://docs.joinaffinityai.com/api/platform-elements).\n","readmeFilename":"README.md"}