@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.mjs CHANGED
@@ -304,10 +304,10 @@ var require_lib = __commonJS({
304
304
  module.exports.sync = writeFileSync6;
305
305
  module.exports._getTmpname = getTmpname;
306
306
  module.exports._cleanupOnExit = cleanupOnExit;
307
- var fs21 = __require("fs");
307
+ var fs17 = __require("fs");
308
308
  var crypto4 = __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
  module.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"(exports, module) {
814
814
  var Stream = __require("stream").Stream;
815
815
  module.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"(exports, module) {
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
- module.exports = patch(clone(fs21));
1005
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs21.__patched) {
1006
- module.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
+ module.exports = patch(clone(fs17));
1005
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs17.__patched) {
1006
+ module.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"(exports, module) {
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"(exports, module) {
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"(exports, module) {
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
  }
@@ -2247,15 +2247,14 @@ function keyPreview(key) {
2247
2247
 
2248
2248
  // src/manifest/parser.ts
2249
2249
  var CLEF_MANIFEST_FILENAME = "clef.yaml";
2250
- var VALID_BACKENDS = ["age", "awskms", "gcpkms", "azurekv", "pgp", "cloud"];
2250
+ var VALID_BACKENDS = ["age", "awskms", "gcpkms", "azurekv", "pgp"];
2251
2251
  var VALID_TOP_LEVEL_KEYS = [
2252
2252
  "version",
2253
2253
  "environments",
2254
2254
  "namespaces",
2255
2255
  "sops",
2256
2256
  "file_pattern",
2257
- "service_identities",
2258
- "cloud"
2257
+ "service_identities"
2259
2258
  ];
2260
2259
  var ENV_NAME_PATTERN = /^[a-z][a-z0-9_-]*$/;
2261
2260
  var FILE_PATTERN_REQUIRED_TOKENS = ["{namespace}", "{environment}"];
@@ -2758,47 +2757,13 @@ var ManifestParser = class {
2758
2757
  siNames.add(si.name);
2759
2758
  }
2760
2759
  }
2761
- let cloud;
2762
- if (obj.cloud !== void 0) {
2763
- if (typeof obj.cloud !== "object" || obj.cloud === null || Array.isArray(obj.cloud)) {
2764
- throw new ManifestValidationError("Field 'cloud' must be an object.", "cloud");
2765
- }
2766
- const cloudObj = obj.cloud;
2767
- if (typeof cloudObj.integrationId !== "string" || cloudObj.integrationId.length === 0) {
2768
- throw new ManifestValidationError(
2769
- "Field 'cloud.integrationId' is required and must be a non-empty string.",
2770
- "cloud"
2771
- );
2772
- }
2773
- if (typeof cloudObj.keyId !== "string" || cloudObj.keyId.length === 0) {
2774
- throw new ManifestValidationError(
2775
- "Field 'cloud.keyId' is required and must be a non-empty string.",
2776
- "cloud"
2777
- );
2778
- }
2779
- if (!/^clef:[a-zA-Z0-9_]+\/[a-zA-Z0-9_-]+$/.test(cloudObj.keyId)) {
2780
- throw new ManifestValidationError(
2781
- `Field 'cloud.keyId' has invalid format '${cloudObj.keyId}'. Must match: clef:<integrationId>/<keyAlias>`,
2782
- "cloud"
2783
- );
2784
- }
2785
- cloud = { integrationId: cloudObj.integrationId, keyId: cloudObj.keyId };
2786
- }
2787
- const usesCloudBackend = sopsConfig.default_backend === "cloud" || environments.some((e) => e.sops?.backend === "cloud");
2788
- if (usesCloudBackend && !cloud) {
2789
- throw new ManifestValidationError(
2790
- "One or more environments use the 'cloud' backend but the manifest is missing the top-level 'cloud' block with 'integrationId' and 'keyId'.",
2791
- "cloud"
2792
- );
2793
- }
2794
2760
  return {
2795
2761
  version: 1,
2796
2762
  environments,
2797
2763
  namespaces,
2798
2764
  sops: sopsConfig,
2799
2765
  file_pattern: obj.file_pattern,
2800
- ...serviceIdentities ? { service_identities: serviceIdentities } : {},
2801
- ...cloud ? { cloud } : {}
2766
+ ...serviceIdentities ? { service_identities: serviceIdentities } : {}
2802
2767
  };
2803
2768
  }
