@fireproof/core 0.14.4 → 0.14.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -4186,10 +4186,6 @@ function pLimit(concurrency) {
4186
4186
  return generator;
4187
4187
  }
4188
4188
 
4189
- // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/reader.js
4190
- import fs from "fs";
4191
- import { promisify } from "util";
4192
-
4193
4189
  // ../../node_modules/.pnpm/@ipld+dag-cbor@9.0.4/node_modules/@ipld/dag-cbor/src/index.js
4194
4190
  var src_exports = {};
4195
4191
  __export(src_exports, {
@@ -7324,51 +7320,6 @@ async function decodeReaderComplete(reader2) {
7324
7320
  return new CarReader(header, blocks);
7325
7321
  }
7326
7322
 
7327
- // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/reader.js
7328
- var fsread = promisify(fs.read);
7329
- var CarReader2 = class extends CarReader {
7330
- /**
7331
- * Reads a block directly from a file descriptor for an open CAR file. This
7332
- * function is **only available in Node.js** and not a browser environment.
7333
- *
7334
- * This function can be used in connection with {@link CarIndexer} which emits
7335
- * the `BlockIndex` objects that are required by this function.
7336
- *
7337
- * The user is responsible for opening and closing the file used in this call.
7338
- *
7339
- * @async
7340
- * @static
7341
- * @memberof CarReader
7342
- * @param {fs.promises.FileHandle | number} fd - A file descriptor from the
7343
- * Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
7344
- * from `fs.promises.open()`.
7345
- * @param {BlockIndex} blockIndex - An index pointing to the location of the
7346
- * Block required. This `BlockIndex` should take the form:
7347
- * `{cid:CID, blockLength:number, blockOffset:number}`.
7348
- * @returns {Promise<Block>} A `{ cid:CID, bytes:Uint8Array }` pair.
7349
- */
7350
- static async readRaw(fd, blockIndex) {
7351
- const { cid, blockLength: blockLength2, blockOffset } = blockIndex;
7352
- const bytes = new Uint8Array(blockLength2);
7353
- let read4;
7354
- if (typeof fd === "number") {
7355
- read4 = (await fsread(fd, bytes, 0, blockLength2, blockOffset)).bytesRead;
7356
- } else if (typeof fd === "object" && typeof fd.read === "function") {
7357
- read4 = (await fd.read(bytes, 0, blockLength2, blockOffset)).bytesRead;
7358
- } else {
7359
- throw new TypeError("Bad fd");
7360
- }
7361
- if (read4 !== blockLength2) {
7362
- throw new Error(`Failed to read entire block (${read4} instead of ${blockLength2})`);
7363
- }
7364
- return { cid, bytes };
7365
- }
7366
- };
7367
-
7368
- // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/buffer-reader.js
7369
- import fs2 from "fs";
7370
- var fsread2 = fs2.readSync;
7371
-
7372
7323
  // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/indexer.js
7373
7324
  var CarIndexer = class {
7374
7325
  /**
@@ -7612,10 +7563,6 @@ async function decodeIterator(reader2) {
7612
7563
  return { version, roots, iterator: decoder.blocks() };
7613
7564
  }
7614
7565
 
7615
- // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/writer.js
7616
- import fs3 from "fs";
7617
- import { promisify as promisify2 } from "util";
7618
-
7619
7566
  // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/encoder.js
7620
7567
  var import_varint4 = __toESM(require_varint(), 1);
7621
7568
 
@@ -7636,10 +7583,6 @@ var CarWriterOut = class {
7636
7583
  }
7637
7584
  };
7638
7585
 
7639
- // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/writer.js
7640
- var fsread3 = promisify2(fs3.read);
7641
- var fswrite = promisify2(fs3.write);
7642
-
7643
7586
  // ../../node_modules/.pnpm/@ipld+car@5.2.0/node_modules/@ipld/car/src/buffer-writer.js
7644
7587
  var import_varint5 = __toESM(require_varint(), 1);
7645
7588
 
@@ -9303,17 +9246,22 @@ async function create4({ bytes, cid, hasher, codec }) {
9303
9246
  });
9304
9247
  }
9305
9248
 
9306
- // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/hashes/sha2.js
9307
- import crypto2 from "crypto";
9249
+ // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/hashes/sha2-browser.js
9250
+ var sha = (name8) => (
9251
+ /**
9252
+ * @param {Uint8Array} data
9253
+ */
9254
+ async (data) => new Uint8Array(await crypto.subtle.digest(name8, data))
9255
+ );
9308
9256
  var sha256 = from3({
9309
9257
  name: "sha2-256",
9310
9258
  code: 18,
9311
- encode: (input) => coerce2(crypto2.createHash("sha256").update(input).digest())
9259
+ encode: sha("SHA-256")
9312
9260
  });
9313
9261
  var sha512 = from3({
9314
9262
  name: "sha2-512",
9315
9263
  code: 19,
9316
- encode: (input) => coerce2(crypto2.createHash("sha512").update(input).digest())
9264
+ encode: sha("SHA-512")
9317
9265
  });
9318
9266
 
9319
9267
  // ../../node_modules/.pnpm/multiformats@12.0.1/node_modules/multiformats/src/codecs/raw.js
@@ -9391,11 +9339,11 @@ function getCrypto() {
9391
9339
  return null;
9392
9340
  }
9393
9341
  }
9394
- var crypto3 = getCrypto();
9342
+ var crypto2 = getCrypto();
9395
9343
  function randomBytes(size3) {
9396
9344
  const bytes = new Uint8Array(size3);
9397
9345
  if (size3 > 0) {
9398
- crypto3.getRandomValues(bytes);
9346
+ crypto2.getRandomValues(bytes);
9399
9347
  }
9400
9348
  return bytes;
9401
9349
  }
@@ -9433,7 +9381,7 @@ var decode14 = (bytes) => {
9433
9381
  };
9434
9382
  var code3 = 3145728 + 1337;
9435
9383
  async function subtleKey(key) {
9436
- return await crypto3.subtle.importKey(
9384
+ return await crypto2.subtle.importKey(
9437
9385
  "raw",
9438
9386
  // raw or jwk
9439
9387
  key,
@@ -9447,7 +9395,7 @@ async function subtleKey(key) {
9447
9395
  var decrypt = async ({ key, value }) => {
9448
9396
  let { bytes, iv } = value;
9449
9397
  const cryKey = await subtleKey(key);
9450
- const deBytes = await crypto3.subtle.decrypt(
9398
+ const deBytes = await crypto2.subtle.decrypt(
9451
9399
  {
9452
9400
  name: "AES-GCM",
9453
9401
  iv,
@@ -9468,7 +9416,7 @@ var encrypt = async ({ key, cid, bytes }) => {
9468
9416
  const msg = concat3([len, cid.bytes, bytes]);
9469
9417
  try {
9470
9418
  const cryKey = await subtleKey(key);
9471
- const deBytes = await crypto3.subtle.encrypt(
9419
+ const deBytes = await crypto2.subtle.encrypt(
9472
9420
  {
9473
9421
  name: "AES-GCM",
9474
9422
  iv,
@@ -11393,7 +11341,7 @@ var parse2 = (data) => decode16(utf8Encoder.encode(data));
11393
11341
  var utf8Encoder = new TextEncoder();
11394
11342
 
11395
11343
  // src/version.ts
11396
- var PACKAGE_VERSION = "0.14.4";
11344
+ var PACKAGE_VERSION = "0.14.5";
11397
11345
 
11398
11346
  // src/store.ts
11399
11347
  var match = PACKAGE_VERSION.match(/^([^.]*\.[^.]*)/);
@@ -11881,7 +11829,7 @@ var Loader = class {
11881
11829
  }
11882
11830
  if (!loadedCar)
11883
11831
  throw new Error(`missing car file ${cidString}`);
11884
- const rawReader = await CarReader2.fromBytes(loadedCar.bytes);
11832
+ const rawReader = await CarReader.fromBytes(loadedCar.bytes);
11885
11833
  const readerP = publicFiles ? Promise.resolve(rawReader) : this.ensureDecryptedReader(rawReader);
11886
11834
  this.carReaders.set(cidString, readerP);
11887
11835
  return readerP;
@@ -11908,10 +11856,10 @@ var Loader = class {
11908
11856
  if (this.key && this.key !== key)
11909
11857
  throw new Error("key mismatch");
11910
11858
  this.key = key;
11911
- const crypto5 = getCrypto();
11912
- if (!crypto5)
11859
+ const crypto3 = getCrypto();
11860
+ if (!crypto3)
11913
11861
  throw new Error("missing crypto module");
11914
- const subtle = crypto5.subtle;
11862
+ const subtle = crypto3.subtle;
11915
11863
  const encoder = new TextEncoder();
11916
11864
  const data = encoder.encode(key);
11917
11865
  const hashBuffer = await subtle.digest("SHA-256", data);
@@ -12736,22 +12684,27 @@ async function decode17({ bytes, codec, hasher }) {
12736
12684
  return new Block3({ value, bytes, cid });
12737
12685
  }
12738
12686
 
12739
- // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/hashes/sha2.js
12740
- var sha2_exports = {};
12741
- __export(sha2_exports, {
12687
+ // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/hashes/sha2-browser.js
12688
+ var sha2_browser_exports = {};
12689
+ __export(sha2_browser_exports, {
12742
12690
  sha256: () => sha2562,
12743
12691
  sha512: () => sha5122
12744
12692
  });
12745
- import crypto4 from "crypto";
12693
+ var sha2 = (name8) => (
12694
+ /**
12695
+ * @param {Uint8Array} data
12696
+ */
12697
+ async (data) => new Uint8Array(await crypto.subtle.digest(name8, data))
12698
+ );
12746
12699
  var sha2562 = from4({
12747
12700
  name: "sha2-256",
12748
12701
  code: 18,
12749
- encode: (input) => coerce(crypto4.createHash("sha256").update(input).digest())
12702
+ encode: sha2("SHA-256")
12750
12703
  });
12751
12704
  var sha5122 = from4({
12752
12705
  name: "sha2-512",
12753
12706
  code: 19,
12754
- encode: (input) => coerce(crypto4.createHash("sha512").update(input).digest())
12707
+ encode: sha2("SHA-512")
12755
12708
  });
12756
12709
 
12757
12710
  // ../../node_modules/.pnpm/@alanshaw+pail@0.3.3/node_modules/@alanshaw/pail/src/clock.js
@@ -18501,7 +18454,7 @@ var textDecoder4 = new TextDecoder();
18501
18454
 
18502
18455
  // ../../node_modules/.pnpm/multiformats@11.0.2/node_modules/multiformats/src/basics.js
18503
18456
  var bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
18504
- var hashes = { ...sha2_exports, ...identity_exports2 };
18457
+ var hashes = { ...sha2_browser_exports, ...identity_exports2 };
18505
18458
 
18506
18459
  // ../../node_modules/.pnpm/uint8arrays@4.0.3/node_modules/uint8arrays/dist/src/util/as-uint8array.js
18507
18460
  function asUint8Array2(buf3) {