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

ethr-did-resolver

Package Overview
Dependencies
Maintainers
5
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.2.0-alpha1 to 0.2.0

197

lib/__tests__/register-test.js

@@ -529,6 +529,4 @@ 'use strict';

});
});
describe('add service endpoints', function () {
describe('HubService', function () {
describe('RSAVerificationKey2018', function () {
beforeAll((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11() {

@@ -540,3 +538,3 @@ return _regenerator2.default.wrap(function _callee11$(_context11) {

_context11.next = 2;
return registry.setAttribute(identity, (0, _register.stringToBytes32)('did/svc/HubService'), 'https://hubs.uport.me', 10, { from: owner });
return registry.setAttribute(identity, (0, _register.stringToBytes32)('did/pub/RSA/veriKey/pem'), '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n', 10, { from: owner });

@@ -550,2 +548,3 @@ case 2:

})));
it('resolves document', function () {

@@ -575,2 +574,7 @@ return expect((0, _didResolver2.default)(did)).resolves.toEqual({

publicKeyBase64: Buffer.from('02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 'hex').toString('base64')
}, {
id: did + '#delegate-4',
type: 'RSAVerificationKey2018',
owner: did,
publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n'
}],

@@ -583,6 +587,2 @@ authentication: [{

publicKey: did + '#delegate-1'
}],
service: [{
type: 'HubService',
serviceEndpoint: 'https://hubs.uport.me'
}]

@@ -594,4 +594,4 @@ });

describe('revoke publicKey', function () {
describe('Secp256k1VerificationKey2018', function () {
describe('add service endpoints', function () {
describe('HubService', function () {
beforeAll((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12() {

@@ -603,8 +603,5 @@ return _regenerator2.default.wrap(function _callee12$(_context12) {

_context12.next = 2;
return registry.revokeAttribute(identity, (0, _register.stringToBytes32)('did/pub/Secp256k1/veriKey'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', { from: owner });
return registry.setAttribute(identity, (0, _register.stringToBytes32)('did/svc/HubService'), 'https://hubs.uport.me', 10, { from: owner });
case 2:
sleep(1);
case 3:
case 'end':

@@ -631,2 +628,7 @@ return _context12.stop();

}, {
id: did + '#delegate-2',
type: 'Secp256k1VerificationKey2018',
owner: did,
publicKeyHex: '02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71'
}, {
id: did + '#delegate-3',

@@ -636,2 +638,7 @@ type: 'Ed25519VerificationKey2018',

publicKeyBase64: Buffer.from('02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', 'hex').toString('base64')
}, {
id: did + '#delegate-4',
type: 'RSAVerificationKey2018',
owner: did,
publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n'
}],

@@ -652,4 +659,6 @@ authentication: [{

});
});
describe('Ed25519VerificationKey2018', function () {
describe('revoke publicKey', function () {
describe('Secp256k1VerificationKey2018', function () {
beforeAll((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13() {

@@ -661,3 +670,3 @@ return _regenerator2.default.wrap(function _callee13$(_context13) {

_context13.next = 2;
return registry.revokeAttribute(identity, (0, _register.stringToBytes32)('did/pub/Ed25519/veriKey/base64'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', { from: owner });
return registry.revokeAttribute(identity, (0, _register.stringToBytes32)('did/pub/Secp256k1/veriKey'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', { from: owner });

@@ -688,2 +697,12 @@ case 2:

ethereumAddress: delegate2
}, {
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'
}],

@@ -704,6 +723,4 @@ authentication: [{

});
});
describe('revoke service endpoints', function () {
describe('HubService', function () {
describe('Ed25519VerificationKey2018', function () {
beforeAll((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14() {

@@ -715,3 +732,3 @@ return _regenerator2.default.wrap(function _callee14$(_context14) {

_context14.next = 2;
return registry.revokeAttribute(identity, (0, _register.stringToBytes32)('did/svc/HubService'), 'https://hubs.uport.me', { from: owner });
return registry.revokeAttribute(identity, (0, _register.stringToBytes32)('did/pub/Ed25519/veriKey/base64'), '0x02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71', { from: owner });

@@ -728,3 +745,57 @@ case 2:

})));
it('resolves document', function () {
return expect((0, _didResolver2.default)(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', function () {
beforeAll((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15() {
return _regenerator2.default.wrap(function _callee15$(_context15) {
while (1) {
switch (_context15.prev = _context15.next) {
case 0:
_context15.next = 2;
return registry.revokeAttribute(identity, (0, _register.stringToBytes32)('did/pub/RSA/veriKey/pem'), '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n', { from: owner });
case 2:
sleep(1);
case 3:
case 'end':
return _context15.stop();
}
}
}, _callee15, undefined);
})));
it('resolves document', function () {

@@ -751,2 +822,6 @@ return expect((0, _didResolver2.default)(did)).resolves.toEqual({

publicKey: did + '#delegate-1'
}],
service: [{
type: 'HubService',
serviceEndpoint: 'https://hubs.uport.me'
}]

@@ -757,15 +832,63 @@ });

});
describe('revoke service endpoints', function () {
describe('HubService', function () {
beforeAll((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16() {
return _regenerator2.default.wrap(function _callee16$(_context16) {
while (1) {
switch (_context16.prev = _context16.next) {
case 0:
_context16.next = 2;
return registry.revokeAttribute(identity, (0, _register.stringToBytes32)('did/svc/HubService'), 'https://hubs.uport.me', { from: owner });
case 2:
sleep(1);
case 3:
case 'end':
return _context16.stop();
}
}
}, _callee16, undefined);
})));
it('resolves document', function () {
return expect((0, _didResolver2.default)(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
}],
authentication: [{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: did + '#owner'
}, {
type: 'Secp256k1SignatureAuthentication2018',
publicKey: did + '#delegate-1'
}]
});
});
});
});
});
describe('multiple events in one block', function () {
beforeAll((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15() {
return _regenerator2.default.wrap(function _callee15$(_context15) {
beforeAll((0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee17() {
return _regenerator2.default.wrap(function _callee17$(_context17) {
while (1) {
switch (_context15.prev = _context15.next) {
switch (_context17.prev = _context17.next) {
case 0:
_context15.next = 2;
_context17.next = 2;
return stopMining();
case 2:
_context15.next = 4;
_context17.next = 4;
return _promise2.default.all([registry.setAttribute(identity, (0, _register.stringToBytes32)('did/svc/TestService'), 'https://test.uport.me', 10, { from: owner }), registry.setAttribute(identity, (0, _register.stringToBytes32)('did/svc/TestService'), 'https://test.uport.me', 10, { from: owner }), sleep(1).then(function () {

@@ -777,20 +900,20 @@ return startMining();

case 'end':
return _context15.stop();
return _context17.stop();
}
}
}, _callee15, undefined);
}, _callee17, undefined);
})));
it('resolves document', (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16() {
return _regenerator2.default.wrap(function _callee16$(_context16) {
it('resolves document', (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee18() {
return _regenerator2.default.wrap(function _callee18$(_context18) {
while (1) {
switch (_context16.prev = _context16.next) {
switch (_context18.prev = _context18.next) {
case 0:
_context16.t0 = expect;
_context16.next = 3;
_context18.t0 = expect;
_context18.next = 3;
return (0, _didResolver2.default)(did);
case 3:
_context16.t1 = _context16.sent;
_context16.t2 = {
_context18.t1 = _context18.sent;
_context18.t2 = {
'@context': 'https://w3id.org/did/v1',

@@ -821,10 +944,10 @@ id: did,

};
(0, _context16.t0)(_context16.t1).toEqual(_context16.t2);
(0, _context18.t0)(_context18.t1).toEqual(_context18.t2);
case 6:
case 'end':
return _context16.stop();
return _context18.stop();
}
}
}, _callee16, undefined);
}, _callee18, undefined);
})));

@@ -831,0 +954,0 @@ });

@@ -156,2 +156,5 @@ 'use strict';

break;
case 'pem':
pk.publicKeyPem = _buffer.Buffer.from(event.value.slice(2), 'hex').toString();
break;
default:

@@ -158,0 +161,0 @@ pk.value = event.value;

4

package.json
{
"name": "ethr-did-resolver",
"version": "0.2.0-alpha1",
"version": "0.2.0",
"description": "Resolve DID documents around ethereum addresses",

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

"buffer": "^5.1.0",
"did-resolver": "0.0.6-alpha5",
"did-resolver": "0.0.6",
"ethjs-abi": "^0.2.1",

@@ -56,0 +56,0 @@ "ethjs-contract": "^0.1.9",

@@ -137,3 +137,3 @@ ---

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

@@ -140,0 +140,0 @@ #### Hex encoded Secp256k1 Verification Key

@@ -444,2 +444,67 @@ import resolve from 'did-resolver'

})
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`,
},
],
})
})
})
})

@@ -491,2 +556,8 @@

},
{
id: `${did}#delegate-4`,
type: 'RSAVerificationKey2018',
owner: did,
publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n',
},
],

@@ -551,2 +622,8 @@ authentication: [

},
{
id: `${did}#delegate-4`,
type: 'RSAVerificationKey2018',
owner: did,
publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n',
},
],

@@ -600,2 +677,8 @@ authentication: [

},
{
id: `${did}#delegate-4`,
type: 'RSAVerificationKey2018',
owner: did,
publicKeyPem: '-----BEGIN PUBLIC KEY...END PUBLIC KEY-----\r\n',
},
],

@@ -621,2 +704,51 @@ authentication: [

})
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',
id: did,
publicKey: [
{
id: `${did}#owner`,
type: 'Secp256k1VerificationKey2018',
owner: did,
ethereumAddress: owner,
},
{
id: `${did}#delegate-1`,
type: 'Secp256k1VerificationKey2018',
owner: did,
ethereumAddress: delegate2,
},
],
authentication: [
{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: `${did}#owner`,
},
{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: `${did}#delegate-1`,
},
],
service: [
{
type: 'HubService',
serviceEndpoint: 'https://hubs.uport.me',
},
],
})
})
})
})

@@ -623,0 +755,0 @@

@@ -118,2 +118,8 @@ import { registerMethod } from 'did-resolver'

break
case 'pem':
pk.publicKeyPem = Buffer.from(
event.value.slice(2),
'hex'
).toString()
break
default:

@@ -120,0 +126,0 @@ pk.value = event.value

Sorry, the diff of this file is too big to display

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