@feltdb/feltkit 0.3.29 → 0.3.30
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 +74 -2
- package/dist/app.js +95 -1
- package/dist/app.js.map +1 -1
- package/dist/appboundry/build.js.map +1 -1
- package/dist/appboundry/guest-tenancy.d.ts +2 -2
- package/dist/appboundry/guest-tenancy.js.map +1 -1
- package/dist/appboundry/guest.js +4 -1
- package/dist/appboundry/guest.js.map +1 -1
- package/dist/appboundry/host.js +3 -0
- package/dist/appboundry/host.js.map +1 -1
- package/dist/authorize.d.ts +23 -1
- package/dist/authorize.js +37 -0
- package/dist/authorize.js.map +1 -1
- package/dist/cli/deploy-appboundry.d.ts +1 -1
- package/dist/cli/deploy-appboundry.js.map +1 -1
- package/dist/cli/deploy.js.map +1 -1
- package/dist/cli/main.js +27 -1
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/dashboard/assets/index-9rMS3yBm.js +15 -0
- package/dist/dashboard/assets/index-DkiYTUMR.css +1 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/docs.d.ts +1 -1
- package/dist/docs.js +3 -0
- package/dist/docs.js.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/event-stage.js.map +1 -1
- package/dist/execution.d.ts +186 -0
- package/dist/execution.js +105 -0
- package/dist/execution.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/measure/index.js.map +1 -1
- package/dist/platform/approvals.js.map +1 -1
- package/dist/platform/artifacts.js.map +1 -1
- package/dist/platform/changes.d.ts +54 -54
- package/dist/platform/changes.js.map +1 -1
- package/dist/platform/deployments.d.ts +32 -32
- package/dist/platform/exec.js.map +1 -1
- package/dist/platform/platform.js.map +1 -1
- package/dist/platform/releases.js.map +1 -1
- package/dist/platform/server.js.map +1 -1
- package/dist/platform/workspaces.js.map +1 -1
- package/dist/react/auth.d.ts +10 -10
- package/dist/react/auth.js +1 -1
- package/dist/react/auth.js.map +1 -1
- package/dist/react/context.d.ts +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/runtime/accounts.js.map +1 -1
- package/dist/runtime/activity.d.ts +1 -1
- package/dist/runtime/activity.js.map +1 -1
- package/dist/runtime/agent.d.ts +3 -3
- package/dist/runtime/agent.js +9 -3
- package/dist/runtime/agent.js.map +1 -1
- package/dist/runtime/application-authority.d.ts +13 -2
- package/dist/runtime/application-authority.js +18 -6
- package/dist/runtime/application-authority.js.map +1 -1
- package/dist/runtime/audit.js.map +1 -1
- package/dist/runtime/authboundry.d.ts +17 -0
- package/dist/runtime/authboundry.js +8 -1
- package/dist/runtime/authboundry.js.map +1 -1
- package/dist/runtime/authority.d.ts +10 -0
- package/dist/runtime/authority.js +17 -0
- package/dist/runtime/authority.js.map +1 -1
- package/dist/runtime/backup-environment.js.map +1 -1
- package/dist/runtime/backup.js.map +1 -1
- package/dist/runtime/changes.js.map +1 -1
- package/dist/runtime/claims.js.map +1 -1
- package/dist/runtime/collections.js.map +1 -1
- package/dist/runtime/content.d.ts +27 -2
- package/dist/runtime/content.js +55 -5
- package/dist/runtime/content.js.map +1 -1
- package/dist/runtime/context.d.ts +153 -0
- package/dist/runtime/contract.js +5 -1
- package/dist/runtime/contract.js.map +1 -1
- package/dist/runtime/credentials.d.ts +31 -2
- package/dist/runtime/credentials.js +55 -3
- package/dist/runtime/credentials.js.map +1 -1
- package/dist/runtime/crypto-token.js.map +1 -1
- package/dist/runtime/data.js.map +1 -1
- package/dist/runtime/decisions.js.map +1 -1
- package/dist/runtime/deployment.js.map +1 -1
- package/dist/runtime/execution-host.d.ts +54 -0
- package/dist/runtime/execution-host.js +54 -0
- package/dist/runtime/execution-host.js.map +1 -0
- package/dist/runtime/generation.js.map +1 -1
- package/dist/runtime/instance.js.map +1 -1
- package/dist/runtime/integrations.d.ts +8 -6
- package/dist/runtime/integrations.js +48 -5
- package/dist/runtime/integrations.js.map +1 -1
- package/dist/runtime/invocations.d.ts +313 -0
- package/dist/runtime/invocations.js +493 -0
- package/dist/runtime/invocations.js.map +1 -0
- package/dist/runtime/loader.js.map +1 -1
- package/dist/runtime/local-authority.d.ts +50 -0
- package/dist/runtime/local-authority.js +214 -0
- package/dist/runtime/local-authority.js.map +1 -0
- package/dist/runtime/oauth-credentials.d.ts +40 -3
- package/dist/runtime/oauth-credentials.js +133 -25
- package/dist/runtime/oauth-credentials.js.map +1 -1
- package/dist/runtime/outbox.js +3 -0
- package/dist/runtime/outbox.js.map +1 -1
- package/dist/runtime/projects.d.ts +1 -1
- package/dist/runtime/readiness.js +11 -0
- package/dist/runtime/readiness.js.map +1 -1
- package/dist/runtime/runtime.d.ts +48 -5
- package/dist/runtime/runtime.js +139 -17
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/services.d.ts +37 -0
- package/dist/runtime/services.js +191 -3
- package/dist/runtime/services.js.map +1 -1
- package/dist/runtime/sessions.js.map +1 -1
- package/dist/runtime/state-contract.js.map +1 -1
- package/dist/runtime/storage-check.js.map +1 -1
- package/dist/runtime/targets.d.ts +1 -1
- package/dist/runtime/tenancy.js.map +1 -1
- package/dist/runtime/transactions.d.ts +15 -0
- package/dist/runtime/transactions.js +5 -0
- package/dist/runtime/transactions.js.map +1 -1
- package/dist/schema.js.map +1 -1
- package/dist/server/admin.d.ts +51 -51
- package/dist/server/admin.js +11 -0
- package/dist/server/admin.js.map +1 -1
- package/dist/server/components.js.map +1 -1
- package/dist/server/index.js +39 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/management.js.map +1 -1
- package/dist/server/mcp.d.ts +59 -37
- package/dist/server/mcp.js +24 -1
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/operators.js.map +1 -1
- package/dist/server/ports.d.ts +7 -0
- package/dist/server/ports.js +17 -0
- package/dist/server/ports.js.map +1 -1
- package/dist/server/production.js.map +1 -1
- package/dist/server/project.js.map +1 -1
- package/dist/server/session-http.js.map +1 -1
- package/dist/server/tenancy.js.map +1 -1
- package/dist/surfaces.d.ts +153 -0
- package/dist/surfaces.js +228 -0
- package/dist/surfaces.js.map +1 -0
- package/dist/testing/index.js.map +1 -1
- package/docs/CONNECTIONS.md +151 -0
- package/docs/EXECUTION.md +271 -0
- package/docs/GUARANTEES.md +54 -2
- package/docs/INVOCATIONS.md +170 -0
- package/docs/README.md +5 -2
- package/package.json +19 -15
- package/skills/.claude-plugin/marketplace.json +1 -1
- package/skills/.claude-plugin/plugin.json +1 -1
- package/skills/feltkit-services/SKILL.md +1 -1
- package/dist/dashboard/assets/index-BehzsQOa.css +0 -1
- package/dist/dashboard/assets/index-UuZ63NA6.js +0 -15
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Principal } from "./authority.js";
|
|
2
|
+
import type { FeltKitRuntime } from "./runtime.js";
|
|
3
|
+
import { type AuthorityConfig } from "./application-authority.js";
|
|
4
|
+
export declare const LOCAL_ADMIN_REF = "credential-ref:authboundry-local-admin";
|
|
5
|
+
export interface Grant {
|
|
6
|
+
id: string;
|
|
7
|
+
capabilities: string[];
|
|
8
|
+
/** Epoch ms, or null (until revoked). */
|
|
9
|
+
expiresAt: number | null;
|
|
10
|
+
status: string;
|
|
11
|
+
}
|
|
12
|
+
export interface LocalAuthorityStatus {
|
|
13
|
+
/** deferred: the test environment starts it on first use (a decision or a grant), not with the application. */
|
|
14
|
+
state: "off" | "external" | "deferred" | "running" | "failed";
|
|
15
|
+
url: string | null;
|
|
16
|
+
dataDir: string | null;
|
|
17
|
+
error: string | null;
|
|
18
|
+
}
|
|
19
|
+
/** The AuthBoundry principal of an application principal (a person): `principal(id)` from the config, else `user:<id>`. */
|
|
20
|
+
export declare function authorityPrincipalOf(config: AuthorityConfig, id: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Every capability the application asks AuthBoundry about: its own (`authority.capabilities`) and one per
|
|
23
|
+
* operation of each integration people connect themselves (the operation's `authority`, default
|
|
24
|
+
* `<integration>.<operation>`), so a person can grant or withhold each one.
|
|
25
|
+
*/
|
|
26
|
+
export declare function applicationCapabilities(runtime: FeltKitRuntime): string[];
|
|
27
|
+
export declare class LocalAuthorityHost {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(runtime: FeltKitRuntime);
|
|
30
|
+
get status(): LocalAuthorityStatus;
|
|
31
|
+
/** The private AuthBoundry's address, once it runs (started on first use where deferred). */
|
|
32
|
+
url(): Promise<string | null>;
|
|
33
|
+
/**
|
|
34
|
+
* With the application: start it when this application asks for a local authority and none is
|
|
35
|
+
* configured elsewhere. The test environment defers it to first use: most tests never ask.
|
|
36
|
+
*/
|
|
37
|
+
start(): Promise<void>;
|
|
38
|
+
/** Running (or failed, once): what a decision or a grant waits for. */
|
|
39
|
+
ensure(): Promise<void>;
|
|
40
|
+
close(): Promise<void>;
|
|
41
|
+
/** A person's grants (`ctx.authority.grants`), for the caller only. */
|
|
42
|
+
grantsFor(principal: Principal | null, requestId: string): {
|
|
43
|
+
list: () => Promise<Grant[]>;
|
|
44
|
+
grant: (input: {
|
|
45
|
+
capabilities: string[];
|
|
46
|
+
expiresAt?: number;
|
|
47
|
+
}) => Promise<Grant>;
|
|
48
|
+
revoke: (id: string) => Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A private AuthBoundry for this application (`authority: { local: true }`), so the people who use it
|
|
3
|
+
* never set AuthBoundry up. When no AuthBoundry address is configured, FeltKit starts one through
|
|
4
|
+
* `@authboundry/local` (installed with the application; loaded only in this mode): on loopback, with its
|
|
5
|
+
* state beside the application's, its administrator's secret generated once and kept in FeltKit's
|
|
6
|
+
* custody, and the application check credential kept there too. Decisions then go to it exactly as they
|
|
7
|
+
* would to a hosted AuthBoundry (runtime/authboundry.ts): same contract, same fail-closed rules.
|
|
8
|
+
*
|
|
9
|
+
* It also gives application code a person's grants (`ctx.authority.grants`): what that person allows the
|
|
10
|
+
* application's executor to do for them. Only for the person asking: the delegator is always the
|
|
11
|
+
* caller, never an argument.
|
|
12
|
+
*/
|
|
13
|
+
import { randomBytes } from "node:crypto";
|
|
14
|
+
import { FeltKitError } from "../errors.js";
|
|
15
|
+
import { authorityApplication, authorityUrl, LOCAL_AGENT_REF } from "./application-authority.js";
|
|
16
|
+
import { OAuthCredentials } from "./oauth-credentials.js";
|
|
17
|
+
export const LOCAL_ADMIN_REF = "credential-ref:authboundry-local-admin";
|
|
18
|
+
const secretId = (ref) => ref.replace(/^credential-ref:/, "");
|
|
19
|
+
/** The AuthBoundry principal of an application principal (a person): `principal(id)` from the config, else `user:<id>`. */
|
|
20
|
+
export function authorityPrincipalOf(config, id) {
|
|
21
|
+
return config.principal ? config.principal(id) : `user:${id}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Every capability the application asks AuthBoundry about: its own (`authority.capabilities`) and one per
|
|
25
|
+
* operation of each integration people connect themselves (the operation's `authority`, default
|
|
26
|
+
* `<integration>.<operation>`), so a person can grant or withhold each one.
|
|
27
|
+
*/
|
|
28
|
+
export function applicationCapabilities(runtime) {
|
|
29
|
+
const out = new Set(runtime.app.options.authority?.capabilities ?? []);
|
|
30
|
+
for (const i of runtime.integrations.definitions()) {
|
|
31
|
+
if (!OAuthCredentials.personal(i))
|
|
32
|
+
continue;
|
|
33
|
+
for (const [name, op] of Object.entries(i.operations))
|
|
34
|
+
out.add(op.authority ?? `${i.name}.${name}`);
|
|
35
|
+
}
|
|
36
|
+
return [...out];
|
|
37
|
+
}
|
|
38
|
+
export class LocalAuthorityHost {
|
|
39
|
+
#runtime;
|
|
40
|
+
#authority = null;
|
|
41
|
+
#status = { state: "off", url: null, dataDir: null, error: null };
|
|
42
|
+
#starting = null;
|
|
43
|
+
constructor(runtime) {
|
|
44
|
+
this.#runtime = runtime;
|
|
45
|
+
}
|
|
46
|
+
get status() {
|
|
47
|
+
return this.#status;
|
|
48
|
+
}
|
|
49
|
+
/** The private AuthBoundry's address, once it runs (started on first use where deferred). */
|
|
50
|
+
async url() {
|
|
51
|
+
await this.ensure();
|
|
52
|
+
return this.#authority?.url ?? null;
|
|
53
|
+
}
|
|
54
|
+
#dataDir() {
|
|
55
|
+
const config = this.#runtime.app.options.authority;
|
|
56
|
+
const local = typeof config.local === "object" ? config.local : {};
|
|
57
|
+
if (local.dataDir)
|
|
58
|
+
return local.dataDir;
|
|
59
|
+
if (process.env.FELTKIT_AUTHORITY_DIR)
|
|
60
|
+
return process.env.FELTKIT_AUTHORITY_DIR;
|
|
61
|
+
const env = this.#runtime.environment;
|
|
62
|
+
// Beside the state: the test environment's temporary state, or a volume given as FELTKIT_STATE_DIR.
|
|
63
|
+
if (env.storage.kind === "local" && (env.name === "test" || (!env.development && process.env.FELTKIT_STATE_DIR)))
|
|
64
|
+
return `${env.storage.path}.authority`;
|
|
65
|
+
return `${env.runtimeDir}/authority`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* With the application: start it when this application asks for a local authority and none is
|
|
69
|
+
* configured elsewhere. The test environment defers it to first use: most tests never ask.
|
|
70
|
+
*/
|
|
71
|
+
async start() {
|
|
72
|
+
const config = this.#runtime.app.options.authority;
|
|
73
|
+
if (!config?.local)
|
|
74
|
+
return;
|
|
75
|
+
const external = config.url ? authorityUrl(config, this.#runtime.environment.production) : null;
|
|
76
|
+
if (external) {
|
|
77
|
+
this.#status = { state: "external", url: external, dataDir: null, error: null };
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (this.#runtime.environment.name === "test") {
|
|
81
|
+
this.#status = { state: "deferred", url: null, dataDir: null, error: null };
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
await this.ensure();
|
|
85
|
+
}
|
|
86
|
+
/** Running (or failed, once): what a decision or a grant waits for. */
|
|
87
|
+
async ensure() {
|
|
88
|
+
const config = this.#runtime.app.options.authority;
|
|
89
|
+
if (!config?.local || this.#status.state === "external")
|
|
90
|
+
return;
|
|
91
|
+
await (this.#starting ??= this.#run());
|
|
92
|
+
}
|
|
93
|
+
async #run() {
|
|
94
|
+
const config = this.#runtime.app.options.authority;
|
|
95
|
+
const dataDir = this.#dataDir();
|
|
96
|
+
try {
|
|
97
|
+
const capabilities = applicationCapabilities(this.#runtime);
|
|
98
|
+
if (!capabilities.length)
|
|
99
|
+
throw new FeltKitError("CONFIGURATION", "authority.local needs authority.capabilities: every capability the application asks AuthBoundry about.");
|
|
100
|
+
const custody = this.#runtime.credentials;
|
|
101
|
+
if (!custody.writable)
|
|
102
|
+
throw new FeltKitError("CONFIGURATION", "A local authority keeps its secrets in FeltKit's credential vault, which this environment can't write.", { hint: "Opt in to the vault: FELTKIT_CREDENTIAL_VAULT=1 (or =database) with FELTKIT_CREDENTIAL_VAULT_KEY." });
|
|
103
|
+
const read = (ref) => custody.withSecret({ reference: { secretId: secretId(ref) } }, (s) => s.value).catch(() => null);
|
|
104
|
+
let adminSecret = await read(LOCAL_ADMIN_REF);
|
|
105
|
+
if (!adminSecret) {
|
|
106
|
+
adminSecret = randomBytes(32).toString("base64url");
|
|
107
|
+
await custody.store({ reference: { secretId: secretId(LOCAL_ADMIN_REF), tenantId: this.#runtime.services.scope.tenantId, kind: "authority-admin" }, value: adminSecret });
|
|
108
|
+
}
|
|
109
|
+
const checkCredential = await read(config.checkCredential);
|
|
110
|
+
// The executor's agent credential: the one this application kept, if it still authenticates.
|
|
111
|
+
const agentRef = config.executor.credential ?? LOCAL_AGENT_REF;
|
|
112
|
+
const agentCredential = await read(agentRef);
|
|
113
|
+
const keepAgent = (value) => custody.store({ reference: { secretId: secretId(agentRef), tenantId: this.#runtime.services.scope.tenantId, kind: "authority-agent" }, value });
|
|
114
|
+
let mod;
|
|
115
|
+
try {
|
|
116
|
+
const name = "@authboundry/local";
|
|
117
|
+
mod = (await import(name));
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
throw new FeltKitError("CONFIGURATION", "authority.local needs @authboundry/local: npm install @authboundry/local.");
|
|
121
|
+
}
|
|
122
|
+
const authority = await mod.startLocalAuthority({
|
|
123
|
+
dataDir,
|
|
124
|
+
application: { id: authorityApplication(config, this.#runtime.environment.production, this.#runtime.app.name), name: this.#runtime.app.options.description ?? this.#runtime.app.name, capabilities },
|
|
125
|
+
executor: { id: config.executor.principal, name: this.#runtime.app.name },
|
|
126
|
+
adminSecret,
|
|
127
|
+
checkCredential,
|
|
128
|
+
agentCredential,
|
|
129
|
+
// A renewed agent credential goes to custody (never a record or a log).
|
|
130
|
+
onAgentCredential: (value) => keepAgent(value),
|
|
131
|
+
logger: { info: (m) => this.#runtime.logger.info(m), warn: (m) => this.#runtime.logger.warn(m) },
|
|
132
|
+
});
|
|
133
|
+
if (authority.issuedCheckCredential) {
|
|
134
|
+
try {
|
|
135
|
+
await custody.store({ reference: { secretId: secretId(config.checkCredential), tenantId: this.#runtime.services.scope.tenantId, kind: "authority-check" }, value: authority.checkCredential });
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
await authority.close();
|
|
139
|
+
throw new FeltKitError("CONFIGURATION", `The local authority's check credential could not be kept: ${error.message}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (authority.issuedAgentCredential) {
|
|
143
|
+
try {
|
|
144
|
+
await keepAgent(authority.agentCredential);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
await authority.close();
|
|
148
|
+
throw new FeltKitError("CONFIGURATION", `The executor's agent credential could not be kept: ${error.message}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
this.#authority = authority;
|
|
152
|
+
this.#status = { state: "running", url: authority.url, dataDir, error: null };
|
|
153
|
+
this.#runtime.activity.record({ kind: "system", name: "authority.local.started", via: "runtime", requestId: `req_${randomBytes(8).toString("hex")}`, principal: null, outcome: "success", durationMs: 0, detail: { url: authority.url, dataDir, issuedCheckCredential: authority.issuedCheckCredential, issuedAgentCredential: authority.issuedAgentCredential, agentCredentialId: authority.agentCredentialId } });
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
// Fail closed: without an authority every decision is "unavailable"; readiness says why.
|
|
157
|
+
this.#status = { state: "failed", url: null, dataDir, error: error.message };
|
|
158
|
+
this.#runtime.logger.warn(`The local authority did not start: ${error.message}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async close() {
|
|
162
|
+
await this.#starting?.catch(() => undefined);
|
|
163
|
+
const authority = this.#authority;
|
|
164
|
+
this.#authority = null;
|
|
165
|
+
if (authority)
|
|
166
|
+
await authority.close();
|
|
167
|
+
}
|
|
168
|
+
/** A person's grants (`ctx.authority.grants`), for the caller only. */
|
|
169
|
+
grantsFor(principal, requestId) {
|
|
170
|
+
const config = this.#runtime.app.options.authority;
|
|
171
|
+
const need = async () => {
|
|
172
|
+
if (!config?.local)
|
|
173
|
+
throw new FeltKitError("FAILED_PRECONDITION", "Grants are managed here only with a local authority (authority.local); with a hosted AuthBoundry, people grant there.");
|
|
174
|
+
if (this.#status.state === "external")
|
|
175
|
+
throw new FeltKitError("UNAVAILABLE", "This environment uses a hosted AuthBoundry (AUTHBOUNDRY_URL); people grant there.");
|
|
176
|
+
if (!principal || principal.type !== "user")
|
|
177
|
+
throw new FeltKitError("FORBIDDEN", "Only a signed-in person grants authority, and only their own.");
|
|
178
|
+
await this.ensure();
|
|
179
|
+
if (!this.#authority)
|
|
180
|
+
throw new FeltKitError("UNAVAILABLE", `The local authority is not running${this.#status.error ? `: ${this.#status.error}` : ""}.`);
|
|
181
|
+
return { authority: this.#authority, delegator: authorityPrincipalOf(config, principal.id) };
|
|
182
|
+
};
|
|
183
|
+
const record = (name, outcome, detail) => this.#runtime.activity.record({ kind: "auth", name, via: "runtime", requestId, principal: principal ? { id: principal.id, type: principal.type, roles: principal.roles } : null, outcome, durationMs: 0, detail });
|
|
184
|
+
const own = (g) => ({ id: g.id, capabilities: g.capabilities, expiresAt: g.expiresAt, status: g.status });
|
|
185
|
+
return {
|
|
186
|
+
list: async () => {
|
|
187
|
+
const { authority, delegator } = await need();
|
|
188
|
+
return (await authority.delegations(delegator)).filter((g) => g.status === "active").map(own);
|
|
189
|
+
},
|
|
190
|
+
grant: async (input) => {
|
|
191
|
+
const { authority, delegator } = await need();
|
|
192
|
+
const known = applicationCapabilities(this.#runtime);
|
|
193
|
+
const unknown = input.capabilities.filter((c) => !known.includes(c));
|
|
194
|
+
if (!input.capabilities.length || unknown.length)
|
|
195
|
+
throw new FeltKitError("INVALID_ARGUMENT", unknown.length ? `Not capabilities of this application: ${unknown.join(", ")}.` : "Grant at least one capability.");
|
|
196
|
+
if (input.expiresAt !== undefined && !(input.expiresAt > Date.now()))
|
|
197
|
+
throw new FeltKitError("INVALID_ARGUMENT", "expiresAt must be in the future.");
|
|
198
|
+
const g = await authority.grant({ delegator, capabilities: input.capabilities, ...(input.expiresAt ? { expiresAt: input.expiresAt } : {}) });
|
|
199
|
+
record("authority.grant", "success", { grant: g.id, capabilities: g.capabilities, expiresAt: g.expiresAt });
|
|
200
|
+
return own(g);
|
|
201
|
+
},
|
|
202
|
+
revoke: async (id) => {
|
|
203
|
+
const { authority, delegator } = await need();
|
|
204
|
+
// Only the caller's own: another person's grant does not exist for them.
|
|
205
|
+
const mine = (await authority.delegations(delegator)).some((g) => g.id === id);
|
|
206
|
+
if (!mine)
|
|
207
|
+
throw new FeltKitError("NOT_FOUND", `No grant ${id}.`);
|
|
208
|
+
await authority.revoke(id);
|
|
209
|
+
record("authority.revoke", "success", { grant: id });
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=local-authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-authority.js","sourceRoot":"","sources":["../../src/runtime/local-authority.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAA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E,EAAE,CAAC,CAAC;YACvD,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -5,6 +5,8 @@ export interface ResolvedClient {
|
|
|
5
5
|
integration: string;
|
|
6
6
|
ref: string;
|
|
7
7
|
id: string;
|
|
8
|
+
/** A person's connection: whose it is (the principal id). Null: the application's grant. */
|
|
9
|
+
owner: string | null;
|
|
8
10
|
tokenUrl: string;
|
|
9
11
|
authorizeUrl: string | null;
|
|
10
12
|
revokeUrl: string | null;
|
|
@@ -18,8 +20,13 @@ export interface ResolvedClient {
|
|
|
18
20
|
export declare class OAuthCredentials {
|
|
19
21
|
#private;
|
|
20
22
|
constructor(runtime: FeltKitRuntime);
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
+
/** Whether each person connects their own account to this integration (credential.owner: "person"). */
|
|
24
|
+
static personal(integration: IntegrationDefinition): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The integration's OAuth client as configured in this environment, or what is missing. For a
|
|
27
|
+
* person's connection, `person` names whose grant it addresses (its own custody id).
|
|
28
|
+
*/
|
|
29
|
+
client(integration: IntegrationDefinition, person?: string): {
|
|
23
30
|
client: ResolvedClient | null;
|
|
24
31
|
problems: Array<{
|
|
25
32
|
message: string;
|
|
@@ -37,12 +44,13 @@ export declare class OAuthCredentials {
|
|
|
37
44
|
*/
|
|
38
45
|
accessToken(integration: IntegrationDefinition, options?: {
|
|
39
46
|
rejected?: string;
|
|
47
|
+
person?: string;
|
|
40
48
|
}): Promise<{
|
|
41
49
|
token: string;
|
|
42
50
|
renewed: boolean;
|
|
43
51
|
}>;
|
|
44
52
|
/** The API refused a token that was just renewed: recorded, so the call fails without looping. */
|
|
45
|
-
rejectedAfterRenewal(integration: IntegrationDefinition): Promise<void>;
|
|
53
|
+
rejectedAfterRenewal(integration: IntegrationDefinition, person?: string): Promise<void>;
|
|
46
54
|
/**
|
|
47
55
|
* Begin connecting an integration's grant, for a person who may store credentials. Returns the
|
|
48
56
|
* provider's authorization URL to open; the provider returns to /api/integrations/<name>/oauth/callback.
|
|
@@ -57,6 +65,19 @@ export declare class OAuthCredentials {
|
|
|
57
65
|
ref: string;
|
|
58
66
|
version: number;
|
|
59
67
|
}>;
|
|
68
|
+
/** One person's connection to an integration: its state, never a token. Only ever the caller's own. */
|
|
69
|
+
connection(integrationName: string, person: string): Promise<ConnectionStatus>;
|
|
70
|
+
/** Every integration a person can connect, with their own state. */
|
|
71
|
+
connections(person: string): Promise<ConnectionStatus[]>;
|
|
72
|
+
/**
|
|
73
|
+
* A person disconnects their own connection: the provider is asked to revoke the tokens (RFC 7009)
|
|
74
|
+
* when it declares how, then the grant is erased here whatever it answered. The next call that needs
|
|
75
|
+
* it is refused. Nobody disconnects another person's connection through this.
|
|
76
|
+
*/
|
|
77
|
+
disconnect(integrationName: string, principal: Principal): Promise<{
|
|
78
|
+
disconnected: boolean;
|
|
79
|
+
providerRevocation: "yes" | "no-endpoint" | "failed" | "none";
|
|
80
|
+
}>;
|
|
60
81
|
/**
|
|
61
82
|
* Disconnect: ask the provider to revoke the tokens (RFC 7009), when it declares how, then the grant
|
|
62
83
|
* is erased here (by the caller, runtime custody's remove) whatever the provider answered.
|
|
@@ -66,3 +87,19 @@ export declare class OAuthCredentials {
|
|
|
66
87
|
}>;
|
|
67
88
|
definitions(): IntegrationDefinition[];
|
|
68
89
|
}
|
|
90
|
+
/** A person's connection, as they (and only they) see it. Never a token. */
|
|
91
|
+
export interface ConnectionStatus {
|
|
92
|
+
integration: string;
|
|
93
|
+
state: "not_connected" | "connected" | "reconnect_required";
|
|
94
|
+
scope?: string | null;
|
|
95
|
+
/** When the access token expires (null: the provider never said). */
|
|
96
|
+
expiresAt?: string | null;
|
|
97
|
+
renewable?: boolean;
|
|
98
|
+
connectedAt?: string;
|
|
99
|
+
renewals?: number;
|
|
100
|
+
failure?: {
|
|
101
|
+
kind: string;
|
|
102
|
+
at: string;
|
|
103
|
+
message: string;
|
|
104
|
+
};
|
|
105
|
+
}
|