hyperdrive
Advanced tools
Comparing version 11.6.3 to 11.7.0
41
index.js
@@ -10,2 +10,4 @@ const Hyperbee = require('hyperbee') | ||
const safetyCatch = require('safety-catch') | ||
const crypto = require('hypercore-crypto') | ||
const Hypercore = require('hypercore') | ||
const { BLOCK_NOT_AVAILABLE } = require('hypercore-errors') | ||
@@ -15,2 +17,4 @@ | ||
const [BLOBS] = crypto.namespace('hyperdrive', 1) | ||
module.exports = class Hyperdrive extends ReadyResource { | ||
@@ -44,2 +48,23 @@ constructor (corestore, key, opts = {}) { | ||
_generateBlobsManifest () { | ||
const m = this.db.core.manifest | ||
if (m.version < 1 || this.db.core.core.compat) return null | ||
const signers = [] | ||
for (const s of m.signers) { | ||
const namespace = crypto.hash([BLOBS, this.core.key, s.namespace]) | ||
signers.push({ ...s, namespace }) | ||
} | ||
return { | ||
version: m.version, | ||
hash: 'blake2b', | ||
allowPatch: m.allowPatch, | ||
quorum: m.quorum, | ||
signers, | ||
prologue: null // TODO: could be configurable through the header still... | ||
} | ||
} | ||
get id () { | ||
@@ -132,3 +157,4 @@ return this.core.id | ||
const blobsKey = header.metadata && header.metadata.contentFeed.subarray(0, 32) | ||
const contentKey = header.metadata && header.metadata.contentFeed && header.metadata.contentFeed.subarray(0, 32) | ||
const blobsKey = contentKey || Hypercore.key(this._generateBlobsManifest()) | ||
if (!blobsKey || blobsKey.length < 32) throw new Error('Invalid or no Blob store key set') | ||
@@ -140,3 +166,4 @@ | ||
onwait: this._onwait, | ||
encryptionKey: this.encryptionKey | ||
encryptionKey: this.encryptionKey, | ||
keyPair: (!contentKey && this.db.core.writable) ? this.db.core.keyPair : null | ||
}) | ||
@@ -168,8 +195,11 @@ await blobsCore.ready() | ||
if (this.db.core.writable && !this.blobs) { | ||
const m = this._generateBlobsManifest() | ||
const blobsCore = this.corestore.get({ | ||
name: this.db.core.id + '/blobs', // simple trick to avoid blobs clashing if no namespace is provided... | ||
manifest: m, | ||
name: m ? null : this.db.core.id + '/blobs', // simple trick to avoid blobs clashing if no namespace is provided... | ||
cache: false, | ||
onwait: this._onwait, | ||
encryptionKey: this.encryptionKey, | ||
compat: this.db.core.core.compat | ||
compat: this.db.core.core.compat, | ||
keyPair: (m && this.db.core.writable) ? this.db.core.keyPair : null | ||
}) | ||
@@ -179,4 +209,5 @@ await blobsCore.ready() | ||
this.blobs = new Hyperblobs(blobsCore) | ||
getBee(this.db).metadata.contentFeed = this.blobs.core.key | ||
if (!m) getBee(this.db).metadata.contentFeed = this.blobs.core.key | ||
this.emit('blobs', this.blobs) | ||
@@ -183,0 +214,0 @@ this.emit('content-key', blobsCore.key) |
{ | ||
"name": "hyperdrive", | ||
"version": "11.6.3", | ||
"version": "11.7.0", | ||
"description": "Hyperdrive is a secure, real-time distributed file system", | ||
@@ -26,2 +26,3 @@ "main": "index.js", | ||
"hyperblobs": "^2.3.0", | ||
"hypercore": "^10.33.0", | ||
"hypercore-errors": "^1.0.0", | ||
@@ -40,3 +41,3 @@ "is-options": "^1.0.2", | ||
"corestore": "^6.8.1", | ||
"hypercore-crypto": "^3.2.1", | ||
"hypercore-crypto": "^3.4.0", | ||
"hyperdht": "^6.6.0", | ||
@@ -43,0 +44,0 @@ "hyperswarm": "^4.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38434
482
11
+ Addedhypercore@^10.33.0
+ Added@hyperswarm/secret-stream@6.7.1(transitive)
+ Addedbare-fs@3.1.1(transitive)
+ Addedbare-os@3.2.1(transitive)
+ Addedbare-path@3.0.0(transitive)
+ Addedbare-stream@2.3.2(transitive)
+ Addedbig-sparse-array@1.0.3(transitive)
+ Addedcompact-encoding@2.15.0(transitive)
+ Addedcrc-native@1.1.4(transitive)
+ Addedcrc-universal@1.0.4(transitive)
+ Addedflat-tree@1.12.1(transitive)
+ Addedfs-native-extensions@1.3.2(transitive)
+ Addedhypercore@10.37.26(transitive)
+ Addedhypercore-crypto@3.4.2(transitive)
+ Addedhypercore-id-encoding@1.3.0(transitive)
+ Addednanoassert@2.0.0(transitive)
+ Addednode-gyp-build@4.8.2(transitive)
+ Addednoise-curve-ed@2.0.1(transitive)
+ Addednoise-handshake@3.1.0(transitive)
+ Addedprotomux@3.10.0(transitive)
+ Addedquickbit-native@2.3.3(transitive)
+ Addedquickbit-universal@2.2.0(transitive)
+ Addedrandom-access-file@4.1.0(transitive)
+ Addedrandom-access-storage@3.0.2(transitive)
+ Addedrandom-array-iterator@1.0.0(transitive)
+ Addedsimdle-native@1.3.3(transitive)
+ Addedsimdle-universal@1.1.2(transitive)
+ Addedsodium-native@4.3.0(transitive)
+ Addedsodium-secretstream@1.1.1(transitive)
+ Addedsodium-universal@4.0.1(transitive)
+ Addedtimeout-refresh@2.0.1(transitive)
+ Addedwhich-runtime@1.2.1(transitive)
+ Addedxache@1.2.1(transitive)
+ Addedz32@1.1.0(transitive)