@mrciphersmith/keryx 0.4.61 → 0.4.62
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/cli.js +7476 -6052
- package/dist/core.js +201 -7
- package/dist/keryx-general-worker-entry.js +345 -18
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -2891,20 +2891,180 @@ var init_pii = __esm(() => {
|
|
|
2891
2891
|
});
|
|
2892
2892
|
|
|
2893
2893
|
// src/security/detect/secrets.ts
|
|
2894
|
+
function nextMatch(pattern, content, from) {
|
|
2895
|
+
pattern.lastIndex = from;
|
|
2896
|
+
return pattern.exec(content);
|
|
2897
|
+
}
|
|
2898
|
+
function isBase64Code(code) {
|
|
2899
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 43 || code === 47 || code === 61;
|
|
2900
|
+
}
|
|
2901
|
+
function isDigitCode(code) {
|
|
2902
|
+
return code >= 48 && code <= 57;
|
|
2903
|
+
}
|
|
2904
|
+
function isHexCode(code) {
|
|
2905
|
+
return isDigitCode(code) || code >= 65 && code <= 70 || code >= 97 && code <= 102;
|
|
2906
|
+
}
|
|
2907
|
+
function isSeparatorCode(code) {
|
|
2908
|
+
return code === 58 || code === 45;
|
|
2909
|
+
}
|
|
2910
|
+
function isSpaceCode(code) {
|
|
2911
|
+
return code === 32 || code === 9 || code === 13 || code === 11 || code === 12;
|
|
2912
|
+
}
|
|
2913
|
+
function isDiffMarkerCode(code) {
|
|
2914
|
+
return code === 32 || code === 43 || code === 45;
|
|
2915
|
+
}
|
|
2916
|
+
function backslashesBefore(content, index, from) {
|
|
2917
|
+
let count = 0;
|
|
2918
|
+
for (let i = index - 1;i >= from && content.charCodeAt(i) === BACKSLASH; i--)
|
|
2919
|
+
count += 1;
|
|
2920
|
+
return count;
|
|
2921
|
+
}
|
|
2922
|
+
function bodyRunStart(content, end, from) {
|
|
2923
|
+
let run = end;
|
|
2924
|
+
while (run > from) {
|
|
2925
|
+
const last = run - 1;
|
|
2926
|
+
const code = content.charCodeAt(last);
|
|
2927
|
+
if (isHexCode(code) && last - 5 >= from && content.charCodeAt(last - 5) === BACKSLASH && content.charCodeAt(last - 4) === LETTER_U && isHexCode(content.charCodeAt(last - 3)) && isHexCode(content.charCodeAt(last - 2)) && isHexCode(content.charCodeAt(last - 1)) && backslashesBefore(content, last - 5, from) % 2 === 0) {
|
|
2928
|
+
run -= 6;
|
|
2929
|
+
continue;
|
|
2930
|
+
}
|
|
2931
|
+
if (code === BACKSLASH) {
|
|
2932
|
+
const count = backslashesBefore(content, run, from);
|
|
2933
|
+
if (count % 2 === 1)
|
|
2934
|
+
break;
|
|
2935
|
+
run -= count;
|
|
2936
|
+
continue;
|
|
2937
|
+
}
|
|
2938
|
+
if (backslashesBefore(content, last, from) % 2 === 1) {
|
|
2939
|
+
if (!BODY_ESCAPE_LETTERS.has(code))
|
|
2940
|
+
break;
|
|
2941
|
+
run -= 2;
|
|
2942
|
+
continue;
|
|
2943
|
+
}
|
|
2944
|
+
if (!isBase64Code(code))
|
|
2945
|
+
break;
|
|
2946
|
+
run -= 1;
|
|
2947
|
+
}
|
|
2948
|
+
return run;
|
|
2949
|
+
}
|
|
2950
|
+
function prefixShape(text) {
|
|
2951
|
+
let shape = "";
|
|
2952
|
+
let i = 0;
|
|
2953
|
+
while (i < text.length) {
|
|
2954
|
+
const code = text.charCodeAt(i);
|
|
2955
|
+
if (isDigitCode(code)) {
|
|
2956
|
+
let j = i;
|
|
2957
|
+
while (j < text.length && isDigitCode(text.charCodeAt(j)))
|
|
2958
|
+
j += 1;
|
|
2959
|
+
if (j < text.length && isSeparatorCode(text.charCodeAt(j))) {
|
|
2960
|
+
j += 1;
|
|
2961
|
+
for (;; ) {
|
|
2962
|
+
let k = j;
|
|
2963
|
+
while (k < text.length && isDigitCode(text.charCodeAt(k)))
|
|
2964
|
+
k += 1;
|
|
2965
|
+
if (k === j || k === text.length || !isSeparatorCode(text.charCodeAt(k)))
|
|
2966
|
+
break;
|
|
2967
|
+
j = k + 1;
|
|
2968
|
+
}
|
|
2969
|
+
shape += "\x00F";
|
|
2970
|
+
} else {
|
|
2971
|
+
shape += "\x00N";
|
|
2972
|
+
}
|
|
2973
|
+
i = j;
|
|
2974
|
+
} else if (isSpaceCode(code)) {
|
|
2975
|
+
let j = i;
|
|
2976
|
+
while (j < text.length && isSpaceCode(text.charCodeAt(j)))
|
|
2977
|
+
j += 1;
|
|
2978
|
+
if (j === text.length || !isDigitCode(text.charCodeAt(j)))
|
|
2979
|
+
shape += text.slice(i, j);
|
|
2980
|
+
i = j;
|
|
2981
|
+
} else if (isSeparatorCode(code) && (i + 1 === text.length || isDigitCode(text.charCodeAt(i + 1)))) {
|
|
2982
|
+
shape += "\x00S";
|
|
2983
|
+
i += 1;
|
|
2984
|
+
} else {
|
|
2985
|
+
shape += code === 0 ? "\x00\x00" : text.charAt(i);
|
|
2986
|
+
i += 1;
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
return shape;
|
|
2990
|
+
}
|
|
2991
|
+
function keyLineOf(line, shape, blankShape) {
|
|
2992
|
+
const text = line.trimEnd();
|
|
2993
|
+
if (text.length === 0)
|
|
2994
|
+
return "blank";
|
|
2995
|
+
let bodyStart = text.length;
|
|
2996
|
+
while (bodyStart > 0 && isBase64Code(text.charCodeAt(bodyStart - 1)))
|
|
2997
|
+
bodyStart -= 1;
|
|
2998
|
+
if (bodyStart < text.length && PEM_BODY.test(text.slice(bodyStart)) && prefixShape(text.slice(0, bodyStart)) === shape)
|
|
2999
|
+
return "body";
|
|
3000
|
+
const header = PEM_HEADER_FIELD.exec(text);
|
|
3001
|
+
if (header !== null && prefixShape(text.slice(0, header.index)) === shape)
|
|
3002
|
+
return "header";
|
|
3003
|
+
return prefixShape(text) === blankShape ? "blank" : undefined;
|
|
3004
|
+
}
|
|
3005
|
+
function diffKeyLineOf(line) {
|
|
3006
|
+
if (line.length > 0 && isDiffMarkerCode(line.charCodeAt(0)))
|
|
3007
|
+
return keyLineOf(line.slice(1), "", "");
|
|
3008
|
+
return line.trimEnd().length === 0 ? "blank" : undefined;
|
|
3009
|
+
}
|
|
3010
|
+
function orphanBodyStart(content, endIndex, from) {
|
|
3011
|
+
const run = bodyRunStart(content, endIndex, from);
|
|
3012
|
+
let lineStart = run;
|
|
3013
|
+
while (lineStart > from && content.charCodeAt(lineStart - 1) !== NEWLINE)
|
|
3014
|
+
lineStart -= 1;
|
|
3015
|
+
const diffLine = endIndex === lineStart + 1 && isDiffMarkerCode(content.charCodeAt(lineStart));
|
|
3016
|
+
const prefix = content.slice(lineStart, run);
|
|
3017
|
+
const shape = prefixShape(prefix);
|
|
3018
|
+
const blankShape = prefixShape(prefix.trimEnd());
|
|
3019
|
+
let start = run;
|
|
3020
|
+
let headerSeen = false;
|
|
3021
|
+
let below = lineStart;
|
|
3022
|
+
while (below > from) {
|
|
3023
|
+
const lineEnd = below - 1;
|
|
3024
|
+
let lineBegin = lineEnd;
|
|
3025
|
+
while (lineBegin > from && content.charCodeAt(lineBegin - 1) !== NEWLINE)
|
|
3026
|
+
lineBegin -= 1;
|
|
3027
|
+
const line = content.slice(lineBegin, lineEnd);
|
|
3028
|
+
const kind = diffLine ? diffKeyLineOf(line) : keyLineOf(line, shape, blankShape);
|
|
3029
|
+
below = lineBegin;
|
|
3030
|
+
if (kind === "blank")
|
|
3031
|
+
continue;
|
|
3032
|
+
if (kind === "header") {
|
|
3033
|
+
headerSeen = true;
|
|
3034
|
+
} else if (kind !== "body" || headerSeen) {
|
|
3035
|
+
break;
|
|
3036
|
+
}
|
|
3037
|
+
start = lineBegin;
|
|
3038
|
+
}
|
|
3039
|
+
return start;
|
|
3040
|
+
}
|
|
2894
3041
|
function scanPrivateKeyBlocks(content) {
|
|
2895
3042
|
const spans = [];
|
|
2896
|
-
|
|
2897
|
-
let begin;
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
3043
|
+
let from = 0;
|
|
3044
|
+
let begin = nextMatch(PRIVATE_KEY_BEGIN, content, 0);
|
|
3045
|
+
let end = nextMatch(PRIVATE_KEY_END, content, 0);
|
|
3046
|
+
while (begin !== null || end !== null) {
|
|
3047
|
+
if (end !== null && (begin === null || end.index < begin.index)) {
|
|
3048
|
+
const stop = end.index + end[0].length;
|
|
3049
|
+
spans.push([orphanBodyStart(content, end.index, from), stop]);
|
|
3050
|
+
from = stop;
|
|
3051
|
+
end = nextMatch(PRIVATE_KEY_END, content, stop);
|
|
3052
|
+
continue;
|
|
3053
|
+
}
|
|
3054
|
+
if (begin === null)
|
|
3055
|
+
break;
|
|
3056
|
+
const headerEnd = begin.index + begin[0].length;
|
|
3057
|
+
if (end !== null && end.index < headerEnd)
|
|
3058
|
+
end = nextMatch(PRIVATE_KEY_END, content, headerEnd);
|
|
2901
3059
|
if (end === null) {
|
|
2902
3060
|
spans.push([begin.index, content.length]);
|
|
2903
3061
|
break;
|
|
2904
3062
|
}
|
|
2905
3063
|
const stop = end.index + end[0].length;
|
|
2906
3064
|
spans.push([begin.index, stop]);
|
|
2907
|
-
|
|
3065
|
+
from = stop;
|
|
3066
|
+
begin = nextMatch(PRIVATE_KEY_BEGIN, content, stop);
|
|
3067
|
+
end = nextMatch(PRIVATE_KEY_END, content, stop);
|
|
2908
3068
|
}
|
|
2909
3069
|
return spans;
|
|
2910
3070
|
}
|
|
@@ -2958,10 +3118,13 @@ function valueGroupOf(rule, m) {
|
|
|
2958
3118
|
}
|
|
2959
3119
|
return;
|
|
2960
3120
|
}
|
|
2961
|
-
var PRIVATE_KEY_BEGIN, PRIVATE_KEY_END, ASSIGNED_VALUE, RULES2;
|
|
3121
|
+
var PRIVATE_KEY_BEGIN, PRIVATE_KEY_END, PEM_BODY, PEM_HEADER_FIELD, NEWLINE = 10, BACKSLASH = 92, LETTER_U = 117, BODY_ESCAPE_LETTERS, ASSIGNED_VALUE, RULES2;
|
|
2962
3122
|
var init_secrets = __esm(() => {
|
|
2963
3123
|
PRIVATE_KEY_BEGIN = /-----BEGIN (?:[A-Z0-9]{1,16} ){0,3}PRIVATE KEY(?: BLOCK)?-----/g;
|
|
2964
3124
|
PRIVATE_KEY_END = /-----END (?:[A-Z0-9]{1,16} ){0,3}PRIVATE KEY(?: BLOCK)?-----/g;
|
|
3125
|
+
PEM_BODY = /^=?[A-Za-z0-9+/]+={0,2}$/;
|
|
3126
|
+
PEM_HEADER_FIELD = /(?:Proc-Type|DEK-Info|Content-Domain|Version|Comment|Hash|Charset|MessageID): /;
|
|
3127
|
+
BODY_ESCAPE_LETTERS = new Set([110, 114, 116, 98, 102, 47]);
|
|
2965
3128
|
ASSIGNED_VALUE = String.raw`(?:"([^"\n]{6,})"|'([^'\n]{6,})'|["']?([^\s"'#]{6,}))`;
|
|
2966
3129
|
RULES2 = [
|
|
2967
3130
|
{
|
|
@@ -44996,6 +45159,7 @@ function readJsonl2(file) {
|
|
|
44996
45159
|
...typeof o.trailStep === "number" && Number.isInteger(o.trailStep) && o.trailStep > 0 ? { trailStep: o.trailStep } : {},
|
|
44997
45160
|
...o.packed === true ? { packed: true } : {},
|
|
44998
45161
|
...o.slateFrame === true ? { slateFrame: true } : {},
|
|
45162
|
+
...o.role === "user" && o.terminalContinuation === true ? { terminalContinuation: true } : {},
|
|
44999
45163
|
...typeof o.ts === "string" && o.ts.length > 0 ? { ts: o.ts } : {},
|
|
45000
45164
|
...reasoning !== undefined ? { reasoning } : {}
|
|
45001
45165
|
});
|
|
@@ -49192,6 +49356,30 @@ var HELP_GROUPS = [
|
|
|
49192
49356
|
group: "Managed work",
|
|
49193
49357
|
summary: "Project rules for implementation: the last resolve, the context cap, warn/block enforcement and conditional references \u2014 /projectctx [warn|block|refs]."
|
|
49194
49358
|
},
|
|
49359
|
+
{
|
|
49360
|
+
kind: "slash",
|
|
49361
|
+
name: "/ref",
|
|
49362
|
+
group: "Managed work",
|
|
49363
|
+
summary: "Linked projects: list, add and remove the folders this project organises \u2014 /ref [list|add <folder>|remove <name>]."
|
|
49364
|
+
},
|
|
49365
|
+
{
|
|
49366
|
+
kind: "slash",
|
|
49367
|
+
name: "/ref-list",
|
|
49368
|
+
group: "Managed work",
|
|
49369
|
+
summary: "List the linked projects with a summary of each."
|
|
49370
|
+
},
|
|
49371
|
+
{
|
|
49372
|
+
kind: "slash",
|
|
49373
|
+
name: "/add-ref",
|
|
49374
|
+
group: "Managed work",
|
|
49375
|
+
summary: "Link a folder (usually a sibling repository) to this project."
|
|
49376
|
+
},
|
|
49377
|
+
{
|
|
49378
|
+
kind: "slash",
|
|
49379
|
+
name: "/ref-remove",
|
|
49380
|
+
group: "Managed work",
|
|
49381
|
+
summary: "Unlink a linked project; the folder itself is not touched."
|
|
49382
|
+
},
|
|
49195
49383
|
{
|
|
49196
49384
|
kind: "slash",
|
|
49197
49385
|
name: "/jevprofile",
|
|
@@ -49553,6 +49741,12 @@ var HELP_GROUPS = [
|
|
|
49553
49741
|
group: "Maintenance and diagnostics",
|
|
49554
49742
|
summary: "Inspect the user-global registry of initialized projects."
|
|
49555
49743
|
},
|
|
49744
|
+
{
|
|
49745
|
+
kind: "cli",
|
|
49746
|
+
name: "ref",
|
|
49747
|
+
group: "Maintenance and diagnostics",
|
|
49748
|
+
summary: "Linked projects: list, add and remove the folders this project organises."
|
|
49749
|
+
},
|
|
49556
49750
|
{
|
|
49557
49751
|
kind: "cli",
|
|
49558
49752
|
name: "serve",
|