@tnunamak/dalan 0.6.1 → 0.7.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/CHANGELOG.md +32 -0
- package/README.md +25 -64
- package/bin/dalan.mjs +9 -0
- package/bin/dot-worker.mjs +16 -2
- package/docs/chatgpt-worker-onboarding.md +10 -14
- package/docs/claude-worker-onboarding.md +9 -8
- package/docs/codex-to-muse.md +21 -35
- package/docs/connect-chatgpt.md +10 -16
- package/docs/dalan-upgrade.md +4 -2
- package/docs/local-agent-mcp.md +24 -4
- package/docs/manual-setup.md +2 -2
- package/docs/operations.md +10 -11
- package/docs/pull-workers.md +1 -2
- package/docs/service-setup.md +99 -145
- package/docs/setup-reference.md +5 -5
- package/docs/worker-clients.md +4 -4
- package/package.json +2 -3
- package/scripts/dalan-try-selfcheck.mjs +8 -7
- package/scripts/worker-bridge-setup.mjs +91 -81
- package/src/as-store.mjs +5 -3
- package/src/as.mjs +35 -26
- package/src/auth-check.mjs +53 -0
- package/src/cli-help.mjs +20 -15
- package/src/client-approval.mjs +57 -0
- package/src/client-convenience.mjs +166 -0
- package/src/client-conveniences.json +106 -0
- package/src/client-conveniences.schema.json +97 -0
- package/src/connect-cli.mjs +5 -5
- package/src/default-home.mjs +36 -0
- package/src/follow-current.mjs +25 -0
- package/src/gozar-routes.mjs +314 -0
- package/src/redirect-policy.mjs +61 -0
- package/src/route-setting.mjs +71 -12
- package/src/server.mjs +38 -2
- package/src/service-auto-update.mjs +68 -0
- package/src/service-launchd.mjs +166 -0
- package/src/service-update-gate.mjs +20 -0
- package/src/service-update-lock.mjs +22 -0
- package/src/service-update-runtime.mjs +290 -0
- package/src/service-update.mjs +399 -0
- package/src/service.mjs +241 -58
- package/src/setup.mjs +55 -44
- package/src/try-exposure.mjs +7 -657
- package/src/try-hosted.mjs +71 -101
- package/src/try-selfcheck.mjs +15 -8
- package/src/try.mjs +9 -13
- package/scripts/lib/expose-tailscale.mjs +0 -408
- package/src/try-hosted-clients.mjs +0 -46
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// What the owner sees, and what is recorded, when a client asks to connect. Everything the client supplied (name, client ID,
|
|
2
|
+
// redirect) is shown as untrusted text: no control, format or separator characters, bounded length, and always labelled.
|
|
3
|
+
// Nothing here makes a trust decision. The name never selects a grant; only the owner's approval of one code does.
|
|
4
|
+
import { untrusted } from './as-files.mjs';
|
|
5
|
+
import { validateRedirectUri } from './redirect-policy.mjs';
|
|
6
|
+
import { displayFor } from './client-convenience.mjs';
|
|
7
|
+
|
|
8
|
+
const OWNER_ID = 'owner';
|
|
9
|
+
|
|
10
|
+
// A display model from one pairing. `resource` must already be the shortened form that hides the secret path.
|
|
11
|
+
export function describeClient({ name, clientId, redirectUri, worker, issuer, resource, scopes, code }) {
|
|
12
|
+
const policy = validateRedirectUri(redirectUri);
|
|
13
|
+
// Display only: a curated label for an exact, already validated HTTPS origin. It never feeds an approval decision.
|
|
14
|
+
const known = policy.ok ? displayFor(policy.uri) : null;
|
|
15
|
+
return {
|
|
16
|
+
code,
|
|
17
|
+
worker: untrusted(worker, 64),
|
|
18
|
+
client_name: untrusted(name, 80),
|
|
19
|
+
client_name_untrusted: true,
|
|
20
|
+
client_id: untrusted(clientId, 128),
|
|
21
|
+
redirect_uri: policy.ok ? policy.uri : untrusted(redirectUri, 512),
|
|
22
|
+
redirect_host: policy.ok ? policy.host : null,
|
|
23
|
+
redirect_origin: policy.ok ? policy.origin : null,
|
|
24
|
+
redirect_kind: policy.ok ? policy.kind : null,
|
|
25
|
+
redirect_punycode: policy.ok ? policy.punycode : false,
|
|
26
|
+
known_client: known ? untrusted(known.name, 80) : null,
|
|
27
|
+
issuer: untrusted(issuer, 256),
|
|
28
|
+
resource: untrusted(resource, 256),
|
|
29
|
+
scopes: [...scopes].map(scope => untrusted(scope, 64)),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Plain-text lines for the browser page (the caller escapes them for HTML).
|
|
34
|
+
export function approvalFacts(view) {
|
|
35
|
+
return [
|
|
36
|
+
['Client name (set by the app, not verified)', view.client_name || '(none)'],
|
|
37
|
+
...(view.known_client ? [['Known client (matched by redirect origin; a label only, not proof)', view.known_client]] : []),
|
|
38
|
+
['Redirect host', view.redirect_host ?? '(invalid)'],
|
|
39
|
+
['Full redirect', view.redirect_uri],
|
|
40
|
+
['Client ID', view.client_id],
|
|
41
|
+
['Worker', view.worker],
|
|
42
|
+
['Issuer', view.issuer],
|
|
43
|
+
['Resource', view.resource],
|
|
44
|
+
['Scopes', view.scopes.join(' ')],
|
|
45
|
+
...(view.redirect_punycode ? [['Note', 'The host contains punycode (xn--). It may look like another name when decoded.']] : []),
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// The record of one approval. The origin groups review and revocation only; it grants nothing to another client, path or port.
|
|
50
|
+
export function approvalRecord({ worker, issuer, resource, clientId, redirectUri, scopes, approvedAt, connectionId }) {
|
|
51
|
+
const policy = validateRedirectUri(redirectUri);
|
|
52
|
+
return {
|
|
53
|
+
ownerId: OWNER_ID, worker, issuer, resource, clientId,
|
|
54
|
+
redirectOrigin: policy.ok ? policy.origin : null, redirectUri, scopes: [...scopes],
|
|
55
|
+
approvedAt: new Date(approvedAt).toISOString(), connectionId,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// Display-only client conveniences: curated name, icon, setup hints and install links.
|
|
2
|
+
//
|
|
3
|
+
// This module is pure presentation. It imports no auth code and exports nothing that
|
|
4
|
+
// answers "may this client connect?". Callers must validate a redirect and make every
|
|
5
|
+
// approval decision first, then ask this module only how to label the result. Adding or
|
|
6
|
+
// deleting a data entry changes labels and nothing else.
|
|
7
|
+
//
|
|
8
|
+
// A deep link carries the owner's endpoint, which can contain a private path. The caller
|
|
9
|
+
// must show it behind an explicit Open action and must never log it or send it anywhere.
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
|
|
13
|
+
const readJson = (name) => JSON.parse(readFileSync(fileURLToPath(new URL(name, import.meta.url)), 'utf8'));
|
|
14
|
+
const SCHEMA = readJson('./client-conveniences.schema.json');
|
|
15
|
+
|
|
16
|
+
// ---- schema interpreter: the keyword subset used by client-conveniences.schema.json ----
|
|
17
|
+
|
|
18
|
+
const regexCache = new Map();
|
|
19
|
+
function regexFor(pattern) {
|
|
20
|
+
let re = regexCache.get(pattern);
|
|
21
|
+
if (!re) { re = new RegExp(pattern, 'u'); regexCache.set(pattern, re); }
|
|
22
|
+
return re;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function typeOf(v) {
|
|
26
|
+
if (v === null) return 'null';
|
|
27
|
+
if (Array.isArray(v)) return 'array';
|
|
28
|
+
return typeof v;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function resolveRef(ref) {
|
|
32
|
+
const m = /^#\/definitions\/([A-Za-z]+)$/.exec(ref);
|
|
33
|
+
const node = m && SCHEMA.definitions[m[1]];
|
|
34
|
+
if (!node) throw new Error('unsupported schema reference');
|
|
35
|
+
return node;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function check(node, value, path, errors) {
|
|
39
|
+
if (node.$ref) return check(resolveRef(node.$ref), value, path, errors);
|
|
40
|
+
if (node.oneOf) {
|
|
41
|
+
const passing = node.oneOf.filter((n) => { const e = []; check(n, value, path, e); return e.length === 0; });
|
|
42
|
+
if (passing.length !== 1) errors.push(`${path}: must match exactly one alternative`);
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
if ('const' in node && value !== node.const) { errors.push(`${path}: must equal ${JSON.stringify(node.const)}`); return undefined; }
|
|
46
|
+
if (node.enum && !node.enum.includes(value)) { errors.push(`${path}: not an allowed value`); return undefined; }
|
|
47
|
+
if (node.type && typeOf(value) !== node.type) { errors.push(`${path}: must be ${node.type}`); return undefined; }
|
|
48
|
+
if (node.type === 'string') {
|
|
49
|
+
if (node.minLength !== undefined && value.length < node.minLength) errors.push(`${path}: too short`);
|
|
50
|
+
if (node.maxLength !== undefined && value.length > node.maxLength) errors.push(`${path}: too long`);
|
|
51
|
+
if (node.pattern && !regexFor(node.pattern).test(value)) errors.push(`${path}: does not match the allowed form`);
|
|
52
|
+
} else if (node.type === 'array') {
|
|
53
|
+
if (node.maxItems !== undefined && value.length > node.maxItems) errors.push(`${path}: too many items`);
|
|
54
|
+
if (node.minItems !== undefined && value.length < node.minItems) errors.push(`${path}: too few items`);
|
|
55
|
+
if (node.uniqueItems && new Set(value).size !== value.length) errors.push(`${path}: items must be unique`);
|
|
56
|
+
if (node.items) value.forEach((v, i) => check(node.items, v, `${path}/${i}`, errors));
|
|
57
|
+
} else if (node.type === 'object') {
|
|
58
|
+
const props = node.properties ?? {};
|
|
59
|
+
for (const key of node.required ?? []) if (!Object.hasOwn(value, key)) errors.push(`${path}: missing ${key}`);
|
|
60
|
+
for (const key of Object.keys(value)) {
|
|
61
|
+
if (Object.hasOwn(props, key)) check(props[key], value[key], `${path}/${key}`, errors);
|
|
62
|
+
else if (node.additionalProperties === false) errors.push(`${path}: unknown field ${key}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const isRealDate = (s) => { const d = new Date(`${s}T00:00:00Z`); return !Number.isNaN(d.getTime()) && d.toISOString().slice(0, 10) === s; };
|
|
69
|
+
|
|
70
|
+
export function validateCatalog(catalog) {
|
|
71
|
+
const errors = [];
|
|
72
|
+
check(SCHEMA, catalog, '#', errors);
|
|
73
|
+
if (errors.length === 0) {
|
|
74
|
+
const ids = new Set();
|
|
75
|
+
const origins = new Map();
|
|
76
|
+
for (const c of catalog.clients) {
|
|
77
|
+
if (ids.has(c.id)) errors.push(`duplicate id ${c.id}`);
|
|
78
|
+
ids.add(c.id);
|
|
79
|
+
if (!isRealDate(c.evidence.checkedAt)) errors.push(`${c.id}: impossible evidence date`);
|
|
80
|
+
if (c.deepLink && !isRealDate(c.deepLink.checkedAt)) errors.push(`${c.id}: impossible link date`);
|
|
81
|
+
for (const o of c.verifiedRedirectOrigins) {
|
|
82
|
+
let normal = null;
|
|
83
|
+
try { normal = new URL(o).origin; } catch { /* reported below */ }
|
|
84
|
+
if (normal !== o) errors.push(`${c.id}: origin is not exact`);
|
|
85
|
+
if (origins.has(o)) errors.push(`${c.id}: origin already claimed by ${origins.get(o)}`);
|
|
86
|
+
origins.set(o, c.id);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return { ok: errors.length === 0, errors };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ---- helper ----
|
|
94
|
+
|
|
95
|
+
function deepFreeze(v) {
|
|
96
|
+
if (v && typeof v === 'object') { Object.values(v).forEach(deepFreeze); Object.freeze(v); }
|
|
97
|
+
return v;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const URL_MAX = 2048;
|
|
101
|
+
const UNSAFE_CHARS = /[\u0000- \u007f\\]/;
|
|
102
|
+
|
|
103
|
+
function parseHttps(value) {
|
|
104
|
+
if (typeof value !== 'string' || value.length === 0 || value.length > URL_MAX || UNSAFE_CHARS.test(value)) return null;
|
|
105
|
+
let u;
|
|
106
|
+
try { u = new URL(value); } catch { return null; }
|
|
107
|
+
if (u.protocol !== 'https:' || u.username || u.password || !u.hostname) return null;
|
|
108
|
+
return u;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function encodeConfig(encoding, endpoint, name) {
|
|
112
|
+
if (encoding === 'base64-json') {
|
|
113
|
+
return encodeURIComponent(Buffer.from(JSON.stringify({ url: endpoint }), 'utf8').toString('base64'));
|
|
114
|
+
}
|
|
115
|
+
return encodeURIComponent(JSON.stringify({ name, type: 'http', url: endpoint }));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function createConvenience(catalog) {
|
|
119
|
+
const verdict = validateCatalog(catalog);
|
|
120
|
+
if (!verdict.ok) throw new Error(`invalid client conveniences: ${verdict.errors[0]}`);
|
|
121
|
+
const clients = deepFreeze(structuredClone(catalog)).clients;
|
|
122
|
+
const byOrigin = new Map();
|
|
123
|
+
const byId = new Map();
|
|
124
|
+
for (const c of clients) {
|
|
125
|
+
byId.set(c.id, c);
|
|
126
|
+
for (const o of c.verifiedRedirectOrigins) byOrigin.set(o, c);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return Object.freeze({
|
|
130
|
+
// Call only after the redirect has passed the caller's own validation. Returns a fresh
|
|
131
|
+
// label object or null. Loopback, http and any origin not listed exactly get null.
|
|
132
|
+
displayFor(redirectUri) {
|
|
133
|
+
const u = parseHttps(redirectUri);
|
|
134
|
+
const c = u && byOrigin.get(u.origin);
|
|
135
|
+
return c ? { name: c.name, icon: c.icon, clientConvenienceId: c.id } : null;
|
|
136
|
+
},
|
|
137
|
+
hintsFor(id) {
|
|
138
|
+
const c = byId.get(id);
|
|
139
|
+
return c ? [...c.setupHints] : [];
|
|
140
|
+
},
|
|
141
|
+
listClients() {
|
|
142
|
+
return clients.map((c) => ({ id: c.id, name: c.name, icon: c.icon, setupHints: [...c.setupHints], hasDeepLink: c.deepLink !== null }));
|
|
143
|
+
},
|
|
144
|
+
// Returns {url, target, requiresExplicitOpen:true} or null. Never log or transmit url.
|
|
145
|
+
deepLinkFor(id, { endpoint, name } = {}) {
|
|
146
|
+
const c = byId.get(id);
|
|
147
|
+
if (!c || !c.deepLink) return null;
|
|
148
|
+
const target = parseHttps(endpoint);
|
|
149
|
+
if (!target || target.hash || typeof name !== 'string' || name.length === 0 || name.length > 200) return null;
|
|
150
|
+
const link = c.deepLink;
|
|
151
|
+
const url = link.template.replace(/\{(endpoint|name|config)\}/g, (_, key) => {
|
|
152
|
+
if (key === 'endpoint') return encodeURIComponent(endpoint);
|
|
153
|
+
if (key === 'name') return encodeURIComponent(name);
|
|
154
|
+
return encodeConfig(link.encoding, endpoint, name);
|
|
155
|
+
});
|
|
156
|
+
return { url, target: c.name, requiresExplicitOpen: true };
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const bundledCatalog = deepFreeze(readJson('./client-conveniences.json'));
|
|
162
|
+
const bundled = createConvenience(bundledCatalog);
|
|
163
|
+
export const displayFor = bundled.displayFor;
|
|
164
|
+
export const hintsFor = bundled.hintsFor;
|
|
165
|
+
export const listClients = bundled.listClients;
|
|
166
|
+
export const deepLinkFor = bundled.deepLinkFor;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"clients": [
|
|
4
|
+
{
|
|
5
|
+
"id": "chatgpt",
|
|
6
|
+
"name": "ChatGPT",
|
|
7
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMzAiIGZpbGw9IiMxMGEzN2YiLz48dGV4dCB4PSIzMiIgeT0iNDIiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iNzAwIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmaWxsPSIjZmZmIj5DPC90ZXh0Pjwvc3ZnPg==",
|
|
8
|
+
"verifiedRedirectOrigins": [
|
|
9
|
+
"https://chatgpt.com"
|
|
10
|
+
],
|
|
11
|
+
"deepLink": null,
|
|
12
|
+
"setupHints": [
|
|
13
|
+
"Open ChatGPT's custom connector setup. Menu names vary by plan and release.",
|
|
14
|
+
"Enter the complete MCP endpoint and choose OAuth with automatic (dynamic) client registration.",
|
|
15
|
+
"Compare the pairing code on the browser page with the code on the bridge computer before approving."
|
|
16
|
+
],
|
|
17
|
+
"evidence": {
|
|
18
|
+
"sourceUrl": "https://developers.openai.com/plugins/deploy/connect-chatgpt",
|
|
19
|
+
"checkedAt": "2026-11-12",
|
|
20
|
+
"runtimeTested": false
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "claude",
|
|
25
|
+
"name": "Claude",
|
|
26
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMzAiIGZpbGw9IiNkOTc3NTciLz48dGV4dCB4PSIzMiIgeT0iNDIiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iNzAwIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmaWxsPSIjZmZmIj5DPC90ZXh0Pjwvc3ZnPg==",
|
|
27
|
+
"verifiedRedirectOrigins": [
|
|
28
|
+
"https://claude.ai"
|
|
29
|
+
],
|
|
30
|
+
"deepLink": null,
|
|
31
|
+
"setupHints": [
|
|
32
|
+
"Open Customize, then Connectors, and add a custom connector.",
|
|
33
|
+
"Enter the complete MCP endpoint and choose Register automatically.",
|
|
34
|
+
"Compare the pairing code on the browser page with the code on the bridge computer before approving."
|
|
35
|
+
],
|
|
36
|
+
"evidence": {
|
|
37
|
+
"sourceUrl": "https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp",
|
|
38
|
+
"checkedAt": "2026-11-12",
|
|
39
|
+
"runtimeTested": false
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "muse",
|
|
44
|
+
"name": "Muse",
|
|
45
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMzAiIGZpbGw9IiM2ZDVkZmMiLz48dGV4dCB4PSIzMiIgeT0iNDIiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iNzAwIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmaWxsPSIjZmZmIj5NPC90ZXh0Pjwvc3ZnPg==",
|
|
46
|
+
"verifiedRedirectOrigins": [
|
|
47
|
+
"https://agent.meta.ai"
|
|
48
|
+
],
|
|
49
|
+
"deepLink": null,
|
|
50
|
+
"setupHints": [
|
|
51
|
+
"Add a remote MCP server in Muse and enter the complete MCP endpoint.",
|
|
52
|
+
"Start its OAuth sign-in and leave the Dalan sign-in page open.",
|
|
53
|
+
"Compare the pairing code on the browser page with the code on the bridge computer before approving."
|
|
54
|
+
],
|
|
55
|
+
"evidence": {
|
|
56
|
+
"sourceUrl": "https://agent.meta.ai/",
|
|
57
|
+
"checkedAt": "2026-11-12",
|
|
58
|
+
"runtimeTested": false
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"id": "cursor",
|
|
63
|
+
"name": "Cursor",
|
|
64
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMzAiIGZpbGw9IiMxZjI5MzciLz48dGV4dCB4PSIzMiIgeT0iNDIiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iNzAwIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmaWxsPSIjZmZmIj5DPC90ZXh0Pjwvc3ZnPg==",
|
|
65
|
+
"verifiedRedirectOrigins": [
|
|
66
|
+
"https://www.cursor.com"
|
|
67
|
+
],
|
|
68
|
+
"deepLink": {
|
|
69
|
+
"template": "cursor://anysphere.cursor-deeplink/mcp/install?name={name}&config={config}",
|
|
70
|
+
"encoding": "base64-json",
|
|
71
|
+
"sourceUrl": "https://cursor.com/docs/mcp/install-links",
|
|
72
|
+
"checkedAt": "2026-11-12"
|
|
73
|
+
},
|
|
74
|
+
"setupHints": [
|
|
75
|
+
"Open the install link on the computer that runs Cursor, review the server it adds, and install it.",
|
|
76
|
+
"Cursor shows its own sign-in prompt for the server. Compare the pairing code before approving."
|
|
77
|
+
],
|
|
78
|
+
"evidence": {
|
|
79
|
+
"sourceUrl": "https://cursor.com/docs/mcp/install-links",
|
|
80
|
+
"checkedAt": "2026-11-12",
|
|
81
|
+
"runtimeTested": false
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "vscode",
|
|
86
|
+
"name": "VS Code",
|
|
87
|
+
"icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMzAiIGZpbGw9IiMwMDdhY2MiLz48dGV4dCB4PSIzMiIgeT0iNDIiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iNzAwIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmaWxsPSIjZmZmIj5WPC90ZXh0Pjwvc3ZnPg==",
|
|
88
|
+
"verifiedRedirectOrigins": [],
|
|
89
|
+
"deepLink": {
|
|
90
|
+
"template": "vscode:mcp/install?{config}",
|
|
91
|
+
"encoding": "url-component",
|
|
92
|
+
"sourceUrl": "https://code.visualstudio.com/api/extension-guides/ai/mcp",
|
|
93
|
+
"checkedAt": "2026-11-12"
|
|
94
|
+
},
|
|
95
|
+
"setupHints": [
|
|
96
|
+
"Open the install link on the computer that runs VS Code. It opens the server editor so you can review the configuration first.",
|
|
97
|
+
"Start the server from VS Code and finish its sign-in. Compare the pairing code before approving."
|
|
98
|
+
],
|
|
99
|
+
"evidence": {
|
|
100
|
+
"sourceUrl": "https://code.visualstudio.com/api/extension-guides/ai/mcp",
|
|
101
|
+
"checkedAt": "2026-11-12",
|
|
102
|
+
"runtimeTested": false
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://github.com/tnunamak/dalan/src/client-conveniences.schema.json",
|
|
4
|
+
"title": "Dalan client conveniences",
|
|
5
|
+
"description": "Display-only hints for known MCP clients: curated name, icon, setup steps and an optional install link. Nothing in this file selects, allows or denies any client; it holds no auth settings.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": ["schemaVersion", "clients"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"schemaVersion": { "const": 1 },
|
|
11
|
+
"clients": {
|
|
12
|
+
"type": "array",
|
|
13
|
+
"maxItems": 64,
|
|
14
|
+
"items": { "$ref": "#/definitions/client" }
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"definitions": {
|
|
18
|
+
"client": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"required": ["id", "name", "icon", "verifiedRedirectOrigins", "deepLink", "setupHints", "evidence"],
|
|
22
|
+
"properties": {
|
|
23
|
+
"id": { "type": "string", "pattern": "^[a-z][a-z0-9-]{0,31}$" },
|
|
24
|
+
"name": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9 .+_-]{0,59}$" },
|
|
25
|
+
"icon": {
|
|
26
|
+
"description": "Inline data: image or a local icons/ path. Never a remote URL.",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"maxLength": 20000,
|
|
29
|
+
"pattern": "^(?:data:image/(?:png|svg\\+xml|webp|jpeg|gif);base64,[A-Za-z0-9+/]+={0,2}|icons/[a-z0-9][a-z0-9._-]*\\.(?:png|svg|webp))$"
|
|
30
|
+
},
|
|
31
|
+
"verifiedRedirectOrigins": {
|
|
32
|
+
"description": "Exact HTTPS origins only: no path, port 443, credentials, query, fragment, wildcard, regex, IP address or localhost.",
|
|
33
|
+
"type": "array",
|
|
34
|
+
"maxItems": 8,
|
|
35
|
+
"uniqueItems": true,
|
|
36
|
+
"items": { "$ref": "#/definitions/httpsOrigin" }
|
|
37
|
+
},
|
|
38
|
+
"deepLink": {
|
|
39
|
+
"oneOf": [{ "type": "null" }, { "$ref": "#/definitions/deepLink" }]
|
|
40
|
+
},
|
|
41
|
+
"setupHints": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"maxItems": 8,
|
|
44
|
+
"items": { "$ref": "#/definitions/hint" }
|
|
45
|
+
},
|
|
46
|
+
"evidence": { "$ref": "#/definitions/evidence" }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"httpsOrigin": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"maxLength": 262,
|
|
52
|
+
"pattern": "^https://(?!\\d+\\.\\d+\\.\\d+\\.\\d+(?::|$))(?![^:]*:443$)[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+(?::(?:[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$"
|
|
53
|
+
},
|
|
54
|
+
"deepLink": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"additionalProperties": false,
|
|
57
|
+
"required": ["template", "encoding", "sourceUrl", "checkedAt"],
|
|
58
|
+
"properties": {
|
|
59
|
+
"template": {
|
|
60
|
+
"description": "App-scheme URL. The only placeholders are {endpoint}, {name} and {config}. Web schemes are refused because they would send the endpoint to a remote server.",
|
|
61
|
+
"type": "string",
|
|
62
|
+
"maxLength": 512,
|
|
63
|
+
"pattern": "^(?!(?:https?|javascript|data|file|vbscript|blob|ftp|wss?):)(?=.*\\{(?:endpoint|name|config)\\})[a-z][a-z0-9+.-]*:(?:[^\\s{}$]|\\{(?:endpoint|name|config)\\})*$"
|
|
64
|
+
},
|
|
65
|
+
"encoding": { "enum": ["url-component", "base64-json"] },
|
|
66
|
+
"sourceUrl": { "$ref": "#/definitions/sourceUrl" },
|
|
67
|
+
"checkedAt": { "$ref": "#/definitions/isoDate" }
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"hint": {
|
|
71
|
+
"description": "Plain text. No markup, control characters, links, or words that suggest credentials.",
|
|
72
|
+
"type": "string",
|
|
73
|
+
"minLength": 1,
|
|
74
|
+
"maxLength": 300,
|
|
75
|
+
"pattern": "^(?!.*://)(?!.*(?:[Aa]uthorization|AUTHORIZATION|[Bb]earer|BEARER|[Tt]oken|TOKEN|[Ss]ecret|SECRET|[Pp]assword|PASSWORD))[^\\u0000-\\u001f\\u007f<>\\[\\]`]+$"
|
|
76
|
+
},
|
|
77
|
+
"evidence": {
|
|
78
|
+
"type": "object",
|
|
79
|
+
"additionalProperties": false,
|
|
80
|
+
"required": ["sourceUrl", "checkedAt", "runtimeTested"],
|
|
81
|
+
"properties": {
|
|
82
|
+
"sourceUrl": { "$ref": "#/definitions/sourceUrl" },
|
|
83
|
+
"checkedAt": { "$ref": "#/definitions/isoDate" },
|
|
84
|
+
"runtimeTested": { "type": "boolean" }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"sourceUrl": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"maxLength": 512,
|
|
90
|
+
"pattern": "^https://[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?::[0-9]{1,5})?(?:/[^\\s]*)?$"
|
|
91
|
+
},
|
|
92
|
+
"isoDate": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"pattern": "^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
package/src/connect-cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { assertPrivateDir, untrusted, writeAtomic } from './as-files.mjs';
|
|
5
5
|
import { normalizeCode, PAIRING_MINUTES } from './as-files.mjs';
|
|
6
|
-
|
|
6
|
+
const WAKE_POLL_SECONDS = 60;
|
|
7
7
|
|
|
8
8
|
// `dalan connect ...`: the owner's side of the built-in authorization server. Every call goes through the owner Unix
|
|
9
9
|
// socket with the operator key; none of it exists on the public listener.
|
|
@@ -18,7 +18,7 @@ export function formatPending(result) {
|
|
|
18
18
|
if (!result.pending.length) lines.push('No pending connections.');
|
|
19
19
|
for (const p of result.pending) {
|
|
20
20
|
lines.push('', `code ${p.code}`, `worker ${p.worker}`, `client_id ${q(p.client_id)}`, `client_name [untrusted, set by the app] ${q(p.client_name)}`,
|
|
21
|
-
`redirect ${q(p.redirect_uri)}`, `resource ${q(p.resource)}`, `scopes ${p.scopes.map(q).join(' ')}`, `age ${p.age_seconds}s (expires in ${p.expires_in_seconds}s)`,
|
|
21
|
+
`redirect ${q(p.redirect_uri)}`, ...(p.redirect_host ? [`host ${q(p.redirect_host)} (the redirect host; the app name above proves nothing)`] : []), ...(p.known_client ? [`known ${q(p.known_client)} (label from the redirect origin only; it proves nothing)`] : []), ...(p.redirect_punycode ? ['WARNING the host contains punycode (xn--); it may look like another name when decoded'] : []), `resource ${q(p.resource)}`, `scopes ${p.scopes.map(q).join(' ')}`, `age ${p.age_seconds}s (expires in ${p.expires_in_seconds}s)`,
|
|
22
22
|
...(p.superseded ? [`SUPERSEDED by the newer attempt ${p.superseded_by}; an app that registered again cannot finish this one, so approve the newest code`] : []),
|
|
23
23
|
...(p.native ? ['WARNING native client, identity not verified: host and name prove nothing; teammate must read this code from the browser page on their own machine and compare it over a trusted channel', ' redirect confirmation is a typo check only; it is not identity proof', `APPROVE dalan connect approve ${p.code} --worker ${p.worker} (approves this code only; other pending codes are unaffected. A native client also needs the exact redirect shown above.)`] : []));
|
|
24
24
|
}
|
|
@@ -109,15 +109,15 @@ export async function connectCommand(args, { request, operator, option, json })
|
|
|
109
109
|
case 'signal-token': {
|
|
110
110
|
if (positional.length || args.some((arg, i) => arg !== '--json' && arg !== '--rotate' && arg !== '--worker' && args[i - 1] !== '--worker')) throw new Error(USAGE);
|
|
111
111
|
const result = await request('/connect/signal-token', 'POST', { rotate: args.includes('--rotate'), ...(worker ? { worker } : {}) }, headers());
|
|
112
|
-
// The poll interval
|
|
113
|
-
const seconds =
|
|
112
|
+
// The poll interval is advice for the hook owner; it is set in the hook, not on the bridge.
|
|
113
|
+
const seconds = WAKE_POLL_SECONDS;
|
|
114
114
|
const dir = defaultPath(os.homedir(),'.config/dot-bridge');
|
|
115
115
|
assertPrivateDir(dir);
|
|
116
116
|
const file = path.join(dir, `signal-url.${result.worker}`);
|
|
117
117
|
writeAtomic(file, `${result.url}\n`);
|
|
118
118
|
// stdout contains only the private file path; the hook owner can read it without exposing the URL in logs.
|
|
119
119
|
if (json) return { result: { path: file, worker: result.worker, rotated: result.rotated, poll_interval_seconds: seconds } };
|
|
120
|
-
process.stderr.write(`Hook poll interval: ${seconds} s or more.
|
|
120
|
+
process.stderr.write(`Hook poll interval: ${seconds} s or more. Do not poll faster than every 60 s.\n`);
|
|
121
121
|
return { result: file, plain: true };
|
|
122
122
|
}
|
|
123
123
|
case 'allow-callback': if (positional.length !== 1) throw new Error(USAGE); return { result: await request('/connect/allow-callback', 'POST', { pattern: positional[0] }, headers()) };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The one default bridge home. `dalan service install` records it in a small pointer file; every other command reads it, so nobody
|
|
2
|
+
// exports DALAN_HOME. DALAN_HOME still wins when it is set. The pointer lives in the real user's config directory, never in the home it names.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { writeAtomic } from './as-files.mjs';
|
|
7
|
+
|
|
8
|
+
export const DEFAULT_SERVICE_HOME = '.local/share/dalan-service';
|
|
9
|
+
export const homePointerPath = (env = process.env) => path.join(env.XDG_CONFIG_HOME && path.isAbsolute(env.XDG_CONFIG_HOME) ? env.XDG_CONFIG_HOME : path.join(env.HOME || os.homedir(), '.config'), 'dalan', 'home');
|
|
10
|
+
|
|
11
|
+
// The recorded home, or null when none is recorded or the record is not a usable bridge home (absolute, a real directory with a Dalan config).
|
|
12
|
+
export function readDefaultHome(env = process.env) {
|
|
13
|
+
let text;
|
|
14
|
+
try { text = fs.readFileSync(homePointerPath(env), 'utf8'); } catch { return null; }
|
|
15
|
+
const home = text.trim();
|
|
16
|
+
if (!home || home.includes('\n') || !path.isAbsolute(home) || path.resolve(home) !== home) return null;
|
|
17
|
+
try { if (!fs.statSync(path.join(home, '.config')).isDirectory()) return null; } catch { return null; }
|
|
18
|
+
return home;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function recordDefaultHome(home, env = process.env) {
|
|
22
|
+
if (!path.isAbsolute(home)) throw new Error('the default home must be an absolute path');
|
|
23
|
+
const file = homePointerPath(env);
|
|
24
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
25
|
+
writeAtomic(file, `${path.resolve(home)}\n`);
|
|
26
|
+
fs.chmodSync(file, 0o600);
|
|
27
|
+
return file;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function forgetDefaultHome(home, env = process.env) {
|
|
31
|
+
const file = homePointerPath(env);
|
|
32
|
+
try { if (fs.readFileSync(file, 'utf8').trim() === path.resolve(home)) fs.rmSync(file); } catch { /* nothing recorded */ }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// DALAN_HOME, then the recorded home, then the service default. `service` commands use this for --home.
|
|
36
|
+
export const serviceHomeFor = (env = process.env) => path.resolve(env.DALAN_HOME || readDefaultHome(env) || path.join(env.HOME || os.homedir(), DEFAULT_SERVICE_HOME));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// The `dalan` on PATH is whichever package npm installed first. After the updater installs newer versions side by side under the service home,
|
|
2
|
+
// the CLI must run the version the service runs, or the two drift. This runs the service's `current` package instead of this one.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { readDefaultHome } from './default-home.mjs';
|
|
7
|
+
|
|
8
|
+
const real = file => { try { return fs.realpathSync(file); } catch { return null; } };
|
|
9
|
+
|
|
10
|
+
// The entry script to hand over to, or null to stay in this package. `ownBin` is this package's bin/dalan.mjs.
|
|
11
|
+
export function followTarget({ ownBin, env = process.env }) {
|
|
12
|
+
if (env.DALAN_NO_FOLLOW === '1' || env.DALAN_FOLLOWED === '1') return null;
|
|
13
|
+
const home = env.DALAN_HOME ? path.resolve(env.DALAN_HOME) : readDefaultHome(env);
|
|
14
|
+
if (!home) return null;
|
|
15
|
+
const target = real(path.join(home, 'current', 'bin', 'dalan.mjs')), own = real(ownBin);
|
|
16
|
+
return target && own && target !== own ? target : null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Runs the other package with the same arguments and exits with its status. Never returns.
|
|
20
|
+
export function handOver(target, { argv = process.argv.slice(2), env = process.env } = {}) {
|
|
21
|
+
const child = spawn(process.execPath, [target, ...argv], { stdio: 'inherit', env: { ...env, DALAN_FOLLOWED: '1' } });
|
|
22
|
+
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) process.on(signal, () => child.kill(signal));
|
|
23
|
+
child.on('error', error => { process.stderr.write(`dalan: could not run the service's current version (${error.message}); set DALAN_NO_FOLLOW=1 to use this copy\n`); process.exit(1); });
|
|
24
|
+
child.on('exit', (code, signal) => { if (signal) { process.removeAllListeners(signal); process.kill(process.pid, signal); } else process.exit(code ?? 1); });
|
|
25
|
+
}
|