hypercore 10.18.0 → 10.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/errors.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // explicitly exposed as hypercore/errors
2
- module.exports = require('./lib/errors')
2
+ module.exports = require('hypercore-errors')
package/index.js CHANGED
@@ -23,7 +23,7 @@ const {
23
23
  SESSION_CLOSED,
24
24
  SESSION_NOT_WRITABLE,
25
25
  SNAPSHOT_NOT_AVAILABLE
26
- } = require('./lib/errors')
26
+ } = require('hypercore-errors')
27
27
 
28
28
  const promises = Symbol.for('hypercore.promises')
29
29
  const inspect = Symbol.for('nodejs.util.inspect.custom')
package/lib/batch.js CHANGED
@@ -1,4 +1,4 @@
1
- const { SESSION_NOT_WRITABLE, BATCH_ALREADY_FLUSHED } = require('./errors')
1
+ const { SESSION_NOT_WRITABLE, BATCH_ALREADY_FLUSHED } = require('hypercore-errors')
2
2
 
3
3
  module.exports = class Batch {
4
4
  constructor (session) {
package/lib/core.js CHANGED
@@ -6,7 +6,7 @@ const MerkleTree = require('./merkle-tree')
6
6
  const BlockStore = require('./block-store')
7
7
  const Bitfield = require('./bitfield')
8
8
  const Info = require('./info')
9
- const { BAD_ARGUMENT, STORAGE_EMPTY, STORAGE_CONFLICT, INVALID_SIGNATURE } = require('./errors')
9
+ const { BAD_ARGUMENT, STORAGE_EMPTY, STORAGE_CONFLICT, INVALID_SIGNATURE } = require('hypercore-errors')
10
10
  const m = require('./messages')
11
11
 
12
12
  module.exports = class Core {
@@ -4,7 +4,7 @@ const c = require('compact-encoding')
4
4
  const Xache = require('xache')
5
5
  const b4a = require('b4a')
6
6
  const caps = require('./caps')
7
- const { INVALID_PROOF, INVALID_CHECKSUM, INVALID_OPERATION, BAD_ARGUMENT } = require('./errors')
7
+ const { INVALID_PROOF, INVALID_CHECKSUM, INVALID_OPERATION, BAD_ARGUMENT } = require('hypercore-errors')
8
8
 
9
9
  const BLANK_HASH = b4a.alloc(32)
10
10
  const OLD_TREE = b4a.from([5, 2, 87, 2, 0, 0, 40, 7, 66, 76, 65, 75, 69, 50, 98])
package/lib/messages.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const c = require('compact-encoding')
2
2
  const b4a = require('b4a')
3
- const { INVALID_OPLOG_VERSION } = require('./errors')
3
+ const { INVALID_OPLOG_VERSION } = require('hypercore-errors')
4
4
 
5
5
  const EMPTY = b4a.alloc(0)
6
6
 
package/lib/oplog.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const cenc = require('compact-encoding')
2
2
  const b4a = require('b4a')
3
3
  const { crc32 } = require('crc-universal')
4
- const { OPLOG_CORRUPT } = require('./errors')
4
+ const { OPLOG_CORRUPT } = require('hypercore-errors')
5
5
 
6
6
  module.exports = class Oplog {
7
7
  constructor (storage, { pageSize = 4096, headerEncoding = cenc.raw, entryEncoding = cenc.raw, readonly = false } = {}) {
package/lib/replicator.js CHANGED
@@ -3,7 +3,7 @@ const safetyCatch = require('safety-catch')
3
3
  const RandomIterator = require('random-array-iterator')
4
4
  const ReceiverQueue = require('./receiver-queue')
5
5
  const RemoteBitfield = require('./remote-bitfield')
6
- const { REQUEST_CANCELLED, REQUEST_TIMEOUT, INVALID_CAPABILITY, SNAPSHOT_NOT_AVAILABLE } = require('./errors')
6
+ const { REQUEST_CANCELLED, REQUEST_TIMEOUT, INVALID_CAPABILITY, SNAPSHOT_NOT_AVAILABLE } = require('hypercore-errors')
7
7
  const m = require('./messages')
8
8
  const caps = require('./caps')
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.18.0",
3
+ "version": "10.18.1",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -44,6 +44,7 @@
44
44
  "fast-fifo": "^1.3.0",
45
45
  "flat-tree": "^1.9.0",
46
46
  "hypercore-crypto": "^3.2.1",
47
+ "hypercore-errors": "^1.0.0",
47
48
  "is-options": "^1.0.1",
48
49
  "protomux": "^3.5.0",
49
50
  "quickbit-universal": "^2.1.1",
package/lib/errors.js DELETED
@@ -1,90 +0,0 @@
1
- module.exports = class HypercoreError extends Error {
2
- constructor (msg, code, fn = HypercoreError) {
3
- super(`${code}: ${msg}`)
4
- this.code = code
5
-
6
- if (Error.captureStackTrace) {
7
- Error.captureStackTrace(this, fn)
8
- }
9
- }
10
-
11
- get name () {
12
- return 'HypercoreError'
13
- }
14
-
15
- static BAD_ARGUMENT (msg) {
16
- return new HypercoreError(msg, 'BAD_ARGUMENT', HypercoreError.BAD_ARGUMENT)
17
- }
18
-
19
- static STORAGE_EMPTY (msg) {
20
- return new HypercoreError(msg, 'STORAGE_EMPTY', HypercoreError.STORAGE_EMPTY)
21
- }
22
-
23
- static STORAGE_CONFLICT (msg) {
24
- return new HypercoreError(msg, 'STORAGE_CONFLICT', HypercoreError.STORAGE_CONFLICT)
25
- }
26
-
27
- static INVALID_SIGNATURE (msg) {
28
- return new HypercoreError(msg, 'INVALID_SIGNATURE', HypercoreError.INVALID_SIGNATURE)
29
- }
30
-
31
- static INVALID_CAPABILITY (msg) {
32
- return new HypercoreError(msg, 'INVALID_CAPABILITY', HypercoreError.INVALID_CAPABILITY)
33
- }
34
-
35
- static INVALID_CHECKSUM (msg = 'Invalid checksum') {
36
- return new HypercoreError(msg, 'INVALID_CHECKSUM', HypercoreError.INVALID_CHECKSUM)
37
- }
38
-
39
- static INVALID_OPERATION (msg) {
40
- return new HypercoreError(msg, 'INVALID_OPERATION', HypercoreError.INVALID_OPERATION)
41
- }
42
-
43
- static INVALID_PROOF (msg = 'Proof not verifiable') {
44
- return new HypercoreError(msg, 'INVALID_PROOF', HypercoreError.INVALID_PROOF)
45
- }
46
-
47
- static BLOCK_NOT_AVAILABLE (msg = 'Block is not available') {
48
- return new HypercoreError(msg, 'BLOCK_NOT_AVAILABLE', HypercoreError.BLOCK_NOT_AVAILABLE)
49
- }
50
-
51
- static SNAPSHOT_NOT_AVAILABLE (msg = 'Snapshot is not available') {
52
- return new HypercoreError(msg, 'SNAPSHOT_NOT_AVAILABLE', HypercoreError.SNAPSHOT_NOT_AVAILABLE)
53
- }
54
-
55
- static REQUEST_CANCELLED (msg = 'Request was cancelled') {
56
- return new HypercoreError(msg, 'REQUEST_CANCELLED', HypercoreError.REQUEST_CANCELLED)
57
- }
58
-
59
- static REQUEST_TIMEOUT (msg = 'Request timed out') {
60
- return new HypercoreError(msg, 'REQUEST_TIMEOUT', HypercoreError.REQUEST_TIMEOUT)
61
- }
62
-
63
- static SESSION_NOT_WRITABLE (msg = 'Session is not writable') {
64
- return new HypercoreError(msg, 'SESSION_NOT_WRITABLE', HypercoreError.SESSION_NOT_WRITABLE)
65
- }
66
-
67
- static SESSION_CLOSED (msg = 'Session is closed') {
68
- return new HypercoreError(msg, 'SESSION_CLOSED', HypercoreError.SESSION_CLOSED)
69
- }
70
-
71
- static BATCH_UNFLUSHED (msg = 'Batch not yet flushed') {
72
- return new HypercoreError(msg, 'BATCH_UNFLUSHED', HypercoreError.BATCH_UNFLUSHED)
73
- }
74
-
75
- static BATCH_ALREADY_EXISTS (msg = 'Batch already exists') {
76
- return new HypercoreError(msg, 'BATCH_ALREADY_EXISTS', HypercoreError.BATCH_ALREADY_EXISTS)
77
- }
78
-
79
- static BATCH_ALREADY_FLUSHED (msg = 'Batch has already been flushed') {
80
- return new HypercoreError(msg, 'BATCH_ALREADY_FLUSHED', HypercoreError.BATCH_ALREADY_FLUSHED)
81
- }
82
-
83
- static OPLOG_CORRUPT (msg = 'Oplog file appears corrupt or out of date') {
84
- return new HypercoreError(msg, 'OPLOG_CORRUPT', HypercoreError.OPLOG_CORRUPT)
85
- }
86
-
87
- static INVALID_OPLOG_VERSION (msg = 'Invalid header version') {
88
- return new HypercoreError(msg, 'INVALID_OPLOG_VERSION', HypercoreError.INVALID_OPLOG_VERSION)
89
- }
90
- }