vit 0.6.3 → 0.6.4
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/package.json +1 -1
- package/src/cmd/doctor.js +9 -0
- package/src/cmd/init.js +15 -1
- package/src/cmd/remix.js +10 -5
- package/src/cmd/vet.js +10 -5
- package/src/lib/beacon.js +19 -0
package/package.json
CHANGED
package/src/cmd/doctor.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { loadConfig } from '../lib/config.js';
|
|
5
5
|
import { restoreAgent } from '../lib/oauth.js';
|
|
6
6
|
import { readProjectConfig } from '../lib/vit-dir.js';
|
|
7
|
+
import { looksLikeIdentityBeacon } from '../lib/beacon.js';
|
|
7
8
|
import { existsSync, lstatSync, readdirSync, readFileSync } from 'node:fs';
|
|
8
9
|
import { join } from 'node:path';
|
|
9
10
|
import { homedir } from 'node:os';
|
|
@@ -94,11 +95,18 @@ export default function register(program) {
|
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
let beaconIdentityWarning = false;
|
|
97
99
|
try {
|
|
98
100
|
const projConfig = readProjectConfig();
|
|
99
101
|
beacon = projConfig.beacon || null;
|
|
100
102
|
if (projConfig.beacon) {
|
|
101
103
|
if (!opts.json) console.log(`${mark} beacon: ${projConfig.beacon}`);
|
|
104
|
+
if (looksLikeIdentityBeacon(projConfig.beacon)) {
|
|
105
|
+
beaconIdentityWarning = true;
|
|
106
|
+
if (!opts.json) {
|
|
107
|
+
console.log(`${mark} beacon looks like a person/identity URL, not a repo URL -- every repo hosted the same way would collapse onto this one beacon. Run vit init --beacon <the repo's own URL> to repair it.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
102
110
|
} else {
|
|
103
111
|
if (!opts.json) console.log(`${mark} beacon: not set (run vit init)`);
|
|
104
112
|
}
|
|
@@ -202,6 +210,7 @@ export default function register(program) {
|
|
|
202
210
|
bluesky: { ok: blueskyOk, did: effectiveDid || null, pds, source: identitySource, authType },
|
|
203
211
|
};
|
|
204
212
|
if (beaconError) result.beaconError = beaconError;
|
|
213
|
+
if (beaconIdentityWarning) result.beaconIdentityWarning = true;
|
|
205
214
|
jsonOk(result);
|
|
206
215
|
}
|
|
207
216
|
if (beaconError) process.exitCode = 1;
|
package/src/cmd/init.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { existsSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { execSync } from 'node:child_process';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
-
import { normalizeBeacon, tryNormalizeBeacon } from '../lib/beacon.js';
|
|
7
|
+
import { normalizeBeacon, tryNormalizeBeacon, looksLikeIdentityBeacon } from '../lib/beacon.js';
|
|
8
8
|
import { vitDir, readProjectConfig, readRawProjectConfig, writeProjectConfig } from '../lib/vit-dir.js';
|
|
9
9
|
import { requireAgent } from '../lib/agent.js';
|
|
10
10
|
import { mark, name, DOT_VIT_README } from '../lib/brand.js';
|
|
@@ -12,6 +12,17 @@ import { jsonOk, jsonError } from '../lib/json-output.js';
|
|
|
12
12
|
import { errorMessage, formatError } from '../lib/error-format.js';
|
|
13
13
|
|
|
14
14
|
const BEACON_REPAIR_HINT = 'run vit init --beacon <canonical-git-url> to repair it';
|
|
15
|
+
const IDENTITY_BEACON_HINT = 'use the repo\'s own URL, not a bare host+identity URL (e.g. a Tangled knot URL with no repo path)';
|
|
16
|
+
|
|
17
|
+
function assertNotIdentityBeacon(beacon, source) {
|
|
18
|
+
if (!looksLikeIdentityBeacon(beacon)) return;
|
|
19
|
+
const err = new Error(
|
|
20
|
+
`${source} looks like a person/identity URL, not a repo URL (derived beacon: ${beacon}). ` +
|
|
21
|
+
'Every repo hosted the same way would collapse onto this one beacon.'
|
|
22
|
+
);
|
|
23
|
+
err.hint = IDENTITY_BEACON_HINT;
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
15
26
|
|
|
16
27
|
export default function register(program) {
|
|
17
28
|
program
|
|
@@ -176,6 +187,7 @@ export default function register(program) {
|
|
|
176
187
|
throw err;
|
|
177
188
|
}
|
|
178
189
|
const secondary = normalizeBeacon(opts.secondary, '--secondary');
|
|
190
|
+
assertNotIdentityBeacon(secondary, '--secondary');
|
|
179
191
|
const merged = { ...config, beacon: primary, secondaryBeacon: secondary };
|
|
180
192
|
writeProjectConfig(merged);
|
|
181
193
|
if (opts.json) {
|
|
@@ -226,11 +238,13 @@ export default function register(program) {
|
|
|
226
238
|
}
|
|
227
239
|
|
|
228
240
|
const beacon = normalizeBeacon(gitUrl, '--beacon');
|
|
241
|
+
assertNotIdentityBeacon(beacon, '--beacon');
|
|
229
242
|
if (verbose) vlog(`[verbose] Computed beacon: ${beacon}`);
|
|
230
243
|
const existing = readRawProjectConfig();
|
|
231
244
|
const merged = { ...existing, beacon };
|
|
232
245
|
if (opts.secondary) {
|
|
233
246
|
merged.secondaryBeacon = normalizeBeacon(opts.secondary, '--secondary');
|
|
247
|
+
assertNotIdentityBeacon(merged.secondaryBeacon, '--secondary');
|
|
234
248
|
} else if (Object.hasOwn(existing, 'secondaryBeacon')) {
|
|
235
249
|
// Tolerant normalization is deliberate on this repair path: an invalid secondary
|
|
236
250
|
// must be dropped with a warning, not block repair of the primary beacon.
|
package/src/cmd/remix.js
CHANGED
|
@@ -115,12 +115,17 @@ export default function register(program) {
|
|
|
115
115
|
let match = null;
|
|
116
116
|
for (const records of allRecords) {
|
|
117
117
|
for (const rec of records) {
|
|
118
|
-
if (!beaconSet.has(tryNormalizeBeacon(rec.value.beacon))) continue;
|
|
119
118
|
const recRef = resolveRef(rec.value, rec.cid);
|
|
120
|
-
if (recRef
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
if (recRef !== ref) continue;
|
|
120
|
+
// Your own caps are exempt from the project-beacon filter: the beacon
|
|
121
|
+
// scopes which OTHER accounts' caps a project will trust, but you
|
|
122
|
+
// already unconditionally query your own DID regardless of following
|
|
123
|
+
// -- there's no equivalent trust question about your own content, and
|
|
124
|
+
// the error hint below has always promised this ("and your own").
|
|
125
|
+
const isSelf = rec.uri?.split('/')[2] === did;
|
|
126
|
+
if (!isSelf && !beaconSet.has(tryNormalizeBeacon(rec.value.beacon))) continue;
|
|
127
|
+
if (!match || (rec.value.createdAt || '') > (match.value.createdAt || '')) {
|
|
128
|
+
match = rec;
|
|
124
129
|
}
|
|
125
130
|
}
|
|
126
131
|
}
|
package/src/cmd/vet.js
CHANGED
|
@@ -291,12 +291,17 @@ export default function register(program) {
|
|
|
291
291
|
let match = null;
|
|
292
292
|
for (const records of allRecords) {
|
|
293
293
|
for (const rec of records) {
|
|
294
|
-
if (!beaconSet.has(tryNormalizeBeacon(rec.value.beacon))) continue;
|
|
295
294
|
const recRef = resolveRef(rec.value, rec.cid);
|
|
296
|
-
if (recRef
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
295
|
+
if (recRef !== ref) continue;
|
|
296
|
+
// Your own caps are exempt from the project-beacon filter: the beacon
|
|
297
|
+
// scopes which OTHER accounts' caps a project will trust, but you
|
|
298
|
+
// already unconditionally query your own DID regardless of following
|
|
299
|
+
// -- there's no equivalent trust question about your own content, and
|
|
300
|
+
// the error hint below has always promised this ("and your own").
|
|
301
|
+
const isSelf = rec.uri?.split('/')[2] === did;
|
|
302
|
+
if (!isSelf && !beaconSet.has(tryNormalizeBeacon(rec.value.beacon))) continue;
|
|
303
|
+
if (!match || (rec.value.createdAt || '') > (match.value.createdAt || '')) {
|
|
304
|
+
match = rec;
|
|
300
305
|
}
|
|
301
306
|
}
|
|
302
307
|
}
|
package/src/lib/beacon.js
CHANGED
|
@@ -86,6 +86,25 @@ function toBeacon(input) {
|
|
|
86
86
|
return org ? `${host}/${org}/${repo}` : `${host}//${repo}`;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
const DID_LIKE = /^did:[a-z0-9]+:/i;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* True when a canonical beacon's org or repo segment looks like an AT Protocol DID
|
|
93
|
+
* rather than a real repository name -- the shape produced when a bare identity URL
|
|
94
|
+
* (e.g. a Tangled *knot* host plus a DID, with no repo path) is fed to `vit init`
|
|
95
|
+
* instead of the actual repo URL. A beacon in this shape identifies a person, not a
|
|
96
|
+
* project, so every repo that person hosts the same mistaken way collapses onto one
|
|
97
|
+
* indistinguishable beacon.
|
|
98
|
+
*/
|
|
99
|
+
export function looksLikeIdentityBeacon(beacon) {
|
|
100
|
+
if (typeof beacon !== 'string') return false;
|
|
101
|
+
const body = beacon.startsWith('vit:') ? beacon.slice(4) : beacon;
|
|
102
|
+
const slash = body.indexOf('/');
|
|
103
|
+
if (slash === -1) return false;
|
|
104
|
+
const segments = body.slice(slash + 1).split('/').filter(Boolean);
|
|
105
|
+
return segments.some(seg => DID_LIKE.test(seg));
|
|
106
|
+
}
|
|
107
|
+
|
|
89
108
|
export const BEACON_ACCEPTED_FORMS = 'vit:host/owner/repo or a git URL (a scheme URL such as https://host/owner/repo, ssh://git@host/owner/repo, or git://host/owner/repo; SCP-style git@host:owner/repo; or host/owner/repo)';
|
|
90
109
|
|
|
91
110
|
export function normalizeBeacon(input, source) {
|