Skip to content

Commit

Permalink
fix: use proxy for uniresolver (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
martines3000 authored Aug 31, 2023
1 parent a2ce3aa commit 637ce36
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-eggs-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@blockchain-lab-um/masca': patch
---

Use proxy for uniresolver service
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"registry": "https://registry.npmjs.org"
}
},
"shasum": "VG30MRut8t/zkwLk99U0kxXD/1l9zlt0zATco8T5hQs="
"shasum": "ctYwri5bRRpuJ89CeP/WLcnwyVxhzM2wCsDV7ejOGWQ="
},
"initialPermissions": {
"endowment:ethereum-provider": {},
Expand Down
9 changes: 5 additions & 4 deletions packages/snap/src/UniversalResolver.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
Resolvable,
} from 'did-resolver';

import { UNIRESOLVER_PROXY_URL } from './utils/config';

/**
* Function that resolves a DID string using the universal resolver
* @returns DIDResolutionResult
Expand All @@ -16,10 +18,9 @@ const resolveDid = async (
_options: DIDResolutionOptions
): Promise<DIDResolutionResult> => {
try {
const response = await fetch(
`https://dev.uniresolver.io/1.0/identifiers/${did}`,
{ signal: AbortSignal.timeout(15000) }
);
const response = await fetch(`${UNIRESOLVER_PROXY_URL}/${did}`, {
signal: AbortSignal.timeout(15000),
});
const data = (await response.json()) as DIDResolutionResult;
return data;
} catch (e) {
Expand Down
5 changes: 2 additions & 3 deletions packages/snap/src/polygon-id/Polygon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { DIDResolutionOptions, DIDResolutionResult } from 'did-resolver';

import EthereumService from '../Ethereum.service';
import StorageService from '../storage/Storage.service';
import { UNIRESOLVER_PROXY_URL } from '../utils/config';
import CircuitStorageService from './CircuitStorage.service';
import {
BLOCKCHAINS,
Expand Down Expand Up @@ -506,9 +507,7 @@ class PolygonService {
_?: DIDResolutionOptions
): Promise<DIDResolutionResult> => {
try {
const response = await fetch(
`https://dev.uniresolver.io/1.0/identifiers/${did}`
);
const response = await fetch(`${UNIRESOLVER_PROXY_URL}/${did}`);
const data = await response.json();
return data as DIDResolutionResult;
} catch (error: unknown) {
Expand Down
2 changes: 2 additions & 0 deletions packages/snap/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import type {
} from '@blockchain-lab-um/masca-types';
import cloneDeep from 'lodash.clonedeep';

export const UNIRESOLVER_PROXY_URL = 'https://masca.io/api/proxy/uniresolver';

const emptyPolygonBaseState: PolygonBaseState = {
credentials: {},
identities: {},
Expand Down

0 comments on commit 637ce36

Please sign in to comment.