@clef-sh/core 0.1.15-beta.106 → 0.1.15-beta.108

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 (38) hide show
  1. package/dist/git/integration.d.ts.map +1 -1
  2. package/dist/index.d.mts +2 -2
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +342 -608
  6. package/dist/index.js.map +4 -4
  7. package/dist/index.mjs +337 -595
  8. package/dist/index.mjs.map +4 -4
  9. package/dist/kms/types.d.ts +1 -1
  10. package/dist/kms/types.d.ts.map +1 -1
  11. package/dist/manifest/parser.d.ts.map +1 -1
  12. package/dist/migration/backend.d.ts +1 -1
  13. package/dist/migration/backend.d.ts.map +1 -1
  14. package/dist/sops/client.d.ts +1 -12
  15. package/dist/sops/client.d.ts.map +1 -1
  16. package/dist/sync/index.d.ts +3 -0
  17. package/dist/sync/index.d.ts.map +1 -0
  18. package/dist/sync/manager.d.ts +58 -0
  19. package/dist/sync/manager.d.ts.map +1 -0
  20. package/dist/types/index.d.ts +2 -8
  21. package/dist/types/index.d.ts.map +1 -1
  22. package/package.json +1 -1
  23. package/dist/cloud/bundled.d.ts +0 -6
  24. package/dist/cloud/bundled.d.ts.map +0 -1
  25. package/dist/cloud/constants.d.ts +0 -2
  26. package/dist/cloud/constants.d.ts.map +0 -1
  27. package/dist/cloud/credentials.d.ts +0 -13
  28. package/dist/cloud/credentials.d.ts.map +0 -1
  29. package/dist/cloud/device-flow.d.ts +0 -46
  30. package/dist/cloud/device-flow.d.ts.map +0 -1
  31. package/dist/cloud/index.d.ts +0 -10
  32. package/dist/cloud/index.d.ts.map +0 -1
  33. package/dist/cloud/keyservice.d.ts +0 -20
  34. package/dist/cloud/keyservice.d.ts.map +0 -1
  35. package/dist/cloud/pack-client.d.ts +0 -34
  36. package/dist/cloud/pack-client.d.ts.map +0 -1
  37. package/dist/cloud/resolver.d.ts +0 -24
  38. package/dist/cloud/resolver.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -304,10 +304,10 @@ var require_lib = __commonJS({
304
304
  module2.exports.sync = writeFileSync6;
305
305
  module2.exports._getTmpname = getTmpname;
306
306
  module2.exports._cleanupOnExit = cleanupOnExit;
307
- var fs21 = require("fs");
307
+ var fs17 = require("fs");
308
308
  var crypto5 = require("node:crypto");
309
309
  var { onExit } = require_cjs();
310
- var path28 = require("path");
310
+ var path25 = require("path");
311
311
  var { promisify } = require("util");
312
312
  var activeFiles = {};
313
313
  var threadId = (function getId() {
@@ -325,7 +325,7 @@ var require_lib = __commonJS({
325
325
  function cleanupOnExit(tmpfile) {
326
326
  return () => {
327
327
  try {
328
- fs21.unlinkSync(typeof tmpfile === "function" ? tmpfile() : tmpfile);
328
+ fs17.unlinkSync(typeof tmpfile === "function" ? tmpfile() : tmpfile);
329
329
  } catch {
330
330
  }
331
331
  };
@@ -360,13 +360,13 @@ var require_lib = __commonJS({
360
360
  let fd;
361
361
  let tmpfile;
362
362
  const removeOnExitHandler = onExit(cleanupOnExit(() => tmpfile));
363
- const absoluteName = path28.resolve(filename);
363
+ const absoluteName = path25.resolve(filename);
364
364
  try {
365
365
  await serializeActiveFile(absoluteName);
366
- const truename = await promisify(fs21.realpath)(filename).catch(() => filename);
366
+ const truename = await promisify(fs17.realpath)(filename).catch(() => filename);
367
367
  tmpfile = getTmpname(truename);
368
368
  if (!options.mode || !options.chown) {
369
- const stats = await promisify(fs21.stat)(truename).catch(() => {
369
+ const stats = await promisify(fs17.stat)(truename).catch(() => {
370
370
  });
371
371
  if (stats) {
372
372
  if (options.mode == null) {
@@ -377,45 +377,45 @@ var require_lib = __commonJS({
377
377
  }
378
378
  }
379
379
  }
380
- fd = await promisify(fs21.open)(tmpfile, "w", options.mode);
380
+ fd = await promisify(fs17.open)(tmpfile, "w", options.mode);
381
381
  if (options.tmpfileCreated) {
382
382
  await options.tmpfileCreated(tmpfile);
383
383
  }
384
384
  if (ArrayBuffer.isView(data)) {
385
- await promisify(fs21.write)(fd, data, 0, data.length, 0);
385
+ await promisify(fs17.write)(fd, data, 0, data.length, 0);
386
386
  } else if (data != null) {
387
- await promisify(fs21.write)(fd, String(data), 0, String(options.encoding || "utf8"));
387
+ await promisify(fs17.write)(fd, String(data), 0, String(options.encoding || "utf8"));
388
388
  }
389
389
  if (options.fsync !== false) {
390
- await promisify(fs21.fsync)(fd);
390
+ await promisify(fs17.fsync)(fd);
391
391
  }
392
- await promisify(fs21.close)(fd);
392
+ await promisify(fs17.close)(fd);
393
393
  fd = null;
394
394
  if (options.chown) {
395
- await promisify(fs21.chown)(tmpfile, options.chown.uid, options.chown.gid).catch((err) => {
395
+ await promisify(fs17.chown)(tmpfile, options.chown.uid, options.chown.gid).catch((err) => {
396
396
  if (!isChownErrOk(err)) {
397
397
  throw err;
398
398
  }
399
399
  });
400
400
  }
401
401
  if (options.mode) {
402
- await promisify(fs21.chmod)(tmpfile, options.mode).catch((err) => {
402
+ await promisify(fs17.chmod)(tmpfile, options.mode).catch((err) => {
403
403
  if (!isChownErrOk(err)) {
404
404
  throw err;
405
405
  }
406
406
  });
407
407
  }
408
- await promisify(fs21.rename)(tmpfile, truename);
408
+ await promisify(fs17.rename)(tmpfile, truename);
409
409
  } finally {
410
410
  if (fd) {
411
- await promisify(fs21.close)(fd).catch(
411
+ await promisify(fs17.close)(fd).catch(
412
412
  /* istanbul ignore next */
413
413
  () => {
414
414
  }
415
415
  );
416
416
  }
417
417
  removeOnExitHandler();
418
- await promisify(fs21.unlink)(tmpfile).catch(() => {
418
+ await promisify(fs17.unlink)(tmpfile).catch(() => {
419
419
  });
420
420
  activeFiles[absoluteName].shift();
421
421
  if (activeFiles[absoluteName].length > 0) {
@@ -448,13 +448,13 @@ var require_lib = __commonJS({
448
448
  options = {};
449
449
  }
450
450
  try {
451
- filename = fs21.realpathSync(filename);
451
+ filename = fs17.realpathSync(filename);
452
452
  } catch (ex) {
453
453
  }
454
454
  const tmpfile = getTmpname(filename);
455
455
  if (!options.mode || !options.chown) {
456
456
  try {
457
- const stats = fs21.statSync(filename);
457
+ const stats = fs17.statSync(filename);
458
458
  options = Object.assign({}, options);
459
459
  if (!options.mode) {
460
460
  options.mode = stats.mode;
@@ -470,23 +470,23 @@ var require_lib = __commonJS({
470
470
  const removeOnExitHandler = onExit(cleanup);
471
471
  let threw = true;
472
472
  try {
473
- fd = fs21.openSync(tmpfile, "w", options.mode || 438);
473
+ fd = fs17.openSync(tmpfile, "w", options.mode || 438);
474
474
  if (options.tmpfileCreated) {
475
475
  options.tmpfileCreated(tmpfile);
476
476
  }
477
477
  if (ArrayBuffer.isView(data)) {
478
- fs21.writeSync(fd, data, 0, data.length, 0);
478
+ fs17.writeSync(fd, data, 0, data.length, 0);
479
479
  } else if (data != null) {
480
- fs21.writeSync(fd, String(data), 0, String(options.encoding || "utf8"));
480
+ fs17.writeSync(fd, String(data), 0, String(options.encoding || "utf8"));
481
481
  }
482
482
  if (options.fsync !== false) {
483
- fs21.fsyncSync(fd);
483
+ fs17.fsyncSync(fd);
484
484
  }
485
- fs21.closeSync(fd);
485
+ fs17.closeSync(fd);
486
486
  fd = null;
487
487
  if (options.chown) {
488
488
  try {
489
- fs21.chownSync(tmpfile, options.chown.uid, options.chown.gid);
489
+ fs17.chownSync(tmpfile, options.chown.uid, options.chown.gid);
490
490
  } catch (err) {
491
491
  if (!isChownErrOk(err)) {
492
492
  throw err;
@@ -495,19 +495,19 @@ var require_lib = __commonJS({
495
495
  }
496
496
  if (options.mode) {
497
497
  try {
498
- fs21.chmodSync(tmpfile, options.mode);
498
+ fs17.chmodSync(tmpfile, options.mode);
499
499
  } catch (err) {
500
500
  if (!isChownErrOk(err)) {
501
501
  throw err;
502
502
  }
503
503
  }
504
504
  }
505
- fs21.renameSync(tmpfile, filename);
505
+ fs17.renameSync(tmpfile, filename);
506
506
  threw = false;
507
507
  } finally {
508
508
  if (fd) {
509
509
  try {
510
- fs21.closeSync(fd);
510
+ fs17.closeSync(fd);
511
511
  } catch (ex) {
512
512
  }
513
513
  }
@@ -546,54 +546,54 @@ var require_polyfills = __commonJS({
546
546
  }
547
547
  var chdir;
548
548
  module2.exports = patch;
549
- function patch(fs21) {
549
+ function patch(fs17) {
550
550
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
551
- patchLchmod(fs21);
552
- }
553
- if (!fs21.lutimes) {
554
- patchLutimes(fs21);
555
- }
556
- fs21.chown = chownFix(fs21.chown);
557
- fs21.fchown = chownFix(fs21.fchown);
558
- fs21.lchown = chownFix(fs21.lchown);
559
- fs21.chmod = chmodFix(fs21.chmod);
560
- fs21.fchmod = chmodFix(fs21.fchmod);
561
- fs21.lchmod = chmodFix(fs21.lchmod);
562
- fs21.chownSync = chownFixSync(fs21.chownSync);
563
- fs21.fchownSync = chownFixSync(fs21.fchownSync);
564
- fs21.lchownSync = chownFixSync(fs21.lchownSync);
565
- fs21.chmodSync = chmodFixSync(fs21.chmodSync);
566
- fs21.fchmodSync = chmodFixSync(fs21.fchmodSync);
567
- fs21.lchmodSync = chmodFixSync(fs21.lchmodSync);
568
- fs21.stat = statFix(fs21.stat);
569
- fs21.fstat = statFix(fs21.fstat);
570
- fs21.lstat = statFix(fs21.lstat);
571
- fs21.statSync = statFixSync(fs21.statSync);
572
- fs21.fstatSync = statFixSync(fs21.fstatSync);
573
- fs21.lstatSync = statFixSync(fs21.lstatSync);
574
- if (fs21.chmod && !fs21.lchmod) {
575
- fs21.lchmod = function(path28, mode, cb) {
551
+ patchLchmod(fs17);
552
+ }
553
+ if (!fs17.lutimes) {
554
+ patchLutimes(fs17);
555
+ }
556
+ fs17.chown = chownFix(fs17.chown);
557
+ fs17.fchown = chownFix(fs17.fchown);
558
+ fs17.lchown = chownFix(fs17.lchown);
559
+ fs17.chmod = chmodFix(fs17.chmod);
560
+ fs17.fchmod = chmodFix(fs17.fchmod);
561
+ fs17.lchmod = chmodFix(fs17.lchmod);
562
+ fs17.chownSync = chownFixSync(fs17.chownSync);
563
+ fs17.fchownSync = chownFixSync(fs17.fchownSync);
564
+ fs17.lchownSync = chownFixSync(fs17.lchownSync);
565
+ fs17.chmodSync = chmodFixSync(fs17.chmodSync);
566
+ fs17.fchmodSync = chmodFixSync(fs17.fchmodSync);
567
+ fs17.lchmodSync = chmodFixSync(fs17.lchmodSync);
568
+ fs17.stat = statFix(fs17.stat);
569
+ fs17.fstat = statFix(fs17.fstat);
570
+ fs17.lstat = statFix(fs17.lstat);
571
+ fs17.statSync = statFixSync(fs17.statSync);
572
+ fs17.fstatSync = statFixSync(fs17.fstatSync);
573
+ fs17.lstatSync = statFixSync(fs17.lstatSync);
574
+ if (fs17.chmod && !fs17.lchmod) {
575
+ fs17.lchmod = function(path25, mode, cb) {
576
576
  if (cb) process.nextTick(cb);
577
577
  };
578
- fs21.lchmodSync = function() {
578
+ fs17.lchmodSync = function() {
579
579
  };
580
580
  }
581
- if (fs21.chown && !fs21.lchown) {
582
- fs21.lchown = function(path28, uid, gid, cb) {
581
+ if (fs17.chown && !fs17.lchown) {
582
+ fs17.lchown = function(path25, uid, gid, cb) {
583
583
  if (cb) process.nextTick(cb);
584
584
  };
585
- fs21.lchownSync = function() {
585
+ fs17.lchownSync = function() {
586
586
  };
587
587
  }
588
588
  if (platform === "win32") {
589
- fs21.rename = typeof fs21.rename !== "function" ? fs21.rename : (function(fs$rename) {
589
+ fs17.rename = typeof fs17.rename !== "function" ? fs17.rename : (function(fs$rename) {
590
590
  function rename(from, to, cb) {
591
591
  var start = Date.now();
592
592
  var backoff = 0;
593
593
  fs$rename(from, to, function CB(er) {
594
594
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
595
595
  setTimeout(function() {
596
- fs21.stat(to, function(stater, st) {
596
+ fs17.stat(to, function(stater, st) {
597
597
  if (stater && stater.code === "ENOENT")
598
598
  fs$rename(from, to, CB);
599
599
  else
@@ -609,9 +609,9 @@ var require_polyfills = __commonJS({
609
609
  }
610
610
  if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
611
611
  return rename;
612
- })(fs21.rename);
612
+ })(fs17.rename);
613
613
  }
614
- fs21.read = typeof fs21.read !== "function" ? fs21.read : (function(fs$read) {
614
+ fs17.read = typeof fs17.read !== "function" ? fs17.read : (function(fs$read) {
615
615
  function read(fd, buffer, offset, length, position, callback_) {
616
616
  var callback;
617
617
  if (callback_ && typeof callback_ === "function") {
@@ -619,22 +619,22 @@ var require_polyfills = __commonJS({
619
619
  callback = function(er, _, __) {
620
620
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
621
621
  eagCounter++;
622
- return fs$read.call(fs21, fd, buffer, offset, length, position, callback);
622
+ return fs$read.call(fs17, fd, buffer, offset, length, position, callback);
623
623
  }
624
624
  callback_.apply(this, arguments);
625
625
  };
626
626
  }
627
- return fs$read.call(fs21, fd, buffer, offset, length, position, callback);
627
+ return fs$read.call(fs17, fd, buffer, offset, length, position, callback);
628
628
  }
629
629
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
630
630
  return read;
631
- })(fs21.read);
632
- fs21.readSync = typeof fs21.readSync !== "function" ? fs21.readSync : /* @__PURE__ */ (function(fs$readSync) {
631
+ })(fs17.read);
632
+ fs17.readSync = typeof fs17.readSync !== "function" ? fs17.readSync : /* @__PURE__ */ (function(fs$readSync) {
633
633
  return function(fd, buffer, offset, length, position) {
634
634
  var eagCounter = 0;
635
635
  while (true) {
636
636
  try {
637
- return fs$readSync.call(fs21, fd, buffer, offset, length, position);
637
+ return fs$readSync.call(fs17, fd, buffer, offset, length, position);
638
638
  } catch (er) {
639
639
  if (er.code === "EAGAIN" && eagCounter < 10) {
640
640
  eagCounter++;
@@ -644,11 +644,11 @@ var require_polyfills = __commonJS({
644
644
  }
645
645
  }
646
646
  };
647
- })(fs21.readSync);
648
- function patchLchmod(fs22) {
649
- fs22.lchmod = function(path28, mode, callback) {
650
- fs22.open(
651
- path28,
647
+ })(fs17.readSync);
648
+ function patchLchmod(fs18) {
649
+ fs18.lchmod = function(path25, mode, callback) {
650
+ fs18.open(
651
+ path25,
652
652
  constants.O_WRONLY | constants.O_SYMLINK,
653
653
  mode,
654
654
  function(err, fd) {
@@ -656,80 +656,80 @@ var require_polyfills = __commonJS({
656
656
  if (callback) callback(err);
657
657
  return;
658
658
  }
659
- fs22.fchmod(fd, mode, function(err2) {
660
- fs22.close(fd, function(err22) {
659
+ fs18.fchmod(fd, mode, function(err2) {
660
+ fs18.close(fd, function(err22) {
661
661
  if (callback) callback(err2 || err22);
662
662
  });
663
663
  });
664
664
  }
665
665
  );
666
666
  };
667
- fs22.lchmodSync = function(path28, mode) {
668
- var fd = fs22.openSync(path28, constants.O_WRONLY | constants.O_SYMLINK, mode);
667
+ fs18.lchmodSync = function(path25, mode) {
668
+ var fd = fs18.openSync(path25, constants.O_WRONLY | constants.O_SYMLINK, mode);
669
669
  var threw = true;
670
670
  var ret;
671
671
  try {
672
- ret = fs22.fchmodSync(fd, mode);
672
+ ret = fs18.fchmodSync(fd, mode);
673
673
  threw = false;
674
674
  } finally {
675
675
  if (threw) {
676
676
  try {
677
- fs22.closeSync(fd);
677
+ fs18.closeSync(fd);
678
678
  } catch (er) {
679
679
  }
680
680
  } else {
681
- fs22.closeSync(fd);
681
+ fs18.closeSync(fd);
682
682
  }
683
683
  }
684
684
  return ret;
685
685
  };
686
686
  }
687
- function patchLutimes(fs22) {
688
- if (constants.hasOwnProperty("O_SYMLINK") && fs22.futimes) {
689
- fs22.lutimes = function(path28, at, mt, cb) {
690
- fs22.open(path28, constants.O_SYMLINK, function(er, fd) {
687
+ function patchLutimes(fs18) {
688
+ if (constants.hasOwnProperty("O_SYMLINK") && fs18.futimes) {
689
+ fs18.lutimes = function(path25, at, mt, cb) {
690
+ fs18.open(path25, constants.O_SYMLINK, function(er, fd) {
691
691
  if (er) {
692
692
  if (cb) cb(er);
693
693
  return;
694
694
  }
695
- fs22.futimes(fd, at, mt, function(er2) {
696
- fs22.close(fd, function(er22) {
695
+ fs18.futimes(fd, at, mt, function(er2) {
696
+ fs18.close(fd, function(er22) {
697
697
  if (cb) cb(er2 || er22);
698
698
  });
699
699
  });
700
700
  });
701
701
  };
702
- fs22.lutimesSync = function(path28, at, mt) {
703
- var fd = fs22.openSync(path28, constants.O_SYMLINK);
702
+ fs18.lutimesSync = function(path25, at, mt) {
703
+ var fd = fs18.openSync(path25, constants.O_SYMLINK);
704
704
  var ret;
705
705
  var threw = true;
706
706
  try {
707
- ret = fs22.futimesSync(fd, at, mt);
707
+ ret = fs18.futimesSync(fd, at, mt);
708
708
  threw = false;
709
709
  } finally {
710
710
  if (threw) {
711
711
  try {
712
- fs22.closeSync(fd);
712
+ fs18.closeSync(fd);
713
713
  } catch (er) {
714
714
  }
715
715
  } else {
716
- fs22.closeSync(fd);
716
+ fs18.closeSync(fd);
717
717
  }
718
718
  }
719
719
  return ret;
720
720
  };
721
- } else if (fs22.futimes) {
722
- fs22.lutimes = function(_a, _b, _c, cb) {
721
+ } else if (fs18.futimes) {
722
+ fs18.lutimes = function(_a, _b, _c, cb) {
723
723
  if (cb) process.nextTick(cb);
724
724
  };
725
- fs22.lutimesSync = function() {
725
+ fs18.lutimesSync = function() {
726
726
  };
727
727
  }
728
728
  }
729
729
  function chmodFix(orig) {
730
730
  if (!orig) return orig;
731
731
  return function(target, mode, cb) {
732
- return orig.call(fs21, target, mode, function(er) {
732
+ return orig.call(fs17, target, mode, function(er) {
733
733
  if (chownErOk(er)) er = null;
734
734
  if (cb) cb.apply(this, arguments);
735
735
  });
@@ -739,7 +739,7 @@ var require_polyfills = __commonJS({
739
739
  if (!orig) return orig;
740
740
  return function(target, mode) {
741
741
  try {
742
- return orig.call(fs21, target, mode);
742
+ return orig.call(fs17, target, mode);
743
743
  } catch (er) {
744
744
  if (!chownErOk(er)) throw er;
745
745
  }
@@ -748,7 +748,7 @@ var require_polyfills = __commonJS({
748
748
  function chownFix(orig) {
749
749
  if (!orig) return orig;
750
750
  return function(target, uid, gid, cb) {
751
- return orig.call(fs21, target, uid, gid, function(er) {
751
+ return orig.call(fs17, target, uid, gid, function(er) {
752
752
  if (chownErOk(er)) er = null;
753
753
  if (cb) cb.apply(this, arguments);
754
754
  });
@@ -758,7 +758,7 @@ var require_polyfills = __commonJS({
758
758
  if (!orig) return orig;
759
759
  return function(target, uid, gid) {
760
760
  try {
761
- return orig.call(fs21, target, uid, gid);
761
+ return orig.call(fs17, target, uid, gid);
762
762
  } catch (er) {
763
763
  if (!chownErOk(er)) throw er;
764
764
  }
@@ -778,13 +778,13 @@ var require_polyfills = __commonJS({
778
778
  }
779
779
  if (cb) cb.apply(this, arguments);
780
780
  }
781
- return options ? orig.call(fs21, target, options, callback) : orig.call(fs21, target, callback);
781
+ return options ? orig.call(fs17, target, options, callback) : orig.call(fs17, target, callback);
782
782
  };
783
783
  }
784
784
  function statFixSync(orig) {
785
785
  if (!orig) return orig;
786
786
  return function(target, options) {
787
- var stats = options ? orig.call(fs21, target, options) : orig.call(fs21, target);
787
+ var stats = options ? orig.call(fs17, target, options) : orig.call(fs17, target);
788
788
  if (stats) {
789
789
  if (stats.uid < 0) stats.uid += 4294967296;
790
790
  if (stats.gid < 0) stats.gid += 4294967296;
@@ -813,16 +813,16 @@ var require_legacy_streams = __commonJS({
813
813
  "../../node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
814
814
  var Stream = require("stream").Stream;
815
815
  module2.exports = legacy;
816
- function legacy(fs21) {
816
+ function legacy(fs17) {
817
817
  return {
818
818
  ReadStream,
819
819
  WriteStream
820
820
  };
821
- function ReadStream(path28, options) {
822
- if (!(this instanceof ReadStream)) return new ReadStream(path28, options);
821
+ function ReadStream(path25, options) {
822
+ if (!(this instanceof ReadStream)) return new ReadStream(path25, options);
823
823
  Stream.call(this);
824
824
  var self = this;
825
- this.path = path28;
825
+ this.path = path25;
826
826
  this.fd = null;
827
827
  this.readable = true;
828
828
  this.paused = false;
@@ -856,7 +856,7 @@ var require_legacy_streams = __commonJS({
856
856
  });
857
857
  return;
858
858
  }
859
- fs21.open(this.path, this.flags, this.mode, function(err, fd) {
859
+ fs17.open(this.path, this.flags, this.mode, function(err, fd) {
860
860
  if (err) {
861
861
  self.emit("error", err);
862
862
  self.readable = false;
@@ -867,10 +867,10 @@ var require_legacy_streams = __commonJS({
867
867
  self._read();
868
868
  });
869
869
  }
870
- function WriteStream(path28, options) {
871
- if (!(this instanceof WriteStream)) return new WriteStream(path28, options);
870
+ function WriteStream(path25, options) {
871
+ if (!(this instanceof WriteStream)) return new WriteStream(path25, options);
872
872
  Stream.call(this);
873
- this.path = path28;
873
+ this.path = path25;
874
874
  this.fd = null;
875
875
  this.writable = true;
876
876
  this.flags = "w";
@@ -895,7 +895,7 @@ var require_legacy_streams = __commonJS({
895
895
  this.busy = false;
896
896
  this._queue = [];
897
897
  if (this.fd === null) {
898
- this._open = fs21.open;
898
+ this._open = fs17.open;
899
899
  this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
900
900
  this.flush();
901
901
  }
@@ -930,7 +930,7 @@ var require_clone = __commonJS({
930
930
  // ../../node_modules/graceful-fs/graceful-fs.js
931
931
  var require_graceful_fs = __commonJS({
932
932
  "../../node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
933
- var fs21 = require("fs");
933
+ var fs17 = require("fs");
934
934
  var polyfills = require_polyfills();
935
935
  var legacy = require_legacy_streams();
936
936
  var clone = require_clone();
@@ -962,12 +962,12 @@ var require_graceful_fs = __commonJS({
962
962
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
963
963
  console.error(m);
964
964
  };
965
- if (!fs21[gracefulQueue]) {
965
+ if (!fs17[gracefulQueue]) {
966
966
  queue = global[gracefulQueue] || [];
967
- publishQueue(fs21, queue);
968
- fs21.close = (function(fs$close) {
967
+ publishQueue(fs17, queue);
968
+ fs17.close = (function(fs$close) {
969
969
  function close(fd, cb) {
970
- return fs$close.call(fs21, fd, function(err) {
970
+ return fs$close.call(fs17, fd, function(err) {
971
971
  if (!err) {
972
972
  resetQueue();
973
973
  }
@@ -979,48 +979,48 @@ var require_graceful_fs = __commonJS({
979
979
  value: fs$close
980
980
  });
981
981
  return close;
982
- })(fs21.close);
983
- fs21.closeSync = (function(fs$closeSync) {
982
+ })(fs17.close);
983
+ fs17.closeSync = (function(fs$closeSync) {
984
984
  function closeSync2(fd) {
985
- fs$closeSync.apply(fs21, arguments);
985
+ fs$closeSync.apply(fs17, arguments);
986
986
  resetQueue();
987
987
  }
988
988
  Object.defineProperty(closeSync2, previousSymbol, {
989
989
  value: fs$closeSync
990
990
  });
991
991
  return closeSync2;
992
- })(fs21.closeSync);
992
+ })(fs17.closeSync);
993
993
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
994
994
  process.on("exit", function() {
995
- debug(fs21[gracefulQueue]);
996
- require("assert").equal(fs21[gracefulQueue].length, 0);
995
+ debug(fs17[gracefulQueue]);
996
+ require("assert").equal(fs17[gracefulQueue].length, 0);
997
997
  });
998
998
  }
999
999
  }
1000
1000
  var queue;
1001
1001
  if (!global[gracefulQueue]) {
1002
- publishQueue(global, fs21[gracefulQueue]);
1003
- }
1004
- module2.exports = patch(clone(fs21));
1005
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs21.__patched) {
1006
- module2.exports = patch(fs21);
1007
- fs21.__patched = true;
1008
- }
1009
- function patch(fs22) {
1010
- polyfills(fs22);
1011
- fs22.gracefulify = patch;
1012
- fs22.createReadStream = createReadStream;
1013
- fs22.createWriteStream = createWriteStream;
1014
- var fs$readFile = fs22.readFile;
1015
- fs22.readFile = readFile;
1016
- function readFile(path28, options, cb) {
1002
+ publishQueue(global, fs17[gracefulQueue]);
1003
+ }
1004
+ module2.exports = patch(clone(fs17));
1005
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs17.__patched) {
1006
+ module2.exports = patch(fs17);
1007
+ fs17.__patched = true;
1008
+ }
1009
+ function patch(fs18) {
1010
+ polyfills(fs18);
1011
+ fs18.gracefulify = patch;
1012
+ fs18.createReadStream = createReadStream;
1013
+ fs18.createWriteStream = createWriteStream;
1014
+ var fs$readFile = fs18.readFile;
1015
+ fs18.readFile = readFile;
1016
+ function readFile(path25, options, cb) {
1017
1017
  if (typeof options === "function")
1018
1018
  cb = options, options = null;
1019
- return go$readFile(path28, options, cb);
1020
- function go$readFile(path29, options2, cb2, startTime) {
1021
- return fs$readFile(path29, options2, function(err) {
1019
+ return go$readFile(path25, options, cb);
1020
+ function go$readFile(path26, options2, cb2, startTime) {
1021
+ return fs$readFile(path26, options2, function(err) {
1022
1022
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
1023
- enqueue([go$readFile, [path29, options2, cb2], err, startTime || Date.now(), Date.now()]);
1023
+ enqueue([go$readFile, [path26, options2, cb2], err, startTime || Date.now(), Date.now()]);
1024
1024
  else {
1025
1025
  if (typeof cb2 === "function")
1026
1026
  cb2.apply(this, arguments);
@@ -1028,16 +1028,16 @@ var require_graceful_fs = __commonJS({
1028
1028
  });
1029
1029
  }
1030
1030
  }
1031
- var fs$writeFile = fs22.writeFile;
1032
- fs22.writeFile = writeFile;
1033
- function writeFile(path28, data, options, cb) {
1031
+ var fs$writeFile = fs18.writeFile;
1032
+ fs18.writeFile = writeFile;
1033
+ function writeFile(path25, data, options, cb) {
1034
1034
  if (typeof options === "function")
1035
1035
  cb = options, options = null;
1036
- return go$writeFile(path28, data, options, cb);
1037
- function go$writeFile(path29, data2, options2, cb2, startTime) {
1038
- return fs$writeFile(path29, data2, options2, function(err) {
1036
+ return go$writeFile(path25, data, options, cb);
1037
+ function go$writeFile(path26, data2, options2, cb2, startTime) {
1038
+ return fs$writeFile(path26, data2, options2, function(err) {
1039
1039
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
1040
- enqueue([go$writeFile, [path29, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
1040
+ enqueue([go$writeFile, [path26, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
1041
1041
  else {
1042
1042
  if (typeof cb2 === "function")
1043
1043
  cb2.apply(this, arguments);
@@ -1045,17 +1045,17 @@ var require_graceful_fs = __commonJS({
1045
1045
  });
1046
1046
  }
1047
1047
  }
1048
- var fs$appendFile = fs22.appendFile;
1048
+ var fs$appendFile = fs18.appendFile;
1049
1049
  if (fs$appendFile)
1050
- fs22.appendFile = appendFile;
1051
- function appendFile(path28, data, options, cb) {
1050
+ fs18.appendFile = appendFile;
1051
+ function appendFile(path25, data, options, cb) {
1052
1052
  if (typeof options === "function")
1053
1053
  cb = options, options = null;
1054
- return go$appendFile(path28, data, options, cb);
1055
- function go$appendFile(path29, data2, options2, cb2, startTime) {
1056
- return fs$appendFile(path29, data2, options2, function(err) {
1054
+ return go$appendFile(path25, data, options, cb);
1055
+ function go$appendFile(path26, data2, options2, cb2, startTime) {
1056
+ return fs$appendFile(path26, data2, options2, function(err) {
1057
1057
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
1058
- enqueue([go$appendFile, [path29, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
1058
+ enqueue([go$appendFile, [path26, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
1059
1059
  else {
1060
1060
  if (typeof cb2 === "function")
1061
1061
  cb2.apply(this, arguments);
@@ -1063,9 +1063,9 @@ var require_graceful_fs = __commonJS({
1063
1063
  });
1064
1064
  }
1065
1065
  }
1066
- var fs$copyFile = fs22.copyFile;
1066
+ var fs$copyFile = fs18.copyFile;
1067
1067
  if (fs$copyFile)
1068
- fs22.copyFile = copyFile;
1068
+ fs18.copyFile = copyFile;
1069
1069
  function copyFile(src, dest, flags, cb) {
1070
1070
  if (typeof flags === "function") {
1071
1071
  cb = flags;
@@ -1083,34 +1083,34 @@ var require_graceful_fs = __commonJS({
1083
1083
  });
1084
1084
  }
1085
1085
  }
1086
- var fs$readdir = fs22.readdir;
1087
- fs22.readdir = readdir;
1086
+ var fs$readdir = fs18.readdir;
1087
+ fs18.readdir = readdir;
1088
1088
  var noReaddirOptionVersions = /^v[0-5]\./;
1089
- function readdir(path28, options, cb) {
1089
+ function readdir(path25, options, cb) {
1090
1090
  if (typeof options === "function")
1091
1091
  cb = options, options = null;
1092
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path29, options2, cb2, startTime) {
1093
- return fs$readdir(path29, fs$readdirCallback(
1094
- path29,
1092
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path26, options2, cb2, startTime) {
1093
+ return fs$readdir(path26, fs$readdirCallback(
1094
+ path26,
1095
1095
  options2,
1096
1096
  cb2,
1097
1097
  startTime
1098
1098
  ));
1099
- } : function go$readdir2(path29, options2, cb2, startTime) {
1100
- return fs$readdir(path29, options2, fs$readdirCallback(
1101
- path29,
1099
+ } : function go$readdir2(path26, options2, cb2, startTime) {
1100
+ return fs$readdir(path26, options2, fs$readdirCallback(
1101
+ path26,
1102
1102
  options2,
1103
1103
  cb2,
1104
1104
  startTime
1105
1105
  ));
1106
1106
  };
1107
- return go$readdir(path28, options, cb);
1108
- function fs$readdirCallback(path29, options2, cb2, startTime) {
1107
+ return go$readdir(path25, options, cb);
1108
+ function fs$readdirCallback(path26, options2, cb2, startTime) {
1109
1109
  return function(err, files) {
1110
1110
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
1111
1111
  enqueue([
1112
1112
  go$readdir,
1113
- [path29, options2, cb2],
1113
+ [path26, options2, cb2],
1114
1114
  err,
1115
1115
  startTime || Date.now(),
1116
1116
  Date.now()
@@ -1125,21 +1125,21 @@ var require_graceful_fs = __commonJS({
1125
1125
  }
1126
1126
  }
1127
1127
  if (process.version.substr(0, 4) === "v0.8") {
1128
- var legStreams = legacy(fs22);
1128
+ var legStreams = legacy(fs18);
1129
1129
  ReadStream = legStreams.ReadStream;
1130
1130
  WriteStream = legStreams.WriteStream;
1131
1131
  }
1132
- var fs$ReadStream = fs22.ReadStream;
1132
+ var fs$ReadStream = fs18.ReadStream;
1133
1133
  if (fs$ReadStream) {
1134
1134
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
1135
1135
  ReadStream.prototype.open = ReadStream$open;
1136
1136
  }
1137
- var fs$WriteStream = fs22.WriteStream;
1137
+ var fs$WriteStream = fs18.WriteStream;
1138
1138
  if (fs$WriteStream) {
1139
1139
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
1140
1140
  WriteStream.prototype.open = WriteStream$open;
1141
1141
  }
1142
- Object.defineProperty(fs22, "ReadStream", {
1142
+ Object.defineProperty(fs18, "ReadStream", {
1143
1143
  get: function() {
1144
1144
  return ReadStream;
1145
1145
  },
@@ -1149,7 +1149,7 @@ var require_graceful_fs = __commonJS({
1149
1149
  enumerable: true,
1150
1150
  configurable: true
1151
1151
  });
1152
- Object.defineProperty(fs22, "WriteStream", {
1152
+ Object.defineProperty(fs18, "WriteStream", {
1153
1153
  get: function() {
1154
1154
  return WriteStream;
1155
1155
  },
@@ -1160,7 +1160,7 @@ var require_graceful_fs = __commonJS({
1160
1160
  configurable: true
1161
1161
  });
1162
1162
  var FileReadStream = ReadStream;
1163
- Object.defineProperty(fs22, "FileReadStream", {
1163
+ Object.defineProperty(fs18, "FileReadStream", {
1164
1164
  get: function() {
1165
1165
  return FileReadStream;
1166
1166
  },
@@ -1171,7 +1171,7 @@ var require_graceful_fs = __commonJS({
1171
1171
  configurable: true
1172
1172
  });
1173
1173
  var FileWriteStream = WriteStream;
1174
- Object.defineProperty(fs22, "FileWriteStream", {
1174
+ Object.defineProperty(fs18, "FileWriteStream", {
1175
1175
  get: function() {
1176
1176
  return FileWriteStream;
1177
1177
  },
@@ -1181,7 +1181,7 @@ var require_graceful_fs = __commonJS({
1181
1181
  enumerable: true,
1182
1182
  configurable: true
1183
1183
  });
1184
- function ReadStream(path28, options) {
1184
+ function ReadStream(path25, options) {
1185
1185
  if (this instanceof ReadStream)
1186
1186
  return fs$ReadStream.apply(this, arguments), this;
1187
1187
  else
@@ -1201,7 +1201,7 @@ var require_graceful_fs = __commonJS({
1201
1201
  }
1202
1202
  });
1203
1203
  }
1204
- function WriteStream(path28, options) {
1204
+ function WriteStream(path25, options) {
1205
1205
  if (this instanceof WriteStream)
1206
1206
  return fs$WriteStream.apply(this, arguments), this;
1207
1207
  else
@@ -1219,22 +1219,22 @@ var require_graceful_fs = __commonJS({
1219
1219
  }
1220
1220
  });
1221
1221
  }
1222
- function createReadStream(path28, options) {
1223
- return new fs22.ReadStream(path28, options);
1222
+ function createReadStream(path25, options) {
1223
+ return new fs18.ReadStream(path25, options);
1224
1224
  }
1225
- function createWriteStream(path28, options) {
1226
- return new fs22.WriteStream(path28, options);
1225
+ function createWriteStream(path25, options) {
1226
+ return new fs18.WriteStream(path25, options);
1227
1227
  }
1228
- var fs$open = fs22.open;
1229
- fs22.open = open;
1230
- function open(path28, flags, mode, cb) {
1228
+ var fs$open = fs18.open;
1229
+ fs18.open = open;
1230
+ function open(path25, flags, mode, cb) {
1231
1231
  if (typeof mode === "function")
1232
1232
  cb = mode, mode = null;
1233
- return go$open(path28, flags, mode, cb);
1234
- function go$open(path29, flags2, mode2, cb2, startTime) {
1235
- return fs$open(path29, flags2, mode2, function(err, fd) {
1233
+ return go$open(path25, flags, mode, cb);
1234
+ function go$open(path26, flags2, mode2, cb2, startTime) {
1235
+ return fs$open(path26, flags2, mode2, function(err, fd) {
1236
1236
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
1237
- enqueue([go$open, [path29, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
1237
+ enqueue([go$open, [path26, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
1238
1238
  else {
1239
1239
  if (typeof cb2 === "function")
1240
1240
  cb2.apply(this, arguments);
@@ -1242,20 +1242,20 @@ var require_graceful_fs = __commonJS({
1242
1242
  });
1243
1243
  }
1244
1244
  }
1245
- return fs22;
1245
+ return fs18;
1246
1246
  }
1247
1247
  function enqueue(elem) {
1248
1248
  debug("ENQUEUE", elem[0].name, elem[1]);
1249
- fs21[gracefulQueue].push(elem);
1249
+ fs17[gracefulQueue].push(elem);
1250
1250
  retry();
1251
1251
  }
1252
1252
  var retryTimer;
1253
1253
  function resetQueue() {
1254
1254
  var now = Date.now();
1255
- for (var i = 0; i < fs21[gracefulQueue].length; ++i) {
1256
- if (fs21[gracefulQueue][i].length > 2) {
1257
- fs21[gracefulQueue][i][3] = now;
1258
- fs21[gracefulQueue][i][4] = now;
1255
+ for (var i = 0; i < fs17[gracefulQueue].length; ++i) {
1256
+ if (fs17[gracefulQueue][i].length > 2) {
1257
+ fs17[gracefulQueue][i][3] = now;
1258
+ fs17[gracefulQueue][i][4] = now;
1259
1259
  }
1260
1260
  }
1261
1261
  retry();
@@ -1263,9 +1263,9 @@ var require_graceful_fs = __commonJS({
1263
1263
  function retry() {
1264
1264
  clearTimeout(retryTimer);
1265
1265
  retryTimer = void 0;
1266
- if (fs21[gracefulQueue].length === 0)
1266
+ if (fs17[gracefulQueue].length === 0)
1267
1267
  return;
1268
- var elem = fs21[gracefulQueue].shift();
1268
+ var elem = fs17[gracefulQueue].shift();
1269
1269
  var fn = elem[0];
1270
1270
  var args = elem[1];
1271
1271
  var err = elem[2];
@@ -1287,7 +1287,7 @@ var require_graceful_fs = __commonJS({
1287
1287
  debug("RETRY", fn.name, args);
1288
1288
  fn.apply(null, args.concat([startTime]));
1289
1289
  } else {
1290
- fs21[gracefulQueue].push(elem);
1290
+ fs17[gracefulQueue].push(elem);
1291
1291
  }
1292
1292
  }
1293
1293
  if (retryTimer === void 0) {
@@ -1722,10 +1722,10 @@ var require_mtime_precision = __commonJS({
1722
1722
  "../../node_modules/proper-lockfile/lib/mtime-precision.js"(exports2, module2) {
1723
1723
  "use strict";
1724
1724
  var cacheSymbol = /* @__PURE__ */ Symbol();
1725
- function probe(file, fs21, callback) {
1726
- const cachedPrecision = fs21[cacheSymbol];
1725
+ function probe(file, fs17, callback) {
1726
+ const cachedPrecision = fs17[cacheSymbol];
1727
1727
  if (cachedPrecision) {
1728
- return fs21.stat(file, (err, stat) => {
1728
+ return fs17.stat(file, (err, stat) => {
1729
1729
  if (err) {
1730
1730
  return callback(err);
1731
1731
  }
@@ -1733,16 +1733,16 @@ var require_mtime_precision = __commonJS({
1733
1733
  });
1734
1734
  }
1735
1735
  const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
1736
- fs21.utimes(file, mtime, mtime, (err) => {
1736
+ fs17.utimes(file, mtime, mtime, (err) => {
1737
1737
  if (err) {
1738
1738
  return callback(err);
1739
1739
  }
1740
- fs21.stat(file, (err2, stat) => {
1740
+ fs17.stat(file, (err2, stat) => {
1741
1741
  if (err2) {
1742
1742
  return callback(err2);
1743
1743
  }
1744
1744
  const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
1745
- Object.defineProperty(fs21, cacheSymbol, { value: precision });
1745
+ Object.defineProperty(fs17, cacheSymbol, { value: precision });
1746
1746
  callback(null, stat.mtime, precision);
1747
1747
  });
1748
1748
  });
@@ -1763,8 +1763,8 @@ var require_mtime_precision = __commonJS({
1763
1763
  var require_lockfile = __commonJS({
1764
1764
  "../../node_modules/proper-lockfile/lib/lockfile.js"(exports2, module2) {
1765
1765
  "use strict";
1766
- var path28 = require("path");
1767
- var fs21 = require_graceful_fs();
1766
+ var path25 = require("path");
1767
+ var fs17 = require_graceful_fs();
1768
1768
  var retry = require_retry2();
1769
1769
  var onExit = require_signal_exit();
1770
1770
  var mtimePrecision = require_mtime_precision();
@@ -1774,7 +1774,7 @@ var require_lockfile = __commonJS({
1774
1774
  }
1775
1775
  function resolveCanonicalPath(file, options, callback) {
1776
1776
  if (!options.realpath) {
1777
- return callback(null, path28.resolve(file));
1777
+ return callback(null, path25.resolve(file));
1778
1778
  }
1779
1779
  options.fs.realpath(file, callback);
1780
1780
  }
@@ -1895,7 +1895,7 @@ var require_lockfile = __commonJS({
1895
1895
  update: null,
1896
1896
  realpath: true,
1897
1897
  retries: 0,
1898
- fs: fs21,
1898
+ fs: fs17,
1899
1899
  onCompromised: (err) => {
1900
1900
  throw err;
1901
1901
  },
@@ -1939,7 +1939,7 @@ var require_lockfile = __commonJS({
1939
1939
  }
1940
1940
  function unlock(file, options, callback) {
1941
1941
  options = {
1942
- fs: fs21,
1942
+ fs: fs17,
1943
1943
  realpath: true,
1944
1944
  ...options
1945
1945
  };
@@ -1961,7 +1961,7 @@ var require_lockfile = __commonJS({
1961
1961
  options = {
1962
1962
  stale: 1e4,
1963
1963
  realpath: true,
1964
- fs: fs21,
1964
+ fs: fs17,
1965
1965
  ...options
1966
1966
  };
1967
1967
  options.stale = Math.max(options.stale || 0, 2e3);
@@ -2000,16 +2000,16 @@ var require_lockfile = __commonJS({
2000
2000
  var require_adapter = __commonJS({
2001
2001
  "../../node_modules/proper-lockfile/lib/adapter.js"(exports2, module2) {
2002
2002
  "use strict";
2003
- var fs21 = require_graceful_fs();
2004
- function createSyncFs(fs22) {
2003
+ var fs17 = require_graceful_fs();
2004
+ function createSyncFs(fs18) {
2005
2005
  const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
2006
- const newFs = { ...fs22 };
2006
+ const newFs = { ...fs18 };
2007
2007
  methods.forEach((method) => {
2008
2008
  newFs[method] = (...args) => {
2009
2009
  const callback = args.pop();
2010
2010
  let ret;
2011
2011
  try {
2012
- ret = fs22[`${method}Sync`](...args);
2012
+ ret = fs18[`${method}Sync`](...args);
2013
2013
  } catch (err) {
2014
2014
  return callback(err);
2015
2015
  }
@@ -2047,7 +2047,7 @@ var require_adapter = __commonJS({
2047
2047
  }
2048
2048
  function toSyncOptions(options) {
2049
2049
  options = { ...options };
2050
- options.fs = createSyncFs(options.fs || fs21);
2050
+ options.fs = createSyncFs(options.fs || fs17);
2051
2051
  if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
2052
2052
  throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
2053
2053
  }
@@ -2675,7 +2675,7 @@ var require_age_encryption = __commonJS({
2675
2675
  };
2676
2676
  }
2677
2677
  // @__NO_SIDE_EFFECTS__
2678
- function join21(separator = "") {
2678
+ function join18(separator = "") {
2679
2679
  astr("join", separator);
2680
2680
  return {
2681
2681
  encode: (from) => {
@@ -2805,9 +2805,9 @@ var require_age_encryption = __commonJS({
2805
2805
  decode(s) {
2806
2806
  return decodeBase64Builtin(s, false);
2807
2807
  }
2808
- } : /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ padding(6), /* @__PURE__ */ join21(""));
2809
- var base64nopad = /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ join21(""));
2810
- var BECH_ALPHABET = /* @__PURE__ */ chain(/* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ join21(""));
2808
+ } : /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ padding(6), /* @__PURE__ */ join18(""));
2809
+ var base64nopad = /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ join18(""));
2810
+ var BECH_ALPHABET = /* @__PURE__ */ chain(/* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ join18(""));
2811
2811
  var POLYMOD_GENERATORS = [996825010, 642813549, 513874426, 1027748829, 705979059];
2812
2812
  function bech32Polymod(pre) {
2813
2813
  const b = pre >> 25;
@@ -8988,9 +8988,7 @@ __export(index_exports, {
8988
8988
  CLEF_SUPPORTED_EXTENSIONS: () => CLEF_SUPPORTED_EXTENSIONS,
8989
8989
  ClefError: () => ClefError,
8990
8990
  CloudApiError: () => CloudApiError,
8991
- CloudArtifactClient: () => CloudArtifactClient,
8992
8991
  CloudClient: () => CloudClient,
8993
- CloudPackClient: () => CloudPackClient,
8994
8992
  ConsumptionClient: () => ConsumptionClient,
8995
8993
  DiffEngine: () => DiffEngine,
8996
8994
  DriftDetector: () => DriftDetector,
@@ -9022,6 +9020,7 @@ __export(index_exports, {
9022
9020
  SopsMissingError: () => SopsMissingError,
9023
9021
  SopsVersionError: () => SopsVersionError,
9024
9022
  StructureManager: () => StructureManager,
9023
+ SyncManager: () => SyncManager,
9025
9024
  TransactionLockError: () => TransactionLockError,
9026
9025
  TransactionManager: () => TransactionManager,
9027
9026
  TransactionPreflightError: () => TransactionPreflightError,
@@ -9042,7 +9041,6 @@ __export(index_exports, {
9042
9041
  generateRandomValue: () => generateRandomValue,
9043
9042
  generateSigningKeyPair: () => generateSigningKeyPair,
9044
9043
  getPendingKeys: () => getPendingKeys,
9045
- initiateDeviceFlow: () => initiateDeviceFlow,
9046
9044
  isHighEntropy: () => isHighEntropy,
9047
9045
  isKmsEnvelope: () => isKmsEnvelope,
9048
9046
  isPending: () => isPending,
@@ -9060,17 +9058,13 @@ __export(index_exports, {
9060
9058
  parseIgnoreContent: () => parseIgnoreContent,
9061
9059
  parseJson: () => parseJson,
9062
9060
  parseYaml: () => parseYaml,
9063
- pollDeviceFlow: () => pollDeviceFlow,
9064
- readCloudCredentials: () => readCloudCredentials,
9065
9061
  readManifestYaml: () => readManifestYaml,
9066
9062
  redactValue: () => redactValue,
9067
9063
  removeAccessRequest: () => removeRequest,
9068
9064
  requestsFilePath: () => requestsFilePath,
9069
- resetKeyserviceResolution: () => resetKeyserviceResolution,
9070
9065
  resetSopsResolution: () => resetSopsResolution,
9071
9066
  resolveBackendConfig: () => resolveBackendConfig,
9072
9067
  resolveIdentitySecrets: () => resolveIdentitySecrets,
9073
- resolveKeyservicePath: () => resolveKeyservicePath,
9074
9068
  resolveRecipientsForEnvironment: () => resolveRecipientsForEnvironment,
9075
9069
  resolveSopsPath: () => resolveSopsPath,
9076
9070
  saveMetadata: () => saveMetadata,
@@ -9080,12 +9074,10 @@ __export(index_exports, {
9080
9074
  shouldIgnoreMatch: () => shouldIgnoreMatch,
9081
9075
  signEd25519: () => signEd25519,
9082
9076
  signKms: () => signKms,
9083
- spawnKeyservice: () => spawnKeyservice,
9084
9077
  upsertRequest: () => upsertRequest,
9085
9078
  validateAgePublicKey: () => validateAgePublicKey,
9086
9079
  validateResetScope: () => validateResetScope,
9087
9080
  verifySignature: () => verifySignature,
9088
- writeCloudCredentials: () => writeCloudCredentials,
9089
9081
  writeManifestYaml: () => writeManifestYaml,
9090
9082
  writeManifestYamlRaw: () => writeManifestYamlRaw
9091
9083
  });
@@ -9241,15 +9233,14 @@ function keyPreview(key) {
9241
9233
 
9242
9234
  // src/manifest/parser.ts
9243
9235
  var CLEF_MANIFEST_FILENAME = "clef.yaml";
9244
- var VALID_BACKENDS = ["age", "awskms", "gcpkms", "azurekv", "pgp", "cloud"];
9236
+ var VALID_BACKENDS = ["age", "awskms", "gcpkms", "azurekv", "pgp"];
9245
9237
  var VALID_TOP_LEVEL_KEYS = [
9246
9238
  "version",
9247
9239
  "environments",
9248
9240
  "namespaces",
9249
9241
  "sops",
9250
9242
  "file_pattern",
9251
- "service_identities",
9252
- "cloud"
9243
+ "service_identities"
9253
9244
  ];
9254
9245
  var ENV_NAME_PATTERN = /^[a-z][a-z0-9_-]*$/;
9255
9246
  var FILE_PATTERN_REQUIRED_TOKENS = ["{namespace}", "{environment}"];
@@ -9752,47 +9743,13 @@ var ManifestParser = class {
9752
9743
  siNames.add(si.name);
9753
9744
  }
9754
9745
  }
9755
- let cloud;
9756
- if (obj.cloud !== void 0) {
9757
- if (typeof obj.cloud !== "object" || obj.cloud === null || Array.isArray(obj.cloud)) {
9758
- throw new ManifestValidationError("Field 'cloud' must be an object.", "cloud");
9759
- }
9760
- const cloudObj = obj.cloud;
9761
- if (typeof cloudObj.integrationId !== "string" || cloudObj.integrationId.length === 0) {
9762
- throw new ManifestValidationError(
9763
- "Field 'cloud.integrationId' is required and must be a non-empty string.",
9764
- "cloud"
9765
- );
9766
- }
9767
- if (typeof cloudObj.keyId !== "string" || cloudObj.keyId.length === 0) {
9768
- throw new ManifestValidationError(
9769
- "Field 'cloud.keyId' is required and must be a non-empty string.",
9770
- "cloud"
9771
- );
9772
- }
9773
- if (!/^clef:[a-zA-Z0-9_]+\/[a-zA-Z0-9_-]+$/.test(cloudObj.keyId)) {
9774
- throw new ManifestValidationError(
9775
- `Field 'cloud.keyId' has invalid format '${cloudObj.keyId}'. Must match: clef:<integrationId>/<keyAlias>`,
9776
- "cloud"
9777
- );
9778
- }
9779
- cloud = { integrationId: cloudObj.integrationId, keyId: cloudObj.keyId };
9780
- }
9781
- const usesCloudBackend = sopsConfig.default_backend === "cloud" || environments.some((e) => e.sops?.backend === "cloud");
9782
- if (usesCloudBackend && !cloud) {
9783
- throw new ManifestValidationError(
9784
- "One or more environments use the 'cloud' backend but the manifest is missing the top-level 'cloud' block with 'integrationId' and 'keyId'.",
9785
- "cloud"
9786
- );
9787
- }
9788
9746
  return {
9789
9747
  version: 1,
9790
9748
  environments,
9791
9749
  namespaces,
9792
9750
  sops: sopsConfig,
9793
9751
  file_pattern: obj.file_pattern,
9794
- ...serviceIdentities ? { service_identities: serviceIdentities } : {},
9795
- ...cloud ? { cloud } : {}
9752
+ ...serviceIdentities ? { service_identities: serviceIdentities } : {}
9796
9753
  };
9797
9754
  }
9798
9755
  /**
@@ -10734,6 +10691,11 @@ var PRE_COMMIT_HOOK = `#!/bin/sh
10734
10691
  # and scans staged files for plaintext secrets.
10735
10692
  # Installed by: clef hooks install
10736
10693
 
10694
+ # Skip during TransactionManager commits (policy scaffolding, migrations, etc.)
10695
+ if [ "$CLEF_IN_TRANSACTION" = "1" ]; then
10696
+ exit 0
10697
+ fi
10698
+
10737
10699
  STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
10738
10700
  EXIT_CODE=0
10739
10701
 
@@ -11090,12 +11052,10 @@ ${mergeRule}
11090
11052
  ` : `# Clef: SOPS-aware merge driver for encrypted files
11091
11053
  ${mergeRule}
11092
11054
  `;
11093
- const writeResult = await this.runner.run("tee", [attrPath], {
11094
- stdin: newContent,
11095
- cwd: repoRoot
11096
- });
11097
- if (writeResult.exitCode !== 0) {
11098
- throw new GitOperationError(`Failed to write .gitattributes: ${writeResult.stderr.trim()}`);
11055
+ try {
11056
+ fs9.writeFileSync(attrPath, newContent, "utf-8");
11057
+ } catch (err) {
11058
+ throw new GitOperationError(`Failed to write .gitattributes: ${err.message}`);
11099
11059
  }
11100
11060
  }
11101
11061
  /**
@@ -11107,22 +11067,18 @@ ${mergeRule}
11107
11067
  */
11108
11068
  async installPreCommitHook(repoRoot) {
11109
11069
  const hookPath = path8.join(repoRoot, ".git", "hooks", "pre-commit");
11110
- const result = await this.runner.run("tee", [hookPath], {
11111
- stdin: PRE_COMMIT_HOOK,
11112
- cwd: repoRoot
11113
- });
11114
- if (result.exitCode !== 0) {
11070
+ try {
11071
+ const hooksDir = path8.dirname(hookPath);
11072
+ if (!fs9.existsSync(hooksDir)) {
11073
+ fs9.mkdirSync(hooksDir, { recursive: true });
11074
+ }
11075
+ fs9.writeFileSync(hookPath, PRE_COMMIT_HOOK, { mode: 493 });
11076
+ } catch (err) {
11115
11077
  throw new GitOperationError(
11116
- `Failed to install pre-commit hook: ${result.stderr.trim()}`,
11078
+ `Failed to install pre-commit hook: ${err.message}`,
11117
11079
  "Ensure .git/hooks/ directory exists."
11118
11080
  );
11119
11081
  }
11120
- const chmodResult = await this.runner.run("chmod", ["+x", hookPath], { cwd: repoRoot });
11121
- if (chmodResult.exitCode !== 0) {
11122
- throw new GitOperationError(
11123
- `Failed to make pre-commit hook executable: ${chmodResult.stderr.trim()}`
11124
- );
11125
- }
11126
11082
  }
11127
11083
  };
11128
11084
 
@@ -11507,13 +11463,6 @@ function openWindowsInputPipe(content) {
11507
11463
  });
11508
11464
  });
11509
11465
  }
11510
- function cloudKeyToArn(keyId) {
11511
- const body = keyId.replace(/^clef:/, "");
11512
- const sep = body.indexOf("/");
11513
- const integration = sep >= 0 ? body.slice(0, sep) : body;
11514
- const env = sep >= 0 ? body.slice(sep + 1) : "default";
11515
- return `arn:aws:kms:us-east-1:000000000000:alias/clef/${integration}/${env}`;
11516
- }
11517
11466
  var SopsClient = class {
11518
11467
  /**
11519
11468
  * @param runner - Subprocess runner used to invoke the `sops` binary.
@@ -11523,18 +11472,14 @@ var SopsClient = class {
11523
11472
  * to the subprocess environment.
11524
11473
  * @param sopsPath - Optional explicit path to the sops binary. When omitted,
11525
11474
  * resolved automatically via {@link resolveSopsPath}.
11526
- * @param keyserviceAddr - Optional keyservice address (e.g. `tcp://127.0.0.1:12345`).
11527
- * When set, all SOPS invocations include `--enable-local-keyservice=false --keyservice <addr>`.
11528
11475
  */
11529
- constructor(runner, ageKeyFile, ageKey, sopsPath, keyserviceAddr) {
11476
+ constructor(runner, ageKeyFile, ageKey, sopsPath) {
11530
11477
  this.runner = runner;
11531
11478
  this.ageKeyFile = ageKeyFile;
11532
11479
  this.ageKey = ageKey;
11533
11480
  this.sopsCommand = sopsPath ?? resolveSopsPath().path;
11534
- this.keyserviceArgs = keyserviceAddr ? ["--enable-local-keyservice=false", "--keyservice", keyserviceAddr] : [];
11535
11481
  }
11536
11482
  sopsCommand;
11537
- keyserviceArgs;
11538
11483
  buildSopsEnv() {
11539
11484
  const env = {};
11540
11485
  if (this.ageKey) {
@@ -11559,7 +11504,7 @@ var SopsClient = class {
11559
11504
  const env = this.buildSopsEnv();
11560
11505
  const result = await this.runner.run(
11561
11506
  this.sopsCommand,
11562
- ["decrypt", ...this.keyserviceArgs, "--output-type", fmt, filePath],
11507
+ ["decrypt", "--output-type", fmt, filePath],
11563
11508
  {
11564
11509
  ...env ? { env } : {}
11565
11510
  }
@@ -11626,7 +11571,6 @@ var SopsClient = class {
11626
11571
  "--config",
11627
11572
  configPath,
11628
11573
  "encrypt",
11629
- ...this.keyserviceArgs,
11630
11574
  ...args,
11631
11575
  "--input-type",
11632
11576
  fmt,
@@ -11683,7 +11627,7 @@ var SopsClient = class {
11683
11627
  const env = this.buildSopsEnv();
11684
11628
  const result = await this.runner.run(
11685
11629
  this.sopsCommand,
11686
- ["rotate", ...this.keyserviceArgs, "-i", "--add-age", key, filePath],
11630
+ ["rotate", "-i", "--add-age", key, filePath],
11687
11631
  {
11688
11632
  ...env ? { env } : {}
11689
11633
  }
@@ -11707,7 +11651,7 @@ var SopsClient = class {
11707
11651
  const env = this.buildSopsEnv();
11708
11652
  const result = await this.runner.run(
11709
11653
  this.sopsCommand,
11710
- ["rotate", ...this.keyserviceArgs, "-i", "--rm-age", key, filePath],
11654
+ ["rotate", "-i", "--rm-age", key, filePath],
11711
11655
  {
11712
11656
  ...env ? { env } : {}
11713
11657
  }
@@ -11819,13 +11763,7 @@ var SopsClient = class {
11819
11763
  }
11820
11764
  detectBackend(sops) {
11821
11765
  if (sops.age && Array.isArray(sops.age) && sops.age.length > 0) return "age";
11822
- if (sops.kms && Array.isArray(sops.kms) && sops.kms.length > 0) {
11823
- const firstArn = sops.kms[0]?.arn;
11824
- if (typeof firstArn === "string" && (firstArn.startsWith("clef:") || firstArn.includes("alias/clef/"))) {
11825
- return "cloud";
11826
- }
11827
- return "awskms";
11828
- }
11766
+ if (sops.kms && Array.isArray(sops.kms) && sops.kms.length > 0) return "awskms";
11829
11767
  if (sops.gcp_kms && Array.isArray(sops.gcp_kms) && sops.gcp_kms.length > 0)
11830
11768
  return "gcpkms";
11831
11769
  if (sops.azure_kv && Array.isArray(sops.azure_kv) && sops.azure_kv.length > 0)
@@ -11839,7 +11777,6 @@ var SopsClient = class {
11839
11777
  const entries = sops.age;
11840
11778
  return entries?.map((e) => String(e.recipient ?? "")) ?? [];
11841
11779
  }
11842
- case "cloud":
11843
11780
  case "awskms": {
11844
11781
  const entries = sops.kms;
11845
11782
  return entries?.map((e) => String(e.arn ?? "")) ?? [];
@@ -11901,13 +11838,6 @@ var SopsClient = class {
11901
11838
  args.push("--pgp", config.pgp_fingerprint);
11902
11839
  }
11903
11840
  break;
11904
- case "cloud": {
11905
- const cloudKeyId = manifest.cloud?.keyId;
11906
- if (cloudKeyId) {
11907
- args.push("--kms", cloudKeyToArn(cloudKeyId));
11908
- }
11909
- break;
11910
- }
11911
11841
  }
11912
11842
  return args;
11913
11843
  }
@@ -14803,12 +14733,7 @@ var ArtifactPacker = class {
14803
14733
  };
14804
14734
 
14805
14735
  // src/kms/types.ts
14806
- var VALID_KMS_PROVIDERS = [
14807
- "aws",
14808
- "gcp",
14809
- "azure",
14810
- "cloud"
14811
- ];
14736
+ var VALID_KMS_PROVIDERS = ["aws", "gcp", "azure"];
14812
14737
 
14813
14738
  // src/migration/backend.ts
14814
14739
  var path22 = __toESM(require("path"));
@@ -14818,8 +14743,7 @@ var BACKEND_KEY_FIELDS = {
14818
14743
  awskms: "aws_kms_arn",
14819
14744
  gcpkms: "gcp_kms_resource_id",
14820
14745
  azurekv: "azure_kv_url",
14821
- pgp: "pgp_fingerprint",
14822
- cloud: void 0
14746
+ pgp: "pgp_fingerprint"
14823
14747
  };
14824
14748
  var ALL_KEY_FIELDS = Object.values(BACKEND_KEY_FIELDS).filter(
14825
14749
  (v) => v !== void 0
@@ -15014,18 +14938,6 @@ var BackendMigrator = class {
15014
14938
  sops[keyField] = target.key;
15015
14939
  }
15016
14940
  }
15017
- if (doc.cloud && target.backend !== "cloud") {
15018
- const sops = doc.sops;
15019
- const environments = doc.environments;
15020
- const defaultIsCloud = sops.default_backend === "cloud";
15021
- const anyEnvIsCloud = environments.some((e) => {
15022
- const envSops = e.sops;
15023
- return envSops?.backend === "cloud";
15024
- });
15025
- if (!defaultIsCloud && !anyEnvIsCloud) {
15026
- delete doc.cloud;
15027
- }
15028
- }
15029
14941
  }
15030
14942
  checkAgeRecipientsWarning(manifest, target, environment, warnings) {
15031
14943
  if (target.backend === "age") return;
@@ -15234,281 +15146,111 @@ function withBackendOverride(manifest, envNames, backend, key) {
15234
15146
  };
15235
15147
  }
15236
15148
 
15237
- // src/cloud/keyservice.ts
15238
- var import_child_process = require("child_process");
15239
- var readline = __toESM(require("readline"));
15240
- var PORT_REGEX = /^PORT=(\d+)$/;
15241
- var STARTUP_TIMEOUT_MS = 5e3;
15242
- var SHUTDOWN_TIMEOUT_MS = 3e3;
15243
- async function spawnKeyservice(options) {
15244
- const args = ["--addr", "127.0.0.1:0"];
15245
- if (options.endpoint) {
15246
- args.push("--endpoint", options.endpoint);
15247
- }
15248
- const child = (0, import_child_process.spawn)(options.binaryPath, args, {
15249
- stdio: ["ignore", "pipe", "pipe"],
15250
- env: { ...process.env, CLEF_CLOUD_TOKEN: options.token }
15251
- });
15252
- const port = await readPort(child);
15253
- const addr = `tcp://127.0.0.1:${port}`;
15254
- return {
15255
- addr,
15256
- kill: () => killGracefully(child)
15257
- };
15258
- }
15259
- function readPort(child) {
15260
- return new Promise((resolve, reject) => {
15261
- let settled = false;
15262
- const rl = readline.createInterface({ input: child.stdout });
15263
- function settle() {
15264
- clearTimeout(timer);
15265
- rl.close();
15266
- }
15267
- const timer = setTimeout(() => {
15268
- if (!settled) {
15269
- settled = true;
15270
- settle();
15271
- child.kill("SIGKILL");
15272
- reject(new Error("Keyservice did not start within 5 seconds."));
15273
- }
15274
- }, STARTUP_TIMEOUT_MS);
15275
- rl.on("line", (line) => {
15276
- const match = PORT_REGEX.exec(line);
15277
- if (match && !settled) {
15278
- settled = true;
15279
- settle();
15280
- resolve(parseInt(match[1], 10));
15149
+ // src/sync/manager.ts
15150
+ var path24 = __toESM(require("path"));
15151
+ var SyncManager = class {
15152
+ constructor(matrixManager, encryption, tx) {
15153
+ this.matrixManager = matrixManager;
15154
+ this.encryption = encryption;
15155
+ this.tx = tx;
15156
+ }
15157
+ /**
15158
+ * Compute what sync would do without mutating anything.
15159
+ */
15160
+ async plan(manifest, repoRoot, opts) {
15161
+ if (opts.namespace) {
15162
+ const exists = manifest.namespaces.some((n) => n.name === opts.namespace);
15163
+ if (!exists) {
15164
+ throw new Error(`Namespace '${opts.namespace}' not found in manifest.`);
15281
15165
  }
15282
- });
15283
- child.on("error", (err) => {
15284
- if (!settled) {
15285
- settled = true;
15286
- settle();
15287
- reject(new Error(`Failed to start keyservice: ${err.message}`));
15166
+ }
15167
+ const allCells = this.matrixManager.resolveMatrix(manifest, repoRoot);
15168
+ const existingCells = allCells.filter((c) => c.exists);
15169
+ const targetCells = opts.namespace ? existingCells.filter((c) => c.namespace === opts.namespace) : existingCells;
15170
+ const keysByNsEnv = {};
15171
+ for (const cell of targetCells) {
15172
+ const keys = readSopsKeyNames(cell.filePath);
15173
+ if (!keys) continue;
15174
+ if (!keysByNsEnv[cell.namespace]) keysByNsEnv[cell.namespace] = {};
15175
+ keysByNsEnv[cell.namespace][cell.environment] = new Set(keys);
15176
+ }
15177
+ const cells = [];
15178
+ let totalKeys = 0;
15179
+ let hasProtectedEnvs = false;
15180
+ for (const [nsName, envKeys] of Object.entries(keysByNsEnv)) {
15181
+ const allKeys = /* @__PURE__ */ new Set();
15182
+ for (const keys of Object.values(envKeys)) {
15183
+ for (const k of keys) allKeys.add(k);
15288
15184
  }
15289
- });
15290
- child.on("exit", (code) => {
15291
- if (!settled) {
15292
- settled = true;
15293
- settle();
15294
- reject(new Error(`Keyservice exited unexpectedly with code ${code}.`));
15185
+ for (const cell of targetCells) {
15186
+ if (cell.namespace !== nsName) continue;
15187
+ const cellKeys = envKeys[cell.environment];
15188
+ if (!cellKeys) continue;
15189
+ const missing = [...allKeys].filter((k) => !cellKeys.has(k));
15190
+ if (missing.length === 0) continue;
15191
+ const isProtected = this.matrixManager.isProtectedEnvironment(manifest, cell.environment);
15192
+ if (isProtected) hasProtectedEnvs = true;
15193
+ cells.push({
15194
+ namespace: cell.namespace,
15195
+ environment: cell.environment,
15196
+ filePath: cell.filePath,
15197
+ missingKeys: missing.sort(),
15198
+ isProtected
15199
+ });
15200
+ totalKeys += missing.length;
15295
15201
  }
15296
- });
15297
- });
15298
- }
15299
- function killGracefully(child) {
15300
- return new Promise((resolve) => {
15301
- if (child.exitCode !== null) {
15302
- resolve();
15303
- return;
15304
- }
15305
- const timer = setTimeout(() => {
15306
- child.kill("SIGKILL");
15307
- }, SHUTDOWN_TIMEOUT_MS);
15308
- child.on("exit", () => {
15309
- clearTimeout(timer);
15310
- resolve();
15311
- });
15312
- child.kill("SIGTERM");
15313
- });
15314
- }
15315
-
15316
- // src/cloud/resolver.ts
15317
- var fs18 = __toESM(require("fs"));
15318
- var path25 = __toESM(require("path"));
15319
-
15320
- // src/cloud/bundled.ts
15321
- var fs17 = __toESM(require("fs"));
15322
- var path24 = __toESM(require("path"));
15323
- function tryBundledKeyservice() {
15324
- const platform = process.platform;
15325
- const arch = process.arch;
15326
- const archName = arch === "x64" ? "x64" : arch === "arm64" ? "arm64" : null;
15327
- if (!archName) return null;
15328
- const platformName = platform === "darwin" ? "darwin" : platform === "linux" ? "linux" : platform === "win32" ? "win32" : null;
15329
- if (!platformName) return null;
15330
- const packageName = `@clef-sh/keyservice-${platformName}-${archName}`;
15331
- const binName = platform === "win32" ? "clef-keyservice.exe" : "clef-keyservice";
15332
- try {
15333
- const packageMain = require.resolve(`${packageName}/package.json`);
15334
- const packageDir = path24.dirname(packageMain);
15335
- const binPath = path24.join(packageDir, "bin", binName);
15336
- return fs17.existsSync(binPath) ? binPath : null;
15337
- } catch {
15338
- return null;
15339
- }
15340
- }
15341
-
15342
- // src/cloud/resolver.ts
15343
- function validateKeyservicePath(candidate) {
15344
- if (!path25.isAbsolute(candidate)) {
15345
- throw new Error(`CLEF_KEYSERVICE_PATH must be an absolute path, got '${candidate}'.`);
15346
- }
15347
- const segments = candidate.split(/[/\\]/);
15348
- if (segments.includes("..")) {
15349
- throw new Error(
15350
- `CLEF_KEYSERVICE_PATH contains '..' path segments ('${candidate}'). Use an absolute path without directory traversal.`
15351
- );
15352
- }
15353
- }
15354
- var cached2;
15355
- function resolveKeyservicePath() {
15356
- if (cached2) return cached2;
15357
- const envPath = process.env.CLEF_KEYSERVICE_PATH?.trim();
15358
- if (envPath) {
15359
- validateKeyservicePath(envPath);
15360
- if (!fs18.existsSync(envPath)) {
15361
- throw new Error(`CLEF_KEYSERVICE_PATH points to '${envPath}' but the file does not exist.`);
15362
15202
  }
15363
- cached2 = { path: envPath, source: "env" };
15364
- return cached2;
15365
- }
15366
- const bundledPath = tryBundledKeyservice();
15367
- if (bundledPath) {
15368
- cached2 = { path: bundledPath, source: "bundled" };
15369
- return cached2;
15370
- }
15371
- cached2 = { path: "clef-keyservice", source: "system" };
15372
- return cached2;
15373
- }
15374
- function resetKeyserviceResolution() {
15375
- cached2 = void 0;
15376
- }
15377
-
15378
- // src/cloud/credentials.ts
15379
- var fs19 = __toESM(require("fs"));
15380
- var path26 = __toESM(require("path"));
15381
- var os = __toESM(require("os"));
15382
- var YAML11 = __toESM(require("yaml"));
15383
-
15384
- // src/cloud/constants.ts
15385
- var CLOUD_DEFAULT_ENDPOINT = "https://api.clef.sh";
15386
-
15387
- // src/cloud/credentials.ts
15388
- var CREDENTIALS_FILENAME = "credentials.yaml";
15389
- function readCloudCredentials() {
15390
- const credPath = path26.join(os.homedir(), ".clef", CREDENTIALS_FILENAME);
15391
- let raw;
15392
- try {
15393
- raw = YAML11.parse(fs19.readFileSync(credPath, "utf-8"));
15394
- } catch {
15395
- return null;
15203
+ return { cells, totalKeys, hasProtectedEnvs };
15396
15204
  }
15397
- if (!raw || typeof raw !== "object") return null;
15398
- const obj = raw;
15399
- const token = typeof obj.token === "string" && obj.token.length > 0 ? obj.token : "";
15400
- const endpoint = typeof obj.endpoint === "string" ? obj.endpoint : CLOUD_DEFAULT_ENDPOINT;
15401
- if (!token && endpoint === CLOUD_DEFAULT_ENDPOINT) return null;
15402
- return { token, endpoint };
15403
- }
15404
- function writeCloudCredentials(credentials) {
15405
- const clefDir = path26.join(os.homedir(), ".clef");
15406
- fs19.mkdirSync(clefDir, { recursive: true, mode: 448 });
15407
- const credPath = path26.join(clefDir, CREDENTIALS_FILENAME);
15408
- const content = { token: credentials.token };
15409
- if (credentials.endpoint) {
15410
- content.endpoint = credentials.endpoint;
15411
- }
15412
- fs19.writeFileSync(credPath, YAML11.stringify(content), { mode: 384 });
15413
- }
15414
-
15415
- // src/cloud/device-flow.ts
15416
- async function initiateDeviceFlow(endpoint, options) {
15417
- const base = endpoint ?? CLOUD_DEFAULT_ENDPOINT;
15418
- const payload = {
15419
- clientType: "cli",
15420
- clientVersion: options.clientVersion,
15421
- repoName: options.repoName,
15422
- flow: options.flow
15423
- };
15424
- if (options.environment) {
15425
- payload.environment = options.environment;
15426
- }
15427
- const res = await fetch(`${base}/api/v1/device/init`, {
15428
- method: "POST",
15429
- headers: { "Content-Type": "application/json" },
15430
- body: JSON.stringify(payload)
15431
- });
15432
- if (!res.ok) {
15433
- const body = await res.text().catch(() => "");
15434
- throw new Error(`Device flow init failed (${res.status}): ${body}`);
15435
- }
15436
- const json = await res.json();
15437
- const session = json.data ?? json;
15438
- if (session.pollUrl && !session.pollUrl.startsWith("http")) {
15439
- session.pollUrl = `${base}${session.pollUrl}`;
15440
- }
15441
- return session;
15442
- }
15443
- async function pollDeviceFlow(pollUrl) {
15444
- const res = await fetch(pollUrl);
15445
- if (!res.ok) {
15446
- const body = await res.text().catch(() => "");
15447
- throw new Error(`Device flow poll failed (${res.status}): ${body}`);
15448
- }
15449
- const json = await res.json();
15450
- return json.data ?? json;
15451
- }
15452
-
15453
- // src/cloud/pack-client.ts
15454
- var fs20 = __toESM(require("fs"));
15455
- var path27 = __toESM(require("path"));
15456
- var CloudPackClient = class {
15457
- endpoint;
15458
- constructor(endpoint) {
15459
- this.endpoint = endpoint ?? CLOUD_DEFAULT_ENDPOINT;
15460
- }
15461
- async pack(token, config) {
15462
- const matrixManager = new MatrixManager();
15463
- const cells = matrixManager.resolveMatrix(config.manifest, config.repoRoot).filter((c) => c.environment === config.environment && c.exists);
15464
- const formData = new FormData();
15465
- const configJson = JSON.stringify({
15466
- identity: config.identity,
15467
- environment: config.environment,
15468
- ...config.ttl ? { ttl: config.ttl } : {}
15469
- });
15470
- formData.append("config", new Blob([configJson], { type: "application/json" }));
15471
- const manifestPath = path27.join(config.repoRoot, "clef.yaml");
15472
- const manifestContent = fs20.readFileSync(manifestPath, "utf-8");
15473
- formData.append("manifest", new Blob([manifestContent], { type: "text/yaml" }));
15474
- for (const cell of cells) {
15475
- const relPath = path27.relative(config.repoRoot, cell.filePath);
15476
- const content = fs20.readFileSync(cell.filePath, "utf-8");
15477
- formData.append(`files`, new Blob([content], { type: "text/yaml" }), relPath);
15478
- }
15479
- const res = await fetch(`${this.endpoint}/api/v1/cloud/pack`, {
15480
- method: "POST",
15481
- headers: { Authorization: `Bearer ${token}` },
15482
- body: formData
15483
- });
15484
- if (!res.ok) {
15485
- const body = await res.text().catch(() => "");
15486
- throw new Error(`Cloud pack failed (${res.status}): ${body}`);
15205
+ /**
15206
+ * Execute the sync: scaffold missing keys with random pending values.
15207
+ *
15208
+ * Returns immediately (no-op) when the plan has nothing to do.
15209
+ * When `dryRun` is set, returns a result with zero modifications —
15210
+ * the caller can inspect the plan via {@link plan} separately.
15211
+ */
15212
+ async sync(manifest, repoRoot, opts = {}) {
15213
+ const syncPlan = await this.plan(manifest, repoRoot, opts);
15214
+ if (opts.dryRun || syncPlan.totalKeys === 0) {
15215
+ return { modifiedCells: [], scaffoldedKeys: {}, totalKeysScaffolded: 0 };
15487
15216
  }
15488
- return await res.json();
15489
- }
15490
- };
15491
- var CloudArtifactClient = class {
15492
- endpoint;
15493
- constructor(endpoint) {
15494
- this.endpoint = endpoint ?? CLOUD_DEFAULT_ENDPOINT;
15495
- }
15496
- async upload(token, config) {
15497
- const res = await fetch(
15498
- `${this.endpoint}/api/v1/cloud/artifacts/${config.identity}/${config.environment}`,
15499
- {
15500
- method: "PUT",
15501
- headers: {
15502
- Authorization: `Bearer ${token}`,
15503
- "Content-Type": "application/json"
15504
- },
15505
- body: config.artifactJson
15217
+ const txPaths = [];
15218
+ for (const cell of syncPlan.cells) {
15219
+ const rel = path24.relative(repoRoot, cell.filePath);
15220
+ txPaths.push(rel);
15221
+ txPaths.push(rel.replace(/\.enc\.(yaml|json)$/, ".clef-meta.yaml"));
15222
+ }
15223
+ const modifiedCells = [];
15224
+ const scaffoldedKeys = {};
15225
+ const nsLabel = opts.namespace ?? "all";
15226
+ const envCount = new Set(syncPlan.cells.map((c) => c.environment)).size;
15227
+ await this.tx.run(repoRoot, {
15228
+ description: `clef sync ${nsLabel}: ${syncPlan.totalKeys} key(s) across ${envCount} environment(s)`,
15229
+ paths: txPaths,
15230
+ mutate: async () => {
15231
+ for (const cell of syncPlan.cells) {
15232
+ const decrypted = await this.encryption.decrypt(cell.filePath);
15233
+ for (const key of cell.missingKeys) {
15234
+ decrypted.values[key] = generateRandomValue();
15235
+ }
15236
+ await this.encryption.encrypt(
15237
+ cell.filePath,
15238
+ decrypted.values,
15239
+ manifest,
15240
+ cell.environment
15241
+ );
15242
+ await markPendingWithRetry(cell.filePath, cell.missingKeys, "clef sync");
15243
+ const cellLabel = `${cell.namespace}/${cell.environment}`;
15244
+ modifiedCells.push(cellLabel);
15245
+ scaffoldedKeys[cellLabel] = cell.missingKeys;
15246
+ }
15506
15247
  }
15507
- );
15508
- if (!res.ok) {
15509
- const body = await res.text().catch(() => "");
15510
- throw new Error(`Artifact upload failed (${res.status}): ${body}`);
15511
- }
15248
+ });
15249
+ return {
15250
+ modifiedCells,
15251
+ scaffoldedKeys,
15252
+ totalKeysScaffolded: syncPlan.totalKeys
15253
+ };
15512
15254
  }
15513
15255
  };
15514
15256
  // Annotate the CommonJS export names for ESM import in node:
@@ -15521,9 +15263,7 @@ var CloudArtifactClient = class {
15521
15263
  CLEF_SUPPORTED_EXTENSIONS,
15522
15264
  ClefError,
15523
15265
  CloudApiError,
15524
- CloudArtifactClient,
15525
15266
  CloudClient,
15526
- CloudPackClient,
15527
15267
  ConsumptionClient,
15528
15268
  DiffEngine,
15529
15269
  DriftDetector,
@@ -15555,6 +15295,7 @@ var CloudArtifactClient = class {
15555
15295
  SopsMissingError,
15556
15296
  SopsVersionError,
15557
15297
  StructureManager,
15298
+ SyncManager,
15558
15299
  TransactionLockError,
15559
15300
  TransactionManager,
15560
15301
  TransactionPreflightError,
@@ -15575,7 +15316,6 @@ var CloudArtifactClient = class {
15575
15316
  generateRandomValue,
15576
15317
  generateSigningKeyPair,
15577
15318
  getPendingKeys,
15578
- initiateDeviceFlow,
15579
15319
  isHighEntropy,
15580
15320
  isKmsEnvelope,
15581
15321
  isPending,
@@ -15593,17 +15333,13 @@ var CloudArtifactClient = class {
15593
15333
  parseIgnoreContent,
15594
15334
  parseJson,
15595
15335
  parseYaml,
15596
- pollDeviceFlow,
15597
- readCloudCredentials,
15598
15336
  readManifestYaml,
15599
15337
  redactValue,
15600
15338
  removeAccessRequest,
15601
15339
  requestsFilePath,
15602
- resetKeyserviceResolution,
15603
15340
  resetSopsResolution,
15604
15341
  resolveBackendConfig,
15605
15342
  resolveIdentitySecrets,
15606
- resolveKeyservicePath,
15607
15343
  resolveRecipientsForEnvironment,
15608
15344
  resolveSopsPath,
15609
15345
  saveMetadata,
@@ -15613,12 +15349,10 @@ var CloudArtifactClient = class {
15613
15349
  shouldIgnoreMatch,
15614
15350
  signEd25519,
15615
15351
  signKms,
15616
- spawnKeyservice,
15617
15352
  upsertRequest,
15618
15353
  validateAgePublicKey,
15619
15354
  validateResetScope,
15620
15355
  verifySignature,
15621
- writeCloudCredentials,
15622
15356
  writeManifestYaml,
15623
15357
  writeManifestYamlRaw
15624
15358
  });