@feltdb/feltkit 0.3.31 → 0.3.32
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/app.d.ts +40 -2
- package/dist/app.js +22 -0
- package/dist/app.js.map +1 -1
- package/dist/broker/assertion.d.ts +68 -0
- package/dist/broker/assertion.js +104 -0
- package/dist/broker/assertion.js.map +1 -0
- package/dist/broker/keys.d.ts +9 -0
- package/dist/broker/keys.js +47 -0
- package/dist/broker/keys.js.map +1 -0
- package/dist/broker/server.d.ts +54 -0
- package/dist/broker/server.js +305 -0
- package/dist/broker/server.js.map +1 -0
- package/dist/cli/broker.d.ts +11 -0
- package/dist/cli/broker.js +72 -0
- package/dist/cli/broker.js.map +1 -0
- package/dist/cli/deploy.js +6 -0
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/main.js +123 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/client/index.d.ts +8 -2
- package/dist/client/index.js +45 -1
- package/dist/client/index.js.map +1 -1
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +2 -0
- package/dist/docs.js.map +1 -1
- package/dist/extension/build.d.ts +50 -0
- package/dist/extension/build.js +205 -0
- package/dist/extension/build.js.map +1 -0
- package/dist/extension/client-shim.d.ts +7 -0
- package/dist/extension/client-shim.js +13 -0
- package/dist/extension/client-shim.js.map +1 -0
- package/dist/extension/connect-ui.d.ts +24 -0
- package/dist/extension/connect-ui.js +67 -0
- package/dist/extension/connect-ui.js.map +1 -0
- package/dist/extension/connection.d.ts +109 -0
- package/dist/extension/connection.js +190 -0
- package/dist/extension/connection.js.map +1 -0
- package/dist/extension/host-core.d.ts +36 -0
- package/dist/extension/host-core.js +50 -0
- package/dist/extension/host-core.js.map +1 -0
- package/dist/extension/host.d.ts +1 -0
- package/dist/extension/host.js +8 -0
- package/dist/extension/host.js.map +1 -0
- package/dist/extension/icons.d.ts +13 -0
- package/dist/extension/icons.js +75 -0
- package/dist/extension/icons.js.map +1 -0
- package/dist/extension/identity.d.ts +40 -0
- package/dist/extension/identity.js +110 -0
- package/dist/extension/identity.js.map +1 -0
- package/dist/extension/options.d.ts +1 -0
- package/dist/extension/options.js +57 -0
- package/dist/extension/options.js.map +1 -0
- package/dist/extension/service-worker.d.ts +1 -0
- package/dist/extension/service-worker.js +38 -0
- package/dist/extension/service-worker.js.map +1 -0
- package/dist/extension/validate.d.ts +7 -0
- package/dist/extension/validate.js +143 -0
- package/dist/extension/validate.js.map +1 -0
- package/dist/extension/zip.d.ts +7 -0
- package/dist/extension/zip.js +94 -0
- package/dist/extension/zip.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/policy.d.ts +7 -0
- package/dist/policy.js +2 -2
- package/dist/policy.js.map +1 -1
- package/dist/runtime/application-authority.d.ts +10 -10
- package/dist/runtime/application-authority.js +40 -14
- package/dist/runtime/application-authority.js.map +1 -1
- package/dist/runtime/authority-contract.d.ts +55 -0
- package/dist/runtime/authority-contract.js +60 -0
- package/dist/runtime/authority-contract.js.map +1 -0
- package/dist/runtime/context.d.ts +24 -0
- package/dist/runtime/integrations.d.ts +2 -0
- package/dist/runtime/integrations.js +9 -4
- package/dist/runtime/integrations.js.map +1 -1
- package/dist/runtime/invocations.d.ts +3 -0
- package/dist/runtime/invocations.js +1 -1
- package/dist/runtime/invocations.js.map +1 -1
- package/dist/runtime/local-authority.d.ts +43 -10
- package/dist/runtime/local-authority.js +84 -21
- package/dist/runtime/local-authority.js.map +1 -1
- package/dist/runtime/readiness.js +31 -1
- package/dist/runtime/readiness.js.map +1 -1
- package/dist/runtime/runtime.d.ts +2 -0
- package/dist/runtime/runtime.js +9 -4
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/server/oauth.d.ts +32 -2
- package/dist/server/oauth.js +130 -23
- package/dist/server/oauth.js.map +1 -1
- package/dist/server/project.d.ts +3 -0
- package/dist/server/project.js +2 -2
- package/dist/server/project.js.map +1 -1
- package/docs/CONNECTIONS.md +10 -3
- package/docs/EXTENSION-HOSTS.md +64 -5
- package/docs/GUARANTEES.md +4 -2
- package/docs/LOCAL-AUTHORITY.md +118 -0
- package/docs/POLICIES.md +1 -1
- package/docs/README.md +4 -2
- package/docs/SECURITY.md +39 -0
- package/docs/SIGN-IN-BROKER.md +77 -0
- package/package.json +6 -6
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-agent/SKILL.md +1 -1
- package/skills/feltkit-build/SKILL.md +10 -0
- package/skills/feltkit-data/SKILL.md +13 -1
- package/skills/feltkit-services/SKILL.md +14 -1
package/dist/cli/main.js
CHANGED
|
@@ -93,6 +93,8 @@ ${c.bold("Commands")}
|
|
|
93
93
|
dev Run the development environment: backend, frontend, dashboard, hot reload
|
|
94
94
|
build Bundle the backend, build the frontend, and verify the result
|
|
95
95
|
start Run the production build (environment: production)
|
|
96
|
+
target:browser-extension Build the app as a Manifest V3 browser extension (side panel, popup or tab) for Chrome
|
|
97
|
+
broker <action> Run FeltKit's GitHub / Google sign-in broker (serve), or make its signing key (keygen)
|
|
96
98
|
test Run the project's tests against an isolated test environment
|
|
97
99
|
inspect Show what the application is, where its state lives, and what it's doing
|
|
98
100
|
deploy Deploy to AppBoundry, or build a verified deployment: one container, an app container + FeltDB, Vercel, Cloudflare, Fly.io
|
|
@@ -150,6 +152,38 @@ export function helpFor(command, action) {
|
|
|
150
152
|
return own.length ? own.map((b) => b.join("\n")).join("\n") : text;
|
|
151
153
|
}
|
|
152
154
|
const COMMAND_HELP = {
|
|
155
|
+
broker: "feltkit broker keygen [--out <dir>]\n" +
|
|
156
|
+
"feltkit broker serve [--port <n>] [--host <h>]\n" +
|
|
157
|
+
" FeltKit's sign-in broker: one GitHub app and one Google client with fixed callback URLs on the broker's own\n" +
|
|
158
|
+
" address, so a FeltKit app (and its browser extension) signs people in with `auth.providers: { github: { broker:\n" +
|
|
159
|
+
" true } }` and nothing to register. It signs the person in with the provider and hands the app a signed\n" +
|
|
160
|
+
" statement of who they are (their id at the provider and their verified e-mail); the app verifies it and makes its\n" +
|
|
161
|
+
" own account and session. Keeps nothing; no provider secret reaches an app.\n" +
|
|
162
|
+
" keygen writes the Ed25519 signing key (PEM, mode 0600) and prints the key id and a secret to set. serve is\n" +
|
|
163
|
+
" configured by FELTKIT_BROKER_URL (the public address with its path, default https://getfeltkit.com/broker),\n" +
|
|
164
|
+
" FELTKIT_BROKER_SIGNING_KEY, FELTKIT_BROKER_KID, FELTKIT_BROKER_SECRET, FELTKIT_BROKER_GITHUB_CLIENT_ID/_SECRET and\n" +
|
|
165
|
+
" FELTKIT_BROKER_GOOGLE_CLIENT_ID/_SECRET (docs: sign-in-broker). It prints the callback URL to register at each\n" +
|
|
166
|
+
" provider.",
|
|
167
|
+
"target:browser-extension": "feltkit target:browser-extension [--instance <url>] [--surface sidepanel|popup|tab] [--out <dir>] [--name <n>]\n" +
|
|
168
|
+
" [--description <t>] [--version <v>] [--icon <png>] [--public-key <key>] [--no-zip] [--json]\n" +
|
|
169
|
+
"feltkit target:browser-extension --check [<dir>]\n" +
|
|
170
|
+
" The application's frontend as a Manifest V3 browser extension, from the project as it is: the same React app\n" +
|
|
171
|
+
" and the same createClient() calls; the functions, authorization and data stay on your instance. Writes an\n" +
|
|
172
|
+
" unpacked extension to dist/extension (chrome://extensions → Developer mode → Load unpacked) and a ZIP for\n" +
|
|
173
|
+
" the Chrome Web Store beside it.\n" +
|
|
174
|
+
" The extension opens in the browser's side panel (--surface sidepanel, the default), the toolbar popup, or\n" +
|
|
175
|
+
" a tab. On first run it asks for the instance's address (or --instance bakes one in: its origin becomes the\n" +
|
|
176
|
+
" one host permission, granted at install) and keeps a bearer session in chrome.storage.local, locked to the\n" +
|
|
177
|
+
" extension's own pages. It refuses an instance serving a different application. Sign in inside the app, or\n" +
|
|
178
|
+
" paste a session from `feltkit session create`. The options page changes instance or disconnects.\n" +
|
|
179
|
+
" The build refuses a result that is not a compliant Manifest V3 extension (inline or remote script, an\n" +
|
|
180
|
+
" unsafe content security policy, access to every site, a file the manifest names that is missing).\n" +
|
|
181
|
+
" The extension has a stable ID: its public key is in the manifest and in extension/identity.json (made on the\n" +
|
|
182
|
+
" first build, committed with the project). The same ID on every machine and build gives it a stable origin and\n" +
|
|
183
|
+
" the stable OAuth redirect https://<id>.chromiumapp.org/, which the app trusts for a provider sign-in started in\n" +
|
|
184
|
+
" the extension. --public-key <key|file> uses the Web Store item's own key (Package → View public key) so the\n" +
|
|
185
|
+
" unpacked and the published extension share one ID; the Web Store package itself carries no key.\n" +
|
|
186
|
+
" --check validates an existing extension directory (default dist/extension) the same way.",
|
|
153
187
|
measure: "feltkit measure [--json] [--write [<file>]] [--check [<file>]] [--compare <a.json> <b.json> …]\n" +
|
|
154
188
|
" Classifies every file in the repository (domain, experience, infrastructure, generated, configuration,\n" +
|
|
155
189
|
" tests, third-party, platform, excluded) with the evidence for it: declarations in feltkit.measure.json,\n" +
|
|
@@ -731,6 +765,95 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
|
|
|
731
765
|
line(c.dim("\nRun it with `feltkit start`, or package it with `feltkit deploy`."));
|
|
732
766
|
return 0;
|
|
733
767
|
}
|
|
768
|
+
case "target:browser-extension": {
|
|
769
|
+
const { buildBrowserExtension, directorySize, EXTENSION_SURFACES } = await import("../extension/build.js");
|
|
770
|
+
const { validateExtension } = await import("../extension/validate.js");
|
|
771
|
+
if (flags.check !== undefined) {
|
|
772
|
+
const target = resolve(projectDir, typeof flags.check === "string" ? flags.check : positional[0] ?? "dist/extension");
|
|
773
|
+
const checked = validateExtension(target);
|
|
774
|
+
if (json) {
|
|
775
|
+
line(JSON.stringify({ ok: checked.ok, dir: target, problems: checked.problems, warnings: checked.warnings }, null, 2));
|
|
776
|
+
return checked.ok ? 0 : 1;
|
|
777
|
+
}
|
|
778
|
+
for (const problem of checked.problems)
|
|
779
|
+
line(`${symbols.fail} ${problem}`);
|
|
780
|
+
for (const warning of checked.warnings)
|
|
781
|
+
line(`${c.yellow("warn")} ${warning}`);
|
|
782
|
+
line(checked.ok ? `${symbols.ok} ${relative(process.cwd(), target) || "."} is a compliant Manifest V3 extension${checked.manifest ? ` (${checked.manifest.name} ${checked.manifest.version})` : ""}` : `${symbols.fail} ${checked.problems.length} problem(s) in ${relative(process.cwd(), target) || "."}`);
|
|
783
|
+
return checked.ok ? 0 : 1;
|
|
784
|
+
}
|
|
785
|
+
if (flags.surface !== undefined && !EXTENSION_SURFACES.includes(String(flags.surface))) {
|
|
786
|
+
throw new FeltKitError("INVALID_ARGUMENT", `Unknown surface "${String(flags.surface)}".`, { hint: `--surface ${EXTENSION_SURFACES.join("|")}` });
|
|
787
|
+
}
|
|
788
|
+
const str = (key) => (typeof flags[key] === "string" ? flags[key] : undefined);
|
|
789
|
+
if (!json)
|
|
790
|
+
line(`${c.bold("feltkit target:browser-extension")} ${c.dim(SDK_VERSION)}`);
|
|
791
|
+
const built = await buildBrowserExtension({
|
|
792
|
+
projectDir,
|
|
793
|
+
...(str("out") ? { outDir: str("out") } : {}),
|
|
794
|
+
...(str("instance") ? { instance: str("instance") } : {}),
|
|
795
|
+
...(str("name") ? { name: str("name") } : {}),
|
|
796
|
+
...(str("description") ? { description: str("description") } : {}),
|
|
797
|
+
...(str("version") ? { version: str("version") } : {}),
|
|
798
|
+
...(str("icon") ? { icon: str("icon") } : {}),
|
|
799
|
+
...(str("public-key") ? { publicKey: existsSync(resolve(projectDir, str("public-key"))) ? readFileSync(resolve(projectDir, str("public-key")), "utf8") : str("public-key") } : {}),
|
|
800
|
+
...(str("surface") ? { surface: str("surface") } : {}),
|
|
801
|
+
...(flags.zip === false ? { zip: false } : {}),
|
|
802
|
+
});
|
|
803
|
+
const shown = (path) => relative(process.cwd(), path) || ".";
|
|
804
|
+
if (json) {
|
|
805
|
+
line(JSON.stringify({ ok: true, application: built.application, name: built.manifest.name, version: built.manifest.version, surface: built.surface, instance: built.instance, dir: built.dir, zip: built.zip, files: built.files, warnings: built.warnings, identity: built.identity }, null, 2));
|
|
806
|
+
return 0;
|
|
807
|
+
}
|
|
808
|
+
line(`${symbols.ok} Extension ${shown(built.dir)} ${c.dim(`(${built.manifest.name} ${built.manifest.version}, Manifest V3, ${built.surface}, ${built.files.length} files, ${(directorySize(built.dir) / 1024).toFixed(0)} KB)`)}`);
|
|
809
|
+
line(`${symbols.ok} Verified ${c.dim("manifest, every file it names, a script-src 'self' content security policy, no inline or remote script, no server-only values")}`);
|
|
810
|
+
if (built.zip)
|
|
811
|
+
line(`${symbols.ok} Web Store ${shown(built.zip)}`);
|
|
812
|
+
line(` ${c.bold("Identity")} ${built.identity.id} ${c.dim(`(${built.identity.source === "project" ? "kept in extension/identity.json" : built.identity.source === "generated" ? "new: written to extension/identity.json, commit it" : "from --public-key: written to extension/identity.json"})`)}`);
|
|
813
|
+
line(` ${c.bold("Sign-in")} ${built.identity.redirectUrl} ${c.dim("(the redirect a provider sign-in started here returns to; apps trust this ID from extension/identity.json, or list it in auth.extensions)")}`);
|
|
814
|
+
line(` ${c.bold("Instance")} ${built.instance ? `${built.instance} (the host permission, granted at install)` : "asked on first run; the browser grants access to that one address only"}`);
|
|
815
|
+
line(` ${c.bold("Application")} ${built.application}: an instance serving another application is refused`);
|
|
816
|
+
for (const warning of built.warnings)
|
|
817
|
+
line(` ${c.yellow("warn")} ${warning}`);
|
|
818
|
+
line(c.dim(`\nTry it: chrome://extensions → Developer mode → Load unpacked → ${shown(built.dir)}`));
|
|
819
|
+
return 0;
|
|
820
|
+
}
|
|
821
|
+
case "broker": {
|
|
822
|
+
const action = positional[0];
|
|
823
|
+
if (action !== "keygen" && action !== "serve")
|
|
824
|
+
throw new FeltKitError("INVALID_ARGUMENT", "Usage: feltkit broker keygen|serve", { hint: "feltkit broker --help" });
|
|
825
|
+
const { brokerConfigFromEnv, brokerKeygen } = await import("./broker.js");
|
|
826
|
+
if (action === "keygen") {
|
|
827
|
+
const made = brokerKeygen(resolve(projectDir, typeof flags.out === "string" ? flags.out : "."));
|
|
828
|
+
if (json) {
|
|
829
|
+
line(JSON.stringify({ kid: made.kid, file: made.file, publicKey: made.publicKey, secret: made.secret }, null, 2));
|
|
830
|
+
return 0;
|
|
831
|
+
}
|
|
832
|
+
line(`${symbols.ok} Signing key ${made.file} ${c.dim("(private; mode 0600: keep it out of the repository)")}`);
|
|
833
|
+
line(` ${c.bold("FELTKIT_BROKER_SIGNING_KEY")}=${made.file}`);
|
|
834
|
+
line(` ${c.bold("FELTKIT_BROKER_KID")}=${made.kid}`);
|
|
835
|
+
line(` ${c.bold("FELTKIT_BROKER_SECRET")}=${made.secret} ${c.dim("(new; this is the only time it is shown)")}`);
|
|
836
|
+
line(c.dim(`Public key (published by the broker for instances to verify with): ${JSON.stringify(made.publicKey)}`));
|
|
837
|
+
return 0;
|
|
838
|
+
}
|
|
839
|
+
const { startBroker } = await import("../broker/server.js");
|
|
840
|
+
const config = brokerConfigFromEnv();
|
|
841
|
+
const port = flags.port !== undefined ? Number(flags.port) : Number(process.env.PORT ?? 8787);
|
|
842
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535)
|
|
843
|
+
throw new FeltKitError("INVALID_ARGUMENT", "--port must be a port number.");
|
|
844
|
+
const started = await startBroker(config, { port, host: typeof flags.host === "string" ? flags.host : "0.0.0.0" });
|
|
845
|
+
line(`${symbols.ok} FeltKit sign-in broker ${config.issuer} ${c.dim(`(listening on ${started.url}; route ${new URL(config.issuer).pathname.replace(/\/$/, "") || "/"} to it)`)}`);
|
|
846
|
+
line(` ${c.bold("Providers")} ${Object.keys(config.providers).join(", ")}`);
|
|
847
|
+
for (const id of Object.keys(config.providers))
|
|
848
|
+
line(` Register at ${id === "github" ? "GitHub" : "Google"}: ${config.issuer}/v1/callback/${id}`);
|
|
849
|
+
line(` Keys ${config.issuer}/.well-known/feltkit-broker-keys.json`);
|
|
850
|
+
await new Promise((done) => {
|
|
851
|
+
process.once("SIGINT", done);
|
|
852
|
+
process.once("SIGTERM", done);
|
|
853
|
+
});
|
|
854
|
+
await started.close();
|
|
855
|
+
return 0;
|
|
856
|
+
}
|
|
734
857
|
case "start": {
|
|
735
858
|
rejectAssignments("start", positional);
|
|
736
859
|
const listen = resolvePort(flags.port);
|