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

ethr-did-resolver

Package Overview
Dependencies
Maintainers
5
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethr-did-resolver - npm Package Compare versions

Comparing version 10.1.5 to 10.1.7

2

lib/config/deployments.js

@@ -11,3 +11,3 @@ "use strict";

// { chainId: 4, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'rinkeby', legacyNonce: true },
{ chainId: 5, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'goerli', legacyNonce: true },
// { chainId: 5, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'goerli', legacyNonce: true },
{ chainId: 11155111, registry: '0x03d5003bf0e79C5F5223588F347ebA39AfbC3818', name: 'sepolia', legacyNonce: false },

@@ -14,0 +14,0 @@ // { chainId: 42, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'kovan', legacyNonce: true },

@@ -17,3 +17,3 @@ "use strict";

};
const knownInfuraNames = ['mainnet', 'goerli', 'aurora', 'linea:goerli', 'sepolia'];
const knownInfuraNames = ['mainnet', 'aurora', 'linea:goerli', 'sepolia'];
function configureNetworksWithInfura(projectId) {

@@ -20,0 +20,0 @@ if (!projectId) {

@@ -30,2 +30,9 @@ import { AddressLike, BlockTag, Contract, Overrides, Provider, Signer, TransactionReceipt } from 'ethers';

constructor(identifier: string | address, contract?: Contract, signer?: Signer, chainNameOrId?: string, provider?: Provider, rpcUrl?: string, registry?: string, legacyNonce?: boolean);
/**
* @returns the encoded attribute value in hex or utf8 bytes
* @param attrValue - the attribute value to encode (e.g. service endpoint, public key, etc.)
*
* @remarks The incoming attribute value may be a hex encoded key, or an utf8 encoded string (like service endpoints)
**/
encodeAttributeValue(attrValue: string | `0x${string}`): Uint8Array | `0x${string}`;
getOwner(address: address, blockTag?: BlockTag): Promise<string>;

@@ -32,0 +39,0 @@ attachContract(controller?: AddressLike): Promise<Contract>;

@@ -52,2 +52,11 @@ "use strict";

}
/**
* @returns the encoded attribute value in hex or utf8 bytes
* @param attrValue - the attribute value to encode (e.g. service endpoint, public key, etc.)
*
* @remarks The incoming attribute value may be a hex encoded key, or an utf8 encoded string (like service endpoints)
**/
encodeAttributeValue(attrValue) {
return (0, ethers_1.isHexString)(attrValue) ? attrValue : (0, ethers_1.toUtf8Bytes)(attrValue);
}
async getOwner(address, blockTag) {

@@ -193,4 +202,3 @@ return this.contract.identityOwner(address, { blockTag });

const paddedNonce = await this.getPaddedNonceCompatibility(true);
// The incoming attribute value may be a hex encoded key, or an utf8 encoded string (like service endpoints)
const encodedValue = (0, ethers_1.isHexString)(attrValue) ? attrValue : (0, ethers_1.toUtf8Bytes)(attrValue);
const encodedValue = this.encodeAttributeValue(attrValue);
const dataToHash = (0, ethers_1.concat)([

@@ -238,2 +246,3 @@ helpers_1.MESSAGE_PREFIX,

const paddedNonce = await this.getPaddedNonceCompatibility(true);
const encodedValue = this.encodeAttributeValue(attrValue);
const dataToHash = (0, ethers_1.concat)([

@@ -244,3 +253,3 @@ helpers_1.MESSAGE_PREFIX,

this.address,
(0, ethers_1.getBytes)((0, ethers_1.concat)([(0, ethers_1.toUtf8Bytes)('revokeAttribute'), (0, ethers_1.encodeBytes32String)(attrName), (0, ethers_1.toUtf8Bytes)(attrValue)])),
(0, ethers_1.getBytes)((0, ethers_1.concat)([(0, ethers_1.toUtf8Bytes)('revokeAttribute'), (0, ethers_1.encodeBytes32String)(attrName), encodedValue])),
]);

@@ -247,0 +256,0 @@ return (0, ethers_1.keccak256)(dataToHash);

{
"name": "ethr-did-resolver",
"version": "10.1.5",
"version": "10.1.7",
"description": "Resolve DID documents for ethereum addresses and public keys",

@@ -83,5 +83,5 @@ "type": "commonjs",

"devDependencies": {
"@babel/core": "7.23.9",
"@babel/preset-env": "7.23.9",
"@babel/preset-typescript": "7.23.3",
"@babel/core": "7.24.4",
"@babel/preset-env": "7.24.4",
"@babel/preset-typescript": "7.24.1",
"@ethers-ext/provider-ganache": "6.0.0-beta.2",

@@ -94,5 +94,5 @@ "@semantic-release/changelog": "6.0.3",

"babel-jest": "29.7.0",
"eslint": "8.56.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "27.6.3",
"eslint-plugin-jest": "27.9.0",
"eslint-plugin-prettier": "5.1.3",

@@ -103,3 +103,3 @@ "jest": "29.7.0",

"semantic-release": "22.0.12",
"typescript": "5.3.3"
"typescript": "5.4.4"
},

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

@@ -12,4 +12,2 @@ import { InfuraProvider, JsonRpcProvider } from 'ethers'

expect(contracts['0x1']).toBeDefined()
expect(contracts['goerli']).toBeDefined()
expect(contracts['0x5']).toBeDefined()
expect(contracts['dev']).toBeDefined()

@@ -31,6 +29,6 @@ expect(contracts['linea:goerli']).toBeDefined()

const contracts = configureResolverWithNetworks({
networks: [{ name: 'goerli', provider: new JsonRpcProvider('some goerli JSONRPC URL') }],
networks: [{ name: 'linea:goerli', provider: new JsonRpcProvider('some goerli JSONRPC URL') }],
})
expect(contracts['goerli']).toBeDefined()
expect(contracts['0x5']).toBeDefined()
expect(contracts['linea:goerli']).toBeDefined()
expect(contracts['0xe704']).toBeDefined()
})

@@ -40,7 +38,7 @@

const contracts = configureResolverWithNetworks({
name: 'goerli',
name: 'linea:goerli',
provider: new JsonRpcProvider('some goerli JSONRPC URL'),
})
expect(contracts['goerli']).toBeDefined()
expect(contracts['0x5']).toBeDefined()
expect(contracts['linea:goerli']).toBeDefined()
expect(contracts['0xe704']).toBeDefined()
})

@@ -47,0 +45,0 @@

@@ -41,29 +41,2 @@ import { Resolver } from 'did-resolver'

it('resolves on goerli when configured', async () => {
const did = 'did:ethr:goerli:' + addr
const ethr = getResolver({
networks: [{ name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/6b734e0b04454df8a6ce234023c04f26' }],
})
const resolver = new Resolver(ethr)
const result = await resolver.resolve(did)
expect(result).toEqual({
didDocumentMetadata: {},
didResolutionMetadata: { contentType: 'application/did+ld+json' },
didDocument: {
'@context': expect.anything(),
id: did,
verificationMethod: [
{
id: `${did}#controller`,
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: did,
blockchainAccountId: `eip155:5:${checksumAddr}`,
},
],
authentication: [`${did}#controller`],
assertionMethod: [`${did}#controller`],
},
})
})
it('resolves on linea:goerli when configured', async () => {

@@ -70,0 +43,0 @@ const did = 'did:ethr:linea:goerli:' + addr

@@ -21,2 +21,66 @@ import { Contract, ethers, hexlify, toUtf8Bytes } from 'ethers'

describe('invoking createSetAttributeHash', () => {
it('sets the "encodedValue" to the passed hex encoded string (e.g. a public key)', async () => {
expect.assertions(3)
const { address: identity, signer } = await randomAccount(provider)
const { pubKey: attrValue } = await randomAccount(provider)
const attrName = 'did/pub/Secp256k1/veriKey'
const controller = new EthrDidController(identity, registryContract, signer)
const encodeAttributeValueSpy = jest.spyOn(controller, 'encodeAttributeValue')
const ttl = 11111
await controller.createSetAttributeHash(attrName, attrValue, ttl)
expect(encodeAttributeValueSpy).toHaveBeenCalledWith(attrValue)
expect(encodeAttributeValueSpy).toHaveBeenCalledTimes(1)
expect(encodeAttributeValueSpy).toHaveReturnedWith(attrValue)
})
it('sets the "encodedValue" to a bytes encoded version of the passed attribute value (e.g. a service endpoint)', async () => {
expect.assertions(3)
const { address: identity, signer } = await randomAccount(provider)
const attrValue = 'https://hubs.uport.me/service-endpoints-are-not-hex'
const attrName = 'did/pub/Secp256k1/veriKey'
const controller = new EthrDidController(identity, registryContract, signer)
const encodeAttributeValueSpy = jest.spyOn(controller, 'encodeAttributeValue')
const ttl = 11111
await controller.createSetAttributeHash(attrName, attrValue, ttl)
expect(encodeAttributeValueSpy).toHaveBeenCalledWith(attrValue)
expect(encodeAttributeValueSpy).toHaveBeenCalledTimes(1)
const expectedEncodedValue = toUtf8Bytes(attrValue)
expect(encodeAttributeValueSpy).toHaveReturnedWith(expectedEncodedValue)
})
})
describe('invoking createRevokeAttributeHash', () => {
beforeEach(() => {
jest.clearAllMocks()
})
it('sets the "encodedValue" to the passed hex encoded string (e.g. a public key)', async () => {
expect.assertions(3)
const { address: identity, signer } = await randomAccount(provider)
const { pubKey: attrValue } = await randomAccount(provider)
const attrName = 'did/pub/Secp256k1/veriKey'
const controller = new EthrDidController(identity, registryContract, signer)
const encodeAttributeValueSpy = jest.spyOn(controller, 'encodeAttributeValue')
await controller.createRevokeAttributeHash(attrName, attrValue)
expect(encodeAttributeValueSpy).toHaveBeenCalledWith(attrValue)
expect(encodeAttributeValueSpy).toHaveBeenCalledTimes(1)
expect(encodeAttributeValueSpy).toHaveReturnedWith(attrValue)
})
it('sets the "encodedValue" to a bytes encoded version of the passed attribute value (e.g. a service endpoint)', async () => {
expect.assertions(3)
const { address: identity, signer } = await randomAccount(provider)
const attrValue = 'https://hubs.uport.me/service-endpoints-are-not-hex'
const attrName = 'did/pub/Secp256k1/veriKey'
const controller = new EthrDidController(identity, registryContract, signer)
const encodeAttributeValueSpy = jest.spyOn(controller, 'encodeAttributeValue')
await controller.createRevokeAttributeHash(attrName, attrValue)
expect(encodeAttributeValueSpy).toHaveBeenCalledWith(attrValue)
expect(encodeAttributeValueSpy).toHaveBeenCalledTimes(1)
const expectedEncodedValue = toUtf8Bytes(attrValue)
expect(encodeAttributeValueSpy).toHaveReturnedWith(expectedEncodedValue)
})
})
describe('add public keys', () => {

@@ -23,0 +87,0 @@ it('add EcdsaSecp256k1VerificationKey2019 signing key', async () => {

@@ -46,3 +46,3 @@ /**

// { chainId: 4, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'rinkeby', legacyNonce: true },
{ chainId: 5, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'goerli', legacyNonce: true },
// { chainId: 5, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'goerli', legacyNonce: true },
{ chainId: 11155111, registry: '0x03d5003bf0e79C5F5223588F347ebA39AfbC3818', name: 'sepolia', legacyNonce: false },

@@ -49,0 +49,0 @@ // { chainId: 42, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'kovan', legacyNonce: true },

@@ -13,3 +13,3 @@ import { Contract, ContractFactory, JsonRpcProvider, Provider } from 'ethers'

const knownInfuraNames = ['mainnet', 'goerli', 'aurora', 'linea:goerli', 'sepolia']
const knownInfuraNames = ['mainnet', 'aurora', 'linea:goerli', 'sepolia']

@@ -16,0 +16,0 @@ /**

@@ -90,2 +90,12 @@ import {

/**
* @returns the encoded attribute value in hex or utf8 bytes
* @param attrValue - the attribute value to encode (e.g. service endpoint, public key, etc.)
*
* @remarks The incoming attribute value may be a hex encoded key, or an utf8 encoded string (like service endpoints)
**/
encodeAttributeValue(attrValue: string | `0x${string}`): Uint8Array | `0x${string}` {
return isHexString(attrValue) ? attrValue : toUtf8Bytes(attrValue)
}
async getOwner(address: address, blockTag?: BlockTag): Promise<string> {

@@ -299,6 +309,3 @@ return this.contract.identityOwner(address, { blockTag })

const paddedNonce = await this.getPaddedNonceCompatibility(true)
// The incoming attribute value may be a hex encoded key, or an utf8 encoded string (like service endpoints)
const encodedValue = isHexString(attrValue) ? attrValue : toUtf8Bytes(attrValue)
const encodedValue = this.encodeAttributeValue(attrValue)
const dataToHash = concat([

@@ -364,3 +371,3 @@ MESSAGE_PREFIX,

const paddedNonce = await this.getPaddedNonceCompatibility(true)
const encodedValue = this.encodeAttributeValue(attrValue)
const dataToHash = concat([

@@ -371,3 +378,3 @@ MESSAGE_PREFIX,

this.address,
getBytes(concat([toUtf8Bytes('revokeAttribute'), encodeBytes32String(attrName), toUtf8Bytes(attrValue)])),
getBytes(concat([toUtf8Bytes('revokeAttribute'), encodeBytes32String(attrName), encodedValue])),
])

@@ -374,0 +381,0 @@ return keccak256(dataToHash)

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