2804
2769
  /**
@@ -3740,6 +3705,11 @@ var PRE_COMMIT_HOOK = `#!/bin/sh
3740
3705
  # and scans staged files for plaintext secrets.
3741
3706
  # Installed by: clef hooks install
3742
3707
 
3708
+ # Skip during TransactionManager commits (policy scaffolding, migrations, etc.)
3709
+ if [ "$CLEF_IN_TRANSACTION" = "1" ]; then
3710
+ exit 0
3711
+ fi
3712
+
3743
3713
  STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
3744
3714
  EXIT_CODE=0
3745
3715
 
@@ -4096,12 +4066,10 @@ ${mergeRule}
4096
4066
  ` : `# Clef: SOPS-aware merge driver for encrypted files
4097
4067
  ${mergeRule}
4098
4068
  `;
4099
- const writeResult = await this.runner.run("tee", [attrPath], {
4100
- stdin: newContent,
4101
- cwd: repoRoot
4102
- });
4103
- if (writeResult.exitCode !== 0) {
4104
- throw new GitOperationError(`Failed to write .gitattributes: ${writeResult.stderr.trim()}`);
4069
+ try {
4070
+ fs9.writeFileSync(attrPath, newContent, "utf-8");
4071
+ } catch (err) {
4072
+ throw new GitOperationError(`Failed to write .gitattributes: ${err.message}`);
4105
4073
  }
4106
4074
  }
4107
4075
  /**
@@ -4113,22 +4081,18 @@ ${mergeRule}
4113
4081
  */
4114
4082
  async installPreCommitHook(repoRoot) {
4115
4083
  const hookPath = path8.join(repoRoot, ".git", "hooks", "pre-commit");
4116
- const result = await this.runner.run("tee", [hookPath], {
4117
- stdin: PRE_COMMIT_HOOK,
4118
- cwd: repoRoot
4119
- });
4120
- if (result.exitCode !== 0) {
4084
+ try {
4085
+ const hooksDir = path8.dirname(hookPath);
4086
+ if (!fs9.existsSync(hooksDir)) {
4087
+ fs9.mkdirSync(hooksDir, { recursive: true });
4088
+ }
4089
+ fs9.writeFileSync(hookPath, PRE_COMMIT_HOOK, { mode: 493 });
4090
+ } catch (err) {
4121
4091
  throw new GitOperationError(
4122
- `Failed to install pre-commit hook: ${result.stderr.trim()}`,
4092
+ `Failed to install pre-commit hook: ${err.message}`,
4123
4093
  "Ensure .git/hooks/ directory exists."
4124
4094
  );
4125
4095
  }
4126
- const chmodResult = await this.runner.run("chmod", ["+x", hookPath], { cwd: repoRoot });
4127
- if (chmodResult.exitCode !== 0) {
4128
- throw new GitOperationError(
4129
- `Failed to make pre-commit hook executable: ${chmodResult.stderr.trim()}`
4130
- );
4131
- }
4132
4096
  }
4133
4097
  };
4134
4098
 
@@ -4513,13 +4477,6 @@ function openWindowsInputPipe(content) {
4513
4477
  });
4514
4478
  });
4515
4479
  }
