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

ethr-did-resolver

Package Overview
Dependencies
Maintainers
1
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 0.0.8 to 0.1.0

2

contracts/ethr-did-registry.json

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

[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"owners","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"bytes32"},{"name":"","type":"address"}],"name":"delegates","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"nonce","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"changed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"identity","type":"address"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"previousChange","type":"uint256"}],"name":"DIDOwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"identity","type":"address"},{"indexed":false,"name":"delegateType","type":"string"},{"indexed":false,"name":"delegate","type":"address"},{"indexed":false,"name":"validTo","type":"uint256"},{"indexed":false,"name":"previousChange","type":"uint256"}],"name":"DIDDelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"identity","type":"address"},{"indexed":false,"name":"name","type":"string"},{"indexed":false,"name":"value","type":"bytes"},{"indexed":false,"name":"validTo","type":"uint256"},{"indexed":false,"name":"previousChange","type":"uint256"}],"name":"DIDAttributeChanged","type":"event"},{"constant":true,"inputs":[{"name":"identity","type":"address"}],"name":"identityOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"identity","type":"address"},{"name":"delegateType","type":"string"},{"name":"delegate","type":"address"}],"name":"validDelegate","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"delegateType","type":"string"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"hash","type":"bytes32"}],"name":"validDelegateSignature","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"newOwner","type":"address"}],"name":"changeOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"newOwner","type":"address"}],"name":"changeOwnerSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"delegateType","type":"string"},{"name":"delegate","type":"address"},{"name":"validity","type":"uint256"}],"name":"addDelegate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"delegateType","type":"string"},{"name":"delegate","type":"address"},{"name":"validity","type":"uint256"}],"name":"addDelegateSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"delegateType","type":"string"},{"name":"delegate","type":"address"}],"name":"revokeDelegate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"delegateType","type":"string"},{"name":"delegate","type":"address"}],"name":"revokeDelegateSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"name","type":"string"},{"name":"value","type":"bytes"},{"name":"validity","type":"uint256"}],"name":"setAttribute","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"name","type":"string"},{"name":"value","type":"bytes"},{"name":"validity","type":"uint256"}],"name":"setAttributeSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"name","type":"string"},{"name":"value","type":"bytes"}],"name":"revokeAttribute","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"name","type":"string"},{"name":"value","type":"bytes"}],"name":"revokeAttributeSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"owners","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"bytes32"},{"name":"","type":"address"}],"name":"delegates","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"nonce","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"changed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"identity","type":"address"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"previousChange","type":"uint256"}],"name":"DIDOwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"identity","type":"address"},{"indexed":false,"name":"delegateType","type":"bytes32"},{"indexed":false,"name":"delegate","type":"address"},{"indexed":false,"name":"validTo","type":"uint256"},{"indexed":false,"name":"previousChange","type":"uint256"}],"name":"DIDDelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"identity","type":"address"},{"indexed":false,"name":"name","type":"bytes32"},{"indexed":false,"name":"value","type":"bytes"},{"indexed":false,"name":"validTo","type":"uint256"},{"indexed":false,"name":"previousChange","type":"uint256"}],"name":"DIDAttributeChanged","type":"event"},{"constant":true,"inputs":[{"name":"identity","type":"address"}],"name":"identityOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"identity","type":"address"},{"name":"delegateType","type":"bytes32"},{"name":"delegate","type":"address"}],"name":"validDelegate","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"newOwner","type":"address"}],"name":"changeOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"newOwner","type":"address"}],"name":"changeOwnerSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"delegateType","type":"bytes32"},{"name":"delegate","type":"address"},{"name":"validity","type":"uint256"}],"name":"addDelegate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"delegateType","type":"bytes32"},{"name":"delegate","type":"address"},{"name":"validity","type":"uint256"}],"name":"addDelegateSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"delegateType","type":"bytes32"},{"name":"delegate","type":"address"}],"name":"revokeDelegate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"delegateType","type":"bytes32"},{"name":"delegate","type":"address"}],"name":"revokeDelegateSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"name","type":"bytes32"},{"name":"value","type":"bytes"},{"name":"validity","type":"uint256"}],"name":"setAttribute","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"name","type":"bytes32"},{"name":"value","type":"bytes"},{"name":"validity","type":"uint256"}],"name":"setAttributeSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"name","type":"bytes32"},{"name":"value","type":"bytes"}],"name":"revokeAttribute","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"identity","type":"address"},{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"name","type":"bytes32"},{"name":"value","type":"bytes"}],"name":"revokeAttributeSigned","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
{
"name": "ethr-did-resolver",
"version": "0.0.8",
"version": "0.1.0",
"description": "Resolve DID documents around ethereum addresses",

@@ -40,2 +40,3 @@ "main": "lib/register.js",

"jest": "^22.4.3",
"jsdom": "11.11.0",
"regenerator-runtime": "^0.11.1",

@@ -56,3 +57,3 @@ "standard": "^11.0.0",

"ethjs-query": "^0.3.5",
"ethr-did-registry": "^0.0.2"
"ethr-did-registry": "^0.0.3"
},

