@agent-deck/backend 1.11.8 → 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/dist/.tsbuildinfo +1 -1
- package/dist/audit/store.d.ts +43 -0
- package/dist/audit/store.d.ts.map +1 -0
- package/dist/audit/store.js +128 -0
- package/dist/audit/store.js.map +1 -0
- package/dist/auth/client-grants.d.ts +109 -0
- package/dist/auth/client-grants.d.ts.map +1 -0
- package/dist/auth/client-grants.js +260 -0
- package/dist/auth/client-grants.js.map +1 -0
- package/dist/auth/hosted-mode.d.ts +16 -0
- package/dist/auth/hosted-mode.d.ts.map +1 -0
- package/dist/auth/hosted-mode.js +136 -0
- package/dist/auth/hosted-mode.js.map +1 -0
- package/dist/auth/owner-auth.d.ts +24 -0
- package/dist/auth/owner-auth.d.ts.map +1 -0
- package/dist/auth/owner-auth.js +68 -0
- package/dist/auth/owner-auth.js.map +1 -0
- package/dist/auth/request-limiter.d.ts +17 -0
- package/dist/auth/request-limiter.d.ts.map +1 -0
- package/dist/auth/request-limiter.js +47 -0
- package/dist/auth/request-limiter.js.map +1 -0
- package/dist/cli-runtime.d.ts +2 -2
- package/dist/container-entrypoint.d.ts +2 -0
- package/dist/container-entrypoint.d.ts.map +1 -0
- package/dist/container-entrypoint.js +52 -0
- package/dist/container-entrypoint.js.map +1 -0
- package/dist/export-import/export-bundle.d.ts +2 -2
- package/dist/export-import/export-bundle.d.ts.map +1 -1
- package/dist/export-import/export-bundle.js +4 -2
- package/dist/export-import/export-bundle.js.map +1 -1
- package/dist/export-import/import-bundle.d.ts.map +1 -1
- package/dist/export-import/import-bundle.js +15 -3
- package/dist/export-import/import-bundle.js.map +1 -1
- package/dist/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/destination-guard.d.ts +32 -0
- package/dist/lib/destination-guard.d.ts.map +1 -0
- package/dist/lib/destination-guard.js +238 -0
- package/dist/lib/destination-guard.js.map +1 -0
- package/dist/lib/fatal.d.ts +4 -4
- package/dist/lib/fatal.d.ts.map +1 -1
- package/dist/lib/fatal.js +36 -16
- package/dist/lib/fatal.js.map +1 -1
- package/dist/lib/graceful-shutdown.d.ts +26 -0
- package/dist/lib/graceful-shutdown.d.ts.map +1 -0
- package/dist/lib/graceful-shutdown.js +92 -0
- package/dist/lib/graceful-shutdown.js.map +1 -0
- package/dist/lib/mcp-oauth-discovery.d.ts.map +1 -1
- package/dist/lib/mcp-oauth-discovery.js +9 -4
- package/dist/lib/mcp-oauth-discovery.js.map +1 -1
- package/dist/lib/structured-console.d.ts +3 -0
- package/dist/lib/structured-console.d.ts.map +1 -0
- package/dist/lib/structured-console.js +29 -0
- package/dist/lib/structured-console.js.map +1 -0
- package/dist/mcp-index.js +2 -14
- package/dist/mcp-index.js.map +1 -1
- package/dist/mcp-server.d.ts +145 -2
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +524 -16
- package/dist/mcp-server.js.map +1 -1
- package/dist/mcp-session-binding.d.ts +54 -0
- package/dist/mcp-session-binding.d.ts.map +1 -1
- package/dist/mcp-session-binding.js +81 -0
- package/dist/mcp-session-binding.js.map +1 -1
- package/dist/mcp-tools/elicitation.d.ts +13 -4
- package/dist/mcp-tools/elicitation.d.ts.map +1 -1
- package/dist/mcp-tools/elicitation.js +34 -14
- package/dist/mcp-tools/elicitation.js.map +1 -1
- package/dist/mcp-tools/register.d.ts.map +1 -1
- package/dist/mcp-tools/register.js +105 -5
- package/dist/mcp-tools/register.js.map +1 -1
- package/dist/models/database.d.ts +12 -8
- package/dist/models/database.d.ts.map +1 -1
- package/dist/models/database.js +67 -51
- package/dist/models/database.js.map +1 -1
- package/dist/routes/agent-grants.d.ts +9 -0
- package/dist/routes/agent-grants.d.ts.map +1 -0
- package/dist/routes/agent-grants.js +97 -0
- package/dist/routes/agent-grants.js.map +1 -0
- package/dist/routes/audit.d.ts +5 -0
- package/dist/routes/audit.d.ts.map +1 -0
- package/dist/routes/audit.js +33 -0
- package/dist/routes/audit.js.map +1 -0
- package/dist/routes/decks.d.ts.map +1 -1
- package/dist/routes/decks.js +27 -0
- package/dist/routes/decks.js.map +1 -1
- package/dist/routes/mcp.d.ts.map +1 -1
- package/dist/routes/mcp.js +5 -4
- package/dist/routes/mcp.js.map +1 -1
- package/dist/routes/playbooks.d.ts.map +1 -1
- package/dist/routes/playbooks.js +9 -10
- package/dist/routes/playbooks.js.map +1 -1
- package/dist/routes/scope.d.ts.map +1 -1
- package/dist/routes/scope.js +4 -2
- package/dist/routes/scope.js.map +1 -1
- package/dist/routes/services.d.ts.map +1 -1
- package/dist/routes/services.js +6 -0
- package/dist/routes/services.js.map +1 -1
- package/dist/routes/trusted-session.d.ts +2 -0
- package/dist/routes/trusted-session.d.ts.map +1 -1
- package/dist/routes/trusted-session.js +194 -1
- package/dist/routes/trusted-session.js.map +1 -1
- package/dist/routes/usage.d.ts +3 -1
- package/dist/routes/usage.d.ts.map +1 -1
- package/dist/routes/usage.js +20 -1
- package/dist/routes/usage.js.map +1 -1
- package/dist/scope/live-display-registry.d.ts +56 -1
- package/dist/scope/live-display-registry.d.ts.map +1 -1
- package/dist/scope/live-display-registry.js +115 -2
- package/dist/scope/live-display-registry.js.map +1 -1
- package/dist/server/cors-origins.d.ts +6 -0
- package/dist/server/cors-origins.d.ts.map +1 -0
- package/dist/server/cors-origins.js +122 -0
- package/dist/server/cors-origins.js.map +1 -0
- package/dist/server/degraded.d.ts +15 -0
- package/dist/server/degraded.d.ts.map +1 -0
- package/dist/server/degraded.js +55 -0
- package/dist/server/degraded.js.map +1 -0
- package/dist/server/graceful-shutdown.fixture.d.ts +2 -0
- package/dist/server/graceful-shutdown.fixture.d.ts.map +1 -0
- package/dist/server/graceful-shutdown.fixture.js +52 -0
- package/dist/server/graceful-shutdown.fixture.js.map +1 -0
- package/dist/server/health.d.ts +21 -0
- package/dist/server/health.d.ts.map +1 -0
- package/dist/server/health.js +65 -0
- package/dist/server/health.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +60 -26
- package/dist/server/index.js.map +1 -1
- package/dist/services/icon-resolver.d.ts.map +1 -1
- package/dist/services/icon-resolver.js +2 -1
- package/dist/services/icon-resolver.js.map +1 -1
- package/dist/services/mcp-client-manager.d.ts.map +1 -1
- package/dist/services/mcp-client-manager.js +3 -0
- package/dist/services/mcp-client-manager.js.map +1 -1
- package/dist/services/mcp-discovery-service.d.ts.map +1 -1
- package/dist/services/mcp-discovery-service.js +2 -1
- package/dist/services/mcp-discovery-service.js.map +1 -1
- package/dist/services/oauth-manager.d.ts.map +1 -1
- package/dist/services/oauth-manager.js +12 -7
- package/dist/services/oauth-manager.js.map +1 -1
- package/dist/services/service-manager.d.ts.map +1 -1
- package/dist/services/service-manager.js +15 -4
- package/dist/services/service-manager.js.map +1 -1
- package/dist/store/atomic-write.d.ts.map +1 -1
- package/dist/store/atomic-write.js +44 -3
- package/dist/store/atomic-write.js.map +1 -1
- package/dist/store/deck-codec.d.ts +9 -0
- package/dist/store/deck-codec.d.ts.map +1 -1
- package/dist/store/deck-codec.js +64 -1
- package/dist/store/deck-codec.js.map +1 -1
- package/dist/store/deck-file.d.ts +3 -3
- package/dist/store/deck-file.d.ts.map +1 -1
- package/dist/store/deck-file.js +4 -3
- package/dist/store/deck-file.js.map +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/migrate-v1-to-v2.d.ts +22 -0
- package/dist/store/migrate-v1-to-v2.d.ts.map +1 -0
- package/dist/store/migrate-v1-to-v2.js +167 -0
- package/dist/store/migrate-v1-to-v2.js.map +1 -0
- package/dist/store/migrate.js +2 -2
- package/dist/store/migrate.js.map +1 -1
- package/dist/store/reindex.d.ts.map +1 -1
- package/dist/store/reindex.js +16 -6
- package/dist/store/reindex.js.map +1 -1
- package/dist/store/startup.d.ts.map +1 -1
- package/dist/store/startup.js +13 -0
- package/dist/store/startup.js.map +1 -1
- package/dist/store/writer.d.ts.map +1 -1
- package/dist/store/writer.js +7 -3
- package/dist/store/writer.js.map +1 -1
- package/dist/trusted-session/route-policy-registry.d.ts.map +1 -1
- package/dist/trusted-session/route-policy-registry.js +12 -1
- package/dist/trusted-session/route-policy-registry.js.map +1 -1
- package/dist/trusted-session/store.d.ts +37 -2
- package/dist/trusted-session/store.d.ts.map +1 -1
- package/dist/trusted-session/store.js +75 -20
- package/dist/trusted-session/store.js.map +1 -1
- package/dist/vault/encrypted-file-secret-store.d.ts +61 -0
- package/dist/vault/encrypted-file-secret-store.d.ts.map +1 -0
- package/dist/vault/encrypted-file-secret-store.js +211 -0
- package/dist/vault/encrypted-file-secret-store.js.map +1 -0
- package/dist/vault/index.d.ts +1 -0
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/index.js +1 -0
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/secret-store.d.ts +8 -0
- package/dist/vault/secret-store.d.ts.map +1 -1
- package/dist/vault/secret-store.js +31 -2
- package/dist/vault/secret-store.js.map +1 -1
- package/package.json +2 -2
- package/static-ui/assets/index-ClYpYc1K.js +251 -0
- package/static-ui/assets/index-DMqzTrRe.css +1 -0
- package/static-ui/index.html +2 -2
- package/static-ui/assets/index-CQf3Vouc.css +0 -1
- package/static-ui/assets/index-DCImqPRz.js +0 -235
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type Database from 'better-sqlite3';
|
|
2
|
+
export declare const AUDIT_RETENTION_MS: number;
|
|
3
|
+
export declare const AUDIT_EVENTS: readonly ["grant.created", "grant.used", "grant.revoked", "deck.selection_denied", "owner.sign_in_succeeded", "owner.sign_in_failed", "elevation.requested", "elevation.approved", "elevation.denied"];
|
|
4
|
+
export type AuditEvent = (typeof AUDIT_EVENTS)[number];
|
|
5
|
+
export type AuditOutcome = 'succeeded' | 'denied';
|
|
6
|
+
export type AuditActor = 'owner' | 'local-launch' | `ag_${string}`;
|
|
7
|
+
export type AuditReasonCode = 'invalid_credentials' | 'resource_out_of_scope' | 'deck_fixed' | 'admin_required' | 'owner_denied';
|
|
8
|
+
export type AuditEntry = {
|
|
9
|
+
id: string;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
installationId: string;
|
|
12
|
+
actor: AuditActor;
|
|
13
|
+
event: AuditEvent;
|
|
14
|
+
targetId: string;
|
|
15
|
+
outcome: AuditOutcome;
|
|
16
|
+
reasonCode: AuditReasonCode | null;
|
|
17
|
+
};
|
|
18
|
+
export type WriteAuditEntry = Omit<AuditEntry, 'id' | 'timestamp' | 'installationId'> & {
|
|
19
|
+
installationId?: string;
|
|
20
|
+
};
|
|
21
|
+
/** Never persist an untrusted deck header/body value as audit content. */
|
|
22
|
+
export declare function auditDeckTarget(value: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Append-only, identifier-only security audit ledger.
|
|
25
|
+
*
|
|
26
|
+
* The typed write shape deliberately has no free-form metadata field. Callers
|
|
27
|
+
* cannot pass request headers, credentials, tokens, tool arguments or results,
|
|
28
|
+
* and the API returns exactly the columns below.
|
|
29
|
+
*/
|
|
30
|
+
export declare class AuditStore {
|
|
31
|
+
private readonly db;
|
|
32
|
+
private readonly now;
|
|
33
|
+
constructor(db: Database.Database, now?: () => number);
|
|
34
|
+
private ensureTable;
|
|
35
|
+
append(entry: WriteAuditEntry): AuditEntry;
|
|
36
|
+
list(options: {
|
|
37
|
+
limit: number;
|
|
38
|
+
before?: string;
|
|
39
|
+
}): AuditEntry[];
|
|
40
|
+
pruneExpired(): number;
|
|
41
|
+
private resolveCursor;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/audit/store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAI3C,eAAO,MAAM,kBAAkB,QAA2B,CAAC;AAE3D,eA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,EAAE;IAuB/D,YAAY,IAAI,MAAM;IAKtB,OAAO,CAAC,aAAa;CAWtB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditStore = exports.AUDIT_EVENTS = exports.AUDIT_RETENTION_MS = void 0;
|
|
4
|
+
exports.auditDeckTarget = auditDeckTarget;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const client_grants_1 = require("../auth/client-grants");
|
|
7
|
+
exports.AUDIT_RETENTION_MS = 90 * 24 * 60 * 60 * 1000;
|
|
8
|
+
exports.AUDIT_EVENTS = [
|
|
9
|
+
'grant.created',
|
|
10
|
+
'grant.used',
|
|
11
|
+
'grant.revoked',
|
|
12
|
+
'deck.selection_denied',
|
|
13
|
+
'owner.sign_in_succeeded',
|
|
14
|
+
'owner.sign_in_failed',
|
|
15
|
+
'elevation.requested',
|
|
16
|
+
'elevation.approved',
|
|
17
|
+
'elevation.denied',
|
|
18
|
+
];
|
|
19
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
20
|
+
/** Never persist an untrusted deck header/body value as audit content. */
|
|
21
|
+
function auditDeckTarget(value) {
|
|
22
|
+
return UUID_PATTERN.test(value) ? value : 'invalid-deck-id';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Append-only, identifier-only security audit ledger.
|
|
26
|
+
*
|
|
27
|
+
* The typed write shape deliberately has no free-form metadata field. Callers
|
|
28
|
+
* cannot pass request headers, credentials, tokens, tool arguments or results,
|
|
29
|
+
* and the API returns exactly the columns below.
|
|
30
|
+
*/
|
|
31
|
+
class AuditStore {
|
|
32
|
+
db;
|
|
33
|
+
now;
|
|
34
|
+
constructor(db, now = Date.now) {
|
|
35
|
+
this.db = db;
|
|
36
|
+
this.now = now;
|
|
37
|
+
this.ensureTable();
|
|
38
|
+
this.pruneExpired();
|
|
39
|
+
}
|
|
40
|
+
ensureTable() {
|
|
41
|
+
this.db.exec(`
|
|
42
|
+
CREATE TABLE IF NOT EXISTS audit_events (
|
|
43
|
+
id TEXT PRIMARY KEY,
|
|
44
|
+
timestamp TEXT NOT NULL,
|
|
45
|
+
installation_id TEXT NOT NULL,
|
|
46
|
+
actor TEXT NOT NULL,
|
|
47
|
+
event TEXT NOT NULL,
|
|
48
|
+
target_id TEXT NOT NULL,
|
|
49
|
+
outcome TEXT NOT NULL,
|
|
50
|
+
reason_code TEXT
|
|
51
|
+
);
|
|
52
|
+
CREATE INDEX IF NOT EXISTS audit_events_page_idx
|
|
53
|
+
ON audit_events (timestamp DESC, id DESC);
|
|
54
|
+
`);
|
|
55
|
+
}
|
|
56
|
+
append(entry) {
|
|
57
|
+
const latest = this.db
|
|
58
|
+
.prepare(`SELECT timestamp FROM audit_events ORDER BY timestamp DESC LIMIT 1`)
|
|
59
|
+
.get();
|
|
60
|
+
const timestampMs = Math.max(this.now(), latest ? Date.parse(latest.timestamp) + 1 : Number.NEGATIVE_INFINITY);
|
|
61
|
+
const row = {
|
|
62
|
+
id: `aud_${(0, node_crypto_1.randomUUID)()}`,
|
|
63
|
+
// SQLite connections in the backend and MCP process can append inside
|
|
64
|
+
// the same millisecond. Keep the public timestamp monotonic so newest-
|
|
65
|
+
// first order and id cursors remain deterministic across processes.
|
|
66
|
+
timestamp: new Date(timestampMs).toISOString(),
|
|
67
|
+
installationId: entry.installationId ?? client_grants_1.OWNER_INSTALLATION_ID,
|
|
68
|
+
actor: entry.actor,
|
|
69
|
+
event: entry.event,
|
|
70
|
+
targetId: entry.targetId,
|
|
71
|
+
outcome: entry.outcome,
|
|
72
|
+
reasonCode: entry.reasonCode,
|
|
73
|
+
};
|
|
74
|
+
this.db
|
|
75
|
+
.prepare(`INSERT INTO audit_events
|
|
76
|
+
(id, timestamp, installation_id, actor, event, target_id, outcome, reason_code)
|
|
77
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
78
|
+
.run(row.id, row.timestamp, row.installationId, row.actor, row.event, row.targetId, row.outcome, row.reasonCode);
|
|
79
|
+
return row;
|
|
80
|
+
}
|
|
81
|
+
list(options) {
|
|
82
|
+
const cursor = options.before ? this.resolveCursor(options.before) : null;
|
|
83
|
+
const rows = cursor
|
|
84
|
+
? this.db
|
|
85
|
+
.prepare(`SELECT id, timestamp, installation_id, actor, event, target_id, outcome, reason_code
|
|
86
|
+
FROM audit_events
|
|
87
|
+
WHERE timestamp < ? OR (timestamp = ? AND id < ?)
|
|
88
|
+
ORDER BY timestamp DESC, id DESC
|
|
89
|
+
LIMIT ?`)
|
|
90
|
+
.all(cursor.timestamp, cursor.timestamp, cursor.id, options.limit)
|
|
91
|
+
: this.db
|
|
92
|
+
.prepare(`SELECT id, timestamp, installation_id, actor, event, target_id, outcome, reason_code
|
|
93
|
+
FROM audit_events
|
|
94
|
+
ORDER BY timestamp DESC, id DESC
|
|
95
|
+
LIMIT ?`)
|
|
96
|
+
.all(options.limit);
|
|
97
|
+
return rows.map(toAuditEntry);
|
|
98
|
+
}
|
|
99
|
+
pruneExpired() {
|
|
100
|
+
const cutoff = new Date(this.now() - exports.AUDIT_RETENTION_MS).toISOString();
|
|
101
|
+
return this.db.prepare(`DELETE FROM audit_events WHERE timestamp < ?`).run(cutoff).changes;
|
|
102
|
+
}
|
|
103
|
+
resolveCursor(before) {
|
|
104
|
+
const byId = this.db
|
|
105
|
+
.prepare(`SELECT id, timestamp FROM audit_events WHERE id = ?`)
|
|
106
|
+
.get(before);
|
|
107
|
+
if (byId)
|
|
108
|
+
return byId;
|
|
109
|
+
const timestamp = Date.parse(before);
|
|
110
|
+
return Number.isFinite(timestamp)
|
|
111
|
+
? { timestamp: new Date(timestamp).toISOString(), id: '' }
|
|
112
|
+
: null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.AuditStore = AuditStore;
|
|
116
|
+
function toAuditEntry(row) {
|
|
117
|
+
return {
|
|
118
|
+
id: row.id,
|
|
119
|
+
timestamp: row.timestamp,
|
|
120
|
+
installationId: row.installation_id,
|
|
121
|
+
actor: row.actor,
|
|
122
|
+
event: row.event,
|
|
123
|
+
targetId: row.target_id,
|
|
124
|
+
outcome: row.outcome,
|
|
125
|
+
reasonCode: row.reason_code,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/audit/store.ts"],"names":[],"mappings":";;;AAgDA,0CAEC;AAlDD,6CAAyC;AAIzC,yDAA8D;AAEjD,QAAA,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE9C,QAAA,YAAY,GAAG;IAC1B,eAAe;IACf,YAAY;IACZ,eAAe;IACf,uBAAuB;IACvB,yBAAyB;IACzB,sBAAsB;IACtB,qBAAqB;IACrB,oBAAoB;IACpB,kBAAkB;CACV,CAAC;AA2BX,MAAM,YAAY,GAAG,4EAA4E,CAAC;AAElG,0EAA0E;AAC1E,SAAgB,eAAe,CAAC,KAAa;IAC3C,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC;AAC9D,CAAC;AAaD;;;;;;GAMG;AACH,MAAa,UAAU;IAEF;IACA;IAFnB,YACmB,EAAqB,EACrB,MAAoB,IAAI,CAAC,GAAG;QAD5B,OAAE,GAAF,EAAE,CAAmB;QACrB,QAAG,GAAH,GAAG,CAAyB;QAE7C,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC;;;;;;;;;;;;;KAaZ,CAAC,CAAC;IACL,CAAC;I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ACxB,cAAc,EAAE,GAAG,CAAC,eAAe;QACnC,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,UAAU,EAAE,GAAG,CAAC,WAAW;KAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type Database from 'better-sqlite3';
|
|
2
|
+
/**
|
|
3
|
+
* NOT-318: per-agent remote grants for the single-owner hosted appliance.
|
|
4
|
+
*
|
|
5
|
+
* Two boundaries live here:
|
|
6
|
+
*
|
|
7
|
+
* - `ClientPrincipal` — the unified authorization principal every MCP
|
|
8
|
+
* session resolves to. Loopback launcher sessions resolve to `local`
|
|
9
|
+
* (unconstrained, exactly as today); remote bearer sessions resolve to
|
|
10
|
+
* `grant` (constrained by the grant allowlist). Both flow through the
|
|
11
|
+
* same deck-scope check (`principalAllowsDeck`), so the deck header can
|
|
12
|
+
* never authorize beyond the principal.
|
|
13
|
+
* - `ClientGrantStore` — SQLite-backed grant metadata. V1 is one
|
|
14
|
+
* installation and one owner (`installationId` defaults to `'owner'`);
|
|
15
|
+
* the field exists so a future tenancy migration has something to
|
|
16
|
+
* partition on.
|
|
17
|
+
*
|
|
18
|
+
* Token format: `adg_<grantId>_<secret>` where `<secret>` carries 256
|
|
19
|
+
* bits of CSPRNG entropy (32 bytes, base64url). The id prefix is
|
|
20
|
+
* routing-only — it confers nothing by itself. The secret is shown once
|
|
21
|
+
* at issuance; only a versioned SHA-256 verifier is persisted (suitable
|
|
22
|
+
* for high-entropy tokens), compared in constant time.
|
|
23
|
+
*/
|
|
24
|
+
export declare const GRANT_TOKEN_PREFIX = "adg";
|
|
25
|
+
/** Current verifier version. Bump when the hash construction changes. */
|
|
26
|
+
export declare const GRANT_VERIFIER_VERSION = "v1";
|
|
27
|
+
/** Single-installation owner principal for V1. */
|
|
28
|
+
export declare const OWNER_INSTALLATION_ID = "owner";
|
|
29
|
+
/** Unified authorization principal for one MCP session. */
|
|
30
|
+
export type ClientPrincipal = {
|
|
31
|
+
kind: 'local';
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'grant';
|
|
34
|
+
grantId: string;
|
|
35
|
+
label: string;
|
|
36
|
+
defaultDeck: string;
|
|
37
|
+
allowedDecks: string[];
|
|
38
|
+
};
|
|
39
|
+
/** Persisted grant row (never carries the bearer secret). */
|
|
40
|
+
export type ClientGrant = {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
verifierVersion: string;
|
|
44
|
+
defaultDeck: string;
|
|
45
|
+
allowedDecks: string[];
|
|
46
|
+
installationId: string;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
expiresAt: string | null;
|
|
49
|
+
revokedAt: string | null;
|
|
50
|
+
lastUsedAt: string | null;
|
|
51
|
+
};
|
|
52
|
+
/** Owner-visible grant view: metadata only, never the persisted verifier. */
|
|
53
|
+
export type ClientGrantPublic = Omit<ClientGrant, 'verifierVersion'>;
|
|
54
|
+
/** Result of issuing a grant — the only moment the secret exists. */
|
|
55
|
+
export type IssuedGrant = {
|
|
56
|
+
grant: ClientGrantPublic;
|
|
57
|
+
/** Full bearer value `adg_<id>_<secret>`. Display once, then drop. */
|
|
58
|
+
token: string;
|
|
59
|
+
};
|
|
60
|
+
export declare function parseGrantToken(token: string): {
|
|
61
|
+
grantId: string;
|
|
62
|
+
secret: string;
|
|
63
|
+
} | null;
|
|
64
|
+
/** True when the principal may serve `deckId`. Local sessions are unconstrained. */
|
|
65
|
+
export declare function principalAllowsDeck(principal: ClientPrincipal, deckId: string): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve the effective deck for an authenticated grant: no requested deck
|
|
68
|
+
* applies the grant default; a requested deck must sit inside the allowlist
|
|
69
|
+
* (null = denied, never fall back — a forged header must not silently
|
|
70
|
+
* land on the default).
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveGrantDeck(principal: Extract<ClientPrincipal, {
|
|
73
|
+
kind: 'grant';
|
|
74
|
+
}>, requestedDeckId?: string): string | null;
|
|
75
|
+
export type IssueGrantInput = {
|
|
76
|
+
label: string;
|
|
77
|
+
defaultDeck: string;
|
|
78
|
+
allowedDecks?: string[];
|
|
79
|
+
expiresAt?: string | null;
|
|
80
|
+
installationId?: string;
|
|
81
|
+
};
|
|
82
|
+
export declare class ClientGrantStore {
|
|
83
|
+
private readonly db;
|
|
84
|
+
private readonly installationId;
|
|
85
|
+
constructor(db: Database.Database, installationId?: string);
|
|
86
|
+
private ensureTables;
|
|
87
|
+
/**
|
|
88
|
+
* Issue a grant and its bearer secret. The returned token is the only
|
|
89
|
+
* copy of the secret — persist nothing but the versioned verifier.
|
|
90
|
+
*/
|
|
91
|
+
issueGrant(input: IssueGrantInput): IssuedGrant;
|
|
92
|
+
getGrant(id: string): ClientGrantPublic | null;
|
|
93
|
+
listGrants(): ClientGrantPublic[];
|
|
94
|
+
/**
|
|
95
|
+
* Authenticate a bearer token. Returns the grant principal on success,
|
|
96
|
+
* null for every failure mode (unknown id, secret mismatch, expired,
|
|
97
|
+
* revoked) — callers map all of them to one uniform 401 with no oracle.
|
|
98
|
+
* Touches `last_used_at` on success only.
|
|
99
|
+
*/
|
|
100
|
+
authenticateToken(token: string): Extract<ClientPrincipal, {
|
|
101
|
+
kind: 'grant';
|
|
102
|
+
}> | null;
|
|
103
|
+
/**
|
|
104
|
+
* Revoke a grant. There is no un-revoke: a re-issued grant for the same
|
|
105
|
+
* agent is a new id with a new secret. Returns false when unknown.
|
|
106
|
+
*/
|
|
107
|
+
revokeGrant(id: string): boolean;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=client-grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-grants.d.ts","sourceRoot":"","sources":["../../src/auth/client-grants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,C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mBAAmB,CAAC,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKvF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,OAAO,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,EACtD,eAAe,CAAC,EAAE,MAAM,GACvB,MAAM,GAAG,IAAI,CAMf;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,cAAc;gBADd,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,cAAc,GAAE,MAA8B;IAKjE,OAAO,CAAC,YAAY;IAoBpB;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW;IA+C/C,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAW9C,UAAU,IAAI,iBAAiB,EAAE;IAWjC;;;;;OAKG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI;IAwCpF;;;OAGG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;CAMjC"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientGrantStore = exports.OWNER_INSTALLATION_ID = exports.GRANT_VERIFIER_VERSION = exports.GRANT_TOKEN_PREFIX = void 0;
|
|
4
|
+
exports.parseGrantToken = parseGrantToken;
|
|
5
|
+
exports.principalAllowsDeck = principalAllowsDeck;
|
|
6
|
+
exports.resolveGrantDeck = resolveGrantDeck;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
/**
|
|
9
|
+
* NOT-318: per-agent remote grants for the single-owner hosted appliance.
|
|
10
|
+
*
|
|
11
|
+
* Two boundaries live here:
|
|
12
|
+
*
|
|
13
|
+
* - `ClientPrincipal` — the unified authorization principal every MCP
|
|
14
|
+
* session resolves to. Loopback launcher sessions resolve to `local`
|
|
15
|
+
* (unconstrained, exactly as today); remote bearer sessions resolve to
|
|
16
|
+
* `grant` (constrained by the grant allowlist). Both flow through the
|
|
17
|
+
* same deck-scope check (`principalAllowsDeck`), so the deck header can
|
|
18
|
+
* never authorize beyond the principal.
|
|
19
|
+
* - `ClientGrantStore` — SQLite-backed grant metadata. V1 is one
|
|
20
|
+
* installation and one owner (`installationId` defaults to `'owner'`);
|
|
21
|
+
* the field exists so a future tenancy migration has something to
|
|
22
|
+
* partition on.
|
|
23
|
+
*
|
|
24
|
+
* Token format: `adg_<grantId>_<secret>` where `<secret>` carries 256
|
|
25
|
+
* bits of CSPRNG entropy (32 bytes, base64url). The id prefix is
|
|
26
|
+
* routing-only — it confers nothing by itself. The secret is shown once
|
|
27
|
+
* at issuance; only a versioned SHA-256 verifier is persisted (suitable
|
|
28
|
+
* for high-entropy tokens), compared in constant time.
|
|
29
|
+
*/
|
|
30
|
+
exports.GRANT_TOKEN_PREFIX = 'adg';
|
|
31
|
+
/** Current verifier version. Bump when the hash construction changes. */
|
|
32
|
+
exports.GRANT_VERIFIER_VERSION = 'v1';
|
|
33
|
+
/** Single-installation owner principal for V1. */
|
|
34
|
+
exports.OWNER_INSTALLATION_ID = 'owner';
|
|
35
|
+
function nowIso() {
|
|
36
|
+
return new Date().toISOString();
|
|
37
|
+
}
|
|
38
|
+
function hashSecret(secret) {
|
|
39
|
+
return (0, node_crypto_1.createHash)('sha256').update(secret, 'utf8').digest('hex');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parse `adg_<grantId>_<secret>`. Returns null for anything else —
|
|
43
|
+
* malformed input is indistinguishable from an unknown grant upstream.
|
|
44
|
+
*
|
|
45
|
+
* The split is anchored on the grant-id shape (`ag_<uuid>`), not on a
|
|
46
|
+
* bare `_`: issued secrets are base64url and may themselves contain `_`,
|
|
47
|
+
* so first- or last-underscore splitting misroutes roughly half of all
|
|
48
|
+
* tokens. `issueGrant` is the only id minter, so the shape is closed.
|
|
49
|
+
*/
|
|
50
|
+
const GRANT_TOKEN_PATTERN = /^adg_(ag_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})_(\S+)$/;
|
|
51
|
+
function parseGrantToken(token) {
|
|
52
|
+
if (typeof token !== 'string') {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const match = GRANT_TOKEN_PATTERN.exec(token.trim());
|
|
56
|
+
if (!match) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return { grantId: match[1], secret: match[2] };
|
|
60
|
+
}
|
|
61
|
+
/** True when the principal may serve `deckId`. Local sessions are unconstrained. */
|
|
62
|
+
function principalAllowsDeck(principal, deckId) {
|
|
63
|
+
if (principal.kind === 'local') {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return principal.allowedDecks.includes(deckId);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolve the effective deck for an authenticated grant: no requested deck
|
|
70
|
+
* applies the grant default; a requested deck must sit inside the allowlist
|
|
71
|
+
* (null = denied, never fall back — a forged header must not silently
|
|
72
|
+
* land on the default).
|
|
73
|
+
*/
|
|
74
|
+
function resolveGrantDeck(principal, requestedDeckId) {
|
|
75
|
+
const requested = requestedDeckId?.trim();
|
|
76
|
+
if (!requested) {
|
|
77
|
+
return principal.defaultDeck;
|
|
78
|
+
}
|
|
79
|
+
return principal.allowedDecks.includes(requested) ? requested : null;
|
|
80
|
+
}
|
|
81
|
+
class ClientGrantStore {
|
|
82
|
+
db;
|
|
83
|
+
installationId;
|
|
84
|
+
constructor(db, installationId = exports.OWNER_INSTALLATION_ID) {
|
|
85
|
+
this.db = db;
|
|
86
|
+
this.installationId = installationId;
|
|
87
|
+
this.ensureTables();
|
|
88
|
+
}
|
|
89
|
+
ensureTables() {
|
|
90
|
+
this.db.exec(`
|
|
91
|
+
CREATE TABLE IF NOT EXISTS agent_grants (
|
|
92
|
+
id TEXT PRIMARY KEY,
|
|
93
|
+
label TEXT NOT NULL,
|
|
94
|
+
verifier_version TEXT NOT NULL,
|
|
95
|
+
secret_hash TEXT NOT NULL,
|
|
96
|
+
default_deck TEXT NOT NULL,
|
|
97
|
+
allowed_decks TEXT NOT NULL,
|
|
98
|
+
installation_id TEXT NOT NULL,
|
|
99
|
+
created_at TEXT NOT NULL,
|
|
100
|
+
expires_at TEXT,
|
|
101
|
+
revoked_at TEXT,
|
|
102
|
+
last_used_at TEXT
|
|
103
|
+
);
|
|
104
|
+
CREATE INDEX IF NOT EXISTS agent_grants_installation_idx
|
|
105
|
+
ON agent_grants (installation_id);
|
|
106
|
+
`);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Issue a grant and its bearer secret. The returned token is the only
|
|
110
|
+
* copy of the secret — persist nothing but the versioned verifier.
|
|
111
|
+
*/
|
|
112
|
+
issueGrant(input) {
|
|
113
|
+
const label = input.label?.trim();
|
|
114
|
+
if (!label) {
|
|
115
|
+
throw new Error('label required');
|
|
116
|
+
}
|
|
117
|
+
const defaultDeck = input.defaultDeck?.trim();
|
|
118
|
+
if (!defaultDeck) {
|
|
119
|
+
throw new Error('defaultDeck required');
|
|
120
|
+
}
|
|
121
|
+
const allowed = [...new Set((input.allowedDecks ?? [defaultDeck]).map((d) => d.trim()).filter(Boolean))];
|
|
122
|
+
if (!allowed.includes(defaultDeck)) {
|
|
123
|
+
allowed.push(defaultDeck);
|
|
124
|
+
}
|
|
125
|
+
if (input.expiresAt !== undefined && input.expiresAt !== null) {
|
|
126
|
+
const ms = Date.parse(input.expiresAt);
|
|
127
|
+
if (!Number.isFinite(ms)) {
|
|
128
|
+
throw new Error('expiresAt must be an ISO timestamp');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const id = `ag_${(0, node_crypto_1.randomUUID)()}`;
|
|
132
|
+
const secret = (0, node_crypto_1.randomBytes)(32).toString('base64url');
|
|
133
|
+
const createdAt = nowIso();
|
|
134
|
+
this.db
|
|
135
|
+
.prepare(`INSERT INTO agent_grants
|
|
136
|
+
(id, label, verifier_version, secret_hash, default_deck, allowed_decks,
|
|
137
|
+
installation_id, created_at, expires_at, revoked_at, last_used_at)
|
|
138
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL)`)
|
|
139
|
+
.run(id, label, exports.GRANT_VERIFIER_VERSION, hashSecret(secret), defaultDeck, JSON.stringify(allowed), input.installationId ?? this.installationId, createdAt, input.expiresAt ?? null);
|
|
140
|
+
return {
|
|
141
|
+
grant: this.getGrant(id),
|
|
142
|
+
token: `${exports.GRANT_TOKEN_PREFIX}_${id}_${secret}`,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
getGrant(id) {
|
|
146
|
+
const row = this.db
|
|
147
|
+
.prepare(`SELECT id, label, verifier_version, secret_hash, default_deck, allowed_decks,
|
|
148
|
+
installation_id, created_at, expires_at, revoked_at, last_used_at
|
|
149
|
+
FROM agent_grants WHERE id = ?`)
|
|
150
|
+
.get(id);
|
|
151
|
+
return row ? toPublicGrant(row) : null;
|
|
152
|
+
}
|
|
153
|
+
listGrants() {
|
|
154
|
+
const rows = this.db
|
|
155
|
+
.prepare(`SELECT id, label, verifier_version, secret_hash, default_deck, allowed_decks,
|
|
156
|
+
installation_id, created_at, expires_at, revoked_at, last_used_at
|
|
157
|
+
FROM agent_grants ORDER BY created_at ASC`)
|
|
158
|
+
.all();
|
|
159
|
+
return rows.map(toPublicGrant);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Authenticate a bearer token. Returns the grant principal on success,
|
|
163
|
+
* null for every failure mode (unknown id, secret mismatch, expired,
|
|
164
|
+
* revoked) — callers map all of them to one uniform 401 with no oracle.
|
|
165
|
+
* Touches `last_used_at` on success only.
|
|
166
|
+
*/
|
|
167
|
+
authenticateToken(token) {
|
|
168
|
+
const parsed = parseGrantToken(token);
|
|
169
|
+
if (!parsed) {
|
|
170
|
+
// Same-cost dummy comparison so malformed input is not measurably
|
|
171
|
+
// cheaper than a secret mismatch.
|
|
172
|
+
dummyCompare();
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
const row = this.db
|
|
176
|
+
.prepare(`SELECT id, label, verifier_version, secret_hash, default_deck, allowed_decks,
|
|
177
|
+
installation_id, created_at, expires_at, revoked_at, last_used_at
|
|
178
|
+
FROM agent_grants WHERE id = ?`)
|
|
179
|
+
.get(parsed.grantId);
|
|
180
|
+
if (!row) {
|
|
181
|
+
dummyCompare();
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
if (!verifierMatches(parsed.secret, row.secret_hash)) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
if (row.revoked_at) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
if (row.expires_at && Date.parse(row.expires_at) <= Date.now()) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
this.db
|
|
194
|
+
.prepare(`UPDATE agent_grants SET last_used_at = ? WHERE id = ?`)
|
|
195
|
+
.run(nowIso(), row.id);
|
|
196
|
+
return {
|
|
197
|
+
kind: 'grant',
|
|
198
|
+
grantId: row.id,
|
|
199
|
+
label: row.label,
|
|
200
|
+
defaultDeck: row.default_deck,
|
|
201
|
+
allowedDecks: parseAllowedDecks(row.allowed_decks),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Revoke a grant. There is no un-revoke: a re-issued grant for the same
|
|
206
|
+
* agent is a new id with a new secret. Returns false when unknown.
|
|
207
|
+
*/
|
|
208
|
+
revokeGrant(id) {
|
|
209
|
+
const result = this.db
|
|
210
|
+
.prepare(`UPDATE agent_grants SET revoked_at = ? WHERE id = ? AND revoked_at IS NULL`)
|
|
211
|
+
.run(nowIso(), id);
|
|
212
|
+
return result.changes > 0;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.ClientGrantStore = ClientGrantStore;
|
|
216
|
+
function toPublicGrant(row) {
|
|
217
|
+
return {
|
|
218
|
+
id: row.id,
|
|
219
|
+
label: row.label,
|
|
220
|
+
defaultDeck: row.default_deck,
|
|
221
|
+
allowedDecks: parseAllowedDecks(row.allowed_decks),
|
|
222
|
+
installationId: row.installation_id,
|
|
223
|
+
createdAt: row.created_at,
|
|
224
|
+
expiresAt: row.expires_at,
|
|
225
|
+
revokedAt: row.revoked_at,
|
|
226
|
+
lastUsedAt: row.last_used_at,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function parseAllowedDecks(raw) {
|
|
230
|
+
try {
|
|
231
|
+
const parsed = JSON.parse(raw);
|
|
232
|
+
return Array.isArray(parsed) ? parsed.filter((d) => typeof d === 'string') : [];
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/** Constant-time comparison of the presented secret against the stored verifier. */
|
|
239
|
+
function verifierMatches(secret, storedHex) {
|
|
240
|
+
let presented;
|
|
241
|
+
let stored;
|
|
242
|
+
try {
|
|
243
|
+
presented = Buffer.from(hashSecret(secret), 'hex');
|
|
244
|
+
stored = Buffer.from(storedHex, 'hex');
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
if (presented.length !== stored.length) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
return (0, node_crypto_1.timingSafeEqual)(presented, stored);
|
|
253
|
+
}
|
|
254
|
+
/** Burn comparable time when there is nothing to compare against (unknown id / malformed). */
|
|
255
|
+
function dummyCompare() {
|
|
256
|
+
const a = Buffer.from(hashSecret('agent-deck-grant-dummy'), 'hex');
|
|
257
|
+
const b = Buffer.from(hashSecret('agent-deck-grant-dummy-other'), 'hex');
|
|
258
|
+
(0, node_crypto_1.timingSafeEqual)(a, b);
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=client-grants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-grants.js","sourceRoot":"","sources":["../../src/auth/client-grants.ts"],"names":[],"mappings":";;;AAqGA,0CASC;AAGD,kDAKC;AAQD,4CASC;AAvID,6CAAmF;AAInF;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEU,QAAA,kBAAkB,GAAG,KAAK,CAAC;AACxC,yEAAyE;AAC5D,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAC3C,kDAAkD;AACrC,QAAA,qBAAqB,GAAG,OAAO,CAAC;AAmD7C,SAAS,MAAM;IACb,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,UAAU,CAAC,MAAc;IAChC,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,mBAAmB,GAAG,+EAA+E,CAAC;AAE5G,SAAgB,eAAe,CAAC,KAAa;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,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_IDLE_MS: number;
|
|
3
|
+
export declare const HOSTED_DASHBOARD_ABSOLUTE_MS: number;
|
|
4
|
+
export declare const HOSTED_RATE_LIMIT_WINDOW_MS = 60000;
|
|
5
|
+
export declare const HOSTED_SIGN_IN_FAILURE_LIMIT = 5;
|
|
6
|
+
export declare const HOSTED_PUBLIC_MUTATION_LIMIT = 60;
|
|
7
|
+
export declare const HOSTED_PUBLIC_BODY_LIMIT_BYTES: number;
|
|
8
|
+
export type HostedModeConfig = {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
publicOrigin?: string;
|
|
11
|
+
now?: () => number;
|
|
12
|
+
};
|
|
13
|
+
export declare function resolveHostedModeConfig(env?: NodeJS.ProcessEnv): HostedModeConfig;
|
|
14
|
+
/** Hosted-mode owner gate. Registered before the legacy route-policy hook. */
|
|
15
|
+
export declare function registerHostedModeGuard(fastify: FastifyInstance, config: HostedModeConfig): void;
|
|
16
|
+
//# sourceMappingURL=hosted-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-mode.d.ts","sourceRoot":"","sources":["../../src/auth/hosted-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AAM7E,eAAO,MAAM,wBAAwB,QAAsB,CAAC;AAC5D,eAAO,MAAM,4BAA4B,QAA0B,CAAC;AACpE,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAClD,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,8BAA8B,QAAc,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,gBAAgB,CAmBlB;AA+DD,8EAA8E;AAC9E,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,gBAAgB,GACvB,IAAI,CAmEN"}
|