Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ens-did-resolver

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ens-did-resolver - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

lib/index.modern.mjs

43

lib/index.js

@@ -7,6 +7,3 @@ var bignumber = require('@ethersproject/bignumber');

mainnet: '0x1',
ropsten: '0x3',
rinkeby: '0x4',
goerli: '0x5',
kovan: '0x2a'
goerli: '0x5'
};

@@ -56,17 +53,5 @@ const knownNetworks = { ...knownInfuraNetworks,

}, {
name: 'ropsten',
chainId: '0x3',
provider: new providers.InfuraProvider('ropsten', projectId)
}, {
name: 'rinkeby',
chainId: '0x4',
provider: new providers.InfuraProvider('rinkeby', projectId)
}, {
name: 'goerli',
chainId: '0x5',
provider: new providers.InfuraProvider('goerli', projectId)
}, {
name: 'kovan',
chainId: '0x2a',
provider: new providers.InfuraProvider('kovan', projectId)
}];

@@ -266,19 +251,15 @@ return configureNetworks({

return Promise.resolve(relationships.reduce(function (memo, relationship) {
try {
return Promise.resolve(memo).then(function () {
const _temp5 = _catch(function () {
return Promise.resolve(getEnsRecord(ensResolver, `org.w3c.did.${relationship}`)).then(function (verificationMethod) {
if (verificationMethod) {
if (didDocument) {
didDocument[relationship] = [...(didDocument[relationship] || []), ...filterValidVerificationMethods(did, verificationMethod, verificationMethods)];
}
return Promise.resolve(memo).then(function () {
const _temp5 = _catch(function () {
return Promise.resolve(getEnsRecord(ensResolver, `org.w3c.did.${relationship}`)).then(function (verificationMethod) {
if (verificationMethod) {
if (didDocument) {
didDocument[relationship] = [...(didDocument[relationship] || []), ...filterValidVerificationMethods(did, verificationMethod, verificationMethods)];
}
});
}, function () {});
}
});
}, function () {});
if (_temp5 && _temp5.then) return _temp5.then(function () {});
});
} catch (e) {
return Promise.reject(e);
}
if (_temp5 && _temp5.then) return _temp5.then(function () {});
});
}, Promise.resolve())).then(function () {

@@ -285,0 +266,0 @@ var _didDocument;

@@ -7,6 +7,3 @@ import { BigNumber } from '@ethersproject/bignumber';

mainnet: '0x1',
ropsten: '0x3',
rinkeby: '0x4',
goerli: '0x5',
kovan: '0x2a'
goerli: '0x5'
};

@@ -56,17 +53,5 @@ const knownNetworks = { ...knownInfuraNetworks,

}, {
name: 'ropsten',
chainId: '0x3',
provider: new InfuraProvider('ropsten', projectId)
}, {
name: 'rinkeby',
chainId: '0x4',
provider: new InfuraProvider('rinkeby', projectId)
}, {
name: 'goerli',
chainId: '0x5',
provider: new InfuraProvider('goerli', projectId)
}, {
name: 'kovan',
chainId: '0x2a',
provider: new InfuraProvider('kovan', projectId)
}];

@@ -266,19 +251,15 @@ return configureNetworks({

return Promise.resolve(relationships.reduce(function (memo, relationship) {
try {
return Promise.resolve(memo).then(function () {
const _temp5 = _catch(function () {
return Promise.resolve(getEnsRecord(ensResolver, `org.w3c.did.${relationship}`)).then(function (verificationMethod) {
if (verificationMethod) {
if (didDocument) {
didDocument[relationship] = [...(didDocument[relationship] || []), ...filterValidVerificationMethods(did, verificationMethod, verificationMethods)];
}
return Promise.resolve(memo).then(function () {
const _temp5 = _catch(function () {
return Promise.resolve(getEnsRecord(ensResolver, `org.w3c.did.${relationship}`)).then(function (verificationMethod) {
if (verificationMethod) {
if (didDocument) {
didDocument[relationship] = [...(didDocument[relationship] || []), ...filterValidVerificationMethods(did, verificationMethod, verificationMethods)];
}
});
}, function () {});
}
});
}, function () {});
if (_temp5 && _temp5.then) return _temp5.then(function () {});
});
} catch (e) {
return Promise.reject(e);
}
if (_temp5 && _temp5.then) return _temp5.then(function () {});
});
}, Promise.resolve())).then(function () {

@@ -285,0 +266,0 @@ var _didDocument;

@@ -9,6 +9,3 @@ (function (global, factory) {

mainnet: '0x1',
ropsten: '0x3',
rinkeby: '0x4',
goerli: '0x5',
kovan: '0x2a'
goerli: '0x5'
};

@@ -58,17 +55,5 @@ const knownNetworks = { ...knownInfuraNetworks,

}, {
name: 'ropsten',
chainId: '0x3',
provider: new providers.InfuraProvider('ropsten', projectId)
}, {
name: 'rinkeby',
chainId: '0x4',
provider: new providers.InfuraProvider('rinkeby', projectId)
}, {
name: 'goerli',
chainId: '0x5',
provider: new providers.InfuraProvider('goerli', projectId)
}, {
name: 'kovan',
chainId: '0x2a',
provider: new providers.InfuraProvider('kovan', projectId)
}];

@@ -268,19 +253,15 @@ return configureNetworks({

return Promise.resolve(relationships.reduce(function (memo, relationship) {
try {
return Promise.resolve(memo).then(function () {
const _temp5 = _catch(function () {
return Promise.resolve(getEnsRecord(ensResolver, `org.w3c.did.${relationship}`)).then(function (verificationMethod) {
if (verificationMethod) {
if (didDocument) {
didDocument[relationship] = [...(didDocument[relationship] || []), ...filterValidVerificationMethods(did, verificationMethod, verificationMethods)];
}
return Promise.resolve(memo).then(function () {
const _temp5 = _catch(function () {
return Promise.resolve(getEnsRecord(ensResolver, `org.w3c.did.${relationship}`)).then(function (verificationMethod) {
if (verificationMethod) {
if (didDocument) {
didDocument[relationship] = [...(didDocument[relationship] || []), ...filterValidVerificationMethods(did, verificationMethod, verificationMethods)];
}
});
}, function () {});
}
});
}, function () {});
if (_temp5 && _temp5.then) return _temp5.then(function () {});
});
} catch (e) {
return Promise.reject(e);
}
if (_temp5 && _temp5.then) return _temp5.then(function () {});
});
}, Promise.resolve())).then(function () {

@@ -287,0 +268,0 @@ var _didDocument;

{
"name": "ens-did-resolver",
"version": "1.0.0",
"version": "1.0.1",
"description": "Resolve DID documents for ENS",

@@ -62,21 +62,21 @@ "source": "src/index.ts",

"devDependencies": {
"@babel/core": "7.14.6",
"@babel/preset-env": "7.14.7",
"@babel/preset-typescript": "7.14.5",
"@babel/core": "7.19.3",
"@babel/preset-env": "7.19.3",
"@babel/preset-typescript": "7.18.6",
"@semantic-release/changelog": "5.0.1",
"@semantic-release/git": "9.0.0",
"@types/jest": "26.0.23",
"@typescript-eslint/eslint-plugin": "4.28.0",
"@typescript-eslint/parser": "4.28.0",
"babel-jest": "27.0.5",
"eslint": "7.29.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-jest": "24.3.6",
"eslint-plugin-prettier": "3.4.0",
"@semantic-release/git": "9.0.1",
"@types/jest": "26.0.24",
"@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0",
"babel-jest": "27.5.1",
"eslint": "7.32.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jest": "24.7.0",
"eslint-plugin-prettier": "3.4.1",
"ganache-cli": "6.12.2",
"jest": "27.0.5",
"microbundle": "0.13.3",
"prettier": "2.3.2",
"semantic-release": "17.4.4",
"typescript": "4.3.4"
"jest": "27.5.1",
"microbundle": "0.15.1",
"prettier": "2.7.1",
"semantic-release": "17.4.7",
"typescript": "4.8.4"
},

@@ -83,0 +83,0 @@ "dependencies": {

@@ -11,5 +11,6 @@ import { DIDDocument, DIDResolutionResult, Resolvable, Resolver } from 'did-resolver'

let didResolver: Resolvable = new Resolver(
getResolver({ rpcUrl: 'https://ropsten.infura.io/v3/e471b8639c314004ae67ec0078f70102' })
getResolver({ rpcUrl: 'https://mainnet.infura.io/v3/e471b8639c314004ae67ec0078f70102' })
)
const did = 'did:ens:oliver-rop.eth'
const did = 'did:ens:vitalik.eth'
const ethrAddr = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
const resolutionResult = await didResolver.resolve(did)

@@ -21,5 +22,5 @@ expect(resolutionResult).toEqual<DIDResolutionResult>({

{
id: `${did}#Web3PublicProfile-0x773230C8719783C18147F18BbB8340a347196eE5`,
id: `${did}#Web3PublicProfile-${ethrAddr}`,
type: 'Web3PublicProfile',
serviceEndpoint: 'oliver-rop.eth',
serviceEndpoint: 'vitalik.eth',
},

@@ -29,19 +30,13 @@ ],

{
id: `${did}#0x773230C8719783C18147F18BbB8340a347196eE5`,
id: `${did}#${ethrAddr}`,
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: did,
blockchainAccountId: '0x773230C8719783C18147F18BbB8340a347196eE5@eip155:3',
blockchainAccountId: `${ethrAddr}@eip155:1`,
},
{
id: `${did}#my-id`,
publicKeyMultibase: 'z9hFgmPVfmBZwRvFEyniQDBkz9LmV7gDEqytWyGZLmDXE',
controller: did,
type: 'X25519KeyAgreementKey2019',
},
],
authentication: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
capabilityDelegation: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
capabilityInvocation: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
assertionMethod: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
keyAgreement: [`${did}#my-id`],
authentication: [`${did}#${ethrAddr}`],
capabilityDelegation: [`${did}#${ethrAddr}`],
capabilityInvocation: [`${did}#${ethrAddr}`],
assertionMethod: [`${did}#${ethrAddr}`],
keyAgreement: [],
},

@@ -56,34 +51,39 @@ didDocumentMetadata: {},

let didResolver: Resolvable = new Resolver(
getResolver({ name: 'ropsten', rpcUrl: 'https://ropsten.infura.io/v3/e471b8639c314004ae67ec0078f70102' })
getResolver({ name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/e471b8639c314004ae67ec0078f70102' })
)
const did = 'did:ens:ropsten:oliver-rop.eth'
const result = await didResolver.resolve(did)
expect(result.didDocument).toEqual<DIDDocument>({
id: did,
service: [
{
id: `${did}#Web3PublicProfile-0x773230C8719783C18147F18BbB8340a347196eE5`,
type: 'Web3PublicProfile',
serviceEndpoint: 'oliver-rop.eth',
},
],
verificationMethod: [
{
id: `${did}#0x773230C8719783C18147F18BbB8340a347196eE5`,
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: did,
blockchainAccountId: '0x773230C8719783C18147F18BbB8340a347196eE5@eip155:3',
},
{
id: `${did}#my-id`,
publicKeyMultibase: 'z9hFgmPVfmBZwRvFEyniQDBkz9LmV7gDEqytWyGZLmDXE',
controller: did,
type: 'X25519KeyAgreementKey2019',
},
],
authentication: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
capabilityDelegation: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
capabilityInvocation: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
assertionMethod: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
keyAgreement: [`${did}#my-id`],
const did = 'did:ens:goerli:whatever.eth'
const ethrAddr = '0x4af859d61d07A8c515FE0E3Cc1Ea5e49A260bBa3'
const resolutionResult = await didResolver.resolve(did)
expect(resolutionResult).toEqual<DIDResolutionResult>({
didDocument: {
id: did,
service: [
{
id: `${did}#Web3PublicProfile-${ethrAddr}`,
type: 'Web3PublicProfile',
serviceEndpoint: 'whatever.eth',
},
],
verificationMethod: [
{
id: `${did}#${ethrAddr}`,
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: did,
blockchainAccountId: `${ethrAddr}@eip155:5`,
},
{
id: `${did}#my-key`,
type: 'X25519KeyAgreementKey2019',
controller: did,
publicKeyMultibase: 'z9hFgmPVfmBZwRvFEyniQDBkz9LmV7gDEqytWyGZLmDXE',
},
],
authentication: [`${did}#${ethrAddr}`],
capabilityDelegation: [`${did}#${ethrAddr}`],
capabilityInvocation: [`${did}#${ethrAddr}`],
assertionMethod: [`${did}#${ethrAddr}`],
keyAgreement: [`${did}#my-key`],
},
didDocumentMetadata: {},
didResolutionMetadata: { contentType: 'application/did+json' },
})

@@ -95,34 +95,67 @@ })

let didResolver: Resolvable = new Resolver(getResolver({ infuraProjectId: 'e471b8639c314004ae67ec0078f70102' }))
const did = 'did:ens:ropsten:oliver-rop.eth'
const result = await didResolver.resolve(did)
expect(result.didDocument).toEqual<DIDDocument>({
id: did,
service: [
{
id: `${did}#Web3PublicProfile-0x773230C8719783C18147F18BbB8340a347196eE5`,
type: 'Web3PublicProfile',
serviceEndpoint: 'oliver-rop.eth',
},
],
verificationMethod: [
{
id: `${did}#0x773230C8719783C18147F18BbB8340a347196eE5`,
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: did,
blockchainAccountId: '0x773230C8719783C18147F18BbB8340a347196eE5@eip155:3',
},
{
id: `${did}#my-id`,
publicKeyMultibase: 'z9hFgmPVfmBZwRvFEyniQDBkz9LmV7gDEqytWyGZLmDXE',
controller: did,
type: 'X25519KeyAgreementKey2019',
},
],
authentication: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
capabilityDelegation: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
capabilityInvocation: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
assertionMethod: [`${did}#0x773230C8719783C18147F18BbB8340a347196eE5`],
keyAgreement: [`${did}#my-id`],
const did = 'did:ens:goerli:whatever.eth'
const ethrAddr = '0x4af859d61d07A8c515FE0E3Cc1Ea5e49A260bBa3'
const resolutionResult = await didResolver.resolve(did)
expect(resolutionResult).toEqual<DIDResolutionResult>({
didDocument: {
id: did,
service: [
{
id: `${did}#Web3PublicProfile-${ethrAddr}`,
type: 'Web3PublicProfile',
serviceEndpoint: 'whatever.eth',
},
],
verificationMethod: [
{
id: `${did}#${ethrAddr}`,
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: did,
blockchainAccountId: `${ethrAddr}@eip155:5`,
},
{
id: `${did}#my-key`,
type: 'X25519KeyAgreementKey2019',
controller: did,
publicKeyMultibase: 'z9hFgmPVfmBZwRvFEyniQDBkz9LmV7gDEqytWyGZLmDXE',
},
],
authentication: [`${did}#${ethrAddr}`],
capabilityDelegation: [`${did}#${ethrAddr}`],
capabilityInvocation: [`${did}#${ethrAddr}`],
assertionMethod: [`${did}#${ethrAddr}`],
keyAgreement: [`${did}#my-key`],
},
didDocumentMetadata: {},
didResolutionMetadata: { contentType: 'application/did+json' },
})
})
it('works fails trying to goerli name on mainnet', async () => {
expect.assertions(1)
let didResolver: Resolvable = new Resolver(
getResolver({ rpcUrl: 'https://mainnet.infura.io/v3/e471b8639c314004ae67ec0078f70102' })
)
const did = 'did:ens:goerli:whatever.eth'
const resolutionResult = await didResolver.resolve(did)
expect(resolutionResult.didResolutionMetadata.error).toEqual('unknownNetwork')
})
it('multi provider config', async () => {
expect.assertions(2)
let didResolver: Resolvable = new Resolver(
getResolver({
networks: [
{ name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/e471b8639c314004ae67ec0078f70102' },
{ rpcUrl: 'https://mainnet.infura.io/v3/e471b8639c314004ae67ec0078f70102' },
],
})
)
const did = 'did:ens:goerli:whatever.eth'
const resolutionResult = await didResolver.resolve(did)
expect(resolutionResult.didDocument?.id).toEqual('did:ens:goerli:whatever.eth')
const resolutionResult2 = await didResolver.resolve('did:ens:vitalik.eth')
expect(resolutionResult2.didDocument?.id).toEqual('did:ens:vitalik.eth')
})
})

@@ -45,6 +45,3 @@ import { BigNumber } from '@ethersproject/bignumber'

{ name: 'mainnet', chainId: '0x1', provider: new InfuraProvider('homestead', projectId) },
{ name: 'ropsten', chainId: '0x3', provider: new InfuraProvider('ropsten', projectId) },
{ name: 'rinkeby', chainId: '0x4', provider: new InfuraProvider('rinkeby', projectId) },
{ name: 'goerli', chainId: '0x5', provider: new InfuraProvider('goerli', projectId) },
{ name: 'kovan', chainId: '0x2a', provider: new InfuraProvider('kovan', projectId) },
]

@@ -51,0 +48,0 @@ return configureNetworks({ networks })

@@ -7,6 +7,3 @@ export const identifierMatcher = /^(.*:)?(.*\.eth)$/

mainnet: '0x1',
ropsten: '0x3',
rinkeby: '0x4',
goerli: '0x5',
kovan: '0x2a',
}

@@ -13,0 +10,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc