Skip to content

Commit

Permalink
fix: replace localhost with 127.0.0.1 (#32)
Browse files Browse the repository at this point in the history
* fix: replace localhost with 127.0.0.1

* fix: handle notary server down
  • Loading branch information
0xtsukino authored Oct 31, 2024
1 parent fee516e commit abf3720
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion server/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ app.get('/ipfs/:cid', async (req, res) => {
};
} else if (jsonProof.version === '0.1.0-alpha.7') {
const notaryUrl = convertNotaryWsToHttp(jsonProof.meta.notaryUrl);
const notaryPem = await fetchPublicKeyFromNotary(notaryUrl);
const notaryPem = await fetchPublicKeyFromNotary(notaryUrl).catch(
() => '',
);
const proof = await verifyV7(jsonProof.data, notaryPem);
proof.notaryUrl = jsonProof.meta.notaryUrl;
storeConfig.proofs.ipfs[req.params.cid].proof = {
Expand Down
7 changes: 5 additions & 2 deletions web/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ export async function verify(
const vk = await tlsProof.verifyingKey();
const verifyingKey = Buffer.from(vk.data).toString('hex');
const notaryUrl = convertNotaryWsToHttp(attestation.meta.notaryUrl);
const publicKey = await new NotaryServer(notaryUrl).publicKey();
const publicKey = await new NotaryServer(notaryUrl)
.publicKey()
.catch(() => '');

return {
version: '0.1.0-alpha.7',
Expand All @@ -151,7 +153,8 @@ export function convertNotaryWsToHttp(notaryWs: string) {
const p = protocol === 'wss:' ? 'https:' : 'http:';
const pt = port ? `:${port}` : '';
const path = pathname === '/' ? '' : pathname.replace('/notarize', '');
return p + '//' + hostname + pt + path;
const h = hostname === 'localhost' ? '127.0.0.1' : hostname;
return p + '//' + h + pt + path;
}

function defer(): {
Expand Down

0 comments on commit abf3720

Please sign in to comment.