v0.1.0:24 — Keysat licensing service end-to-end
Daemon, StartOS wrapper, admin SPA, public buy/thank-you pages, discount codes, free-license redemption, Apply-discount UX, self-licensing, and v0.1.0 release notes.
This commit is contained in:
@@ -1,28 +1,29 @@
|
||||
// Action: manually issue a license for a product (comp, press, dev).
|
||||
|
||||
import { sdk } from '../sdk'
|
||||
import { store } from '../fileModels/store'
|
||||
import { adminCall, LICENSING_URL } from '../utils'
|
||||
|
||||
const input = sdk.InputSpec.of({
|
||||
product_slug: {
|
||||
type: 'text',
|
||||
const { InputSpec, Value } = sdk
|
||||
|
||||
const input = InputSpec.of({
|
||||
product_slug: Value.text({
|
||||
name: 'Product slug',
|
||||
description: 'Which product to issue a license for.',
|
||||
required: true,
|
||||
default: null,
|
||||
},
|
||||
note: {
|
||||
type: 'text',
|
||||
}),
|
||||
note: Value.text({
|
||||
name: 'Note (optional)',
|
||||
description: 'Audit trail — e.g., "comp for @alice", "press key".',
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
}),
|
||||
})
|
||||
|
||||
export const issueLicense = sdk.Action.withInput(
|
||||
'issueLicense',
|
||||
async ({ effects }) => ({
|
||||
'issue-license',
|
||||
async () => ({
|
||||
name: 'Issue license manually',
|
||||
description: 'Generate a license key outside the purchase flow. Useful for comps and press.',
|
||||
warning: null,
|
||||
@@ -31,9 +32,11 @@ export const issueLicense = sdk.Action.withInput(
|
||||
visibility: 'enabled',
|
||||
}),
|
||||
input,
|
||||
async ({ effects, input: formInput }) => {
|
||||
const store = await sdk.store.getOwn(effects, sdk.StorePath).const()
|
||||
const resp = await adminCall(LICENSING_URL, store.admin_api_key, '/v1/admin/licenses', {
|
||||
async () => null,
|
||||
async ({ effects: _effects, input: formInput }) => {
|
||||
const storeData = await store.read().once()
|
||||
if (!storeData) throw new Error('Store not initialized — restart the service.')
|
||||
const resp = await adminCall(LICENSING_URL, storeData.admin_api_key, '/v1/admin/licenses', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
product_slug: formInput.product_slug,
|
||||
@@ -43,11 +46,18 @@ export const issueLicense = sdk.Action.withInput(
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Issue failed: HTTP ${resp.status} — ${await resp.text()}`)
|
||||
}
|
||||
const body = await resp.json()
|
||||
const body = (await resp.json()) as { license_id: string; license_key: string }
|
||||
return {
|
||||
message:
|
||||
`License issued.\nID: ${body.license_id}\n\n` +
|
||||
`Key (give this to the recipient):\n${body.license_key}`,
|
||||
version: '1',
|
||||
title: 'License issued',
|
||||
message: `License ID: ${body.license_id}\n\nGive this key to the recipient.`,
|
||||
result: {
|
||||
type: 'single',
|
||||
value: body.license_key,
|
||||
copyable: true,
|
||||
qr: true,
|
||||
masked: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user