@clef-sh/core 0.1.16-beta.110 → 0.1.17
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/compliance/generator.d.ts +19 -0
- package/dist/compliance/generator.d.ts.map +1 -0
- package/dist/compliance/run.d.ts +66 -0
- package/dist/compliance/run.d.ts.map +1 -0
- package/dist/compliance/types.d.ts +72 -0
- package/dist/compliance/types.d.ts.map +1 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +594 -237
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +533 -213
- package/dist/index.mjs.map +4 -4
- package/dist/policy/evaluator.d.ts +39 -0
- package/dist/policy/evaluator.d.ts.map +1 -0
- package/dist/policy/parser.d.ts +36 -0
- package/dist/policy/parser.d.ts.map +1 -0
- package/dist/policy/types.d.ts +70 -0
- package/dist/policy/types.d.ts.map +1 -0
- package/dist/sops/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +24 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -304,10 +304,10 @@ var require_lib = __commonJS({
|
|
|
304
304
|
module2.exports.sync = writeFileSync6;
|
|
305
305
|
module2.exports._getTmpname = getTmpname;
|
|
306
306
|
module2.exports._cleanupOnExit = cleanupOnExit;
|
|
307
|
-
var
|
|
307
|
+
var fs18 = require("fs");
|
|
308
308
|
var crypto5 = require("node:crypto");
|
|
309
309
|
var { onExit } = require_cjs();
|
|
310
|
-
var
|
|
310
|
+
var path26 = 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
|
+
fs18.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 = path26.resolve(filename);
|
|
364
364
|
try {
|
|
365
365
|
await serializeActiveFile(absoluteName);
|
|
366
|
-
const truename = await promisify(
|
|
366
|
+
const truename = await promisify(fs18.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(fs18.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(fs18.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(fs18.write)(fd, data, 0, data.length, 0);
|
|
386
386
|
} else if (data != null) {
|
|
387
|
-
await promisify(
|
|
387
|
+
await promisify(fs18.write)(fd, String(data), 0, String(options.encoding || "utf8"));
|
|
388
388
|
}
|
|
389
389
|
if (options.fsync !== false) {
|
|
390
|
-
await promisify(
|
|
390
|
+
await promisify(fs18.fsync)(fd);
|
|
391
391
|
}
|
|
392
|
-
await promisify(
|
|
392
|
+
await promisify(fs18.close)(fd);
|
|
393
393
|
fd = null;
|
|
394
394
|
if (options.chown) {
|
|
395
|
-
await promisify(
|
|
395
|
+
await promisify(fs18.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(fs18.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(fs18.rename)(tmpfile, truename);
|
|
409
409
|
} finally {
|
|
410
410
|
if (fd) {
|
|
411
|
-
await promisify(
|
|
411
|
+
await promisify(fs18.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(fs18.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 = fs18.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 = fs18.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 = fs18.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
|
+
fs18.writeSync(fd, data, 0, data.length, 0);
|
|
479
479
|
} else if (data != null) {
|
|
480
|
-
|
|
480
|
+
fs18.writeSync(fd, String(data), 0, String(options.encoding || "utf8"));
|
|
481
481
|
}
|
|
482
482
|
if (options.fsync !== false) {
|
|
483
|
-
|
|
483
|
+
fs18.fsyncSync(fd);
|
|
484
484
|
}
|
|
485
|
-
|
|
485
|
+
fs18.closeSync(fd);
|
|
486
486
|
fd = null;
|
|
487
487
|
if (options.chown) {
|
|
488
488
|
try {
|
|
489
|
-
|
|
489
|
+
fs18.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
|
+
fs18.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
|
+
fs18.renameSync(tmpfile, filename);
|
|
506
506
|
threw = false;
|
|
507
507
|
} finally {
|
|
508
508
|
if (fd) {
|
|
509
509
|
try {
|
|
510
|
-
|
|
510
|
+
fs18.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(fs18) {
|
|
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(fs18);
|
|
552
|
+
}
|
|
553
|
+
if (!fs18.lutimes) {
|
|
554
|
+
patchLutimes(fs18);
|
|
555
|
+
}
|
|
556
|
+
fs18.chown = chownFix(fs18.chown);
|
|
557
|
+
fs18.fchown = chownFix(fs18.fchown);
|
|
558
|
+
fs18.lchown = chownFix(fs18.lchown);
|
|
559
|
+
fs18.chmod = chmodFix(fs18.chmod);
|
|
560
|
+
fs18.fchmod = chmodFix(fs18.fchmod);
|
|
561
|
+
fs18.lchmod = chmodFix(fs18.lchmod);
|
|
562
|
+
fs18.chownSync = chownFixSync(fs18.chownSync);
|
|
563
|
+
fs18.fchownSync = chownFixSync(fs18.fchownSync);
|
|
564
|
+
fs18.lchownSync = chownFixSync(fs18.lchownSync);
|
|
565
|
+
fs18.chmodSync = chmodFixSync(fs18.chmodSync);
|
|
566
|
+
fs18.fchmodSync = chmodFixSync(fs18.fchmodSync);
|
|
567
|
+
fs18.lchmodSync = chmodFixSync(fs18.lchmodSync);
|
|
568
|
+
fs18.stat = statFix(fs18.stat);
|
|
569
|
+
fs18.fstat = statFix(fs18.fstat);
|
|
570
|
+
fs18.lstat = statFix(fs18.lstat);
|
|
571
|
+
fs18.statSync = statFixSync(fs18.statSync);
|
|
572
|
+
fs18.fstatSync = statFixSync(fs18.fstatSync);
|
|
573
|
+
fs18.lstatSync = statFixSync(fs18.lstatSync);
|
|
574
|
+
if (fs18.chmod && !fs18.lchmod) {
|
|
575
|
+
fs18.lchmod = function(path26, mode, cb) {
|
|
576
576
|
if (cb) process.nextTick(cb);
|
|
577
577
|
};
|
|
578
|
-
|
|
578
|
+
fs18.lchmodSync = function() {
|
|
579
579
|
};
|
|
580
580
|
}
|
|
581
|
-
if (
|
|
582
|
-
|
|
581
|
+
if (fs18.chown && !fs18.lchown) {
|
|
582
|
+
fs18.lchown = function(path26, uid, gid, cb) {
|
|
583
583
|
if (cb) process.nextTick(cb);
|
|
584
584
|
};
|
|
585
|
-
|
|
585
|
+
fs18.lchownSync = function() {
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
588
|
if (platform === "win32") {
|
|
589
|
-
|
|
589
|
+
fs18.rename = typeof fs18.rename !== "function" ? fs18.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
|
+
fs18.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
|
+
})(fs18.rename);
|
|
613
613
|
}
|
|
614
|
-
|
|
614
|
+
fs18.read = typeof fs18.read !== "function" ? fs18.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(fs18, 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(fs18, 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
|
+
})(fs18.read);
|
|
632
|
+
fs18.readSync = typeof fs18.readSync !== "function" ? fs18.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(fs18, 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
|
+
})(fs18.readSync);
|
|
648
|
+
function patchLchmod(fs19) {
|
|
649
|
+
fs19.lchmod = function(path26, mode, callback) {
|
|
650
|
+
fs19.open(
|
|
651
|
+
path26,
|
|
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
|
+
fs19.fchmod(fd, mode, function(err2) {
|
|
660
|
+
fs19.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
|
+
fs19.lchmodSync = function(path26, mode) {
|
|
668
|
+
var fd = fs19.openSync(path26, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
669
669
|
var threw = true;
|
|
670
670
|
var ret;
|
|
671
671
|
try {
|
|
672
|
-
ret =
|
|
672
|
+
ret = fs19.fchmodSync(fd, mode);
|
|
673
673
|
threw = false;
|
|
674
674
|
} finally {
|
|
675
675
|
if (threw) {
|
|
676
676
|
try {
|
|
677
|
-
|
|
677
|
+
fs19.closeSync(fd);
|
|
678
678
|
} catch (er) {
|
|
679
679
|
}
|
|
680
680
|
} else {
|
|
681
|
-
|
|
681
|
+
fs19.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(fs19) {
|
|
688
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs19.futimes) {
|
|
689
|
+
fs19.lutimes = function(path26, at, mt, cb) {
|
|
690
|
+
fs19.open(path26, constants.O_SYMLINK, function(er, fd) {
|
|
691
691
|
if (er) {
|
|
692
692
|
if (cb) cb(er);
|
|
693
693
|
return;
|
|
694
694
|
}
|
|
695
|
-
|
|
696
|
-
|
|
695
|
+
fs19.futimes(fd, at, mt, function(er2) {
|
|
696
|
+
fs19.close(fd, function(er22) {
|
|
697
697
|
if (cb) cb(er2 || er22);
|
|
698
698
|
});
|
|
699
699
|
});
|
|
700
700
|
});
|
|
701
701
|
};
|
|
702
|
-
|
|
703
|
-
var fd =
|
|
702
|
+
fs19.lutimesSync = function(path26, at, mt) {
|
|
703
|
+
var fd = fs19.openSync(path26, constants.O_SYMLINK);
|
|
704
704
|
var ret;
|
|
705
705
|
var threw = true;
|
|
706
706
|
try {
|
|
707
|
-
ret =
|
|
707
|
+
ret = fs19.futimesSync(fd, at, mt);
|
|
708
708
|
threw = false;
|
|
709
709
|
} finally {
|
|
710
710
|
if (threw) {
|
|
711
711
|
try {
|
|
712
|
-
|
|
712
|
+
fs19.closeSync(fd);
|
|
713
713
|
} catch (er) {
|
|
714
714
|
}
|
|
715
715
|
} else {
|
|
716
|
-
|
|
716
|
+
fs19.closeSync(fd);
|
|
717
717
|
}
|
|
718
718
|
}
|
|
719
719
|
return ret;
|
|
720
720
|
};
|
|
721
|
-
} else if (
|
|
722
|
-
|
|
721
|
+
} else if (fs19.futimes) {
|
|
722
|
+
fs19.lutimes = function(_a, _b, _c, cb) {
|
|
723
723
|
if (cb) process.nextTick(cb);
|
|
724
724
|
};
|
|
725
|
-
|
|
725
|
+
fs19.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(fs18, 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(fs18, 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(fs18, 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(fs18, 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(fs18, target, options, callback) : orig.call(fs18, 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(fs18, target, options) : orig.call(fs18, 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(fs18) {
|
|
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(path26, options) {
|
|
822
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path26, options);
|
|
823
823
|
Stream.call(this);
|
|
824
824
|
var self = this;
|
|
825
|
-
this.path =
|
|
825
|
+
this.path = path26;
|
|
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
|
+
fs18.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(path26, options) {
|
|
871
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path26, options);
|
|
872
872
|
Stream.call(this);
|
|
873
|
-
this.path =
|
|
873
|
+
this.path = path26;
|
|
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 = fs18.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 fs18 = 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 (!fs18[gracefulQueue]) {
|
|
966
966
|
queue = global[gracefulQueue] || [];
|
|
967
|
-
publishQueue(
|
|
968
|
-
|
|
967
|
+
publishQueue(fs18, queue);
|
|
968
|
+
fs18.close = (function(fs$close) {
|
|
969
969
|
function close(fd, cb) {
|
|
970
|
-
return fs$close.call(
|
|
970
|
+
return fs$close.call(fs18, 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
|
+
})(fs18.close);
|
|
983
|
+
fs18.closeSync = (function(fs$closeSync) {
|
|
984
984
|
function closeSync2(fd) {
|
|
985
|
-
fs$closeSync.apply(
|
|
985
|
+
fs$closeSync.apply(fs18, 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
|
+
})(fs18.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(fs18[gracefulQueue]);
|
|
996
|
+
require("assert").equal(fs18[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, fs18[gracefulQueue]);
|
|
1003
|
+
}
|
|
1004
|
+
module2.exports = patch(clone(fs18));
|
|
1005
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs18.__patched) {
|
|
1006
|
+
module2.exports = patch(fs18);
|
|
1007
|
+
fs18.__patched = true;
|
|
1008
|
+
}
|
|
1009
|
+
function patch(fs19) {
|
|
1010
|
+
polyfills(fs19);
|
|
1011
|
+
fs19.gracefulify = patch;
|
|
1012
|
+
fs19.createReadStream = createReadStream;
|
|
1013
|
+
fs19.createWriteStream = createWriteStream;
|
|
1014
|
+
var fs$readFile = fs19.readFile;
|
|
1015
|
+
fs19.readFile = readFile;
|
|
1016
|
+
function readFile(path26, 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(path26, options, cb);
|
|
1020
|
+
function go$readFile(path27, options2, cb2, startTime) {
|
|
1021
|
+
return fs$readFile(path27, options2, function(err) {
|
|
1022
1022
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
1023
|
-
enqueue([go$readFile, [
|
|
1023
|
+
enqueue([go$readFile, [path27, 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 = fs19.writeFile;
|
|
1032
|
+
fs19.writeFile = writeFile;
|
|
1033
|
+
function writeFile(path26, 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(path26, data, options, cb);
|
|
1037
|
+
function go$writeFile(path27, data2, options2, cb2, startTime) {
|
|
1038
|
+
return fs$writeFile(path27, data2, options2, function(err) {
|
|
1039
1039
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
1040
|
-
enqueue([go$writeFile, [
|
|
1040
|
+
enqueue([go$writeFile, [path27, 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 = fs19.appendFile;
|
|
1049
1049
|
if (fs$appendFile)
|
|
1050
|
-
|
|
1051
|
-
function appendFile(
|
|
1050
|
+
fs19.appendFile = appendFile;
|
|
1051
|
+
function appendFile(path26, 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(path26, data, options, cb);
|
|
1055
|
+
function go$appendFile(path27, data2, options2, cb2, startTime) {
|
|
1056
|
+
return fs$appendFile(path27, data2, options2, function(err) {
|
|
1057
1057
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
1058
|
-
enqueue([go$appendFile, [
|
|
1058
|
+
enqueue([go$appendFile, [path27, 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 = fs19.copyFile;
|
|
1067
1067
|
if (fs$copyFile)
|
|
1068
|
-
|
|
1068
|
+
fs19.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 = fs19.readdir;
|
|
1087
|
+
fs19.readdir = readdir;
|
|
1088
1088
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
1089
|
-
function readdir(
|
|
1089
|
+
function readdir(path26, 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(path27, options2, cb2, startTime) {
|
|
1093
|
+
return fs$readdir(path27, fs$readdirCallback(
|
|
1094
|
+
path27,
|
|
1095
1095
|
options2,
|
|
1096
1096
|
cb2,
|
|
1097
1097
|
startTime
|
|
1098
1098
|
));
|
|
1099
|
-
} : function go$readdir2(
|
|
1100
|
-
return fs$readdir(
|
|
1101
|
-
|
|
1099
|
+
} : function go$readdir2(path27, options2, cb2, startTime) {
|
|
1100
|
+
return fs$readdir(path27, options2, fs$readdirCallback(
|
|
1101
|
+
path27,
|
|
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(path26, options, cb);
|
|
1108
|
+
function fs$readdirCallback(path27, 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
|
+
[path27, 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(fs19);
|
|
1129
1129
|
ReadStream = legStreams.ReadStream;
|
|
1130
1130
|
WriteStream = legStreams.WriteStream;
|
|
1131
1131
|
}
|
|
1132
|
-
var fs$ReadStream =
|
|
1132
|
+
var fs$ReadStream = fs19.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 = fs19.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(fs19, "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(fs19, "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(fs19, "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(fs19, "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(path26, 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(path26, 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(path26, options) {
|
|
1223
|
+
return new fs19.ReadStream(path26, options);
|
|
1224
1224
|
}
|
|
1225
|
-
function createWriteStream(
|
|
1226
|
-
return new
|
|
1225
|
+
function createWriteStream(path26, options) {
|
|
1226
|
+
return new fs19.WriteStream(path26, options);
|
|
1227
1227
|
}
|
|
1228
|
-
var fs$open =
|
|
1229
|
-
|
|
1230
|
-
function open(
|
|
1228
|
+
var fs$open = fs19.open;
|
|
1229
|
+
fs19.open = open;
|
|
1230
|
+
function open(path26, 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(path26, flags, mode, cb);
|
|
1234
|
+
function go$open(path27, flags2, mode2, cb2, startTime) {
|
|
1235
|
+
return fs$open(path27, flags2, mode2, function(err, fd) {
|
|
1236
1236
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
1237
|
-
enqueue([go$open, [
|
|
1237
|
+
enqueue([go$open, [path27, 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 fs19;
|
|
1246
1246
|
}
|
|
1247
1247
|
function enqueue(elem) {
|
|
1248
1248
|
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
1249
|
-
|
|
1249
|
+
fs18[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 < fs18[gracefulQueue].length; ++i) {
|
|
1256
|
+
if (fs18[gracefulQueue][i].length > 2) {
|
|
1257
|
+
fs18[gracefulQueue][i][3] = now;
|
|
1258
|
+
fs18[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 (fs18[gracefulQueue].length === 0)
|
|
1267
1267
|
return;
|
|
1268
|
-
var elem =
|
|
1268
|
+
var elem = fs18[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
|
+
fs18[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, fs18, callback) {
|
|
1726
|
+
const cachedPrecision = fs18[cacheSymbol];
|
|
1727
1727
|
if (cachedPrecision) {
|
|
1728
|
-
return
|
|
1728
|
+
return fs18.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
|
+
fs18.utimes(file, mtime, mtime, (err) => {
|
|
1737
1737
|
if (err) {
|
|
1738
1738
|
return callback(err);
|
|
1739
1739
|
}
|
|
1740
|
-
|
|
1740
|
+
fs18.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(fs18, 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 path26 = require("path");
|
|
1767
|
+
var fs18 = 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, path26.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: fs18,
|
|
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: fs18,
|
|
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: fs18,
|
|
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 fs18 = require_graceful_fs();
|
|
2004
|
+
function createSyncFs(fs19) {
|
|
2005
2005
|
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
2006
|
-
const newFs = { ...
|
|
2006
|
+
const newFs = { ...fs19 };
|
|
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 = fs19[`${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 || fs18);
|
|
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
|
}
|
|
@@ -2131,12 +2131,16 @@ var require_age_encryption = __commonJS({
|
|
|
2131
2131
|
});
|
|
2132
2132
|
module2.exports = __toCommonJS2(stdin_exports);
|
|
2133
2133
|
function isBytes(a) {
|
|
2134
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
2134
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
2135
2135
|
}
|
|
2136
2136
|
function anumber(n, title = "") {
|
|
2137
|
+
if (typeof n !== "number") {
|
|
2138
|
+
const prefix2 = title && `"${title}" `;
|
|
2139
|
+
throw new TypeError(`${prefix2}expected number, got ${typeof n}`);
|
|
2140
|
+
}
|
|
2137
2141
|
if (!Number.isSafeInteger(n) || n < 0) {
|
|
2138
2142
|
const prefix2 = title && `"${title}" `;
|
|
2139
|
-
throw new
|
|
2143
|
+
throw new RangeError(`${prefix2}expected integer >= 0, got ${n}`);
|
|
2140
2144
|
}
|
|
2141
2145
|
}
|
|
2142
2146
|
function abytes(value, length, title = "") {
|
|
@@ -2147,15 +2151,22 @@ var require_age_encryption = __commonJS({
|
|
|
2147
2151
|
const prefix2 = title && `"${title}" `;
|
|
2148
2152
|
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
2149
2153
|
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
2150
|
-
|
|
2154
|
+
const message = prefix2 + "expected Uint8Array" + ofLen + ", got " + got;
|
|
2155
|
+
if (!bytes)
|
|
2156
|
+
throw new TypeError(message);
|
|
2157
|
+
throw new RangeError(message);
|
|
2151
2158
|
}
|
|
2152
2159
|
return value;
|
|
2153
2160
|
}
|
|
2154
2161
|
function ahash(h) {
|
|
2155
2162
|
if (typeof h !== "function" || typeof h.create !== "function")
|
|
2156
|
-
throw new
|
|
2163
|
+
throw new TypeError("Hash must wrapped by utils.createHasher");
|
|
2157
2164
|
anumber(h.outputLen);
|
|
2158
2165
|
anumber(h.blockLen);
|
|
2166
|
+
if (h.outputLen < 1)
|
|
2167
|
+
throw new Error('"outputLen" must be >= 1');
|
|
2168
|
+
if (h.blockLen < 1)
|
|
2169
|
+
throw new Error('"blockLen" must be >= 1');
|
|
2159
2170
|
}
|
|
2160
2171
|
function aexists(instance, checkFinished = true) {
|
|
2161
2172
|
if (instance.destroyed)
|
|
@@ -2167,7 +2178,7 @@ var require_age_encryption = __commonJS({
|
|
|
2167
2178
|
abytes(out, void 0, "digestInto() output");
|
|
2168
2179
|
const min = instance.outputLen;
|
|
2169
2180
|
if (out.length < min) {
|
|
2170
|
-
throw new
|
|
2181
|
+
throw new RangeError('"digestInto() output" expected to be of length >=' + min);
|
|
2171
2182
|
}
|
|
2172
2183
|
}
|
|
2173
2184
|
function u32(arr) {
|
|
@@ -2200,7 +2211,7 @@ var require_age_encryption = __commonJS({
|
|
|
2200
2211
|
var swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
2201
2212
|
function utf8ToBytes(str) {
|
|
2202
2213
|
if (typeof str !== "string")
|
|
2203
|
-
throw new
|
|
2214
|
+
throw new TypeError("string expected");
|
|
2204
2215
|
return new Uint8Array(new TextEncoder().encode(str));
|
|
2205
2216
|
}
|
|
2206
2217
|
function kdfInputToBytes(data, errorTitle = "") {
|
|
@@ -2210,7 +2221,7 @@ var require_age_encryption = __commonJS({
|
|
|
2210
2221
|
}
|
|
2211
2222
|
function checkOpts(defaults, opts2) {
|
|
2212
2223
|
if (opts2 !== void 0 && {}.toString.call(opts2) !== "[object Object]")
|
|
2213
|
-
throw new
|
|
2224
|
+
throw new TypeError("options must be object or undefined");
|
|
2214
2225
|
const merged = Object.assign(defaults, opts2);
|
|
2215
2226
|
return merged;
|
|
2216
2227
|
}
|
|
@@ -2219,17 +2230,23 @@ var require_age_encryption = __commonJS({
|
|
|
2219
2230
|
const tmp = hashCons(void 0);
|
|
2220
2231
|
hashC.outputLen = tmp.outputLen;
|
|
2221
2232
|
hashC.blockLen = tmp.blockLen;
|
|
2233
|
+
hashC.canXOF = tmp.canXOF;
|
|
2222
2234
|
hashC.create = (opts2) => hashCons(opts2);
|
|
2223
2235
|
Object.assign(hashC, info);
|
|
2224
2236
|
return Object.freeze(hashC);
|
|
2225
2237
|
}
|
|
2226
2238
|
function randomBytes4(bytesLength = 32) {
|
|
2239
|
+
anumber(bytesLength, "bytesLength");
|
|
2227
2240
|
const cr = typeof globalThis === "object" ? globalThis.crypto : null;
|
|
2228
2241
|
if (typeof cr?.getRandomValues !== "function")
|
|
2229
2242
|
throw new Error("crypto.getRandomValues must be defined");
|
|
2243
|
+
if (bytesLength > 65536)
|
|
2244
|
+
throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
2230
2245
|
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
2231
2246
|
}
|
|
2232
2247
|
var oidNist = (suffix) => ({
|
|
2248
|
+
// Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
|
|
2249
|
+
// Larger suffix values would need base-128 OID encoding and a different length byte.
|
|
2233
2250
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
2234
2251
|
});
|
|
2235
2252
|
var _HMAC = class {
|
|
@@ -2237,6 +2254,7 @@ var require_age_encryption = __commonJS({
|
|
|
2237
2254
|
iHash;
|
|
2238
2255
|
blockLen;
|
|
2239
2256
|
outputLen;
|
|
2257
|
+
canXOF = false;
|
|
2240
2258
|
finished = false;
|
|
2241
2259
|
destroyed = false;
|
|
2242
2260
|
constructor(hash, key) {
|
|
@@ -2266,11 +2284,12 @@ var require_age_encryption = __commonJS({
|
|
|
2266
2284
|
}
|
|
2267
2285
|
digestInto(out) {
|
|
2268
2286
|
aexists(this);
|
|
2269
|
-
|
|
2287
|
+
aoutput(out, this);
|
|
2270
2288
|
this.finished = true;
|
|
2271
|
-
this.
|
|
2272
|
-
this.
|
|
2273
|
-
this.oHash.
|
|
2289
|
+
const buf = out.subarray(0, this.outputLen);
|
|
2290
|
+
this.iHash.digestInto(buf);
|
|
2291
|
+
this.oHash.update(buf);
|
|
2292
|
+
this.oHash.digestInto(buf);
|
|
2274
2293
|
this.destroy();
|
|
2275
2294
|
}
|
|
2276
2295
|
digest() {
|
|
@@ -2299,8 +2318,11 @@ var require_age_encryption = __commonJS({
|
|
|
2299
2318
|
this.iHash.destroy();
|
|
2300
2319
|
}
|
|
2301
2320
|
};
|
|
2302
|
-
var hmac =
|
|
2303
|
-
|
|
2321
|
+
var hmac = /* @__PURE__ */ (() => {
|
|
2322
|
+
const hmac_ = ((hash, key, message) => new _HMAC(hash, key).update(message).digest());
|
|
2323
|
+
hmac_.create = (hash, key) => new _HMAC(hash, key);
|
|
2324
|
+
return hmac_;
|
|
2325
|
+
})();
|
|
2304
2326
|
function extract(hash, ikm, salt) {
|
|
2305
2327
|
ahash(hash);
|
|
2306
2328
|
if (salt === void 0)
|
|
@@ -2312,7 +2334,10 @@ var require_age_encryption = __commonJS({
|
|
|
2312
2334
|
function expand(hash, prk, info, length = 32) {
|
|
2313
2335
|
ahash(hash);
|
|
2314
2336
|
anumber(length, "length");
|
|
2337
|
+
abytes(prk, void 0, "prk");
|
|
2315
2338
|
const olen = hash.outputLen;
|
|
2339
|
+
if (prk.length < olen)
|
|
2340
|
+
throw new Error('"prk" must be at least HashLen octets');
|
|
2316
2341
|
if (length > 255 * olen)
|
|
2317
2342
|
throw new Error("Length must be <= 255*HashLen");
|
|
2318
2343
|
const blocks = Math.ceil(length / olen);
|
|
@@ -2345,6 +2370,7 @@ var require_age_encryption = __commonJS({
|
|
|
2345
2370
|
var HashMD = class {
|
|
2346
2371
|
blockLen;
|
|
2347
2372
|
outputLen;
|
|
2373
|
+
canXOF = false;
|
|
2348
2374
|
padOffset;
|
|
2349
2375
|
isLE;
|
|
2350
2376
|
// For partial updates less than block size
|
|
@@ -2572,6 +2598,7 @@ var require_age_encryption = __commonJS({
|
|
|
2572
2598
|
clean(SHA256_W);
|
|
2573
2599
|
}
|
|
2574
2600
|
destroy() {
|
|
2601
|
+
this.destroyed = true;
|
|
2575
2602
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
2576
2603
|
clean(this.buffer);
|
|
2577
2604
|
}
|
|
@@ -2675,7 +2702,7 @@ var require_age_encryption = __commonJS({
|
|
|
2675
2702
|
};
|
|
2676
2703
|
}
|
|
2677
2704
|
// @__NO_SIDE_EFFECTS__
|
|
2678
|
-
function
|
|
2705
|
+
function join19(separator = "") {
|
|
2679
2706
|
astr("join", separator);
|
|
2680
2707
|
return {
|
|
2681
2708
|
encode: (from) => {
|
|
@@ -2805,9 +2832,9 @@ var require_age_encryption = __commonJS({
|
|
|
2805
2832
|
decode(s) {
|
|
2806
2833
|
return decodeBase64Builtin(s, false);
|
|
2807
2834
|
}
|
|
2808
|
-
} : /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ padding(6), /* @__PURE__ */
|
|
2809
|
-
var base64nopad = /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */
|
|
2810
|
-
var BECH_ALPHABET = /* @__PURE__ */ chain(/* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */
|
|
2835
|
+
} : /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ padding(6), /* @__PURE__ */ join19(""));
|
|
2836
|
+
var base64nopad = /* @__PURE__ */ chain(/* @__PURE__ */ radix2(6), /* @__PURE__ */ alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ join19(""));
|
|
2837
|
+
var BECH_ALPHABET = /* @__PURE__ */ chain(/* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ join19(""));
|
|
2811
2838
|
var POLYMOD_GENERATORS = [996825010, 642813549, 513874426, 1027748829, 705979059];
|
|
2812
2839
|
function bech32Polymod(pre) {
|
|
2813
2840
|
const b = pre >> 25;
|
|
@@ -2909,6 +2936,10 @@ var require_age_encryption = __commonJS({
|
|
|
2909
2936
|
anumber(asyncTick, "asyncTick");
|
|
2910
2937
|
if (c < 1)
|
|
2911
2938
|
throw new Error("iterations (c) must be >= 1");
|
|
2939
|
+
if (dkLen < 1)
|
|
2940
|
+
throw new Error('"dkLen" must be >= 1');
|
|
2941
|
+
if (dkLen > (2 ** 32 - 1) * hash.outputLen)
|
|
2942
|
+
throw new Error("derived key too long");
|
|
2912
2943
|
const password = kdfInputToBytes(_password, "password");
|
|
2913
2944
|
const salt = kdfInputToBytes(_salt, "salt");
|
|
2914
2945
|
const DK = new Uint8Array(dkLen);
|
|
@@ -3040,9 +3071,9 @@ var require_age_encryption = __commonJS({
|
|
|
3040
3071
|
throw new Error('"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)');
|
|
3041
3072
|
if (dkLen < 1 || dkLen > (pow32 - 1) * 32)
|
|
3042
3073
|
throw new Error('"dkLen" expected integer 1..(2^32 - 1) * 32');
|
|
3043
|
-
const memUsed = blockSize * (N2 + p);
|
|
3074
|
+
const memUsed = blockSize * (N2 + p + 1);
|
|
3044
3075
|
if (memUsed > maxmem)
|
|
3045
|
-
throw new Error('"maxmem" limit was hit
|
|
3076
|
+
throw new Error('"maxmem" limit was hit: memUsed(128*r*(N+p+1))=' + memUsed + ", maxmem=" + maxmem);
|
|
3046
3077
|
const B = pbkdf2(sha256, password, salt, { c: 1, dkLen: blockSize * p });
|
|
3047
3078
|
const B32 = u32(B);
|
|
3048
3079
|
const V = u32(new Uint8Array(blockSize * N2));
|
|
@@ -8984,12 +9015,15 @@ __export(index_exports, {
|
|
|
8984
9015
|
BackendMigrator: () => BackendMigrator,
|
|
8985
9016
|
BulkOps: () => BulkOps,
|
|
8986
9017
|
CLEF_MANIFEST_FILENAME: () => CLEF_MANIFEST_FILENAME,
|
|
9018
|
+
CLEF_POLICY_FILENAME: () => CLEF_POLICY_FILENAME,
|
|
8987
9019
|
CLEF_REPORT_SCHEMA_VERSION: () => CLEF_REPORT_SCHEMA_VERSION,
|
|
8988
9020
|
CLEF_SUPPORTED_EXTENSIONS: () => CLEF_SUPPORTED_EXTENSIONS,
|
|
8989
9021
|
ClefError: () => ClefError,
|
|
8990
9022
|
CloudApiError: () => CloudApiError,
|
|
8991
9023
|
CloudClient: () => CloudClient,
|
|
9024
|
+
ComplianceGenerator: () => ComplianceGenerator,
|
|
8992
9025
|
ConsumptionClient: () => ConsumptionClient,
|
|
9026
|
+
DEFAULT_POLICY: () => DEFAULT_POLICY,
|
|
8993
9027
|
DiffEngine: () => DiffEngine,
|
|
8994
9028
|
DriftDetector: () => DriftDetector,
|
|
8995
9029
|
FilePackOutput: () => FilePackOutput,
|
|
@@ -9001,6 +9035,9 @@ __export(index_exports, {
|
|
|
9001
9035
|
ManifestValidationError: () => ManifestValidationError,
|
|
9002
9036
|
MatrixManager: () => MatrixManager,
|
|
9003
9037
|
MemoryPackOutput: () => MemoryPackOutput,
|
|
9038
|
+
PolicyEvaluator: () => PolicyEvaluator,
|
|
9039
|
+
PolicyParser: () => PolicyParser,
|
|
9040
|
+
PolicyValidationError: () => PolicyValidationError,
|
|
9004
9041
|
REQUESTS_FILENAME: () => REQUESTS_FILENAME,
|
|
9005
9042
|
REQUIREMENTS: () => REQUIREMENTS,
|
|
9006
9043
|
RecipientManager: () => RecipientManager,
|
|
@@ -9067,6 +9104,7 @@ __export(index_exports, {
|
|
|
9067
9104
|
resolveIdentitySecrets: () => resolveIdentitySecrets,
|
|
9068
9105
|
resolveRecipientsForEnvironment: () => resolveRecipientsForEnvironment,
|
|
9069
9106
|
resolveSopsPath: () => resolveSopsPath,
|
|
9107
|
+
runCompliance: () => runCompliance,
|
|
9070
9108
|
saveMetadata: () => saveMetadata,
|
|
9071
9109
|
saveRequests: () => saveRequests,
|
|
9072
9110
|
shannonEntropy: () => shannonEntropy,
|
|
@@ -9147,6 +9185,13 @@ var GitOperationError = class extends ClefError {
|
|
|
9147
9185
|
this.name = "GitOperationError";
|
|
9148
9186
|
}
|
|
9149
9187
|
};
|
|
9188
|
+
var PolicyValidationError = class extends ClefError {
|
|
9189
|
+
constructor(message, field) {
|
|
9190
|
+
super(message, field ? `Check the '${field}' field in .clef/policy.yaml` : void 0);
|
|
9191
|
+
this.field = field;
|
|
9192
|
+
this.name = "PolicyValidationError";
|
|
9193
|
+
}
|
|
9194
|
+
};
|
|
9150
9195
|
var SchemaLoadError = class extends ClefError {
|
|
9151
9196
|
constructor(message, filePath) {
|
|
9152
9197
|
super(
|
|
@@ -11765,8 +11810,11 @@ var SopsClient = class {
|
|
|
11765
11810
|
}
|
|
11766
11811
|
const backend = this.detectBackend(sops);
|
|
11767
11812
|
const recipients = this.extractRecipients(sops, backend);
|
|
11768
|
-
const
|
|
11769
|
-
|
|
11813
|
+
const lastModifiedRaw = typeof sops.lastmodified === "string" ? sops.lastmodified : void 0;
|
|
11814
|
+
const lastModified = lastModifiedRaw ? new Date(lastModifiedRaw) : /* @__PURE__ */ new Date();
|
|
11815
|
+
const lastModifiedPresent = lastModifiedRaw !== void 0;
|
|
11816
|
+
const version = typeof sops.version === "string" ? sops.version : void 0;
|
|
11817
|
+
return { backend, recipients, lastModified, lastModifiedPresent, version };
|
|
11770
11818
|
}
|
|
11771
11819
|
detectBackend(sops) {
|
|
11772
11820
|
if (sops.age && Array.isArray(sops.age) && sops.age.length > 0) return "age";
|
|
@@ -15292,18 +15340,324 @@ var SyncManager = class {
|
|
|
15292
15340
|
};
|
|
15293
15341
|
}
|
|
15294
15342
|
};
|
|
15343
|
+
|
|
15344
|
+
// src/policy/parser.ts
|
|
15345
|
+
var fs17 = __toESM(require("fs"));
|
|
15346
|
+
var YAML11 = __toESM(require("yaml"));
|
|
15347
|
+
|
|
15348
|
+
// src/policy/types.ts
|
|
15349
|
+
var DEFAULT_POLICY = Object.freeze({
|
|
15350
|
+
version: 1,
|
|
15351
|
+
rotation: Object.freeze({ max_age_days: 90 })
|
|
15352
|
+
});
|
|
15353
|
+
|
|
15354
|
+
// src/policy/parser.ts
|
|
15355
|
+
var CLEF_POLICY_FILENAME = ".clef/policy.yaml";
|
|
15356
|
+
var SUPPORTED_VERSIONS = [1];
|
|
15357
|
+
var PolicyParser = class {
|
|
15358
|
+
/**
|
|
15359
|
+
* Read and validate a policy file from disk.
|
|
15360
|
+
*
|
|
15361
|
+
* @throws {@link PolicyValidationError} If the file cannot be read, contains
|
|
15362
|
+
* invalid YAML, or fails schema validation.
|
|
15363
|
+
*/
|
|
15364
|
+
parse(filePath) {
|
|
15365
|
+
let raw;
|
|
15366
|
+
try {
|
|
15367
|
+
raw = fs17.readFileSync(filePath, "utf-8");
|
|
15368
|
+
} catch {
|
|
15369
|
+
throw new PolicyValidationError(`Could not read policy file at '${filePath}'.`);
|
|
15370
|
+
}
|
|
15371
|
+
return this.parseContent(raw);
|
|
15372
|
+
}
|
|
15373
|
+
/**
|
|
15374
|
+
* Parse and validate a policy document from a YAML string.
|
|
15375
|
+
*
|
|
15376
|
+
* @throws {@link PolicyValidationError} If the content is malformed or
|
|
15377
|
+
* fails validation.
|
|
15378
|
+
*/
|
|
15379
|
+
parseContent(content) {
|
|
15380
|
+
let parsed;
|
|
15381
|
+
try {
|
|
15382
|
+
parsed = YAML11.parse(content);
|
|
15383
|
+
} catch {
|
|
15384
|
+
throw new PolicyValidationError(
|
|
15385
|
+
"Policy file contains invalid YAML. Check for syntax errors."
|
|
15386
|
+
);
|
|
15387
|
+
}
|
|
15388
|
+
return this.validate(parsed);
|
|
15389
|
+
}
|
|
15390
|
+
/**
|
|
15391
|
+
* Load policy from disk, returning {@link DEFAULT_POLICY} if the file does
|
|
15392
|
+
* not exist. Any other read or validation error throws.
|
|
15393
|
+
*/
|
|
15394
|
+
load(filePath) {
|
|
15395
|
+
if (!fs17.existsSync(filePath)) return DEFAULT_POLICY;
|
|
15396
|
+
return this.parse(filePath);
|
|
15397
|
+
}
|
|
15398
|
+
validate(raw) {
|
|
15399
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
15400
|
+
throw new PolicyValidationError("Policy file must be a YAML object.");
|
|
15401
|
+
}
|
|
15402
|
+
const doc = raw;
|
|
15403
|
+
if (!SUPPORTED_VERSIONS.includes(doc.version)) {
|
|
15404
|
+
throw new PolicyValidationError(
|
|
15405
|
+
`Policy file must declare 'version: 1', got: ${JSON.stringify(doc.version)}.`,
|
|
15406
|
+
"version"
|
|
15407
|
+
);
|
|
15408
|
+
}
|
|
15409
|
+
const rotation = doc.rotation === void 0 ? void 0 : this.validateRotation(doc.rotation);
|
|
15410
|
+
return { version: 1, ...rotation ? { rotation } : {} };
|
|
15411
|
+
}
|
|
15412
|
+
validateRotation(raw) {
|
|
15413
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
15414
|
+
throw new PolicyValidationError("Policy 'rotation' must be an object.", "rotation");
|
|
15415
|
+
}
|
|
15416
|
+
const rot = raw;
|
|
15417
|
+
const maxAge = rot.max_age_days;
|
|
15418
|
+
if (typeof maxAge !== "number" || !Number.isFinite(maxAge) || maxAge <= 0) {
|
|
15419
|
+
throw new PolicyValidationError(
|
|
15420
|
+
"Policy 'rotation.max_age_days' must be a positive number.",
|
|
15421
|
+
"rotation.max_age_days"
|
|
15422
|
+
);
|
|
15423
|
+
}
|
|
15424
|
+
const result = { max_age_days: maxAge };
|
|
15425
|
+
if (rot.environments !== void 0) {
|
|
15426
|
+
if (typeof rot.environments !== "object" || rot.environments === null || Array.isArray(rot.environments)) {
|
|
15427
|
+
throw new PolicyValidationError(
|
|
15428
|
+
"Policy 'rotation.environments' must be an object keyed by environment name.",
|
|
15429
|
+
"rotation.environments"
|
|
15430
|
+
);
|
|
15431
|
+
}
|
|
15432
|
+
const envs = {};
|
|
15433
|
+
for (const [envName, envVal] of Object.entries(rot.environments)) {
|
|
15434
|
+
if (typeof envVal !== "object" || envVal === null || Array.isArray(envVal)) {
|
|
15435
|
+
throw new PolicyValidationError(
|
|
15436
|
+
`Policy 'rotation.environments.${envName}' must be an object.`,
|
|
15437
|
+
`rotation.environments.${envName}`
|
|
15438
|
+
);
|
|
15439
|
+
}
|
|
15440
|
+
const envMaxAge = envVal.max_age_days;
|
|
15441
|
+
if (typeof envMaxAge !== "number" || !Number.isFinite(envMaxAge) || envMaxAge <= 0) {
|
|
15442
|
+
throw new PolicyValidationError(
|
|
15443
|
+
`Policy 'rotation.environments.${envName}.max_age_days' must be a positive number.`,
|
|
15444
|
+
`rotation.environments.${envName}.max_age_days`
|
|
15445
|
+
);
|
|
15446
|
+
}
|
|
15447
|
+
envs[envName] = { max_age_days: envMaxAge };
|
|
15448
|
+
}
|
|
15449
|
+
result.environments = envs;
|
|
15450
|
+
}
|
|
15451
|
+
return result;
|
|
15452
|
+
}
|
|
15453
|
+
};
|
|
15454
|
+
|
|
15455
|
+
// src/policy/evaluator.ts
|
|
15456
|
+
var MS_PER_DAY = 864e5;
|
|
15457
|
+
var DEFAULT_MAX_AGE_DAYS = 90;
|
|
15458
|
+
var PolicyEvaluator = class {
|
|
15459
|
+
constructor(policy) {
|
|
15460
|
+
this.policy = policy;
|
|
15461
|
+
}
|
|
15462
|
+
/**
|
|
15463
|
+
* Evaluate a single encrypted file's rotation state.
|
|
15464
|
+
*
|
|
15465
|
+
* @param filePath Repo-relative or absolute path to the encrypted file.
|
|
15466
|
+
* @param environment Environment name from the matrix; selects per-env
|
|
15467
|
+
* overrides if present in the policy.
|
|
15468
|
+
* @param metadata Result of `SopsClient.getMetadata()` for the file.
|
|
15469
|
+
* @param now Reference time (defaults to `new Date()`). Inject for
|
|
15470
|
+
* deterministic tests and reproducible audits.
|
|
15471
|
+
*/
|
|
15472
|
+
evaluateFile(filePath, environment, metadata, now = /* @__PURE__ */ new Date()) {
|
|
15473
|
+
const maxAgeDays = this.resolveMaxAgeDays(environment);
|
|
15474
|
+
const rotationDue = new Date(metadata.lastModified.getTime() + maxAgeDays * MS_PER_DAY);
|
|
15475
|
+
const rotationOverdue = now.getTime() > rotationDue.getTime();
|
|
15476
|
+
const daysOverdue = rotationOverdue ? Math.floor((now.getTime() - rotationDue.getTime()) / MS_PER_DAY) : 0;
|
|
15477
|
+
return {
|
|
15478
|
+
path: filePath,
|
|
15479
|
+
environment,
|
|
15480
|
+
backend: metadata.backend,
|
|
15481
|
+
recipients: metadata.recipients,
|
|
15482
|
+
last_modified: metadata.lastModified.toISOString(),
|
|
15483
|
+
// Treat a missing `lastModifiedPresent` as `true` — the field is
|
|
15484
|
+
// optional on SopsMetadata and only `parseMetadataFromFile` knows
|
|
15485
|
+
// authoritatively whether the underlying file carried `sops.lastmodified`.
|
|
15486
|
+
// Hand-constructed metadata is assumed trustworthy.
|
|
15487
|
+
last_modified_known: metadata.lastModifiedPresent !== false,
|
|
15488
|
+
rotation_due: rotationDue.toISOString(),
|
|
15489
|
+
rotation_overdue: rotationOverdue,
|
|
15490
|
+
days_overdue: daysOverdue,
|
|
15491
|
+
compliant: !rotationOverdue
|
|
15492
|
+
};
|
|
15493
|
+
}
|
|
15494
|
+
resolveMaxAgeDays(environment) {
|
|
15495
|
+
const envOverride = this.policy.rotation?.environments?.[environment];
|
|
15496
|
+
if (envOverride !== void 0) return envOverride.max_age_days;
|
|
15497
|
+
return this.policy.rotation?.max_age_days ?? DEFAULT_MAX_AGE_DAYS;
|
|
15498
|
+
}
|
|
15499
|
+
};
|
|
15500
|
+
|
|
15501
|
+
// src/compliance/generator.ts
|
|
15502
|
+
var import_crypto2 = require("crypto");
|
|
15503
|
+
var SCHEMA_VERSION = "1";
|
|
15504
|
+
function canonicalJson(value) {
|
|
15505
|
+
if (value === null || typeof value !== "object") {
|
|
15506
|
+
return JSON.stringify(value);
|
|
15507
|
+
}
|
|
15508
|
+
if (Array.isArray(value)) {
|
|
15509
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
15510
|
+
}
|
|
15511
|
+
const obj = value;
|
|
15512
|
+
const keys = Object.keys(obj).sort();
|
|
15513
|
+
const entries = keys.map((k) => `${JSON.stringify(k)}:${canonicalJson(obj[k])}`);
|
|
15514
|
+
return `{${entries.join(",")}}`;
|
|
15515
|
+
}
|
|
15516
|
+
var ComplianceGenerator = class {
|
|
15517
|
+
generate(opts) {
|
|
15518
|
+
const { sha, repo, policy, scanResult, lintResult, files, now } = opts;
|
|
15519
|
+
const generated_at = (now ?? /* @__PURE__ */ new Date()).toISOString();
|
|
15520
|
+
const policy_hash = `sha256:${(0, import_crypto2.createHash)("sha256").update(canonicalJson(policy)).digest("hex")}`;
|
|
15521
|
+
return {
|
|
15522
|
+
schema_version: SCHEMA_VERSION,
|
|
15523
|
+
generated_at,
|
|
15524
|
+
sha,
|
|
15525
|
+
repo,
|
|
15526
|
+
policy_hash,
|
|
15527
|
+
policy_snapshot: policy,
|
|
15528
|
+
summary: this.buildSummary(scanResult, lintResult, files),
|
|
15529
|
+
files,
|
|
15530
|
+
scan: scanResult,
|
|
15531
|
+
lint: lintResult
|
|
15532
|
+
};
|
|
15533
|
+
}
|
|
15534
|
+
/**
|
|
15535
|
+
* Compute a {@link ComplianceDocument.policy_hash}-format hash of any
|
|
15536
|
+
* {@link PolicyDocument} without generating a full document. Useful for
|
|
15537
|
+
* external consumers that want to compare policies across repos.
|
|
15538
|
+
*/
|
|
15539
|
+
static hashPolicy(policy) {
|
|
15540
|
+
return `sha256:${(0, import_crypto2.createHash)("sha256").update(canonicalJson(policy)).digest("hex")}`;
|
|
15541
|
+
}
|
|
15542
|
+
buildSummary(scan, lint, files) {
|
|
15543
|
+
return {
|
|
15544
|
+
total_files: files.length,
|
|
15545
|
+
compliant: files.filter((f) => f.compliant).length,
|
|
15546
|
+
rotation_overdue: files.filter((f) => f.rotation_overdue).length,
|
|
15547
|
+
scan_violations: scan.matches.length,
|
|
15548
|
+
lint_errors: lint.issues.filter((i) => i.severity === "error").length
|
|
15549
|
+
};
|
|
15550
|
+
}
|
|
15551
|
+
};
|
|
15552
|
+
|
|
15553
|
+
// src/compliance/run.ts
|
|
15554
|
+
var path25 = __toESM(require("path"));
|
|
15555
|
+
var UNKNOWN = "unknown";
|
|
15556
|
+
async function runCompliance(opts) {
|
|
15557
|
+
const start = Date.now();
|
|
15558
|
+
const repoRoot = opts.repoRoot ?? process.cwd();
|
|
15559
|
+
const manifestPath = opts.manifestPath ?? path25.join(repoRoot, "clef.yaml");
|
|
15560
|
+
const policyPath = opts.policyPath ?? path25.join(repoRoot, CLEF_POLICY_FILENAME);
|
|
15561
|
+
const include = {
|
|
15562
|
+
scan: opts.include?.scan ?? true,
|
|
15563
|
+
lint: opts.include?.lint ?? true,
|
|
15564
|
+
rotation: opts.include?.rotation ?? true
|
|
15565
|
+
};
|
|
15566
|
+
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
15567
|
+
const manifest = new ManifestParser().parse(manifestPath);
|
|
15568
|
+
const policy = opts.policy ?? new PolicyParser().load(policyPath);
|
|
15569
|
+
const sopsClient = new SopsClient(opts.runner);
|
|
15570
|
+
const matrixManager = new MatrixManager();
|
|
15571
|
+
const schemaValidator = new SchemaValidator();
|
|
15572
|
+
const [sha, repo, files, scanResult, lintResult] = await Promise.all([
|
|
15573
|
+
opts.sha !== void 0 ? Promise.resolve(opts.sha) : detectSha(opts.runner, repoRoot),
|
|
15574
|
+
opts.repo !== void 0 ? Promise.resolve(opts.repo) : detectRepo(opts.runner, repoRoot),
|
|
15575
|
+
include.rotation ? evaluateMatrix({
|
|
15576
|
+
manifest,
|
|
15577
|
+
repoRoot,
|
|
15578
|
+
policy,
|
|
15579
|
+
matrixManager,
|
|
15580
|
+
sopsClient,
|
|
15581
|
+
filter: opts.filter,
|
|
15582
|
+
now
|
|
15583
|
+
}) : Promise.resolve([]),
|
|
15584
|
+
include.scan ? new ScanRunner(opts.runner).scan(repoRoot, manifest) : Promise.resolve(emptyScan()),
|
|
15585
|
+
include.lint ? new LintRunner(matrixManager, schemaValidator, sopsClient).run(manifest, repoRoot) : Promise.resolve(emptyLint())
|
|
15586
|
+
]);
|
|
15587
|
+
const document = new ComplianceGenerator().generate({
|
|
15588
|
+
sha,
|
|
15589
|
+
repo,
|
|
15590
|
+
policy,
|
|
15591
|
+
scanResult,
|
|
15592
|
+
lintResult,
|
|
15593
|
+
files,
|
|
15594
|
+
now
|
|
15595
|
+
});
|
|
15596
|
+
const passed = document.summary.rotation_overdue === 0 && document.summary.scan_violations === 0 && document.summary.lint_errors === 0;
|
|
15597
|
+
return { document, passed, durationMs: Date.now() - start };
|
|
15598
|
+
}
|
|
15599
|
+
async function evaluateMatrix(args) {
|
|
15600
|
+
const evaluator = new PolicyEvaluator(args.policy);
|
|
15601
|
+
const cells = args.matrixManager.resolveMatrix(args.manifest, args.repoRoot).filter((c) => applyFilter(c.namespace, c.environment, args.filter)).filter((c) => c.exists);
|
|
15602
|
+
return Promise.all(
|
|
15603
|
+
cells.map(async (cell) => {
|
|
15604
|
+
const metadata = await args.sopsClient.getMetadata(cell.filePath);
|
|
15605
|
+
const relPath = path25.relative(args.repoRoot, cell.filePath).replace(/\\/g, "/");
|
|
15606
|
+
return evaluator.evaluateFile(relPath, cell.environment, metadata, args.now);
|
|
15607
|
+
})
|
|
15608
|
+
);
|
|
15609
|
+
}
|
|
15610
|
+
function applyFilter(namespace, environment, filter) {
|
|
15611
|
+
if (filter?.namespaces?.length && !filter.namespaces.includes(namespace)) return false;
|
|
15612
|
+
if (filter?.environments?.length && !filter.environments.includes(environment)) return false;
|
|
15613
|
+
return true;
|
|
15614
|
+
}
|
|
15615
|
+
function emptyScan() {
|
|
15616
|
+
return {
|
|
15617
|
+
matches: [],
|
|
15618
|
+
filesScanned: 0,
|
|
15619
|
+
filesSkipped: 0,
|
|
15620
|
+
unencryptedMatrixFiles: [],
|
|
15621
|
+
durationMs: 0
|
|
15622
|
+
};
|
|
15623
|
+
}
|
|
15624
|
+
function emptyLint() {
|
|
15625
|
+
return { issues: [], fileCount: 0, pendingCount: 0 };
|
|
15626
|
+
}
|
|
15627
|
+
async function detectSha(runner, repoRoot) {
|
|
15628
|
+
const env = process.env;
|
|
15629
|
+
const fromEnv = env.GITHUB_SHA ?? env.CI_COMMIT_SHA ?? env.BITBUCKET_COMMIT ?? env.CIRCLE_SHA1 ?? env.BUILD_VCS_NUMBER;
|
|
15630
|
+
if (fromEnv) return fromEnv;
|
|
15631
|
+
const result = await runner.run("git", ["rev-parse", "HEAD"], { cwd: repoRoot });
|
|
15632
|
+
if (result.exitCode !== 0) return UNKNOWN;
|
|
15633
|
+
const trimmed = result.stdout.trim();
|
|
15634
|
+
return trimmed || UNKNOWN;
|
|
15635
|
+
}
|
|
15636
|
+
async function detectRepo(runner, repoRoot) {
|
|
15637
|
+
const env = process.env;
|
|
15638
|
+
const fromEnv = env.GITHUB_REPOSITORY ?? env.CI_PROJECT_PATH ?? env.BITBUCKET_REPO_FULL_NAME ?? (env.CIRCLE_PROJECT_USERNAME && env.CIRCLE_PROJECT_REPONAME ? `${env.CIRCLE_PROJECT_USERNAME}/${env.CIRCLE_PROJECT_REPONAME}` : void 0);
|
|
15639
|
+
if (fromEnv) return fromEnv;
|
|
15640
|
+
const result = await runner.run("git", ["remote", "get-url", "origin"], { cwd: repoRoot });
|
|
15641
|
+
if (result.exitCode !== 0) return UNKNOWN;
|
|
15642
|
+
const url = result.stdout.trim();
|
|
15643
|
+
const match = url.match(/[:/]([^/:]+)\/([^/]+?)(?:\.git)?\/?$/);
|
|
15644
|
+
return match ? `${match[1]}/${match[2]}` : UNKNOWN;
|
|
15645
|
+
}
|
|
15295
15646
|
// Annotate the CommonJS export names for ESM import in node:
|
|
15296
15647
|
0 && (module.exports = {
|
|
15297
15648
|
ArtifactPacker,
|
|
15298
15649
|
BackendMigrator,
|
|
15299
15650
|
BulkOps,
|
|
15300
15651
|
CLEF_MANIFEST_FILENAME,
|
|
15652
|
+
CLEF_POLICY_FILENAME,
|
|
15301
15653
|
CLEF_REPORT_SCHEMA_VERSION,
|
|
15302
15654
|
CLEF_SUPPORTED_EXTENSIONS,
|
|
15303
15655
|
ClefError,
|
|
15304
15656
|
CloudApiError,
|
|
15305
15657
|
CloudClient,
|
|
15658
|
+
ComplianceGenerator,
|
|
15306
15659
|
ConsumptionClient,
|
|
15660
|
+
DEFAULT_POLICY,
|
|
15307
15661
|
DiffEngine,
|
|
15308
15662
|
DriftDetector,
|
|
15309
15663
|
FilePackOutput,
|
|
@@ -15315,6 +15669,9 @@ var SyncManager = class {
|
|
|
15315
15669
|
ManifestValidationError,
|
|
15316
15670
|
MatrixManager,
|
|
15317
15671
|
MemoryPackOutput,
|
|
15672
|
+
PolicyEvaluator,
|
|
15673
|
+
PolicyParser,
|
|
15674
|
+
PolicyValidationError,
|
|
15318
15675
|
REQUESTS_FILENAME,
|
|
15319
15676
|
REQUIREMENTS,
|
|
15320
15677
|
RecipientManager,
|
|
@@ -15381,6 +15738,7 @@ var SyncManager = class {
|
|
|
15381
15738
|
resolveIdentitySecrets,
|
|
15382
15739
|
resolveRecipientsForEnvironment,
|
|
15383
15740
|
resolveSopsPath,
|
|
15741
|
+
runCompliance,
|
|
15384
15742
|
saveMetadata,
|
|
15385
15743
|
saveRequests,
|
|
15386
15744
|
shannonEntropy,
|
|
@@ -15397,17 +15755,16 @@ var SyncManager = class {
|
|
|
15397
15755
|
});
|
|
15398
15756
|
/*! Bundled license information:
|
|
15399
15757
|
|
|
15400
|
-
@noble/hashes/utils.js:
|
|
15401
|
-
@noble/hashes/utils.js:
|
|
15402
|
-
@noble/hashes/utils.js:
|
|
15403
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
15404
|
-
|
|
15405
15758
|
@scure/base/index.js:
|
|
15406
15759
|
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
15407
15760
|
|
|
15408
15761
|
@noble/ciphers/utils.js:
|
|
15409
15762
|
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
|
|
15410
15763
|
|
|
15764
|
+
@noble/hashes/utils.js:
|
|
15765
|
+
@noble/hashes/utils.js:
|
|
15766
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
15767
|
+
|
|
15411
15768
|
@noble/curves/utils.js:
|
|
15412
15769
|
@noble/curves/abstract/modular.js:
|
|
15413
15770
|
@noble/curves/abstract/curve.js:
|