Initial public commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { PublicKey, Verifier } from '@keysat/licensing-client'
|
||||
|
||||
// Paste the issuer's PEM into an env var, or (in production) embed via
|
||||
// bundler (e.g. Vite `?raw` import, webpack raw-loader, etc.).
|
||||
const pem = process.env.LICENSING_PUBKEY_PEM
|
||||
if (!pem) throw new Error('set LICENSING_PUBKEY_PEM')
|
||||
const keyStr = process.argv[2]
|
||||
if (!keyStr) throw new Error('pass a license key as an argument')
|
||||
|
||||
const verifier = new Verifier(PublicKey.fromPem(pem))
|
||||
const result = verifier.verify(keyStr)
|
||||
console.log('license OK')
|
||||
console.log(' licenseId =', result.licenseId)
|
||||
console.log(' productId =', result.productId)
|
||||
console.log(' issuedAt =', result.payload.issuedAt)
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Client } from '@keysat/licensing-client'
|
||||
|
||||
const [baseUrl, slug] = process.argv.slice(2)
|
||||
if (!baseUrl || !slug) {
|
||||
throw new Error('usage: tsx online-validate.ts <base-url> <product-slug>')
|
||||
}
|
||||
|
||||
const client = new Client(baseUrl)
|
||||
const session = await client.startPurchase(slug)
|
||||
console.log('open the checkout in your browser:')
|
||||
console.log(' ' + session.checkoutUrl)
|
||||
console.log('waiting for settlement...')
|
||||
|
||||
const key = await client.waitForLicense(session.invoiceId)
|
||||
console.log('license issued:\n ' + key)
|
||||
|
||||
const v = await client.validate(key, slug)
|
||||
console.log(`server says: ok=${v.ok} reason=${v.reason ?? '(none)'}`)
|
||||
Reference in New Issue
Block a user