From 989f154e4682df8748319b4a6d7cdf5bed5c3ce2 Mon Sep 17 00:00:00 2001 From: TYRONE AVNIT Date: Tue, 3 Sep 2024 08:23:45 -0500 Subject: [PATCH 1/3] TECH-292 - Show the credential when presented --- src/civic_sign_frontend_demo/src/App.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/civic_sign_frontend_demo/src/App.tsx b/src/civic_sign_frontend_demo/src/App.tsx index f59df11..104b88e 100644 --- a/src/civic_sign_frontend_demo/src/App.tsx +++ b/src/civic_sign_frontend_demo/src/App.tsx @@ -9,6 +9,7 @@ function App() { const [principal, setPrincipal] = useState(undefined); const [urlCode, setUrlCode] = useState(null); const [selectedGatekeeperNetwork, setSelectedGatekeeperNetwork] = useState(config.gatekeeperNetworks[0]); + const [credentialCheckResponse, setCredentialCheckResponse] = useState(undefined); // Assume we have an array of available gatekeeperNetworks const gatekeeperNetworks = useMemo(() => config.gatekeeperNetworks, []); @@ -38,24 +39,36 @@ function App() { }, []); const handleCredentialCheck = useCallback(async (credential?: CredentialCheckResponse, error?: Error) => { - console.log('handleCredentialCheck', credential, error); + if (error) { + console.error('Error checking credential:', error); + return; + } + console.log('Credential check response:', credential); + setCredentialCheckResponse(credential); }, []); const handleGatekeeperNetworkChange = useCallback((event: React.ChangeEvent) => { const selectedNetwork = gatekeeperNetworks.find((network) => network.name === event.target.value); console.log('Selected network:', selectedNetwork); setSelectedGatekeeperNetwork(selectedNetwork || gatekeeperNetworks[0]); + setCredentialCheckResponse(undefined); }, []); return (
-
+
DFINITY logo {principal ? (

Welcome to the ICP Relying Canister

Logged in as {principal?.toText()}

+ {credentialCheckResponse && ( +
+

Response:

+

{JSON.stringify(credentialCheckResponse.credential, undefined, 2)}

+
+ )} )}
+
); } From f5dd3078e0cf721e1d6ccfd61889ee11a00ea2b6 Mon Sep 17 00:00:00 2001 From: TYRONE AVNIT Date: Tue, 3 Sep 2024 08:27:48 -0500 Subject: [PATCH 2/3] TECH-292 - Update UI --- src/civic_sign_frontend_demo/src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/civic_sign_frontend_demo/src/App.tsx b/src/civic_sign_frontend_demo/src/App.tsx index 104b88e..ffaafbf 100644 --- a/src/civic_sign_frontend_demo/src/App.tsx +++ b/src/civic_sign_frontend_demo/src/App.tsx @@ -56,7 +56,7 @@ function App() { return (
-
+
DFINITY logo {principal ? ( From d785ce402effaae3e326b649f88680cba4afd900 Mon Sep 17 00:00:00 2001 From: TYRONE AVNIT Date: Tue, 3 Sep 2024 08:39:00 -0500 Subject: [PATCH 3/3] TECH-292 - Update to use pre instead of p tag --- src/civic_sign_frontend_demo/src/App.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/civic_sign_frontend_demo/src/App.tsx b/src/civic_sign_frontend_demo/src/App.tsx index ffaafbf..fcb2b7b 100644 --- a/src/civic_sign_frontend_demo/src/App.tsx +++ b/src/civic_sign_frontend_demo/src/App.tsx @@ -64,9 +64,13 @@ function App() {

Welcome to the ICP Relying Canister

Logged in as {principal?.toText()}

{credentialCheckResponse && ( -
-

Response:

-

{JSON.stringify(credentialCheckResponse.credential, undefined, 2)}

+
+

Response:

+
+
+                    {JSON.stringify(credentialCheckResponse.credential, null, 2)}
+                  
+
)}