Skip to content

Commit 6bb12c8

Browse files
Address Copilot review on JavaScriptSolidServer#321
- Alias `id`/`type` to @id/@type in @context so nested service[] entries are interpreted as real JSON-LD node identifiers/types rather than plain properties. CID 1.0 and DID contexts do the same; LWS verifiers that expand JSON-LD would otherwise fail to read these entries. - Tighten the two service-entry tests with explicit assertions on `jsonLd.service` being an array and `oidc` being truthy, so missing data produces clean assertion failures instead of TypeError.
1 parent cccd081 commit 6bb12c8

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/webid/profile.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ export function generateProfileJsonLd({ webId, name, podUri, issuer }) {
3939
'ldp': LDP,
4040
'cid': CID,
4141
'lws': LWS,
42+
// Alias `id` → @id and `type` → @type so nested nodes (like each
43+
// `service[]` entry) are interpreted correctly by JSON-LD processors.
44+
// CID 1.0 and DID contexts do the same.
45+
'id': '@id',
46+
'type': '@type',
4247
'inbox': { '@id': 'ldp:inbox', '@type': '@id' },
4348
'storage': { '@id': 'pim:storage', '@type': '@id' },
4449
'oidcIssuer': { '@id': 'solid:oidcIssuer', '@type': '@id' },

test/webid.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ describe('WebID Profile', () => {
113113
it('lws:OpenIdProvider service.serviceEndpoint mirrors oidcIssuer', async () => {
114114
const res = await request(profilePath);
115115
const jsonLd = await res.json();
116+
assert.ok(Array.isArray(jsonLd.service), 'profile should have a service array');
116117
const oidc = jsonLd.service.find((s) => s.type === 'lws:OpenIdProvider');
118+
assert.ok(oidc, 'service[] must include an lws:OpenIdProvider entry');
117119
assert.strictEqual(
118120
oidc.serviceEndpoint,
119121
jsonLd.oidcIssuer,
@@ -124,7 +126,9 @@ describe('WebID Profile', () => {
124126
it('lws:OpenIdProvider service.id is a fragment on the profile document', async () => {
125127
const res = await request(profilePath);
126128
const jsonLd = await res.json();
129+
assert.ok(Array.isArray(jsonLd.service), 'profile should have a service array');
127130
const oidc = jsonLd.service.find((s) => s.type === 'lws:OpenIdProvider');
131+
assert.ok(oidc, 'service[] must include an lws:OpenIdProvider entry');
128132
const docUrl = jsonLd['@id'].split('#')[0];
129133
assert.strictEqual(oidc.id, `${docUrl}#oidc`,
130134
'service entry id should be `<profile-doc>#oidc`');

0 commit comments

Comments
 (0)