@kvbox/server 0.5.25 → 0.5.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,8 @@ function paths(home = kvboxHome()) {
37
37
  serverLog: join(home, "server.log"),
38
38
  /** The CLI's login to the control plane (`kvbox login`): url, bearer token, user. Mode 600. */
39
39
  cli: join(home, "cli.json"),
40
+ /** The CLI's last look at npm for a newer @kvbox/cli: `{checkedAt, latest}`, at most once a day (cli update.ts). */
41
+ updateCheck: join(home, "update-check.json"),
40
42
  ssh: join(home, "ssh"),
41
43
  sshKey: join(home, "ssh", "id_ed25519"),
42
44
  /** The device key signed by the control plane's CA (#51); ssh loads it by itself next to `-i id_ed25519`. */
@@ -512,6 +514,8 @@ var VolumeSchema = z3.object({
512
514
  ownerKind: z3.enum(["user", "org"]).optional()
513
515
  });
514
516
  var MAX_VOLUME_GIB = 4096;
517
+ var VOLUME_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
518
+ var VOLUME_NAME_RULE = "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit";
515
519
  var CreateVolumeRequest = z3.object({
516
520
  name: z3.string(),
517
521
  sizeGib: z3.number().int().min(1).max(MAX_VOLUME_GIB),
@@ -841,10 +845,26 @@ var TopUpSchema = z3.object({
841
845
  slug: z3.string(),
842
846
  amount: z3.number(),
843
847
  currency: z3.string(),
844
- source: z3.enum(["admin", "card", "trial"]),
848
+ /** `transfer` (#93): an owner moving credit to an org they own, a negative row on their slug and a positive one on the org's. */
849
+ source: z3.enum(["admin", "card", "trial", "transfer"]),
845
850
  note: z3.string().nullable(),
846
851
  at: z3.string()
847
852
  });
853
+ var TOP_UP_AMOUNTS = [10, 25, 50, 100];
854
+ var BillingInfoSchema = z3.object({
855
+ card: z3.object({ brand: z3.string(), last4: z3.string() }).nullable(),
856
+ cardInUse: z3.boolean(),
857
+ balance: BalanceSchema
858
+ });
859
+ var BillingRedirectSchema = z3.object({ url: z3.string() });
860
+ var TopUpCheckoutRequestSchema = z3.object({
861
+ amount: z3.literal(TOP_UP_AMOUNTS)
862
+ });
863
+ var TransferRequestSchema = z3.object({
864
+ org: z3.string().min(1),
865
+ amount: z3.number().positive().multipleOf(0.01, "amount is in cents at most")
866
+ });
867
+ var TransferResponseSchema = z3.object({ from: BalanceSchema, to: BalanceSchema, activated: z3.boolean() });
848
868
  var LoginRequestSchema = z3.object({
849
869
  email: z3.string().min(1),
850
870
  password: z3.string().min(1),
@@ -1671,7 +1691,6 @@ function hostBootTime() {
1671
1691
  }
1672
1692
 
1673
1693
  // src/core/volumes.ts
1674
- var VOLUME_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
1675
1694
  var volumeLabel = (name) => `kv:${name}`;
1676
1695
  function toVolume(meta, attachedTo, p) {
1677
1696
  let usedBytes2 = 0;
@@ -1752,7 +1771,7 @@ async function diskCapacity(p = paths()) {
1752
1771
  }
1753
1772
  async function createVolume(req, owner, p = paths()) {
1754
1773
  if (!VOLUME_NAME_RE.test(req.name)) {
1755
- throw new KvboxError(`invalid volume name "${req.name}": 1-12 chars, lowercase letters, digits and '-', starting with a letter or digit`);
1774
+ throw new KvboxError(`invalid volume name "${req.name}": ${VOLUME_NAME_RULE}`);
1756
1775
  }
1757
1776
  if (!Number.isInteger(req.sizeGib) || req.sizeGib < 1 || req.sizeGib > MAX_VOLUME_GIB) {
1758
1777
  throw new KvboxError(`volume size: whole GB between 1 and ${MAX_VOLUME_GIB}`);
@@ -3577,7 +3596,7 @@ function versionOf(srcFileUrl, injected) {
3577
3596
  }
3578
3597
 
3579
3598
  // src/version.ts
3580
- var VERSION = versionOf(import.meta.url, true ? "0.5.25" : void 0);
3599
+ var VERSION = versionOf(import.meta.url, true ? "0.5.26" : void 0);
3581
3600
 
3582
3601
  // src/caller.ts
3583
3602
  import { createHash as createHash2, timingSafeEqual } from "node:crypto";