Skip to content

Commit

Permalink
Merge branch 'release/v0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-xu committed Jan 14, 2019
2 parents 2fc3285 + 7e6fab7 commit 55e75d7
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 6,818 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ While any attribute can be stored. For the DID document we currently support add

The name of the attribute should follow this format:

`did/pub/(Secp256k1|Rsa|Ed25519)/(veriKey|sigAuth)/(hex|base64)`
`did/pub/(Secp256k1|RSA|Ed25519)/(veriKey|sigAuth)/(hex|base64)`

#### Hex encoded Secp256k1 Verification Key

Expand Down
27 changes: 12 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethr-did-resolver",
"version": "0.1.3",
"version": "0.2.0",
"description": "Resolve DID documents around ethereum addresses",
"main": "lib/register.js",
"repository": {
Expand Down Expand Up @@ -50,7 +50,7 @@
"babel-plugin-module-resolver": "^3.1.1",
"babel-runtime": "^6.26.0",
"buffer": "^5.1.0",
"did-resolver": "^0.0.4",
"did-resolver": "0.0.6",
"ethjs-abi": "^0.2.1",
"ethjs-contract": "^0.1.9",
"ethjs-provider-http": "^0.1.6",
Expand Down
132 changes: 132 additions & 0 deletions src/__tests__/register-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,71 @@ describe('ethrResolver', () => {
})
})
})

describe('RSAVerificationKey2018', () => {
beforeAll(async () => {
await registry.setAttribute(
identity,
stringToBytes32('did/pub/RSA/veriKey/pem'),
'-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n',
10,
{ from: owner }
)
})

it('resolves document', () => {
return expect(resolve(did)).resolves.toEqual({
'@context': 'https://w3id.org/did/v1',
id: did,
publicKey: [
{
id: `${did}#owner`,
type: 'Secp256k1VerificationKey2018',
owner: did,
ethereumAddress: owner,
},
{
id: `${did}#delegate-1`,
type: 'Secp256k1VerificationKey2018',
owner: did,
ethereumAddress: delegate2,
},
{
id: `${did}#delegate-2`,
type: 'Secp256k1VerificationKey2018',
owner: did,
publicKeyHex:
'02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71',
},
{
id: `${did}#delegate-3`,
type: 'Ed25519VerificationKey2018',
owner: did,
publicKeyBase64: Buffer.from(
'02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71',
'hex'
).toString('base64'),
},
{
id: `${did}#delegate-4`,
type: 'RSAVerificationKey2018',
owner: did,
publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n',
},
],
authentication: [
{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: `${did}#owner`,
},
{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: `${did}#delegate-1`,
},
],
})
})
})
})

describe('add service endpoints', () => {
Expand Down Expand Up @@ -487,6 +552,12 @@ describe('ethrResolver', () => {
'hex'
).toString('base64'),
},
{
id: `${did}#delegate-4`,
type: 'RSAVerificationKey2018',
owner: did,
publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n',
},
],
authentication: [
{
Expand Down Expand Up @@ -546,6 +617,12 @@ describe('ethrResolver', () => {
'hex'
).toString('base64'),
},
{
id: `${did}#delegate-4`,
type: 'RSAVerificationKey2018',
owner: did,
publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n',
},
],
authentication: [
{
Expand Down Expand Up @@ -577,6 +654,61 @@ describe('ethrResolver', () => {
)
sleep(1)
})
it('resolves document', () => {
return expect(resolve(did)).resolves.toEqual({
'@context': 'https://w3id.org/did/v1',
id: did,
publicKey: [
{
id: `${did}#owner`,
type: 'Secp256k1VerificationKey2018',
owner: did,
ethereumAddress: owner,
},
{
id: `${did}#delegate-1`,
type: 'Secp256k1VerificationKey2018',
owner: did,
ethereumAddress: delegate2,
},
{
id: `${did}#delegate-4`,
type: 'RSAVerificationKey2018',
owner: did,
publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n',
},
],
authentication: [
{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: `${did}#owner`,
},
{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: `${did}#delegate-1`,
},
],
service: [
{
type: 'HubService',
serviceEndpoint: 'https://hubs.uport.me',
},
],
})
})
})

describe('RSAVerificationKey2018', () => {
beforeAll(async () => {
await registry.revokeAttribute(
identity,
stringToBytes32('did/pub/RSA/veriKey/pem'),
'-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n',
{ from: owner }
)
sleep(1)
})

it('resolves document', () => {
return expect(resolve(did)).resolves.toEqual({
'@context': 'https://w3id.org/did/v1',
Expand Down
6 changes: 6 additions & 0 deletions src/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ export function wrapDidDocument(did, owner, history) {
'hex'
).toString('base58')
break
case 'pem':
pk.publicKeyPem = Buffer.from(
event.value.slice(2),
'hex'
).toString()
break
default:
pk.value = event.value
}
Expand Down
Loading

0 comments on commit 55e75d7

Please sign in to comment.