Skip to content

Commit 88c2c3a

Browse files
jeswrlangsamu
andauthored
Add oidcIssuers getter to Agent (#28)
Co-authored-by: Samu Lang <langsamu@users.noreply.github.com>
1 parent 6591266 commit 88c2c3a

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/webid/Agent.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export class Agent extends TermWrapper {
6363
return SetFrom.subjectPredicate(this, SOLID.storage, NamedNodeAs.string, NamedNodeFrom.string)
6464
}
6565

66+
get oidcIssuer(): Set<string> {
67+
return SetFrom.subjectPredicate(this, SOLID.oidcIssuer, NamedNodeAs.string, NamedNodeFrom.string)
68+
}
69+
6670
get email(): string | null {
6771
return this.hasEmail?.value ?? null
6872
}

test/unit/agent.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { DataFactory, Parser, Store } from "n3"
2+
import assert from "node:assert"
3+
import { describe, it } from "node:test"
4+
5+
import { Agent } from "@solid/object"
6+
7+
describe("Agent oidcIssuer", () => {
8+
9+
const sampleRDF = `
10+
@prefix solid: <http://www.w3.org/ns/solid/terms#> .
11+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
12+
13+
<https://example.org/profile/card#me>
14+
a foaf:Person ;
15+
solid:oidcIssuer <https://idp.example.org/> , <https://idp.other.example/> .
16+
`;
17+
18+
it("returns the set of solid:oidcIssuer values declared on the WebID", () => {
19+
const store = new Store()
20+
store.addQuads(new Parser().parse(sampleRDF))
21+
22+
const agent = new Agent(
23+
DataFactory.namedNode("https://example.org/profile/card#me"),
24+
store,
25+
DataFactory
26+
)
27+
28+
assert.deepStrictEqual(
29+
new Set(agent.oidcIssuer),
30+
new Set(["https://idp.example.org/", "https://idp.other.example/"])
31+
)
32+
})
33+
})

0 commit comments

Comments
 (0)