Skip to content

Commit abf3720

Browse files
authored
fix: replace localhost with 127.0.0.1 (#32)
* fix: replace localhost with 127.0.0.1 * fix: handle notary server down
1 parent fee516e commit abf3720

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

server/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ app.get('/ipfs/:cid', async (req, res) => {
109109
};
110110
} else if (jsonProof.version === '0.1.0-alpha.7') {
111111
const notaryUrl = convertNotaryWsToHttp(jsonProof.meta.notaryUrl);
112-
const notaryPem = await fetchPublicKeyFromNotary(notaryUrl);
112+
const notaryPem = await fetchPublicKeyFromNotary(notaryUrl).catch(
113+
() => '',
114+
);
113115
const proof = await verifyV7(jsonProof.data, notaryPem);
114116
proof.notaryUrl = jsonProof.meta.notaryUrl;
115117
storeConfig.proofs.ipfs[req.params.cid].proof = {

web/utils/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ export async function verify(
128128
const vk = await tlsProof.verifyingKey();
129129
const verifyingKey = Buffer.from(vk.data).toString('hex');
130130
const notaryUrl = convertNotaryWsToHttp(attestation.meta.notaryUrl);
131-
const publicKey = await new NotaryServer(notaryUrl).publicKey();
131+
const publicKey = await new NotaryServer(notaryUrl)
132+
.publicKey()
133+
.catch(() => '');
132134

133135
return {
134136
version: '0.1.0-alpha.7',
@@ -151,7 +153,8 @@ export function convertNotaryWsToHttp(notaryWs: string) {
151153
const p = protocol === 'wss:' ? 'https:' : 'http:';
152154
const pt = port ? `:${port}` : '';
153155
const path = pathname === '/' ? '' : pathname.replace('/notarize', '');
154-
return p + '//' + hostname + pt + path;
156+
const h = hostname === 'localhost' ? '127.0.0.1' : hostname;
157+
return p + '//' + h + pt + path;
155158
}
156159

157160
function defer(): {

0 commit comments

Comments
 (0)