Skip to content

Commit

Permalink
Merge branch 'release/v1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-xu committed Aug 22, 2019
2 parents 5a04777 + 3b4ba20 commit 6451f01
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethr-did-resolver",
"version": "1.0.0",
"version": "1.0.1",
"description": "Resolve DID documents around ethereum addresses",
"main": "dist/ethr-did-resolver.js",
"source": "src/ethr-did-resolver.js",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/ethr-did-resolver-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Resolver } from 'did-resolver'
import getResolver, { stringToBytes32, delegateTypes } from '../ethr-did-resolver'
import { getResolver, stringToBytes32, delegateTypes } from '../ethr-did-resolver'
import Contract from 'truffle-contract'
import DidRegistryContract from 'ethr-did-registry'
import Web3 from 'web3'
Expand Down
24 changes: 17 additions & 7 deletions src/ethr-did-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ 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 = '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b'
const REGISTRY = '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b'

export function bytes32toString (bytes32) {
function bytes32toString (bytes32) {
return Buffer.from(bytes32.slice(2), 'hex')
.toString('utf8')
.replace(/\0+$/, '')
}

export function stringToBytes32 (str) {
function stringToBytes32 (str) {
const buffstr =
'0x' +
Buffer.from(str)
Expand All @@ -22,17 +22,17 @@ export function stringToBytes32 (str) {
return buffstr + '0'.repeat(66 - buffstr.length)
}

export const delegateTypes = {
const delegateTypes = {
Secp256k1SignatureAuthentication2018: stringToBytes32('sigAuth'),
Secp256k1VerificationKey2018: stringToBytes32('veriKey')
}

export const attrTypes = {
const attrTypes = {
sigAuth: 'SignatureAuthentication2018',
veriKey: 'VerificationKey2018'
}

export function wrapDidDocument (did, owner, history) {
function wrapDidDocument (did, owner, history) {
const now = new BN(Math.floor(new Date().getTime() / 1000))
// const expired = {}
const publicKey = [
Expand Down Expand Up @@ -175,7 +175,7 @@ function configureProvider (conf = {}) {
}
}

export default function getResolver (conf = {}) {
function getResolver (conf = {}) {
const provider = configureProvider(conf)
const eth = new Eth(provider)
const registryAddress = conf.registry || REGISTRY
Expand Down Expand Up @@ -224,3 +224,13 @@ export default function getResolver (conf = {}) {

return { 'ethr': resolve }
}

module.exports = {
REGISTRY,
bytes32toString,
stringToBytes32,
delegateTypes,
attrTypes,
wrapDidDocument,
getResolver
}

0 comments on commit 6451f01

Please sign in to comment.