@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.
Files changed (104) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +18 -0
  3. package/dist/arid-derivation-1CJuU-kZ.cjs +150 -0
  4. package/dist/arid-derivation-1CJuU-kZ.cjs.map +1 -0
  5. package/dist/arid-derivation-CbqACjdg.mjs +126 -0
  6. package/dist/arid-derivation-CbqACjdg.mjs.map +1 -0
  7. package/dist/bin/hubert.cjs +384 -0
  8. package/dist/bin/hubert.cjs.map +1 -0
  9. package/dist/bin/hubert.d.cts +1 -0
  10. package/dist/bin/hubert.d.mts +1 -0
  11. package/dist/bin/hubert.mjs +383 -0
  12. package/dist/bin/hubert.mjs.map +1 -0
  13. package/dist/chunk-CbDLau6x.cjs +34 -0
  14. package/dist/hybrid/index.cjs +14 -0
  15. package/dist/hybrid/index.d.cts +3 -0
  16. package/dist/hybrid/index.d.mts +3 -0
  17. package/dist/hybrid/index.mjs +6 -0
  18. package/dist/hybrid-BZhumygj.mjs +356 -0
  19. package/dist/hybrid-BZhumygj.mjs.map +1 -0
  20. package/dist/hybrid-dX5JLumO.cjs +410 -0
  21. package/dist/hybrid-dX5JLumO.cjs.map +1 -0
  22. package/dist/index-BEzpUC7r.d.mts +380 -0
  23. package/dist/index-BEzpUC7r.d.mts.map +1 -0
  24. package/dist/index-C2F6ugLL.d.mts +210 -0
  25. package/dist/index-C2F6ugLL.d.mts.map +1 -0
  26. package/dist/index-CUnDouMb.d.mts +215 -0
  27. package/dist/index-CUnDouMb.d.mts.map +1 -0
  28. package/dist/index-CV6lZJqY.d.cts +380 -0
  29. package/dist/index-CV6lZJqY.d.cts.map +1 -0
  30. package/dist/index-CY3TCzIm.d.cts +217 -0
  31. package/dist/index-CY3TCzIm.d.cts.map +1 -0
  32. package/dist/index-DEr4SR1J.d.cts +215 -0
  33. package/dist/index-DEr4SR1J.d.cts.map +1 -0
  34. package/dist/index-T1LHanIb.d.mts +217 -0
  35. package/dist/index-T1LHanIb.d.mts.map +1 -0
  36. package/dist/index-jyzuOhFB.d.cts +210 -0
  37. package/dist/index-jyzuOhFB.d.cts.map +1 -0
  38. package/dist/index.cjs +60 -0
  39. package/dist/index.d.cts +161 -0
  40. package/dist/index.d.cts.map +1 -0
  41. package/dist/index.d.mts +161 -0
  42. package/dist/index.d.mts.map +1 -0
  43. package/dist/index.mjs +10 -0
  44. package/dist/ipfs/index.cjs +13 -0
  45. package/dist/ipfs/index.d.cts +3 -0
  46. package/dist/ipfs/index.d.mts +3 -0
  47. package/dist/ipfs/index.mjs +5 -0
  48. package/dist/ipfs-BRMMCBjv.mjs +1 -0
  49. package/dist/ipfs-CetOVQcO.cjs +0 -0
  50. package/dist/kv-BAmhmMOo.cjs +425 -0
  51. package/dist/kv-BAmhmMOo.cjs.map +1 -0
  52. package/dist/kv-C-emxv0w.mjs +375 -0
  53. package/dist/kv-C-emxv0w.mjs.map +1 -0
  54. package/dist/kv-DJiKvypY.mjs +403 -0
  55. package/dist/kv-DJiKvypY.mjs.map +1 -0
  56. package/dist/kv-store-DmngWWuw.d.mts +183 -0
  57. package/dist/kv-store-DmngWWuw.d.mts.map +1 -0
  58. package/dist/kv-store-ww-AUyLd.d.cts +183 -0
  59. package/dist/kv-store-ww-AUyLd.d.cts.map +1 -0
  60. package/dist/kv-yjvQa_LH.cjs +457 -0
  61. package/dist/kv-yjvQa_LH.cjs.map +1 -0
  62. package/dist/logging-hmzNzifq.mjs +158 -0
  63. package/dist/logging-hmzNzifq.mjs.map +1 -0
  64. package/dist/logging-qc9uMgil.cjs +212 -0
  65. package/dist/logging-qc9uMgil.cjs.map +1 -0
  66. package/dist/mainline/index.cjs +12 -0
  67. package/dist/mainline/index.d.cts +3 -0
  68. package/dist/mainline/index.d.mts +3 -0
  69. package/dist/mainline/index.mjs +5 -0
  70. package/dist/mainline-D_jfeFMh.cjs +0 -0
  71. package/dist/mainline-cFIuXbo-.mjs +1 -0
  72. package/dist/server/index.cjs +14 -0
  73. package/dist/server/index.d.cts +3 -0
  74. package/dist/server/index.d.mts +3 -0
  75. package/dist/server/index.mjs +3 -0
  76. package/dist/server-BBNRZ30D.cjs +912 -0
  77. package/dist/server-BBNRZ30D.cjs.map +1 -0
  78. package/dist/server-DVyk9gqU.mjs +836 -0
  79. package/dist/server-DVyk9gqU.mjs.map +1 -0
  80. package/package.json +125 -0
  81. package/src/arid-derivation.ts +155 -0
  82. package/src/bin/hubert.ts +667 -0
  83. package/src/error.ts +89 -0
  84. package/src/hybrid/error.ts +77 -0
  85. package/src/hybrid/index.ts +24 -0
  86. package/src/hybrid/kv.ts +236 -0
  87. package/src/hybrid/reference.ts +176 -0
  88. package/src/index.ts +145 -0
  89. package/src/ipfs/error.ts +83 -0
  90. package/src/ipfs/index.ts +24 -0
  91. package/src/ipfs/kv.ts +476 -0
  92. package/src/ipfs/value.ts +85 -0
  93. package/src/kv-store.ts +128 -0
  94. package/src/logging.ts +88 -0
  95. package/src/mainline/error.ts +108 -0
  96. package/src/mainline/index.ts +23 -0
  97. package/src/mainline/kv.ts +411 -0
  98. package/src/server/error.ts +83 -0
  99. package/src/server/index.ts +29 -0
  100. package/src/server/kv.ts +211 -0
  101. package/src/server/memory-kv.ts +191 -0
  102. package/src/server/server-kv.ts +92 -0
  103. package/src/server/server.ts +369 -0
  104. package/src/server/sqlite-kv.ts +295 -0
