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

@arcblock/did

Package Overview
Dependencies
Maintainers
4
Versions
551
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcblock/did - npm Package Compare versions

Comparing version 1.6.3 to 1.6.4

11

lib/index.js

@@ -16,3 +16,3 @@ /**

isEthereumType,
isEthereumAddress,
isEthereumDid,
DID_TYPE_FORGE,

@@ -141,3 +141,5 @@ DID_TYPE_ETHEREUM,

const isValid = (did) => {
const { hash } = toTypeInfo(did);
const address = toAddress(did);
const { hash } = toTypeInfo(address);
if (typeof hash === 'undefined') {

@@ -147,3 +149,3 @@ return false;

if (isEthereumAddress(did)) {
if (isEthereumDid(address)) {
return true;

@@ -153,5 +155,6 @@ }

const hashFn = getHasher(hash);
const bytes = toBytes(did);
const bytes = toBytes(address);
const bytesHex = toStrictHex(Buffer.from(bytes.slice(0, 22)).toString('hex'));
const didChecksum = toStrictHex(Buffer.from(bytes.slice(22, 26)).toString('hex'));
const checksum = stripHexPrefix(hashFn(`0x${bytesHex}`, 1)).slice(0, 8);

@@ -158,0 +161,0 @@

@@ -6,3 +6,3 @@ const BN = require('bn.js');

const { types, Hasher } = require('@ocap/mcrypto');
const { numberToHex, stripHexPrefix } = require('@ocap/util');
const { numberToHex, stripHexPrefix, toAddress, isHex } = require('@ocap/util');
const { toBits, toBytes, toStrictHex } = require('./util');

@@ -40,7 +40,9 @@

*
* @method isEthereumAddress
* @method isEthereumDid
* @param {String} address the given HEX address
* @return {Boolean}
*/
const isEthereumAddress = (address) => {
const isEthereumDid = (did) => {
const address = toAddress(did);
// check if it has the basic requirements of an address

@@ -232,3 +234,3 @@ if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {

let type = null;
if (isEthereumAddress(did)) {
if (isEthereumDid(did)) {
type = DID_TYPE_ETHEREUM;

@@ -247,2 +249,3 @@ } else {

hash: parseInt(hashBits, 2),
address: isHex(toAddress(did)) ? types.EncodingType.BASE16 : types.EncodingType.BASE58,
};

@@ -278,5 +281,5 @@ }

isEthereumType,
isEthereumAddress,
isEthereumDid,
toChecksumAddress,
DidType,
};
const padStart = require('lodash/padStart');
const { toBN, fromBase58 } = require('@ocap/util');
const { toBN, fromBase58, isHexStrict, stripHexPrefix } = require('@ocap/util');

@@ -14,2 +14,6 @@ const DID_PREFIX = 'did:abt:';

try {
if (isHexStrict(did)) {
return Buffer.from(stripHexPrefix(did), 'hex');
}
let bytes = fromBase58(did.replace(DID_PREFIX, ''));

@@ -16,0 +20,0 @@ while (bytes.length < 26) {

{
"name": "@arcblock/did",
"version": "1.6.3",
"version": "1.6.4",
"description": "Javascript lib to work with ArcBlock DID",

@@ -48,4 +48,4 @@ "keywords": [

"dependencies": {
"@ocap/mcrypto": "^1.6.3",
"@ocap/util": "^1.6.3",
"@ocap/mcrypto": "^1.6.4",
"@ocap/util": "^1.6.4",
"bn.js": "^5.1.3",

@@ -55,3 +55,3 @@ "debug": "^4.3.1",

},
"gitHead": "5246168dbbc268a3e6f95c3992d9d343647ca25b"
"gitHead": "1f9e09a49a5feda886b136fb4198c3b1bb81a43d"
}
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