@dxos/vendor-hypercore 0.8.4-main.72ec0f3 → 0.8.4-main.937b3ca
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/dist/lib/browser/chunk-WLEV7IVZ.mjs +6336 -0
- package/dist/lib/browser/chunk-WLEV7IVZ.mjs.map +7 -0
- package/dist/lib/browser/hypercore-crypto.mjs +1 -1
- package/dist/lib/browser/hypercore.mjs +1022 -1128
- package/dist/lib/browser/hypercore.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/chunk-H7LBQLKP.mjs +5779 -0
- package/dist/lib/node-esm/chunk-H7LBQLKP.mjs.map +7 -0
- package/dist/lib/node-esm/hypercore-crypto.mjs +1 -1
- package/dist/lib/node-esm/hypercore.mjs +1050 -203
- package/dist/lib/node-esm/hypercore.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/package.json +7 -2
- package/dist/lib/browser/chunk-XAJ5RWMK.mjs +0 -223
- package/dist/lib/browser/chunk-XAJ5RWMK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IEADO42Y.mjs +0 -222
- package/dist/lib/node-esm/chunk-IEADO42Y.mjs.map +0 -7
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import "@dxos/node-std/globals";
|
|
2
|
-
import import$sodium_universal from 'sodium-universal';
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
-
}) : x)(function(x) {
|
|
12
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
-
});
|
|
15
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
16
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
-
};
|
|
18
|
-
var __export = (target, all) => {
|
|
19
|
-
for (var name in all)
|
|
20
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
-
};
|
|
22
|
-
var __copyProps = (to, from, except, desc) => {
|
|
23
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
-
for (let key of __getOwnPropNames(from))
|
|
25
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
-
}
|
|
28
|
-
return to;
|
|
29
|
-
};
|
|
30
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
31
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
37
|
-
mod
|
|
38
|
-
));
|
|
39
|
-
|
|
40
|
-
// ../../node_modules/.pnpm/uint64be@3.0.0/node_modules/uint64be/index.js
|
|
41
|
-
var require_uint64be = __commonJS({
|
|
42
|
-
"../../node_modules/.pnpm/uint64be@3.0.0/node_modules/uint64be/index.js"(exports) {
|
|
43
|
-
var UINT_32_MAX = Math.pow(2, 32);
|
|
44
|
-
exports.encodingLength = function() {
|
|
45
|
-
return 8;
|
|
46
|
-
};
|
|
47
|
-
exports.encode = function(num, buf, offset) {
|
|
48
|
-
if (!buf) buf = Buffer.allocUnsafe(8);
|
|
49
|
-
if (!offset) offset = 0;
|
|
50
|
-
const top = Math.floor(num / UINT_32_MAX);
|
|
51
|
-
const rem = num - top * UINT_32_MAX;
|
|
52
|
-
buf.writeUInt32BE(top, offset);
|
|
53
|
-
buf.writeUInt32BE(rem, offset + 4);
|
|
54
|
-
return buf;
|
|
55
|
-
};
|
|
56
|
-
exports.decode = function(buf, offset) {
|
|
57
|
-
if (!offset) offset = 0;
|
|
58
|
-
const top = buf.readUInt32BE(offset);
|
|
59
|
-
const rem = buf.readUInt32BE(offset + 4);
|
|
60
|
-
return top * UINT_32_MAX + rem;
|
|
61
|
-
};
|
|
62
|
-
exports.encode.bytes = 8;
|
|
63
|
-
exports.decode.bytes = 8;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// ../../node_modules/.pnpm/hypercore-crypto@2.3.2/node_modules/hypercore-crypto/index.js
|
|
68
|
-
var require_hypercore_crypto = __commonJS({
|
|
69
|
-
"../../node_modules/.pnpm/hypercore-crypto@2.3.2/node_modules/hypercore-crypto/index.js"(exports) {
|
|
70
|
-
var sodium = import$sodium_universal;
|
|
71
|
-
var uint64be = require_uint64be();
|
|
72
|
-
var LEAF_TYPE = Buffer.from([0]);
|
|
73
|
-
var PARENT_TYPE = Buffer.from([1]);
|
|
74
|
-
var ROOT_TYPE = Buffer.from([2]);
|
|
75
|
-
var CAP_TYPE = Buffer.from([3]);
|
|
76
|
-
var HYPERCORE = Buffer.from("hypercore");
|
|
77
|
-
var HYPERCORE_CAP = Buffer.from("hypercore capability");
|
|
78
|
-
exports.writerCapability = function(key, secretKey, split) {
|
|
79
|
-
if (!split) return null;
|
|
80
|
-
const out = Buffer.allocUnsafe(32);
|
|
81
|
-
sodium.crypto_generichash_batch(out, [
|
|
82
|
-
CAP_TYPE,
|
|
83
|
-
HYPERCORE_CAP,
|
|
84
|
-
split.tx.slice(0, 32),
|
|
85
|
-
key
|
|
86
|
-
], split.rx.slice(0, 32));
|
|
87
|
-
return exports.sign(out, secretKey);
|
|
88
|
-
};
|
|
89
|
-
exports.verifyRemoteWriterCapability = function(key, cap, split) {
|
|
90
|
-
if (!split) return null;
|
|
91
|
-
const out = Buffer.allocUnsafe(32);
|
|
92
|
-
sodium.crypto_generichash_batch(out, [
|
|
93
|
-
CAP_TYPE,
|
|
94
|
-
HYPERCORE_CAP,
|
|
95
|
-
split.rx.slice(0, 32),
|
|
96
|
-
key
|
|
97
|
-
], split.tx.slice(0, 32));
|
|
98
|
-
return exports.verify(out, cap, key);
|
|
99
|
-
};
|
|
100
|
-
exports.capability = function(key, split) {
|
|
101
|
-
if (!split) return null;
|
|
102
|
-
const out = Buffer.allocUnsafe(32);
|
|
103
|
-
sodium.crypto_generichash_batch(out, [
|
|
104
|
-
HYPERCORE_CAP,
|
|
105
|
-
split.tx.slice(0, 32),
|
|
106
|
-
key
|
|
107
|
-
], split.rx.slice(0, 32));
|
|
108
|
-
return out;
|
|
109
|
-
};
|
|
110
|
-
exports.remoteCapability = function(key, split) {
|
|
111
|
-
if (!split) return null;
|
|
112
|
-
const out = Buffer.allocUnsafe(32);
|
|
113
|
-
sodium.crypto_generichash_batch(out, [
|
|
114
|
-
HYPERCORE_CAP,
|
|
115
|
-
split.rx.slice(0, 32),
|
|
116
|
-
key
|
|
117
|
-
], split.tx.slice(0, 32));
|
|
118
|
-
return out;
|
|
119
|
-
};
|
|
120
|
-
exports.keyPair = function(seed) {
|
|
121
|
-
const publicKey = Buffer.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES);
|
|
122
|
-
const secretKey = Buffer.allocUnsafe(sodium.crypto_sign_SECRETKEYBYTES);
|
|
123
|
-
if (seed) sodium.crypto_sign_seed_keypair(publicKey, secretKey, seed);
|
|
124
|
-
else sodium.crypto_sign_keypair(publicKey, secretKey);
|
|
125
|
-
return {
|
|
126
|
-
publicKey,
|
|
127
|
-
secretKey
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
exports.validateKeyPair = function(keyPair) {
|
|
131
|
-
const pk = Buffer.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES);
|
|
132
|
-
sodium.crypto_sign_ed25519_sk_to_pk(pk, keyPair.secretKey);
|
|
133
|
-
return pk.equals(keyPair.publicKey);
|
|
134
|
-
};
|
|
135
|
-
exports.sign = function(message, secretKey) {
|
|
136
|
-
const signature = Buffer.allocUnsafe(sodium.crypto_sign_BYTES);
|
|
137
|
-
sodium.crypto_sign_detached(signature, message, secretKey);
|
|
138
|
-
return signature;
|
|
139
|
-
};
|
|
140
|
-
exports.verify = function(message, signature, publicKey) {
|
|
141
|
-
return sodium.crypto_sign_verify_detached(signature, message, publicKey);
|
|
142
|
-
};
|
|
143
|
-
exports.data = function(data) {
|
|
144
|
-
const out = Buffer.allocUnsafe(32);
|
|
145
|
-
sodium.crypto_generichash_batch(out, [
|
|
146
|
-
LEAF_TYPE,
|
|
147
|
-
encodeUInt64(data.length),
|
|
148
|
-
data
|
|
149
|
-
]);
|
|
150
|
-
return out;
|
|
151
|
-
};
|
|
152
|
-
exports.leaf = function(leaf) {
|
|
153
|
-
return exports.data(leaf.data);
|
|
154
|
-
};
|
|
155
|
-
exports.parent = function(a, b) {
|
|
156
|
-
if (a.index > b.index) {
|
|
157
|
-
const tmp = a;
|
|
158
|
-
a = b;
|
|
159
|
-
b = tmp;
|
|
160
|
-
}
|
|
161
|
-
const out = Buffer.allocUnsafe(32);
|
|
162
|
-
sodium.crypto_generichash_batch(out, [
|
|
163
|
-
PARENT_TYPE,
|
|
164
|
-
encodeUInt64(a.size + b.size),
|
|
165
|
-
a.hash,
|
|
166
|
-
b.hash
|
|
167
|
-
]);
|
|
168
|
-
return out;
|
|
169
|
-
};
|
|
170
|
-
exports.tree = function(roots, out) {
|
|
171
|
-
const buffers = new Array(3 * roots.length + 1);
|
|
172
|
-
var j = 0;
|
|
173
|
-
buffers[j++] = ROOT_TYPE;
|
|
174
|
-
for (var i = 0; i < roots.length; i++) {
|
|
175
|
-
const r = roots[i];
|
|
176
|
-
buffers[j++] = r.hash;
|
|
177
|
-
buffers[j++] = encodeUInt64(r.index);
|
|
178
|
-
buffers[j++] = encodeUInt64(r.size);
|
|
179
|
-
}
|
|
180
|
-
if (!out) out = Buffer.allocUnsafe(32);
|
|
181
|
-
sodium.crypto_generichash_batch(out, buffers);
|
|
182
|
-
return out;
|
|
183
|
-
};
|
|
184
|
-
exports.signable = function(roots, length) {
|
|
185
|
-
const out = Buffer.allocUnsafe(40);
|
|
186
|
-
if (Buffer.isBuffer(roots)) roots.copy(out);
|
|
187
|
-
else exports.tree(roots, out.slice(0, 32));
|
|
188
|
-
uint64be.encode(length, out.slice(32));
|
|
189
|
-
return out;
|
|
190
|
-
};
|
|
191
|
-
exports.randomBytes = function(n) {
|
|
192
|
-
const buf = Buffer.allocUnsafe(n);
|
|
193
|
-
sodium.randombytes_buf(buf);
|
|
194
|
-
return buf;
|
|
195
|
-
};
|
|
196
|
-
exports.discoveryKey = function(publicKey) {
|
|
197
|
-
const digest = Buffer.allocUnsafe(32);
|
|
198
|
-
sodium.crypto_generichash(digest, HYPERCORE, publicKey);
|
|
199
|
-
return digest;
|
|
200
|
-
};
|
|
201
|
-
if (sodium.sodium_free) {
|
|
202
|
-
exports.free = function(secureBuf) {
|
|
203
|
-
if (secureBuf.secure) sodium.sodium_free(secureBuf);
|
|
204
|
-
};
|
|
205
|
-
} else {
|
|
206
|
-
exports.free = function() {
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
function encodeUInt64(n) {
|
|
210
|
-
return uint64be.encode(n, Buffer.allocUnsafe(8));
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
export {
|
|
216
|
-
__require,
|
|
217
|
-
__commonJS,
|
|
218
|
-
__export,
|
|
219
|
-
__reExport,
|
|
220
|
-
__toESM,
|
|
221
|
-
require_hypercore_crypto
|
|
222
|
-
};
|
|
223
|
-
//# sourceMappingURL=chunk-XAJ5RWMK.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../node_modules/.pnpm/uint64be@3.0.0/node_modules/uint64be/index.js", "../../../../../node_modules/.pnpm/hypercore-crypto@2.3.2/node_modules/hypercore-crypto/index.js"],
|
|
4
|
-
"sourcesContent": ["const UINT_32_MAX = Math.pow(2, 32)\n\nexports.encodingLength = function () {\n return 8\n}\n\nexports.encode = function (num, buf, offset) {\n if (!buf) buf = Buffer.allocUnsafe(8)\n if (!offset) offset = 0\n\n const top = Math.floor(num / UINT_32_MAX)\n const rem = num - top * UINT_32_MAX\n\n buf.writeUInt32BE(top, offset)\n buf.writeUInt32BE(rem, offset + 4)\n return buf\n}\n\nexports.decode = function (buf, offset) {\n if (!offset) offset = 0\n\n const top = buf.readUInt32BE(offset)\n const rem = buf.readUInt32BE(offset + 4)\n\n return top * UINT_32_MAX + rem\n}\n\nexports.encode.bytes = 8\nexports.decode.bytes = 8\n", "const sodium = require('sodium-universal')\nconst uint64be = require('uint64be')\n\n// https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_attack\nconst LEAF_TYPE = Buffer.from([0])\nconst PARENT_TYPE = Buffer.from([1])\nconst ROOT_TYPE = Buffer.from([2])\nconst CAP_TYPE = Buffer.from([3])\n\nconst HYPERCORE = Buffer.from('hypercore')\nconst HYPERCORE_CAP = Buffer.from('hypercore capability')\n\nexports.writerCapability = function (key, secretKey, split) {\n if (!split) return null\n\n const out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, [\n CAP_TYPE,\n HYPERCORE_CAP,\n split.tx.slice(0, 32),\n key\n ], split.rx.slice(0, 32))\n\n return exports.sign(out, secretKey)\n}\n\nexports.verifyRemoteWriterCapability = function (key, cap, split) {\n if (!split) return null\n\n const out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, [\n CAP_TYPE,\n HYPERCORE_CAP,\n split.rx.slice(0, 32),\n key\n ], split.tx.slice(0, 32))\n\n return exports.verify(out, cap, key)\n}\n\n// TODO: add in the CAP_TYPE in a future version\nexports.capability = function (key, split) {\n if (!split) return null\n\n const out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, [\n HYPERCORE_CAP,\n split.tx.slice(0, 32),\n key\n ], split.rx.slice(0, 32))\n\n return out\n}\n\n// TODO: add in the CAP_TYPE in a future version\nexports.remoteCapability = function (key, split) {\n if (!split) return null\n\n const out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, [\n HYPERCORE_CAP,\n split.rx.slice(0, 32),\n key\n ], split.tx.slice(0, 32))\n\n return out\n}\n\nexports.keyPair = function (seed) {\n const publicKey = Buffer.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES)\n const secretKey = Buffer.allocUnsafe(sodium.crypto_sign_SECRETKEYBYTES)\n\n if (seed) sodium.crypto_sign_seed_keypair(publicKey, secretKey, seed)\n else sodium.crypto_sign_keypair(publicKey, secretKey)\n\n return {\n publicKey,\n secretKey\n }\n}\n\nexports.validateKeyPair = function (keyPair) {\n const pk = Buffer.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES)\n sodium.crypto_sign_ed25519_sk_to_pk(pk, keyPair.secretKey)\n return pk.equals(keyPair.publicKey)\n}\n\nexports.sign = function (message, secretKey) {\n const signature = Buffer.allocUnsafe(sodium.crypto_sign_BYTES)\n sodium.crypto_sign_detached(signature, message, secretKey)\n return signature\n}\n\nexports.verify = function (message, signature, publicKey) {\n return sodium.crypto_sign_verify_detached(signature, message, publicKey)\n}\n\nexports.data = function (data) {\n const out = Buffer.allocUnsafe(32)\n\n sodium.crypto_generichash_batch(out, [\n LEAF_TYPE,\n encodeUInt64(data.length),\n data\n ])\n\n return out\n}\n\nexports.leaf = function (leaf) {\n return exports.data(leaf.data)\n}\n\nexports.parent = function (a, b) {\n if (a.index > b.index) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const out = Buffer.allocUnsafe(32)\n\n sodium.crypto_generichash_batch(out, [\n PARENT_TYPE,\n encodeUInt64(a.size + b.size),\n a.hash,\n b.hash\n ])\n\n return out\n}\n\nexports.tree = function (roots, out) {\n const buffers = new Array(3 * roots.length + 1)\n var j = 0\n\n buffers[j++] = ROOT_TYPE\n\n for (var i = 0; i < roots.length; i++) {\n const r = roots[i]\n buffers[j++] = r.hash\n buffers[j++] = encodeUInt64(r.index)\n buffers[j++] = encodeUInt64(r.size)\n }\n\n if (!out) out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, buffers)\n return out\n}\n\nexports.signable = function (roots, length) {\n const out = Buffer.allocUnsafe(40)\n\n if (Buffer.isBuffer(roots)) roots.copy(out)\n else exports.tree(roots, out.slice(0, 32))\n\n uint64be.encode(length, out.slice(32))\n\n return out\n}\n\nexports.randomBytes = function (n) {\n const buf = Buffer.allocUnsafe(n)\n sodium.randombytes_buf(buf)\n return buf\n}\n\nexports.discoveryKey = function (publicKey) {\n const digest = Buffer.allocUnsafe(32)\n sodium.crypto_generichash(digest, HYPERCORE, publicKey)\n return digest\n}\n\nif (sodium.sodium_free) {\n exports.free = function (secureBuf) {\n if (secureBuf.secure) sodium.sodium_free(secureBuf)\n }\n} else {\n exports.free = function () {}\n}\n\nfunction encodeUInt64 (n) {\n return uint64be.encode(n, Buffer.allocUnsafe(8))\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,QAAM,cAAc,KAAK,IAAI,GAAG,EAAE;AAElC,YAAQ,iBAAiB,WAAY;AACnC,aAAO;AAAA,IACT;AAEA,YAAQ,SAAS,SAAU,KAAK,KAAK,QAAQ;AAC3C,UAAI,CAAC,IAAK,OAAM,OAAO,YAAY,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AAO;AAAA,IACT;AAEA,YAAQ,WAAW,SAAU,OAAO,QAAQ;AAC1C,YAAM,MAAM,OAAO,YAAY,EAAE;AAEjC,UAAI,OAAO,SAAS,KAAK,EAAG,OAAM,KAAK,GAAG;AAAA,UACrC,SAAQ,KAAK,OAAO,IAAI,MAAM,GAAG,EAAE,CAAC;AAEzC,eAAS,OAAO,QAAQ,IAAI,MAAM,EAAE,CAAC;AAErC,aAAO;AAAA,IACT;AAEA,YAAQ,cAAc,SAAU,GAAG;AACjC,YAAM,MAAM,OAAO,YAAY,CAAC;AAChC,aAAO,gBAAgB,GAAG;AAC1B,aAAO;AAAA,IACT;AAEA,YAAQ,eAAe,SAAU,WAAW;AAC1C,YAAM,SAAS,OAAO,YAAY,EAAE;AACpC,aAAO,mBAAmB,QAAQ,WAAW,SAAS;AACtD,aAAO;AAAA,IACT;AAEA,QAAI,OAAO,aAAa;AACtB,cAAQ,OAAO,SAAU,WAAW;AAClC,YAAI,UAAU,OAAQ,QAAO,YAAY,SAAS;AAAA,MACpD;AAAA,IACF,OAAO;AACL,cAAQ,OAAO,WAAY;AAAA,MAAC;AAAA,IAC9B;AAEA,aAAS,aAAc,GAAG;AACxB,aAAO,SAAS,OAAO,GAAG,OAAO,YAAY,CAAC,CAAC;AAAA,IACjD;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
-
}) : x)(function(x) {
|
|
11
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
-
});
|
|
14
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
-
};
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(from))
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
30
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
-
mod
|
|
37
|
-
));
|
|
38
|
-
|
|
39
|
-
// ../../node_modules/.pnpm/uint64be@3.0.0/node_modules/uint64be/index.js
|
|
40
|
-
var require_uint64be = __commonJS({
|
|
41
|
-
"../../node_modules/.pnpm/uint64be@3.0.0/node_modules/uint64be/index.js"(exports) {
|
|
42
|
-
var UINT_32_MAX = Math.pow(2, 32);
|
|
43
|
-
exports.encodingLength = function() {
|
|
44
|
-
return 8;
|
|
45
|
-
};
|
|
46
|
-
exports.encode = function(num, buf, offset) {
|
|
47
|
-
if (!buf) buf = Buffer.allocUnsafe(8);
|
|
48
|
-
if (!offset) offset = 0;
|
|
49
|
-
const top = Math.floor(num / UINT_32_MAX);
|
|
50
|
-
const rem = num - top * UINT_32_MAX;
|
|
51
|
-
buf.writeUInt32BE(top, offset);
|
|
52
|
-
buf.writeUInt32BE(rem, offset + 4);
|
|
53
|
-
return buf;
|
|
54
|
-
};
|
|
55
|
-
exports.decode = function(buf, offset) {
|
|
56
|
-
if (!offset) offset = 0;
|
|
57
|
-
const top = buf.readUInt32BE(offset);
|
|
58
|
-
const rem = buf.readUInt32BE(offset + 4);
|
|
59
|
-
return top * UINT_32_MAX + rem;
|
|
60
|
-
};
|
|
61
|
-
exports.encode.bytes = 8;
|
|
62
|
-
exports.decode.bytes = 8;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
// ../../node_modules/.pnpm/hypercore-crypto@2.3.2/node_modules/hypercore-crypto/index.js
|
|
67
|
-
var require_hypercore_crypto = __commonJS({
|
|
68
|
-
"../../node_modules/.pnpm/hypercore-crypto@2.3.2/node_modules/hypercore-crypto/index.js"(exports) {
|
|
69
|
-
var sodium = __require("sodium-universal");
|
|
70
|
-
var uint64be = require_uint64be();
|
|
71
|
-
var LEAF_TYPE = Buffer.from([0]);
|
|
72
|
-
var PARENT_TYPE = Buffer.from([1]);
|
|
73
|
-
var ROOT_TYPE = Buffer.from([2]);
|
|
74
|
-
var CAP_TYPE = Buffer.from([3]);
|
|
75
|
-
var HYPERCORE = Buffer.from("hypercore");
|
|
76
|
-
var HYPERCORE_CAP = Buffer.from("hypercore capability");
|
|
77
|
-
exports.writerCapability = function(key, secretKey, split) {
|
|
78
|
-
if (!split) return null;
|
|
79
|
-
const out = Buffer.allocUnsafe(32);
|
|
80
|
-
sodium.crypto_generichash_batch(out, [
|
|
81
|
-
CAP_TYPE,
|
|
82
|
-
HYPERCORE_CAP,
|
|
83
|
-
split.tx.slice(0, 32),
|
|
84
|
-
key
|
|
85
|
-
], split.rx.slice(0, 32));
|
|
86
|
-
return exports.sign(out, secretKey);
|
|
87
|
-
};
|
|
88
|
-
exports.verifyRemoteWriterCapability = function(key, cap, split) {
|
|
89
|
-
if (!split) return null;
|
|
90
|
-
const out = Buffer.allocUnsafe(32);
|
|
91
|
-
sodium.crypto_generichash_batch(out, [
|
|
92
|
-
CAP_TYPE,
|
|
93
|
-
HYPERCORE_CAP,
|
|
94
|
-
split.rx.slice(0, 32),
|
|
95
|
-
key
|
|
96
|
-
], split.tx.slice(0, 32));
|
|
97
|
-
return exports.verify(out, cap, key);
|
|
98
|
-
};
|
|
99
|
-
exports.capability = function(key, split) {
|
|
100
|
-
if (!split) return null;
|
|
101
|
-
const out = Buffer.allocUnsafe(32);
|
|
102
|
-
sodium.crypto_generichash_batch(out, [
|
|
103
|
-
HYPERCORE_CAP,
|
|
104
|
-
split.tx.slice(0, 32),
|
|
105
|
-
key
|
|
106
|
-
], split.rx.slice(0, 32));
|
|
107
|
-
return out;
|
|
108
|
-
};
|
|
109
|
-
exports.remoteCapability = function(key, split) {
|
|
110
|
-
if (!split) return null;
|
|
111
|
-
const out = Buffer.allocUnsafe(32);
|
|
112
|
-
sodium.crypto_generichash_batch(out, [
|
|
113
|
-
HYPERCORE_CAP,
|
|
114
|
-
split.rx.slice(0, 32),
|
|
115
|
-
key
|
|
116
|
-
], split.tx.slice(0, 32));
|
|
117
|
-
return out;
|
|
118
|
-
};
|
|
119
|
-
exports.keyPair = function(seed) {
|
|
120
|
-
const publicKey = Buffer.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES);
|
|
121
|
-
const secretKey = Buffer.allocUnsafe(sodium.crypto_sign_SECRETKEYBYTES);
|
|
122
|
-
if (seed) sodium.crypto_sign_seed_keypair(publicKey, secretKey, seed);
|
|
123
|
-
else sodium.crypto_sign_keypair(publicKey, secretKey);
|
|
124
|
-
return {
|
|
125
|
-
publicKey,
|
|
126
|
-
secretKey
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
exports.validateKeyPair = function(keyPair) {
|
|
130
|
-
const pk = Buffer.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES);
|
|
131
|
-
sodium.crypto_sign_ed25519_sk_to_pk(pk, keyPair.secretKey);
|
|
132
|
-
return pk.equals(keyPair.publicKey);
|
|
133
|
-
};
|
|
134
|
-
exports.sign = function(message, secretKey) {
|
|
135
|
-
const signature = Buffer.allocUnsafe(sodium.crypto_sign_BYTES);
|
|
136
|
-
sodium.crypto_sign_detached(signature, message, secretKey);
|
|
137
|
-
return signature;
|
|
138
|
-
};
|
|
139
|
-
exports.verify = function(message, signature, publicKey) {
|
|
140
|
-
return sodium.crypto_sign_verify_detached(signature, message, publicKey);
|
|
141
|
-
};
|
|
142
|
-
exports.data = function(data) {
|
|
143
|
-
const out = Buffer.allocUnsafe(32);
|
|
144
|
-
sodium.crypto_generichash_batch(out, [
|
|
145
|
-
LEAF_TYPE,
|
|
146
|
-
encodeUInt64(data.length),
|
|
147
|
-
data
|
|
148
|
-
]);
|
|
149
|
-
return out;
|
|
150
|
-
};
|
|
151
|
-
exports.leaf = function(leaf) {
|
|
152
|
-
return exports.data(leaf.data);
|
|
153
|
-
};
|
|
154
|
-
exports.parent = function(a, b) {
|
|
155
|
-
if (a.index > b.index) {
|
|
156
|
-
const tmp = a;
|
|
157
|
-
a = b;
|
|
158
|
-
b = tmp;
|
|
159
|
-
}
|
|
160
|
-
const out = Buffer.allocUnsafe(32);
|
|
161
|
-
sodium.crypto_generichash_batch(out, [
|
|
162
|
-
PARENT_TYPE,
|
|
163
|
-
encodeUInt64(a.size + b.size),
|
|
164
|
-
a.hash,
|
|
165
|
-
b.hash
|
|
166
|
-
]);
|
|
167
|
-
return out;
|
|
168
|
-
};
|
|
169
|
-
exports.tree = function(roots, out) {
|
|
170
|
-
const buffers = new Array(3 * roots.length + 1);
|
|
171
|
-
var j = 0;
|
|
172
|
-
buffers[j++] = ROOT_TYPE;
|
|
173
|
-
for (var i = 0; i < roots.length; i++) {
|
|
174
|
-
const r = roots[i];
|
|
175
|
-
buffers[j++] = r.hash;
|
|
176
|
-
buffers[j++] = encodeUInt64(r.index);
|
|
177
|
-
buffers[j++] = encodeUInt64(r.size);
|
|
178
|
-
}
|
|
179
|
-
if (!out) out = Buffer.allocUnsafe(32);
|
|
180
|
-
sodium.crypto_generichash_batch(out, buffers);
|
|
181
|
-
return out;
|
|
182
|
-
};
|
|
183
|
-
exports.signable = function(roots, length) {
|
|
184
|
-
const out = Buffer.allocUnsafe(40);
|
|
185
|
-
if (Buffer.isBuffer(roots)) roots.copy(out);
|
|
186
|
-
else exports.tree(roots, out.slice(0, 32));
|
|
187
|
-
uint64be.encode(length, out.slice(32));
|
|
188
|
-
return out;
|
|
189
|
-
};
|
|
190
|
-
exports.randomBytes = function(n) {
|
|
191
|
-
const buf = Buffer.allocUnsafe(n);
|
|
192
|
-
sodium.randombytes_buf(buf);
|
|
193
|
-
return buf;
|
|
194
|
-
};
|
|
195
|
-
exports.discoveryKey = function(publicKey) {
|
|
196
|
-
const digest = Buffer.allocUnsafe(32);
|
|
197
|
-
sodium.crypto_generichash(digest, HYPERCORE, publicKey);
|
|
198
|
-
return digest;
|
|
199
|
-
};
|
|
200
|
-
if (sodium.sodium_free) {
|
|
201
|
-
exports.free = function(secureBuf) {
|
|
202
|
-
if (secureBuf.secure) sodium.sodium_free(secureBuf);
|
|
203
|
-
};
|
|
204
|
-
} else {
|
|
205
|
-
exports.free = function() {
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function encodeUInt64(n) {
|
|
209
|
-
return uint64be.encode(n, Buffer.allocUnsafe(8));
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
export {
|
|
215
|
-
__require,
|
|
216
|
-
__commonJS,
|
|
217
|
-
__export,
|
|
218
|
-
__reExport,
|
|
219
|
-
__toESM,
|
|
220
|
-
require_hypercore_crypto
|
|
221
|
-
};
|
|
222
|
-
//# sourceMappingURL=chunk-IEADO42Y.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../node_modules/.pnpm/uint64be@3.0.0/node_modules/uint64be/index.js", "../../../../../node_modules/.pnpm/hypercore-crypto@2.3.2/node_modules/hypercore-crypto/index.js"],
|
|
4
|
-
"sourcesContent": ["const UINT_32_MAX = Math.pow(2, 32)\n\nexports.encodingLength = function () {\n return 8\n}\n\nexports.encode = function (num, buf, offset) {\n if (!buf) buf = Buffer.allocUnsafe(8)\n if (!offset) offset = 0\n\n const top = Math.floor(num / UINT_32_MAX)\n const rem = num - top * UINT_32_MAX\n\n buf.writeUInt32BE(top, offset)\n buf.writeUInt32BE(rem, offset + 4)\n return buf\n}\n\nexports.decode = function (buf, offset) {\n if (!offset) offset = 0\n\n const top = buf.readUInt32BE(offset)\n const rem = buf.readUInt32BE(offset + 4)\n\n return top * UINT_32_MAX + rem\n}\n\nexports.encode.bytes = 8\nexports.decode.bytes = 8\n", "const sodium = require('sodium-universal')\nconst uint64be = require('uint64be')\n\n// https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_attack\nconst LEAF_TYPE = Buffer.from([0])\nconst PARENT_TYPE = Buffer.from([1])\nconst ROOT_TYPE = Buffer.from([2])\nconst CAP_TYPE = Buffer.from([3])\n\nconst HYPERCORE = Buffer.from('hypercore')\nconst HYPERCORE_CAP = Buffer.from('hypercore capability')\n\nexports.writerCapability = function (key, secretKey, split) {\n if (!split) return null\n\n const out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, [\n CAP_TYPE,\n HYPERCORE_CAP,\n split.tx.slice(0, 32),\n key\n ], split.rx.slice(0, 32))\n\n return exports.sign(out, secretKey)\n}\n\nexports.verifyRemoteWriterCapability = function (key, cap, split) {\n if (!split) return null\n\n const out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, [\n CAP_TYPE,\n HYPERCORE_CAP,\n split.rx.slice(0, 32),\n key\n ], split.tx.slice(0, 32))\n\n return exports.verify(out, cap, key)\n}\n\n// TODO: add in the CAP_TYPE in a future version\nexports.capability = function (key, split) {\n if (!split) return null\n\n const out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, [\n HYPERCORE_CAP,\n split.tx.slice(0, 32),\n key\n ], split.rx.slice(0, 32))\n\n return out\n}\n\n// TODO: add in the CAP_TYPE in a future version\nexports.remoteCapability = function (key, split) {\n if (!split) return null\n\n const out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, [\n HYPERCORE_CAP,\n split.rx.slice(0, 32),\n key\n ], split.tx.slice(0, 32))\n\n return out\n}\n\nexports.keyPair = function (seed) {\n const publicKey = Buffer.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES)\n const secretKey = Buffer.allocUnsafe(sodium.crypto_sign_SECRETKEYBYTES)\n\n if (seed) sodium.crypto_sign_seed_keypair(publicKey, secretKey, seed)\n else sodium.crypto_sign_keypair(publicKey, secretKey)\n\n return {\n publicKey,\n secretKey\n }\n}\n\nexports.validateKeyPair = function (keyPair) {\n const pk = Buffer.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES)\n sodium.crypto_sign_ed25519_sk_to_pk(pk, keyPair.secretKey)\n return pk.equals(keyPair.publicKey)\n}\n\nexports.sign = function (message, secretKey) {\n const signature = Buffer.allocUnsafe(sodium.crypto_sign_BYTES)\n sodium.crypto_sign_detached(signature, message, secretKey)\n return signature\n}\n\nexports.verify = function (message, signature, publicKey) {\n return sodium.crypto_sign_verify_detached(signature, message, publicKey)\n}\n\nexports.data = function (data) {\n const out = Buffer.allocUnsafe(32)\n\n sodium.crypto_generichash_batch(out, [\n LEAF_TYPE,\n encodeUInt64(data.length),\n data\n ])\n\n return out\n}\n\nexports.leaf = function (leaf) {\n return exports.data(leaf.data)\n}\n\nexports.parent = function (a, b) {\n if (a.index > b.index) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const out = Buffer.allocUnsafe(32)\n\n sodium.crypto_generichash_batch(out, [\n PARENT_TYPE,\n encodeUInt64(a.size + b.size),\n a.hash,\n b.hash\n ])\n\n return out\n}\n\nexports.tree = function (roots, out) {\n const buffers = new Array(3 * roots.length + 1)\n var j = 0\n\n buffers[j++] = ROOT_TYPE\n\n for (var i = 0; i < roots.length; i++) {\n const r = roots[i]\n buffers[j++] = r.hash\n buffers[j++] = encodeUInt64(r.index)\n buffers[j++] = encodeUInt64(r.size)\n }\n\n if (!out) out = Buffer.allocUnsafe(32)\n sodium.crypto_generichash_batch(out, buffers)\n return out\n}\n\nexports.signable = function (roots, length) {\n const out = Buffer.allocUnsafe(40)\n\n if (Buffer.isBuffer(roots)) roots.copy(out)\n else exports.tree(roots, out.slice(0, 32))\n\n uint64be.encode(length, out.slice(32))\n\n return out\n}\n\nexports.randomBytes = function (n) {\n const buf = Buffer.allocUnsafe(n)\n sodium.randombytes_buf(buf)\n return buf\n}\n\nexports.discoveryKey = function (publicKey) {\n const digest = Buffer.allocUnsafe(32)\n sodium.crypto_generichash(digest, HYPERCORE, publicKey)\n return digest\n}\n\nif (sodium.sodium_free) {\n exports.free = function (secureBuf) {\n if (secureBuf.secure) sodium.sodium_free(secureBuf)\n }\n} else {\n exports.free = function () {}\n}\n\nfunction encodeUInt64 (n) {\n return uint64be.encode(n, Buffer.allocUnsafe(8))\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,QAAM,cAAc,KAAK,IAAI,GAAG,EAAE;AAElC,YAAQ,iBAAiB,WAAY;AACnC,aAAO;AAAA,IACT;AAEA,YAAQ,SAAS,SAAU,KAAK,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