diff --git a/src/common/constants.ts b/src/common/constants.ts index c177ea4d1..75526eb9d 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -35,7 +35,7 @@ export const solidVc = { SolidAccessRequest: namedNode(`${VC}SolidAccessRequest`), SolidAccessGrant: namedNode(`${VC}SolidAccessGrant`), SolidAccessDenial: namedNode(`${VC}SolidAccessDenial`), -} +}; export const gc = { providedConsent: namedNode(`${GC}providedConsent`), diff --git a/src/common/getters.ts b/src/common/getters.ts index 898c094b5..dda2e2ff6 100644 --- a/src/common/getters.ts +++ b/src/common/getters.ts @@ -18,6 +18,14 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +import type { DatasetWithId } from "@inrupt/solid-client-vc"; +import { + getCredentialSubject, + getExpirationDate, + getId, + getIssuanceDate, + getIssuer, +} from "@inrupt/solid-client-vc"; import type { BlankNode, DatasetCore, @@ -26,18 +34,9 @@ import type { Term, } from "@rdfjs/types"; import { DataFactory } from "n3"; -import { - getId, - getCredentialSubject, - getIssuer, - getIssuanceDate, - getExpirationDate, - DatasetWithId, -} from "@inrupt/solid-client-vc"; import type { AccessGrantGConsent } from "../gConsent/type/AccessGrant"; -import type { AccessRequestGConsent } from "../gConsent/type/AccessRequest"; import type { AccessModes } from "../type/AccessModes"; -import { INHERIT, XSD_BOOLEAN, gc, acl, TYPE } from "./constants"; +import { INHERIT, TYPE, XSD_BOOLEAN, acl, gc } from "./constants"; const { namedNode, defaultGraph, quad, literal } = DataFactory; @@ -118,11 +117,11 @@ function getSingleObject( return object; } export { - getId, - getIssuer, - getIssuanceDate, getCredentialSubject, getExpirationDate, + getId, + getIssuanceDate, + getIssuer, }; /** @@ -160,9 +159,7 @@ export function getConsent(vc: DatasetWithId) { * @param vc The Access Grant/Request * @returns The resources IRIs */ -export function getResources( - vc: DatasetWithId, -): string[] { +export function getResources(vc: DatasetWithId): string[] { const resources: string[] = []; for (const { object } of vc.match( @@ -194,9 +191,7 @@ export function getResources( * @param vc The Access Grant/Request * @returns The purpose IRIs */ -export function getPurposes( - vc: DatasetWithId, -): string[] { +export function getPurposes(vc: DatasetWithId): string[] { const consent = getConsent(vc); const purposes: string[] = []; @@ -217,9 +212,7 @@ export function getPurposes( return purposes; } -export function isGConsentAccessGrant( - vc: DatasetWithId, -): boolean { +export function isGConsentAccessGrant(vc: DatasetWithId): boolean { const credentialSubject = getCredentialSubject(vc); const providedConsent = getSingleObject( vc, @@ -263,12 +256,8 @@ export function isGConsentAccessGrant( * @returns The resource owner WebID */ export function getResourceOwner(vc: AccessGrantGConsent): string; -export function getResourceOwner( - vc: DatasetWithId, -): string | undefined; -export function getResourceOwner( - vc: DatasetWithId, -): string | undefined { +export function getResourceOwner(vc: DatasetWithId): string | undefined; +export function getResourceOwner(vc: DatasetWithId): string | undefined { const credentialSubject = getCredentialSubject(vc); if (isGConsentAccessGrant(vc)) { return credentialSubject.value; @@ -294,9 +283,7 @@ export function getResourceOwner( * @param vc The Access Grant/Request * @returns The requestor WebID */ -export function getRequestor( - vc: DatasetWithId, -): string { +export function getRequestor(vc: DatasetWithId): string { const credentialSubject = getCredentialSubject(vc); const providedConsent = getSingleObject( vc, @@ -324,9 +311,7 @@ export function getRequestor( * @param vc The Access Grant/Request * @returns The access modes the grant recipient can exercise. */ -export function getAccessModes( - vc: DatasetWithId, -): AccessModes { +export function getAccessModes(vc: DatasetWithId): AccessModes { const consent = getConsent(vc); return { read: vc.has(quad(consent, acl.mode, acl.Read, defaultGraph())), @@ -357,9 +342,7 @@ const shorthand = { * @param vc The Access Grant/Request * @returns The VC types */ -export function getTypes( - vc: DatasetWithId, -): string[] { +export function getTypes(vc: DatasetWithId): string[] { const results = [ ...vc.match(namedNode(getId(vc)), TYPE, undefined, defaultGraph()), ].map((res) => res.object); @@ -393,9 +376,7 @@ export function getTypes( * @param vc The Access Grant/Request * @returns true if the Grant applies to contained resources, false otherwise. */ -export function getInherit( - vc: DatasetWithId, -): boolean { +export function getInherit(vc: DatasetWithId): boolean { return !vc.has( quad( getConsent(vc), diff --git a/src/gConsent/guard/isBaseAccessGrantVerifiableCredential.test.ts b/src/gConsent/guard/isBaseAccessGrantVerifiableCredential.test.ts index 845218470..7f523b77b 100644 --- a/src/gConsent/guard/isBaseAccessGrantVerifiableCredential.test.ts +++ b/src/gConsent/guard/isBaseAccessGrantVerifiableCredential.test.ts @@ -20,8 +20,11 @@ // import { it, describe, expect } from "@jest/globals"; -import { isBaseAccessGrantVerifiableCredential, isRdfjsBaseAccessGrantVerifiableCredential } from "./isBaseAccessGrantVerifiableCredential"; import { verifiableCredentialToDataset } from "@inrupt/solid-client-vc"; +import { + isBaseAccessGrantVerifiableCredential, + isRdfjsBaseAccessGrantVerifiableCredential, +} from "./isBaseAccessGrantVerifiableCredential"; const validAccessGrantVerifiableCredential = { "@context": [ @@ -64,7 +67,9 @@ describe("isBaseAccessGrantVerifiableCredential", () => { ).toBe(true); expect( isRdfjsBaseAccessGrantVerifiableCredential( - await verifiableCredentialToDataset(validAccessGrantVerifiableCredential), + await verifiableCredentialToDataset( + validAccessGrantVerifiableCredential, + ), ), ).toBe(true); }); @@ -80,12 +85,12 @@ describe("isBaseAccessGrantVerifiableCredential", () => { forPersonalData: ["https://example.pod/resourceX", {}], }, }, - } - expect( - isBaseAccessGrantVerifiableCredential(vc), - ).toBe(false); + }; + expect(isBaseAccessGrantVerifiableCredential(vc)).toBe(false); expect( - isRdfjsBaseAccessGrantVerifiableCredential(await verifiableCredentialToDataset(vc)), + isRdfjsBaseAccessGrantVerifiableCredential( + await verifiableCredentialToDataset(vc), + ), ).toBe(false); }); @@ -94,11 +99,11 @@ describe("isBaseAccessGrantVerifiableCredential", () => { ...validAccessGrantVerifiableCredential, issuanceDate: [], }; + expect(isBaseAccessGrantVerifiableCredential(vc)).toBe(false); expect( - isBaseAccessGrantVerifiableCredential(vc), - ).toBe(false); - expect( - isRdfjsBaseAccessGrantVerifiableCredential(await verifiableCredentialToDataset(vc)), + isRdfjsBaseAccessGrantVerifiableCredential( + await verifiableCredentialToDataset(vc), + ), ).toBe(false); }); @@ -106,10 +111,8 @@ describe("isBaseAccessGrantVerifiableCredential", () => { const vc = { ...validAccessGrantVerifiableCredential, issuanceDate: undefined, - } - expect( - isBaseAccessGrantVerifiableCredential(vc), - ).toBe(true); + }; + expect(isBaseAccessGrantVerifiableCredential(vc)).toBe(true); }); // FIXME: Work out why undefined issuance dates are allowed when they are required in the VC type @@ -117,9 +120,11 @@ describe("isBaseAccessGrantVerifiableCredential", () => { const vc = { ...validAccessGrantVerifiableCredential, issuanceDate: undefined, - } + }; expect( - isRdfjsBaseAccessGrantVerifiableCredential(await verifiableCredentialToDataset(vc)), + isRdfjsBaseAccessGrantVerifiableCredential( + await verifiableCredentialToDataset(vc), + ), ).toBe(true); }); }); diff --git a/src/gConsent/guard/isBaseAccessGrantVerifiableCredential.ts b/src/gConsent/guard/isBaseAccessGrantVerifiableCredential.ts index 489cbc6dc..1a77dbf5a 100644 --- a/src/gConsent/guard/isBaseAccessGrantVerifiableCredential.ts +++ b/src/gConsent/guard/isBaseAccessGrantVerifiableCredential.ts @@ -19,6 +19,11 @@ // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +import type { DatasetWithId } from "@inrupt/solid-client-vc"; +import { getId, getIssuanceDate } from "@inrupt/solid-client-vc"; +import { DataFactory } from "n3"; +import { TYPE, solidVc } from "../../common/constants"; +import { getConsent } from "../../common/getters"; import type { BaseGrantBody, GrantCredentialSubject, @@ -26,14 +31,12 @@ import type { RequestCredentialSubject, RequestCredentialSubjectPayload, } from "../type/AccessVerifiableCredential"; -import { isGConsentAttributes, isRdfjsGConsentAttributes } from "./isGConsentAttributes"; import { isBaseAccessVcBody } from "./isBaseAccessVcBody"; -import { DatasetWithId, getCredentialSubject, getExpirationDate, getId, getIssuanceDate, getIssuer } from "@inrupt/solid-client-vc"; -import { TYPE, gc, solidVc } from "../../common/constants"; -import { DataFactory } from "n3"; -import { NamedNode } from "@rdfjs/types"; -import { getAccessModes, getResources } from "../../common"; -import { getConsent, getPurposes } from "../../common/getters"; +import { + isGConsentAttributes, + isRdfjsGConsentAttributes, +} from "./isGConsentAttributes"; + const { namedNode, quad } = DataFactory; function isGrantCredentialSubject( @@ -56,16 +59,22 @@ export function isBaseAccessGrantVerifiableCredential( ); } -export function isRdfjsBaseAccessGrantVerifiableCredential(data: DatasetWithId) { +export function isRdfjsBaseAccessGrantVerifiableCredential( + data: DatasetWithId, +) { const s = namedNode(getId(data)); - if(!data.has(quad(s, TYPE, solidVc.SolidAccessDenial)) && !data.has(quad(s, TYPE, solidVc.SolidAccessGrant)) && !data.has(quad(s, TYPE, solidVc.SolidAccessRequest))) { + if ( + !data.has(quad(s, TYPE, solidVc.SolidAccessDenial)) && + !data.has(quad(s, TYPE, solidVc.SolidAccessGrant)) && + !data.has(quad(s, TYPE, solidVc.SolidAccessRequest)) + ) { return false; } // getConsent and getIssuanceDate can error try { getIssuanceDate(data); - return isRdfjsGConsentAttributes(data, getConsent(data)) + return isRdfjsGConsentAttributes(data, getConsent(data)); } catch (e) { return false; } diff --git a/src/gConsent/guard/isGConsentAttributes.ts b/src/gConsent/guard/isGConsentAttributes.ts index 2d319447f..f3d0a6341 100644 --- a/src/gConsent/guard/isGConsentAttributes.ts +++ b/src/gConsent/guard/isGConsentAttributes.ts @@ -72,7 +72,6 @@ export function isRdfjsGConsentAttributes( if ( ![acl.Append, acl.Read, acl.Write].some((mode) => mode.equals(object)) ) { - console.log('mode issue') return false; } } diff --git a/src/gConsent/manage/approveAccessRequest.ts b/src/gConsent/manage/approveAccessRequest.ts index 77b028fcf..e53613d50 100644 --- a/src/gConsent/manage/approveAccessRequest.ts +++ b/src/gConsent/manage/approveAccessRequest.ts @@ -22,7 +22,10 @@ import type { UrlString, WebId } from "@inrupt/solid-client"; // eslint-disable-next-line camelcase import { acp_ess_2 } from "@inrupt/solid-client"; -import type { VerifiableCredential, VerifiableCredentialBase } from "@inrupt/solid-client-vc"; +import type { + VerifiableCredential, + VerifiableCredentialBase, +} from "@inrupt/solid-client-vc"; import type { AccessBaseOptions } from "../type/AccessBaseOptions"; import type { AccessGrantBody } from "../type/AccessVerifiableCredential"; import type { AccessGrantParameters } from "../type/Parameter"; diff --git a/src/gConsent/manage/getAccessGrant.test.ts b/src/gConsent/manage/getAccessGrant.test.ts index 8cccb616c..6c841ba51 100644 --- a/src/gConsent/manage/getAccessGrant.test.ts +++ b/src/gConsent/manage/getAccessGrant.test.ts @@ -23,7 +23,7 @@ import type * as CrossFetch from "@inrupt/universal-fetch"; import { Response } from "@inrupt/universal-fetch"; import { beforeAll, describe, expect, it, jest } from "@jest/globals"; import { isomorphic } from "rdf-isomorphic"; -import { getResources } from "../../common/getters" +import { getResources } from "../../common/getters"; import { mockAccessGrantObject, @@ -77,7 +77,7 @@ describe("getAccessGrant", () => { getAccessGrant("https://some.vc.url", { fetch: async () => new Response("Not Found", { status: 404, statusText: "Not Found" }), - returnLegacyJsonld: false + returnLegacyJsonld: false, }), ).rejects.toThrow( "Fetching the Verifiable Credential [https://some.vc.url] failed: 404 Not Found", @@ -95,7 +95,7 @@ describe("getAccessGrant", () => { await expect( getAccessGrant("https://some.vc.url", { fetch: async () => new Response("{'someKey': 'someValue'}"), - returnLegacyJsonld: false + returnLegacyJsonld: false, }), ).rejects.toThrow( "Parsing the Verifiable Credential [https://some.vc.url] as JSON failed", @@ -104,9 +104,9 @@ describe("getAccessGrant", () => { it("throws if the given IRI does not resolve to a access grant Verifiable Credential", async () => { const fetchFn = async () => - new Response(JSON.stringify(await mockAccessRequestVc()), { - headers: new Headers([["content-type", "application/json"]]), - }) + new Response(JSON.stringify(await mockAccessRequestVc()), { + headers: new Headers([["content-type", "application/json"]]), + }); await expect( getAccessGrant("https://some.vc.url", { fetch: fetchFn, @@ -115,7 +115,7 @@ describe("getAccessGrant", () => { await expect( getAccessGrant("https://some.vc.url", { fetch: fetchFn, - returnLegacyJsonld: false + returnLegacyJsonld: false, }), ).rejects.toThrow(/not an Access Grant/); }); @@ -129,19 +129,24 @@ describe("getAccessGrant", () => { "https://w3id.org/GConsent#ConsentStatusDenied"; const fetchFn = async () => - new Response(JSON.stringify(mockedAccessGrant), { - headers: new Headers([["content-type", "application/json"]]), - }); + new Response(JSON.stringify(mockedAccessGrant), { + headers: new Headers([["content-type", "application/json"]]), + }); const accessGrant = await getAccessGrant("https://some.vc.url", { fetch: fetchFn, }); - const accessGrantNoProperties = await getAccessGrant("https://some.vc.url", { - fetch: fetchFn, - returnLegacyJsonld: false - }); + const accessGrantNoProperties = await getAccessGrant( + "https://some.vc.url", + { + fetch: fetchFn, + returnLegacyJsonld: false, + }, + ); toBeEqual(accessGrant, mockedAccessGrant); - expect(isomorphic([...accessGrant], [...accessGrantNoProperties])).toBe(true); + expect(isomorphic([...accessGrant], [...accessGrantNoProperties])).toBe( + true, + ); }); // There is an expect call in the `toBeEqual` function, @@ -163,112 +168,138 @@ describe("getAccessGrant", () => { it("normalizes equivalent JSON-LD VCs", async () => { const normalizedAccessGrant = mockAccessGrantObject(); const fetchFn = async () => - new Response( - JSON.stringify({ - ...normalizedAccessGrant, - credentialSubject: { - ...normalizedAccessGrant.credentialSubject, - providedConsent: { - ...normalizedAccessGrant.credentialSubject.providedConsent, - // The 1-value array is replaced by the literal value. - forPersonalData: - normalizedAccessGrant.credentialSubject.providedConsent - .forPersonalData[0], - mode: normalizedAccessGrant.credentialSubject.providedConsent - .mode[0], - inherit: "true", + new Response( + JSON.stringify({ + ...normalizedAccessGrant, + credentialSubject: { + ...normalizedAccessGrant.credentialSubject, + providedConsent: { + ...normalizedAccessGrant.credentialSubject.providedConsent, + // The 1-value array is replaced by the literal value. + forPersonalData: + normalizedAccessGrant.credentialSubject.providedConsent + .forPersonalData[0], + mode: normalizedAccessGrant.credentialSubject.providedConsent + .mode[0], + inherit: "true", + }, }, + }), + { + headers: new Headers([["content-type", "application/json"]]), }, - }), - { - headers: new Headers([["content-type", "application/json"]]), - }, - ); - + ); + const accessGrant = await getAccessGrant("https://some.vc.url", { // The server returns an equivalent JSON-LD with a different frame: fetch: fetchFn, }); - toBeEqual( - accessGrant, - mockAccessGrant, - ); - expect(accessGrant.credentialSubject.providedConsent.forPersonalData).toEqual(["https://some.resource"]); + toBeEqual(accessGrant, mockAccessGrant); + expect( + accessGrant.credentialSubject.providedConsent.forPersonalData, + ).toEqual(["https://some.resource"]); expect(getResources(accessGrant)).toEqual(["https://some.resource"]); - const accessGrantNoProperties = await getAccessGrant(new URL("https://some.vc.url"), { - fetch: fetchFn, - returnLegacyJsonld: false - }); + const accessGrantNoProperties = await getAccessGrant( + new URL("https://some.vc.url"), + { + fetch: fetchFn, + returnLegacyJsonld: false, + }, + ); // @ts-expect-error no object properties should be available expect(accessGrantNoProperties.credentialSubject).toBeUndefined(); - expect(getResources(accessGrantNoProperties)).toEqual(["https://some.resource"]); + expect(getResources(accessGrantNoProperties)).toEqual([ + "https://some.resource", + ]); - expect(isomorphic([...accessGrant], [...accessGrantNoProperties])).toBe(true); + expect(isomorphic([...accessGrant], [...accessGrantNoProperties])).toBe( + true, + ); }); // There is an expect call in the `toBeEqual` function, // but the linter doesn't pick up on this. // eslint-disable-next-line jest/expect-expect it("returns the access grant with the given URL object", async () => { - const mockedFetch = jest.fn(async () => new Response(JSON.stringify(mockAccessGrantObject()), { - headers: new Headers([["content-type", "application/json"]]), - })); + const mockedFetch = jest.fn( + async () => + new Response(JSON.stringify(mockAccessGrantObject()), { + headers: new Headers([["content-type", "application/json"]]), + }), + ); const accessGrant = await getAccessGrant(new URL("https://some.vc.url"), { fetch: mockedFetch, }); toBeEqual(accessGrant, mockAccessGrant); - expect(accessGrant.credentialSubject.providedConsent.forPersonalData).toEqual(["https://some.resource"]); + expect( + accessGrant.credentialSubject.providedConsent.forPersonalData, + ).toEqual(["https://some.resource"]); expect(getResources(accessGrant)).toEqual(["https://some.resource"]); - const accessGrantNoProperties = await getAccessGrant(new URL("https://some.vc.url"), { - fetch: mockedFetch, - returnLegacyJsonld: false - }); + const accessGrantNoProperties = await getAccessGrant( + new URL("https://some.vc.url"), + { + fetch: mockedFetch, + returnLegacyJsonld: false, + }, + ); // @ts-expect-error no object properties should be available expect(accessGrantNoProperties.credentialSubject).toBeUndefined(); - expect(getResources(accessGrantNoProperties)).toEqual(["https://some.resource"]); + expect(getResources(accessGrantNoProperties)).toEqual([ + "https://some.resource", + ]); - expect(isomorphic([...accessGrant], [...accessGrantNoProperties])).toBe(true); + expect(isomorphic([...accessGrant], [...accessGrantNoProperties])).toBe( + true, + ); }); it("errors if the response is not a full access grant", async () => { const fetchFn = async () => - new Response( - JSON.stringify({ - "@context": "https://www.w3.org/2018/credentials/v1", - id: "https://some.credential", - }), - ) + new Response( + JSON.stringify({ + "@context": "https://www.w3.org/2018/credentials/v1", + id: "https://some.credential", + }), + ); await expect( getAccessGrant(new URL("https://some.vc.url"), { fetch: fetchFn, }), - ).rejects.toThrow("The value received from [https://some.vc.url/] is not a Verifiable Credential"); + ).rejects.toThrow( + "The value received from [https://some.vc.url/] is not a Verifiable Credential", + ); await expect( getAccessGrant(new URL("https://some.vc.url"), { fetch: fetchFn, - returnLegacyJsonld: false + returnLegacyJsonld: false, }), - ).rejects.toThrow("The value received from [https://some.vc.url/] is not a Verifiable Credential"); + ).rejects.toThrow( + "The value received from [https://some.vc.url/] is not a Verifiable Credential", + ); }); it("errors if the response is an empty json object", async () => { const fetchFn = async () => - new Response(JSON.stringify({}), { - headers: new Headers([["content-type", "application/json"]]), - }); + new Response(JSON.stringify({}), { + headers: new Headers([["content-type", "application/json"]]), + }); await expect( getAccessGrant(new URL("https://some.vc.url"), { fetch: fetchFn, }), - ).rejects.toThrow("The value received from [https://some.vc.url/] is not a Verifiable Credential"); + ).rejects.toThrow( + "The value received from [https://some.vc.url/] is not a Verifiable Credential", + ); await expect( getAccessGrant(new URL("https://some.vc.url"), { fetch: fetchFn, - returnLegacyJsonld: false + returnLegacyJsonld: false, }), - ).rejects.toThrow("Verifiable credential is not an object, or does not have an id"); + ).rejects.toThrow( + "Verifiable credential is not an object, or does not have an id", + ); }); }); diff --git a/src/gConsent/manage/getAccessGrant.ts b/src/gConsent/manage/getAccessGrant.ts index c87ca4da9..891d6f0d8 100644 --- a/src/gConsent/manage/getAccessGrant.ts +++ b/src/gConsent/manage/getAccessGrant.ts @@ -20,15 +20,17 @@ // import type { UrlString } from "@inrupt/solid-client"; -import { DatasetWithId, getVerifiableCredential } from "@inrupt/solid-client-vc"; -import { DataFactory } from "n3"; +import type { DatasetWithId } from "@inrupt/solid-client-vc"; +import { getVerifiableCredential } from "@inrupt/solid-client-vc"; import { isGConsentAccessGrant } from "../../common/getters"; import { isAccessGrant } from "../guard/isAccessGrant"; -import { isBaseAccessGrantVerifiableCredential, isRdfjsBaseAccessGrantVerifiableCredential } from "../guard/isBaseAccessGrantVerifiableCredential"; +import { + isBaseAccessGrantVerifiableCredential, + isRdfjsBaseAccessGrantVerifiableCredential, +} from "../guard/isBaseAccessGrantVerifiableCredential"; import type { AccessBaseOptions } from "../type/AccessBaseOptions"; import type { AccessGrant } from "../type/AccessGrant"; import { normalizeAccessGrant } from "./approveAccessRequest"; -const { namedNode } = DataFactory; /** * Retrieve the Access Grant associated to the given URL. @@ -44,7 +46,7 @@ export async function getAccessGrant( options?: AccessBaseOptions & { returnLegacyJsonld?: true; }, -): Promise +): Promise; /** * Retrieve the Access Grant associated to the given URL. * @@ -58,7 +60,7 @@ export async function getAccessGrant( options?: AccessBaseOptions & { returnLegacyJsonld?: boolean; }, -): Promise +): Promise; /** * Retrieve the Access Grant associated to the given URL. * @@ -77,17 +79,22 @@ export async function getAccessGrant( typeof accessGrantVcUrl === "string" ? accessGrantVcUrl : accessGrantVcUrl.href; - + if (options?.returnLegacyJsonld === false) { const data = await getVerifiableCredential(vcUrl, { fetch: options?.fetch, - returnLegacyJsonld: false + returnLegacyJsonld: false, }); - if (!isRdfjsBaseAccessGrantVerifiableCredential(data) || !isGConsentAccessGrant(data)) { + if ( + !isRdfjsBaseAccessGrantVerifiableCredential(data) || + !isGConsentAccessGrant(data) + ) { throw new Error( `Unexpected response when resolving [${vcUrl}], the result is not an Access Grant: ${JSON.stringify( - data, null, 2 + data, + null, + 2, )}`, ); } @@ -96,11 +103,9 @@ export async function getAccessGrant( const data = await getVerifiableCredential(vcUrl, { fetch: options?.fetch, - normalize: normalizeAccessGrant + normalize: normalizeAccessGrant, }); - if ( - !isBaseAccessGrantVerifiableCredential(data) || !isAccessGrant(data) - ) { + if (!isBaseAccessGrantVerifiableCredential(data) || !isAccessGrant(data)) { throw new Error( `Unexpected response when resolving [${vcUrl}], the result is not an Access Grant: ${JSON.stringify( data, diff --git a/src/gConsent/request/issueAccessRequest.ts b/src/gConsent/request/issueAccessRequest.ts index b1df67f44..560c6a353 100644 --- a/src/gConsent/request/issueAccessRequest.ts +++ b/src/gConsent/request/issueAccessRequest.ts @@ -19,7 +19,10 @@ // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -import type { VerifiableCredential, VerifiableCredentialBase } from "@inrupt/solid-client-vc"; +import type { + VerifiableCredential, + VerifiableCredentialBase, +} from "@inrupt/solid-client-vc"; import { getRequestBody, issueAccessVc } from "../util/issueAccessVc"; import type { AccessBaseOptions } from "../type/AccessBaseOptions"; import type {