Skip to content

Commit

Permalink
chore: upgrade to
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswr committed Nov 26, 2023
1 parent 150bacd commit c6063b9
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 89 deletions.
131 changes: 69 additions & 62 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
},
"dependencies": {
"@inrupt/solid-client": "^1.25.1",
"@inrupt/solid-client-vc": "file:../solid-client-vc-js",
"@inrupt/solid-client-vc": "^0.8.0-beta.1",
"@inrupt/universal-fetch": "^1.0.1",
"@types/rdfjs__dataset": "^1.0.5",
"auth-header": "^1.0.0",
Expand Down
7 changes: 4 additions & 3 deletions src/common/getters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
} from "./getters";
import type { AccessGrant, AccessRequest } from "../gConsent";
import { TYPE, gc } from "./constants";

const { quad, namedNode, literal, blankNode } = DataFactory;

describe("getters", () => {
Expand Down Expand Up @@ -362,12 +363,12 @@ describe("getters", () => {

store.addQuad(
namedNode(getId(mockedGConsentGrant)),
namedNode('https://www.w3.org/2018/credentials#expirationDate'),
namedNode("https://www.w3.org/2018/credentials#expirationDate"),
namedNode("http://example.org/this/is/a/date"),
);

expect(() => getExpirationDate(store as any)).toThrow(
"Expected expiration date to be a Literal. Found [http://example.org/this/is/a/date] of type [NamedNode]."
"Expected expiration date to be a Literal. Found [http://example.org/this/is/a/date] of type [NamedNode].",
);
});

Expand All @@ -376,7 +377,7 @@ describe("getters", () => {

store.addQuad(
namedNode(getId(mockedGConsentGrant)),
namedNode('https://www.w3.org/2018/credentials#expirationDate'),
namedNode("https://www.w3.org/2018/credentials#expirationDate"),
literal("boo"),
);

Expand Down
10 changes: 8 additions & 2 deletions src/common/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
getCredentialSubject,
getIssuer,
getIssuanceDate,
getExpirationDate
getExpirationDate,
} from "@inrupt/solid-client-vc";
import type { AccessGrantGConsent } from "../gConsent/type/AccessGrant";
import type { AccessRequestGConsent } from "../gConsent/type/AccessRequest";
Expand Down Expand Up @@ -116,7 +116,13 @@ function getSingleObject(

return object;
}
export { getId, getIssuer, getIssuanceDate, getCredentialSubject, getExpirationDate };
export {
getId,
getIssuer,
getIssuanceDate,
getCredentialSubject,
getExpirationDate,
};

/**
* @internal
Expand Down
10 changes: 7 additions & 3 deletions src/common/verify/isValidAccessGrant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ describe("isValidAccessGrant", () => {
const { verifiableCredentialToDataset } = jest.requireActual<
typeof VcLibrary
>("@inrupt/solid-client-vc");
MOCK_ACCESS_GRANT = await verifiableCredentialToDataset(
MOCK_ACCESS_GRANT_BASE,
);
MOCK_ACCESS_GRANT =
await verifiableCredentialToDataset<VcLibrary.VerifiableCredentialBase>(
MOCK_ACCESS_GRANT_BASE,
{
includeVcProperties: true,
},
);
});

it("uses the provided fetch if any", async () => {
Expand Down
25 changes: 18 additions & 7 deletions src/fetch/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

import { jest, describe, it, expect, beforeAll } from "@jest/globals";
import { fetch as crossFetch, Response } from "@inrupt/universal-fetch";
import type { VerifiableCredential } from "@inrupt/solid-client-vc";
import type {
VerifiableCredential,
VerifiableCredentialBase,
} from "@inrupt/solid-client-vc";
import { verifiableCredentialToDataset } from "@inrupt/solid-client-vc";

import base64url from "base64url";
Expand Down Expand Up @@ -138,9 +141,13 @@ describe("getUmaConfiguration", () => {
describe("exchangeTicketForAccessToken", () => {
let MOCK_VC: VerifiableCredential;
beforeAll(async () => {
MOCK_VC = await verifiableCredentialToDataset(MOCK_VC_BASE, {
baseIRI: MOCK_VC_BASE.id,
});
MOCK_VC = await verifiableCredentialToDataset<VerifiableCredentialBase>(
MOCK_VC_BASE,
{
baseIRI: MOCK_VC_BASE.id,
includeVcProperties: true,
},
);
});

it("posts to the token endpoint and parses the resulting access token", async () => {
Expand Down Expand Up @@ -261,9 +268,13 @@ describe("boundFetch", () => {
describe("fetchWithVc", () => {
let MOCK_VC: VerifiableCredential;
beforeAll(async () => {
MOCK_VC = await verifiableCredentialToDataset(MOCK_VC_BASE, {
baseIRI: MOCK_VC_BASE.id,
});
MOCK_VC = await verifiableCredentialToDataset<VerifiableCredentialBase>(
MOCK_VC_BASE,
{
baseIRI: MOCK_VC_BASE.id,
includeVcProperties: true,
},
);
});

// These tests may be fairly brittle due to the nature of the mocked calls.
Expand Down
1 change: 1 addition & 0 deletions src/gConsent/guard/isAccessGrant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const GC_CONSENT_STATUS_EXPLICITLY_GIVEN =
export const GC_CONSENT_STATUS_REQUESTED =
"https://w3id.org/GConsent#ConsentStatusRequested";

// Implemented as isGConsentAccessGrant in src/common/getters
export function isAccessGrant<T extends BaseAccessVcBody>(
vc: T,
): vc is T & AccessGrantBody {
Expand Down
Loading

0 comments on commit c6063b9

Please sign in to comment.