From 6ad8e1b07dcd4202c095a8008ee3cc5cdf6ac672 Mon Sep 17 00:00:00 2001
From: Nicolas Ayral Seydoux
Date: Thu, 12 Dec 2024 13:52:13 +0100
Subject: [PATCH 1/6] Prepare demo
---
.../components/accessGrants/index.tsx | 147 ++++++++++++++++--
e2e/browser/test/e2e.playwright.ts | 14 +-
2 files changed, 145 insertions(+), 16 deletions(-)
diff --git a/e2e/browser/test-app/components/accessGrants/index.tsx b/e2e/browser/test-app/components/accessGrants/index.tsx
index eee31fb3e..4651cb4a9 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,
@@ -33,20 +40,68 @@ import {
getSourceUrl,
deleteFile,
} from "@inrupt/solid-client";
-import React, { useState } from "react";
+import React, { useEffect, useState } from "react";
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 [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,6 +158,21 @@ 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);
@@ -137,7 +207,7 @@ export default function AccessController({
redirectCallback: (url: string) => {
window.location.replace(url);
},
- fallbackAccessManagementUi: `https://amc.inrupt.com/accessRequest/`,
+ fallbackAccessManagementUi: "http://localhost:3001/accessRequest/", // `https://amc.inrupt.com/accessRequest/`,
fetch: session.fetch,
},
);
@@ -181,15 +251,68 @@ export default function AccessController({
Created resource:{" "}
{sharedResourceIri}
+
+ Custom fields:{" "}
+
+
Access Request to Approve:{" "}
{
- setAccessRequest(e.currentTarget.value);
- }}
+ // onChange={(e) => {
+ // setAccessRequest(e.currentTarget.value);
+ // }}
/>
@@ -216,16 +339,10 @@ export default function AccessController({
- Issued access request:{" "}
-
- {accessRequest && JSON.stringify(accessRequest, null, 2)}
-
+ Issued access request:
- Granted access:{" "}
-
- {accessGrant && JSON.stringify(accessGrant, null, 2)}
-
+ Granted access:
- Issued access request:
+ Issued access request:{" "}
+
- Granted access:
+ Granted access:{" "}
+