five-bells-shared
Advanced tools
Comparing version 13.0.3 to 14.0.0
'use strict' | ||
const crypto = require('crypto') | ||
const url = require('url') | ||
@@ -184,5 +185,5 @@ const tweetnacl = require('tweetnacl') | ||
} | ||
keyPair = tweetnacl.sign.keyPair() | ||
ed25519.secret = tweetnacl.util.encodeBase64(keyPair.secretKey) | ||
ed25519.public = tweetnacl.util.encodeBase64(keyPair.publicKey) | ||
const seed = crypto.randomBytes(32) | ||
keyPair = tweetnacl.sign.keyPair.fromSeed(seed) | ||
ed25519.secret = seed.toString('base64') | ||
} | ||
@@ -192,7 +193,6 @@ | ||
if (!keyPair) { | ||
keyPair = tweetnacl.sign.keyPair.fromSecretKey( | ||
tweetnacl.util.decodeBase64(ed25519.secret)) | ||
keyPair = tweetnacl.sign.keyPair.fromSeed( | ||
new Buffer(ed25519.secret, 'base64')) | ||
} | ||
ed25519.public = | ||
tweetnacl.util.encodeBase64(keyPair.publicKey) | ||
ed25519.public = new Buffer(keyPair.publicKey).toString('base64') | ||
} | ||
@@ -199,0 +199,0 @@ |
@@ -138,3 +138,3 @@ 'use strict' | ||
_applyFilter (filter, data0) { | ||
let data = _.assign({}, _.cloneDeep(data0)) | ||
let data = _.isObject(data0) ? _.assign({}, _.cloneDeep(data0)) : data0 | ||
@@ -141,0 +141,0 @@ data = filter(data, this) |
{ | ||
"name": "five-bells-shared", | ||
"version": "13.0.3", | ||
"version": "14.0.0", | ||
"description": "Shared components for Five Bells projects.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
{ | ||
"$schema": "http://json-schema.org/draft-04/schema", | ||
"title": "Condition", | ||
"definitions": { | ||
"HashSha256Condition": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"enum": ["sha256"] | ||
}, | ||
"digest": { | ||
"type": "string", | ||
"pattern": "^[0-9A-F]{64}$" | ||
} | ||
}, | ||
"required": ["type", "digest"], | ||
"additionalProperties": false | ||
}, | ||
"TimeBeforeCondition": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"enum": ["before"] | ||
}, | ||
"date": { | ||
"type": "string", | ||
"format": "date-time" | ||
} | ||
}, | ||
"required": ["type", "date"], | ||
"additionalProperties": false | ||
}, | ||
"BooleanAndCondition": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"enum": ["and"] | ||
}, | ||
"subconditions": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#" | ||
}, | ||
"minItems": 1 | ||
} | ||
}, | ||
"required": ["type", "subconditions"], | ||
"additionalProperties": false | ||
}, | ||
"Ed25519_Sha512_Condition": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"enum": ["ed25519-sha512"] | ||
}, | ||
"message_hash": { | ||
"description": "Base64-encoded hash of the message (hash algorithm dependent on signing algorithm) ", | ||
"$ref": "Base64.json" | ||
}, | ||
"signer": { | ||
"description": "IRI of signer", | ||
"$ref": "Iri.json" | ||
}, | ||
"public_key": { | ||
"description": "Base64-encoded public key of signer", | ||
"$ref": "Base64.json" | ||
} | ||
}, | ||
"required": ["type", "message_hash", "signer", "public_key"], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"oneOf": [ | ||
{ "$ref": "#/definitions/HashSha256Condition" }, | ||
{ "$ref": "#/definitions/TimeBeforeCondition" }, | ||
{ "$ref": "#/definitions/BooleanAndCondition" }, | ||
{ "$ref": "#/definitions/Ed25519_Sha512_Condition" } | ||
] | ||
"description": "A fingerprint of a future cryptographically proven event", | ||
"type": "string", | ||
"pattern": "^cc:([1-9a-f][0-9a-f]{0,3}|0):[1-9a-f][0-9a-f]{0,15}:[a-zA-Z0-9_-]{0,86}:([1-9][0-9]{0,17}|0)$" | ||
} |
@@ -5,52 +5,4 @@ { | ||
"description": "Proof of condition completion", | ||
"definitions": { | ||
"HashSha256Fulfillment": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"enum": ["sha256"] | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["type", "message"], | ||
"additionalProperties": false | ||
}, | ||
"Ed25519_Sha512": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"enum": ["ed25519-sha512"] | ||
}, | ||
"signature": { | ||
"$ref": "Base64.json" | ||
} | ||
}, | ||
"required": ["type", "signature"], | ||
"additionalProperties": false | ||
}, | ||
"BooleanAndFulfillment": { | ||
"type": "object", | ||
"properties": { | ||
"type": { | ||
"enum": ["and"] | ||
}, | ||
"subfulfillments": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#" | ||
}, | ||
"minItems": 1 | ||
} | ||
}, | ||
"required": ["type", "subfulfillments"], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"oneOf": [ | ||
{ "$ref": "#/definitions/HashSha256Fulfillment" }, | ||
{ "$ref": "#/definitions/Ed25519_Sha512" }, | ||
{ "$ref": "#/definitions/BooleanAndFulfillment" } | ||
] | ||
"type": "string", | ||
"pattern": "^cf:([1-9a-f][0-9a-f]{0,3}|0):[a-zA-Z0-9_-]*$" | ||
} |
@@ -286,3 +286,3 @@ 'use strict' | ||
it('ED25519_SECRET_KEY', () => { | ||
const secret = 'WvWye3P79SXVGWJT8E4NhsGeKgJZlxhMyXDh7cRcbHsEqvDmg2dhC8EWdAAwTf6B8hzzdI/dq7WZXyqEobN9rw==' | ||
const secret = 'xreWtZOXBF9VKIStlzFQcQhShnTzxGVX7l5REDr/534=' | ||
process.env.ED25519_SECRET_KEY = secret | ||
@@ -293,2 +293,3 @@ const _config = Config.loadConfig() | ||
expect(_config.getIn(['keys', 'ed25519', 'secret'])).to.equal(secret) | ||
expect(_config.getIn(['keys', 'ed25519', 'public'])).to.equal('doUky4CUYF8mAQ1v6TOIPf8qC2q52bhBIhIs7ZX9MpA=') | ||
}) | ||
@@ -295,0 +296,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1776492
4153