From 27f0f1dbc3ebe95ba32636a1ae04b5205e933153 Mon Sep 17 00:00:00 2001 From: Niko Lockenvitz Date: Wed, 1 Apr 2020 17:04:02 +0200 Subject: [PATCH 1/3] add method to revoke attributes --- src/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/index.js b/src/index.js index 3da0c77..76498b0 100644 --- a/src/index.js +++ b/src/index.js @@ -111,6 +111,18 @@ export default class EthrDID { ) } + async revokeAttribute (key, value) { + const owner = await this.lookupOwner() + return this.registry.revokeAttribute( + this.address, + stringToBytes32(key), + attributeToHex(key, value), + { + from: owner + } + ) + } + // Create a temporary signing delegate able to sign JWT on behalf of identity async createSigningDelegate ( delegateType = Secp256k1VerificationKey2018, From 1ed00e364edded6e49d0257b41453bd1f380da88 Mon Sep 17 00:00:00 2001 From: Niko Lockenvitz Date: Wed, 1 Apr 2020 17:35:45 +0200 Subject: [PATCH 2/3] add test for service revocation (revokeAttribute) --- src/__tests__/index-test.js | 68 +++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/src/__tests__/index-test.js b/src/__tests__/index-test.js index 07f9517..67b2c57 100644 --- a/src/__tests__/index-test.js +++ b/src/__tests__/index-test.js @@ -534,6 +534,68 @@ describe('EthrDID', () => { }) }) }) + + describe('revoke HubService', () => { + beforeAll(async () => { + await ethrDid.revokeAttribute( + 'did/svc/HubService', + 'https://hubs.uport.me' + ) + }) + it('resolves document', () => { + return expect(resolver.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: 'Ed25519VerificationKey2018', + owner: did, + publicKeyBase64: + '8rl8MN52fwhM4wgBaO4pMFO6M7I11xFqMmPSnxRQk2ty' + } + ], + authentication: [ + { + type: 'Secp256k1SignatureAuthentication2018', + publicKey: `${did}#owner` + }, + { + type: 'Secp256k1SignatureAuthentication2018', + publicKey: `${did}#delegate-1` + } + ] + }) + }) + }) }) }) }) @@ -608,12 +670,6 @@ describe('EthrDID', () => { type: 'Secp256k1SignatureAuthentication2018', publicKey: `${did}#delegate-1` } - ], - service: [ - { - type: 'HubService', - serviceEndpoint: 'https://hubs.uport.me' - } ] }) }) From f18d42cfc21dc2e991521a3f56e55913544bfffd Mon Sep 17 00:00:00 2001 From: Niko Lockenvitz Date: Tue, 21 Apr 2020 12:37:48 +0200 Subject: [PATCH 3/3] add gasLimit to attribute revocation --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 76498b0..d6ad327 100644 --- a/src/index.js +++ b/src/index.js @@ -111,14 +111,15 @@ export default class EthrDID { ) } - async revokeAttribute (key, value) { + async revokeAttribute (key, value, gasLimit) { const owner = await this.lookupOwner() return this.registry.revokeAttribute( this.address, stringToBytes32(key), attributeToHex(key, value), { - from: owner + from: owner, + gas: gasLimit } ) }