@@ -59,0 +60,0 @@ "standard": {

@@ -0,1 +1,9 @@

---
title: "Ethr DID Resolver"
index: 7
category: "reference"
type: "content"
source: "https://github.com/uport-project/ethr-did-resolver/blob/develop/README.md"
---
# ethr DID Resolver

@@ -28,13 +36,11 @@

'@context': 'https://w3id.org/did/v1',
id:'did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74',
id: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a',
publicKey: [{
id: 'did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74#owner',
type: 'Secp256k1VerificationKey2018',
owner: 'did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74',
ethereumAddress: '0xf3beac30c498d9e26865f34fcaa57dbb935b0d74'
}],
id: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#owner',
type: 'Secp256k1VerificationKey2018',
owner: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a',
ethereumAddress: '0xb9c5714089478a327f09197987f16f9e5d936e8a'}],
authentication: [{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: 'did:eth:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74#owner'
}]
type: 'Secp256k1SignatureAuthentication2018',
publicKey: 'did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a#owner'}]
}

@@ -86,3 +92,3 @@ ```

A `DIDDelegateChanged` event is published that is used to build a DID.
A `DIDDelegateChanged` event is published that is used to build a DID.

@@ -92,3 +98,3 @@ ```solidity

address indexed identity,
string delegateType,
bytes32 delegateType,
address delegate,

@@ -102,5 +108,7 @@ uint validTo,

- `Secp256k1VerificationKey2018` which is added to the `publicKey` section of document
- `Secp256k1SignatureAuthentication2018` which is also added to the `publicKey` section of document. An entry is also added to the `authentication` section of document
- `veriKey` Which adds a `Secp256k1VerificationKey2018` to the `publicKey` section of document
- `sigAuth` Which adds a `Secp256k1SignatureAuthentication2018` to the `publicKey` section of document. An entry is also added to the `authentication` section of document.
**Note** The `delegateType` is a `bytes32` type for Ethereum gas efficiency reasons and not a string. This restricts us to 32 bytes, which is why we use the short hand versions above.
Only events with a `validTo` in seconds greater or equal to current time should be included in the DID document.

@@ -115,3 +123,3 @@

address indexed identity,
string name,
bytes32 name,
bytes value,

@@ -123,2 +131,4 @@ uint validTo,

**Note** The `name` is a `bytes32` type for Ethereum gas efficiency reasons and not a string. This restricts us to 32 bytes, which is why we use the short hand attribute versions below.
While any attribute can be stored. For the DID document we currently support adding to each of these sections of the DID document:

@@ -129,13 +139,53 @@

### Public Keys
The name of the attribute should follow this format:
`did/[section]/[type]/[encoding]` with encoding being optional.
`did/pub/(Secp256k1|Rsa|Ed25519)/(veriKey|sigAuth)/(hex|base64)`
|section|type|encoding|
|-------|----|--------|
|`publicKey`| Any valid Public Key type eg. `Secp256k1VerificationKey2018`, `Ed25519VerificationKey2018`, `RsaVerificationKey2018` | `publicKeyHex` (default), `publicKeyBase64` (please submit PRs for `publicKeyPem`, `publicKeyJwk`, `publicKeyBase58`)|
|`service`| Any valid service type eg `HubService`, `AgentService` | n/a |
#### Hex encoded Secp256k1 Verification Key
Values should be encoded in binary bytes for efficiency reasons. Encoding in the DID document will be converted according to method. Any unsupported attributes and unknown encodings will be ignored.
A `DIDAttributeChanged` event for the identity `0xf3beac30c498d9e26865f34fcaa57dbb935b0d74` with the name `did/pub/Secp256k1/veriKey/hex` and the value of `0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71` generates a `PublicKey` entry like this:
```js
{
id: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74#delegate-1",
type: "Secp256k1VerificationKey2018",
owner: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74",
publicKeyHex: '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71'
}
```
#### Base64 encoded Ed25519 Verification Key
A `DIDAttributeChanged` event for the identity `0xf3beac30c498d9e26865f34fcaa57dbb935b0d74` with the name `did/pub/Ed25519/veriKey/base64` and the value of `0xb97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71` generates a `PublicKey` entry like this:
```js
{
id: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74#delegate-1",
type: "Secp256k1VerificationKey2018",
owner: "did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74",
publicKeyBase64: "uXww3nZ/CEzjCAFo7ikwU7ozsjXXEWoyY9KfFFCTa3E="
}
```
We are looking for people to submit support for `pem`, `base58` and `jwk` key formats as well.
### Service Endpoints
The name of the attribute should follow this format:
`did/svc/[ServiceName]`
#### Hex encoded Secp256k1 Verification Key
A `DIDAttributeChanged` event for the identity `0xf3beac30c498d9e26865f34fcaa57dbb935b0d74` with the name `did/svc/HubService` and value of the url `https://hubs.uport.me` hex encoded as `0x68747470733a2f2f687562732e75706f72742e6d65` generates a `Service` entry like this:
```js
{
type: "HubService",
serviceEndpoint: "https://hubs.uport.me"
}
```
## Resolving a DID document