4516
- function cloudKeyToArn(keyId) {
4517
- const body = keyId.replace(/^clef:/, "");
4518
- const sep = body.indexOf("/");
4519
- const integration = sep >= 0 ? body.slice(0, sep) : body;
4520
- const env = sep >= 0 ? body.slice(sep + 1) : "default";
4521
- return `arn:aws:kms:us-east-1:000000000000:alias/clef/${integration}/${env}`;
4522
- }
4523
4480
  var SopsClient = class {
4524
4481
  /**
4525
4482
  * @param runner - Subprocess runner used to invoke the `sops` binary.
@@ -4529,18 +4486,14 @@ var SopsClient = class {
4529
4486
  * to the subprocess environment.
4530
4487
  * @param sopsPath - Optional explicit path to the sops binary. When omitted,
4531
4488
  * resolved automatically via {@link resolveSopsPath}.
4532
- * @param keyserviceAddr - Optional keyservice address (e.g. `tcp://127.0.0.1:12345`).
4533
- * When set, all SOPS invocations include `--enable-local-keyservice=false --keyservice <addr>`.
4534
4489
  */
4535
- constructor(runner, ageKeyFile, ageKey, sopsPath, keyserviceAddr) {
4490
+ constructor(runner, ageKeyFile, ageKey, sopsPath) {
4536
4491
  this.runner = runner;
4537
4492
  this.ageKeyFile = ageKeyFile;
4538
4493
  this.ageKey = ageKey;
4539
4494
  this.sopsCommand = sopsPath ?? resolveSopsPath().path;
4540
- this.keyserviceArgs = keyserviceAddr ? ["--enable-local-keyservice=false", "--keyservice", keyserviceAddr] : [];
4541
4495
  }
4542
4496
  sopsCommand;
4543
- keyserviceArgs;
4544
4497
  buildSopsEnv() {
4545
4498
  const env = {};
4546
4499
  if (this.ageKey) {
@@ -4565,7 +4518,7 @@ var SopsClient = class {
4565
4518
  const env = this.buildSopsEnv();
4566
4519
  const result = await this.runner.run(
4567
4520
  this.sopsCommand,
4568
- ["decrypt", ...this.keyserviceArgs, "--output-type", fmt, filePath],
4521
+ ["decrypt", "--output-type", fmt, filePath],
4569
4522
  {
4570
4523
  ...env ? { env } : {}
4571
4524
  }
@@ -4632,7 +4585,6 @@ var SopsClient = class {
4632
4585
  "--config",
4633
4586
  configPath,
4634
4587
  "encrypt",
4635
- ...this.keyserviceArgs,
4636
4588
  ...args,
4637
4589
  "--input-type",
4638
4590
  fmt,
@@ -4689,7 +4641,7 @@ var SopsClient = class {
4689
4641
  const env = this.buildSopsEnv();
4690
4642
  const result = await this.runner.run(
4691
4643
  this.sopsCommand,
4692
- ["rotate", ...this.keyserviceArgs, "-i", "--add-age", key, filePath],
4644
+ ["rotate", "-i", "--add-age", key, filePath],
4693
4645
  {
4694
4646
  ...env ? { env } : {}
4695
4647
  }
@@ -4713,7 +4665,7 @@ var SopsClient = class {
4713
4665
  const env = this.buildSopsEnv();
4714
4666
  const result = await this.runner.run(
4715
4667
  this.sopsCommand,
4716
- ["rotate", ...this.keyserviceArgs, "-i", "--rm-age", key, filePath],
4668
+ ["rotate", "-i", "--rm-age", key, filePath],
4717
4669
  {
4718
4670
  ...env ? { env } : {}
4719
4671
  }
@@ -4825,13 +4777,7 @@ var SopsClient = class {
4825
4777
  }
4826
4778
  detectBackend(sops) {
4827
4779
  if (sops.age && Array.isArray(sops.age) && sops.age.length > 0) return "age";
4828
- if (sops.kms && Array.isArray(sops.kms) && sops.kms.length > 0) {
4829
- const firstArn = sops.kms[0]?.arn;
4830
- if (typeof firstArn === "string" && (firstArn.startsWith("clef:") || firstArn.includes("alias/clef/"))) {
4831
- return "cloud";
4832
- }
4833
- return "awskms";
4834
- }
4780
+ if (sops.kms && Array.isArray(sops.kms) && sops.kms.length > 0) return "awskms";
4835
4781
  if (sops.gcp_kms && Array.isArray(sops.gcp_kms) && sops.gcp_kms.length > 0)
4836
4782
  return "gcpkms";
4837
4783
  if (sops.azure_kv && Array.isArray(sops.azure_kv) && sops.azure_kv.length > 0)
@@ -4845,7 +4791,6 @@ var SopsClient = class {
4845
4791
  const entries = sops.age;
4846
4792
  return entries?.map((e) => String(e.recipient ?? "")) ?? [];
4847
4793
  }
4848
- case "cloud":
4849
4794
  case "awskms": {
4850
4795
  const entries = sops.kms;
4851
4796
  return entries?.map((e) => String(e.arn ?? "")) ?? [];
@@ -4907,13 +4852,6 @@ var SopsClient = class {
4907
4852
  args.push("--pgp", config.pgp_fingerprint);
4908
4853
  }
4909
4854
  break;
4910
- case "cloud": {
4911
- const cloudKeyId = manifest.cloud?.keyId;
4912
- if (cloudKeyId) {
4913
- args.push("--kms", cloudKeyToArn(cloudKeyId));
4914
- }
4915
- break;
4916
- }
4917
4855
  }
4918
4856
  return args;
4919
4857
  }
@@ -7809,12 +7747,7 @@ var ArtifactPacker = class {
7809
7747
  };
7810
7748
 
7811
7749
  // src/kms/types.ts
7812
- var VALID_KMS_PROVIDERS = [
7813
- "aws",
7814
- "gcp",
7815
- "azure",
7816
- "cloud"
7817
- ];
7750
+ var VALID_KMS_PROVIDERS = ["aws", "gcp", "azure"];
7818
7751
 
7819
7752
  // src/migration/backend.ts
7820
7753
  import * as path22 from "path";
@@ -7824,8 +7757,7 @@ var BACKEND_KEY_FIELDS = {
7824
7757
  awskms: "aws_kms_arn",
7825
7758
  gcpkms: "gcp_kms_resource_id",
7826
7759
  azurekv: "azure_kv_url",
7827
- pgp: "pgp_fingerprint",
7828
- cloud: void 0
7760
+ pgp: "pgp_fingerprint"
7829
7761
  };
7830
7762
  var ALL_KEY_FIELDS = Object.values(BACKEND_KEY_FIELDS).filter(
7831
7763
  (v) => v !== void 0
@@ -8020,18 +7952,6 @@ var BackendMigrator = class {
8020
7952
  sops[keyField] = target.key;
8021
7953
  }
8022
7954
  }
8023
- if (doc.cloud && target.backend !== "cloud") {
8024
- const sops = doc.sops;
8025
- const environments = doc.environments;
8026
- const defaultIsCloud = sops.default_backend === "cloud";
8027
- const anyEnvIsCloud = environments.some((e) => {
8028
- const envSops = e.sops;
8029
- return envSops?.backend === "cloud";
8030
- });
8031
- if (!defaultIsCloud && !anyEnvIsCloud) {
8032
- delete doc.cloud;
8033
- }
8034
- }
8035
7955
  }
8036
7956
  checkAgeRecipientsWarning(manifest, target, environment, warnings) {
8037
7957
  if (target.backend === "age") return;
@@ -8240,281 +8160,111 @@ function withBackendOverride(manifest, envNames, backend, key) {
8240
8160
  };
8241
8161
  }
8242
8162
 
8243
- // src/cloud/keyservice.ts
8244
- import { spawn } from "child_process";
8245
- import * as readline from "readline";
8246
- var PORT_REGEX = /^PORT=(\d+)$/;
8247
- var STARTUP_TIMEOUT_MS = 5e3;
8248
- var SHUTDOWN_TIMEOUT_MS = 3e3;
8249
- async function spawnKeyservice(options) {
8250
- const args = ["--addr", "127.0.0.1:0"];
8251
- if (options.endpoint) {
8252
- args.push("--endpoint", options.endpoint);
8253
- }
8254
- const child = spawn(options.binaryPath, args, {
8255
- stdio: ["ignore", "pipe", "pipe"],
8256
- env: { ...process.env, CLEF_CLOUD_TOKEN: options.token }
8257
- });
8258
- const port = await readPort(child);
8259
- const addr = `tcp://127.0.0.1:${port}`;
8260
- return {
8261
- addr,
8262
- kill: () => killGracefully(child)
8263
- };
8264
- }
8265
- function readPort(child) {
8266
- return new Promise((resolve, reject) => {
8267
- let settled = false;
8268
- const rl = readline.createInterface({ input: child.stdout });
8269
- function settle() {
8270
- clearTimeout(timer);
8271
- rl.close();
8272
- }
8273
- const timer = setTimeout(() => {
8274
- if (!settled) {
8275
- settled = true;
8276
- settle();
8277
- child.kill("SIGKILL");
8278
- reject(new Error("Keyservice did not start within 5 seconds."));
8279
- }
8280
- }, STARTUP_TIMEOUT_MS);
8281
- rl.on("line", (line) => {
8282
- const match = PORT_REGEX.exec(line);
8283
- if (match && !settled) {
8284
- settled = true;
8285
- settle();
8286
- resolve(parseInt(match[1], 10));
8163
+ // src/sync/manager.ts
8164
+ import * as path24 from "path";
8165
+ var SyncManager = class {
8166
+ constructor(matrixManager, encryption, tx) {
8167
+ this.matrixManager = matrixManager;
8168
+ this.encryption = encryption;
8169
+ this.tx = tx;
8170
+ }
8171
+ /**
8172
+ * Compute what sync would do without mutating anything.
8173
+ */
8174
+ async plan(manifest, repoRoot, opts) {
8175
+ if (opts.namespace) {
8176
+ const exists = manifest.namespaces.some((n) => n.name === opts.namespace);
8177
+ if (!exists) {
8178
+ throw new Error(`Namespace '${opts.namespace}' not found in manifest.`);
8287
8179
  }
8288
- });
8289
- child.on("error", (err) => {
8290
- if (!settled) {
8291
- settled = true;
8292
- settle();
8293
- reject(new Error(`Failed to start keyservice: ${err.message}`));
8180
+ }
8181
+ const allCells = this.matrixManager.resolveMatrix(manifest, repoRoot);
8182
+ const existingCells = allCells.filter((c) => c.exists);
8183
+ const targetCells = opts.namespace ? existingCells.filter((c) => c.namespace === opts.namespace) : existingCells;
8184
+ const keysByNsEnv = {};
8185
+ for (const cell of targetCells) {
8186
+ const keys = readSopsKeyNames(cell.filePath);
8187
+ if (!keys) continue;
8188
+ if (!keysByNsEnv[cell.namespace]) keysByNsEnv[cell.namespace] = {};
8189
+ keysByNsEnv[cell.namespace][cell.environment] = new Set(keys);
8190
+ }
8191
+ const cells = [];
8192
+ let totalKeys = 0;
8193
+ let hasProtectedEnvs = false;
8194
+ for (const [nsName, envKeys] of Object.entries(keysByNsEnv)) {
8195
+ const allKeys = /* @__PURE__ */ new Set();
8196
+ for (const keys of Object.values(envKeys)) {
8197
+ for (const k of keys) allKeys.add(k);
8294
8198
  }
8295
- });
8296
- child.on("exit", (code) => {
8297
- if (!settled) {
8298
- settled = true;
8299
- settle();
8300
- reject(new Error(`Keyservice exited unexpectedly with code ${code}.`));
8199
+ for (const cell of targetCells) {
8200
+ if (cell.namespace !== nsName) continue;
8201
+ const cellKeys = envKeys[cell.environment];
8202
+ if (!cellKeys) continue;
8203
+ const missing = [...allKeys].filter((k) => !cellKeys.has(k));
8204
+ if (missing.length === 0) continue;
8205
+ const isProtected = this.matrixManager.isProtectedEnvironment(manifest, cell.environment);
8206
+ if (isProtected) hasProtectedEnvs = true;
8207
+ cells.push({
8208
+ namespace: cell.namespace,
8209
+ environment: cell.environment,
8210
+ filePath: cell.filePath,
8211
+ missingKeys: missing.sort(),
8212
+ isProtected
8213
+ });
8214
+ totalKeys += missing.length;
8301
8215
  }
8302
- });
8303
- });
8304
- }
8305
- function killGracefully(child) {
8306
- return new Promise((resolve) => {
8307
- if (child.exitCode !== null) {
8308
- resolve();
8309
- return;
8310
- }
8311
- const timer = setTimeout(() => {
8312
- child.kill("SIGKILL");
8313
- }, SHUTDOWN_TIMEOUT_MS);
8314
- child.on("exit", () => {
8315
- clearTimeout(timer);
8316
- resolve();
8317
- });
8318
- child.kill("SIGTERM");
8319
- });
8320
- }
8321
-
8322
- // src/cloud/resolver.ts
8323
- import * as fs18 from "fs";
8324
- import * as path25 from "path";
8325
-
8326
- // src/cloud/bundled.ts
8327
- import * as fs17 from "fs";
8328
- import * as path24 from "path";
8329
- function tryBundledKeyservice() {
8330
- const platform = process.platform;
8331
- const arch = process.arch;
8332
- const archName = arch === "x64" ? "x64" : arch === "arm64" ? "arm64" : null;
8333
- if (!archName) return null;
8334
- const platformName = platform === "darwin" ? "darwin" : platform === "linux" ? "linux" : platform === "win32" ? "win32" : null;
8335
- if (!platformName) return null;
8336
- const packageName = `@clef-sh/keyservice-${platformName}-${archName}`;
8337
- const binName = platform === "win32" ? "clef-keyservice.exe" : "clef-keyservice";
8338
- try {
8339
- const packageMain = __require.resolve(`${packageName}/package.json`);
8340
- const packageDir = path24.dirname(packageMain);
8341
- const binPath = path24.join(packageDir, "bin", binName);
8342
- return fs17.existsSync(binPath) ? binPath : null;
8343
- } catch {
8344
- return null;
8345
- }
8346
- }
8347
-
8348
- // src/cloud/resolver.ts
8349
- function validateKeyservicePath(candidate) {
8350
- if (!path25.isAbsolute(candidate)) {
8351
- throw new Error(`CLEF_KEYSERVICE_PATH must be an absolute path, got '${candidate}'.`);
8352
- }
8353
- const segments = candidate.split(/[/\\]/);
8354
- if (segments.includes("..")) {
8355
- throw new Error(
8356
- `CLEF_KEYSERVICE_PATH contains '..' path segments ('${candidate}'). Use an absolute path without directory traversal.`
8357
- );
8358
- }
8359
- }
8360
- var cached2;
8361
- function resolveKeyservicePath() {
8362
- if (cached2) return cached2;
8363
- const envPath = process.env.CLEF_KEYSERVICE_PATH?.trim();
8364
- if (envPath) {
8365
- validateKeyservicePath(envPath);
8366
- if (!fs18.existsSync(envPath)) {
8367
- throw new Error(`CLEF_KEYSERVICE_PATH points to '${envPath}' but the file does not exist.`);
8368
8216
  }
8369
- cached2 = { path: envPath, source: "env" };
8370
- return cached2;
8371
- }
8372
- const bundledPath = tryBundledKeyservice();
8373
- if (bundledPath) {
8374
- cached2 = { path: bundledPath, source: "bundled" };
8375
- return cached2;
8376
- }
8377
- cached2 = { path: "clef-keyservice", source: "system" };
8378
- return cached2;
8379
- }
8380
- function resetKeyserviceResolution() {
8381
- cached2 = void 0;
8382
- }
8383
-
8384
- // src/cloud/credentials.ts
8385
- import * as fs19 from "fs";
8386
- import * as path26 from "path";
8387
- import * as os from "os";
8388
- import * as YAML11 from "yaml";
8389
-
8390
- // src/cloud/constants.ts
8391
- var CLOUD_DEFAULT_ENDPOINT = "https://api.clef.sh";
8392
-
8393
- // src/cloud/credentials.ts
8394
- var CREDENTIALS_FILENAME = "credentials.yaml";
8395
- function readCloudCredentials() {
8396
- const credPath = path26.join(os.homedir(), ".clef", CREDENTIALS_FILENAME);
8397
- let raw;
8398
- try {
8399
- raw = YAML11.parse(fs19.readFileSync(credPath, "utf-8"));
8400
- } catch {
8401
- return null;
8217
+ return { cells, totalKeys, hasProtectedEnvs };
8402
8218
  }
8403
- if (!raw || typeof raw !== "object") return null;
8404
- const obj = raw;
8405
- const token = typeof obj.token === "string" && obj.token.length > 0 ? obj.token : "";
8406
- const endpoint = typeof obj.endpoint === "string" ? obj.endpoint : CLOUD_DEFAULT_ENDPOINT;
8407
- if (!token && endpoint === CLOUD_DEFAULT_ENDPOINT) return null;
8408
- return { token, endpoint };
8409
- }
8410
- function writeCloudCredentials(credentials) {
8411
- const clefDir = path26.join(os.homedir(), ".clef");
8412
- fs19.mkdirSync(clefDir, { recursive: true, mode: 448 });
8413
- const credPath = path26.join(clefDir, CREDENTIALS_FILENAME);
8414
- const content = { token: credentials.token };
8415
- if (credentials.endpoint) {
8416
- content.endpoint = credentials.endpoint;
8417
- }
8418
- fs19.writeFileSync(credPath, YAML11.stringify(content), { mode: 384 });
8419
- }
8420
-
8421
- // src/cloud/device-flow.ts
8422
- async function initiateDeviceFlow(endpoint, options) {
8423
- const base = endpoint ?? CLOUD_DEFAULT_ENDPOINT;
8424
- const payload = {
8425
- clientType: "cli",
8426
- clientVersion: options.clientVersion,
8427
- repoName: options.repoName,
8428
- flow: options.flow
8429
- };
8430
- if (options.environment) {
8431
- payload.environment = options.environment;
8432
- }
8433
- const res = await fetch(`${base}/api/v1/device/init`, {
8434
- method: "POST",
8435
- headers: { "Content-Type": "application/json" },
8436
- body: JSON.stringify(payload)
8437
- });
8438
- if (!res.ok) {
8439
- const body = await res.text().catch(() => "");
8440
- throw new Error(`Device flow init failed (${res.status}): ${body}`);
8441
- }
8442
- const json = await res.json();
8443
- const session = json.data ?? json;
8444
- if (session.pollUrl && !session.pollUrl.startsWith("http")) {
8445
- session.pollUrl = `${base}${session.pollUrl}`;
8446
- }
8447
- return session;
8448
- }
8449
- async function pollDeviceFlow(pollUrl) {
8450
- const res = await fetch(pollUrl);
8451
- if (!res.ok) {
8452
- const body = await res.text().catch(() => "");
8453
- throw new Error(`Device flow poll failed (${res.status}): ${body}`);
8454
- }
8455
- const json = await res.json();
8456
- return json.data ?? json;
8457
- }
8458
-
8459
- // src/cloud/pack-client.ts
8460
- import * as fs20 from "fs";
8461
- import * as path27 from "path";
8462
- var CloudPackClient = class {
8463
- endpoint;
8464
- constructor(endpoint) {
8465
- this.endpoint = endpoint ?? CLOUD_DEFAULT_ENDPOINT;
8466
- }
8467
- async pack(token, config) {
8468
- const matrixManager = new MatrixManager();
8469
- const cells = matrixManager.resolveMatrix(config.manifest, config.repoRoot).filter((c) => c.environment === config.environment && c.exists);
8470
- const formData = new FormData();
8471
- const configJson = JSON.stringify({
8472
- identity: config.identity,
8473
- environment: config.environment,
8474
- ...config.ttl ? { ttl: config.ttl } : {}
8475
- });
8476
- formData.append("config", new Blob([configJson], { type: "application/json" }));
8477
- const manifestPath = path27.join(config.repoRoot, "clef.yaml");
8478
- const manifestContent = fs20.readFileSync(manifestPath, "utf-8");
8479
- formData.append("manifest", new Blob([manifestContent], { type: "text/yaml" }));
8480
- for (const cell of cells) {
8481
- const relPath = path27.relative(config.repoRoot, cell.filePath);
8482
- const content = fs20.readFileSync(cell.filePath, "utf-8");
8483
- formData.append(`files`, new Blob([content], { type: "text/yaml" }), relPath);
8484
- }
8485
- const res = await fetch(`${this.endpoint}/api/v1/cloud/pack`, {
8486
- method: "POST",
8487
- headers: { Authorization: `Bearer ${token}` },
8488
- body: formData
8489
- });
8490
- if (!res.ok) {
8491
- const body = await res.text().catch(() => "");
8492
- throw new Error(`Cloud pack failed (${res.status}): ${body}`);
8219
+ /**
8220
+ * Execute the sync: scaffold missing keys with random pending values.
8221
+ *
8222
+ * Returns immediately (no-op) when the plan has nothing to do.
8223
+ * When `dryRun` is set, returns a result with zero modifications —
8224
+ * the caller can inspect the plan via {@link plan} separately.
8225
+ */
8226
+ async sync(manifest, repoRoot, opts = {}) {
8227
+ const syncPlan = await this.plan(manifest, repoRoot, opts);
8228
+ if (opts.dryRun || syncPlan.totalKeys === 0) {
8229
+ return { modifiedCells: [], scaffoldedKeys: {}, totalKeysScaffolded: 0 };
8493
8230
  }
8494
- return await res.json();
8495
- }
8496
- };
8497
- var CloudArtifactClient = class {
8498
- endpoint;
8499
- constructor(endpoint) {
8500
- this.endpoint = endpoint ?? CLOUD_DEFAULT_ENDPOINT;
8501
- }
8502
- async upload(token, config) {
8503
- const res = await fetch(
8504
- `${this.endpoint}/api/v1/cloud/artifacts/${config.identity}/${config.environment}`,
8505
- {
8506
- method: "PUT",
8507
- headers: {
8508
- Authorization: `Bearer ${token}`,
8509
- "Content-Type": "application/json"
8510
- },
8511
- body: config.artifactJson
8231
+ const txPaths = [];
8232
+ for (const cell of syncPlan.cells) {
8233
+ const rel = path24.relative(repoRoot, cell.filePath);
8234
+ txPaths.push(rel);
8235
+ txPaths.push(rel.replace(/\.enc\.(yaml|json)$/, ".clef-meta.yaml"));
8236
+ }
8237
+ const modifiedCells = [];
8238
+ const scaffoldedKeys = {};
8239
+ const nsLabel = opts.namespace ?? "all";
8240
+ const envCount = new Set(syncPlan.cells.map((c) => c.environment)).size;
8241
+ await this.tx.run(repoRoot, {
8242
+ description: `clef sync ${nsLabel}: ${syncPlan.totalKeys} key(s) across ${envCount} environment(s)`,
8243
+ paths: txPaths,
8244
+ mutate: async () => {
8245
+ for (const cell of syncPlan.cells) {
8246
+ const decrypted = await this.encryption.decrypt(cell.filePath);
8247
+ for (const key of cell.missingKeys) {
8248
+ decrypted.values[key] = generateRandomValue();
8249
+ }
8250
+ await this.encryption.encrypt(
8251
+ cell.filePath,
8252
+ decrypted.values,
8253
+ manifest,
8254
+ cell.environment
8255
+ );
8256
+ await markPendingWithRetry(cell.filePath, cell.missingKeys, "clef sync");
8257
+ const cellLabel = `${cell.namespace}/${cell.environment}`;
8258
+ modifiedCells.push(cellLabel);
8259
+ scaffoldedKeys[cellLabel] = cell.missingKeys;
8260
+ }
8512
8261
  }
8513
- );
8514
- if (!res.ok) {
8515
- const body = await res.text().catch(() => "");
8516
- throw new Error(`Artifact upload failed (${res.status}): ${body}`);
8517
- }
8262
+ });
8263
+ return {
8264
+ modifiedCells,
8265
+ scaffoldedKeys,
8266
+ totalKeysScaffolded: syncPlan.totalKeys
8267
+ };
8518
8268
  }
8519
8269
  };
8520
8270
  export {
@@ -8526,9 +8276,7 @@ export {
8526
8276
  CLEF_SUPPORTED_EXTENSIONS,
8527
8277
  ClefError,
8528
8278
  CloudApiError,
8529
- CloudArtifactClient,
8530
8279
  CloudClient,
8531
- CloudPackClient,
8532
8280
  ConsumptionClient,
8533
8281
  DiffEngine,
8534
8282
  DriftDetector,
@@ -8560,6 +8308,7 @@ export {
8560
8308
  SopsMissingError,
8561
8309
  SopsVersionError,
8562
8310
  StructureManager,
8311
+ SyncManager,
8563
8312
  TransactionLockError,
8564
8313
  TransactionManager,
8565
8314
  TransactionPreflightError,
@@ -8580,7 +8329,6 @@ export {
8580
8329
  generateRandomValue,
8581
8330
  generateSigningKeyPair,
8582
8331
  getPendingKeys,
8583
- initiateDeviceFlow,
8584
8332
  isHighEntropy,
8585
8333
  isKmsEnvelope,
8586
8334
  isPending,
@@ -8598,17 +8346,13 @@ export {
8598
8346
  parseIgnoreContent,
8599
8347
  parseJson,
8600
8348
  parseYaml,
8601
- pollDeviceFlow,
8602
- readCloudCredentials,
8603
8349
  readManifestYaml,
8604
8350
  redactValue,
8605
8351
  removeRequest as removeAccessRequest,
8606
8352
  requestsFilePath,
8607
- resetKeyserviceResolution,
8608
8353
  resetSopsResolution,
8609
8354
  resolveBackendConfig,
8610
8355
  resolveIdentitySecrets,
8611
- resolveKeyservicePath,
8612
8356
  resolveRecipientsForEnvironment,
8613
8357
  resolveSopsPath,
8614
8358
  saveMetadata,
@@ -8618,12 +8362,10 @@ export {
8618
8362
  shouldIgnoreMatch,
8619
8363
  signEd25519,
8620
8364
  signKms,
8621
- spawnKeyservice,
8622
8365
  upsertRequest,
8623
8366
  validateAgePublicKey,
8624
8367
  validateResetScope,
8625
8368
  verifySignature,
8626
- writeCloudCredentials,
8627
8369
  writeManifestYaml,
8628
8370
  writeManifestYamlRaw
8629
8371
  };