Skip to content

Commit

Permalink
fix: check port number for notary url (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtsukino authored Oct 10, 2024
1 parent 24cbc6a commit fee516e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions web/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ export async function verify(
const notaryUrl = convertNotaryWsToHttp(attestation.meta.notaryUrl);
const publicKey = await new NotaryServer(notaryUrl).publicKey();

if (verifyingKey !== publicKey)
throw new Error(`Notary key doesn't match verifying key`);

return {
version: '0.1.0-alpha.7',
sent: transcript.sent(),
Expand All @@ -150,10 +147,11 @@ export async function verify(
}

export function convertNotaryWsToHttp(notaryWs: string) {
const { protocol, pathname, hostname } = new URL(notaryWs);
const p = protocol === 'wss:' ? 'https:' : 'http';
const { protocol, pathname, hostname, port } = new URL(notaryWs);
const p = protocol === 'wss:' ? 'https:' : 'http:';
const pt = port ? `:${port}` : '';
const path = pathname === '/' ? '' : pathname.replace('/notarize', '');
return p + '//' + hostname + path;
return p + '//' + hostname + pt + path;
}

function defer(): {
Expand Down

0 comments on commit fee516e

Please sign in to comment.