@clef-sh/core 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifact/guards.d.ts +40 -0
- package/dist/artifact/guards.d.ts.map +1 -0
- package/dist/artifact/packer.d.ts.map +1 -1
- package/dist/artifact/types.d.ts +11 -2
- package/dist/artifact/types.d.ts.map +1 -1
- package/dist/hsm/bundled.d.ts +10 -0
- package/dist/hsm/bundled.d.ts.map +1 -0
- package/dist/hsm/index.d.ts +4 -0
- package/dist/hsm/index.d.ts.map +1 -0
- package/dist/hsm/keyservice.d.ts +36 -0
- package/dist/hsm/keyservice.d.ts.map +1 -0
- package/dist/hsm/resolver.d.ts +22 -0
- package/dist/hsm/resolver.d.ts.map +1 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +748 -308
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +731 -304
- package/dist/index.mjs.map +4 -4
- package/dist/manifest/parser.d.ts.map +1 -1
- package/dist/migration/backend.d.ts.map +1 -1
- package/dist/pack/backends/json-envelope.d.ts +33 -0
- package/dist/pack/backends/json-envelope.d.ts.map +1 -0
- package/dist/pack/registry.d.ts +27 -0
- package/dist/pack/registry.d.ts.map +1 -0
- package/dist/pack/types.d.ts +78 -0
- package/dist/pack/types.d.ts.map +1 -0
- package/dist/sops/client.d.ts +11 -1
- package/dist/sops/client.d.ts.map +1 -1
- package/dist/sops/hsm-arn.d.ts +51 -0
- package/dist/sops/hsm-arn.d.ts.map +1 -0
- package/dist/types/index.d.ts +17 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -304,10 +304,10 @@ var require_lib = __commonJS({
|
|
|
304
304
|
module2.exports.sync = writeFileSync7;
|
|
305
305
|
module2.exports._getTmpname = getTmpname;
|
|
306
306
|
module2.exports._cleanupOnExit = cleanupOnExit;
|
|
307
|
-
var
|
|
307
|
+
var fs21 = require("fs");
|
|
308
308
|
var crypto5 = require("node:crypto");
|
|
309
309
|
var { onExit } = require_cjs();
|
|
310
|
-
var
|
|
310
|
+
var path28 = 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
|
-
|
|
328
|
+
fs21.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 =
|
|
363
|
+
const absoluteName = path28.resolve(filename);
|
|
364
364
|
try {
|
|
365
365
|
await serializeActiveFile(absoluteName);
|
|
366
|
-
const truename = await promisify(
|
|
366
|
+
const truename = await promisify(fs21.realpath)(filename).catch(() => filename);
|
|
367
367
|
tmpfile = getTmpname(truename);
|
|
368
368
|
if (!options.mode || !options.chown) {
|
|
369
|
-
const stats = await promisify(
|
|
369
|
+
const stats = await promisify(fs21.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(
|
|
380
|
+
fd = await promisify(fs21.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(
|
|
385
|
+
await promisify(fs21.write)(fd, data, 0, data.length, 0);
|
|
386
386
|
} else if (data != null) {
|
|
387
|
-
await promisify(
|
|
387
|
+
await promisify(fs21.write)(fd, String(data), 0, String(options.encoding || "utf8"));
|
|
388
388
|
}
|
|
389
389
|
if (options.fsync !== false) {
|
|
390
|
-
await promisify(
|
|
390
|
+
await promisify(fs21.fsync)(fd);
|
|
391
391
|
}
|
|
392
|
-
await promisify(
|
|
392
|
+
await promisify(fs21.close)(fd);
|
|
393
393
|
fd = null;
|
|
394
394
|
if (options.chown) {
|
|
395
|
-
await promisify(
|
|
395
|
+
await promisify(fs21.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(
|
|
402
|
+
await promisify(fs21.chmod)(tmpfile, options.mode).catch((err) => {
|
|
403
403
|
if (!isChownErrOk(err)) {
|
|
404
404
|
throw err;
|
|
405
405
|
}
|
|
406
406
|
});
|
|
407
407
|
}
|
|
408
|
-
await promisify(
|
|
408
|
+
await promisify(fs21.rename)(tmpfile, truename);
|
|
409
409
|
} finally {
|
|
410
410
|
if (fd) {
|
|
411
|
-
await promisify(
|
|
411
|
+
await promisify(fs21.close)(fd).catch(
|
|
412
412
|
/* istanbul ignore next */
|
|
413
413
|
() => {
|
|
414
414
|
}
|
|
415
415
|
);
|
|
416
416
|
}
|
|
417
417
|
removeOnExitHandler();
|
|
418
|
-
await promisify(
|
|
418
|
+
await promisify(fs21.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 =
|
|
451
|
+
filename = fs21.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 =
|
|
457
|
+
const stats = fs21.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 =
|
|
473
|
+
fd = fs21.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
|
-
|
|
478
|
+
fs21.writeSync(fd, data, 0, data.length, 0);
|
|
479
479
|
} else if (data != null) {
|
|
480
|
-
|
|
480
|
+
fs21.writeSync(fd, String(data), 0, String(options.encoding || "utf8"));
|
|
481
481
|
}
|
|
482
482
|
if (options.fsync !== false) {
|
|
483
|
-
|
|
483
|
+
fs21.fsyncSync(fd);
|
|
484
484
|
}
|
|
485
|
-
|
|
485
|
+
fs21.closeSync(fd);
|
|
486
486
|
fd = null;
|
|
487
487
|
if (options.chown) {
|
|
488
488
|
try {
|
|
489
|
-
|
|
489
|
+
fs21.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
|
-
|
|
498
|
+
fs21.chmodSync(tmpfile, options.mode);
|
|
499
499
|
} catch (err) {
|
|
500
500
|
if (!isChownErrOk(err)) {
|
|
501
501
|
throw err;
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
|
-
|
|
505
|
+
fs21.renameSync(tmpfile, filename);
|
|
506
506
|
threw = false;
|
|
507
507
|
} finally {
|
|
508
508
|
if (fd) {
|
|
509
509
|
try {
|
|
510
|
-
|
|
510
|
+
fs21.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(
|
|
549
|
+
function patch(fs21) {
|
|
550
550
|
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
551
|
-
patchLchmod(
|
|
552
|
-
}
|
|
553
|
-
if (!
|
|
554
|
-
patchLutimes(
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
if (
|
|
575
|
-
|
|
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) {
|
|
576
576
|
if (cb) process.nextTick(cb);
|
|
577
577
|
};
|
|
578
|
-
|
|
578
|
+
fs21.lchmodSync = function() {
|
|
579
579
|
};
|
|
580
580
|
}
|
|
581
|
-
if (
|
|
582
|
-
|
|
581
|
+
if (fs21.chown && !fs21.lchown) {
|
|
582
|
+
fs21.lchown = function(path28, uid, gid, cb) {
|
|
583
583
|
if (cb) process.nextTick(cb);
|
|
584
584
|
};
|
|
585
|
-
|
|
585
|
+
fs21.lchownSync = function() {
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
588
|
if (platform === "win32") {
|
|
589
|
-
|
|
589
|
+
fs21.rename = typeof fs21.rename !== "function" ? fs21.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
|
-
|
|
596
|
+
fs21.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
|
-
})(
|
|
612
|
+
})(fs21.rename);
|
|
613
613
|
}
|
|
614
|
-
|
|
614
|
+
fs21.read = typeof fs21.read !== "function" ? fs21.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(
|
|
622
|
+
return fs$read.call(fs21, fd, buffer, offset, length, position, callback);
|
|
623
623
|
}
|
|
624
624
|
callback_.apply(this, arguments);
|
|
625
625
|
};
|
|
626
626
|
}
|
|
627
|
-
return fs$read.call(
|
|
627
|
+
return fs$read.call(fs21, fd, buffer, offset, length, position, callback);
|
|
628
628
|
}
|
|
629
629
|
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
630
630
|
return read;
|
|
631
|
-
})(
|
|
632
|
-
|
|
631
|
+
})(fs21.read);
|
|
632
|
+
fs21.readSync = typeof fs21.readSync !== "function" ? fs21.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(
|
|
637
|
+
return fs$readSync.call(fs21, 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
|
-
})(
|
|
648
|
-
function patchLchmod(
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
647
|
+
})(fs21.readSync);
|
|
648
|
+
function patchLchmod(fs22) {
|
|
649
|
+
fs22.lchmod = function(path28, mode, callback) {
|
|
650
|
+
fs22.open(
|
|
651
|
+
path28,
|
|
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
|
-
|
|
660
|
-
|
|
659
|
+
fs22.fchmod(fd, mode, function(err2) {
|
|
660
|
+
fs22.close(fd, function(err22) {
|
|
661
661
|
if (callback) callback(err2 || err22);
|
|
662
662
|
});
|
|
663
663
|
});
|
|
664
664
|
}
|
|
665
665
|
);
|
|
666
666
|
};
|
|
667
|
-
|
|
668
|
-
var fd =
|
|
667
|
+
fs22.lchmodSync = function(path28, mode) {
|
|
668
|
+
var fd = fs22.openSync(path28, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
669
669
|
var threw = true;
|
|
670
670
|
var ret;
|
|
671
671
|
try {
|
|
672
|
-
ret =
|
|
672
|
+
ret = fs22.fchmodSync(fd, mode);
|
|
673
673
|
threw = false;
|
|
674
674
|
} finally {
|
|
675
675
|
if (threw) {
|
|
676
676
|
try {
|
|
677
|
-
|
|
677
|
+
fs22.closeSync(fd);
|
|
678
678
|
} catch (er) {
|
|
679
679
|
}
|
|
680
680
|
} else {
|
|
681
|
-
|
|
681
|
+
fs22.closeSync(fd);
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
return ret;
|
|
685
685
|
};
|
|
686
686
|
}
|
|
687
|
-
function patchLutimes(
|
|
688
|
-
if (constants.hasOwnProperty("O_SYMLINK") &&
|
|
689
|
-
|
|
690
|
-
|
|
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) {
|
|
691
691
|
if (er) {
|
|
692
692
|
if (cb) cb(er);
|
|
693
693
|
return;
|
|
694
694
|
}
|
|
695
|
-
|
|
696
|
-
|
|
695
|
+
fs22.futimes(fd, at, mt, function(er2) {
|
|
696
|
+
fs22.close(fd, function(er22) {
|
|
697
697
|
if (cb) cb(er2 || er22);
|
|
698
698
|
});
|
|
699
699
|
});
|
|
700
700
|
});
|
|
701
701
|
};
|
|
702
|
-
|
|
703
|
-
var fd =
|
|
702
|
+
fs22.lutimesSync = function(path28, at, mt) {
|
|
703
|
+
var fd = fs22.openSync(path28, constants.O_SYMLINK);
|
|
704
704
|
var ret;
|
|
705
705
|
var threw = true;
|
|
706
706
|
try {
|
|
707
|
-
ret =
|
|
707
|
+
ret = fs22.futimesSync(fd, at, mt);
|
|
708
708
|
threw = false;
|
|
709
709
|
} finally {
|
|
710
710
|
if (threw) {
|
|
711
711
|
try {
|
|
712
|
-
|
|
712
|
+
fs22.closeSync(fd);
|
|
713
713
|
} catch (er) {
|
|
714
714
|
}
|
|
715
715
|
} else {
|
|
716
|
-
|
|
716
|
+
fs22.closeSync(fd);
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
719
|
return ret;
|
|
720
720
|
};
|
|
721
|
-
} else if (
|
|
722
|
-
|
|
721
|
+
} else if (fs22.futimes) {
|
|
722
|
+
fs22.lutimes = function(_a, _b, _c, cb) {
|
|
723
723
|
if (cb) process.nextTick(cb);
|
|
724
724
|
};
|
|
725
|
-
|
|
725
|
+
fs22.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(
|
|
732
|
+
return orig.call(fs21, 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(
|
|
742
|
+
return orig.call(fs21, 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(
|
|
751
|
+
return orig.call(fs21, 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(
|
|
761
|
+
return orig.call(fs21, 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(
|
|
781
|
+
return options ? orig.call(fs21, target, options, callback) : orig.call(fs21, 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(
|
|
787
|
+
var stats = options ? orig.call(fs21, target, options) : orig.call(fs21, 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(
|
|
816
|
+
function legacy(fs21) {
|
|
817
817
|
return {
|
|
818
818
|
ReadStream,
|
|
819
819
|
WriteStream
|
|
820
820
|
};
|
|
821
|
-
function ReadStream(
|
|
822
|
-
if (!(this instanceof ReadStream)) return new ReadStream(
|
|
821
|
+
function ReadStream(path28, options) {
|
|
822
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path28, options);
|
|
823
823
|
Stream.call(this);
|
|
824
824
|
var self = this;
|
|
825
|
-
this.path =
|
|
825
|
+
this.path = path28;
|
|
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
|
-
|
|
859
|
+
fs21.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(
|
|
871
|
-
if (!(this instanceof WriteStream)) return new WriteStream(
|
|
870
|
+
function WriteStream(path28, options) {
|
|
871
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path28, options);
|
|
872
872
|
Stream.call(this);
|
|
873
|
-
this.path =
|
|
873
|
+
this.path = path28;
|
|
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 =
|
|
898
|
+
this._open = fs21.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
|
|
933
|
+
var fs21 = 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 (!
|
|
965
|
+
if (!fs21[gracefulQueue]) {
|
|
966
966
|
queue = global[gracefulQueue] || [];
|
|
967
|
-
publishQueue(
|
|
968
|
-
|
|
967
|
+
publishQueue(fs21, queue);
|
|
968
|
+
fs21.close = (function(fs$close) {
|
|
969
969
|
function close(fd, cb) {
|
|
970
|
-
return fs$close.call(
|
|
970
|
+
return fs$close.call(fs21, 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
|
-
})(
|
|
983
|
-
|
|
982
|
+
})(fs21.close);
|
|
983
|
+
fs21.closeSync = (function(fs$closeSync) {
|
|
984
984
|
function closeSync2(fd) {
|
|
985
|
-
fs$closeSync.apply(
|
|
985
|
+
fs$closeSync.apply(fs21, arguments);
|
|
986
986
|
resetQueue();
|
|
987
987
|
}
|
|
988
988
|
Object.defineProperty(closeSync2, previousSymbol, {
|
|
989
989
|
value: fs$closeSync
|
|
990
990
|
});
|
|
991
991
|
return closeSync2;
|
|
992
|
-
})(
|
|
992
|
+
})(fs21.closeSync);
|
|
993
993
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
994
994
|
process.on("exit", function() {
|
|
995
|
-
debug(
|
|
996
|
-
require("assert").equal(
|
|
995
|
+
debug(fs21[gracefulQueue]);
|
|
996
|
+
require("assert").equal(fs21[gracefulQueue].length, 0);
|
|
997
997
|
});
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
1000
|
var queue;
|
|
1001
1001
|
if (!global[gracefulQueue]) {
|
|
1002
|
-
publishQueue(global,
|
|
1003
|
-
}
|
|
1004
|
-
module2.exports = patch(clone(
|
|
1005
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !
|
|
1006
|
-
module2.exports = patch(
|
|
1007
|
-
|
|
1008
|
-
}
|
|
1009
|
-
function patch(
|
|
1010
|
-
polyfills(
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
var fs$readFile =
|
|
1015
|
-
|
|
1016
|
-
function readFile(
|
|
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) {
|
|
1017
1017
|
if (typeof options === "function")
|
|
1018
1018
|
cb = options, options = null;
|
|
1019
|
-
return go$readFile(
|
|
1020
|
-
function go$readFile(
|
|
1021
|
-
return fs$readFile(
|
|
1019
|
+
return go$readFile(path28, options, cb);
|
|
1020
|
+
function go$readFile(path29, options2, cb2, startTime) {
|
|
1021
|
+
return fs$readFile(path29, options2, function(err) {
|
|
1022
1022
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
1023
|
-
enqueue([go$readFile, [
|
|
1023
|
+
enqueue([go$readFile, [path29, 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 =
|
|
1032
|
-
|
|
1033
|
-
function writeFile(
|
|
1031
|
+
var fs$writeFile = fs22.writeFile;
|
|
1032
|
+
fs22.writeFile = writeFile;
|
|
1033
|
+
function writeFile(path28, data, options, cb) {
|
|
1034
1034
|
if (typeof options === "function")
|
|
1035
1035
|
cb = options, options = null;
|
|
1036
|
-
return go$writeFile(
|
|
1037
|
-
function go$writeFile(
|
|
1038
|
-
return fs$writeFile(
|
|
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) {
|
|
1039
1039
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
1040
|
-
enqueue([go$writeFile, [
|
|
1040
|
+
enqueue([go$writeFile, [path29, 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 =
|
|
1048
|
+
var fs$appendFile = fs22.appendFile;
|
|
1049
1049
|
if (fs$appendFile)
|
|
1050
|
-
|
|
1051
|
-
function appendFile(
|
|
1050
|
+
fs22.appendFile = appendFile;
|
|
1051
|
+
function appendFile(path28, data, options, cb) {
|
|
1052
1052
|
if (typeof options === "function")
|
|
1053
1053
|
cb = options, options = null;
|
|
1054
|
-
return go$appendFile(
|
|
1055
|
-
function go$appendFile(
|
|
1056
|
-
return fs$appendFile(
|
|
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) {
|
|
1057
1057
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
1058
|
-
enqueue([go$appendFile, [
|
|
1058
|
+
enqueue([go$appendFile, [path29, 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 =
|
|
1066
|
+
var fs$copyFile = fs22.copyFile;
|
|
1067
1067
|
if (fs$copyFile)
|
|
1068
|
-
|
|
1068
|
+
fs22.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 =
|
|
1087
|
-
|
|
1086
|
+
var fs$readdir = fs22.readdir;
|
|
1087
|
+
fs22.readdir = readdir;
|
|
1088
1088
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
1089
|
-
function readdir(
|
|
1089
|
+
function readdir(path28, 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(
|
|
1093
|
-
return fs$readdir(
|
|
1094
|
-
|
|
1092
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path29, options2, cb2, startTime) {
|
|
1093
|
+
return fs$readdir(path29, fs$readdirCallback(
|
|
1094
|
+
path29,
|
|
1095
1095
|
options2,
|
|
1096
1096
|
cb2,
|
|
1097
1097
|
startTime
|
|
1098
1098
|
));
|
|
1099
|
-
} : function go$readdir2(
|
|
1100
|
-
return fs$readdir(
|
|
1101
|
-
|
|
1099
|
+
} : function go$readdir2(path29, options2, cb2, startTime) {
|
|
1100
|
+
return fs$readdir(path29, options2, fs$readdirCallback(
|
|
1101
|
+
path29,
|
|
1102
1102
|
options2,
|
|
1103
1103
|
cb2,
|
|
1104
1104
|
startTime
|
|
1105
1105
|
));
|
|
1106
1106
|
};
|
|
1107
|
-
return go$readdir(
|
|
1108
|
-
function fs$readdirCallback(
|
|
1107
|
+
return go$readdir(path28, options, cb);
|
|
1108
|
+
function fs$readdirCallback(path29, 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
|
-
[
|
|
1113
|
+
[path29, 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(
|
|
1128
|
+
var legStreams = legacy(fs22);
|
|
1129
1129
|
ReadStream = legStreams.ReadStream;
|
|
1130
1130
|
WriteStream = legStreams.WriteStream;
|
|
1131
1131
|
}
|
|
1132
|
-
var fs$ReadStream =
|
|
1132
|
+
var fs$ReadStream = fs22.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 =
|
|
1137
|
+
var fs$WriteStream = fs22.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(
|
|
1142
|
+
Object.defineProperty(fs22, "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(
|
|
1152
|
+
Object.defineProperty(fs22, "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(
|
|
1163
|
+
Object.defineProperty(fs22, "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(
|
|
1174
|
+
Object.defineProperty(fs22, "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(
|
|
1184
|
+
function ReadStream(path28, 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(
|
|
1204
|
+
function WriteStream(path28, 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(
|
|
1223
|
-
return new
|
|
1222
|
+
function createReadStream(path28, options) {
|
|
1223
|
+
return new fs22.ReadStream(path28, options);
|
|
1224
1224
|
}
|
|
1225
|
-
function createWriteStream(
|
|
1226
|
-
return new
|
|
1225
|
+
function createWriteStream(path28, options) {
|
|
1226
|
+
return new fs22.WriteStream(path28, options);
|
|
1227
1227
|
}
|
|
1228
|
-
var fs$open =
|
|
1229
|
-
|
|
1230
|
-
function open(
|
|
1228
|
+
var fs$open = fs22.open;
|
|
1229
|
+
fs22.open = open;
|
|
1230
|
+
function open(path28, flags, mode, cb) {
|
|
1231
1231
|
if (typeof mode === "function")
|
|
1232
1232
|
cb = mode, mode = null;
|
|
1233
|
-
return go$open(
|
|
1234
|
-
function go$open(
|
|
1235
|
-
return fs$open(
|
|
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) {
|
|
1236
1236
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
1237
|
-
enqueue([go$open, [
|
|
1237
|
+
enqueue([go$open, [path29, 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
|
|
1245
|
+
return fs22;
|
|
1246
1246
|
}
|
|
1247
1247
|
function enqueue(elem) {
|
|
1248
1248
|
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
1249
|
-
|
|
1249
|
+
fs21[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 <
|
|
1256
|
-
if (
|
|
1257
|
-
|
|
1258
|
-
|
|
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;
|
|
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 (
|
|
1266
|
+
if (fs21[gracefulQueue].length === 0)
|
|
1267
1267
|
return;
|
|
1268
|
-
var elem =
|
|
1268
|
+
var elem = fs21[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
|
-
|
|
1290
|
+
fs21[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,
|
|
1726
|
-
const cachedPrecision =
|
|
1725
|
+
function probe(file, fs21, callback) {
|
|
1726
|
+
const cachedPrecision = fs21[cacheSymbol];
|
|
1727
1727
|
if (cachedPrecision) {
|
|
1728
|
-
return
|
|
1728
|
+
return fs21.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
|
-
|
|
1736
|
+
fs21.utimes(file, mtime, mtime, (err) => {
|
|
1737
1737
|
if (err) {
|
|
1738
1738
|
return callback(err);
|
|
1739
1739
|
}
|
|
1740
|
-
|
|
1740
|
+
fs21.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(
|
|
1745
|
+
Object.defineProperty(fs21, 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
|
|
1767
|
-
var
|
|
1766
|
+
var path28 = require("path");
|
|
1767
|
+
var fs21 = 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,
|
|
1777
|
+
return callback(null, path28.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:
|
|
1898
|
+
fs: fs21,
|
|
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:
|
|
1942
|
+
fs: fs21,
|
|
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:
|
|
1964
|
+
fs: fs21,
|
|
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
|
|
2004
|
-
function createSyncFs(
|
|
2003
|
+
var fs21 = require_graceful_fs();
|
|
2004
|
+
function createSyncFs(fs22) {
|
|
2005
2005
|
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
2006
|
-
const newFs = { ...
|
|
2006
|
+
const newFs = { ...fs22 };
|
|
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 =
|
|
2012
|
+
ret = fs22[`${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 ||
|
|
2050
|
+
options.fs = createSyncFs(options.fs || fs21);
|
|
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
|
}
|
|
@@ -2702,7 +2702,7 @@ var require_age_encryption = __commonJS({
|
|
|
2702
2702
|
};
|
|
2703
2703
|
}
|
|
2704
2704
|
// @__NO_SIDE_EFFECTS__
|
|
2705
|
-
function
|
|
2705
|
+
function join20(separator = "") {
|
|
2706
2706
|
astr("join", separator);
|
|
2707
2707
|
return {
|
|
2708
2708
|
encode: (from) => {
|
|
@@ -2832,9 +2832,9 @@ var require_age_encryption = __commonJS({
|
|
|
2832
2832
|
decode(s) {
|
|
2833
2833
|
return decodeBase64Builtin(s, false);
|
|
2834
2834
|
}
|
|
2835
|
-
} : /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ padding(6), /* @__PURE__ */
|
|
2836
|
-
var base64nopad = /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */
|
|
2837
|
-
var BECH_ALPHABET = /* @__PURE__ */ chain(/* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */
|
|
2835
|
+
} : /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ padding(6), /* @__PURE__ */ join20(""));
|
|
2836
|
+
var base64nopad = /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ join20(""));
|
|
2837
|
+
var BECH_ALPHABET = /* @__PURE__ */ chain(/* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ join20(""));
|
|
2838
2838
|
var POLYMOD_GENERATORS = [996825010, 642813549, 513874426, 1027748829, 705979059];
|
|
2839
2839
|
function bech32Polymod(pre) {
|
|
2840
2840
|
const b = pre >> 25;
|
|
@@ -9030,11 +9030,14 @@ __export(index_exports, {
|
|
|
9030
9030
|
GitIntegration: () => GitIntegration,
|
|
9031
9031
|
GitOperationError: () => GitOperationError,
|
|
9032
9032
|
ImportRunner: () => ImportRunner,
|
|
9033
|
+
InvalidArtifactError: () => InvalidArtifactError,
|
|
9034
|
+
JsonEnvelopeBackend: () => JsonEnvelopeBackend,
|
|
9033
9035
|
LintRunner: () => LintRunner,
|
|
9034
9036
|
ManifestParser: () => ManifestParser,
|
|
9035
9037
|
ManifestValidationError: () => ManifestValidationError,
|
|
9036
9038
|
MatrixManager: () => MatrixManager,
|
|
9037
9039
|
MemoryPackOutput: () => MemoryPackOutput,
|
|
9040
|
+
PackBackendRegistry: () => PackBackendRegistry,
|
|
9038
9041
|
PolicyEvaluator: () => PolicyEvaluator,
|
|
9039
9042
|
PolicyParser: () => PolicyParser,
|
|
9040
9043
|
PolicyValidationError: () => PolicyValidationError,
|
|
@@ -9063,6 +9066,7 @@ __export(index_exports, {
|
|
|
9063
9066
|
TransactionPreflightError: () => TransactionPreflightError,
|
|
9064
9067
|
TransactionRollbackError: () => TransactionRollbackError,
|
|
9065
9068
|
VALID_KMS_PROVIDERS: () => VALID_KMS_PROVIDERS,
|
|
9069
|
+
assertPackedArtifact: () => assertPackedArtifact,
|
|
9066
9070
|
assertSops: () => assertSops,
|
|
9067
9071
|
buildSigningPayload: () => buildSigningPayload,
|
|
9068
9072
|
checkAll: () => checkAll,
|
|
@@ -9079,8 +9083,10 @@ __export(index_exports, {
|
|
|
9079
9083
|
generateSigningKeyPair: () => generateSigningKeyPair,
|
|
9080
9084
|
getPendingKeys: () => getPendingKeys,
|
|
9081
9085
|
getRotations: () => getRotations,
|
|
9086
|
+
isClefHsmArn: () => isClefHsmArn,
|
|
9082
9087
|
isHighEntropy: () => isHighEntropy,
|
|
9083
9088
|
isKmsEnvelope: () => isKmsEnvelope,
|
|
9089
|
+
isPackedArtifact: () => isPackedArtifact,
|
|
9084
9090
|
isPending: () => isPending,
|
|
9085
9091
|
keyPreview: () => keyPreview,
|
|
9086
9092
|
loadIgnoreRules: () => loadIgnoreRules,
|
|
@@ -9098,15 +9104,18 @@ __export(index_exports, {
|
|
|
9098
9104
|
parseIgnoreContent: () => parseIgnoreContent,
|
|
9099
9105
|
parseJson: () => parseJson,
|
|
9100
9106
|
parseYaml: () => parseYaml,
|
|
9107
|
+
pkcs11UriToSyntheticArn: () => pkcs11UriToSyntheticArn,
|
|
9101
9108
|
readManifestYaml: () => readManifestYaml,
|
|
9102
9109
|
recordRotation: () => recordRotation,
|
|
9103
9110
|
redactValue: () => redactValue,
|
|
9104
9111
|
removeAccessRequest: () => removeRequest,
|
|
9105
9112
|
removeRotation: () => removeRotation,
|
|
9106
9113
|
requestsFilePath: () => requestsFilePath,
|
|
9114
|
+
resetKeyserviceResolution: () => resetKeyserviceResolution,
|
|
9107
9115
|
resetSopsResolution: () => resetSopsResolution,
|
|
9108
9116
|
resolveBackendConfig: () => resolveBackendConfig,
|
|
9109
9117
|
resolveIdentitySecrets: () => resolveIdentitySecrets,
|
|
9118
|
+
resolveKeyservicePath: () => resolveKeyservicePath,
|
|
9110
9119
|
resolveRecipientsForEnvironment: () => resolveRecipientsForEnvironment,
|
|
9111
9120
|
resolveSopsPath: () => resolveSopsPath,
|
|
9112
9121
|
runCompliance: () => runCompliance,
|
|
@@ -9117,8 +9126,12 @@ __export(index_exports, {
|
|
|
9117
9126
|
shouldIgnoreMatch: () => shouldIgnoreMatch,
|
|
9118
9127
|
signEd25519: () => signEd25519,
|
|
9119
9128
|
signKms: () => signKms,
|
|
9129
|
+
spawnKeyservice: () => spawnKeyservice,
|
|
9130
|
+
syntheticArnToPkcs11Uri: () => syntheticArnToPkcs11Uri,
|
|
9131
|
+
tryBundledKeyservice: () => tryBundledKeyservice,
|
|
9120
9132
|
upsertRequest: () => upsertRequest,
|
|
9121
9133
|
validateAgePublicKey: () => validateAgePublicKey,
|
|
9134
|
+
validatePackedArtifact: () => validatePackedArtifact,
|
|
9122
9135
|
validateResetScope: () => validateResetScope,
|
|
9123
9136
|
verifySignature: () => verifySignature,
|
|
9124
9137
|
writeManifestYaml: () => writeManifestYaml,
|
|
@@ -9136,7 +9149,8 @@ function resolveBackendConfig(manifest, environment) {
|
|
|
9136
9149
|
aws_kms_arn: manifest.sops.aws_kms_arn,
|
|
9137
9150
|
gcp_kms_resource_id: manifest.sops.gcp_kms_resource_id,
|
|
9138
9151
|
azure_kv_url: manifest.sops.azure_kv_url,
|
|
9139
|
-
pgp_fingerprint: manifest.sops.pgp_fingerprint
|
|
9152
|
+
pgp_fingerprint: manifest.sops.pgp_fingerprint,
|
|
9153
|
+
pkcs11_uri: manifest.sops.pkcs11_uri
|
|
9140
9154
|
};
|
|
9141
9155
|
}
|
|
9142
9156
|
function resolveRecipientsForEnvironment(manifest, environment) {
|
|
@@ -9283,7 +9297,8 @@ function keyPreview(key) {
|
|
|
9283
9297
|
|
|
9284
9298
|
// src/manifest/parser.ts
|
|
9285
9299
|
var CLEF_MANIFEST_FILENAME = "clef.yaml";
|
|
9286
|
-
var VALID_BACKENDS = ["age", "awskms", "gcpkms", "azurekv", "pgp"];
|
|
9300
|
+
var VALID_BACKENDS = ["age", "awskms", "gcpkms", "azurekv", "pgp", "hsm"];
|
|
9301
|
+
var PKCS11_URI_PATTERN = /^pkcs11:[a-zA-Z][a-zA-Z0-9_-]*=[^;]+/;
|
|
9287
9302
|
var VALID_TOP_LEVEL_KEYS = [
|
|
9288
9303
|
"version",
|
|
9289
9304
|
"environments",
|
|
@@ -9442,12 +9457,27 @@ var ManifestParser = class {
|
|
|
9442
9457
|
"environments"
|
|
9443
9458
|
);
|
|
9444
9459
|
}
|
|
9460
|
+
if (backend === "hsm") {
|
|
9461
|
+
if (typeof sopsOverride.pkcs11_uri !== "string") {
|
|
9462
|
+
throw new ManifestValidationError(
|
|
9463
|
+
`Environment '${envObj.name}' uses 'hsm' backend but is missing 'pkcs11_uri'.`,
|
|
9464
|
+
"environments"
|
|
9465
|
+
);
|
|
9466
|
+
}
|
|
9467
|
+
if (!PKCS11_URI_PATTERN.test(sopsOverride.pkcs11_uri)) {
|
|
9468
|
+
throw new ManifestValidationError(
|
|
9469
|
+
`Environment '${envObj.name}' has an invalid 'pkcs11_uri' '${sopsOverride.pkcs11_uri}'. Must start with 'pkcs11:' and contain at least one attribute (e.g. 'pkcs11:slot=0;label=clef-dek-wrapper').`,
|
|
9470
|
+
"environments"
|
|
9471
|
+
);
|
|
9472
|
+
}
|
|
9473
|
+
}
|
|
9445
9474
|
result.sops = {
|
|
9446
9475
|
backend,
|
|
9447
9476
|
...typeof sopsOverride.aws_kms_arn === "string" ? { aws_kms_arn: sopsOverride.aws_kms_arn } : {},
|
|
9448
9477
|
...typeof sopsOverride.gcp_kms_resource_id === "string" ? { gcp_kms_resource_id: sopsOverride.gcp_kms_resource_id } : {},
|
|
9449
9478
|
...typeof sopsOverride.azure_kv_url === "string" ? { azure_kv_url: sopsOverride.azure_kv_url } : {},
|
|
9450
|
-
...typeof sopsOverride.pgp_fingerprint === "string" ? { pgp_fingerprint: sopsOverride.pgp_fingerprint } : {}
|
|
9479
|
+
...typeof sopsOverride.pgp_fingerprint === "string" ? { pgp_fingerprint: sopsOverride.pgp_fingerprint } : {},
|
|
9480
|
+
...typeof sopsOverride.pkcs11_uri === "string" ? { pkcs11_uri: sopsOverride.pkcs11_uri } : {}
|
|
9451
9481
|
};
|
|
9452
9482
|
}
|
|
9453
9483
|
if (envObj.recipients !== void 0) {
|
|
@@ -9579,7 +9609,7 @@ var ManifestParser = class {
|
|
|
9579
9609
|
const sopsObj = obj.sops;
|
|
9580
9610
|
if (!sopsObj.default_backend || typeof sopsObj.default_backend !== "string") {
|
|
9581
9611
|
throw new ManifestValidationError(
|
|
9582
|
-
|
|
9612
|
+
`Field 'sops.default_backend' is required and must be one of: ${VALID_BACKENDS.join(", ")}.`,
|
|
9583
9613
|
"sops.default_backend"
|
|
9584
9614
|
);
|
|
9585
9615
|
}
|
|
@@ -9606,13 +9636,32 @@ var ManifestParser = class {
|
|
|
9606
9636
|
})
|
|
9607
9637
|
}
|
|
9608
9638
|
} : {};
|
|
9639
|
+
if (sopsObj.pkcs11_uri !== void 0 && typeof sopsObj.pkcs11_uri !== "string") {
|
|
9640
|
+
throw new ManifestValidationError(
|
|
9641
|
+
"Field 'sops.pkcs11_uri' must be a string.",
|
|
9642
|
+
"sops.pkcs11_uri"
|
|
9643
|
+
);
|
|
9644
|
+
}
|
|
9645
|
+
if (typeof sopsObj.pkcs11_uri === "string" && !PKCS11_URI_PATTERN.test(sopsObj.pkcs11_uri)) {
|
|
9646
|
+
throw new ManifestValidationError(
|
|
9647
|
+
`Field 'sops.pkcs11_uri' has invalid format '${sopsObj.pkcs11_uri}'. Must start with 'pkcs11:' and contain at least one attribute (e.g. 'pkcs11:slot=0;label=clef-dek-wrapper').`,
|
|
9648
|
+
"sops.pkcs11_uri"
|
|
9649
|
+
);
|
|
9650
|
+
}
|
|
9651
|
+
if (sopsObj.default_backend === "hsm" && typeof sopsObj.pkcs11_uri !== "string") {
|
|
9652
|
+
throw new ManifestValidationError(
|
|
9653
|
+
"Field 'sops.pkcs11_uri' is required when sops.default_backend is 'hsm'.",
|
|
9654
|
+
"sops.pkcs11_uri"
|
|
9655
|
+
);
|
|
9656
|
+
}
|
|
9609
9657
|
const sopsConfig = {
|
|
9610
9658
|
default_backend: sopsObj.default_backend,
|
|
9611
9659
|
...parsedAge,
|
|
9612
9660
|
...typeof sopsObj.aws_kms_arn === "string" ? { aws_kms_arn: sopsObj.aws_kms_arn } : {},
|
|
9613
9661
|
...typeof sopsObj.gcp_kms_resource_id === "string" ? { gcp_kms_resource_id: sopsObj.gcp_kms_resource_id } : {},
|
|
9614
9662
|
...typeof sopsObj.azure_kv_url === "string" ? { azure_kv_url: sopsObj.azure_kv_url } : {},
|
|
9615
|
-
...typeof sopsObj.pgp_fingerprint === "string" ? { pgp_fingerprint: sopsObj.pgp_fingerprint } : {}
|
|
9663
|
+
...typeof sopsObj.pgp_fingerprint === "string" ? { pgp_fingerprint: sopsObj.pgp_fingerprint } : {},
|
|
9664
|
+
...typeof sopsObj.pkcs11_uri === "string" ? { pkcs11_uri: sopsObj.pkcs11_uri } : {}
|
|
9616
9665
|
};
|
|
9617
9666
|
for (const env of environments) {
|
|
9618
9667
|
if (env.recipients && env.recipients.length > 0) {
|
|
@@ -11577,6 +11626,39 @@ ${privateKey}
|
|
|
11577
11626
|
`;
|
|
11578
11627
|
}
|
|
11579
11628
|
|
|
11629
|
+
// src/sops/hsm-arn.ts
|
|
11630
|
+
var CLEF_HSM_ARN_RE = /^arn:aws[\w-]*:kms:[^:]+:\d+:alias\/clef-hsm\/(v\d+)\/([A-Za-z0-9_-]+)$/;
|
|
11631
|
+
var ARN_PREFIX = "arn:aws:kms:us-east-1:000000000000:alias/clef-hsm/v1/";
|
|
11632
|
+
var SUPPORTED_VERSION = "v1";
|
|
11633
|
+
function pkcs11UriToSyntheticArn(uri) {
|
|
11634
|
+
if (!uri.startsWith("pkcs11:")) {
|
|
11635
|
+
throw new Error(`Expected a pkcs11 URI starting with 'pkcs11:', got '${uri}'.`);
|
|
11636
|
+
}
|
|
11637
|
+
const payload = Buffer.from(uri, "utf8").toString("base64url");
|
|
11638
|
+
const arn = ARN_PREFIX + payload;
|
|
11639
|
+
if (!CLEF_HSM_ARN_RE.test(arn)) {
|
|
11640
|
+
throw new Error(`Synthesized ARN failed self-validation: '${arn}'.`);
|
|
11641
|
+
}
|
|
11642
|
+
return arn;
|
|
11643
|
+
}
|
|
11644
|
+
function syntheticArnToPkcs11Uri(arn) {
|
|
11645
|
+
const match = CLEF_HSM_ARN_RE.exec(arn);
|
|
11646
|
+
if (!match) return null;
|
|
11647
|
+
const [, version, payload] = match;
|
|
11648
|
+
if (version !== SUPPORTED_VERSION) return null;
|
|
11649
|
+
let decoded;
|
|
11650
|
+
try {
|
|
11651
|
+
decoded = Buffer.from(payload, "base64url").toString("utf8");
|
|
11652
|
+
} catch {
|
|
11653
|
+
return null;
|
|
11654
|
+
}
|
|
11655
|
+
if (!decoded.startsWith("pkcs11:")) return null;
|
|
11656
|
+
return decoded;
|
|
11657
|
+
}
|
|
11658
|
+
function isClefHsmArn(arn) {
|
|
11659
|
+
return CLEF_HSM_ARN_RE.test(arn);
|
|
11660
|
+
}
|
|
11661
|
+
|
|
11580
11662
|
// src/sops/client.ts
|
|
11581
11663
|
function formatFromPath(filePath) {
|
|
11582
11664
|
return filePath.endsWith(".json") ? "json" : "yaml";
|
|
@@ -11608,14 +11690,25 @@ var SopsClient = class {
|
|
|
11608
11690
|
* to the subprocess environment.
|
|
11609
11691
|
* @param sopsPath - Optional explicit path to the sops binary. When omitted,
|
|
11610
11692
|
* resolved automatically via {@link resolveSopsPath}.
|
|
11693
|
+
* @param keyserviceAddr - Optional address of an external SOPS KeyService
|
|
11694
|
+
* sidecar (e.g. `tcp://127.0.0.1:12345`). When set, every SOPS invocation
|
|
11695
|
+
* includes `--enable-local-keyservice=false --keyservice <addr>` so KMS
|
|
11696
|
+
* wrap/unwrap is routed to the sidecar (used for the HSM backend, where
|
|
11697
|
+
* the sidecar is `clef-keyservice` talking PKCS#11 to the HSM).
|
|
11698
|
+
*
|
|
11699
|
+
* The flags are inserted **after** the SOPS subcommand — placing them
|
|
11700
|
+
* before is silently ignored by SOPS (a footgun discovered the first
|
|
11701
|
+
* time we shipped this).
|
|
11611
11702
|
*/
|
|
11612
|
-
constructor(runner, ageKeyFile, ageKey, sopsPath) {
|
|
11703
|
+
constructor(runner, ageKeyFile, ageKey, sopsPath, keyserviceAddr) {
|
|
11613
11704
|
this.runner = runner;
|
|
11614
11705
|
this.ageKeyFile = ageKeyFile;
|
|
11615
11706
|
this.ageKey = ageKey;
|
|
11616
11707
|
this.sopsCommand = sopsPath ?? resolveSopsPath().path;
|
|
11708
|
+
this.keyserviceArgs = keyserviceAddr ? Object.freeze(["--enable-local-keyservice=false", "--keyservice", keyserviceAddr]) : Object.freeze([]);
|
|
11617
11709
|
}
|
|
11618
11710
|
sopsCommand;
|
|
11711
|
+
keyserviceArgs;
|
|
11619
11712
|
buildSopsEnv() {
|
|
11620
11713
|
const env = {};
|
|
11621
11714
|
if (this.ageKey) {
|
|
@@ -11640,7 +11733,7 @@ var SopsClient = class {
|
|
|
11640
11733
|
const env = this.buildSopsEnv();
|
|
11641
11734
|
const result = await this.runner.run(
|
|
11642
11735
|
this.sopsCommand,
|
|
11643
|
-
["decrypt", "--output-type", fmt, filePath],
|
|
11736
|
+
["decrypt", ...this.keyserviceArgs, "--output-type", fmt, filePath],
|
|
11644
11737
|
{
|
|
11645
11738
|
...env ? { env } : {}
|
|
11646
11739
|
}
|
|
@@ -11707,6 +11800,7 @@ var SopsClient = class {
|
|
|
11707
11800
|
"--config",
|
|
11708
11801
|
configPath,
|
|
11709
11802
|
"encrypt",
|
|
11803
|
+
...this.keyserviceArgs,
|
|
11710
11804
|
...args,
|
|
11711
11805
|
"--input-type",
|
|
11712
11806
|
fmt,
|
|
@@ -11763,7 +11857,7 @@ var SopsClient = class {
|
|
|
11763
11857
|
const env = this.buildSopsEnv();
|
|
11764
11858
|
const result = await this.runner.run(
|
|
11765
11859
|
this.sopsCommand,
|
|
11766
|
-
["rotate", "-i", "--add-age", key, filePath],
|
|
11860
|
+
["rotate", ...this.keyserviceArgs, "-i", "--add-age", key, filePath],
|
|
11767
11861
|
{
|
|
11768
11862
|
...env ? { env } : {}
|
|
11769
11863
|
}
|
|
@@ -11787,7 +11881,7 @@ var SopsClient = class {
|
|
|
11787
11881
|
const env = this.buildSopsEnv();
|
|
11788
11882
|
const result = await this.runner.run(
|
|
11789
11883
|
this.sopsCommand,
|
|
11790
|
-
["rotate", "-i", "--rm-age", key, filePath],
|
|
11884
|
+
["rotate", ...this.keyserviceArgs, "-i", "--rm-age", key, filePath],
|
|
11791
11885
|
{
|
|
11792
11886
|
...env ? { env } : {}
|
|
11793
11887
|
}
|
|
@@ -11902,7 +11996,14 @@ var SopsClient = class {
|
|
|
11902
11996
|
}
|
|
11903
11997
|
detectBackend(sops) {
|
|
11904
11998
|
if (sops.age && Array.isArray(sops.age) && sops.age.length > 0) return "age";
|
|
11905
|
-
if (sops.kms && Array.isArray(sops.kms) && sops.kms.length > 0)
|
|
11999
|
+
if (sops.kms && Array.isArray(sops.kms) && sops.kms.length > 0) {
|
|
12000
|
+
const kmsEntries = sops.kms;
|
|
12001
|
+
const firstArn = kmsEntries[0]?.arn;
|
|
12002
|
+
if (typeof firstArn === "string" && isClefHsmArn(firstArn)) {
|
|
12003
|
+
return "hsm";
|
|
12004
|
+
}
|
|
12005
|
+
return "awskms";
|
|
12006
|
+
}
|
|
11906
12007
|
if (sops.gcp_kms && Array.isArray(sops.gcp_kms) && sops.gcp_kms.length > 0)
|
|
11907
12008
|
return "gcpkms";
|
|
11908
12009
|
if (sops.azure_kv && Array.isArray(sops.azure_kv) && sops.azure_kv.length > 0)
|
|
@@ -11920,6 +12021,13 @@ var SopsClient = class {
|
|
|
11920
12021
|
const entries = sops.kms;
|
|
11921
12022
|
return entries?.map((e) => String(e.arn ?? "")) ?? [];
|
|
11922
12023
|
}
|
|
12024
|
+
case "hsm": {
|
|
12025
|
+
const entries = sops.kms;
|
|
12026
|
+
return entries?.map((e) => {
|
|
12027
|
+
const raw = String(e.arn ?? "");
|
|
12028
|
+
return syntheticArnToPkcs11Uri(raw) ?? raw;
|
|
12029
|
+
}) ?? [];
|
|
12030
|
+
}
|
|
11923
12031
|
case "gcpkms": {
|
|
11924
12032
|
const entries = sops.gcp_kms;
|
|
11925
12033
|
return entries?.map((e) => String(e.resource_id ?? "")) ?? [];
|
|
@@ -11945,7 +12053,8 @@ var SopsClient = class {
|
|
|
11945
12053
|
aws_kms_arn: manifest.sops.aws_kms_arn,
|
|
11946
12054
|
gcp_kms_resource_id: manifest.sops.gcp_kms_resource_id,
|
|
11947
12055
|
azure_kv_url: manifest.sops.azure_kv_url,
|
|
11948
|
-
pgp_fingerprint: manifest.sops.pgp_fingerprint
|
|
12056
|
+
pgp_fingerprint: manifest.sops.pgp_fingerprint,
|
|
12057
|
+
pkcs11_uri: manifest.sops.pkcs11_uri
|
|
11949
12058
|
};
|
|
11950
12059
|
switch (config.backend) {
|
|
11951
12060
|
case "age": {
|
|
@@ -11977,13 +12086,172 @@ var SopsClient = class {
|
|
|
11977
12086
|
args.push("--pgp", config.pgp_fingerprint);
|
|
11978
12087
|
}
|
|
11979
12088
|
break;
|
|
12089
|
+
case "hsm":
|
|
12090
|
+
if (config.pkcs11_uri) {
|
|
12091
|
+
args.push("--kms", pkcs11UriToSyntheticArn(config.pkcs11_uri));
|
|
12092
|
+
}
|
|
12093
|
+
break;
|
|
11980
12094
|
}
|
|
11981
12095
|
return args;
|
|
11982
12096
|
}
|
|
11983
12097
|
};
|
|
11984
12098
|
|
|
11985
|
-
// src/
|
|
12099
|
+
// src/hsm/bundled.ts
|
|
12100
|
+
var fs14 = __toESM(require("fs"));
|
|
11986
12101
|
var path12 = __toESM(require("path"));
|
|
12102
|
+
function tryBundledKeyservice() {
|
|
12103
|
+
const platform = process.platform;
|
|
12104
|
+
const arch = process.arch;
|
|
12105
|
+
const archName = arch === "x64" ? "x64" : arch === "arm64" ? "arm64" : null;
|
|
12106
|
+
if (!archName) return null;
|
|
12107
|
+
const platformName = platform === "darwin" ? "darwin" : platform === "linux" ? "linux" : null;
|
|
12108
|
+
if (!platformName) return null;
|
|
12109
|
+
const packageName = `@clef-sh/keyservice-${platformName}-${archName}`;
|
|
12110
|
+
const binName = "clef-keyservice";
|
|
12111
|
+
try {
|
|
12112
|
+
const packageMain = require.resolve(`${packageName}/package.json`);
|
|
12113
|
+
const packageDir = path12.dirname(packageMain);
|
|
12114
|
+
const binPath = path12.join(packageDir, "bin", binName);
|
|
12115
|
+
return fs14.existsSync(binPath) ? binPath : null;
|
|
12116
|
+
} catch {
|
|
12117
|
+
return null;
|
|
12118
|
+
}
|
|
12119
|
+
}
|
|
12120
|
+
|
|
12121
|
+
// src/hsm/resolver.ts
|
|
12122
|
+
var fs15 = __toESM(require("fs"));
|
|
12123
|
+
var path13 = __toESM(require("path"));
|
|
12124
|
+
function validateKeyservicePath(candidate) {
|
|
12125
|
+
if (!path13.isAbsolute(candidate)) {
|
|
12126
|
+
throw new Error(`CLEF_KEYSERVICE_PATH must be an absolute path, got '${candidate}'.`);
|
|
12127
|
+
}
|
|
12128
|
+
const segments = candidate.split(/[/\\]/);
|
|
12129
|
+
if (segments.includes("..")) {
|
|
12130
|
+
throw new Error(
|
|
12131
|
+
`CLEF_KEYSERVICE_PATH contains '..' path segments ('${candidate}'). Use an absolute path without directory traversal.`
|
|
12132
|
+
);
|
|
12133
|
+
}
|
|
12134
|
+
}
|
|
12135
|
+
var cached2;
|
|
12136
|
+
function resolveKeyservicePath() {
|
|
12137
|
+
if (cached2) return cached2;
|
|
12138
|
+
const envPath = process.env.CLEF_KEYSERVICE_PATH?.trim();
|
|
12139
|
+
if (envPath) {
|
|
12140
|
+
validateKeyservicePath(envPath);
|
|
12141
|
+
if (!fs15.existsSync(envPath)) {
|
|
12142
|
+
throw new Error(`CLEF_KEYSERVICE_PATH points to '${envPath}' but the file does not exist.`);
|
|
12143
|
+
}
|
|
12144
|
+
cached2 = { path: envPath, source: "env" };
|
|
12145
|
+
return cached2;
|
|
12146
|
+
}
|
|
12147
|
+
const bundledPath = tryBundledKeyservice();
|
|
12148
|
+
if (bundledPath) {
|
|
12149
|
+
cached2 = { path: bundledPath, source: "bundled" };
|
|
12150
|
+
return cached2;
|
|
12151
|
+
}
|
|
12152
|
+
cached2 = { path: "clef-keyservice", source: "system" };
|
|
12153
|
+
return cached2;
|
|
12154
|
+
}
|
|
12155
|
+
function resetKeyserviceResolution() {
|
|
12156
|
+
cached2 = void 0;
|
|
12157
|
+
}
|
|
12158
|
+
|
|
12159
|
+
// src/hsm/keyservice.ts
|
|
12160
|
+
var import_child_process = require("child_process");
|
|
12161
|
+
var readline = __toESM(require("readline"));
|
|
12162
|
+
var PORT_REGEX = /^PORT=(\d+)$/;
|
|
12163
|
+
var STARTUP_TIMEOUT_MS = 5e3;
|
|
12164
|
+
var SHUTDOWN_TIMEOUT_MS = 3e3;
|
|
12165
|
+
async function spawnKeyservice(options) {
|
|
12166
|
+
if (!options.pin && !options.pinFile) {
|
|
12167
|
+
throw new Error(
|
|
12168
|
+
"Keyservice requires a PIN. Set CLEF_PKCS11_PIN, CLEF_PKCS11_PIN_FILE, or .clef/config.yaml pkcs11_pin_file."
|
|
12169
|
+
);
|
|
12170
|
+
}
|
|
12171
|
+
const args = ["--addr", "127.0.0.1:0", "--pkcs11-module", options.modulePath];
|
|
12172
|
+
const childEnv = {
|
|
12173
|
+
...process.env,
|
|
12174
|
+
...options.extraEnv ?? {},
|
|
12175
|
+
...options.pin ? { CLEF_PKCS11_PIN: options.pin } : {},
|
|
12176
|
+
...options.pinFile ? { CLEF_PKCS11_PIN_FILE: options.pinFile } : {}
|
|
12177
|
+
};
|
|
12178
|
+
const child = (0, import_child_process.spawn)(options.binaryPath, args, {
|
|
12179
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
12180
|
+
env: childEnv
|
|
12181
|
+
});
|
|
12182
|
+
const port = await readPort(child);
|
|
12183
|
+
return {
|
|
12184
|
+
addr: `tcp://127.0.0.1:${port}`,
|
|
12185
|
+
kill: () => killGracefully(child)
|
|
12186
|
+
};
|
|
12187
|
+
}
|
|
12188
|
+
function readPort(child) {
|
|
12189
|
+
return new Promise((resolve, reject) => {
|
|
12190
|
+
let settled = false;
|
|
12191
|
+
if (!child.stdout) {
|
|
12192
|
+
reject(new Error("Keyservice child has no stdout pipe."));
|
|
12193
|
+
return;
|
|
12194
|
+
}
|
|
12195
|
+
const rl = readline.createInterface({ input: child.stdout });
|
|
12196
|
+
const settle = () => {
|
|
12197
|
+
clearTimeout(timer);
|
|
12198
|
+
rl.close();
|
|
12199
|
+
};
|
|
12200
|
+
const timer = setTimeout(() => {
|
|
12201
|
+
if (!settled) {
|
|
12202
|
+
settled = true;
|
|
12203
|
+
settle();
|
|
12204
|
+
child.kill("SIGKILL");
|
|
12205
|
+
reject(
|
|
12206
|
+
new Error(
|
|
12207
|
+
`clef-keyservice did not report a port within ${STARTUP_TIMEOUT_MS}ms. Check that the PKCS#11 module path is valid and the PIN is correct.`
|
|
12208
|
+
)
|
|
12209
|
+
);
|
|
12210
|
+
}
|
|
12211
|
+
}, STARTUP_TIMEOUT_MS);
|
|
12212
|
+
rl.on("line", (line) => {
|
|
12213
|
+
const match = PORT_REGEX.exec(line);
|
|
12214
|
+
if (match && !settled) {
|
|
12215
|
+
settled = true;
|
|
12216
|
+
settle();
|
|
12217
|
+
resolve(parseInt(match[1], 10));
|
|
12218
|
+
}
|
|
12219
|
+
});
|
|
12220
|
+
child.on("error", (err) => {
|
|
12221
|
+
if (!settled) {
|
|
12222
|
+
settled = true;
|
|
12223
|
+
settle();
|
|
12224
|
+
reject(new Error(`Failed to start clef-keyservice: ${err.message}`));
|
|
12225
|
+
}
|
|
12226
|
+
});
|
|
12227
|
+
child.on("exit", (code) => {
|
|
12228
|
+
if (!settled) {
|
|
12229
|
+
settled = true;
|
|
12230
|
+
settle();
|
|
12231
|
+
reject(new Error(`clef-keyservice exited with code ${code} before reporting a port.`));
|
|
12232
|
+
}
|
|
12233
|
+
});
|
|
12234
|
+
});
|
|
12235
|
+
}
|
|
12236
|
+
function killGracefully(child) {
|
|
12237
|
+
return new Promise((resolve) => {
|
|
12238
|
+
if (child.exitCode !== null) {
|
|
12239
|
+
resolve();
|
|
12240
|
+
return;
|
|
12241
|
+
}
|
|
12242
|
+
const timer = setTimeout(() => {
|
|
12243
|
+
child.kill("SIGKILL");
|
|
12244
|
+
}, SHUTDOWN_TIMEOUT_MS);
|
|
12245
|
+
child.on("exit", () => {
|
|
12246
|
+
clearTimeout(timer);
|
|
12247
|
+
resolve();
|
|
12248
|
+
});
|
|
12249
|
+
child.kill("SIGTERM");
|
|
12250
|
+
});
|
|
12251
|
+
}
|
|
12252
|
+
|
|
12253
|
+
// src/lint/runner.ts
|
|
12254
|
+
var path14 = __toESM(require("path"));
|
|
11987
12255
|
var LintRunner = class {
|
|
11988
12256
|
constructor(matrixManager, schemaValidator, sopsClient) {
|
|
11989
12257
|
this.matrixManager = matrixManager;
|
|
@@ -12083,7 +12351,7 @@ var LintRunner = class {
|
|
|
12083
12351
|
}
|
|
12084
12352
|
const ns = manifest.namespaces.find((n) => n.name === cell.namespace);
|
|
12085
12353
|
if (ns?.schema) {
|
|
12086
|
-
const schemaPath =
|
|
12354
|
+
const schemaPath = path14.join(repoRoot, ns.schema);
|
|
12087
12355
|
try {
|
|
12088
12356
|
const schema = this.schemaValidator.loadSchema(schemaPath);
|
|
12089
12357
|
const result = this.schemaValidator.validate(decrypted.values, schema);
|
|
@@ -12370,14 +12638,14 @@ Use 'clef exec' to inject secrets directly into a process, or 'clef export --for
|
|
|
12370
12638
|
};
|
|
12371
12639
|
|
|
12372
12640
|
// src/import/index.ts
|
|
12373
|
-
var
|
|
12641
|
+
var path16 = __toESM(require("path"));
|
|
12374
12642
|
|
|
12375
12643
|
// src/import/parsers.ts
|
|
12376
|
-
var
|
|
12644
|
+
var path15 = __toESM(require("path"));
|
|
12377
12645
|
var YAML8 = __toESM(require("yaml"));
|
|
12378
12646
|
function detectFormat(filePath, content) {
|
|
12379
|
-
const base =
|
|
12380
|
-
const ext =
|
|
12647
|
+
const base = path15.basename(filePath);
|
|
12648
|
+
const ext = path15.extname(filePath).toLowerCase();
|
|
12381
12649
|
if (base === ".env" || base.startsWith(".env.")) {
|
|
12382
12650
|
return "dotenv";
|
|
12383
12651
|
}
|
|
@@ -12543,7 +12811,7 @@ var ImportRunner = class {
|
|
|
12543
12811
|
*/
|
|
12544
12812
|
async import(target, sourcePath, content, manifest, repoRoot, options) {
|
|
12545
12813
|
const [ns, env] = target.split("/");
|
|
12546
|
-
const filePath =
|
|
12814
|
+
const filePath = path16.join(
|
|
12547
12815
|
repoRoot,
|
|
12548
12816
|
manifest.file_pattern.replace("{namespace}", ns).replace("{environment}", env)
|
|
12549
12817
|
);
|
|
@@ -12595,7 +12863,7 @@ var ImportRunner = class {
|
|
|
12595
12863
|
if (imported.length === 0) {
|
|
12596
12864
|
return { imported, skipped, failed, warnings, dryRun: false };
|
|
12597
12865
|
}
|
|
12598
|
-
const relCellPath =
|
|
12866
|
+
const relCellPath = path16.relative(repoRoot, filePath);
|
|
12599
12867
|
const relMetaPath = relCellPath.replace(/\.enc\.(yaml|json)$/, ".clef-meta.yaml");
|
|
12600
12868
|
await this.tx.run(repoRoot, {
|
|
12601
12869
|
description: `clef import ${target}: ${imported.length} key(s)`,
|
|
@@ -12614,7 +12882,7 @@ var ImportRunner = class {
|
|
|
12614
12882
|
};
|
|
12615
12883
|
|
|
12616
12884
|
// src/recipients/index.ts
|
|
12617
|
-
var
|
|
12885
|
+
var path17 = __toESM(require("path"));
|
|
12618
12886
|
function parseRecipientEntry(entry) {
|
|
12619
12887
|
if (typeof entry === "string") {
|
|
12620
12888
|
return { key: entry };
|
|
@@ -12739,7 +13007,7 @@ var RecipientManager = class {
|
|
|
12739
13007
|
const reEncryptedFiles = [];
|
|
12740
13008
|
await this.tx.run(repoRoot, {
|
|
12741
13009
|
description: environment ? `clef recipients add ${keyPreview(normalizedKey)} -e ${environment}` : `clef recipients add ${keyPreview(normalizedKey)}`,
|
|
12742
|
-
paths: [...cells.map((c) =>
|
|
13010
|
+
paths: [...cells.map((c) => path17.relative(repoRoot, c.filePath)), CLEF_MANIFEST_FILENAME],
|
|
12743
13011
|
mutate: async () => {
|
|
12744
13012
|
const doc = readManifestYaml(repoRoot);
|
|
12745
13013
|
const recipients = environment ? ensureEnvironmentRecipientsArray(doc, environment) : ensureRecipientsArray(doc);
|
|
@@ -12798,7 +13066,7 @@ var RecipientManager = class {
|
|
|
12798
13066
|
const reEncryptedFiles = [];
|
|
12799
13067
|
await this.tx.run(repoRoot, {
|
|
12800
13068
|
description: environment ? `clef recipients remove ${keyPreview(trimmedKey)} -e ${environment}` : `clef recipients remove ${keyPreview(trimmedKey)}`,
|
|
12801
|
-
paths: [...cells.map((c) =>
|
|
13069
|
+
paths: [...cells.map((c) => path17.relative(repoRoot, c.filePath)), CLEF_MANIFEST_FILENAME],
|
|
12802
13070
|
mutate: async () => {
|
|
12803
13071
|
const doc = readManifestYaml(repoRoot);
|
|
12804
13072
|
const recipients = environment ? ensureEnvironmentRecipientsArray(doc, environment) : ensureRecipientsArray(doc);
|
|
@@ -12827,19 +13095,19 @@ var RecipientManager = class {
|
|
|
12827
13095
|
};
|
|
12828
13096
|
|
|
12829
13097
|
// src/recipients/requests.ts
|
|
12830
|
-
var
|
|
12831
|
-
var
|
|
13098
|
+
var fs16 = __toESM(require("fs"));
|
|
13099
|
+
var path18 = __toESM(require("path"));
|
|
12832
13100
|
var YAML9 = __toESM(require("yaml"));
|
|
12833
13101
|
var REQUESTS_FILENAME = ".clef-requests.yaml";
|
|
12834
13102
|
var HEADER_COMMENT2 = "# Pending recipient access requests. Approve with: clef recipients approve <label>\n";
|
|
12835
13103
|
function requestsFilePath(repoRoot) {
|
|
12836
|
-
return
|
|
13104
|
+
return path18.join(repoRoot, REQUESTS_FILENAME);
|
|
12837
13105
|
}
|
|
12838
13106
|
function loadRequests(repoRoot) {
|
|
12839
13107
|
const filePath = requestsFilePath(repoRoot);
|
|
12840
13108
|
try {
|
|
12841
|
-
if (!
|
|
12842
|
-
const content =
|
|
13109
|
+
if (!fs16.existsSync(filePath)) return [];
|
|
13110
|
+
const content = fs16.readFileSync(filePath, "utf-8");
|
|
12843
13111
|
const parsed = YAML9.parse(content);
|
|
12844
13112
|
if (!parsed || !Array.isArray(parsed.requests)) return [];
|
|
12845
13113
|
return parsed.requests.map((r) => ({
|
|
@@ -12856,7 +13124,7 @@ function saveRequests(repoRoot, requests) {
|
|
|
12856
13124
|
const filePath = requestsFilePath(repoRoot);
|
|
12857
13125
|
if (requests.length === 0) {
|
|
12858
13126
|
try {
|
|
12859
|
-
|
|
13127
|
+
fs16.unlinkSync(filePath);
|
|
12860
13128
|
} catch {
|
|
12861
13129
|
}
|
|
12862
13130
|
return;
|
|
@@ -12872,7 +13140,7 @@ function saveRequests(repoRoot, requests) {
|
|
|
12872
13140
|
return raw;
|
|
12873
13141
|
})
|
|
12874
13142
|
};
|
|
12875
|
-
|
|
13143
|
+
fs16.writeFileSync(filePath, HEADER_COMMENT2 + YAML9.stringify(data), "utf-8");
|
|
12876
13144
|
}
|
|
12877
13145
|
function upsertRequest(repoRoot, key, label, environment) {
|
|
12878
13146
|
const requests = loadRequests(repoRoot);
|
|
@@ -12908,7 +13176,7 @@ function findInList(requests, identifier) {
|
|
|
12908
13176
|
}
|
|
12909
13177
|
|
|
12910
13178
|
// src/drift/detector.ts
|
|
12911
|
-
var
|
|
13179
|
+
var path19 = __toESM(require("path"));
|
|
12912
13180
|
var DriftDetector = class {
|
|
12913
13181
|
parser = new ManifestParser();
|
|
12914
13182
|
matrix = new MatrixManager();
|
|
@@ -12921,8 +13189,8 @@ var DriftDetector = class {
|
|
|
12921
13189
|
* @returns Drift result with any issues found.
|
|
12922
13190
|
*/
|
|
12923
13191
|
detect(localRoot, remoteRoot, namespaceFilter) {
|
|
12924
|
-
const localManifest = this.parser.parse(
|
|
12925
|
-
const remoteManifest = this.parser.parse(
|
|
13192
|
+
const localManifest = this.parser.parse(path19.join(localRoot, CLEF_MANIFEST_FILENAME));
|
|
13193
|
+
const remoteManifest = this.parser.parse(path19.join(remoteRoot, CLEF_MANIFEST_FILENAME));
|
|
12926
13194
|
const localCells = this.matrix.resolveMatrix(localManifest, localRoot);
|
|
12927
13195
|
const remoteCells = this.matrix.resolveMatrix(remoteManifest, remoteRoot);
|
|
12928
13196
|
const localEnvNames = localManifest.environments.map((e) => e.name);
|
|
@@ -12986,7 +13254,7 @@ var DriftDetector = class {
|
|
|
12986
13254
|
};
|
|
12987
13255
|
|
|
12988
13256
|
// src/report/generator.ts
|
|
12989
|
-
var
|
|
13257
|
+
var path20 = __toESM(require("path"));
|
|
12990
13258
|
|
|
12991
13259
|
// src/report/sanitizer.ts
|
|
12992
13260
|
var ReportSanitizer = class {
|
|
@@ -13142,7 +13410,7 @@ var ReportGenerator = class {
|
|
|
13142
13410
|
let manifest = null;
|
|
13143
13411
|
try {
|
|
13144
13412
|
const parser = new ManifestParser();
|
|
13145
|
-
manifest = parser.parse(
|
|
13413
|
+
manifest = parser.parse(path20.join(repoRoot, "clef.yaml"));
|
|
13146
13414
|
} catch {
|
|
13147
13415
|
const emptyManifest = {
|
|
13148
13416
|
manifestVersion: 0,
|
|
@@ -13620,7 +13888,7 @@ var SopsMergeDriver = class {
|
|
|
13620
13888
|
};
|
|
13621
13889
|
|
|
13622
13890
|
// src/merge/metadata-driver.ts
|
|
13623
|
-
var
|
|
13891
|
+
var fs17 = __toESM(require("fs"));
|
|
13624
13892
|
var YAML10 = __toESM(require("yaml"));
|
|
13625
13893
|
var HEADER_COMMENT3 = "# Managed by Clef. Do not edit manually.\n";
|
|
13626
13894
|
function parseMetadata(content) {
|
|
@@ -13723,14 +13991,14 @@ function mergeMetadataContents(oursContent, theirsContent) {
|
|
|
13723
13991
|
return serializeMetadata({ version: 1, pending, rotations });
|
|
13724
13992
|
}
|
|
13725
13993
|
function mergeMetadataFiles(_basePath, oursPath, theirsPath) {
|
|
13726
|
-
const oursContent =
|
|
13727
|
-
const theirsContent =
|
|
13994
|
+
const oursContent = fs17.existsSync(oursPath) ? fs17.readFileSync(oursPath, "utf-8") : "";
|
|
13995
|
+
const theirsContent = fs17.existsSync(theirsPath) ? fs17.readFileSync(theirsPath, "utf-8") : "";
|
|
13728
13996
|
const merged = mergeMetadataContents(oursContent, theirsContent);
|
|
13729
|
-
|
|
13997
|
+
fs17.writeFileSync(oursPath, merged, "utf-8");
|
|
13730
13998
|
}
|
|
13731
13999
|
|
|
13732
14000
|
// src/service-identity/manager.ts
|
|
13733
|
-
var
|
|
14001
|
+
var path21 = __toESM(require("path"));
|
|
13734
14002
|
var ServiceIdentityManager = class {
|
|
13735
14003
|
constructor(encryption, matrixManager, tx) {
|
|
13736
14004
|
this.encryption = encryption;
|
|
@@ -13742,7 +14010,7 @@ var ServiceIdentityManager = class {
|
|
|
13742
14010
|
* to seed TransactionManager.run's `paths` argument.
|
|
13743
14011
|
*/
|
|
13744
14012
|
txPaths(repoRoot, cells) {
|
|
13745
|
-
return [...cells.map((c) =>
|
|
14013
|
+
return [...cells.map((c) => path21.relative(repoRoot, c.filePath)), CLEF_MANIFEST_FILENAME];
|
|
13746
14014
|
}
|
|
13747
14015
|
/**
|
|
13748
14016
|
* Create a new service identity with per-environment age key pairs or KMS envelope config.
|
|
@@ -14264,8 +14532,8 @@ var ServiceIdentityManager = class {
|
|
|
14264
14532
|
};
|
|
14265
14533
|
|
|
14266
14534
|
// src/structure/manager.ts
|
|
14267
|
-
var
|
|
14268
|
-
var
|
|
14535
|
+
var fs18 = __toESM(require("fs"));
|
|
14536
|
+
var path22 = __toESM(require("path"));
|
|
14269
14537
|
var StructureManager = class {
|
|
14270
14538
|
constructor(matrixManager, encryption, tx) {
|
|
14271
14539
|
this.matrixManager = matrixManager;
|
|
@@ -14286,15 +14554,15 @@ var StructureManager = class {
|
|
|
14286
14554
|
this.assertValidIdentifier("namespace", name);
|
|
14287
14555
|
const newCellPaths = manifest.environments.map((env) => ({
|
|
14288
14556
|
environment: env.name,
|
|
14289
|
-
filePath:
|
|
14557
|
+
filePath: path22.join(
|
|
14290
14558
|
repoRoot,
|
|
14291
14559
|
manifest.file_pattern.replace("{namespace}", name).replace("{environment}", env.name)
|
|
14292
14560
|
)
|
|
14293
14561
|
}));
|
|
14294
14562
|
for (const cell of newCellPaths) {
|
|
14295
|
-
if (
|
|
14563
|
+
if (fs18.existsSync(cell.filePath)) {
|
|
14296
14564
|
throw new Error(
|
|
14297
|
-
`Cannot add namespace '${name}': file '${
|
|
14565
|
+
`Cannot add namespace '${name}': file '${path22.relative(repoRoot, cell.filePath)}' already exists.`
|
|
14298
14566
|
);
|
|
14299
14567
|
}
|
|
14300
14568
|
}
|
|
@@ -14313,7 +14581,7 @@ var StructureManager = class {
|
|
|
14313
14581
|
await this.tx.run(repoRoot, {
|
|
14314
14582
|
description: `clef namespace add ${name}`,
|
|
14315
14583
|
paths: [
|
|
14316
|
-
...newCellPaths.map((c) =>
|
|
14584
|
+
...newCellPaths.map((c) => path22.relative(repoRoot, c.filePath)),
|
|
14317
14585
|
CLEF_MANIFEST_FILENAME
|
|
14318
14586
|
],
|
|
14319
14587
|
mutate: async () => {
|
|
@@ -14358,15 +14626,15 @@ var StructureManager = class {
|
|
|
14358
14626
|
this.assertValidIdentifier("environment", name);
|
|
14359
14627
|
const newCellPaths = manifest.namespaces.map((ns) => ({
|
|
14360
14628
|
namespace: ns.name,
|
|
14361
|
-
filePath:
|
|
14629
|
+
filePath: path22.join(
|
|
14362
14630
|
repoRoot,
|
|
14363
14631
|
manifest.file_pattern.replace("{namespace}", ns.name).replace("{environment}", name)
|
|
14364
14632
|
)
|
|
14365
14633
|
}));
|
|
14366
14634
|
for (const cell of newCellPaths) {
|
|
14367
|
-
if (
|
|
14635
|
+
if (fs18.existsSync(cell.filePath)) {
|
|
14368
14636
|
throw new Error(
|
|
14369
|
-
`Cannot add environment '${name}': file '${
|
|
14637
|
+
`Cannot add environment '${name}': file '${path22.relative(repoRoot, cell.filePath)}' already exists.`
|
|
14370
14638
|
);
|
|
14371
14639
|
}
|
|
14372
14640
|
}
|
|
@@ -14385,7 +14653,7 @@ var StructureManager = class {
|
|
|
14385
14653
|
await this.tx.run(repoRoot, {
|
|
14386
14654
|
description: `clef env add ${name}`,
|
|
14387
14655
|
paths: [
|
|
14388
|
-
...newCellPaths.map((c) =>
|
|
14656
|
+
...newCellPaths.map((c) => path22.relative(repoRoot, c.filePath)),
|
|
14389
14657
|
CLEF_MANIFEST_FILENAME
|
|
14390
14658
|
],
|
|
14391
14659
|
mutate: async () => {
|
|
@@ -14448,7 +14716,7 @@ var StructureManager = class {
|
|
|
14448
14716
|
paths: this.deletePaths(repoRoot, cellsToDelete),
|
|
14449
14717
|
mutate: async () => {
|
|
14450
14718
|
for (const cell of cellsToDelete) {
|
|
14451
|
-
|
|
14719
|
+
fs18.unlinkSync(cell.filePath);
|
|
14452
14720
|
this.unlinkMetaSibling(cell.filePath);
|
|
14453
14721
|
}
|
|
14454
14722
|
const doc = readManifestYaml(repoRoot);
|
|
@@ -14498,7 +14766,7 @@ var StructureManager = class {
|
|
|
14498
14766
|
paths: this.deletePaths(repoRoot, cellsToDelete),
|
|
14499
14767
|
mutate: async () => {
|
|
14500
14768
|
for (const cell of cellsToDelete) {
|
|
14501
|
-
|
|
14769
|
+
fs18.unlinkSync(cell.filePath);
|
|
14502
14770
|
this.unlinkMetaSibling(cell.filePath);
|
|
14503
14771
|
}
|
|
14504
14772
|
const doc = readManifestYaml(repoRoot);
|
|
@@ -14540,9 +14808,9 @@ var StructureManager = class {
|
|
|
14540
14808
|
const renamePairs = isRename ? this.collectRenamePairs(manifest, repoRoot, name, opts.rename, "namespace") : [];
|
|
14541
14809
|
if (isRename) {
|
|
14542
14810
|
for (const pair of renamePairs) {
|
|
14543
|
-
if (
|
|
14811
|
+
if (fs18.existsSync(pair.to)) {
|
|
14544
14812
|
throw new Error(
|
|
14545
|
-
`Rename target '${
|
|
14813
|
+
`Rename target '${path22.relative(repoRoot, pair.to)}' already exists. Move or remove it first.`
|
|
14546
14814
|
);
|
|
14547
14815
|
}
|
|
14548
14816
|
}
|
|
@@ -14583,9 +14851,9 @@ var StructureManager = class {
|
|
|
14583
14851
|
const renamePairs = isRename ? this.collectRenamePairs(manifest, repoRoot, name, opts.rename, "environment") : [];
|
|
14584
14852
|
if (isRename) {
|
|
14585
14853
|
for (const pair of renamePairs) {
|
|
14586
|
-
if (
|
|
14854
|
+
if (fs18.existsSync(pair.to)) {
|
|
14587
14855
|
throw new Error(
|
|
14588
|
-
`Rename target '${
|
|
14856
|
+
`Rename target '${path22.relative(repoRoot, pair.to)}' already exists. Move or remove it first.`
|
|
14589
14857
|
);
|
|
14590
14858
|
}
|
|
14591
14859
|
}
|
|
@@ -14620,7 +14888,7 @@ var StructureManager = class {
|
|
|
14620
14888
|
const newCellPath = this.swapAxisInCellPath(repoRoot, manifest, cell, axis, newName);
|
|
14621
14889
|
pairs.push({ from: cell.filePath, to: newCellPath });
|
|
14622
14890
|
const oldMeta = cell.filePath.replace(/\.enc\.(yaml|json)$/, ".clef-meta.yaml");
|
|
14623
|
-
if (
|
|
14891
|
+
if (fs18.existsSync(oldMeta)) {
|
|
14624
14892
|
const newMeta = newCellPath.replace(/\.enc\.(yaml|json)$/, ".clef-meta.yaml");
|
|
14625
14893
|
pairs.push({ from: oldMeta, to: newMeta });
|
|
14626
14894
|
}
|
|
@@ -14635,7 +14903,7 @@ var StructureManager = class {
|
|
|
14635
14903
|
swapAxisInCellPath(repoRoot, manifest, cell, axis, newName) {
|
|
14636
14904
|
const ns = axis === "namespace" ? newName : cell.namespace;
|
|
14637
14905
|
const env = axis === "environment" ? newName : cell.environment;
|
|
14638
|
-
return
|
|
14906
|
+
return path22.join(
|
|
14639
14907
|
repoRoot,
|
|
14640
14908
|
manifest.file_pattern.replace("{namespace}", ns).replace("{environment}", env)
|
|
14641
14909
|
);
|
|
@@ -14647,8 +14915,8 @@ var StructureManager = class {
|
|
|
14647
14915
|
txPaths(repoRoot, renamePairs) {
|
|
14648
14916
|
const paths = /* @__PURE__ */ new Set();
|
|
14649
14917
|
for (const pair of renamePairs) {
|
|
14650
|
-
paths.add(
|
|
14651
|
-
paths.add(
|
|
14918
|
+
paths.add(path22.relative(repoRoot, pair.from));
|
|
14919
|
+
paths.add(path22.relative(repoRoot, pair.to));
|
|
14652
14920
|
}
|
|
14653
14921
|
paths.add(CLEF_MANIFEST_FILENAME);
|
|
14654
14922
|
return [...paths];
|
|
@@ -14659,11 +14927,11 @@ var StructureManager = class {
|
|
|
14659
14927
|
*/
|
|
14660
14928
|
applyRenames(pairs) {
|
|
14661
14929
|
for (const pair of pairs) {
|
|
14662
|
-
const targetDir =
|
|
14663
|
-
if (!
|
|
14664
|
-
|
|
14930
|
+
const targetDir = path22.dirname(pair.to);
|
|
14931
|
+
if (!fs18.existsSync(targetDir)) {
|
|
14932
|
+
fs18.mkdirSync(targetDir, { recursive: true });
|
|
14665
14933
|
}
|
|
14666
|
-
|
|
14934
|
+
fs18.renameSync(pair.from, pair.to);
|
|
14667
14935
|
}
|
|
14668
14936
|
}
|
|
14669
14937
|
/**
|
|
@@ -14674,10 +14942,10 @@ var StructureManager = class {
|
|
|
14674
14942
|
deletePaths(repoRoot, cells) {
|
|
14675
14943
|
const paths = /* @__PURE__ */ new Set();
|
|
14676
14944
|
for (const cell of cells) {
|
|
14677
|
-
paths.add(
|
|
14945
|
+
paths.add(path22.relative(repoRoot, cell.filePath));
|
|
14678
14946
|
const meta = cell.filePath.replace(/\.enc\.(yaml|json)$/, ".clef-meta.yaml");
|
|
14679
|
-
if (
|
|
14680
|
-
paths.add(
|
|
14947
|
+
if (fs18.existsSync(meta)) {
|
|
14948
|
+
paths.add(path22.relative(repoRoot, meta));
|
|
14681
14949
|
}
|
|
14682
14950
|
}
|
|
14683
14951
|
paths.add(CLEF_MANIFEST_FILENAME);
|
|
@@ -14690,8 +14958,8 @@ var StructureManager = class {
|
|
|
14690
14958
|
*/
|
|
14691
14959
|
unlinkMetaSibling(cellPath) {
|
|
14692
14960
|
const meta = cellPath.replace(/\.enc\.(yaml|json)$/, ".clef-meta.yaml");
|
|
14693
|
-
if (
|
|
14694
|
-
|
|
14961
|
+
if (fs18.existsSync(meta)) {
|
|
14962
|
+
fs18.unlinkSync(meta);
|
|
14695
14963
|
}
|
|
14696
14964
|
}
|
|
14697
14965
|
/**
|
|
@@ -14836,20 +15104,20 @@ async function resolveIdentitySecrets(identityName, environment, manifest, repoR
|
|
|
14836
15104
|
var crypto4 = __toESM(require("crypto"));
|
|
14837
15105
|
|
|
14838
15106
|
// src/artifact/output.ts
|
|
14839
|
-
var
|
|
14840
|
-
var
|
|
15107
|
+
var fs19 = __toESM(require("fs"));
|
|
15108
|
+
var path23 = __toESM(require("path"));
|
|
14841
15109
|
var FilePackOutput = class {
|
|
14842
15110
|
constructor(outputPath) {
|
|
14843
15111
|
this.outputPath = outputPath;
|
|
14844
15112
|
}
|
|
14845
15113
|
async write(_artifact, json) {
|
|
14846
|
-
const outputDir =
|
|
14847
|
-
if (!
|
|
14848
|
-
|
|
15114
|
+
const outputDir = path23.dirname(this.outputPath);
|
|
15115
|
+
if (!fs19.existsSync(outputDir)) {
|
|
15116
|
+
fs19.mkdirSync(outputDir, { recursive: true });
|
|
14849
15117
|
}
|
|
14850
15118
|
const tmpOutput = `${this.outputPath}.tmp.${process.pid}`;
|
|
14851
|
-
|
|
14852
|
-
|
|
15119
|
+
fs19.writeFileSync(tmpOutput, json, "utf-8");
|
|
15120
|
+
fs19.renameSync(tmpOutput, this.outputPath);
|
|
14853
15121
|
}
|
|
14854
15122
|
};
|
|
14855
15123
|
var MemoryPackOutput = class {
|
|
@@ -15056,28 +15324,187 @@ var ArtifactPacker = class {
|
|
|
15056
15324
|
const json = JSON.stringify(artifact, null, 2);
|
|
15057
15325
|
const output = config.output ?? new FilePackOutput(config.outputPath ?? "artifact.json");
|
|
15058
15326
|
await output.write(artifact, json);
|
|
15327
|
+
const keys = Object.keys(resolved.values);
|
|
15059
15328
|
return {
|
|
15060
15329
|
outputPath: config.outputPath ?? "",
|
|
15061
15330
|
namespaceCount: resolved.identity.namespaces.length,
|
|
15062
|
-
keyCount:
|
|
15331
|
+
keyCount: keys.length,
|
|
15332
|
+
keys,
|
|
15063
15333
|
artifactSize: Buffer.byteLength(json, "utf-8"),
|
|
15064
15334
|
revision: artifact.revision
|
|
15065
15335
|
};
|
|
15066
15336
|
}
|
|
15067
15337
|
};
|
|
15068
15338
|
|
|
15339
|
+
// src/artifact/guards.ts
|
|
15340
|
+
var InvalidArtifactError = class extends ClefError {
|
|
15341
|
+
constructor(message) {
|
|
15342
|
+
super(
|
|
15343
|
+
message,
|
|
15344
|
+
"Ensure the artifact was produced by a compatible clef version and was not tampered with."
|
|
15345
|
+
);
|
|
15346
|
+
this.name = "InvalidArtifactError";
|
|
15347
|
+
}
|
|
15348
|
+
};
|
|
15349
|
+
var VALID_SIGNATURE_ALGORITHMS = ["Ed25519", "ECDSA_SHA256"];
|
|
15350
|
+
function isKmsEnvelope2(x) {
|
|
15351
|
+
if (typeof x !== "object" || x === null) return false;
|
|
15352
|
+
const o = x;
|
|
15353
|
+
return typeof o.provider === "string" && typeof o.keyId === "string" && typeof o.wrappedKey === "string" && typeof o.algorithm === "string" && typeof o.iv === "string" && typeof o.authTag === "string";
|
|
15354
|
+
}
|
|
15355
|
+
function validatePackedArtifact(x) {
|
|
15356
|
+
if (typeof x !== "object" || x === null) {
|
|
15357
|
+
return { valid: false, reason: "expected object" };
|
|
15358
|
+
}
|
|
15359
|
+
const o = x;
|
|
15360
|
+
if (o.version !== 1) {
|
|
15361
|
+
return { valid: false, reason: `unsupported version: ${String(o.version)}` };
|
|
15362
|
+
}
|
|
15363
|
+
if (typeof o.identity !== "string") {
|
|
15364
|
+
return { valid: false, reason: "missing or invalid 'identity' (expected string)" };
|
|
15365
|
+
}
|
|
15366
|
+
if (typeof o.environment !== "string") {
|
|
15367
|
+
return { valid: false, reason: "missing or invalid 'environment' (expected string)" };
|
|
15368
|
+
}
|
|
15369
|
+
if (typeof o.packedAt !== "string") {
|
|
15370
|
+
return { valid: false, reason: "missing or invalid 'packedAt' (expected string)" };
|
|
15371
|
+
}
|
|
15372
|
+
if (typeof o.revision !== "string") {
|
|
15373
|
+
return { valid: false, reason: "missing or invalid 'revision' (expected string)" };
|
|
15374
|
+
}
|
|
15375
|
+
if (typeof o.ciphertextHash !== "string") {
|
|
15376
|
+
return { valid: false, reason: "missing or invalid 'ciphertextHash' (expected string)" };
|
|
15377
|
+
}
|
|
15378
|
+
if (typeof o.ciphertext !== "string") {
|
|
15379
|
+
return { valid: false, reason: "missing or invalid 'ciphertext' (expected string)" };
|
|
15380
|
+
}
|
|
15381
|
+
if (o.envelope !== void 0 && !isKmsEnvelope2(o.envelope)) {
|
|
15382
|
+
return { valid: false, reason: "invalid 'envelope' (expected KmsEnvelope shape)" };
|
|
15383
|
+
}
|
|
15384
|
+
if (o.expiresAt !== void 0 && typeof o.expiresAt !== "string") {
|
|
15385
|
+
return { valid: false, reason: "invalid 'expiresAt' (expected string)" };
|
|
15386
|
+
}
|
|
15387
|
+
if (o.revokedAt !== void 0 && typeof o.revokedAt !== "string") {
|
|
15388
|
+
return { valid: false, reason: "invalid 'revokedAt' (expected string)" };
|
|
15389
|
+
}
|
|
15390
|
+
if (o.signature !== void 0 && typeof o.signature !== "string") {
|
|
15391
|
+
return { valid: false, reason: "invalid 'signature' (expected string)" };
|
|
15392
|
+
}
|
|
15393
|
+
if (o.signatureAlgorithm !== void 0 && !VALID_SIGNATURE_ALGORITHMS.includes(o.signatureAlgorithm)) {
|
|
15394
|
+
return {
|
|
15395
|
+
valid: false,
|
|
15396
|
+
reason: `invalid 'signatureAlgorithm': expected one of ${VALID_SIGNATURE_ALGORITHMS.join(", ")}`
|
|
15397
|
+
};
|
|
15398
|
+
}
|
|
15399
|
+
return { valid: true, value: o };
|
|
15400
|
+
}
|
|
15401
|
+
function isPackedArtifact(x) {
|
|
15402
|
+
return validatePackedArtifact(x).valid;
|
|
15403
|
+
}
|
|
15404
|
+
function assertPackedArtifact(x, context) {
|
|
15405
|
+
const result = validatePackedArtifact(x);
|
|
15406
|
+
if (!result.valid) {
|
|
15407
|
+
const prefix = context ? `${context}: ` : "";
|
|
15408
|
+
throw new InvalidArtifactError(`${prefix}${result.reason}`);
|
|
15409
|
+
}
|
|
15410
|
+
}
|
|
15411
|
+
|
|
15412
|
+
// src/pack/registry.ts
|
|
15413
|
+
var PackBackendRegistry = class {
|
|
15414
|
+
factories = /* @__PURE__ */ new Map();
|
|
15415
|
+
/**
|
|
15416
|
+
* Register a backend factory under the given id. Throws if a backend
|
|
15417
|
+
* with the same id is already registered — collisions surface as a clear
|
|
15418
|
+
* error rather than a silent overwrite.
|
|
15419
|
+
*/
|
|
15420
|
+
register(id, factory) {
|
|
15421
|
+
if (this.factories.has(id)) {
|
|
15422
|
+
throw new Error(`Pack backend "${id}" is already registered.`);
|
|
15423
|
+
}
|
|
15424
|
+
this.factories.set(id, factory);
|
|
15425
|
+
}
|
|
15426
|
+
/** Whether a backend with the given id has been registered. */
|
|
15427
|
+
has(id) {
|
|
15428
|
+
return this.factories.has(id);
|
|
15429
|
+
}
|
|
15430
|
+
/** Registered backend ids, in registration order. */
|
|
15431
|
+
list() {
|
|
15432
|
+
return [...this.factories.keys()];
|
|
15433
|
+
}
|
|
15434
|
+
/**
|
|
15435
|
+
* Resolve a backend by id. Throws if unknown. Factories may be async so
|
|
15436
|
+
* a plugin package can defer construction (e.g. loading a heavy SDK only
|
|
15437
|
+
* when the backend is actually used).
|
|
15438
|
+
*/
|
|
15439
|
+
async resolve(id) {
|
|
15440
|
+
const factory = this.factories.get(id);
|
|
15441
|
+
if (!factory) {
|
|
15442
|
+
const available = this.list().join(", ") || "(none)";
|
|
15443
|
+
throw new Error(`Unknown pack backend "${id}". Available backends: ${available}`);
|
|
15444
|
+
}
|
|
15445
|
+
return await factory();
|
|
15446
|
+
}
|
|
15447
|
+
};
|
|
15448
|
+
|
|
15449
|
+
// src/pack/backends/json-envelope.ts
|
|
15450
|
+
var JsonEnvelopeBackend = class {
|
|
15451
|
+
id = "json-envelope";
|
|
15452
|
+
description = "Write the Clef JSON artifact envelope to a local file (default).";
|
|
15453
|
+
validateOptions(raw) {
|
|
15454
|
+
const opts = raw;
|
|
15455
|
+
if (opts.signingKey && opts.signingKmsKeyId) {
|
|
15456
|
+
throw new Error(
|
|
15457
|
+
"Cannot specify both signingKey (Ed25519) and signingKmsKeyId (KMS). Choose one."
|
|
15458
|
+
);
|
|
15459
|
+
}
|
|
15460
|
+
if (!opts.outputPath && !opts.output) {
|
|
15461
|
+
throw new Error("json-envelope backend requires an 'outputPath' or 'output' option.");
|
|
15462
|
+
}
|
|
15463
|
+
}
|
|
15464
|
+
async pack(req) {
|
|
15465
|
+
const opts = req.backendOptions;
|
|
15466
|
+
const packer = new ArtifactPacker(
|
|
15467
|
+
req.services.encryption,
|
|
15468
|
+
new MatrixManager(),
|
|
15469
|
+
req.services.kms
|
|
15470
|
+
);
|
|
15471
|
+
const output = opts.output ?? (opts.outputPath ? new FilePackOutput(opts.outputPath) : void 0);
|
|
15472
|
+
const result = await packer.pack(
|
|
15473
|
+
{
|
|
15474
|
+
identity: req.identity,
|
|
15475
|
+
environment: req.environment,
|
|
15476
|
+
outputPath: opts.outputPath,
|
|
15477
|
+
output,
|
|
15478
|
+
ttl: req.ttl,
|
|
15479
|
+
signingKey: opts.signingKey,
|
|
15480
|
+
signingKmsKeyId: opts.signingKmsKeyId
|
|
15481
|
+
},
|
|
15482
|
+
req.manifest,
|
|
15483
|
+
req.repoRoot
|
|
15484
|
+
);
|
|
15485
|
+
return {
|
|
15486
|
+
...result,
|
|
15487
|
+
backend: this.id,
|
|
15488
|
+
details: {
|
|
15489
|
+
outputPath: opts.outputPath ?? null
|
|
15490
|
+
}
|
|
15491
|
+
};
|
|
15492
|
+
}
|
|
15493
|
+
};
|
|
15494
|
+
|
|
15069
15495
|
// src/kms/types.ts
|
|
15070
15496
|
var VALID_KMS_PROVIDERS = ["aws", "gcp", "azure"];
|
|
15071
15497
|
|
|
15072
15498
|
// src/migration/backend.ts
|
|
15073
|
-
var
|
|
15499
|
+
var path24 = __toESM(require("path"));
|
|
15074
15500
|
var YAML11 = __toESM(require("yaml"));
|
|
15075
15501
|
var BACKEND_KEY_FIELDS = {
|
|
15076
15502
|
age: void 0,
|
|
15077
15503
|
awskms: "aws_kms_arn",
|
|
15078
15504
|
gcpkms: "gcp_kms_resource_id",
|
|
15079
15505
|
azurekv: "azure_kv_url",
|
|
15080
|
-
pgp: "pgp_fingerprint"
|
|
15506
|
+
pgp: "pgp_fingerprint",
|
|
15507
|
+
hsm: "pkcs11_uri"
|
|
15081
15508
|
};
|
|
15082
15509
|
var ALL_KEY_FIELDS = Object.values(BACKEND_KEY_FIELDS).filter(
|
|
15083
15510
|
(v) => v !== void 0
|
|
@@ -15187,7 +15614,7 @@ var BackendMigrator = class {
|
|
|
15187
15614
|
await this.tx.run(repoRoot, {
|
|
15188
15615
|
description: environment ? `clef migrate-backend ${target.backend}: ${environment}` : `clef migrate-backend ${target.backend}`,
|
|
15189
15616
|
paths: [
|
|
15190
|
-
...toMigrate.map((c) =>
|
|
15617
|
+
...toMigrate.map((c) => path24.relative(repoRoot, c.filePath)),
|
|
15191
15618
|
CLEF_MANIFEST_FILENAME
|
|
15192
15619
|
],
|
|
15193
15620
|
mutate: async () => {
|
|
@@ -15285,7 +15712,7 @@ var BackendMigrator = class {
|
|
|
15285
15712
|
};
|
|
15286
15713
|
|
|
15287
15714
|
// src/reset/manager.ts
|
|
15288
|
-
var
|
|
15715
|
+
var path25 = __toESM(require("path"));
|
|
15289
15716
|
var ResetManager = class {
|
|
15290
15717
|
constructor(matrixManager, encryption, schemaValidator, tx) {
|
|
15291
15718
|
this.matrixManager = matrixManager;
|
|
@@ -15310,11 +15737,11 @@ var ResetManager = class {
|
|
|
15310
15737
|
txPaths.push(CLEF_MANIFEST_FILENAME);
|
|
15311
15738
|
}
|
|
15312
15739
|
for (const cell of targetCells) {
|
|
15313
|
-
txPaths.push(
|
|
15740
|
+
txPaths.push(path25.relative(repoRoot, cell.filePath));
|
|
15314
15741
|
const cellKeys = keyPlan.get(cell.namespace) ?? [];
|
|
15315
15742
|
if (cellKeys.length > 0) {
|
|
15316
15743
|
txPaths.push(
|
|
15317
|
-
|
|
15744
|
+
path25.relative(repoRoot, cell.filePath.replace(/\.enc\.(yaml|json)$/, ".clef-meta.yaml"))
|
|
15318
15745
|
);
|
|
15319
15746
|
}
|
|
15320
15747
|
}
|
|
@@ -15402,7 +15829,7 @@ var ResetManager = class {
|
|
|
15402
15829
|
for (const namespace of namespaces) {
|
|
15403
15830
|
const nsDef = manifest.namespaces.find((n) => n.name === namespace);
|
|
15404
15831
|
if (nsDef?.schema) {
|
|
15405
|
-
const schema = this.schemaValidator.loadSchema(
|
|
15832
|
+
const schema = this.schemaValidator.loadSchema(path25.join(repoRoot, nsDef.schema));
|
|
15406
15833
|
plan.set(namespace, Object.keys(schema.keys));
|
|
15407
15834
|
continue;
|
|
15408
15835
|
}
|
|
@@ -15481,7 +15908,7 @@ function withBackendOverride(manifest, envNames, backend, key) {
|
|
|
15481
15908
|
}
|
|
15482
15909
|
|
|
15483
15910
|
// src/sync/manager.ts
|
|
15484
|
-
var
|
|
15911
|
+
var path26 = __toESM(require("path"));
|
|
15485
15912
|
var SyncManager = class {
|
|
15486
15913
|
constructor(matrixManager, encryption, tx) {
|
|
15487
15914
|
this.matrixManager = matrixManager;
|
|
@@ -15550,7 +15977,7 @@ var SyncManager = class {
|
|
|
15550
15977
|
}
|
|
15551
15978
|
const txPaths = [];
|
|
15552
15979
|
for (const cell of syncPlan.cells) {
|
|
15553
|
-
const rel =
|
|
15980
|
+
const rel = path26.relative(repoRoot, cell.filePath);
|
|
15554
15981
|
txPaths.push(rel);
|
|
15555
15982
|
txPaths.push(rel.replace(/\.enc\.(yaml|json)$/, ".clef-meta.yaml"));
|
|
15556
15983
|
}
|
|
@@ -15589,7 +16016,7 @@ var SyncManager = class {
|
|
|
15589
16016
|
};
|
|
15590
16017
|
|
|
15591
16018
|
// src/policy/parser.ts
|
|
15592
|
-
var
|
|
16019
|
+
var fs20 = __toESM(require("fs"));
|
|
15593
16020
|
var YAML12 = __toESM(require("yaml"));
|
|
15594
16021
|
|
|
15595
16022
|
// src/policy/types.ts
|
|
@@ -15611,7 +16038,7 @@ var PolicyParser = class {
|
|
|
15611
16038
|
parse(filePath) {
|
|
15612
16039
|
let raw;
|
|
15613
16040
|
try {
|
|
15614
|
-
raw =
|
|
16041
|
+
raw = fs20.readFileSync(filePath, "utf-8");
|
|
15615
16042
|
} catch {
|
|
15616
16043
|
throw new PolicyValidationError(`Could not read policy file at '${filePath}'.`);
|
|
15617
16044
|
}
|
|
@@ -15639,7 +16066,7 @@ var PolicyParser = class {
|
|
|
15639
16066
|
* not exist. Any other read or validation error throws.
|
|
15640
16067
|
*/
|
|
15641
16068
|
load(filePath) {
|
|
15642
|
-
if (!
|
|
16069
|
+
if (!fs20.existsSync(filePath)) return DEFAULT_POLICY;
|
|
15643
16070
|
return this.parse(filePath);
|
|
15644
16071
|
}
|
|
15645
16072
|
validate(raw) {
|
|
@@ -15832,13 +16259,13 @@ var ComplianceGenerator = class {
|
|
|
15832
16259
|
};
|
|
15833
16260
|
|
|
15834
16261
|
// src/compliance/run.ts
|
|
15835
|
-
var
|
|
16262
|
+
var path27 = __toESM(require("path"));
|
|
15836
16263
|
var UNKNOWN = "unknown";
|
|
15837
16264
|
async function runCompliance(opts) {
|
|
15838
16265
|
const start = Date.now();
|
|
15839
16266
|
const repoRoot = opts.repoRoot ?? process.cwd();
|
|
15840
|
-
const manifestPath = opts.manifestPath ??
|
|
15841
|
-
const policyPath = opts.policyPath ??
|
|
16267
|
+
const manifestPath = opts.manifestPath ?? path27.join(repoRoot, "clef.yaml");
|
|
16268
|
+
const policyPath = opts.policyPath ?? path27.join(repoRoot, CLEF_POLICY_FILENAME);
|
|
15842
16269
|
const include = {
|
|
15843
16270
|
scan: opts.include?.scan ?? true,
|
|
15844
16271
|
lint: opts.include?.lint ?? true,
|
|
@@ -15884,7 +16311,7 @@ async function evaluateMatrix(args) {
|
|
|
15884
16311
|
return Promise.all(
|
|
15885
16312
|
cells.map(async (cell) => {
|
|
15886
16313
|
const metadata = await args.sopsClient.getMetadata(cell.filePath);
|
|
15887
|
-
const relPath =
|
|
16314
|
+
const relPath = path27.relative(args.repoRoot, cell.filePath).replace(/\\/g, "/");
|
|
15888
16315
|
const keys = readSopsKeyNames(cell.filePath) ?? [];
|
|
15889
16316
|
const rotations = await getRotations(cell.filePath);
|
|
15890
16317
|
return evaluator.evaluateFile(relPath, cell.environment, metadata, keys, rotations, args.now);
|
|
@@ -15963,11 +16390,14 @@ async function detectRepo(runner, repoRoot) {
|
|
|
15963
16390
|
GitIntegration,
|
|
15964
16391
|
GitOperationError,
|
|
15965
16392
|
ImportRunner,
|
|
16393
|
+
InvalidArtifactError,
|
|
16394
|
+
JsonEnvelopeBackend,
|
|
15966
16395
|
LintRunner,
|
|
15967
16396
|
ManifestParser,
|
|
15968
16397
|
ManifestValidationError,
|
|
15969
16398
|
MatrixManager,
|
|
15970
16399
|
MemoryPackOutput,
|
|
16400
|
+
PackBackendRegistry,
|
|
15971
16401
|
PolicyEvaluator,
|
|
15972
16402
|
PolicyParser,
|
|
15973
16403
|
PolicyValidationError,
|
|
@@ -15996,6 +16426,7 @@ async function detectRepo(runner, repoRoot) {
|
|
|
15996
16426
|
TransactionPreflightError,
|
|
15997
16427
|
TransactionRollbackError,
|
|
15998
16428
|
VALID_KMS_PROVIDERS,
|
|
16429
|
+
assertPackedArtifact,
|
|
15999
16430
|
assertSops,
|
|
16000
16431
|
buildSigningPayload,
|
|
16001
16432
|
checkAll,
|
|
@@ -16012,8 +16443,10 @@ async function detectRepo(runner, repoRoot) {
|
|
|
16012
16443
|
generateSigningKeyPair,
|
|
16013
16444
|
getPendingKeys,
|
|
16014
16445
|
getRotations,
|
|
16446
|
+
isClefHsmArn,
|
|
16015
16447
|
isHighEntropy,
|
|
16016
16448
|
isKmsEnvelope,
|
|
16449
|
+
isPackedArtifact,
|
|
16017
16450
|
isPending,
|
|
16018
16451
|
keyPreview,
|
|
16019
16452
|
loadIgnoreRules,
|
|
@@ -16031,15 +16464,18 @@ async function detectRepo(runner, repoRoot) {
|
|
|
16031
16464
|
parseIgnoreContent,
|
|
16032
16465
|
parseJson,
|
|
16033
16466
|
parseYaml,
|
|
16467
|
+
pkcs11UriToSyntheticArn,
|
|
16034
16468
|
readManifestYaml,
|
|
16035
16469
|
recordRotation,
|
|
16036
16470
|
redactValue,
|
|
16037
16471
|
removeAccessRequest,
|
|
16038
16472
|
removeRotation,
|
|
16039
16473
|
requestsFilePath,
|
|
16474
|
+
resetKeyserviceResolution,
|
|
16040
16475
|
resetSopsResolution,
|
|
16041
16476
|
resolveBackendConfig,
|
|
16042
16477
|
resolveIdentitySecrets,
|
|
16478
|
+
resolveKeyservicePath,
|
|
16043
16479
|
resolveRecipientsForEnvironment,
|
|
16044
16480
|
resolveSopsPath,
|
|
16045
16481
|
runCompliance,
|
|
@@ -16050,8 +16486,12 @@ async function detectRepo(runner, repoRoot) {
|
|
|
16050
16486
|
shouldIgnoreMatch,
|
|
16051
16487
|
signEd25519,
|
|
16052
16488
|
signKms,
|
|
16489
|
+
spawnKeyservice,
|
|
16490
|
+
syntheticArnToPkcs11Uri,
|
|
16491
|
+
tryBundledKeyservice,
|
|
16053
16492
|
upsertRequest,
|
|
16054
16493
|
validateAgePublicKey,
|
|
16494
|
+
validatePackedArtifact,
|
|
16055
16495
|
validateResetScope,
|
|
16056
16496
|
verifySignature,
|
|
16057
16497
|
writeManifestYaml,
|