{"_id":"@broadwayroyalty/sdk","_rev":"2-ea3c9e646867e8d21aa42597e265657f","name":"@broadwayroyalty/sdk","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@broadwayroyalty/sdk","version":"1.0.0","keywords":["broadway","royalty","settlement","ed25519","signed-observation"],"author":{"name":"Jeffrey Ash","email":"jeffreya12345@gmail.com"},"license":"SEE LICENSE IN LICENSE.md","_id":"@broadwayroyalty/sdk@1.0.0","maintainers":[{"name":"jeffrey-ash","email":"jeffreya12345@gmail.com"}],"homepage":"https://github.com/JefffromNJ/broadway-royalty-platform#readme","bugs":{"url":"https://github.com/JefffromNJ/broadway-royalty-platform/issues"},"dist":{"shasum":"eb518fa6ce3efeb3c117dd7c8d8d2ce5ab5d5bce","tarball":"https://registry.npmjs.org/@broadwayroyalty/sdk/-/sdk-1.0.0.tgz","fileCount":23,"integrity":"sha512-gBeBOM/WGa56umiEGmXzYMW7zGuvwL5xqtHzis+TxoLHDuuXYINVWWyrsWe+GXT5gRBV2vH890sDzkdO54lrbw==","signatures":[{"sig":"MEYCIQCpDLswSj8rPjjmMDNX5RIa6wzYQnaOdV5g7+DJjKfobQIhALnjlb6xfnVN6v1fq+j2CXjIZdfpE2GQBmncxqjekoxF","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34515},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"ba956b10e9bf7f78833675747241e509dff1118a","scripts":{"build":"tsc -p tsconfig.json","clean":"rimraf dist","typecheck":"tsc -p tsconfig.json --noEmit","prepublishOnly":"pnpm run clean && pnpm run build"},"_npmUser":{"name":"jeffrey-ash","email":"jeffreya12345@gmail.com"},"repository":{"url":"git+https://github.com/JefffromNJ/broadway-royalty-platform.git","type":"git","directory":"packages/sdk"},"_npmVersion":"11.13.0","description":"Broadway Royalty Platform — official TypeScript SDK for the /v1 API","directories":{},"_nodeVersion":"24.16.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.0.1","typescript":"^5.7.2"},"_npmOperationalInternal":{"tmp":"tmp/sdk_1.0.0_1784491878669_0.20218395269143752","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@broadwayroyalty/sdk","version":"1.1.0","description":"Broadway Royalty Platform — official TypeScript SDK for the /v1 API","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.json --noEmit","clean":"rimraf dist","prepublishOnly":"pnpm run clean && pnpm run build"},"engines":{"node":">=18"},"keywords":["broadway","royalty","settlement","ed25519","signed-observation"],"author":{"name":"Jeffrey Ash","email":"jeffreya12345@gmail.com"},"license":"SEE LICENSE IN LICENSE.md","homepage":"https://github.com/JefffromNJ/broadway-royalty-platform#readme","repository":{"type":"git","url":"git+https://github.com/JefffromNJ/broadway-royalty-platform.git","directory":"packages/sdk"},"bugs":{"url":"https://github.com/JefffromNJ/broadway-royalty-platform/issues"},"publishConfig":{"access":"public"},"devDependencies":{"rimraf":"^6.0.1","typescript":"^5.7.2"},"gitHead":"7e02c25aaf4252ddc90ce706a2c337965d9b3c21","_id":"@broadwayroyalty/sdk@1.1.0","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-lfPsJMk1qnSFIRFPeQLIKSrkiRZIlpCu8ooTCLiXUwxEs3HDmBIchMc0SmTaF7gqx1B5kVOza/JyXg63XPxXIA==","shasum":"e8b0a0857ecd2c154a1e5333d7e3e1503c2027ff","tarball":"https://registry.npmjs.org/@broadwayroyalty/sdk/-/sdk-1.1.0.tgz","fileCount":23,"unpackedSize":58728,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCRCG7CrrldQm/SRx280vJ+Qs52c1TVNyYvfupsMLSCAwIhAPhsQ9sdp0P9iWqgnMeRiQ96MRLCFTObSM8mssTPig9h"}]},"_npmUser":{"name":"jeffrey-ash","email":"jeffreya12345@gmail.com"},"directories":{},"maintainers":[{"name":"jeffrey-ash","email":"jeffreya12345@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_1.1.0_1784492800736_0.9867481743655646"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-19T20:11:18.485Z","modified":"2026-07-19T20:26:41.024Z","1.0.0":"2026-07-19T20:11:18.807Z","1.1.0":"2026-07-19T20:26:40.876Z"},"bugs":{"url":"https://github.com/JefffromNJ/broadway-royalty-platform/issues"},"author":{"name":"Jeffrey Ash","email":"jeffreya12345@gmail.com"},"license":"SEE LICENSE IN LICENSE.md","homepage":"https://github.com/JefffromNJ/broadway-royalty-platform#readme","keywords":["broadway","royalty","settlement","ed25519","signed-observation"],"repository":{"type":"git","url":"git+https://github.com/JefffromNJ/broadway-royalty-platform.git","directory":"packages/sdk"},"description":"Broadway Royalty Platform — official TypeScript SDK for the /v1 API","maintainers":[{"name":"jeffrey-ash","email":"jeffreya12345@gmail.com"}],"readme":"# @broadwayroyalty/sdk\n\nOfficial TypeScript SDK for the [Broadway Royalty Platform](https://github.com/JefffromNJ/broadway-royalty-platform) /v1 API.\n\n## Install\n\n```bash\nnpm install @broadwayroyalty/sdk\n```\n\nRequires Node 18+.\n\n## Quick start\n\n```ts\nimport { BwrpClient } from '@broadwayroyalty/sdk';\n\nconst client = new BwrpClient({\n  base_url: 'https://api.broadwayroyalty.example',\n  api_key: process.env.BWRP_API_KEY!,\n});\n\n// Evaluate a settlement from a signed box-office observation\nconst settlement = await client.settlements.evaluate({\n  observation: {\n    show_id: 'the_meridian',\n    cycle_start: '2026-04-20T00:00:00Z',\n    cycle_end: '2026-04-26T23:59:59Z',\n    gross_cents: 78_000_000,\n    observation_id: 'nightly-2026-04-26',\n  },\n  key_id: process.env.BWRP_SIGNING_KEY_ID!,\n  private_key_pem: process.env.BWRP_SIGNING_PRIVATE_PEM!,\n});\n\nconsole.log(settlement.settlement_id, settlement.total_distributed_cents);\n```\n\n## Review-and-countersign (Phase 6E)\n\nWhen a submitting partner is opted into review, the response carries\n`settlement_status: \"pending_review\"` and downstream webhooks + state-machine\nevents are deferred until a countersigner runs `approve()`.\n\n```ts\n// Countersigner side\nconst { settlements } = await client.settlements.listPending();\nfor (const s of settlements) {\n  await client.settlements.approve({\n    settlement_id: s.settlement_id,\n    key_id: process.env.REVIEWER_KEY_ID!,\n    private_key_pem: process.env.REVIEWER_PRIVATE_PEM!,\n    notes: 'Verified against bank statement',\n  });\n}\n```\n\n`reject()` has the same signature but fires `settlement.rejected` so the\nsubmitter can address and re-submit. Every decision is signed with the\nreviewer's Ed25519 key; the append-only log is available via\n`client.settlements.listApprovals(id)`.\n\n## Multi-sig recoupment declaration\n\nThe state machine will not flip a show to post-recoupment unless the\nconfigured number of designated declarants have submitted signed\ndeclarations attesting recoupment has been reached.\n\n```ts\n// Each declarant (producer, lead investor, GM) runs this independently\nawait client.recoupment.declare({\n  show_id: 'the_meridian',\n  declared_target_cents: 1_200_000_000, // $12M capitalization\n  declared_cumulative_cents: 1_205_000_000, // observed to date\n  notes: 'Confirmed against Q2 audit',\n  key_id: process.env.DECLARANT_KEY_ID!,\n  private_key_pem: process.env.DECLARANT_PRIVATE_PEM!,\n});\n\nconst status = await client.recoupment.getStatus('the_meridian');\nconsole.log(status.threshold_met, status.approvals_count, status.threshold_count);\n```\n\n## Webhook receiver\n\n```ts\nimport { verifyWebhookSignature } from '@broadwayroyalty/sdk';\n\napp.post('/bwrp-webhook', (req, res) => {\n  const signature = req.header('x-bwrp-signature')!;\n  const raw = req.rawBody; // must be the untouched request body bytes\n  const ok = verifyWebhookSignature({\n    raw_body: raw,\n    header_signature: signature,\n    signing_secret_b64: process.env.BWRP_WEBHOOK_SECRET_B64!,\n  });\n  if (!ok) return res.status(401).send('bad signature');\n  const event = JSON.parse(raw);\n  // handle event.event_type ...\n  res.status(200).send('ok');\n});\n```\n\n## Resources\n\n**Settlements**\n- `client.settlements.evaluate(input)` — sign + submit a box-office observation\n- `client.settlements.get(id)`\n- `client.settlements.listPending()` — countersigner's queue\n- `client.settlements.approve({ settlement_id, key_id, private_key_pem, notes? })`\n- `client.settlements.reject({ settlement_id, key_id, private_key_pem, notes? })`\n- `client.settlements.listApprovals(settlement_id)` — append-only decision log\n\n**Recoupment**\n- `client.recoupment.declare({ show_id, declared_target_cents, declared_cumulative_cents, ... })`\n- `client.recoupment.listDeclarations(show_id)`\n- `client.recoupment.listDeclarants(show_id)`\n- `client.recoupment.getStatus(show_id, { threshold_count? })`\n\n**Rules**\n- `client.rules.draft({ rule, effective_at })`\n- `client.rules.listVersions(show_id)`\n\n**Webhooks**\n- `client.webhooks.subscribe({ target_url, events })`\n- `client.webhooks.list()` / `client.webhooks.unsubscribe(id)`\n\n**Custody**\n- `client.custody.verify(chain_id)`\n- `client.custody.replayPackage(chain_id)`\n\n**Meta**\n- `client.health()` / `client.openapi()`\n\n## Signing helpers\n\nStandalone helpers exported for callers who want to sign without going\nthrough the client:\n\n- `signObservation({ observation, key_id, private_key_pem })`\n- `signApprovalDecision({ decision, key_id, private_key_pem })`\n- `signRecoupmentDeclaration({ declaration, key_id, private_key_pem })`\n- `canonicalize(value)` — RFC 8785 JCS canonical JSON\n\n## Errors\n\nAny non-2xx response is thrown as a `BwrpApiError` carrying `status`, `code`, and the parsed response `body`.\n\n```ts\ntry {\n  await client.settlements.evaluate(...);\n} catch (err) {\n  const e = err as import('@broadwayroyalty/sdk').BwrpApiError;\n  console.error(e.status, e.code, e.message);\n}\n```\n","readmeFilename":"README.md"}