dnsprovejs
Advanced tools
Comparing version
@@ -522,3 +522,3 @@ { | ||
"schemaVersion": "2.0.1", | ||
"updatedAt": "2018-09-04T10:41:12.378Z" | ||
"updatedAt": "2018-09-04T16:48:36.299Z" | ||
} |
@@ -466,3 +466,3 @@ { | ||
"schemaVersion": "2.0.1", | ||
"updatedAt": "2018-09-04T10:41:12.357Z" | ||
"updatedAt": "2018-09-04T16:48:36.299Z" | ||
} |
@@ -1379,3 +1379,3 @@ { | ||
"schemaVersion": "2.0.1", | ||
"updatedAt": "2018-09-04T10:41:12.379Z" | ||
"updatedAt": "2018-09-04T16:48:36.314Z" | ||
} |
@@ -970,3 +970,3 @@ { | ||
"schemaVersion": "2.0.1", | ||
"updatedAt": "2018-09-04T10:41:12.366Z" | ||
"updatedAt": "2018-09-04T16:48:36.304Z" | ||
} |
@@ -764,3 +764,3 @@ { | ||
"schemaVersion": "2.0.1", | ||
"updatedAt": "2018-09-04T10:41:12.368Z" | ||
"updatedAt": "2018-09-04T16:48:36.305Z" | ||
} |
@@ -146,2 +146,7 @@ 'use strict'; | ||
}, { | ||
key: 'toProve', | ||
value: function toProve(proof) { | ||
return this.web3.utils.sha3(proof.rrdata).slice(0, 42); | ||
} | ||
}, { | ||
key: 'getAllProofs', | ||
@@ -239,3 +244,3 @@ value: function () { | ||
var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(result) { | ||
var i, proof, proven; | ||
var i, proof, proven, toProve; | ||
return regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
@@ -257,3 +262,3 @@ while (1) { | ||
if (!(i < result.proofs.length)) { | ||
_context6.next = 13; | ||
_context6.next = 14; | ||
break; | ||
@@ -268,11 +273,12 @@ } | ||
proven = _context6.sent; | ||
toProve = this.toProve(proof); | ||
if (!(parseInt(proven) == 0)) { | ||
_context6.next = 10; | ||
if (!(parseInt(proven) == 0 || proven != toProve)) { | ||
_context6.next = 11; | ||
break; | ||
} | ||
return _context6.abrupt('break', 13); | ||
return _context6.abrupt('break', 14); | ||
case 10: | ||
case 11: | ||
i++; | ||
@@ -282,6 +288,6 @@ _context6.next = 3; | ||
case 13: | ||
case 14: | ||
return _context6.abrupt('return', i); | ||
case 14: | ||
case 15: | ||
case 'end': | ||
@@ -288,0 +294,0 @@ return _context6.stop(); |
{ | ||
"name": "dnsprovejs", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Port of dnsprove.go", | ||
@@ -5,0 +5,0 @@ "main": "dist/dnsprover.js", |
@@ -28,2 +28,38 @@ const nock = require('nock'); | ||
let buffer = new Buffer([]); | ||
function rrsigdata(typeCoverd, signersName, override){ | ||
let obj = { | ||
"typeCovered": typeCoverd, | ||
"algorithm": 253, | ||
"labels": 1, | ||
"originalTTL": 3600, | ||
"expiration": 2528174800, | ||
"inception": 1526834834, | ||
"keyTag": 1277, | ||
"signersName": signersName, | ||
"signature": buffer | ||
} | ||
return Object.assign(obj, override); | ||
} | ||
let dnskeydata = { | ||
"flags": 256, | ||
"algorithm": 253, | ||
"key": buffer | ||
} | ||
let dnskeydata2 = { | ||
"flags": 257, | ||
"algorithm": 253, | ||
"key": buffer | ||
} | ||
let dsdata = { | ||
"keyTag": 1277, | ||
"algorithm": 253, | ||
"digestType": 253, | ||
"digest": buffer | ||
} | ||
contract('DNSSEC', function(accounts) { | ||
@@ -73,41 +109,5 @@ const owner = accounts[0]; | ||
describe('_ens.matoken.xyz', async function(){ | ||
describe('submit', async function(){ | ||
beforeEach(async function() { | ||
let text = Buffer.from(`a=${owner}`, 'ascii'); | ||
let buffer = new Buffer([]); | ||
function rrsigdata(typeCoverd, signersName, override){ | ||
let obj = { | ||
"typeCovered": typeCoverd, | ||
"algorithm": 253, | ||
"labels": 1, | ||
"originalTTL": 300, | ||
"expiration": 2528174800, | ||
"inception": 1526834834, | ||
"keyTag": 1277, | ||
"signersName": signersName, | ||
"signature": buffer | ||
} | ||
return Object.assign(obj, override); | ||
} | ||
let dnskeydata = { | ||
"flags": 256, | ||
"algorithm": 253, | ||
"key": buffer | ||
} | ||
let dnskeydata2 = { | ||
"flags": 257, | ||
"algorithm": 253, | ||
"key": buffer | ||
} | ||
let dsdata = { | ||
"keyTag": 1277, | ||
"algorithm": 253, | ||
"digestType": 253, | ||
"digest": buffer | ||
} | ||
nock('https://dns.google.com') | ||
@@ -233,41 +233,69 @@ .get('/experimental?ct=application/dns-udpwireformat&dns=AAEBAAABAAAAAAABBF9lbnMHbWF0b2tlbgN4eXoAABAAAQAAKRAAAACAAAAA') | ||
describe('deleteRRSet', async function(){ | ||
describe('update', async function(){ | ||
this.beforeEach(async function(){ | ||
let text = Buffer.from(`a=${owner}`, 'ascii'); | ||
let buffer = new Buffer([]); | ||
function rrsigdata(typeCoverd, signersName, override){ | ||
let obj = { | ||
"typeCovered": typeCoverd, | ||
"algorithm": 253, | ||
"labels": 1, | ||
"originalTTL": 3600, | ||
"expiration": 2528174800, | ||
"inception": 1526834834, | ||
"keyTag": 1277, | ||
"signersName": signersName, | ||
"signature": buffer | ||
} | ||
return Object.assign(obj, override); | ||
} | ||
nock('https://dns.google.com') | ||
.get('/experimental?ct=application/dns-udpwireformat&dns=AAEBAAABAAAAAAABAWIAABAAAQAAKRAAAACAAAAA') | ||
.once() | ||
.reply(200, packet.encode({ | ||
questions: [ { name: 'b', type: 'TXT', class: 'IN' } ], | ||
answers: [ | ||
{ name: 'b', type: 'TXT', class: 'IN', data: Buffer.from(`foo`, 'ascii') }, | ||
{ name: 'b', type: 'RRSIG',class: 'IN',ttl: 3600, data: rrsigdata('TXT', '.', {labels:1, keyTag:5647}) } | ||
] | ||
})); | ||
let dnskeydata = { | ||
"flags": 256, | ||
"algorithm": 253, | ||
"key": buffer | ||
} | ||
nock('https://dns.google.com') | ||
.get('/experimental?ct=application/dns-udpwireformat&dns=AAEBAAABAAAAAAABAWIAABAAAQAAKRAAAACAAAAA') | ||
.twice() | ||
.reply(200, packet.encode({ | ||
questions: [ { name: 'b', type: 'TXT', class: 'IN' } ], | ||
answers: [ | ||
{ name: 'b', type: 'TXT', class: 'IN', data: Buffer.from(`bar`, 'ascii') }, | ||
{ name: 'b', type: 'RRSIG',class: 'IN',ttl: 3600, data: rrsigdata('TXT', '.', {labels:1, keyTag:5647}) } | ||
] | ||
})); | ||
nock('https://dns.google.com') | ||
.get('/experimental?ct=application/dns-udpwireformat&dns=AAEBAAABAAAAAAABAAAwAAEAACkQAAAAgAAAAA==') | ||
.times(2) | ||
.reply(200, packet.encode({ | ||
questions: [ { name: '.', type: 'DNSKEY', class: 'IN' } ], | ||
answers: [ | ||
{ name: '.', type: 'DNSKEY', class: 'IN', data: {flags: 0x0101, algorithm: 253, key: Buffer.from("1111", "HEX")} }, | ||
{ name: '.', type: 'DNSKEY', class: 'IN', data: {flags: 0, algorithm: 253, key: Buffer.from("1111", "HEX")} }, | ||
{ name: '.', type: 'DNSKEY', class: 'IN', data: {flags: 0, algorithm: 253, key: Buffer.from("1112", "HEX")} }, | ||
{ name: '.', type: 'RRSIG', class: 'IN', data: rrsigdata('DNSKEY', '.', { labels:0, keyTag:5647 }) } | ||
] | ||
})); | ||
}) | ||
it('updates .b', async function(){ | ||
// Step 1. Look up dns entry | ||
const dnsprove = new DnsProve(provider); | ||
const dnsResult = await dnsprove.lookup('TXT', 'b'); | ||
const oracle = await dnsprove.getOracle(address); | ||
// Step 2. Checks that the result is found and is valid. | ||
assert.equal(dnsResult.found, true); | ||
assert.equal(dnsResult.results[1].rrs[0].data.toString(), 'foo'); | ||
let proofs = dnsResult.proofs | ||
await oracle.submitAll(dnsResult, { from: owner, gas:gas }); | ||
let result = await oracle.knownProof(dnsResult.proofs[1]); | ||
assert.equal(result, oracle.toProve(dnsResult.proofs[1])); | ||
const dnsResult2 = await dnsprove.lookup('TXT', 'b'); | ||
assert.equal(dnsResult2.found, true); | ||
assert.equal(dnsResult2.results[1].rrs[0].data.toString(), 'bar'); | ||
await oracle.submitAll(dnsResult2, { from: owner, gas:gas }); | ||
let result2 = await oracle.knownProof(dnsResult2.proofs[1]); | ||
assert.equal(result2, oracle.toProve(dnsResult2.proofs[1])); | ||
}) | ||
}) | ||
describe('delete', async function(){ | ||
this.beforeEach(async function(){ | ||
let text = Buffer.from(`a=${owner}`, 'ascii'); | ||
let dnskeydata2 = { | ||
"flags": 257, | ||
"algorithm": 253, | ||
"key": buffer | ||
} | ||
let dsdata = { | ||
"keyTag": 1277, | ||
"algorithm": 253, | ||
"digestType": 253, | ||
"digest": buffer | ||
} | ||
nock('https://dns.google.com') | ||
@@ -313,2 +341,3 @@ .get('/experimental?ct=application/dns-udpwireformat&dns=AAEBAAABAAAAAAABAWIAABAAAQAAKRAAAACAAAAA') | ||
nock('https://dns.google.com') | ||
@@ -315,0 +344,0 @@ .get('/experimental?ct=application/dns-udpwireformat&dns=AAEBAAABAAAAAAABAAAwAAEAACkQAAAAgAAAAA==') |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6008665
61.62%41
10.81%134789
64.37%8
-11.11%