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 9.1.1 to 10.0.0

2

lib/controller.d.ts

@@ -1,2 +0,2 @@

import { Signer, Contract, BlockTag, Provider, TransactionReceipt, Overrides, AddressLike } from 'ethers';
import { AddressLike, BlockTag, Contract, Overrides, Provider, Signer, TransactionReceipt } from 'ethers';
import { address, MetaSignature } from './helpers';

@@ -3,0 +3,0 @@ /**

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

attrName = attrName.startsWith('0x') ? attrName : (0, helpers_1.stringToBytes32)(attrName);
attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex');
attrValue = attrValue.startsWith('0x') ? attrValue : (0, ethers_1.hexlify)((0, ethers_1.toUtf8Bytes)(attrValue));
const contract = await this.attachContract(overrides.from ?? undefined);

@@ -216,3 +216,3 @@ delete overrides.from;

attrName = attrName.startsWith('0x') ? attrName : (0, helpers_1.stringToBytes32)(attrName);
attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex');
attrValue = attrValue.startsWith('0x') ? attrValue : (0, ethers_1.hexlify)((0, ethers_1.toUtf8Bytes)(attrValue));
const contract = await this.attachContract(overrides.from ?? undefined);

@@ -230,3 +230,3 @@ delete overrides.from;

attrName = attrName.startsWith('0x') ? attrName : (0, helpers_1.stringToBytes32)(attrName);
attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex');
attrValue = attrValue.startsWith('0x') ? attrValue : (0, ethers_1.hexlify)((0, ethers_1.toUtf8Bytes)(attrValue));
const contract = await this.attachContract(overrides.from ?? undefined);

@@ -272,3 +272,3 @@ delete overrides.from;

attrName = attrName.startsWith('0x') ? attrName : (0, helpers_1.stringToBytes32)(attrName);
attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex');
attrValue = attrValue.startsWith('0x') ? attrValue : (0, ethers_1.hexlify)((0, ethers_1.toUtf8Bytes)(attrValue));
const contract = await this.attachContract(overrides.from ?? undefined);

@@ -275,0 +275,0 @@ delete overrides.from;

@@ -46,9 +46,8 @@ "use strict";

function bytes32toString(input) {
const buff = typeof input === 'string' ? Buffer.from(input.slice(2), 'hex') : Buffer.from(input);
return buff.toString('utf8').replace(/\0+$/, '');
return (0, ethers_1.toUtf8String)(input).replace(/\0+$/, '');
}
exports.bytes32toString = bytes32toString;
function stringToBytes32(str) {
const buffStr = '0x' + Buffer.from(str).slice(0, 32).toString('hex');
return buffStr + '0'.repeat(66 - buffStr.length);
const bytes = (0, ethers_1.toUtf8Bytes)(str);
return (0, ethers_1.zeroPadBytes)(bytes.slice(0, 32), 32);
}

@@ -55,0 +54,0 @@ exports.stringToBytes32 = stringToBytes32;

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

const authentication = [`${did}#controller`];
// const keyAgreement: string[] = []
const assertionMethod = [`${did}#controller`];
let versionId = 0;

@@ -98,2 +98,3 @@ let nextVersionId = Number.POSITIVE_INFINITY;

const keyAgreementRefs = {};
const signingRefs = {};
const pks = {};

@@ -127,2 +128,3 @@ const services = {};

auth[eventIndex] = `${did}#delegate-${delegateCount}`;
signingRefs[eventIndex] = `${did}#delegate-${delegateCount}`;
// eslint-disable-next-line no-fallthrough

@@ -136,2 +138,3 @@ case 'veriKey':

};
signingRefs[eventIndex] = `${did}#delegate-${delegateCount}`;
break;

@@ -165,9 +168,9 @@ }

case 'base64':
pk.publicKeyBase64 = Buffer.from(currentEvent.value.slice(2), 'hex').toString('base64');
pk.publicKeyBase64 = (0, ethers_1.encodeBase64)(currentEvent.value);
break;
case 'base58':
pk.publicKeyBase58 = (0, ethers_1.encodeBase58)(Buffer.from(currentEvent.value.slice(2), 'hex'));
pk.publicKeyBase58 = (0, ethers_1.encodeBase58)(currentEvent.value);
break;
case 'pem':
pk.publicKeyPem = Buffer.from(currentEvent.value.slice(2), 'hex').toString();
pk.publicKeyPem = (0, ethers_1.toUtf8String)(currentEvent.value);
break;

@@ -180,2 +183,3 @@ default:

auth[eventIndex] = pk.id;
signingRefs[eventIndex] = pk.id;
}

@@ -185,11 +189,15 @@ else if (match[4] === 'enc') {

}
else {
signingRefs[eventIndex] = pk.id;
}
break;
}
case 'svc':
case 'svc': {
serviceCount++;
const encodedService = (0, ethers_1.toUtf8String)(currentEvent.value);
try {
endpoint = JSON.parse(Buffer.from(currentEvent.value.slice(2), 'hex').toString());
endpoint = JSON.parse(encodedService);
}
catch {
endpoint = Buffer.from(currentEvent.value.slice(2), 'hex').toString();
endpoint = encodedService;
}

@@ -202,2 +210,3 @@ services[eventIndex] = {

break;
}
}

@@ -226,2 +235,3 @@ }

delete auth[eventIndex];
delete signingRefs[eventIndex];
delete pks[eventIndex];

@@ -247,2 +257,3 @@ delete services[eventIndex];

authentication.push(`${did}#controllerKey`);
assertionMethod.push(`${did}#controllerKey`);
}

@@ -253,2 +264,3 @@ const didDocument = {

authentication: authentication.concat(Object.values(auth)),
assertionMethod: assertionMethod.concat(Object.values(signingRefs)),
};

@@ -261,3 +273,2 @@ if (Object.values(services).length > 0) {

}
didDocument.assertionMethod = [...(didDocument.verificationMethod?.map((pk) => pk.id) || [])];
return deactivated

@@ -264,0 +275,0 @@ ? {

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

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

@@ -145,4 +145,3 @@ import { Contract, ethers } from 'ethers'

authentication: [`${did}#controller`],
// This is a bug. Encryption keys should not be added to assertionMethod See #184
assertionMethod: [`${did}#controller`, `${did}#delegate-1`],
assertionMethod: [`${did}#controller`],
keyAgreement: [`${did}#delegate-1`],

@@ -149,0 +148,0 @@ })

import {
Signer,
Addressable,
AddressLike,
BlockTag,
concat,
Contract,
BlockTag,
encodeBytes32String,
getBytes,
hexlify,
isHexString,
JsonRpcProvider,
keccak256,
Overrides,
Provider,
Signer,
toBeHex,
toUtf8Bytes,
TransactionReceipt,
getBytes,
concat,
toBeHex,
isHexString,
zeroPadValue,
toUtf8Bytes,
keccak256,
encodeBytes32String,
Overrides,
AddressLike,
Addressable,
} from 'ethers'

@@ -288,3 +289,3 @@ import { getContractForNetwork } from './configuration'

attrName = attrName.startsWith('0x') ? attrName : stringToBytes32(attrName)
attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex')
attrValue = attrValue.startsWith('0x') ? attrValue : hexlify(toUtf8Bytes(attrValue))
const contract = await this.attachContract(overrides.from ?? undefined)

@@ -330,3 +331,3 @@ delete overrides.from

attrName = attrName.startsWith('0x') ? attrName : stringToBytes32(attrName)
attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex')
attrValue = attrValue.startsWith('0x') ? attrValue : hexlify(toUtf8Bytes(attrValue))
const contract = await this.attachContract(overrides.from ?? undefined)

@@ -354,3 +355,3 @@ delete overrides.from

attrName = attrName.startsWith('0x') ? attrName : stringToBytes32(attrName)
attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex')
attrValue = attrValue.startsWith('0x') ? attrValue : hexlify(toUtf8Bytes(attrValue))
const contract = await this.attachContract(overrides.from ?? undefined)

@@ -404,3 +405,3 @@ delete overrides.from

attrName = attrName.startsWith('0x') ? attrName : stringToBytes32(attrName)
attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex')
attrValue = attrValue.startsWith('0x') ? attrValue : hexlify(toUtf8Bytes(attrValue))
const contract = await this.attachContract(overrides.from ?? undefined)

@@ -407,0 +408,0 @@ delete overrides.from

import { VerificationMethod } from 'did-resolver'
import { computeAddress, getAddress } from 'ethers'
import { computeAddress, getAddress, toUtf8Bytes, toUtf8String, zeroPadBytes } from 'ethers'

@@ -98,9 +98,8 @@ export const identifierMatcher = /^(.*)?(0x[0-9a-fA-F]{40}|0x[0-9a-fA-F]{66})$/

export function bytes32toString(input: bytes32 | Uint8Array): string {
const buff: Buffer = typeof input === 'string' ? Buffer.from(input.slice(2), 'hex') : Buffer.from(input)
return buff.toString('utf8').replace(/\0+$/, '')
return toUtf8String(input).replace(/\0+$/, '')
}
export function stringToBytes32(str: string): string {
const buffStr = '0x' + Buffer.from(str).slice(0, 32).toString('hex')
return buffStr + '0'.repeat(66 - buffStr.length)
const bytes = toUtf8Bytes(str)
return zeroPadBytes(bytes.slice(0, 32), 32)
}

@@ -107,0 +106,0 @@

@@ -1,2 +0,2 @@

import { BlockTag, encodeBase58 } from 'ethers'
import { BlockTag, encodeBase58, encodeBase64, toUtf8String } from 'ethers'
import { ConfigurationOptions, ConfiguredNetworks, configureResolverWithNetworks } from './configuration'

@@ -126,3 +126,3 @@ import {

const authentication = [`${did}#controller`]
// const keyAgreement: string[] = []
const assertionMethod = [`${did}#controller`]

@@ -137,2 +137,3 @@ let versionId = 0

const keyAgreementRefs: Record<string, string> = {}
const signingRefs: Record<string, string> = {}
const pks: Record<string, VerificationMethod> = {}

@@ -167,2 +168,3 @@ const services: Record<string, Service> = {}

auth[eventIndex] = `${did}#delegate-${delegateCount}`
signingRefs[eventIndex] = `${did}#delegate-${delegateCount}`
// eslint-disable-next-line no-fallthrough

@@ -176,2 +178,3 @@ case 'veriKey':

}
signingRefs[eventIndex] = `${did}#delegate-${delegateCount}`
break

@@ -204,9 +207,9 @@ }

case 'base64':
pk.publicKeyBase64 = Buffer.from(currentEvent.value.slice(2), 'hex').toString('base64')
pk.publicKeyBase64 = encodeBase64(currentEvent.value)
break
case 'base58':
pk.publicKeyBase58 = encodeBase58(Buffer.from(currentEvent.value.slice(2), 'hex'))
pk.publicKeyBase58 = encodeBase58(currentEvent.value)
break
case 'pem':
pk.publicKeyPem = Buffer.from(currentEvent.value.slice(2), 'hex').toString()
pk.publicKeyPem = toUtf8String(currentEvent.value)
break

@@ -219,13 +222,17 @@ default:

auth[eventIndex] = pk.id
signingRefs[eventIndex] = pk.id
} else if (match[4] === 'enc') {
keyAgreementRefs[eventIndex] = pk.id
} else {
signingRefs[eventIndex] = pk.id
}
break
}
case 'svc':
case 'svc': {
serviceCount++
const encodedService = toUtf8String(currentEvent.value)
try {
endpoint = JSON.parse(Buffer.from(currentEvent.value.slice(2), 'hex').toString())
endpoint = JSON.parse(encodedService)
} catch {
endpoint = Buffer.from(currentEvent.value.slice(2), 'hex').toString()
endpoint = encodedService
}

@@ -238,2 +245,3 @@ services[eventIndex] = {

break
}
}

@@ -263,2 +271,3 @@ }

delete auth[eventIndex]
delete signingRefs[eventIndex]
delete pks[eventIndex]

@@ -286,2 +295,3 @@ delete services[eventIndex]

authentication.push(`${did}#controllerKey`)
assertionMethod.push(`${did}#controllerKey`)
}

@@ -293,2 +303,3 @@

authentication: authentication.concat(Object.values(auth)),
assertionMethod: assertionMethod.concat(Object.values(signingRefs)),
}

@@ -301,3 +312,2 @@ if (Object.values(services).length > 0) {

}
didDocument.assertionMethod = [...(didDocument.verificationMethod?.map((pk) => pk.id) || [])]

@@ -304,0 +314,0 @@ return deactivated

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

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