javascript-solid-server 0.0.173 → 0.0.174
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/webid/profile.js +33 -1
- package/test/webid.test.js +47 -0
package/package.json
CHANGED
package/src/webid/profile.js
CHANGED
|
@@ -31,6 +31,12 @@ export function generateProfileJsonLd({ webId, name, podUri, issuer }) {
|
|
|
31
31
|
const docUrl = webId.split('#')[0];
|
|
32
32
|
|
|
33
33
|
return {
|
|
34
|
+
// CID v1 vocabulary is declared inline (rather than via an imported
|
|
35
|
+
// context URL) so JSS's JSON-LD → Turtle conneg layer can expand
|
|
36
|
+
// every term without fetching external contexts. Semantically
|
|
37
|
+
// equivalent to importing https://www.w3.org/ns/cid/v1: the IRIs
|
|
38
|
+
// each term expands to are the same. This keeps the profile a valid
|
|
39
|
+
// W3C Controlled Identifier document per LWS 1.0 (#386 Phase A).
|
|
34
40
|
'@context': {
|
|
35
41
|
'foaf': FOAF,
|
|
36
42
|
'solid': SOLID,
|
|
@@ -48,13 +54,39 @@ export function generateProfileJsonLd({ webId, name, podUri, issuer }) {
|
|
|
48
54
|
'isPrimaryTopicOf': { '@id': 'foaf:isPrimaryTopicOf', '@type': '@id' },
|
|
49
55
|
'mainEntityOfPage': { '@id': 'schema:mainEntityOfPage', '@type': '@id' },
|
|
50
56
|
'service': { '@id': 'cid:service', '@container': '@set' },
|
|
51
|
-
'serviceEndpoint': { '@id': 'cid:serviceEndpoint', '@type': '@id' }
|
|
57
|
+
'serviceEndpoint': { '@id': 'cid:serviceEndpoint', '@type': '@id' },
|
|
58
|
+
// CID v1 terms used by Phase A and prepped for Phase B (the
|
|
59
|
+
// standalone "add my keys" app). Declaring these now means the
|
|
60
|
+
// app can PATCH in verificationMethod entries without having to
|
|
61
|
+
// also rewrite the @context.
|
|
62
|
+
//
|
|
63
|
+
// verificationMethod: NO @type:@id — values are inline verification
|
|
64
|
+
// method *objects* (id/type/controller/publicKey…), not just IRI
|
|
65
|
+
// references. @container:@set so a single entry stays an array.
|
|
66
|
+
// authentication / assertionMethod: @type:@id — values reference a
|
|
67
|
+
// verificationMethod entry by its IRI. @container:@set for arrays.
|
|
68
|
+
// publicKeyJwk: @type:@json so the JWK object round-trips as a
|
|
69
|
+
// literal JSON value (rdf:JSON datatype). Note: JSS's Turtle
|
|
70
|
+
// conneg layer doesn't yet emit @type:@json literals (tracked as
|
|
71
|
+
// a Phase B blocker in the PR description); declaring here is
|
|
72
|
+
// forward-looking and spec-correct.
|
|
73
|
+
'controller': { '@id': 'cid:controller', '@type': '@id' },
|
|
74
|
+
'verificationMethod': { '@id': 'cid:verificationMethod', '@container': '@set' },
|
|
75
|
+
'authentication': { '@id': 'cid:authentication', '@type': '@id', '@container': '@set' },
|
|
76
|
+
'assertionMethod': { '@id': 'cid:assertionMethod', '@type': '@id', '@container': '@set' },
|
|
77
|
+
'publicKeyJwk': { '@id': 'cid:publicKeyJwk', '@type': '@json' },
|
|
78
|
+
'publicKeyMultibase': { '@id': 'cid:publicKeyMultibase' }
|
|
52
79
|
},
|
|
53
80
|
'@id': webId,
|
|
54
81
|
'@type': ['foaf:Person', 'schema:Person'],
|
|
55
82
|
'foaf:name': name,
|
|
56
83
|
'isPrimaryTopicOf': '',
|
|
57
84
|
'mainEntityOfPage': '',
|
|
85
|
+
// CID v1 self-control: the WebID is its own controller. Phase A of
|
|
86
|
+
// #386 ships this triple even with no verificationMethods yet, so a
|
|
87
|
+
// future Phase B "add-keys" app PATCHing in verificationMethod
|
|
88
|
+
// entries doesn't have to also wire up controllership separately.
|
|
89
|
+
'controller': webId,
|
|
58
90
|
'inbox': `${pod}inbox/`,
|
|
59
91
|
'storage': pod,
|
|
60
92
|
'oidcIssuer': issuer,
|
package/test/webid.test.js
CHANGED
|
@@ -47,6 +47,53 @@ describe('WebID Profile', () => {
|
|
|
47
47
|
assert.ok(jsonLd['@id'], 'Should have @id');
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
+
// LWS-CID document conformance, Phase A of #386. The profile must be
|
|
51
|
+
// structurally a W3C Controlled Identifier document so a future
|
|
52
|
+
// PATCH-in-keys app (or server migration) can drop verificationMethod
|
|
53
|
+
// entries in without further plumbing. CID v1 vocabulary is declared
|
|
54
|
+
// inline rather than via context URL so JSS's conneg layer can
|
|
55
|
+
// expand every term without fetching external contexts — the IRIs
|
|
56
|
+
// are the same either way.
|
|
57
|
+
it('declares all six CID v1 terms in @context (#386 Phase A)', async () => {
|
|
58
|
+
const res = await request(profilePath);
|
|
59
|
+
const jsonLd = await res.json();
|
|
60
|
+
const ctx = jsonLd['@context'];
|
|
61
|
+
assert.ok(ctx, '@context required');
|
|
62
|
+
|
|
63
|
+
// All six CID terms must be declared and expand to the CID v1
|
|
64
|
+
// namespace. Accept either prefixed (cid:term) or full-URI
|
|
65
|
+
// (https://www.w3.org/ns/cid/v1#term) form.
|
|
66
|
+
const cidTerms = ['controller', 'verificationMethod', 'authentication', 'assertionMethod', 'publicKeyJwk', 'publicKeyMultibase'];
|
|
67
|
+
for (const term of cidTerms) {
|
|
68
|
+
const mapping = ctx[term];
|
|
69
|
+
assert.ok(mapping, `@context must define \`${term}\``);
|
|
70
|
+
const id = typeof mapping === 'string' ? mapping : mapping['@id'];
|
|
71
|
+
assert.match(id, new RegExp(`^(cid:${term}|https://www\\.w3\\.org/ns/cid/v1#${term})$`),
|
|
72
|
+
`${term} must map to the CID v1 namespace`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Container/type flags Phase B relies on:
|
|
76
|
+
// verificationMethod values are inline objects, NOT IRIs — must
|
|
77
|
+
// NOT have @type:@id (would force string-only) and SHOULD have
|
|
78
|
+
// @container:@set so a single entry is still an array.
|
|
79
|
+
assert.notStrictEqual(ctx.verificationMethod['@type'], '@id',
|
|
80
|
+
'verificationMethod values are objects, not IRIs');
|
|
81
|
+
assert.strictEqual(ctx.verificationMethod['@container'], '@set');
|
|
82
|
+
// authentication / assertionMethod reference verificationMethod
|
|
83
|
+
// entries by IRI, so @type:@id is correct.
|
|
84
|
+
assert.strictEqual(ctx.authentication['@type'], '@id');
|
|
85
|
+
assert.strictEqual(ctx.assertionMethod['@type'], '@id');
|
|
86
|
+
// JWK is a literal JSON value (rdf:JSON datatype) per JSON-LD 1.1.
|
|
87
|
+
assert.strictEqual(ctx.publicKeyJwk['@type'], '@json');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('declares self-control via controller === @id (#386 Phase A)', async () => {
|
|
91
|
+
const res = await request(profilePath);
|
|
92
|
+
const jsonLd = await res.json();
|
|
93
|
+
assert.strictEqual(jsonLd.controller, jsonLd['@id'],
|
|
94
|
+
'profile must declare itself as its own controller per CID v1');
|
|
95
|
+
});
|
|
96
|
+
|
|
50
97
|
it('should have correct WebID URI', async () => {
|
|
51
98
|
const res = await request(profilePath);
|
|
52
99
|
const jsonLd = await res.json();
|