-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support universal resolver in verification lib (#637)
- Loading branch information
1 parent
786b340
commit 411a30d
Showing
20 changed files
with
802 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blockchain-lab-um/did-provider-key": patch | ||
--- | ||
|
||
Update Vitest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blockchain-lab-um/veramo-datamanager": patch | ||
--- | ||
|
||
Update Vitest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blockchain-lab-um/utils": patch | ||
--- | ||
|
||
Update Vitest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blockchain-lab-um/extended-verification": patch | ||
--- | ||
|
||
Update Vitest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blockchain-lab-um/extended-verification": minor | ||
--- | ||
|
||
Add universal resolver support. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blockchain-lab-um/oidc-client-plugin": patch | ||
--- | ||
|
||
Update Vitest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@blockchain-lab-um/masca": patch | ||
--- | ||
|
||
Update Vitest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@blockchain-lab-um/masca": patch | ||
"@blockchain-lab-um/utils": patch | ||
--- | ||
|
||
Move UniversalResolver service implementation to utils library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import type { | ||
DIDResolutionOptions, | ||
DIDResolutionResult, | ||
ParsedDID, | ||
Resolvable, | ||
} from 'did-resolver'; | ||
|
||
export class UniversalResolverService { | ||
static universalResolverUrl: string | null = null; | ||
|
||
static init(universalResolverUrl = 'https://masca.io/api/proxy/uniresolver') { | ||
UniversalResolverService.universalResolverUrl = universalResolverUrl; | ||
} | ||
|
||
/** | ||
* Function that resolves a DID string using the universal resolver | ||
* @returns DIDResolutionResult | ||
*/ | ||
static resolveDid = async ( | ||
did: string, | ||
_parsed: ParsedDID, | ||
_resolver: Resolvable, | ||
_options: DIDResolutionOptions | ||
): Promise<DIDResolutionResult> => { | ||
try { | ||
const response = await fetch( | ||
`${UniversalResolverService.universalResolverUrl}/${did}`, | ||
{ | ||
signal: AbortSignal.timeout(15000), | ||
} | ||
); | ||
const data = (await response.json()) as DIDResolutionResult; | ||
return data; | ||
} catch (e) { | ||
let errorMsg = 'Failed to resolve DID Document'; | ||
if (typeof e === 'string') { | ||
errorMsg = e; | ||
} | ||
if ((e as Error).message && typeof (e as Error).message === 'string') { | ||
errorMsg = (e as Error).message; | ||
} | ||
return { | ||
didDocument: null, | ||
didDocumentMetadata: {}, | ||
didResolutionMetadata: { | ||
error: errorMsg, | ||
}, | ||
}; | ||
} | ||
}; | ||
|
||
static getResolver() { | ||
return { | ||
ens: UniversalResolverService.resolveDid, | ||
ion: UniversalResolverService.resolveDid, | ||
ebsi: UniversalResolverService.resolveDid, | ||
web: UniversalResolverService.resolveDid, | ||
github: UniversalResolverService.resolveDid, | ||
cheqd: UniversalResolverService.resolveDid, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.