Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var isRef = require('ssb-ref')
var isHash = isRef.isHash
var isFeedId = isRef.isFeedId
var contpara = require('cont').para
var explain = require('explain-error')
// make a validation stream?
// read the latest record in the database
// check it against the incoming data,
// and then read through
function clone (obj) {
var o = {}
for(var k in obj) o[k] = obj[k];
return o
}
function get (db, key) {
return function (cb) {
var ref = require('ssb-ref')
var ssbKeys = require('ssb-keys')
var isHash = ref.isHash
var isFeedId = ref.isFeedId
var timestamp = require('monotonic-timestamp')
var isCanonicalBase64 = require('is-canonical-base64')
var isEncryptedRx = isCanonicalBase64('','\.box.*')
var isSignatureRx = isCanonicalBase64('','\.sig.\w+')
function isValidOrder (msg, signed) {
var i = 0
var keys = Object.keys(msg)
if(signed && keys.length !== 7) return false
if(
keys[0] !== 'previous' ||
keys[3] !== 'timestamp' ||
keys[4] !== 'hash' ||
keys[5] !== 'content' ||
(signed && keys[6] !== 'signature')
'use strict'
var ssbKeys = require('ssb-keys')
var timestamp = require('monotonic-timestamp')
var isRef = require('ssb-ref')
var isHash = isRef.isHash
var isFeedId = isRef.isFeedId
var encode = exports.encode = function (obj) {
return JSON.stringify(obj, null, 2)
}
function isString (s) {
return 'string' === typeof s
}
function isInteger (n) {
return ~~n === n
}
function isObject (o) {
return o && 'object' === typeof o