Skip to content

Commit c1fe422

Browse files
Address copilot pass 4 on #2
- lib/lws-cid.js: VM controllers are now compared against the profile's declared `controller` (absolutized), with fallback to `@id`. The previous code used `@id` unconditionally, which would incorrectly fail otherwise-valid delegated-control profiles. Also fixes the converse: a delegated profile with VMs still pointing at the original WebID now correctly fails (verified with a mismatched test case). - doctor.css + doctor.js: copy-status no longer renders error text in the success color. Added `.success` and `.error` modifier classes with a neutral default; click handler sets the appropriate one.
1 parent 9894984 commit c1fe422

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

doctor.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,10 @@ a { color: var(--accent); }
266266
.add-key .copy-status {
267267
margin-left: 10px;
268268
font-size: 12px;
269-
color: var(--pass);
269+
color: var(--muted);
270270
}
271+
.add-key .copy-status.success { color: var(--pass); }
272+
.add-key .copy-status.error { color: var(--fail); }
271273

272274
.kv {
273275
display: grid;

doctor.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ function clearSignerOutput() {
193193
snippetTarget.textContent = '';
194194
connectButton.textContent = 'Connect signer';
195195
copyStatus.textContent = '';
196+
copyStatus.className = 'copy-status';
196197
}
197198

198199
function detectSigner() {
@@ -255,11 +256,16 @@ function renderSnippet(xOnlyHex, webId, docUrl) {
255256
copyButton.addEventListener('click', async () => {
256257
try {
257258
await navigator.clipboard.writeText(snippetEl.textContent);
259+
copyStatus.className = 'copy-status success';
258260
copyStatus.textContent = 'Copied.';
259261
} catch (err) {
262+
copyStatus.className = 'copy-status error';
260263
copyStatus.textContent = `Couldn't copy: ${err.message || err}`;
261264
}
262-
setTimeout(() => { copyStatus.textContent = ''; }, 2500);
265+
setTimeout(() => {
266+
copyStatus.textContent = '';
267+
copyStatus.className = 'copy-status';
268+
}, 2500);
263269
});
264270

265271
function renderChecks(checks) {

lib/lws-cid.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,19 @@ export function runLwsCidChecks(profile, { webIdUrl }) {
128128
});
129129

130130
// Entry-level checks. VM controllers are compared against the
131-
// profile's @id (with fragment if present) — that matches the CID
132-
// v1 self-control pattern where the outer profile.controller is
133-
// also the WebID itself, not the bare document URL.
134-
const profileIdAbs = absolutize(id, requestedNoHash);
131+
// profile's declared `controller` (absolutized), with a fallback
132+
// to `@id`. Most profiles are self-controlled (controller === @id)
133+
// so the two are equal; for delegated-control profiles, VMs are
134+
// expected to be controlled by whoever the profile says controls
135+
// it, not by the WebID itself.
136+
const expectedCtrlSource = controller !== undefined
137+
? (typeof controller === 'string' ? controller : controller['@id'])
138+
: id;
139+
const expectedCtrl = absolutize(expectedCtrlSource, requestedNoHash);
135140
const seenIds = new Set();
136141
let allOk = true;
137142
for (const [i, vm] of vms.entries()) {
138-
const probs = validateVerificationMethod(vm, requestedNoHash, profileIdAbs);
143+
const probs = validateVerificationMethod(vm, requestedNoHash, expectedCtrl);
139144
if (probs.length === 0) continue;
140145
allOk = false;
141146
out.push({

0 commit comments

Comments
 (0)