@bcts/hubert 1.0.0-alpha.17
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/LICENSE +48 -0
- package/README.md +18 -0
- package/dist/arid-derivation-1CJuU-kZ.cjs +150 -0
- package/dist/arid-derivation-1CJuU-kZ.cjs.map +1 -0
- package/dist/arid-derivation-CbqACjdg.mjs +126 -0
- package/dist/arid-derivation-CbqACjdg.mjs.map +1 -0
- package/dist/bin/hubert.cjs +384 -0
- package/dist/bin/hubert.cjs.map +1 -0
- package/dist/bin/hubert.d.cts +1 -0
- package/dist/bin/hubert.d.mts +1 -0
- package/dist/bin/hubert.mjs +383 -0
- package/dist/bin/hubert.mjs.map +1 -0
- package/dist/chunk-CbDLau6x.cjs +34 -0
- package/dist/hybrid/index.cjs +14 -0
- package/dist/hybrid/index.d.cts +3 -0
- package/dist/hybrid/index.d.mts +3 -0
- package/dist/hybrid/index.mjs +6 -0
- package/dist/hybrid-BZhumygj.mjs +356 -0
- package/dist/hybrid-BZhumygj.mjs.map +1 -0
- package/dist/hybrid-dX5JLumO.cjs +410 -0
- package/dist/hybrid-dX5JLumO.cjs.map +1 -0
- package/dist/index-BEzpUC7r.d.mts +380 -0
- package/dist/index-BEzpUC7r.d.mts.map +1 -0
- package/dist/index-C2F6ugLL.d.mts +210 -0
- package/dist/index-C2F6ugLL.d.mts.map +1 -0
- package/dist/index-CUnDouMb.d.mts +215 -0
- package/dist/index-CUnDouMb.d.mts.map +1 -0
- package/dist/index-CV6lZJqY.d.cts +380 -0
- package/dist/index-CV6lZJqY.d.cts.map +1 -0
- package/dist/index-CY3TCzIm.d.cts +217 -0
- package/dist/index-CY3TCzIm.d.cts.map +1 -0
- package/dist/index-DEr4SR1J.d.cts +215 -0
- package/dist/index-DEr4SR1J.d.cts.map +1 -0
- package/dist/index-T1LHanIb.d.mts +217 -0
- package/dist/index-T1LHanIb.d.mts.map +1 -0
- package/dist/index-jyzuOhFB.d.cts +210 -0
- package/dist/index-jyzuOhFB.d.cts.map +1 -0
- package/dist/index.cjs +60 -0
- package/dist/index.d.cts +161 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +161 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +10 -0
- package/dist/ipfs/index.cjs +13 -0
- package/dist/ipfs/index.d.cts +3 -0
- package/dist/ipfs/index.d.mts +3 -0
- package/dist/ipfs/index.mjs +5 -0
- package/dist/ipfs-BRMMCBjv.mjs +1 -0
- package/dist/ipfs-CetOVQcO.cjs +0 -0
- package/dist/kv-BAmhmMOo.cjs +425 -0
- package/dist/kv-BAmhmMOo.cjs.map +1 -0
- package/dist/kv-C-emxv0w.mjs +375 -0
- package/dist/kv-C-emxv0w.mjs.map +1 -0
- package/dist/kv-DJiKvypY.mjs +403 -0
- package/dist/kv-DJiKvypY.mjs.map +1 -0
- package/dist/kv-store-DmngWWuw.d.mts +183 -0
- package/dist/kv-store-DmngWWuw.d.mts.map +1 -0
- package/dist/kv-store-ww-AUyLd.d.cts +183 -0
- package/dist/kv-store-ww-AUyLd.d.cts.map +1 -0
- package/dist/kv-yjvQa_LH.cjs +457 -0
- package/dist/kv-yjvQa_LH.cjs.map +1 -0
- package/dist/logging-hmzNzifq.mjs +158 -0
- package/dist/logging-hmzNzifq.mjs.map +1 -0
- package/dist/logging-qc9uMgil.cjs +212 -0
- package/dist/logging-qc9uMgil.cjs.map +1 -0
- package/dist/mainline/index.cjs +12 -0
- package/dist/mainline/index.d.cts +3 -0
- package/dist/mainline/index.d.mts +3 -0
- package/dist/mainline/index.mjs +5 -0
- package/dist/mainline-D_jfeFMh.cjs +0 -0
- package/dist/mainline-cFIuXbo-.mjs +1 -0
- package/dist/server/index.cjs +14 -0
- package/dist/server/index.d.cts +3 -0
- package/dist/server/index.d.mts +3 -0
- package/dist/server/index.mjs +3 -0
- package/dist/server-BBNRZ30D.cjs +912 -0
- package/dist/server-BBNRZ30D.cjs.map +1 -0
- package/dist/server-DVyk9gqU.mjs +836 -0
- package/dist/server-DVyk9gqU.mjs.map +1 -0
- package/package.json +125 -0
- package/src/arid-derivation.ts +155 -0
- package/src/bin/hubert.ts +667 -0
- package/src/error.ts +89 -0
- package/src/hybrid/error.ts +77 -0
- package/src/hybrid/index.ts +24 -0
- package/src/hybrid/kv.ts +236 -0
- package/src/hybrid/reference.ts +176 -0
- package/src/index.ts +145 -0
- package/src/ipfs/error.ts +83 -0
- package/src/ipfs/index.ts +24 -0
- package/src/ipfs/kv.ts +476 -0
- package/src/ipfs/value.ts +85 -0
- package/src/kv-store.ts +128 -0
- package/src/logging.ts +88 -0
- package/src/mainline/error.ts +108 -0
- package/src/mainline/index.ts +23 -0
- package/src/mainline/kv.ts +411 -0
- package/src/server/error.ts +83 -0
- package/src/server/index.ts +29 -0
- package/src/server/kv.ts +211 -0
- package/src/server/memory-kv.ts +191 -0
- package/src/server/server-kv.ts +92 -0
- package/src/server/server.ts +369 -0
- package/src/server/sqlite-kv.ts +295 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hubert - Distributed infrastructure for secure multiparty transactions.
|
|
3
|
+
*
|
|
4
|
+
* This library provides distributed key-value storage using ARID-based addressing
|
|
5
|
+
* with multiple storage backends for FROST threshold signature protocols.
|
|
6
|
+
*
|
|
7
|
+
* Port of lib.rs from hubert-rust.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
* @module @bcts/hubert
|
|
11
|
+
*
|
|
12
|
+
* @example Basic Usage
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { KvStore, deriveIpfsKeyName } from "@bcts/hubert";
|
|
15
|
+
* import { ARID } from "@bcts/components";
|
|
16
|
+
* import { Envelope } from "@bcts/envelope";
|
|
17
|
+
*
|
|
18
|
+
* // Create an ARID
|
|
19
|
+
* const arid = ARID.new();
|
|
20
|
+
*
|
|
21
|
+
* // Create an envelope
|
|
22
|
+
* const envelope = Envelope.new("Hello, Hubert!");
|
|
23
|
+
*
|
|
24
|
+
* // Use any KvStore implementation to store/retrieve
|
|
25
|
+
* async function example(store: KvStore) {
|
|
26
|
+
* await store.put(arid, envelope);
|
|
27
|
+
* const result = await store.get(arid);
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
// =============================================================================
|
|
33
|
+
// Error Types
|
|
34
|
+
// =============================================================================
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
HubertError,
|
|
38
|
+
AlreadyExistsError,
|
|
39
|
+
NotFoundError,
|
|
40
|
+
InvalidAridError,
|
|
41
|
+
IoError,
|
|
42
|
+
} from "./error.js";
|
|
43
|
+
|
|
44
|
+
// =============================================================================
|
|
45
|
+
// KvStore Interface
|
|
46
|
+
// =============================================================================
|
|
47
|
+
|
|
48
|
+
export { type KvStore } from "./kv-store.js";
|
|
49
|
+
|
|
50
|
+
// =============================================================================
|
|
51
|
+
// ARID Derivation
|
|
52
|
+
// =============================================================================
|
|
53
|
+
|
|
54
|
+
export {
|
|
55
|
+
deriveKey,
|
|
56
|
+
deriveIpfsKeyName,
|
|
57
|
+
deriveMainlineKey,
|
|
58
|
+
obfuscateWithArid,
|
|
59
|
+
} from "./arid-derivation.js";
|
|
60
|
+
|
|
61
|
+
// =============================================================================
|
|
62
|
+
// Logging Utilities
|
|
63
|
+
// =============================================================================
|
|
64
|
+
|
|
65
|
+
export { timestamp, verbosePrintln, verbosePrintDot, verboseNewline } from "./logging.js";
|
|
66
|
+
|
|
67
|
+
// =============================================================================
|
|
68
|
+
// Server Module
|
|
69
|
+
// =============================================================================
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
// Error types
|
|
73
|
+
ServerError,
|
|
74
|
+
ServerGeneralError,
|
|
75
|
+
ServerNetworkError,
|
|
76
|
+
ServerParseError,
|
|
77
|
+
SqliteError,
|
|
78
|
+
// Storage backends
|
|
79
|
+
MemoryKv,
|
|
80
|
+
SqliteKv,
|
|
81
|
+
type ServerKv,
|
|
82
|
+
createMemoryKv,
|
|
83
|
+
createSqliteKv,
|
|
84
|
+
// HTTP server
|
|
85
|
+
Server,
|
|
86
|
+
type ServerConfig,
|
|
87
|
+
defaultServerConfig,
|
|
88
|
+
// HTTP client
|
|
89
|
+
ServerKvClient,
|
|
90
|
+
} from "./server/index.js";
|
|
91
|
+
|
|
92
|
+
// =============================================================================
|
|
93
|
+
// IPFS Module
|
|
94
|
+
// =============================================================================
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
// Error types
|
|
98
|
+
IpfsError,
|
|
99
|
+
EnvelopeTooLargeError,
|
|
100
|
+
IpfsDaemonError,
|
|
101
|
+
IpfsTimeoutError,
|
|
102
|
+
UnexpectedIpnsPathFormatError,
|
|
103
|
+
// IPFS value helpers
|
|
104
|
+
addBytes,
|
|
105
|
+
catBytes,
|
|
106
|
+
pinCid,
|
|
107
|
+
// IPFS KvStore implementation
|
|
108
|
+
IpfsKv,
|
|
109
|
+
} from "./ipfs/index.js";
|
|
110
|
+
|
|
111
|
+
// =============================================================================
|
|
112
|
+
// Mainline Module
|
|
113
|
+
// =============================================================================
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
// Error types
|
|
117
|
+
MainlineError,
|
|
118
|
+
ValueTooLargeError,
|
|
119
|
+
DhtError,
|
|
120
|
+
PutQueryError,
|
|
121
|
+
DecodeIdError,
|
|
122
|
+
PutMutableError,
|
|
123
|
+
MainlineIoError,
|
|
124
|
+
// Mainline DHT KvStore implementation
|
|
125
|
+
MainlineDhtKv,
|
|
126
|
+
} from "./mainline/index.js";
|
|
127
|
+
|
|
128
|
+
// =============================================================================
|
|
129
|
+
// Hybrid Module
|
|
130
|
+
// =============================================================================
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
// Error types
|
|
134
|
+
HybridError,
|
|
135
|
+
ContentNotFoundError,
|
|
136
|
+
NotReferenceEnvelopeError,
|
|
137
|
+
InvalidReferenceAridError,
|
|
138
|
+
NoIdAssertionError,
|
|
139
|
+
// Reference envelope utilities
|
|
140
|
+
createReferenceEnvelope,
|
|
141
|
+
isReferenceEnvelope,
|
|
142
|
+
extractReferenceArid,
|
|
143
|
+
// Hybrid KvStore implementation
|
|
144
|
+
HybridKv,
|
|
145
|
+
} from "./hybrid/index.js";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPFS-specific errors.
|
|
3
|
+
*
|
|
4
|
+
* Port of ipfs/error.rs from hubert-rust.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { HubertError } from "../error.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Base class for IPFS-specific errors.
|
|
13
|
+
*
|
|
14
|
+
* @category IPFS
|
|
15
|
+
*/
|
|
16
|
+
export class IpfsError extends HubertError {
|
|
17
|
+
constructor(message: string) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = "IpfsError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Envelope size exceeds practical limit.
|
|
25
|
+
*
|
|
26
|
+
* Port of `Error::EnvelopeTooLarge { size }` from ipfs/error.rs line 5.
|
|
27
|
+
*
|
|
28
|
+
* @category IPFS
|
|
29
|
+
*/
|
|
30
|
+
export class EnvelopeTooLargeError extends IpfsError {
|
|
31
|
+
readonly size: number;
|
|
32
|
+
|
|
33
|
+
constructor(size: number) {
|
|
34
|
+
super(`Envelope size ${size} exceeds practical limit`);
|
|
35
|
+
this.name = "EnvelopeTooLargeError";
|
|
36
|
+
this.size = size;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* IPFS daemon error.
|
|
42
|
+
*
|
|
43
|
+
* Port of `Error::DaemonError` from ipfs/error.rs line 8.
|
|
44
|
+
*
|
|
45
|
+
* @category IPFS
|
|
46
|
+
*/
|
|
47
|
+
export class IpfsDaemonError extends IpfsError {
|
|
48
|
+
constructor(message: string) {
|
|
49
|
+
super(`IPFS daemon error: ${message}`);
|
|
50
|
+
this.name = "IpfsDaemonError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Operation timed out.
|
|
56
|
+
*
|
|
57
|
+
* Port of `Error::Timeout` from ipfs/error.rs line 11.
|
|
58
|
+
*
|
|
59
|
+
* @category IPFS
|
|
60
|
+
*/
|
|
61
|
+
export class IpfsTimeoutError extends IpfsError {
|
|
62
|
+
constructor() {
|
|
63
|
+
super("Operation timed out");
|
|
64
|
+
this.name = "IpfsTimeoutError";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Unexpected IPNS path format.
|
|
70
|
+
*
|
|
71
|
+
* Port of `Error::UnexpectedIpnsPathFormat` from ipfs/error.rs line 14.
|
|
72
|
+
*
|
|
73
|
+
* @category IPFS
|
|
74
|
+
*/
|
|
75
|
+
export class UnexpectedIpnsPathFormatError extends IpfsError {
|
|
76
|
+
readonly path: string;
|
|
77
|
+
|
|
78
|
+
constructor(path: string) {
|
|
79
|
+
super(`Unexpected IPNS path format: ${path}`);
|
|
80
|
+
this.name = "UnexpectedIpnsPathFormatError";
|
|
81
|
+
this.path = path;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPFS module for Hubert distributed storage.
|
|
3
|
+
*
|
|
4
|
+
* This module provides IPFS-backed storage using IPNS for ARID-based addressing.
|
|
5
|
+
*
|
|
6
|
+
* Port of ipfs/mod.rs from hubert-rust.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Error types
|
|
12
|
+
export {
|
|
13
|
+
IpfsError,
|
|
14
|
+
EnvelopeTooLargeError,
|
|
15
|
+
IpfsDaemonError,
|
|
16
|
+
IpfsTimeoutError,
|
|
17
|
+
UnexpectedIpnsPathFormatError,
|
|
18
|
+
} from "./error.js";
|
|
19
|
+
|
|
20
|
+
// IPFS value helpers
|
|
21
|
+
export { addBytes, catBytes, pinCid } from "./value.js";
|
|
22
|
+
|
|
23
|
+
// IPFS KvStore implementation
|
|
24
|
+
export { IpfsKv } from "./kv.js";
|