Skip to content

Commit

Permalink
chore: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswr committed Nov 12, 2023
1 parent 0e69c0c commit a0aa7a4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
8 changes: 5 additions & 3 deletions src/common/verify/isValidAccessGrant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type * as CrossFetch from "@inrupt/universal-fetch";
import {
isVerifiableCredential,
getVerifiableCredentialApiConfiguration,
verifiableCredentialToDataset
verifiableCredentialToDataset,
} from "@inrupt/solid-client-vc";

Check failure on line 29 in src/common/verify/isValidAccessGrant.test.ts

View workflow job for this annotation

GitHub Actions / lint / lint

Unable to resolve path to module '@inrupt/solid-client-vc'

import type * as VcLibrary from "@inrupt/solid-client-vc";
Expand Down Expand Up @@ -94,10 +94,12 @@ describe("isValidAccessGrant", () => {
const MOCK_ACCESS_ENDPOINT = "https://consent.example.com";
const MOCK_VERIFY_RESPONSE = { checks: [], warning: [], errors: [] };

let MOCK_ACCESS_GRANT: VcLibrary.VerifiableCredential
let MOCK_ACCESS_GRANT: VcLibrary.VerifiableCredential;

beforeAll(async () => {
MOCK_ACCESS_GRANT = await verifiableCredentialToDataset(MOCK_ACCESS_GRANT_BASE)
MOCK_ACCESS_GRANT = await verifiableCredentialToDataset(
MOCK_ACCESS_GRANT_BASE,
);
});

it("uses the provided fetch if any", async () => {
Expand Down
4 changes: 3 additions & 1 deletion src/gConsent/manage/getAccessGrant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ describe("getAccessGrant", () => {
const accessGrant = await getAccessGrant("https://some.vc.url", {
fetch: mockedFetch,
});
expect(withoutDataset(accessGrant)).toEqual(withoutDataset(mockedAccessGrant));
expect(withoutDataset(accessGrant)).toEqual(
withoutDataset(mockedAccessGrant),
);
});

it("returns the access grant with the given IRI", async () => {
Expand Down
54 changes: 34 additions & 20 deletions src/gConsent/util/access.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

/* eslint-disable no-param-reassign */
import { type VerifiableCredential } from "@inrupt/solid-client-vc";
import type { UrlString } from "@inrupt/solid-client";
import type { DatasetCore, Quad } from "@rdfjs/types";
Expand Down Expand Up @@ -106,10 +106,11 @@ export const mockAccessRequestVc = async (
expandModeUri?: boolean;
skipValidation?: boolean;
},
modify?: (asObject: Record<string, any>) => void
// eslint-disable-next-line @typescript-eslint/no-explicit-any
modify?: (asObject: Record<string, any>) => void,
): Promise<AccessRequest & DatasetCore<Quad, Quad>> => {
const asObject = mockAccessRequestVcObject(options);
modify?.(asObject)
modify?.(asObject);

const asString = JSON.stringify(asObject, null, 2);
const asResponse = new Response(asString, {
Expand Down Expand Up @@ -150,8 +151,10 @@ export const mockAccessRequestVc = async (

if (framingOptions?.expandModeUri) {
accessRequest.credentialSubject.hasConsent.mode =
accessRequest.credentialSubject.hasConsent.mode.map(
(mode) => mode.startsWith('http') ? mode : `http://www.w3.org/ns/auth/acl#${mode}`,
accessRequest.credentialSubject.hasConsent.mode.map((mode) =>
mode.startsWith("http")
? mode
: `http://www.w3.org/ns/auth/acl#${mode}`,
);
}

Expand Down Expand Up @@ -203,7 +206,8 @@ export const mockAccessGrantVc = async (
// This should only be used for testing /issue calls
expandModeUri?: boolean;
},
modify?: (asObject: Record<string, any>) => void
// eslint-disable-next-line @typescript-eslint/no-explicit-any
modify?: (asObject: Record<string, any>) => void,
): Promise<AccessGrant & DatasetCore<Quad, Quad>> => {
const asObject = mockAccessGrantObject(options);
modify?.(asObject);
Expand All @@ -227,8 +231,10 @@ export const mockAccessGrantVc = async (
| { mode?: string[] | undefined }
| undefined;
if (providedConsent) {
providedConsent.mode = providedConsent.mode?.map(
(mode: string) => mode.startsWith('http') ? mode : `http://www.w3.org/ns/auth/acl#${mode}`,
providedConsent.mode = providedConsent.mode?.map((mode: string) =>
mode.startsWith("http")
? mode
: `http://www.w3.org/ns/auth/acl#${mode}`,
);
}
}
Expand All @@ -254,11 +260,15 @@ export const mockConsentRequestVc = async (
): Promise<
VerifiableCredential & BaseRequestBody & DatasetCore<Quad, Quad>
> => {
const requestVc = await mockAccessRequestVc(options, framingOptions, object => {
object.credentialSubject.hasConsent.forPurpose = ["https://some.purpose"];
object.expirationDate = new Date(2021, 8, 14).toISOString();
object.issuanceDate = new Date(2021, 8, 13).toISOString();
});
const requestVc = await mockAccessRequestVc(
options,
framingOptions,
(object) => {
object.credentialSubject.hasConsent.forPurpose = ["https://some.purpose"];
object.expirationDate = new Date(2021, 8, 14).toISOString();
object.issuanceDate = new Date(2021, 8, 13).toISOString();
},
);
return requestVc;
};

Expand All @@ -274,12 +284,16 @@ export const mockConsentGrantVc = async (
expandModeUri?: boolean;
},
): Promise<VerifiableCredential & BaseGrantBody & DatasetCore<Quad, Quad>> => {
const requestVc = await mockAccessGrantVc(options, framingOptions, object => {
object.credentialSubject.providedConsent.forPurpose = [
"https://some.purpose",
];
object.expirationDate = new Date(2021, 8, 14).toISOString();
object.issuanceDate = new Date(2021, 8, 13).toISOString();
});
const requestVc = await mockAccessGrantVc(
options,
framingOptions,
(object) => {
object.credentialSubject.providedConsent.forPurpose = [
"https://some.purpose",
];
object.expirationDate = new Date(2021, 8, 14).toISOString();
object.issuanceDate = new Date(2021, 8, 13).toISOString();
},
);
return requestVc;
};

0 comments on commit a0aa7a4

Please sign in to comment.