Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: poc tweaks to get running (needs tidy up) #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ services:
dockerfile: ./packages/server/Dockerfile
restart: unless-stopped
environment:
- ISSUER_OOBI=${ISSUER_OOBI}
- ISSUER_PRE=${ISSUER_PRE}
- ISSUER_REGK=${ISSUER_REGK}
- KERIA_ENDPOINT=${KERIA_ENDPOINT:-http://keria:3901}
- KERIA_BOOT_ENDPOINT=${KERIA_BOOT_ENDPOINT:-http://keria:3903}
- ISSUER_OOBI=${ISSUER_OOBI:-http://t10n.guild1.com:3902/oobi/EN-JeVj67PgehbEBD8W7W5aRJ8FZ9D2_WTaIlb5UprRL/agent/EKn5dfFLpsnzOA-QRBBMJM6E0VuHjmRo5DDJYYx0lp9M}
- ISSUER_PRE=${ISSUER_PRE:-EN-JeVj67PgehbEBD8W7W5aRJ8FZ9D2_WTaIlb5UprRL}
- ISSUER_REGK=${ISSUER_REGK:-EEPQVQ6uMfF_aTHVXn8oo6DceQKkhNvIX9UulTg1Cx1G}
- KERIA_ENDPOINT=${KERIA_ENDPOINT:-http://keria-g1:3901}
- KERIA_BOOT_ENDPOINT=${KERIA_BOOT_ENDPOINT:-http://keria-g1:3903}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me keria-g1 is on the same traefik network (commented out below). This should be cardanofoundation/cf-idw-keria:keria-3c72a12c8e8fea354b603d8406b31f6bab860a11.

It doesn't need to be the same one as the issuer, whichever works.

ports:
- 3000:3000
- 5632:3000
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

port changes just as these were already open on the machine, ignore..

volumes:
- server-data:/app/data

Expand All @@ -24,9 +24,14 @@ services:
dockerfile: ./packages/ui/Dockerfile
restart: unless-stopped
environment:
- VITE_BACKEND_BASE_URL=${VITE_BACKEND_BASE_URL:-http://localhost:3000}
- VITE_BACKEND_BASE_URL=${VITE_BACKEND_BASE_URL:-http://server:3000}
ports:
- 5173:80
- 5633:80

volumes:
server-data:

# networks:
# default:
# name: traefik
# external: true
12 changes: 9 additions & 3 deletions packages/server/src/controllers/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,20 @@ export async function verifyCredential(req: Request, res: Response) {
// @TODO - foconnor: Improve typing post PoC.
const acdcked = await (await fetch(`http://t10n.guild1.com:9090/api/public/attachment/${vciHex}`)).json() as Dict<any>;
const issked = await (await fetch(`http://t10n.guild1.com:9090/api/public/attachment/${issHex}`)).json() as Dict<any>;

acdcked.d = vci;
issked.d = iss;

acdcked.d = vci;
issked.d = iss;

console.log(`\nACDC is ${JSON.stringify(acdcked, null, 2)}`);
console.log(`\niss is ${JSON.stringify(issked, null, 2)}`);

// This could be better done in the background with watchers
console.log(`Querying issuer ${config.issuerPre}`);
await waitAndGetDoneOp(client, await client.keyStates().query(config.issuerPre));
console.log(`Querying TEL (${config.issuerPre}, ${config.registryId}, ${acdcked.d})`);
await waitAndGetDoneOp(client, await client.keyStates().telquery(config.issuerPre, config.registryId, acdcked.d));

console.log(`Preparing to verify...`);
const completedOp = await waitAndGetDoneOp(client, await client.credentials().verify(new Serder(Saider.saidify(acdcked)[1]), new Serder(Saider.saidify(issked)[1])));
res.status(200).send(completedOp?.metadata?.ced);
}
3 changes: 2 additions & 1 deletion packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ async function getClient(): Promise<SignifyClient> {

// If already resolved, this is very fast
await waitAndGetDoneOp(client, await client.oobis().resolve(config.issuerOobi));
await waitAndGetDoneOp(client, await client.oobis().resolve(`http://localhost:3000/oobi/${config.schemaSaid}`));
// await waitAndGetDoneOp(client, await client.oobis().resolve(`http://server:3000/oobi/${config.schemaSaid}`));
await waitAndGetDoneOp(client, await client.oobis().resolve(`http://t10n.guild1.com:3000/oobi/EA3NRCtGF0czMPeiG5-CWbgCnmcpBDpPo2mYlxoGkk0j`));
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe was some issue in the production build overriding VITE_BACKEND_BASE_URL via the docker URL. Something to fix


try {
await client.registries().get(config.registryId);
Expand Down
21 changes: 11 additions & 10 deletions packages/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ enum BLOCKFROST_ASSETS_URL {
PREVIEW = "https://preview.blockfrost.cf-systems.org"
}

const BACKEND_BASE_URL = import.meta.env.VITE_BACKEND_BASE_URL ?? "http://localhost:3000";
const BACKEND_BASE_URL = import.meta.env.VITE_BACKEND_BASE_URL ?? "http://dev.keria.cf-keripy.metadata.dev.cf-deployments.org:5632";
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Whatever the case this should be the URL of the /server deployment

const POLICY_ID = import.meta.env.VITE_POLICY_ID ?? "d441227553a0f1a965fee7d60a0f724b368dd1bddbc208730fccebcf";

async function fetchBlockfrost(path: string) {
Expand All @@ -21,16 +21,17 @@ async function fetchBlockfrost(path: string) {
}

async function verifyACDC(vci: string, iss: string) {
const credential = await fetch(`${BACKEND_BASE_URL}/credentials/${vci}`).catch(error => {
console.error(error); // @TODO - check for actual 404 or re-throw
});
// const credential = await fetch(`${BACKEND_BASE_URL}/credentials/${vci}`).catch(error => {
// console.error(error); // @TODO - check for actual 404 or re-throw
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here was to check if it exists already and just return it if so, but fetch throws an error for 404 so I just commented it out. Would be easy to adjust.

// });

if (!credential) return;
// if (!credential) return;

// @TODO - foconnor: If exists, re-query if not revoked. Revocation not in scope for PoC.
if (credential.ok) {
return await credential.json();
}
//if (credential.ok) {
// return await credential.json();
//}
if (vci !== "EDlZ9u5_yGUiXWyNx2Tp-N4SXj5oRxF6KL8c3gMP7XbR") return;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this ACDC is from an old version. Maybe this change can be reverted, from memory I think it was just noise in the logs when I was debugging the final issues.


const response = await fetch(`${BACKEND_BASE_URL}/credentials/verify`, {
method: "POST",
Expand Down Expand Up @@ -64,7 +65,7 @@ export function App() {
if (acdcMetadata.claimACDCSaid && acdcMetadata.claimIssSaid) {
const result = await verifyACDC(acdcMetadata.claimACDCSaid, acdcMetadata.claimIssSaid);
if (result) {
setCredentials([...credentials, { data: result.sad, txid: historyItem.tx_hash }]);
setCredentials([...credentials, { data: result, txid: historyItem.tx_hash }]);
}
}
}
Expand All @@ -77,7 +78,7 @@ export function App() {
fetchACDCs();
}
}, [isConnected]);

return (
<>
<ConnectWalletButton
Expand Down