diff --git a/src/gConsent/manage/denyAccessRequest.test.ts b/src/gConsent/manage/denyAccessRequest.test.ts index 80fe32486..92cf4880b 100644 --- a/src/gConsent/manage/denyAccessRequest.test.ts +++ b/src/gConsent/manage/denyAccessRequest.test.ts @@ -69,7 +69,10 @@ describe("denyAccessRequest", () => { beforeAll(async () => { accessRequestVc = await mockAccessRequestVc(); - accessRequestVcExpanded = await mockAccessRequestVc({}, { expandModeUri: true }); + accessRequestVcExpanded = await mockAccessRequestVc( + {}, + { expandModeUri: true }, + ); }); it("throws if the provided VC isn't a Solid access request", async () => { @@ -197,7 +200,8 @@ describe("denyAccessRequest", () => { mode: accessRequestVcExpanded.credentialSubject.hasConsent.mode, hasStatus: "https://w3id.org/GConsent#ConsentStatusDenied", forPersonalData: - accessRequestVcExpanded.credentialSubject.hasConsent.forPersonalData, + accessRequestVcExpanded.credentialSubject.hasConsent + .forPersonalData, }), inbox: accessRequestVcExpanded.credentialSubject.inbox, }), @@ -232,7 +236,8 @@ describe("denyAccessRequest", () => { mode: accessRequestVcExpanded.credentialSubject.hasConsent.mode, hasStatus: "https://w3id.org/GConsent#ConsentStatusDenied", forPersonalData: - accessRequestVcExpanded.credentialSubject.hasConsent.forPersonalData, + accessRequestVcExpanded.credentialSubject.hasConsent + .forPersonalData, }), inbox: accessRequestVcExpanded.credentialSubject.inbox, }), @@ -264,7 +269,8 @@ describe("denyAccessRequest", () => { mode: accessRequestVcExpanded.credentialSubject.hasConsent.mode, hasStatus: "https://w3id.org/GConsent#ConsentStatusDenied", forPersonalData: - accessRequestVcExpanded.credentialSubject.hasConsent.forPersonalData, + accessRequestVcExpanded.credentialSubject.hasConsent + .forPersonalData, isProvidedTo: "https://some.requestor", }, inbox: accessRequestVcExpanded.credentialSubject.inbox, diff --git a/src/gConsent/manage/denyAccessRequest.ts b/src/gConsent/manage/denyAccessRequest.ts index 67eb19dee..66879711b 100644 --- a/src/gConsent/manage/denyAccessRequest.ts +++ b/src/gConsent/manage/denyAccessRequest.ts @@ -89,8 +89,8 @@ async function denyAccessRequest( typeof options !== "undefined" || (typeof resourceOwnerOrVc === "string" && typeof vcOrOptions === "string") || - // FIXME: Understand why adding this typeof vcOrOptions === "object" && was necessary before - // making a release. Without it we were passing undefined to isVerifiableCredential + // FIXME: Understand why adding this typeof vcOrOptions === "object" && was necessary before + // making a release. Without it we were passing undefined to isVerifiableCredential (typeof vcOrOptions === "object" && isVerifiableCredential(vcOrOptions)) ) { // The deprecated signature is being used: ignore the first parameter diff --git a/src/gConsent/manage/getAccessGrant.test.ts b/src/gConsent/manage/getAccessGrant.test.ts index a2b211860..449a6f996 100644 --- a/src/gConsent/manage/getAccessGrant.test.ts +++ b/src/gConsent/manage/getAccessGrant.test.ts @@ -28,7 +28,6 @@ import { mockAccessGrantObject, mockAccessGrantVc, mockConsentRequestObject, - mockConsentRequestVc, } from "../util/access.mock"; import { getAccessGrant } from "./getAccessGrant"; @@ -45,7 +44,7 @@ function withoutDataset(data: any) { has: undefined, [Symbol.iterator]: undefined, delete: undefined, - } + }; } jest.mock("@inrupt/universal-fetch", () => { @@ -147,9 +146,9 @@ describe("getAccessGrant", () => { ...withoutDataset(mockAccessGrant).credentialSubject, providedConsent: { ...withoutDataset(mockAccessGrant).credentialSubject.providedConsent, - hasStatus: 'Consent:StatusDenied' - } - } + hasStatus: "Consent:StatusDenied", + }, + }, }); }); @@ -164,7 +163,9 @@ describe("getAccessGrant", () => { const accessGrant = await getAccessGrant("https://some.vc.url", { fetch: mockedFetch, }); - expect(withoutDataset(accessGrant)).toEqual(withoutDataset(mockAccessGrant)); + expect(withoutDataset(accessGrant)).toEqual( + withoutDataset(mockAccessGrant), + ); }); it("normalizes equivalent JSON-LD VCs", async () => { @@ -196,9 +197,11 @@ describe("getAccessGrant", () => { ); expect( - withoutDataset(await getAccessGrant("https://some.vc.url", { - fetch: mockedFetch, - })), + withoutDataset( + await getAccessGrant("https://some.vc.url", { + fetch: mockedFetch, + }), + ), ).toEqual(withoutDataset(mockAccessGrant)); }); @@ -213,6 +216,8 @@ describe("getAccessGrant", () => { const accessGrant = await getAccessGrant(new URL("https://some.vc.url"), { fetch: mockedFetch, }); - expect(withoutDataset(accessGrant)).toMatchObject(withoutDataset(mockAccessGrant)); + expect(withoutDataset(accessGrant)).toMatchObject( + withoutDataset(mockAccessGrant), + ); }); }); diff --git a/src/gConsent/manage/getAccessGrantAll.test.ts b/src/gConsent/manage/getAccessGrantAll.test.ts index ca2a35f2b..7f7f8d821 100644 --- a/src/gConsent/manage/getAccessGrantAll.test.ts +++ b/src/gConsent/manage/getAccessGrantAll.test.ts @@ -35,12 +35,9 @@ import { mockAccessGrantVc } from "../util/access.mock"; const otherFetch = jest.fn(global.fetch); jest.mock("@inrupt/solid-client-vc", () => { - const { - getVerifiableCredentialFromResponse, - getVerifiableCredentialAllFromShape, - } = jest.requireActual("@inrupt/solid-client-vc") as jest.Mocked< - typeof VcLibrary - >; + const { getVerifiableCredentialFromResponse } = jest.requireActual( + "@inrupt/solid-client-vc", + ) as jest.Mocked; return { getVerifiableCredentialFromResponse, issueVerifiableCredential: jest.fn(), diff --git a/src/gConsent/manage/revokeAccessGrant.test.ts b/src/gConsent/manage/revokeAccessGrant.test.ts index d86a6ce1c..dbfe578a9 100644 --- a/src/gConsent/manage/revokeAccessGrant.test.ts +++ b/src/gConsent/manage/revokeAccessGrant.test.ts @@ -19,7 +19,6 @@ // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -import type { revokeVerifiableCredential } from "@inrupt/solid-client-vc"; import { jest, describe, it, expect } from "@jest/globals"; import { Response } from "@inrupt/universal-fetch"; @@ -41,7 +40,7 @@ jest.mock("@inrupt/solid-client-vc", () => { describe("revokeAccessGrant", () => { it("uses the provided fetch if any", async () => { const mockedVcModule = jest.requireMock("@inrupt/solid-client-vc") as { - revokeVerifiableCredential: typeof revokeVerifiableCredential; + revokeVerifiableCredential: (typeof VcLibrary)["revokeVerifiableCredential"]; }; const spiedRevoke = jest.spyOn( mockedVcModule, @@ -66,7 +65,7 @@ describe("revokeAccessGrant", () => { it("looks up the VC if provided as an IRI", async () => { const mockedVcModule = jest.requireMock("@inrupt/solid-client-vc") as { - revokeVerifiableCredential: typeof revokeVerifiableCredential; + revokeVerifiableCredential: (typeof VcLibrary)["revokeVerifiableCredential"]; }; const spiedRevoke = jest.spyOn( mockedVcModule, @@ -110,7 +109,7 @@ describe("revokeAccessGrant", () => { it("gets the VC identifier if provided as a full credential", async () => { const mockedVcModule = jest.requireMock("@inrupt/solid-client-vc") as { - revokeVerifiableCredential: typeof revokeVerifiableCredential; + revokeVerifiableCredential: (typeof VcLibrary)["revokeVerifiableCredential"]; }; const spiedRevoke = jest.spyOn( mockedVcModule, diff --git a/src/gConsent/util/access.mock.ts b/src/gConsent/util/access.mock.ts index 46a121dcd..30e454621 100644 --- a/src/gConsent/util/access.mock.ts +++ b/src/gConsent/util/access.mock.ts @@ -47,11 +47,9 @@ type RequestVcOptions = Partial<{ resourceOwner: string | null; inherit: boolean; purpose: UrlString[]; -}> +}>; -export const mockAccessRequestVcObject = ( - options?: RequestVcOptions -) => { +export const mockAccessRequestVcObject = (options?: RequestVcOptions) => { const hasConsent = { forPersonalData: options?.resources ?? ["https://some.resource"], hasStatus: GC_CONSENT_STATUS_REQUESTED, @@ -96,8 +94,8 @@ export const mockAccessRequestVcObject = ( asObject.credentialSubject.hasConsent.forPurpose = options.purpose; } - return asObject -} + return asObject; +}; export const mockAccessRequestVc = async ( options?: RequestVcOptions, @@ -228,10 +226,7 @@ export const mockAccessGrantVc = async ( return accessGrant as unknown as AccessGrant & DatasetCore; }; - -export const mockConsentRequestObject = ( - options?: RequestVcOptions, -) => { +export const mockConsentRequestObject = (options?: RequestVcOptions) => { const requestVc = mockAccessRequestVcObject(options); requestVc.credentialSubject.hasConsent.forPurpose = ["https://some.purpose"]; requestVc.expirationDate = new Date(2021, 8, 14).toISOString(); @@ -239,7 +234,6 @@ export const mockConsentRequestObject = ( return requestVc; }; - export const mockConsentRequestVc = async ( options?: RequestVcOptions, framingOptions?: {