javascript-solid-server 0.0.219 → 0.0.220
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
CHANGED
|
@@ -492,13 +492,26 @@ export async function resolveDidNostrLocally(pubkeyHex) {
|
|
|
492
492
|
* Multikey value is computed deterministically from the pubkey via
|
|
493
493
|
* the f-form recipe (multibase `f` + multicodec `e701` + parity byte
|
|
494
494
|
* `02` + 32-byte xonly hex) — the same shape the doctor's B.2 emits.
|
|
495
|
+
*
|
|
496
|
+
* `@context` MUST lead with the DID Core context — DID Core requires
|
|
497
|
+
* the first value to be `https://www.w3.org/ns/did/v1`, and did:nostr
|
|
498
|
+
* 0.1.1 adopted that ordering (nostrcg/did-nostr#136, fixed by #139).
|
|
499
|
+
* `cid/v1` still follows it, because this document's Multikey
|
|
500
|
+
* verification method comes from the Controlled Identifiers
|
|
501
|
+
* vocabulary. The ordering is normative only for DID documents, so
|
|
502
|
+
* standalone CID resources (src/keys/provision.js) and WebID profiles
|
|
503
|
+
* (src/webid/profile.js) correctly keep `cid/v1` alone.
|
|
495
504
|
*/
|
|
496
505
|
function buildDidDocument({ pubkey, webId }) {
|
|
497
506
|
const did = `did:nostr:${pubkey.toLowerCase()}`;
|
|
498
507
|
const multikey = `f` + `e701` + `02` + pubkey.toLowerCase();
|
|
499
508
|
const vmId = `${did}#key1`;
|
|
500
509
|
return {
|
|
501
|
-
'@context': [
|
|
510
|
+
'@context': [
|
|
511
|
+
'https://www.w3.org/ns/did/v1',
|
|
512
|
+
'https://www.w3.org/ns/cid/v1',
|
|
513
|
+
'https://w3id.org/nostr/context',
|
|
514
|
+
],
|
|
502
515
|
'id': did,
|
|
503
516
|
'type': 'DIDNostr',
|
|
504
517
|
'alsoKnownAs': [webId],
|
package/src/server.js
CHANGED
|
@@ -578,6 +578,14 @@ export function createServer(options = {}) {
|
|
|
578
578
|
return;
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
+
// App plugins own their prefix (#206) — a plugin mounted at a dot path
|
|
582
|
+
// (e.g. the webrtc plugin at /.webrtc, matching core's historical URL)
|
|
583
|
+
// must stay reachable, exactly as the WAC hook already defers to
|
|
584
|
+
// appPaths. Read per request: plugin activation pushes entries.
|
|
585
|
+
if (appPaths.some(p => urlNoQuery === p || urlNoQuery.startsWith(p + '/'))) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
|
|
581
589
|
// Only inspect the path component — splitting the full URL on '/'
|
|
582
590
|
// would catch dot-prefixed segments inside query-string values
|
|
583
591
|
// (e.g. /proxy?url=https://example.com/.git/config), rejecting
|
package/test/plugins.test.js
CHANGED
|
@@ -177,6 +177,32 @@ describe('plugin loader (#206)', () => {
|
|
|
177
177
|
assert.ok([401, 403].includes(res.status), `expected WAC rejection, got ${res.status}`);
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
+
it('a plugin mounted at a dot prefix stays reachable (dotfile guard defers to the mount)', async () => {
|
|
181
|
+
// The webrtc plugin replaces core's wss://pod/.webrtc at the same URL,
|
|
182
|
+
// so a dot prefix must reach the app — HTTP and ws.route alike — while
|
|
183
|
+
// unrelated dotfiles keep the 403 guard.
|
|
184
|
+
await startWith([
|
|
185
|
+
{ module: `${FIXTURE_DIR}/fixture-plugin.js`, prefix: '/.myapp' },
|
|
186
|
+
]);
|
|
187
|
+
const res = await fetch(`${baseUrl}/.myapp/echo`, { method: 'POST' });
|
|
188
|
+
assert.strictEqual(res.status, 200);
|
|
189
|
+
assert.strictEqual((await res.json()).app, true);
|
|
190
|
+
const ws = new WebSocket(`${baseUrl.replace('http', 'ws')}/.myapp/ws`);
|
|
191
|
+
await new Promise((resolve, reject) => {
|
|
192
|
+
ws.on('open', resolve);
|
|
193
|
+
ws.on('error', reject);
|
|
194
|
+
});
|
|
195
|
+
const reply = await new Promise((resolve, reject) => {
|
|
196
|
+
ws.on('message', (data) => resolve(String(data)));
|
|
197
|
+
ws.on('error', reject);
|
|
198
|
+
ws.send('hello');
|
|
199
|
+
});
|
|
200
|
+
assert.strictEqual(reply, 'pong:hello');
|
|
201
|
+
ws.close();
|
|
202
|
+
const guarded = await fetch(`${baseUrl}/.env`);
|
|
203
|
+
assert.strictEqual(guarded.status, 403);
|
|
204
|
+
});
|
|
205
|
+
|
|
180
206
|
it('a plugin that cannot be imported fails listen() loudly', async () => {
|
|
181
207
|
await fs.emptyDir(TEST_DATA_DIR);
|
|
182
208
|
server = createServer({
|
|
@@ -129,7 +129,11 @@ describe('GET /.well-known/did/nostr/:pubkey (#407)', () => {
|
|
|
129
129
|
assert.ok(r.headers.get('last-modified'));
|
|
130
130
|
|
|
131
131
|
const doc = await r.json();
|
|
132
|
-
assert.deepStrictEqual(doc['@context'], [
|
|
132
|
+
assert.deepStrictEqual(doc['@context'], [
|
|
133
|
+
'https://www.w3.org/ns/did/v1',
|
|
134
|
+
'https://www.w3.org/ns/cid/v1',
|
|
135
|
+
'https://w3id.org/nostr/context',
|
|
136
|
+
]);
|
|
133
137
|
assert.strictEqual(doc.id, `did:nostr:${alicePk}`);
|
|
134
138
|
assert.strictEqual(doc.type, 'DIDNostr');
|
|
135
139
|
assert.ok(Array.isArray(doc.alsoKnownAs));
|
|
@@ -139,6 +143,26 @@ describe('GET /.well-known/did/nostr/:pubkey (#407)', () => {
|
|
|
139
143
|
assert.strictEqual(doc.authentication[0], `did:nostr:${alicePk}#key1`);
|
|
140
144
|
});
|
|
141
145
|
|
|
146
|
+
it('leads @context with the DID Core context (did:nostr 0.1.1)', async () => {
|
|
147
|
+
// DID Core requires a DID document's @context to lead with
|
|
148
|
+
// https://www.w3.org/ns/did/v1; did:nostr 0.1.1 adopted that ordering
|
|
149
|
+
// (nostrcg/did-nostr#136 → #139). Asserted separately from the
|
|
150
|
+
// full-shape check above so a reordering regression names itself.
|
|
151
|
+
const r = await fetch(`${baseUrl}/.well-known/did/nostr/${alicePk}.json`);
|
|
152
|
+
assert.strictEqual(r.status, 200);
|
|
153
|
+
const doc = await r.json();
|
|
154
|
+
// Assert the shape before indexing, so a dropped @context fails with
|
|
155
|
+
// this message rather than a TypeError.
|
|
156
|
+
const ctx = doc['@context'];
|
|
157
|
+
assert.ok(Array.isArray(ctx), '@context must be present and an array');
|
|
158
|
+
assert.strictEqual(ctx[0], 'https://www.w3.org/ns/did/v1',
|
|
159
|
+
'@context must lead with the DID Core context');
|
|
160
|
+
// The CID context must still be present — the document's Multikey
|
|
161
|
+
// verification method is drawn from that vocabulary.
|
|
162
|
+
assert.ok(ctx.includes('https://www.w3.org/ns/cid/v1'),
|
|
163
|
+
'@context must still include the CID v1 context');
|
|
164
|
+
});
|
|
165
|
+
|
|
142
166
|
it('accepts the .jsonld suffix (alias)', async () => {
|
|
143
167
|
const r = await fetch(`${baseUrl}/.well-known/did/nostr/${alicePk}.jsonld`);
|
|
144
168
|
assert.strictEqual(r.status, 200);
|