@volter/world-platform 2.0.0
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/LICENSE +202 -0
- package/README.md +29 -0
- package/client/platform.css +228 -0
- package/client/platform.tsx +1049 -0
- package/client/reserved.ts +3 -0
- package/dist/client/platform.bundle.js +237 -0
- package/dist/client/platform.css +228 -0
- package/dist/client/platform.tsx +1049 -0
- package/dist/client/reserved.d.ts +1 -0
- package/dist/client/reserved.js +3 -0
- package/dist/client/reserved.ts +3 -0
- package/dist/src/audit.d.ts +24 -0
- package/dist/src/audit.js +23 -0
- package/dist/src/backup.d.ts +37 -0
- package/dist/src/backup.js +94 -0
- package/dist/src/biller.d.ts +59 -0
- package/dist/src/biller.js +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +112 -0
- package/dist/src/db/migrations/0000_init.sql +143 -0
- package/dist/src/db/migrations/meta/0000_snapshot.json +877 -0
- package/dist/src/db/migrations/meta/_journal.json +13 -0
- package/dist/src/db/migrations.d.ts +4 -0
- package/dist/src/db/migrations.js +33 -0
- package/dist/src/db/open.d.ts +11 -0
- package/dist/src/db/open.js +114 -0
- package/dist/src/db/pack-migrations.d.ts +1 -0
- package/dist/src/db/pack-migrations.js +33 -0
- package/dist/src/db/schema.d.ts +1803 -0
- package/dist/src/db/schema.js +123 -0
- package/dist/src/directory.d.ts +75 -0
- package/dist/src/directory.js +199 -0
- package/dist/src/doors.d.ts +16 -0
- package/dist/src/doors.js +123 -0
- package/dist/src/identity.d.ts +88 -0
- package/dist/src/identity.js +314 -0
- package/dist/src/labs.d.ts +14 -0
- package/dist/src/labs.js +7 -0
- package/dist/src/mail.d.ts +16 -0
- package/dist/src/mail.js +27 -0
- package/dist/src/pages.d.ts +15 -0
- package/dist/src/pages.js +73 -0
- package/dist/src/platform.d.ts +77 -0
- package/dist/src/platform.js +1845 -0
- package/dist/src/sample.d.ts +11 -0
- package/dist/src/sample.js +93 -0
- package/dist/src/store.d.ts +110 -0
- package/dist/src/store.js +142 -0
- package/dist/src/tokens.d.ts +69 -0
- package/dist/src/tokens.js +96 -0
- package/dist/src/webhooks.d.ts +60 -0
- package/dist/src/webhooks.js +92 -0
- package/package.json +78 -0
- package/src/audit.ts +26 -0
- package/src/backup.ts +73 -0
- package/src/biller.ts +45 -0
- package/src/cli.ts +99 -0
- package/src/db/migrations/0000_init.sql +143 -0
- package/src/db/migrations/meta/0000_snapshot.json +877 -0
- package/src/db/migrations/meta/_journal.json +13 -0
- package/src/db/migrations.ts +33 -0
- package/src/db/open.ts +92 -0
- package/src/db/pack-migrations.ts +19 -0
- package/src/db/schema.ts +137 -0
- package/src/directory.ts +216 -0
- package/src/doors.ts +138 -0
- package/src/identity.ts +279 -0
- package/src/labs.ts +8 -0
- package/src/mail.ts +27 -0
- package/src/pages.ts +69 -0
- package/src/platform.ts +1183 -0
- package/src/sample.ts +84 -0
- package/src/store.ts +154 -0
- package/src/tokens.ts +94 -0
- package/src/webhooks.ts +85 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type SigningKey } from '@volter/world-access';
|
|
2
|
+
import { type Mailer } from './mail.js';
|
|
3
|
+
import { type Backups } from './backup.js';
|
|
4
|
+
import type { BillerFactory } from './biller.js';
|
|
5
|
+
import { type IdentityOptions, type ProviderOptions } from './identity.js';
|
|
6
|
+
import { Store } from './store.js';
|
|
7
|
+
/** An enrolled host: where worlds are provisioned. A world-host, or the hosted World on Cloudflare
|
|
8
|
+
* (`apps/cloud`), which answers the same admin doors with the same inventory row. */
|
|
9
|
+
export type HostProvider = {
|
|
10
|
+
id: string;
|
|
11
|
+
base: string;
|
|
12
|
+
adminToken: string;
|
|
13
|
+
};
|
|
14
|
+
/** The platform's enrolled providers: the hosts it provisions onto. */
|
|
15
|
+
export type Providers = {
|
|
16
|
+
hosts: HostProvider[];
|
|
17
|
+
};
|
|
18
|
+
export type PlatformOptions = {
|
|
19
|
+
store: Store;
|
|
20
|
+
/** The header the deploy's own proxy sets to the client's address (`cf-connecting-ip` on Cloudflare, `x-forwarded-for`
|
|
21
|
+
* behind a proxy that appends to it): the rate limit keys an unauthenticated request on it. Unset, no request names
|
|
22
|
+
* its own address, and unauthenticated requests share one bucket. */
|
|
23
|
+
clientIpHeader?: string;
|
|
24
|
+
/** The state directory: the operator token (`<state>/admin`) and the providers record live here. */
|
|
25
|
+
stateDir?: string;
|
|
26
|
+
/** Called when the enrolled hosts change (enroll/unenroll) so the record persists. */
|
|
27
|
+
onProviders?: (providers: Providers) => void;
|
|
28
|
+
/** The access provider people sign in with (identity.ts): Volter Identity (its `VOLTER_*` names from the env by
|
|
29
|
+
* default) or any OpenID Connect issuer, whose directory the platform then keeps in its state. */
|
|
30
|
+
provider?: ProviderOptions;
|
|
31
|
+
/** The Volter provider's settings, for callers that name only those. */
|
|
32
|
+
identity?: IdentityOptions;
|
|
33
|
+
/** The enrolled hosts; the first is the default target for provisioning. At least one. */
|
|
34
|
+
hosts: HostProvider[];
|
|
35
|
+
/** This platform's own public origin, for the OAuth redirect URI. */
|
|
36
|
+
origin: string;
|
|
37
|
+
/** A biller to attach (biller.ts; Volter's is apps/billing's `createBiller`). Absent, nothing is limited or priced. */
|
|
38
|
+
billing?: BillerFactory;
|
|
39
|
+
/** The platform's own mail: a member added or invited, a World deleted, and the biller's notices (mail.ts; the resend twin in rehearsal). */
|
|
40
|
+
mail?: Mailer;
|
|
41
|
+
/** The product's site (the front door): its docs, and the terms and privacy a person accepts at org creation.
|
|
42
|
+
* Absent (a self-hosted platform), no terms are asked for. */
|
|
43
|
+
siteUrl?: string;
|
|
44
|
+
/** Where the Help form's mail goes (layer 6, a flag: --support-to); absent, the request is kept and logged only. */
|
|
45
|
+
supportTo?: string;
|
|
46
|
+
/** Backups of the state directory to S3 through the boundary (backup.ts); absent when no --backup-bucket is named. */
|
|
47
|
+
backups?: Backups;
|
|
48
|
+
/** Requests a person or an org may make per minute against the doors (plans.ts may raise it later). */
|
|
49
|
+
rateLimitPerMinute?: number;
|
|
50
|
+
/** The platform's own clock (layer 5): the tick's cadence in seconds (0 = never; default 3600) and the backup's time of day, UTC HH:MM (default 00:00). */
|
|
51
|
+
clock?: {
|
|
52
|
+
tickEverySeconds?: number;
|
|
53
|
+
backupAt?: string;
|
|
54
|
+
deliverEverySeconds?: number; /** how often the keys of people no longer in an org are swept from its Worlds (seconds; 0 = never; default 3600) */
|
|
55
|
+
sweepMembersEverySeconds?: number;
|
|
56
|
+
};
|
|
57
|
+
/** The key the platform signs passes with (docs/contributing/architecture.md, "The hosted product"); its public half
|
|
58
|
+
* is published at /.well-known/jwks.json for the hosts that trust this platform. Absent, no World opens by pass. */
|
|
59
|
+
signingKey?: SigningKey;
|
|
60
|
+
};
|
|
61
|
+
export declare function createPlatform(opts: PlatformOptions): {
|
|
62
|
+
fetch: (request: Request) => Promise<Response>;
|
|
63
|
+
stop: () => void;
|
|
64
|
+
};
|
|
65
|
+
/** Serve a platform on a port, under Node or Bun (world-core's serve seam). `origin` is where people reach it (behind a
|
|
66
|
+
* proxy, its public address); by default the address it listens on. */
|
|
67
|
+
export declare function servePlatform(opts: Omit<PlatformOptions, 'origin'> & {
|
|
68
|
+
port?: number;
|
|
69
|
+
host?: string;
|
|
70
|
+
origin?: string;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
url: string;
|
|
73
|
+
port: number;
|
|
74
|
+
stop: () => Promise<void>;
|
|
75
|
+
}>;
|
|
76
|
+
/** The platform's operator token: minted once, kept at `<state>/admin` (0600) — the host's pattern, never an env. */
|
|
77
|
+
export declare function operatorTokenFor(stateDir: string): string;
|