@kvbox/server 0.5.25 → 0.5.27
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.
- package/dist/kvbox-server.js +36 -4
- package/dist/kvbox-server.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox-server.js
CHANGED
|
@@ -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`. */
|
|
@@ -457,6 +459,19 @@ var SubdomainSchema = z3.object({
|
|
|
457
459
|
url: z3.string(),
|
|
458
460
|
routes: z3.array(z3.object({ name: z3.string(), port: BoxPortSchema, url: z3.string() }))
|
|
459
461
|
});
|
|
462
|
+
var AddDomainRequest = z3.object({ domain: z3.string(), port: BoxPortSchema.optional() });
|
|
463
|
+
var DomainSchema = z3.object({
|
|
464
|
+
owner: z3.string(),
|
|
465
|
+
box: z3.string(),
|
|
466
|
+
domain: z3.string(),
|
|
467
|
+
port: BoxPortSchema,
|
|
468
|
+
status: z3.enum(["pending", "live"]),
|
|
469
|
+
www: z3.boolean(),
|
|
470
|
+
url: z3.string(),
|
|
471
|
+
error: z3.string().nullable(),
|
|
472
|
+
records: z3.array(z3.object({ type: z3.enum(["A", "TXT", "CNAME"]), name: z3.string(), value: z3.string() })),
|
|
473
|
+
createdAt: z3.string()
|
|
474
|
+
});
|
|
460
475
|
var MachineSchema = z3.object({
|
|
461
476
|
/** Host-unique short id (the tap is `kv-<id>`). Missing only on a box made before ids that has not restarted since. */
|
|
462
477
|
id: z3.string(),
|
|
@@ -512,6 +527,8 @@ var VolumeSchema = z3.object({
|
|
|
512
527
|
ownerKind: z3.enum(["user", "org"]).optional()
|
|
513
528
|
});
|
|
514
529
|
var MAX_VOLUME_GIB = 4096;
|
|
530
|
+
var VOLUME_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
|
|
531
|
+
var VOLUME_NAME_RULE = "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit";
|
|
515
532
|
var CreateVolumeRequest = z3.object({
|
|
516
533
|
name: z3.string(),
|
|
517
534
|
sizeGib: z3.number().int().min(1).max(MAX_VOLUME_GIB),
|
|
@@ -841,10 +858,26 @@ var TopUpSchema = z3.object({
|
|
|
841
858
|
slug: z3.string(),
|
|
842
859
|
amount: z3.number(),
|
|
843
860
|
currency: z3.string(),
|
|
844
|
-
|
|
861
|
+
/** `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. */
|
|
862
|
+
source: z3.enum(["admin", "card", "trial", "transfer"]),
|
|
845
863
|
note: z3.string().nullable(),
|
|
846
864
|
at: z3.string()
|
|
847
865
|
});
|
|
866
|
+
var TOP_UP_AMOUNTS = [10, 25, 50, 100];
|
|
867
|
+
var BillingInfoSchema = z3.object({
|
|
868
|
+
card: z3.object({ brand: z3.string(), last4: z3.string() }).nullable(),
|
|
869
|
+
cardInUse: z3.boolean(),
|
|
870
|
+
balance: BalanceSchema
|
|
871
|
+
});
|
|
872
|
+
var BillingRedirectSchema = z3.object({ url: z3.string() });
|
|
873
|
+
var TopUpCheckoutRequestSchema = z3.object({
|
|
874
|
+
amount: z3.literal(TOP_UP_AMOUNTS)
|
|
875
|
+
});
|
|
876
|
+
var TransferRequestSchema = z3.object({
|
|
877
|
+
org: z3.string().min(1),
|
|
878
|
+
amount: z3.number().positive().multipleOf(0.01, "amount is in cents at most")
|
|
879
|
+
});
|
|
880
|
+
var TransferResponseSchema = z3.object({ from: BalanceSchema, to: BalanceSchema, activated: z3.boolean() });
|
|
848
881
|
var LoginRequestSchema = z3.object({
|
|
849
882
|
email: z3.string().min(1),
|
|
850
883
|
password: z3.string().min(1),
|
|
@@ -1671,7 +1704,6 @@ function hostBootTime() {
|
|
|
1671
1704
|
}
|
|
1672
1705
|
|
|
1673
1706
|
// src/core/volumes.ts
|
|
1674
|
-
var VOLUME_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
|
|
1675
1707
|
var volumeLabel = (name) => `kv:${name}`;
|
|
1676
1708
|
function toVolume(meta, attachedTo, p) {
|
|
1677
1709
|
let usedBytes2 = 0;
|
|
@@ -1752,7 +1784,7 @@ async function diskCapacity(p = paths()) {
|
|
|
1752
1784
|
}
|
|
1753
1785
|
async function createVolume(req, owner, p = paths()) {
|
|
1754
1786
|
if (!VOLUME_NAME_RE.test(req.name)) {
|
|
1755
|
-
throw new KvboxError(`invalid volume name "${req.name}":
|
|
1787
|
+
throw new KvboxError(`invalid volume name "${req.name}": ${VOLUME_NAME_RULE}`);
|
|
1756
1788
|
}
|
|
1757
1789
|
if (!Number.isInteger(req.sizeGib) || req.sizeGib < 1 || req.sizeGib > MAX_VOLUME_GIB) {
|
|
1758
1790
|
throw new KvboxError(`volume size: whole GB between 1 and ${MAX_VOLUME_GIB}`);
|
|
@@ -3577,7 +3609,7 @@ function versionOf(srcFileUrl, injected) {
|
|
|
3577
3609
|
}
|
|
3578
3610
|
|
|
3579
3611
|
// src/version.ts
|
|
3580
|
-
var VERSION = versionOf(import.meta.url, true ? "0.5.
|
|
3612
|
+
var VERSION = versionOf(import.meta.url, true ? "0.5.27" : void 0);
|
|
3581
3613
|
|
|
3582
3614
|
// src/caller.ts
|
|
3583
3615
|
import { createHash as createHash2, timingSafeEqual } from "node:crypto";
|