diff --git a/e2e/browser/test-app/components/accessGrants/index.tsx b/e2e/browser/test-app/components/accessGrants/index.tsx
index eee31fb3e..a90d832a0 100644
--- a/e2e/browser/test-app/components/accessGrants/index.tsx
+++ b/e2e/browser/test-app/components/accessGrants/index.tsx
@@ -20,12 +20,19 @@
//
import { getDefaultSession } from "@inrupt/solid-client-authn-browser";
-import type { AccessGrant } from "@inrupt/solid-client-access-grants";
+import type {
+ AccessGrant,
+ DatasetWithId,
+} from "@inrupt/solid-client-access-grants";
import {
issueAccessRequest,
redirectToAccessManagementUi,
getAccessGrant,
cancelAccessRequest,
+ getCustomFields,
+ getResourceOwner,
+ getResources,
+ getAccessModes,
} from "@inrupt/solid-client-access-grants";
import {
getPodUrlAll,
@@ -39,14 +46,63 @@ import { useRouter } from "next/router";
const session = getDefaultSession();
const SHARED_FILE_CONTENT = "Some content.\n";
+function AccessCredential({
+ vc,
+ testId,
+}: {
+ vc: DatasetWithId | undefined;
+ testId: "access-request" | "access-grant";
+}) {
+ if (vc === undefined) {
+ return undefined;
+ }
+ return (
+
+
+ Resource owner:{" "}
+ {getResourceOwner(vc)}
+
+
+ Requested resources:{" "}
+ {getResources(vc)}
+
+
+ Requested modes:{" "}
+
+ {JSON.stringify(getAccessModes(vc))}
+
+
+
+ Custom fields:{" "}
+
+ {JSON.stringify(getCustomFields(vc))}
+
+
+
+ );
+}
+
export default function AccessController({
setErrorMessage,
}: {
setErrorMessage: (msg: string) => void;
}) {
const [accessGrant, setAccessGrant] = useState();
- const [accessRequest, setAccessRequest] = useState();
+ const [accessRequestUrl, setAccessRequestUrl] = useState();
+ const [accessRequest, setAccessRequest] = useState();
const [sharedResourceIri, setSharedResourceIri] = useState();
+ const [customInt, setCustomInt] = useState();
+ const [customIntUrl, setCustomIntUrl] = useState(
+ "https://example.org/my-int",
+ );
+ const [customStr, setCustomStr] = useState();
+ const [customStrUrl, setCustomStrUrl] = useState(
+ "https://example.org/my-string",
+ );
+ const [customBoolean, setCustomBoolean] = useState();
+ const [customBooleanUrl, setCustomBooleanUrl] = useState(
+ "https://example.org/my-boolean",
+ );
const router = useRouter();
const handleCreate = async () => {
@@ -103,9 +159,25 @@ export default function AccessController({
},
{
fetch: session.fetch,
+ returnLegacyJsonld: false,
+ customFields: new Set([
+ {
+ key: new URL(customIntUrl),
+ value: customInt!,
+ },
+ {
+ key: new URL(customStrUrl),
+ value: customStr!,
+ },
+ {
+ key: new URL(customBooleanUrl),
+ value: customBoolean!,
+ },
+ ]),
},
);
setAccessRequest(accessRequestReturned);
+ setAccessRequestUrl(accessRequestReturned.id);
};
const handleRevoke = async () => {
@@ -117,6 +189,7 @@ export default function AccessController({
fetch: session.fetch,
});
setAccessRequest(undefined);
+ setAccessRequestUrl(undefined);
};
const handleCallAuthedGrant = async () => {
@@ -129,15 +202,20 @@ export default function AccessController({
};
const handleAccessRequest = async () => {
+ if (accessRequestUrl === undefined || !URL.canParse(accessRequestUrl)) {
+ console.error(
+ "Please issue an Access Request and provide its URL before being redirected.",
+ );
+ return;
+ }
await redirectToAccessManagementUi(
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- accessRequest!,
+ accessRequestUrl,
`http://localhost:3000/`,
{
redirectCallback: (url: string) => {
window.location.replace(url);
},
- fallbackAccessManagementUi: `https://amc.inrupt.com/accessRequest/`,
+ fallbackAccessManagementUi: "https://amc.inrupt.com/accessRequest/",
fetch: session.fetch,
},
);
@@ -181,6 +259,59 @@ export default function AccessController({
Created resource:{" "}
{sharedResourceIri}
+
+ Custom fields:{" "}
+
+
Access Request to Approve:{" "}
{
- setAccessRequest(e.currentTarget.value);
+ setAccessRequestUrl(e.currentTarget.value);
}}
+ value={accessRequestUrl}
/>
@@ -217,15 +349,11 @@ export default function AccessController({
Issued access request:{" "}
-
- {accessRequest && JSON.stringify(accessRequest, null, 2)}
-
+
Granted access:{" "}
-
- {accessGrant && JSON.stringify(accessGrant, null, 2)}
-
+