c3a57a043e
Two additions, both responding to a real-world ask from the Recap
team building an in-app tier picker against the same Keysat
instance.
1. StartPurchaseOptions gains `policySlug?: string`. The daemon's
/v1/purchase has accepted policy_slug since v0.1.0:27 (tiered
pricing); the SDK was the only thing missing the field. With
it set, the licensing service prices the invoice at the
chosen policy's price_sats_override and remembers the policy
on the invoice so the issued license carries that policy's
entitlements / duration / max_machines / trial flag.
2. New `Client.listPublicPolicies(productSlug)` returns the
buyer-visible tier list for a product (slug, name, price,
entitlements, recurring + trial flags, "Most popular" flag).
Same data the /buy/<slug> page renders server-side. Public
endpoint — no auth. Lets in-app tier pickers render
dynamically and stay in sync with admin-side tier setup.
Usage:
```ts
const tiers = await client.listPublicPolicies('recap')
// render tiers.policies in your UI; user clicks "Pro"
const session = await client.startPurchase('recap', {
policySlug: 'pro',
buyerEmail: 'buyer@example.com',
redirectUrl: 'https://recap.app/thank-you',
})
window.location.href = session.checkoutUrl
```
15/15 existing crosscheck tests still pass — wire-format coverage
is unchanged. Bumps to 0.2.0 on minor since the API is purely
additive.
43 lines
1.1 KiB
JSON
43 lines
1.1 KiB
JSON
{
|
|
"name": "@keysat/licensing-client",
|
|
"version": "0.2.0",
|
|
"description": "Client library for Keysat. Verifies signed license keys offline and wraps the HTTP API for purchase and revocation checks.",
|
|
"type": "module",
|
|
"main": "./dist/index.cjs",
|
|
"module": "./dist/index.js",
|
|
"types": "./dist/index.d.ts",
|
|
"exports": {
|
|
".": {
|
|
"types": "./dist/index.d.ts",
|
|
"import": "./dist/index.js",
|
|
"require": "./dist/index.cjs"
|
|
}
|
|
},
|
|
"files": ["dist", "README.md", "LICENSE"],
|
|
"scripts": {
|
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
"test": "vitest run",
|
|
"prepare": "npm run build",
|
|
"prepublishOnly": "npm run build && npm test"
|
|
},
|
|
"keywords": [
|
|
"bitcoin",
|
|
"licensing",
|
|
"btcpay",
|
|
"start9",
|
|
"ed25519"
|
|
],
|
|
"repository": "https://github.com/keysat-xyz/keysat-client-ts",
|
|
"license": "MIT",
|
|
"engines": { "node": ">=18" },
|
|
"dependencies": {
|
|
"@noble/ed25519": "^2.0.0",
|
|
"@noble/hashes": "^1.3.3"
|
|
},
|
|
"devDependencies": {
|
|
"typescript": "^5.3.0",
|
|
"tsup": "^8.0.0",
|
|
"vitest": "^1.0.0"
|
|
}
|
|
}
|