@@ -142,0 +192,0 @@

import resolve from 'did-resolver'
import register from '../register'
import register, { stringToBytes32, delegateTypes } from '../register'
import Contract from 'truffle-contract'

@@ -9,5 +8,8 @@ import DidRegistryContract from 'ethr-did-registry'

const { Secp256k1SignatureAuthentication2018, Secp256k1VerificationKey2018 } = delegateTypes
function sleep (seconds) {
return new Promise((resolve, reject) => setTimeout(resolve, seconds * 1000))
}
describe('ethrResolver', () => {

@@ -85,3 +87,3 @@ const provider = ganache.provider()

beforeAll(async () => {
await registry.addDelegate(identity, 'Secp256k1VerificationKey2018', delegate1, 2, {from: owner})
await registry.addDelegate(identity, Secp256k1VerificationKey2018, delegate1, 2, {from: owner})
})

@@ -114,3 +116,3 @@

beforeAll(async () => {
await registry.addDelegate(identity, 'Secp256k1SignatureAuthentication2018', delegate2, 10, {from: owner})
await registry.addDelegate(identity, Secp256k1SignatureAuthentication2018, delegate2, 10, {from: owner})
})

@@ -182,3 +184,4 @@

beforeAll(async () => {
await registry.revokeDelegate(identity, 'Secp256k1SignatureAuthentication2018', delegate2, {from: owner})
await registry.revokeDelegate(identity, Secp256k1SignatureAuthentication2018, delegate2, {from: owner})
await sleep(1)
})

@@ -206,3 +209,4 @@

beforeAll(async () => {
await registry.addDelegate(identity, 'Secp256k1SignatureAuthentication2018', delegate2, 86400, {from: owner})
await sleep(3)
await registry.addDelegate(identity, Secp256k1SignatureAuthentication2018, delegate2, 86400, {from: owner})
})

@@ -241,5 +245,4 @@

beforeAll(async () => {
await registry.setAttribute(identity, 'did/publicKey/Secp256k1VerificationKey2018', '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 10, {from: owner})
await registry.setAttribute(identity, stringToBytes32('did/pub/Secp256k1/veriKey'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 10, {from: owner})
})
it('resolves document', () => {

@@ -278,3 +281,3 @@ return expect(resolve(did)).resolves.toEqual({

beforeAll(async () => {
await registry.setAttribute(identity, 'did/publicKey/Ed25519VerificationKey2018/publicKeyBase64', '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 10, {from: owner})
await registry.setAttribute(identity, stringToBytes32('did/pub/Ed25519/veriKey/base64'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 10, {from: owner})
})

@@ -322,3 +325,3 @@

beforeAll(async () => {
await registry.setAttribute(identity, 'did/service/HubService', 'https://hubs.uport.me', 10, {from: owner})
await registry.setAttribute(identity, stringToBytes32('did/svc/HubService'), 'https://hubs.uport.me', 10, {from: owner})
})

@@ -325,0 +328,0 @@ it('resolves document', () => {

@@ -5,9 +5,29 @@ import { registerMethod } from 'did-resolver'

import abi from 'ethjs-abi'
import BN from 'bn.js'
import EthContract from 'ethjs-contract'
import DidRegistryContract from '../contracts/ethr-did-registry.json'
import { Buffer } from 'buffer'
export const REGISTRY = '0xc1b66dea11f8f321b7981e1666fdaf3637fe0f61'
export const REGISTRY = '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b'
export function bytes32toString (bytes32) {
return Buffer.from(bytes32.slice(2), 'hex').toString('utf8').replace(/\0+$/, '')
}
export function stringToBytes32 (str) {
const buffstr = '0x' + Buffer.from(str).slice(0, 32).toString('hex')
return buffstr + '0'.repeat(66 - buffstr.length)
}
export const delegateTypes = {
Secp256k1SignatureAuthentication2018: stringToBytes32('sigAuth'),
Secp256k1VerificationKey2018: stringToBytes32('veriKey')
}
export const attrTypes = {
sigAuth: 'SignatureAuthentication2018',
veriKey: 'VerificationKey2018'
}
export function wrapDidDocument (did, owner, history) {
const now = Math.floor(new Date().getTime() / 1000)
const now = new BN(Math.floor(new Date().getTime() / 1000))
// const expired = {}

@@ -31,9 +51,10 @@ const publicKey = [{

for (let event of history) {
// console.log(`validTo: ${event.validTo.toNumber()} and now: ${now}`)
const key = `${event._eventName}-${event.delegateType||event.name}-${event.delegate||event.value}`
if (event.validTo && event.validTo.toNumber() >= now) {
if (event._eventName === 'DIDDelegateChanged') {
let validTo = event.validTo
const key = `${event._eventName}-${event.delegateType || event.name}-${event.delegate || event.value}`
if (validTo && validTo.gte(now)) {
if (event._eventName === 'DIDDelegateChanged') {
delegateCount++
switch (event.delegateType) {
case 'Secp256k1SignatureAuthentication2018':
const delegateType = bytes32toString(event.delegateType)
switch (delegateType) {
case 'sigAuth':
auth[key] = {

@@ -43,3 +64,3 @@ type: 'Secp256k1SignatureAuthentication2018',

}
case 'Secp256k1VerificationKey2018':
case 'veriKey':
pks[key] = {

@@ -54,13 +75,15 @@ id: `${did}#delegate-${delegateCount}`,

} else if (event._eventName === 'DIDAttributeChanged') {
const match = event.name.match(/^did\/(publicKey|authentication|service)\/(\w+)(\/(\w+))?$/)
const name = bytes32toString(event.name)
const match = name.match(/^did\/(pub|auth|svc)\/(\w+)(\/(\w+))?(\/(\w+))?$/)
if (match) {
const section = match[1]
const type = match[2]
const encoding = match[4]
const algo = match[2]
const type = attrTypes[match[4]] || match[4]
const encoding = match[6]
switch (section) {
case 'publicKey':
case 'pub':
delegateCount++
const pk = {
id: `${did}#delegate-${delegateCount}`,
type,
type: `${algo}${type}`,
owner: did

@@ -71,9 +94,9 @@ }

case undefined:
case 'publicKeyHex':
case 'hex':
pk.publicKeyHex = event.value.slice(2)
break
case 'publicKeyBase64':
case 'base64':
pk.publicKeyBase64 = Buffer.from(event.value.slice(2), 'hex').toString('base64')
break
case 'publicKeyBase58':
case 'base58':
pk.publicKeyBase58 = Buffer.from(event.value.slice(2), 'hex').toString('base58')

@@ -86,4 +109,4 @@ break

break
case 'service':
services[key] = {type, serviceEndpoint: Buffer.from(event.value.slice(2), 'hex').toString()}
case 'svc':
services[key] = {type: algo, serviceEndpoint: Buffer.from(event.value.slice(2), 'hex').toString()}
break

@@ -94,3 +117,3 @@ }

} else {
if ((event._eventName === 'DIDDelegateChanged' || (event._eventName === 'DIDAttributeChanged' && event.name.match(/^did\/publicKey\//))) && event.validTo.toNumber() === 0) delegateCount--
if (delegateCount > 0 && (event._eventName === 'DIDDelegateChanged' || (event._eventName === 'DIDAttributeChanged' && delegateType.match(/^did\/publicKey\//))) && validTo.lt(now)) delegateCount--
delete auth[key]

@@ -125,3 +148,3 @@ delete pks[key]

function register (conf = {}) {
export default function register (conf = {}) {
const provider = configureProvider(conf)

@@ -163,2 +186,2 @@ const eth = new Eth(provider)

module.exports = register
// module.exports = register
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