@unicitylabs/sphere-sdk 0.1.3 → 0.1.4
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/README.md +54 -15
- package/dist/core/index.cjs +298 -72
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +300 -204
- package/dist/core/index.d.ts +300 -204
- package/dist/core/index.js +298 -72
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +1089 -219
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +1086 -222
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/browser/ipfs.cjs +443 -4
- package/dist/impl/browser/ipfs.cjs.map +1 -1
- package/dist/impl/browser/ipfs.js +442 -3
- package/dist/impl/browser/ipfs.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +1078 -222
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +131 -55
- package/dist/impl/nodejs/index.d.ts +131 -55
- package/dist/impl/nodejs/index.js +1085 -225
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +298 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +608 -286
- package/dist/index.d.ts +608 -286
- package/dist/index.js +298 -72
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
|
@@ -93,9 +93,443 @@ var DEFAULT_IPFS_BOOTSTRAP_PEERS = [
|
|
|
93
93
|
var DEFAULT_BASE_PATH = "m/44'/0'/0'";
|
|
94
94
|
var DEFAULT_DERIVATION_PATH = `${DEFAULT_BASE_PATH}/0/0`;
|
|
95
95
|
|
|
96
|
+
// node_modules/@noble/hashes/utils.js
|
|
97
|
+
function isBytes(a) {
|
|
98
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
99
|
+
}
|
|
100
|
+
function anumber(n, title = "") {
|
|
101
|
+
if (!Number.isSafeInteger(n) || n < 0) {
|
|
102
|
+
const prefix = title && `"${title}" `;
|
|
103
|
+
throw new Error(`${prefix}expected integer >= 0, got ${n}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function abytes(value, length, title = "") {
|
|
107
|
+
const bytes = isBytes(value);
|
|
108
|
+
const len = value?.length;
|
|
109
|
+
const needsLen = length !== void 0;
|
|
110
|
+
if (!bytes || needsLen && len !== length) {
|
|
111
|
+
const prefix = title && `"${title}" `;
|
|
112
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
113
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
114
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
function ahash(h) {
|
|
119
|
+
if (typeof h !== "function" || typeof h.create !== "function")
|
|
120
|
+
throw new Error("Hash must wrapped by utils.createHasher");
|
|
121
|
+
anumber(h.outputLen);
|
|
122
|
+
anumber(h.blockLen);
|
|
123
|
+
}
|
|
124
|
+
function aexists(instance, checkFinished = true) {
|
|
125
|
+
if (instance.destroyed)
|
|
126
|
+
throw new Error("Hash instance has been destroyed");
|
|
127
|
+
if (checkFinished && instance.finished)
|
|
128
|
+
throw new Error("Hash#digest() has already been called");
|
|
129
|
+
}
|
|
130
|
+
function aoutput(out, instance) {
|
|
131
|
+
abytes(out, void 0, "digestInto() output");
|
|
132
|
+
const min = instance.outputLen;
|
|
133
|
+
if (out.length < min) {
|
|
134
|
+
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function clean(...arrays) {
|
|
138
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
139
|
+
arrays[i].fill(0);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function createView(arr) {
|
|
143
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
144
|
+
}
|
|
145
|
+
function rotr(word, shift) {
|
|
146
|
+
return word << 32 - shift | word >>> shift;
|
|
147
|
+
}
|
|
148
|
+
function createHasher(hashCons, info = {}) {
|
|
149
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
150
|
+
const tmp = hashCons(void 0);
|
|
151
|
+
hashC.outputLen = tmp.outputLen;
|
|
152
|
+
hashC.blockLen = tmp.blockLen;
|
|
153
|
+
hashC.create = (opts) => hashCons(opts);
|
|
154
|
+
Object.assign(hashC, info);
|
|
155
|
+
return Object.freeze(hashC);
|
|
156
|
+
}
|
|
157
|
+
var oidNist = (suffix) => ({
|
|
158
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// node_modules/@noble/hashes/hmac.js
|
|
162
|
+
var _HMAC = class {
|
|
163
|
+
oHash;
|
|
164
|
+
iHash;
|
|
165
|
+
blockLen;
|
|
166
|
+
outputLen;
|
|
167
|
+
finished = false;
|
|
168
|
+
destroyed = false;
|
|
169
|
+
constructor(hash, key) {
|
|
170
|
+
ahash(hash);
|
|
171
|
+
abytes(key, void 0, "key");
|
|
172
|
+
this.iHash = hash.create();
|
|
173
|
+
if (typeof this.iHash.update !== "function")
|
|
174
|
+
throw new Error("Expected instance of class which extends utils.Hash");
|
|
175
|
+
this.blockLen = this.iHash.blockLen;
|
|
176
|
+
this.outputLen = this.iHash.outputLen;
|
|
177
|
+
const blockLen = this.blockLen;
|
|
178
|
+
const pad = new Uint8Array(blockLen);
|
|
179
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
180
|
+
for (let i = 0; i < pad.length; i++)
|
|
181
|
+
pad[i] ^= 54;
|
|
182
|
+
this.iHash.update(pad);
|
|
183
|
+
this.oHash = hash.create();
|
|
184
|
+
for (let i = 0; i < pad.length; i++)
|
|
185
|
+
pad[i] ^= 54 ^ 92;
|
|
186
|
+
this.oHash.update(pad);
|
|
187
|
+
clean(pad);
|
|
188
|
+
}
|
|
189
|
+
update(buf) {
|
|
190
|
+
aexists(this);
|
|
191
|
+
this.iHash.update(buf);
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
digestInto(out) {
|
|
195
|
+
aexists(this);
|
|
196
|
+
abytes(out, this.outputLen, "output");
|
|
197
|
+
this.finished = true;
|
|
198
|
+
this.iHash.digestInto(out);
|
|
199
|
+
this.oHash.update(out);
|
|
200
|
+
this.oHash.digestInto(out);
|
|
201
|
+
this.destroy();
|
|
202
|
+
}
|
|
203
|
+
digest() {
|
|
204
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
205
|
+
this.digestInto(out);
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
_cloneInto(to) {
|
|
209
|
+
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
210
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
211
|
+
to = to;
|
|
212
|
+
to.finished = finished;
|
|
213
|
+
to.destroyed = destroyed;
|
|
214
|
+
to.blockLen = blockLen;
|
|
215
|
+
to.outputLen = outputLen;
|
|
216
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
217
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
218
|
+
return to;
|
|
219
|
+
}
|
|
220
|
+
clone() {
|
|
221
|
+
return this._cloneInto();
|
|
222
|
+
}
|
|
223
|
+
destroy() {
|
|
224
|
+
this.destroyed = true;
|
|
225
|
+
this.oHash.destroy();
|
|
226
|
+
this.iHash.destroy();
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
var hmac = (hash, key, message) => new _HMAC(hash, key).update(message).digest();
|
|
230
|
+
hmac.create = (hash, key) => new _HMAC(hash, key);
|
|
231
|
+
|
|
232
|
+
// node_modules/@noble/hashes/hkdf.js
|
|
233
|
+
function extract(hash, ikm, salt) {
|
|
234
|
+
ahash(hash);
|
|
235
|
+
if (salt === void 0)
|
|
236
|
+
salt = new Uint8Array(hash.outputLen);
|
|
237
|
+
return hmac(hash, salt, ikm);
|
|
238
|
+
}
|
|
239
|
+
var HKDF_COUNTER = /* @__PURE__ */ Uint8Array.of(0);
|
|
240
|
+
var EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
241
|
+
function expand(hash, prk, info, length = 32) {
|
|
242
|
+
ahash(hash);
|
|
243
|
+
anumber(length, "length");
|
|
244
|
+
const olen = hash.outputLen;
|
|
245
|
+
if (length > 255 * olen)
|
|
246
|
+
throw new Error("Length must be <= 255*HashLen");
|
|
247
|
+
const blocks = Math.ceil(length / olen);
|
|
248
|
+
if (info === void 0)
|
|
249
|
+
info = EMPTY_BUFFER;
|
|
250
|
+
else
|
|
251
|
+
abytes(info, void 0, "info");
|
|
252
|
+
const okm = new Uint8Array(blocks * olen);
|
|
253
|
+
const HMAC = hmac.create(hash, prk);
|
|
254
|
+
const HMACTmp = HMAC._cloneInto();
|
|
255
|
+
const T = new Uint8Array(HMAC.outputLen);
|
|
256
|
+
for (let counter = 0; counter < blocks; counter++) {
|
|
257
|
+
HKDF_COUNTER[0] = counter + 1;
|
|
258
|
+
HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T).update(info).update(HKDF_COUNTER).digestInto(T);
|
|
259
|
+
okm.set(T, olen * counter);
|
|
260
|
+
HMAC._cloneInto(HMACTmp);
|
|
261
|
+
}
|
|
262
|
+
HMAC.destroy();
|
|
263
|
+
HMACTmp.destroy();
|
|
264
|
+
clean(T, HKDF_COUNTER);
|
|
265
|
+
return okm.slice(0, length);
|
|
266
|
+
}
|
|
267
|
+
var hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
|
|
268
|
+
|
|
269
|
+
// node_modules/@noble/hashes/_md.js
|
|
270
|
+
function Chi(a, b, c) {
|
|
271
|
+
return a & b ^ ~a & c;
|
|
272
|
+
}
|
|
273
|
+
function Maj(a, b, c) {
|
|
274
|
+
return a & b ^ a & c ^ b & c;
|
|
275
|
+
}
|
|
276
|
+
var HashMD = class {
|
|
277
|
+
blockLen;
|
|
278
|
+
outputLen;
|
|
279
|
+
padOffset;
|
|
280
|
+
isLE;
|
|
281
|
+
// For partial updates less than block size
|
|
282
|
+
buffer;
|
|
283
|
+
view;
|
|
284
|
+
finished = false;
|
|
285
|
+
length = 0;
|
|
286
|
+
pos = 0;
|
|
287
|
+
destroyed = false;
|
|
288
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
289
|
+
this.blockLen = blockLen;
|
|
290
|
+
this.outputLen = outputLen;
|
|
291
|
+
this.padOffset = padOffset;
|
|
292
|
+
this.isLE = isLE;
|
|
293
|
+
this.buffer = new Uint8Array(blockLen);
|
|
294
|
+
this.view = createView(this.buffer);
|
|
295
|
+
}
|
|
296
|
+
update(data) {
|
|
297
|
+
aexists(this);
|
|
298
|
+
abytes(data);
|
|
299
|
+
const { view, buffer, blockLen } = this;
|
|
300
|
+
const len = data.length;
|
|
301
|
+
for (let pos = 0; pos < len; ) {
|
|
302
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
303
|
+
if (take === blockLen) {
|
|
304
|
+
const dataView = createView(data);
|
|
305
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
306
|
+
this.process(dataView, pos);
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
310
|
+
this.pos += take;
|
|
311
|
+
pos += take;
|
|
312
|
+
if (this.pos === blockLen) {
|
|
313
|
+
this.process(view, 0);
|
|
314
|
+
this.pos = 0;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
this.length += data.length;
|
|
318
|
+
this.roundClean();
|
|
319
|
+
return this;
|
|
320
|
+
}
|
|
321
|
+
digestInto(out) {
|
|
322
|
+
aexists(this);
|
|
323
|
+
aoutput(out, this);
|
|
324
|
+
this.finished = true;
|
|
325
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
326
|
+
let { pos } = this;
|
|
327
|
+
buffer[pos++] = 128;
|
|
328
|
+
clean(this.buffer.subarray(pos));
|
|
329
|
+
if (this.padOffset > blockLen - pos) {
|
|
330
|
+
this.process(view, 0);
|
|
331
|
+
pos = 0;
|
|
332
|
+
}
|
|
333
|
+
for (let i = pos; i < blockLen; i++)
|
|
334
|
+
buffer[i] = 0;
|
|
335
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
336
|
+
this.process(view, 0);
|
|
337
|
+
const oview = createView(out);
|
|
338
|
+
const len = this.outputLen;
|
|
339
|
+
if (len % 4)
|
|
340
|
+
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
341
|
+
const outLen = len / 4;
|
|
342
|
+
const state = this.get();
|
|
343
|
+
if (outLen > state.length)
|
|
344
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
345
|
+
for (let i = 0; i < outLen; i++)
|
|
346
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
347
|
+
}
|
|
348
|
+
digest() {
|
|
349
|
+
const { buffer, outputLen } = this;
|
|
350
|
+
this.digestInto(buffer);
|
|
351
|
+
const res = buffer.slice(0, outputLen);
|
|
352
|
+
this.destroy();
|
|
353
|
+
return res;
|
|
354
|
+
}
|
|
355
|
+
_cloneInto(to) {
|
|
356
|
+
to ||= new this.constructor();
|
|
357
|
+
to.set(...this.get());
|
|
358
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
359
|
+
to.destroyed = destroyed;
|
|
360
|
+
to.finished = finished;
|
|
361
|
+
to.length = length;
|
|
362
|
+
to.pos = pos;
|
|
363
|
+
if (length % blockLen)
|
|
364
|
+
to.buffer.set(buffer);
|
|
365
|
+
return to;
|
|
366
|
+
}
|
|
367
|
+
clone() {
|
|
368
|
+
return this._cloneInto();
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
372
|
+
1779033703,
|
|
373
|
+
3144134277,
|
|
374
|
+
1013904242,
|
|
375
|
+
2773480762,
|
|
376
|
+
1359893119,
|
|
377
|
+
2600822924,
|
|
378
|
+
528734635,
|
|
379
|
+
1541459225
|
|
380
|
+
]);
|
|
381
|
+
|
|
382
|
+
// node_modules/@noble/hashes/sha2.js
|
|
383
|
+
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
384
|
+
1116352408,
|
|
385
|
+
1899447441,
|
|
386
|
+
3049323471,
|
|
387
|
+
3921009573,
|
|
388
|
+
961987163,
|
|
389
|
+
1508970993,
|
|
390
|
+
2453635748,
|
|
391
|
+
2870763221,
|
|
392
|
+
3624381080,
|
|
393
|
+
310598401,
|
|
394
|
+
607225278,
|
|
395
|
+
1426881987,
|
|
396
|
+
1925078388,
|
|
397
|
+
2162078206,
|
|
398
|
+
2614888103,
|
|
399
|
+
3248222580,
|
|
400
|
+
3835390401,
|
|
401
|
+
4022224774,
|
|
402
|
+
264347078,
|
|
403
|
+
604807628,
|
|
404
|
+
770255983,
|
|
405
|
+
1249150122,
|
|
406
|
+
1555081692,
|
|
407
|
+
1996064986,
|
|
408
|
+
2554220882,
|
|
409
|
+
2821834349,
|
|
410
|
+
2952996808,
|
|
411
|
+
3210313671,
|
|
412
|
+
3336571891,
|
|
413
|
+
3584528711,
|
|
414
|
+
113926993,
|
|
415
|
+
338241895,
|
|
416
|
+
666307205,
|
|
417
|
+
773529912,
|
|
418
|
+
1294757372,
|
|
419
|
+
1396182291,
|
|
420
|
+
1695183700,
|
|
421
|
+
1986661051,
|
|
422
|
+
2177026350,
|
|
423
|
+
2456956037,
|
|
424
|
+
2730485921,
|
|
425
|
+
2820302411,
|
|
426
|
+
3259730800,
|
|
427
|
+
3345764771,
|
|
428
|
+
3516065817,
|
|
429
|
+
3600352804,
|
|
430
|
+
4094571909,
|
|
431
|
+
275423344,
|
|
432
|
+
430227734,
|
|
433
|
+
506948616,
|
|
434
|
+
659060556,
|
|
435
|
+
883997877,
|
|
436
|
+
958139571,
|
|
437
|
+
1322822218,
|
|
438
|
+
1537002063,
|
|
439
|
+
1747873779,
|
|
440
|
+
1955562222,
|
|
441
|
+
2024104815,
|
|
442
|
+
2227730452,
|
|
443
|
+
2361852424,
|
|
444
|
+
2428436474,
|
|
445
|
+
2756734187,
|
|
446
|
+
3204031479,
|
|
447
|
+
3329325298
|
|
448
|
+
]);
|
|
449
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
450
|
+
var SHA2_32B = class extends HashMD {
|
|
451
|
+
constructor(outputLen) {
|
|
452
|
+
super(64, outputLen, 8, false);
|
|
453
|
+
}
|
|
454
|
+
get() {
|
|
455
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
456
|
+
return [A, B, C, D, E, F, G, H];
|
|
457
|
+
}
|
|
458
|
+
// prettier-ignore
|
|
459
|
+
set(A, B, C, D, E, F, G, H) {
|
|
460
|
+
this.A = A | 0;
|
|
461
|
+
this.B = B | 0;
|
|
462
|
+
this.C = C | 0;
|
|
463
|
+
this.D = D | 0;
|
|
464
|
+
this.E = E | 0;
|
|
465
|
+
this.F = F | 0;
|
|
466
|
+
this.G = G | 0;
|
|
467
|
+
this.H = H | 0;
|
|
468
|
+
}
|
|
469
|
+
process(view, offset) {
|
|
470
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
471
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
472
|
+
for (let i = 16; i < 64; i++) {
|
|
473
|
+
const W15 = SHA256_W[i - 15];
|
|
474
|
+
const W2 = SHA256_W[i - 2];
|
|
475
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
476
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
477
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
478
|
+
}
|
|
479
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
480
|
+
for (let i = 0; i < 64; i++) {
|
|
481
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
482
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
483
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
484
|
+
const T2 = sigma0 + Maj(A, B, C) | 0;
|
|
485
|
+
H = G;
|
|
486
|
+
G = F;
|
|
487
|
+
F = E;
|
|
488
|
+
E = D + T1 | 0;
|
|
489
|
+
D = C;
|
|
490
|
+
C = B;
|
|
491
|
+
B = A;
|
|
492
|
+
A = T1 + T2 | 0;
|
|
493
|
+
}
|
|
494
|
+
A = A + this.A | 0;
|
|
495
|
+
B = B + this.B | 0;
|
|
496
|
+
C = C + this.C | 0;
|
|
497
|
+
D = D + this.D | 0;
|
|
498
|
+
E = E + this.E | 0;
|
|
499
|
+
F = F + this.F | 0;
|
|
500
|
+
G = G + this.G | 0;
|
|
501
|
+
H = H + this.H | 0;
|
|
502
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
503
|
+
}
|
|
504
|
+
roundClean() {
|
|
505
|
+
clean(SHA256_W);
|
|
506
|
+
}
|
|
507
|
+
destroy() {
|
|
508
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
509
|
+
clean(this.buffer);
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
var _SHA256 = class extends SHA2_32B {
|
|
513
|
+
// We cannot use array here since array allows indexing by variable
|
|
514
|
+
// which means optimizer/compiler cannot use registers.
|
|
515
|
+
A = SHA256_IV[0] | 0;
|
|
516
|
+
B = SHA256_IV[1] | 0;
|
|
517
|
+
C = SHA256_IV[2] | 0;
|
|
518
|
+
D = SHA256_IV[3] | 0;
|
|
519
|
+
E = SHA256_IV[4] | 0;
|
|
520
|
+
F = SHA256_IV[5] | 0;
|
|
521
|
+
G = SHA256_IV[6] | 0;
|
|
522
|
+
H = SHA256_IV[7] | 0;
|
|
523
|
+
constructor() {
|
|
524
|
+
super(32);
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
var sha256 = /* @__PURE__ */ createHasher(
|
|
528
|
+
() => new _SHA256(),
|
|
529
|
+
/* @__PURE__ */ oidNist(1)
|
|
530
|
+
);
|
|
531
|
+
|
|
96
532
|
// impl/browser/storage/IpfsStorageProvider.ts
|
|
97
|
-
var import_hkdf = require("@noble/hashes/hkdf.js");
|
|
98
|
-
var import_sha2 = require("@noble/hashes/sha2.js");
|
|
99
533
|
var heliaModule = null;
|
|
100
534
|
var heliaJsonModule = null;
|
|
101
535
|
var libp2pBootstrapModule = null;
|
|
@@ -236,7 +670,7 @@ var IpfsStorageProvider = class {
|
|
|
236
670
|
try {
|
|
237
671
|
const { generateKeyPairFromSeed, peerIdFromPrivateKey } = await loadHeliaModules();
|
|
238
672
|
const walletSecret = this.hexToBytes(identity.privateKey);
|
|
239
|
-
const derivedKey =
|
|
673
|
+
const derivedKey = hkdf(sha256, walletSecret, void 0, HKDF_INFO, 32);
|
|
240
674
|
this.ipnsKeyPair = await generateKeyPairFromSeed("Ed25519", derivedKey);
|
|
241
675
|
const peerId = peerIdFromPrivateKey(this.ipnsKeyPair);
|
|
242
676
|
this.ipnsName = peerId.toString();
|
|
@@ -403,7 +837,7 @@ var IpfsStorageProvider = class {
|
|
|
403
837
|
const emptyData = {
|
|
404
838
|
_meta: {
|
|
405
839
|
version: 0,
|
|
406
|
-
address: this.identity?.
|
|
840
|
+
address: this.identity?.l1Address ?? "",
|
|
407
841
|
formatVersion: "2.0",
|
|
408
842
|
updatedAt: Date.now()
|
|
409
843
|
},
|
|
@@ -670,4 +1104,9 @@ var IpfsStorageProvider = class {
|
|
|
670
1104
|
function createIpfsStorageProvider(config) {
|
|
671
1105
|
return new IpfsStorageProvider(config);
|
|
672
1106
|
}
|
|
1107
|
+
/*! Bundled license information:
|
|
1108
|
+
|
|
1109
|
+
@noble/hashes/utils.js:
|
|
1110
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
1111
|
+
*/
|
|
673
1112
|
//# sourceMappingURL=ipfs.cjs.map
|