@@ -0,0 +1,210 @@
1
+ import { r as HubertError, t as KvStore } from "./kv-store-ww-AUyLd.cjs";
2
+ import { ARID } from "@bcts/components";
3
+ import { Envelope } from "@bcts/envelope";
4
+
5
+ //#region src/mainline/error.d.ts
6
+ /**
7
+ * Base class for Mainline DHT-specific errors.
8
+ *
9
+ * @category Mainline
10
+ */
11
+ declare class MainlineError extends HubertError {
12
+ constructor(message: string);
13
+ }
14
+ /**
15
+ * Value size exceeds DHT limit.
16
+ *
17
+ * Port of `Error::ValueTooLarge { size }` from mainline/error.rs line 4-5.
18
+ *
19
+ * @category Mainline
20
+ */
21
+ declare class ValueTooLargeError extends MainlineError {
22
+ readonly size: number;
23
+ constructor(size: number);
24
+ }
25
+ /**
26
+ * DHT operation error.
27
+ *
28
+ * Port of `Error::DhtError` from mainline/error.rs line 7-8.
29
+ *
30
+ * @category Mainline
31
+ */
32
+ declare class DhtError extends MainlineError {
33
+ constructor(message: string);
34
+ }
35
+ /**
36
+ * Put query error.
37
+ *
38
+ * Port of `Error::PutQueryError` from mainline/error.rs line 10-11.
39
+ *
40
+ * @category Mainline
41
+ */
42
+ declare class PutQueryError extends MainlineError {
43
+ constructor(message: string);
44
+ }
45
+ /**
46
+ * Decode ID error.
47
+ *
48
+ * Port of `Error::DecodeIdError` from mainline/error.rs line 13-14.
49
+ *
50
+ * @category Mainline
51
+ */
52
+ declare class DecodeIdError extends MainlineError {
53
+ constructor(message: string);
54
+ }
55
+ /**
56
+ * Put mutable error.
57
+ *
58
+ * Port of `Error::PutMutableError` from mainline/error.rs line 16-17.
59
+ *
60
+ * @category Mainline
61
+ */
62
+ declare class PutMutableError extends MainlineError {
63
+ constructor(message: string);
64
+ }
65
+ /**
66
+ * I/O error.
67
+ *
68
+ * Port of `Error::Io` from mainline/error.rs line 19-20.
69
+ *
70
+ * @category Mainline
71
+ */
72
+ declare class MainlineIoError extends MainlineError {
73
+ constructor(message: string);
74
+ }
75
+ //#endregion
76
+ //#region src/mainline/kv.d.ts
77
+ /**
78
+ * Mainline DHT-backed key-value store using ARID-based addressing.
79
+ *
80
+ * This implementation uses:
81
+ * - ARID → ed25519 signing key derivation (deterministic)
82
+ * - BEP-44 mutable storage (fixed location based on pubkey)
83
+ * - Mainline DHT (BitTorrent DHT) for decentralized storage
84
+ * - Write-once semantics (seq=1, put fails if already exists)
85
+ * - Maximum value size: 1000 bytes (DHT protocol limit)
86
+ *
87
+ * Port of `struct MainlineDhtKv` from mainline/kv.rs lines 60-64.
88
+ *
89
+ * # Storage Model
90
+ *
91
+ * Uses BEP-44 mutable items where:
92
+ * - Public key derived from ARID (deterministic ed25519)
93
+ * - Sequence number starts at 1 (write-once)
94
+ * - Optional salt for namespace separation
95
+ * - Location fixed by pubkey (not content hash)
96
+ *
97
+ * # Requirements
98
+ *
99
+ * No external daemon required - the DHT client runs embedded.
100
+ *
101
+ * # Size Limits
102
+ *
103
+ * The Mainline DHT has a practical limit of ~1KB per value. For larger
104
+ * envelopes, use `IpfsKv` or `HybridKv` instead.
105
+ *
106
+ * @category Mainline Backend
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const store = await MainlineDhtKv.create();
111
+ * const arid = ARID.new();
112
+ * const envelope = Envelope.new("Small message");
113
+ *
114
+ * // Put envelope (write-once)
115
+ * await store.put(arid, envelope);
116
+ *
117
+ * // Get envelope with verbose logging
118
+ * const retrieved = await store.get(arid, undefined, true);
119
+ * ```
120
+ */
121
+ declare class MainlineDhtKv implements KvStore {
122
+ private readonly dht;
123
+ private maxValueSize;
124
+ private salt;
125
+ private _isBootstrapped;
126
+ /**
127
+ * Private constructor - use `create()` factory method.
128
+ */
129
+ private constructor();
130
+ /**
131
+ * Check if the DHT is bootstrapped.
132
+ */
133
+ get isBootstrapped(): boolean;
134
+ /**
135
+ * Create a new Mainline DHT KV store with default settings.
136
+ *
137
+ * Port of `MainlineDhtKv::new()` from mainline/kv.rs lines 68-79.
138
+ */
139
+ static create(): Promise<MainlineDhtKv>;
140
+ /**
141
+ * Set the maximum value size (default: 1000 bytes).
142
+ *
143
+ * Note: Values larger than ~1KB may not be reliably stored in the DHT.
144
+ *
145
+ * Port of `MainlineDhtKv::with_max_size()` from mainline/kv.rs lines 84-87.
146
+ */
147
+ withMaxSize(size: number): this;
148
+ /**
149
+ * Set a salt for namespace separation.
150
+ *
151
+ * Different salts will create separate namespaces for the same ARID.
152
+ *
153
+ * Port of `MainlineDhtKv::with_salt()` from mainline/kv.rs lines 92-95.
154
+ */
155
+ withSalt(salt: Uint8Array): this;
156
+ /**
157
+ * Derive an ed25519 signing key from an ARID.
158
+ *
159
+ * Uses the ARID-derived key material extended to 32 bytes for ed25519.
160
+ *
161
+ * Port of `MainlineDhtKv::derive_signing_key()` from mainline/kv.rs lines 100-112.
162
+ *
163
+ * @internal
164
+ */
165
+ private static deriveSigningKey;
166
+ /**
167
+ * Get mutable item from DHT.
168
+ *
169
+ * @internal
170
+ */
171
+ private getMutable;
172
+ /**
173
+ * Put mutable item to DHT.
174
+ *
175
+ * @internal
176
+ */
177
+ private putMutable;
178
+ /**
179
+ * Compute DHT target hash from public key and optional salt.
180
+ *
181
+ * @internal
182
+ */
183
+ private computeTarget;
184
+ /**
185
+ * Store an envelope at the given ARID.
186
+ *
187
+ * Port of `KvStore::put()` implementation from mainline/kv.rs lines 144-220.
188
+ */
189
+ put(arid: ARID, envelope: Envelope, _ttlSeconds?: number, // Ignored - DHT has no TTL support
190
+ verbose?: boolean): Promise<string>;
191
+ /**
192
+ * Retrieve an envelope for the given ARID.
193
+ *
194
+ * Port of `KvStore::get()` implementation from mainline/kv.rs lines 223-303.
195
+ */
196
+ get(arid: ARID, timeoutSeconds?: number, verbose?: boolean): Promise<Envelope | null>;
197
+ /**
198
+ * Check if an envelope exists at the given ARID.
199
+ *
200
+ * Port of `KvStore::exists()` implementation from mainline/kv.rs lines 306-314.
201
+ */
202
+ exists(arid: ARID): Promise<boolean>;
203
+ /**
204
+ * Destroy the DHT client and release resources.
205
+ */
206
+ destroy(): Promise<void>;
207
+ }
208
+ //#endregion
209
+ export { MainlineIoError as a, ValueTooLargeError as c, MainlineError as i, DecodeIdError as n, PutMutableError as o, DhtError as r, PutQueryError as s, MainlineDhtKv as t };
210
+ //# sourceMappingURL=index-jyzuOhFB.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-jyzuOhFB.d.cts","names":[],"sources":["../src/mainline/error.ts","../src/mainline/kv.ts"],"mappings":";;;;;;;;;;cAea,aAAA,SAAsB,WAAA;cACrB,OAAA;AAAA;;;;;;;;cAaD,kBAAA,SAA2B,aAAA;EAAA,SAC7B,IAAA;cAEG,IAAA;AAAA;;;;;;;AA4Bd;cAda,QAAA,SAAiB,aAAA;cAChB,OAAA;AAAA;;;;;;AA2Bd;;cAda,aAAA,SAAsB,aAAA;cACrB,OAAA;AAAA;;;;;AA2Bd;;;cAda,aAAA,SAAsB,aAAA;cACrB,OAAA;AAAA;;;;AA2Bd;;;;cAda,eAAA,SAAwB,aAAA;cACvB,OAAA;AAAA;;;;;;ACxBd;;cDqCa,eAAA,SAAwB,aAAA;cACvB,OAAA;AAAA;;;;;;;AA1Ed;;;;;;;;;;AAiBA;;;;;;;;;AAcA;;;;;;;;;AAcA;;;;;;;;;AAcA;;;cCvBa,aAAA,YAAyB,OAAA;EAAA,iBACnB,GAAA;EAAA,QACT,YAAA;EAAA,QACA,IAAA;EAAA,QACA,eAAA;EDoBmB;AAa7B;;EAb6B,QCfpB,WAAA,CAAA;ED4ByC;;;EAAA,IClB5C,cAAA,CAAA;EDmBuB;;;;;EAAA,OCVd,MAAA,CAAA,GAAU,OAAA,CAAQ,aAAA;EA5BN;;;;;;;EA6DzB,WAAA,CAAY,IAAA;EAiMI;;;;;;;EArLhB,QAAA,CAAS,IAAA,EAAM,UAAA;EAzE4B;;;;;;;;;EAAA,eAuF5B,gBAAA;EA3DgB;;;;;EAAA,QAiFvB,UAAA;EAtBO;;;;;EAAA,QAyCP,UAAA;EA4DN;;;;;EAAA,QAlBM,aAAA;EAoFF;;;;;EAnEA,GAAA,CACJ,IAAA,EAAM,IAAA,EACN,QAAA,EAAU,QAAA,EACV,WAAA;EACA,OAAA,aACC,OAAA;EAuIG;;;;;EAzEA,GAAA,CAAI,IAAA,EAAM,IAAA,EAAM,cAAA,WAAyB,OAAA,aAAoB,OAAA,CAAQ,QAAA;EAoFzD;;;;;EAXZ,MAAA,CAAO,IAAA,EAAM,IAAA,GAAO,OAAA;;;;EAW1B,OAAA,CAAA,GAAW,OAAA;AAAA"}
package/dist/index.cjs ADDED
@@ -0,0 +1,60 @@
1
+ const require_logging = require('./logging-qc9uMgil.cjs');
2
+ const require_arid_derivation = require('./arid-derivation-1CJuU-kZ.cjs');
3
+ const require_server = require('./server-BBNRZ30D.cjs');
4
+ const require_kv = require('./kv-yjvQa_LH.cjs');
5
+ require('./ipfs-CetOVQcO.cjs');
6
+ const require_kv$1 = require('./kv-BAmhmMOo.cjs');
7
+ require('./mainline-D_jfeFMh.cjs');
8
+ const require_hybrid = require('./hybrid-dX5JLumO.cjs');
9
+
10
+ exports.AlreadyExistsError = require_logging.AlreadyExistsError;
11
+ exports.ContentNotFoundError = require_hybrid.ContentNotFoundError;
12
+ exports.DecodeIdError = require_kv$1.DecodeIdError;
13
+ exports.DhtError = require_kv$1.DhtError;
14
+ exports.EnvelopeTooLargeError = require_kv.EnvelopeTooLargeError;
15
+ exports.HubertError = require_logging.HubertError;
16
+ exports.HybridError = require_hybrid.HybridError;
17
+ exports.HybridKv = require_hybrid.HybridKv;
18
+ exports.InvalidAridError = require_logging.InvalidAridError;
19
+ exports.InvalidReferenceAridError = require_hybrid.InvalidReferenceAridError;
20
+ exports.IoError = require_logging.IoError;
21
+ exports.IpfsDaemonError = require_kv.IpfsDaemonError;
22
+ exports.IpfsError = require_kv.IpfsError;
23
+ exports.IpfsKv = require_kv.IpfsKv;
24
+ exports.IpfsTimeoutError = require_kv.IpfsTimeoutError;
25
+ exports.MainlineDhtKv = require_kv$1.MainlineDhtKv;
26
+ exports.MainlineError = require_kv$1.MainlineError;
27
+ exports.MainlineIoError = require_kv$1.MainlineIoError;
28
+ exports.MemoryKv = require_server.MemoryKv;
29
+ exports.NoIdAssertionError = require_hybrid.NoIdAssertionError;
30
+ exports.NotFoundError = require_logging.NotFoundError;
31
+ exports.NotReferenceEnvelopeError = require_hybrid.NotReferenceEnvelopeError;
32
+ exports.PutMutableError = require_kv$1.PutMutableError;
33
+ exports.PutQueryError = require_kv$1.PutQueryError;
34
+ exports.Server = require_server.Server;
35
+ exports.ServerError = require_server.ServerError;
36
+ exports.ServerGeneralError = require_server.ServerGeneralError;
37
+ exports.ServerKvClient = require_server.ServerKvClient;
38
+ exports.ServerNetworkError = require_server.ServerNetworkError;
39
+ exports.ServerParseError = require_server.ServerParseError;
40
+ exports.SqliteError = require_server.SqliteError;
41
+ exports.SqliteKv = require_server.SqliteKv;
42
+ exports.UnexpectedIpnsPathFormatError = require_kv.UnexpectedIpnsPathFormatError;
43
+ exports.ValueTooLargeError = require_kv$1.ValueTooLargeError;
44
+ exports.addBytes = require_kv.addBytes;
45
+ exports.catBytes = require_kv.catBytes;
46
+ exports.createMemoryKv = require_server.createMemoryKv;
47
+ exports.createReferenceEnvelope = require_hybrid.createReferenceEnvelope;
48
+ exports.createSqliteKv = require_server.createSqliteKv;
49
+ exports.defaultServerConfig = require_server.defaultServerConfig;
50
+ exports.deriveIpfsKeyName = require_arid_derivation.deriveIpfsKeyName;
51
+ exports.deriveKey = require_arid_derivation.deriveKey;
52
+ exports.deriveMainlineKey = require_arid_derivation.deriveMainlineKey;
53
+ exports.extractReferenceArid = require_hybrid.extractReferenceArid;
54
+ exports.isReferenceEnvelope = require_hybrid.isReferenceEnvelope;
55
+ exports.obfuscateWithArid = require_arid_derivation.obfuscateWithArid;
56
+ exports.pinCid = require_kv.pinCid;
57
+ exports.timestamp = require_logging.timestamp;
58
+ exports.verboseNewline = require_logging.verboseNewline;
59
+ exports.verbosePrintDot = require_logging.verbosePrintDot;
60
+ exports.verbosePrintln = require_logging.verbosePrintln;
@@ -0,0 +1,161 @@
1
+ import { a as IoError, i as InvalidAridError, n as AlreadyExistsError, o as NotFoundError, r as HubertError, t as KvStore } from "./kv-store-ww-AUyLd.cjs";
2
+ import { a as ContentNotFoundError, c as NoIdAssertionError, i as isReferenceEnvelope, l as NotReferenceEnvelopeError, n as createReferenceEnvelope, o as HybridError, r as extractReferenceArid, s as InvalidReferenceAridError, t as HybridKv } from "./index-CY3TCzIm.cjs";
3
+ import { a as ServerKv, c as SqliteKv, d as ServerGeneralError, f as ServerNetworkError, i as defaultServerConfig, l as MemoryKv, m as SqliteError, n as Server, o as createMemoryKv, p as ServerParseError, r as ServerConfig, s as createSqliteKv, t as ServerKvClient, u as ServerError } from "./index-CV6lZJqY.cjs";
4
+ import { a as EnvelopeTooLargeError, c as IpfsTimeoutError, i as pinCid, l as UnexpectedIpnsPathFormatError, n as addBytes, o as IpfsDaemonError, r as catBytes, s as IpfsError, t as IpfsKv } from "./index-DEr4SR1J.cjs";
5
+ import { a as MainlineIoError, c as ValueTooLargeError, i as MainlineError, n as DecodeIdError, o as PutMutableError, r as DhtError, s as PutQueryError, t as MainlineDhtKv } from "./index-jyzuOhFB.cjs";
6
+ import { ARID } from "@bcts/components";
7
+
8
+ //#region src/arid-derivation.d.ts
9
+ /**
10
+ * Derive a deterministic key from an ARID using a specific salt.
11
+ *
12
+ * Uses HKDF to derive key material from the ARID, ensuring that:
13
+ * - Same ARID always produces same key for a given salt
14
+ * - Keys are cryptographically derived (not guessable)
15
+ * - Collision resistance inherited from ARID
16
+ * - No identifying information in the key (fully anonymized)
17
+ *
18
+ * Port of `derive_key()` from arid_derivation.rs lines 8-29.
19
+ *
20
+ * @param salt - Domain-specific salt to ensure different backends derive different keys
21
+ * @param arid - The ARID to derive from
22
+ * @param outputLen - Length of output in bytes (typically 20 or 32)
23
+ * @returns Derived key bytes
24
+ * @category ARID Derivation
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const key = deriveKey(new TextEncoder().encode("my-salt"), arid, 32);
29
+ * ```
30
+ */
31
+ declare function deriveKey(salt: Uint8Array, arid: ARID, outputLen: number): Uint8Array;
32
+ /**
33
+ * Derive an IPNS key name from an ARID.
34
+ *
35
+ * Returns a 64-character hex string suitable for use as an IPFS key name.
36
+ *
37
+ * Port of `derive_ipfs_key_name()` from arid_derivation.rs lines 31-37.
38
+ *
39
+ * @param arid - The ARID to derive from
40
+ * @returns 64-character hex string
41
+ * @category ARID Derivation
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const keyName = deriveIpfsKeyName(arid);
46
+ * // => "a1b2c3d4e5f6..." (64 hex characters)
47
+ * ```
48
+ */
49
+ declare function deriveIpfsKeyName(arid: ARID): string;
50
+ /**
51
+ * Derive Mainline DHT key material from an ARID.
52
+ *
53
+ * Returns 20 bytes of key material (SHA-1 compatible length).
54
+ *
55
+ * Port of `derive_mainline_key()` from arid_derivation.rs lines 39-45.
56
+ *
57
+ * @param arid - The ARID to derive from
58
+ * @returns 20 bytes of key material
59
+ * @category ARID Derivation
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const key = deriveMainlineKey(arid);
64
+ * // => Uint8Array(20) [...]
65
+ * ```
66
+ */
67
+ declare function deriveMainlineKey(arid: ARID): Uint8Array;
68
+ /**
69
+ * Obfuscate or deobfuscate data using ChaCha20 with an ARID-derived key.
70
+ *
71
+ * This function uses ChaCha20 as a stream cipher to XOR the data with a
72
+ * keystream derived from the ARID. Since XOR is symmetric, the same function
73
+ * is used for both obfuscation and deobfuscation.
74
+ *
75
+ * The result appears as uniform random data to anyone who doesn't have the
76
+ * ARID, hiding both the structure and content of the reference envelope.
77
+ *
78
+ * Port of `obfuscate_with_arid()` from arid_derivation.rs lines 47-91.
79
+ *
80
+ * @param arid - The ARID used to derive the obfuscation key
81
+ * @param data - The data to obfuscate or deobfuscate
82
+ * @returns The obfuscated (or deobfuscated) data
83
+ * @category ARID Derivation
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const obfuscated = obfuscateWithArid(arid, plaintext);
88
+ * const deobfuscated = obfuscateWithArid(arid, obfuscated);
89
+ * // deobfuscated === plaintext
90
+ * ```
91
+ */
92
+ declare function obfuscateWithArid(arid: ARID, data: Uint8Array): Uint8Array;
93
+ //#endregion
94
+ //#region src/logging.d.ts
95
+ /**
96
+ * Logging utilities for verbose output with timestamps.
97
+ *
98
+ * Port of logging.rs from hubert-rust.
99
+ *
100
+ * @module
101
+ */
102
+ /**
103
+ * Format a timestamp in ISO-8601 Zulu format with fractional seconds.
104
+ *
105
+ * Port of `timestamp()` from logging.rs lines 6-71.
106
+ *
107
+ * @returns Timestamp string in format "YYYY-MM-DDTHH:MM:SS.mmmZ"
108
+ * @category Logging
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * timestamp() // => "2024-01-15T14:30:45.123Z"
113
+ * ```
114
+ */
115
+ declare function timestamp(): string;
116
+ /**
117
+ * Print a verbose message with timestamp prefix.
118
+ *
119
+ * Port of `verbose_println()` from logging.rs lines 74-78.
120
+ *
121
+ * @param message - The message to print
122
+ * @category Logging
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * verbosePrintln("Starting operation...");
127
+ * // Output: [2024-01-15T14:30:45.123Z] Starting operation...
128
+ * ```
129
+ */
130
+ declare function verbosePrintln(message: string): void;
131
+ /**
132
+ * Print a polling dot on the same line (no newline).
133
+ *
134
+ * Port of `verbose_print_dot()` from logging.rs lines 81-84.
135
+ *
136
+ * @category Logging
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * verbosePrintDot(); // Prints "." without newline
141
+ * ```
142
+ */
143
+ declare function verbosePrintDot(): void;
144
+ /**
145
+ * Print a newline after dots.
146
+ *
147
+ * Port of `verbose_newline()` from logging.rs lines 87-89.
148
+ *
149
+ * @category Logging
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * verbosePrintDot();
154
+ * verbosePrintDot();
155
+ * verboseNewline(); // Completes the line of dots
156
+ * ```
157
+ */
158
+ declare function verboseNewline(): void;
159
+ //#endregion
160
+ export { AlreadyExistsError, ContentNotFoundError, DecodeIdError, DhtError, EnvelopeTooLargeError, HubertError, HybridError, HybridKv, InvalidAridError, InvalidReferenceAridError, IoError, IpfsDaemonError, IpfsError, IpfsKv, IpfsTimeoutError, type KvStore, MainlineDhtKv, MainlineError, MainlineIoError, MemoryKv, NoIdAssertionError, NotFoundError, NotReferenceEnvelopeError, PutMutableError, PutQueryError, Server, type ServerConfig, ServerError, ServerGeneralError, type ServerKv, ServerKvClient, ServerNetworkError, ServerParseError, SqliteError, SqliteKv, UnexpectedIpnsPathFormatError, ValueTooLargeError, addBytes, catBytes, createMemoryKv, createReferenceEnvelope, createSqliteKv, defaultServerConfig, deriveIpfsKeyName, deriveKey, deriveMainlineKey, extractReferenceArid, isReferenceEnvelope, obfuscateWithArid, pinCid, timestamp, verboseNewline, verbosePrintDot, verbosePrintln };
161
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/arid-derivation.ts","../src/logging.ts"],"mappings":";;;;;;;;AAkCA;;;;;;;;;;;;;;;;AA0CA;;;;;AAsBA;AAhEA,iBAAgB,SAAA,CAAU,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,IAAA,EAAM,SAAA,WAAoB,UAAA;;;;;;;;AA4F5E;;;;;;;;;;iBAlDgB,iBAAA,CAAkB,IAAA,EAAM,IAAA;;;;;;;;ACvDxC;;;;;AA4BA;;;;;iBDiDgB,iBAAA,CAAkB,IAAA,EAAM,IAAA,GAAO,UAAA;;;;;ACb/C;;;;;;;;;;;;;;;;;;;;iBDyCgB,iBAAA,CAAkB,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,UAAA,GAAa,UAAA;;;;;;;;;;;AA5FjE;;;;;;;;;;;;iBCbgB,SAAA,CAAA;;;;ADuDhB;;;;;AAsBA;;;;;;iBCjDgB,cAAA,CAAe,OAAA;;;AD6E/B;;;;;;;;;;iBC3DgB,eAAA,CAAA;;;;;;;;AA9ChB;;;;;AA4BA;;iBAoCgB,cAAA,CAAA"}
@@ -0,0 +1,161 @@
1
+ import { a as IoError, i as InvalidAridError, n as AlreadyExistsError, o as NotFoundError, r as HubertError, t as KvStore } from "./kv-store-DmngWWuw.mjs";
2
+ import { a as ContentNotFoundError, c as NoIdAssertionError, i as isReferenceEnvelope, l as NotReferenceEnvelopeError, n as createReferenceEnvelope, o as HybridError, r as extractReferenceArid, s as InvalidReferenceAridError, t as HybridKv } from "./index-T1LHanIb.mjs";
3
+ import { a as ServerKv, c as SqliteKv, d as ServerGeneralError, f as ServerNetworkError, i as defaultServerConfig, l as MemoryKv, m as SqliteError, n as Server, o as createMemoryKv, p as ServerParseError, r as ServerConfig, s as createSqliteKv, t as ServerKvClient, u as ServerError } from "./index-BEzpUC7r.mjs";
4
+ import { a as EnvelopeTooLargeError, c as IpfsTimeoutError, i as pinCid, l as UnexpectedIpnsPathFormatError, n as addBytes, o as IpfsDaemonError, r as catBytes, s as IpfsError, t as IpfsKv } from "./index-CUnDouMb.mjs";
5
+ import { a as MainlineIoError, c as ValueTooLargeError, i as MainlineError, n as DecodeIdError, o as PutMutableError, r as DhtError, s as PutQueryError, t as MainlineDhtKv } from "./index-C2F6ugLL.mjs";
6
+ import { ARID } from "@bcts/components";
7
+
8
+ //#region src/arid-derivation.d.ts
9
+ /**
10
+ * Derive a deterministic key from an ARID using a specific salt.
11
+ *
12
+ * Uses HKDF to derive key material from the ARID, ensuring that:
13
+ * - Same ARID always produces same key for a given salt
14
+ * - Keys are cryptographically derived (not guessable)
15
+ * - Collision resistance inherited from ARID
16
+ * - No identifying information in the key (fully anonymized)
17
+ *
18
+ * Port of `derive_key()` from arid_derivation.rs lines 8-29.
19
+ *
20
+ * @param salt - Domain-specific salt to ensure different backends derive different keys
21
+ * @param arid - The ARID to derive from
22
+ * @param outputLen - Length of output in bytes (typically 20 or 32)
23
+ * @returns Derived key bytes
24
+ * @category ARID Derivation
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const key = deriveKey(new TextEncoder().encode("my-salt"), arid, 32);
29
+ * ```
30
+ */
31
+ declare function deriveKey(salt: Uint8Array, arid: ARID, outputLen: number): Uint8Array;
32
+ /**
33
+ * Derive an IPNS key name from an ARID.
34
+ *
35
+ * Returns a 64-character hex string suitable for use as an IPFS key name.
36
+ *
37
+ * Port of `derive_ipfs_key_name()` from arid_derivation.rs lines 31-37.
38
+ *
39
+ * @param arid - The ARID to derive from
40
+ * @returns 64-character hex string
41
+ * @category ARID Derivation
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const keyName = deriveIpfsKeyName(arid);
46
+ * // => "a1b2c3d4e5f6..." (64 hex characters)
47
+ * ```
48
+ */
49
+ declare function deriveIpfsKeyName(arid: ARID): string;
50
+ /**
51
+ * Derive Mainline DHT key material from an ARID.
52
+ *
53
+ * Returns 20 bytes of key material (SHA-1 compatible length).
54
+ *
55
+ * Port of `derive_mainline_key()` from arid_derivation.rs lines 39-45.
56
+ *
57
+ * @param arid - The ARID to derive from
58
+ * @returns 20 bytes of key material
59
+ * @category ARID Derivation
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const key = deriveMainlineKey(arid);
64
+ * // => Uint8Array(20) [...]
65
+ * ```
66
+ */
67
+ declare function deriveMainlineKey(arid: ARID): Uint8Array;
68
+ /**
69
+ * Obfuscate or deobfuscate data using ChaCha20 with an ARID-derived key.
70
+ *
71
+ * This function uses ChaCha20 as a stream cipher to XOR the data with a
72
+ * keystream derived from the ARID. Since XOR is symmetric, the same function
73
+ * is used for both obfuscation and deobfuscation.
74
+ *
75
+ * The result appears as uniform random data to anyone who doesn't have the
76
+ * ARID, hiding both the structure and content of the reference envelope.
77
+ *
78
+ * Port of `obfuscate_with_arid()` from arid_derivation.rs lines 47-91.
79
+ *
80
+ * @param arid - The ARID used to derive the obfuscation key
81
+ * @param data - The data to obfuscate or deobfuscate
82
+ * @returns The obfuscated (or deobfuscated) data
83
+ * @category ARID Derivation
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const obfuscated = obfuscateWithArid(arid, plaintext);
88
+ * const deobfuscated = obfuscateWithArid(arid, obfuscated);
89
+ * // deobfuscated === plaintext
90
+ * ```
91
+ */
92
+ declare function obfuscateWithArid(arid: ARID, data: Uint8Array): Uint8Array;
93
+ //#endregion
94
+ //#region src/logging.d.ts
95
+ /**
96
+ * Logging utilities for verbose output with timestamps.
97
+ *
98
+ * Port of logging.rs from hubert-rust.
99
+ *
100
+ * @module
101
+ */
102
+ /**
103
+ * Format a timestamp in ISO-8601 Zulu format with fractional seconds.
104
+ *
105
+ * Port of `timestamp()` from logging.rs lines 6-71.
106
+ *
107
+ * @returns Timestamp string in format "YYYY-MM-DDTHH:MM:SS.mmmZ"
108
+ * @category Logging
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * timestamp() // => "2024-01-15T14:30:45.123Z"
113
+ * ```
114
+ */
115
+ declare function timestamp(): string;
116
+ /**
117
+ * Print a verbose message with timestamp prefix.
118
+ *
119
+ * Port of `verbose_println()` from logging.rs lines 74-78.
120
+ *
121
+ * @param message - The message to print
122
+ * @category Logging
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * verbosePrintln("Starting operation...");
127
+ * // Output: [2024-01-15T14:30:45.123Z] Starting operation...
128
+ * ```
129
+ */
130
+ declare function verbosePrintln(message: string): void;
131
+ /**
132
+ * Print a polling dot on the same line (no newline).
133
+ *
134
+ * Port of `verbose_print_dot()` from logging.rs lines 81-84.
135
+ *
136
+ * @category Logging
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * verbosePrintDot(); // Prints "." without newline
141
+ * ```
142
+ */
143
+ declare function verbosePrintDot(): void;
144
+ /**
145
+ * Print a newline after dots.
146
+ *
147
+ * Port of `verbose_newline()` from logging.rs lines 87-89.
148
+ *
149
+ * @category Logging
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * verbosePrintDot();
154
+ * verbosePrintDot();
155
+ * verboseNewline(); // Completes the line of dots
156
+ * ```
157
+ */
158
+ declare function verboseNewline(): void;
159
+ //#endregion
160
+ export { AlreadyExistsError, ContentNotFoundError, DecodeIdError, DhtError, EnvelopeTooLargeError, HubertError, HybridError, HybridKv, InvalidAridError, InvalidReferenceAridError, IoError, IpfsDaemonError, IpfsError, IpfsKv, IpfsTimeoutError, type KvStore, MainlineDhtKv, MainlineError, MainlineIoError, MemoryKv, NoIdAssertionError, NotFoundError, NotReferenceEnvelopeError, PutMutableError, PutQueryError, Server, type ServerConfig, ServerError, ServerGeneralError, type ServerKv, ServerKvClient, ServerNetworkError, ServerParseError, SqliteError, SqliteKv, UnexpectedIpnsPathFormatError, ValueTooLargeError, addBytes, catBytes, createMemoryKv, createReferenceEnvelope, createSqliteKv, defaultServerConfig, deriveIpfsKeyName, deriveKey, deriveMainlineKey, extractReferenceArid, isReferenceEnvelope, obfuscateWithArid, pinCid, timestamp, verboseNewline, verbosePrintDot, verbosePrintln };
161
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/arid-derivation.ts","../src/logging.ts"],"mappings":";;;;;;;;AAkCA;;;;;;;;;;;;;;;;AA0CA;;;;;AAsBA;AAhEA,iBAAgB,SAAA,CAAU,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,IAAA,EAAM,SAAA,WAAoB,UAAA;;;;;;;;AA4F5E;;;;;;;;;;iBAlDgB,iBAAA,CAAkB,IAAA,EAAM,IAAA;;;;;;;;ACvDxC;;;;;AA4BA;;;;;iBDiDgB,iBAAA,CAAkB,IAAA,EAAM,IAAA,GAAO,UAAA;;;;;ACb/C;;;;;;;;;;;;;;;;;;;;iBDyCgB,iBAAA,CAAkB,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,UAAA,GAAa,UAAA;;;;;;;;;;;AA5FjE;;;;;;;;;;;;iBCbgB,SAAA,CAAA;;;;ADuDhB;;;;;AAsBA;;;;;;iBCjDgB,cAAA,CAAe,OAAA;;;AD6E/B;;;;;;;;;;iBC3DgB,eAAA,CAAA;;;;;;;;AA9ChB;;;;;AA4BA;;iBAoCgB,cAAA,CAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,10 @@
1
+ import { a as AlreadyExistsError, c as IoError, i as verbosePrintln, l as NotFoundError, n as verboseNewline, o as HubertError, r as verbosePrintDot, s as InvalidAridError, t as timestamp } from "./logging-hmzNzifq.mjs";
2
+ import { i as obfuscateWithArid, n as deriveKey, r as deriveMainlineKey, t as deriveIpfsKeyName } from "./arid-derivation-CbqACjdg.mjs";
3
+ import { a as createSqliteKv, c as ServerError, d as ServerParseError, f as SqliteError, i as createMemoryKv, l as ServerGeneralError, n as Server, o as SqliteKv, r as defaultServerConfig, s as MemoryKv, t as ServerKvClient, u as ServerNetworkError } from "./server-DVyk9gqU.mjs";
4
+ import { a as EnvelopeTooLargeError, c as IpfsTimeoutError, i as pinCid, l as UnexpectedIpnsPathFormatError, n as addBytes, o as IpfsDaemonError, r as catBytes, s as IpfsError, t as IpfsKv } from "./kv-DJiKvypY.mjs";
5
+ import "./ipfs-BRMMCBjv.mjs";
6
+ import { a as MainlineIoError, c as ValueTooLargeError, i as MainlineError, n as DecodeIdError, o as PutMutableError, r as DhtError, s as PutQueryError, t as MainlineDhtKv } from "./kv-C-emxv0w.mjs";
7
+ import "./mainline-cFIuXbo-.mjs";
8
+ import { a as ContentNotFoundError, c as NoIdAssertionError, i as isReferenceEnvelope, l as NotReferenceEnvelopeError, n as createReferenceEnvelope, o as HybridError, r as extractReferenceArid, s as InvalidReferenceAridError, t as HybridKv } from "./hybrid-BZhumygj.mjs";
9
+
10
+ export { AlreadyExistsError, ContentNotFoundError, DecodeIdError, DhtError, EnvelopeTooLargeError, HubertError, HybridError, HybridKv, InvalidAridError, InvalidReferenceAridError, IoError, IpfsDaemonError, IpfsError, IpfsKv, IpfsTimeoutError, MainlineDhtKv, MainlineError, MainlineIoError, MemoryKv, NoIdAssertionError, NotFoundError, NotReferenceEnvelopeError, PutMutableError, PutQueryError, Server, ServerError, ServerGeneralError, ServerKvClient, ServerNetworkError, ServerParseError, SqliteError, SqliteKv, UnexpectedIpnsPathFormatError, ValueTooLargeError, addBytes, catBytes, createMemoryKv, createReferenceEnvelope, createSqliteKv, defaultServerConfig, deriveIpfsKeyName, deriveKey, deriveMainlineKey, extractReferenceArid, isReferenceEnvelope, obfuscateWithArid, pinCid, timestamp, verboseNewline, verbosePrintDot, verbosePrintln };
@@ -0,0 +1,13 @@
1
+ require('../arid-derivation-1CJuU-kZ.cjs');
2
+ const require_kv = require('../kv-yjvQa_LH.cjs');
3
+ require('../ipfs-CetOVQcO.cjs');
4
+
5
+ exports.EnvelopeTooLargeError = require_kv.EnvelopeTooLargeError;
6
+ exports.IpfsDaemonError = require_kv.IpfsDaemonError;
7
+ exports.IpfsError = require_kv.IpfsError;
8
+ exports.IpfsKv = require_kv.IpfsKv;
9
+ exports.IpfsTimeoutError = require_kv.IpfsTimeoutError;
10
+ exports.UnexpectedIpnsPathFormatError = require_kv.UnexpectedIpnsPathFormatError;
11
+ exports.addBytes = require_kv.addBytes;
12
+ exports.catBytes = require_kv.catBytes;
13
+ exports.pinCid = require_kv.pinCid;
@@ -0,0 +1,3 @@
1
+ import "../kv-store-ww-AUyLd.cjs";
2
+ import { a as EnvelopeTooLargeError, c as IpfsTimeoutError, i as pinCid, l as UnexpectedIpnsPathFormatError, n as addBytes, o as IpfsDaemonError, r as catBytes, s as IpfsError, t as IpfsKv } from "../index-DEr4SR1J.cjs";
3
+ export { EnvelopeTooLargeError, IpfsDaemonError, IpfsError, IpfsKv, IpfsTimeoutError, UnexpectedIpnsPathFormatError, addBytes, catBytes, pinCid };
@@ -0,0 +1,3 @@
1
+ import "../kv-store-DmngWWuw.mjs";
2
+ import { a as EnvelopeTooLargeError, c as IpfsTimeoutError, i as pinCid, l as UnexpectedIpnsPathFormatError, n as addBytes, o as IpfsDaemonError, r as catBytes, s as IpfsError, t as IpfsKv } from "../index-CUnDouMb.mjs";
3
+ export { EnvelopeTooLargeError, IpfsDaemonError, IpfsError, IpfsKv, IpfsTimeoutError, UnexpectedIpnsPathFormatError, addBytes, catBytes, pinCid };
@@ -0,0 +1,5 @@
1
+ import "../arid-derivation-CbqACjdg.mjs";
2
+ import { a as EnvelopeTooLargeError, c as IpfsTimeoutError, i as pinCid, l as UnexpectedIpnsPathFormatError, n as addBytes, o as IpfsDaemonError, r as catBytes, s as IpfsError, t as IpfsKv } from "../kv-DJiKvypY.mjs";
3
+ import "../ipfs-BRMMCBjv.mjs";
4
+
5
+ export { EnvelopeTooLargeError, IpfsDaemonError, IpfsError, IpfsKv, IpfsTimeoutError, UnexpectedIpnsPathFormatError, addBytes, catBytes, pinCid };
@@ -0,0 +1 @@
1
+ export { };
File without changes