@truto/truto-jsonata 1.0.43 → 1.0.45
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/README.md +38 -55
- package/dist/browser/index.js +293 -1302
- package/dist/browser/index.js.map +18 -35
- package/dist/cjs/index.cjs +293 -1302
- package/dist/cjs/index.cjs.map +18 -35
- package/dist/esm/index.js +158 -66
- package/dist/esm/index.js.map +7 -7
- package/dist/functions/convertMdToPdf.d.ts +23 -0
- package/dist/functions/convertNotionToMarkdown.d.ts +1 -1
- package/package.json +2 -2
- package/dist/functions/signJwt.d.ts +0 -2
package/dist/browser/index.js
CHANGED
|
@@ -7718,7 +7718,7 @@ var require_select = __commonJS((exports, module) => {
|
|
|
7718
7718
|
var regex = rules.inside.source.replace(/</g, start).replace(/>/g, end);
|
|
7719
7719
|
return new RegExp(regex);
|
|
7720
7720
|
};
|
|
7721
|
-
var
|
|
7721
|
+
var replace = function(regex, name, val) {
|
|
7722
7722
|
regex = regex.source;
|
|
7723
7723
|
regex = regex.replace(name, val.source || val);
|
|
7724
7724
|
return new RegExp(regex);
|
|
@@ -8143,20 +8143,20 @@ var require_select = __commonJS((exports, module) => {
|
|
|
8143
8143
|
inside: /(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|<[^"'>]*>|\\["'>]|[^"'>])*/,
|
|
8144
8144
|
ident: /^(cssid)$/
|
|
8145
8145
|
};
|
|
8146
|
-
rules.cssid =
|
|
8147
|
-
rules.cssid =
|
|
8148
|
-
rules.qname =
|
|
8149
|
-
rules.simple =
|
|
8150
|
-
rules.ref =
|
|
8151
|
-
rules.attr =
|
|
8152
|
-
rules.pseudo =
|
|
8153
|
-
rules.inside =
|
|
8154
|
-
rules.attr =
|
|
8155
|
-
rules.pseudo =
|
|
8156
|
-
rules.simple =
|
|
8157
|
-
rules.simple =
|
|
8158
|
-
rules.ident =
|
|
8159
|
-
rules.str_escape =
|
|
8146
|
+
rules.cssid = replace(rules.cssid, "nonascii", rules.nonascii);
|
|
8147
|
+
rules.cssid = replace(rules.cssid, "escape", rules.escape);
|
|
8148
|
+
rules.qname = replace(rules.qname, "cssid", rules.cssid);
|
|
8149
|
+
rules.simple = replace(rules.simple, "cssid", rules.cssid);
|
|
8150
|
+
rules.ref = replace(rules.ref, "cssid", rules.cssid);
|
|
8151
|
+
rules.attr = replace(rules.attr, "cssid", rules.cssid);
|
|
8152
|
+
rules.pseudo = replace(rules.pseudo, "cssid", rules.cssid);
|
|
8153
|
+
rules.inside = replace(rules.inside, `[^"'>]*`, rules.inside);
|
|
8154
|
+
rules.attr = replace(rules.attr, "inside", makeInside("\\[", "\\]"));
|
|
8155
|
+
rules.pseudo = replace(rules.pseudo, "inside", makeInside("\\(", "\\)"));
|
|
8156
|
+
rules.simple = replace(rules.simple, "pseudo", rules.pseudo);
|
|
8157
|
+
rules.simple = replace(rules.simple, "attr", rules.attr);
|
|
8158
|
+
rules.ident = replace(rules.ident, "cssid", rules.cssid);
|
|
8159
|
+
rules.str_escape = replace(rules.str_escape, "escape", rules.escape);
|
|
8160
8160
|
var compile = function(sel_) {
|
|
8161
8161
|
var sel = sel_.replace(/^\s+|\s+$/g, ""), test, filter2 = [], buff = [], subject, qname, cap, op, ref;
|
|
8162
8162
|
while (sel) {
|
|
@@ -30337,7 +30337,7 @@ var require_object_inspect = __commonJS((exports, module) => {
|
|
|
30337
30337
|
}
|
|
30338
30338
|
return inspect_(value, opts, depth + 1, seen);
|
|
30339
30339
|
}
|
|
30340
|
-
if (typeof obj === "function" && !
|
|
30340
|
+
if (typeof obj === "function" && !isRegExp2(obj)) {
|
|
30341
30341
|
var name = nameOf(obj);
|
|
30342
30342
|
var keys2 = arrObjKeys(obj, inspect2);
|
|
30343
30343
|
return "[Function" + (name ? ": " + name : " (anonymous)") + "]" + (keys2.length > 0 ? " { " + $join.call(keys2, ", ") + " }" : "");
|
|
@@ -30431,7 +30431,7 @@ var require_object_inspect = __commonJS((exports, module) => {
|
|
|
30431
30431
|
if (typeof globalThis !== "undefined" && obj === globalThis || typeof global !== "undefined" && obj === global) {
|
|
30432
30432
|
return "{ [object globalThis] }";
|
|
30433
30433
|
}
|
|
30434
|
-
if (!isDate2(obj) && !
|
|
30434
|
+
if (!isDate2(obj) && !isRegExp2(obj)) {
|
|
30435
30435
|
var ys = arrObjKeys(obj, inspect2);
|
|
30436
30436
|
var isPlainObject3 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
30437
30437
|
var protoTag = obj instanceof Object ? "" : "null prototype";
|
|
@@ -30465,7 +30465,7 @@ var require_object_inspect = __commonJS((exports, module) => {
|
|
|
30465
30465
|
function isDate2(obj) {
|
|
30466
30466
|
return toStr(obj) === "[object Date]" && canTrustToString(obj);
|
|
30467
30467
|
}
|
|
30468
|
-
function
|
|
30468
|
+
function isRegExp2(obj) {
|
|
30469
30469
|
return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
|
|
30470
30470
|
}
|
|
30471
30471
|
function isError2(obj) {
|
|
@@ -31655,7 +31655,7 @@ var require_side_channel = __commonJS((exports, module) => {
|
|
|
31655
31655
|
|
|
31656
31656
|
// node_modules/qs/lib/formats.js
|
|
31657
31657
|
var require_formats = __commonJS((exports, module) => {
|
|
31658
|
-
var
|
|
31658
|
+
var replace = String.prototype.replace;
|
|
31659
31659
|
var percentTwenties = /%20/g;
|
|
31660
31660
|
var Format = {
|
|
31661
31661
|
RFC1738: "RFC1738",
|
|
@@ -31665,7 +31665,7 @@ var require_formats = __commonJS((exports, module) => {
|
|
|
31665
31665
|
default: Format.RFC3986,
|
|
31666
31666
|
formatters: {
|
|
31667
31667
|
RFC1738: function(value) {
|
|
31668
|
-
return
|
|
31668
|
+
return replace.call(value, percentTwenties, "+");
|
|
31669
31669
|
},
|
|
31670
31670
|
RFC3986: function(value) {
|
|
31671
31671
|
return String(value);
|
|
@@ -31842,7 +31842,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
31842
31842
|
compactQueue(queue);
|
|
31843
31843
|
return value;
|
|
31844
31844
|
};
|
|
31845
|
-
var
|
|
31845
|
+
var isRegExp2 = function isRegExp(obj) {
|
|
31846
31846
|
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
31847
31847
|
};
|
|
31848
31848
|
var isBuffer3 = function isBuffer(obj) {
|
|
@@ -31872,7 +31872,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
31872
31872
|
decode,
|
|
31873
31873
|
encode,
|
|
31874
31874
|
isBuffer: isBuffer3,
|
|
31875
|
-
isRegExp,
|
|
31875
|
+
isRegExp: isRegExp2,
|
|
31876
31876
|
maybeMap,
|
|
31877
31877
|
merge
|
|
31878
31878
|
};
|
|
@@ -36270,6 +36270,66 @@ function baseSlice(array, start, end) {
|
|
|
36270
36270
|
}
|
|
36271
36271
|
var _baseSlice_default = baseSlice;
|
|
36272
36272
|
|
|
36273
|
+
// node_modules/lodash-es/_castSlice.js
|
|
36274
|
+
function castSlice(array, start, end) {
|
|
36275
|
+
var length = array.length;
|
|
36276
|
+
end = end === undefined ? length : end;
|
|
36277
|
+
return !start && end >= length ? array : _baseSlice_default(array, start, end);
|
|
36278
|
+
}
|
|
36279
|
+
var _castSlice_default = castSlice;
|
|
36280
|
+
|
|
36281
|
+
// node_modules/lodash-es/_hasUnicode.js
|
|
36282
|
+
var rsAstralRange = "\\ud800-\\udfff";
|
|
36283
|
+
var rsComboMarksRange = "\\u0300-\\u036f";
|
|
36284
|
+
var reComboHalfMarksRange = "\\ufe20-\\ufe2f";
|
|
36285
|
+
var rsComboSymbolsRange = "\\u20d0-\\u20ff";
|
|
36286
|
+
var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
|
|
36287
|
+
var rsVarRange = "\\ufe0e\\ufe0f";
|
|
36288
|
+
var rsZWJ = "\\u200d";
|
|
36289
|
+
var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + "]");
|
|
36290
|
+
function hasUnicode(string) {
|
|
36291
|
+
return reHasUnicode.test(string);
|
|
36292
|
+
}
|
|
36293
|
+
var _hasUnicode_default = hasUnicode;
|
|
36294
|
+
|
|
36295
|
+
// node_modules/lodash-es/_asciiToArray.js
|
|
36296
|
+
function asciiToArray(string) {
|
|
36297
|
+
return string.split("");
|
|
36298
|
+
}
|
|
36299
|
+
var _asciiToArray_default = asciiToArray;
|
|
36300
|
+
|
|
36301
|
+
// node_modules/lodash-es/_unicodeToArray.js
|
|
36302
|
+
var rsAstralRange2 = "\\ud800-\\udfff";
|
|
36303
|
+
var rsComboMarksRange2 = "\\u0300-\\u036f";
|
|
36304
|
+
var reComboHalfMarksRange2 = "\\ufe20-\\ufe2f";
|
|
36305
|
+
var rsComboSymbolsRange2 = "\\u20d0-\\u20ff";
|
|
36306
|
+
var rsComboRange2 = rsComboMarksRange2 + reComboHalfMarksRange2 + rsComboSymbolsRange2;
|
|
36307
|
+
var rsVarRange2 = "\\ufe0e\\ufe0f";
|
|
36308
|
+
var rsAstral = "[" + rsAstralRange2 + "]";
|
|
36309
|
+
var rsCombo = "[" + rsComboRange2 + "]";
|
|
36310
|
+
var rsFitz = "\\ud83c[\\udffb-\\udfff]";
|
|
36311
|
+
var rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")";
|
|
36312
|
+
var rsNonAstral = "[^" + rsAstralRange2 + "]";
|
|
36313
|
+
var rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}";
|
|
36314
|
+
var rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]";
|
|
36315
|
+
var rsZWJ2 = "\\u200d";
|
|
36316
|
+
var reOptMod = rsModifier + "?";
|
|
36317
|
+
var rsOptVar = "[" + rsVarRange2 + "]?";
|
|
36318
|
+
var rsOptJoin = "(?:" + rsZWJ2 + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*";
|
|
36319
|
+
var rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
|
36320
|
+
var rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
|
|
36321
|
+
var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
|
|
36322
|
+
function unicodeToArray(string) {
|
|
36323
|
+
return string.match(reUnicode) || [];
|
|
36324
|
+
}
|
|
36325
|
+
var _unicodeToArray_default = unicodeToArray;
|
|
36326
|
+
|
|
36327
|
+
// node_modules/lodash-es/_stringToArray.js
|
|
36328
|
+
function stringToArray(string) {
|
|
36329
|
+
return _hasUnicode_default(string) ? _unicodeToArray_default(string) : _asciiToArray_default(string);
|
|
36330
|
+
}
|
|
36331
|
+
var _stringToArray_default = stringToArray;
|
|
36332
|
+
|
|
36273
36333
|
// node_modules/lodash-es/_arrayReduce.js
|
|
36274
36334
|
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
|
36275
36335
|
var index = -1, length = array == null ? 0 : array.length;
|
|
@@ -37557,11 +37617,17 @@ function isNil(value) {
|
|
|
37557
37617
|
return value == null;
|
|
37558
37618
|
}
|
|
37559
37619
|
var isNil_default = isNil;
|
|
37560
|
-
// node_modules/lodash-es/
|
|
37561
|
-
|
|
37562
|
-
|
|
37620
|
+
// node_modules/lodash-es/_baseIsRegExp.js
|
|
37621
|
+
var regexpTag5 = "[object RegExp]";
|
|
37622
|
+
function baseIsRegExp(value) {
|
|
37623
|
+
return isObjectLike_default(value) && _baseGetTag_default(value) == regexpTag5;
|
|
37563
37624
|
}
|
|
37564
|
-
var
|
|
37625
|
+
var _baseIsRegExp_default = baseIsRegExp;
|
|
37626
|
+
|
|
37627
|
+
// node_modules/lodash-es/isRegExp.js
|
|
37628
|
+
var nodeIsRegExp = _nodeUtil_default && _nodeUtil_default.isRegExp;
|
|
37629
|
+
var isRegExp = nodeIsRegExp ? _baseUnary_default(nodeIsRegExp) : _baseIsRegExp_default;
|
|
37630
|
+
var isRegExp_default = isRegExp;
|
|
37565
37631
|
// node_modules/lodash-es/join.js
|
|
37566
37632
|
var arrayProto2 = Array.prototype;
|
|
37567
37633
|
var nativeJoin = arrayProto2.join;
|
|
@@ -37828,12 +37894,6 @@ function repeat(string, n, guard) {
|
|
|
37828
37894
|
return _baseRepeat_default(toString_default(string), n);
|
|
37829
37895
|
}
|
|
37830
37896
|
var repeat_default = repeat;
|
|
37831
|
-
// node_modules/lodash-es/replace.js
|
|
37832
|
-
function replace() {
|
|
37833
|
-
var args = arguments, string = toString_default(args[0]);
|
|
37834
|
-
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
|
37835
|
-
}
|
|
37836
|
-
var replace_default = replace;
|
|
37837
37897
|
// node_modules/lodash-es/set.js
|
|
37838
37898
|
function set(object, path, value) {
|
|
37839
37899
|
return object == null ? object : _baseSet_default(object, path, value);
|
|
@@ -37853,6 +37913,55 @@ var sortBy = _baseRest_default(function(collection, iteratees) {
|
|
|
37853
37913
|
return _baseOrderBy_default(collection, _baseFlatten_default(iteratees, 1), []);
|
|
37854
37914
|
});
|
|
37855
37915
|
var sortBy_default = sortBy;
|
|
37916
|
+
// node_modules/lodash-es/split.js
|
|
37917
|
+
var MAX_ARRAY_LENGTH = 4294967295;
|
|
37918
|
+
function split(string, separator, limit) {
|
|
37919
|
+
if (limit && typeof limit != "number" && _isIterateeCall_default(string, separator, limit)) {
|
|
37920
|
+
separator = limit = undefined;
|
|
37921
|
+
}
|
|
37922
|
+
limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
|
|
37923
|
+
if (!limit) {
|
|
37924
|
+
return [];
|
|
37925
|
+
}
|
|
37926
|
+
string = toString_default(string);
|
|
37927
|
+
if (string && (typeof separator == "string" || separator != null && !isRegExp_default(separator))) {
|
|
37928
|
+
separator = _baseToString_default(separator);
|
|
37929
|
+
if (!separator && _hasUnicode_default(string)) {
|
|
37930
|
+
return _castSlice_default(_stringToArray_default(string), 0, limit);
|
|
37931
|
+
}
|
|
37932
|
+
}
|
|
37933
|
+
return string.split(separator, limit);
|
|
37934
|
+
}
|
|
37935
|
+
var split_default = split;
|
|
37936
|
+
// node_modules/lodash-es/_charsEndIndex.js
|
|
37937
|
+
function charsEndIndex(strSymbols, chrSymbols) {
|
|
37938
|
+
var index = strSymbols.length;
|
|
37939
|
+
while (index-- && _baseIndexOf_default(chrSymbols, strSymbols[index], 0) > -1) {}
|
|
37940
|
+
return index;
|
|
37941
|
+
}
|
|
37942
|
+
var _charsEndIndex_default = charsEndIndex;
|
|
37943
|
+
|
|
37944
|
+
// node_modules/lodash-es/_charsStartIndex.js
|
|
37945
|
+
function charsStartIndex(strSymbols, chrSymbols) {
|
|
37946
|
+
var index = -1, length = strSymbols.length;
|
|
37947
|
+
while (++index < length && _baseIndexOf_default(chrSymbols, strSymbols[index], 0) > -1) {}
|
|
37948
|
+
return index;
|
|
37949
|
+
}
|
|
37950
|
+
var _charsStartIndex_default = charsStartIndex;
|
|
37951
|
+
|
|
37952
|
+
// node_modules/lodash-es/trim.js
|
|
37953
|
+
function trim(string, chars, guard) {
|
|
37954
|
+
string = toString_default(string);
|
|
37955
|
+
if (string && (guard || chars === undefined)) {
|
|
37956
|
+
return _baseTrim_default(string);
|
|
37957
|
+
}
|
|
37958
|
+
if (!string || !(chars = _baseToString_default(chars))) {
|
|
37959
|
+
return string;
|
|
37960
|
+
}
|
|
37961
|
+
var strSymbols = _stringToArray_default(string), chrSymbols = _stringToArray_default(chars), start = _charsStartIndex_default(strSymbols, chrSymbols), end = _charsEndIndex_default(strSymbols, chrSymbols) + 1;
|
|
37962
|
+
return _castSlice_default(strSymbols, start, end).join("");
|
|
37963
|
+
}
|
|
37964
|
+
var trim_default = trim;
|
|
37856
37965
|
// src/functions/base64decode.ts
|
|
37857
37966
|
function base64decode(base64, urlSafe = false) {
|
|
37858
37967
|
if (urlSafe) {
|
|
@@ -45491,7 +45600,7 @@ var formatPlainText = (x) => {
|
|
|
45491
45600
|
return textToReturn;
|
|
45492
45601
|
}
|
|
45493
45602
|
};
|
|
45494
|
-
var convertNotionToMd = function(block3, level = 1) {
|
|
45603
|
+
var convertNotionToMd = function(block3, level = 1, linkChildPages = false) {
|
|
45495
45604
|
const n = `
|
|
45496
45605
|
|
|
45497
45606
|
`;
|
|
@@ -45503,16 +45612,16 @@ var convertNotionToMd = function(block3, level = 1) {
|
|
|
45503
45612
|
case "bookmark":
|
|
45504
45613
|
return `[${data.url}](data.url)${n}`;
|
|
45505
45614
|
case "bulleted_list_item":
|
|
45506
|
-
childData = map_default(block3.children, (child) => convertNotionToMd(child, level + 1))
|
|
45507
|
-
return `- ${plainText
|
|
45615
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level + 1, linkChildPages)), repeat_default("\t", level));
|
|
45616
|
+
return `- ${join_default(plainText, "")}
|
|
45508
45617
|
` + (childData ? `${repeat_default("\t", level)}${childData}` : "");
|
|
45509
45618
|
case "numbered_list_item":
|
|
45510
|
-
childData = map_default(block3.children, (child) => convertNotionToMd(child, level + 1))
|
|
45511
|
-
return `${block3.number}. ${plainText
|
|
45619
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level + 1, linkChildPages)), repeat_default("\t", level));
|
|
45620
|
+
return `${block3.number}. ${join_default(plainText, "")}
|
|
45512
45621
|
` + (childData ? `${repeat_default("\t", level)}${childData}` : "");
|
|
45513
45622
|
case "quote":
|
|
45514
45623
|
case "callout":
|
|
45515
|
-
return `> ${plainText
|
|
45624
|
+
return `> ${join_default(plainText, "")}${n}`;
|
|
45516
45625
|
case "code":
|
|
45517
45626
|
return `\`\`\`${data.language}
|
|
45518
45627
|
${plainText}
|
|
@@ -45524,51 +45633,60 @@ ${plainText}
|
|
|
45524
45633
|
case "equation":
|
|
45525
45634
|
return data.expression;
|
|
45526
45635
|
case "paragraph":
|
|
45527
|
-
return plainText
|
|
45636
|
+
return join_default(plainText, "") + n;
|
|
45528
45637
|
case "video":
|
|
45529
45638
|
case "pdf":
|
|
45530
45639
|
case "file":
|
|
45531
45640
|
return `[${caption.length ? caption : "File"}](${data.file ? data.file.url : data.external ? data.external.url : ""})${n}`;
|
|
45532
45641
|
case "heading_1":
|
|
45533
|
-
return `# ${plainText
|
|
45642
|
+
return `# ${join_default(plainText, "")}${n}`;
|
|
45534
45643
|
case "heading_2":
|
|
45535
|
-
return `## ${plainText
|
|
45644
|
+
return `## ${join_default(plainText, "")}${n}`;
|
|
45536
45645
|
case "heading_3":
|
|
45537
|
-
return `### ${plainText
|
|
45646
|
+
return `### ${join_default(plainText, "")}${n}`;
|
|
45538
45647
|
case "heading_4":
|
|
45539
|
-
return `#### ${plainText
|
|
45648
|
+
return `#### ${join_default(plainText, "")}${n}`;
|
|
45540
45649
|
case "heading_5":
|
|
45541
|
-
return `##### ${plainText
|
|
45650
|
+
return `##### ${join_default(plainText, "")}${n}`;
|
|
45542
45651
|
case "heading_6":
|
|
45543
|
-
return `###### ${plainText
|
|
45652
|
+
return `###### ${join_default(plainText, "")}${n}`;
|
|
45544
45653
|
case "image":
|
|
45545
45654
|
return `${n}`;
|
|
45655
|
+
case "child_page":
|
|
45656
|
+
if (linkChildPages) {
|
|
45657
|
+
const pageTitle = data.title || "Untitled Page";
|
|
45658
|
+
const pageUrl = `https://www.notion.so/${block3.id.replace(/-/g, "")}`;
|
|
45659
|
+
return `[${pageTitle}](${pageUrl})${n}`;
|
|
45660
|
+
} else {
|
|
45661
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level, linkChildPages)), "");
|
|
45662
|
+
return (data.title || "Untitled Page") + n + childData;
|
|
45663
|
+
}
|
|
45546
45664
|
case "table":
|
|
45547
45665
|
if (block3.children) {
|
|
45548
45666
|
const firstChild = block3.children[0];
|
|
45549
45667
|
const remainingChildren = block3.children.slice(1);
|
|
45550
|
-
const header = `| ${firstChild.table_row.cells.map((x) => x.map((y) => formatPlainText(y))
|
|
45668
|
+
const header = `| ${join_default(firstChild.table_row.cells.map((x) => join_default(x.map((y) => formatPlainText(y)), "")), " | ")} |
|
|
45551
45669
|
`;
|
|
45552
45670
|
const divider = `|${repeat_default("---|", data.table_width)}
|
|
45553
45671
|
`;
|
|
45554
|
-
const rows = remainingChildren.map((row) => {
|
|
45555
|
-
return `| ${row.table_row.cells.map((x) => x.map((y) => formatPlainText(y))
|
|
45556
|
-
})
|
|
45672
|
+
const rows = join_default(remainingChildren.map((row) => {
|
|
45673
|
+
return `| ${join_default(row.table_row.cells.map((x) => join_default(x.map((y) => formatPlainText(y)), "")), " | ")} |`;
|
|
45674
|
+
}), `
|
|
45557
45675
|
`);
|
|
45558
45676
|
return `${header}${divider}${rows}${n}`;
|
|
45559
45677
|
}
|
|
45560
45678
|
return `Table as CSV
|
|
45561
45679
|
`;
|
|
45562
45680
|
case "table_row":
|
|
45563
|
-
return `| ${data.cells.map((x) => x.map((y) => formatPlainText(y))
|
|
45681
|
+
return `| ${join_default(data.cells.map((x) => join_default(x.map((y) => formatPlainText(y)), "")), " | ")} |
|
|
45564
45682
|
`;
|
|
45565
45683
|
case "to_do":
|
|
45566
|
-
childData = map_default(block3.children, (child) => convertNotionToMd(child, level + 1))
|
|
45567
|
-
return `- [${data.checked ? "X" : " "}] ${plainText
|
|
45684
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level + 1, linkChildPages)), repeat_default("\t", level));
|
|
45685
|
+
return `- [${data.checked ? "X" : " "}] ${join_default(plainText, "")}
|
|
45568
45686
|
` + (childData ? `${repeat_default("\t", level)}${childData}` : "");
|
|
45569
45687
|
default:
|
|
45570
|
-
childData = map_default(block3.children, (child) => convertNotionToMd(child))
|
|
45571
|
-
return plainText
|
|
45688
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level, linkChildPages)), "");
|
|
45689
|
+
return join_default(plainText, "") + n + childData;
|
|
45572
45690
|
}
|
|
45573
45691
|
};
|
|
45574
45692
|
var resolveChildren = function(block3, blocks) {
|
|
@@ -45618,13 +45736,13 @@ var insertNewLinesBetweenLists = function(blocks) {
|
|
|
45618
45736
|
return block3;
|
|
45619
45737
|
}));
|
|
45620
45738
|
};
|
|
45621
|
-
var convertNotionToMarkdown = function(blocks) {
|
|
45739
|
+
var convertNotionToMarkdown = function(blocks, linkChildPages = false) {
|
|
45622
45740
|
const arrayBlocks = insertNewLinesBetweenLists(castArray_default(blocks));
|
|
45623
45741
|
const parentBlocks = reject_default(arrayBlocks, (block3) => block3.parent?.type === "block_id");
|
|
45624
45742
|
const blocksWithChildren = numberOrderedLists(parentBlocks.map((block3) => {
|
|
45625
45743
|
return resolveChildren(block3, arrayBlocks);
|
|
45626
45744
|
}));
|
|
45627
|
-
return blocksWithChildren.map((block3) => convertNotionToMd(block3))
|
|
45745
|
+
return join_default(blocksWithChildren.map((block3) => convertNotionToMd(block3, 1, linkChildPages)), "");
|
|
45628
45746
|
};
|
|
45629
45747
|
var convertNotionToMarkdown_default = convertNotionToMarkdown;
|
|
45630
45748
|
|
|
@@ -55235,17 +55353,17 @@ function stringify(obj, replacer, spacer, options3) {
|
|
|
55235
55353
|
return res;
|
|
55236
55354
|
}
|
|
55237
55355
|
}
|
|
55238
|
-
function setReplace(
|
|
55356
|
+
function setReplace(replace, val, k, parent2) {
|
|
55239
55357
|
var propertyDescriptor = Object.getOwnPropertyDescriptor(parent2, k);
|
|
55240
55358
|
if (propertyDescriptor.get !== undefined) {
|
|
55241
55359
|
if (propertyDescriptor.configurable) {
|
|
55242
|
-
Object.defineProperty(parent2, k, { value:
|
|
55360
|
+
Object.defineProperty(parent2, k, { value: replace });
|
|
55243
55361
|
arr.push([parent2, k, val, propertyDescriptor]);
|
|
55244
55362
|
} else {
|
|
55245
|
-
replacerStack.push([val, k,
|
|
55363
|
+
replacerStack.push([val, k, replace]);
|
|
55246
55364
|
}
|
|
55247
55365
|
} else {
|
|
55248
|
-
parent2[k] =
|
|
55366
|
+
parent2[k] = replace;
|
|
55249
55367
|
arr.push([parent2, k, val]);
|
|
55250
55368
|
}
|
|
55251
55369
|
}
|
|
@@ -56917,7 +57035,7 @@ Message: ${result.detail.join(`
|
|
|
56917
57035
|
const result = await response.json();
|
|
56918
57036
|
return result["examples"];
|
|
56919
57037
|
}
|
|
56920
|
-
async createExample(inputs, outputs, { datasetId, datasetName, createdAt, exampleId, metadata, split, sourceRunId }) {
|
|
57038
|
+
async createExample(inputs, outputs, { datasetId, datasetName, createdAt, exampleId, metadata, split: split2, sourceRunId }) {
|
|
56921
57039
|
let datasetId_ = datasetId;
|
|
56922
57040
|
if (datasetId_ === undefined && datasetName === undefined) {
|
|
56923
57041
|
throw new Error("Must provide either datasetName or datasetId");
|
|
@@ -56935,7 +57053,7 @@ Message: ${result.detail.join(`
|
|
|
56935
57053
|
created_at: createdAt_?.toISOString(),
|
|
56936
57054
|
id: exampleId,
|
|
56937
57055
|
metadata,
|
|
56938
|
-
split,
|
|
57056
|
+
split: split2,
|
|
56939
57057
|
source_run_id: sourceRunId
|
|
56940
57058
|
};
|
|
56941
57059
|
const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/examples`, {
|
|
@@ -57037,8 +57155,8 @@ Message: ${result.detail.join(`
|
|
|
57037
57155
|
}
|
|
57038
57156
|
}
|
|
57039
57157
|
if (splits !== undefined) {
|
|
57040
|
-
for (const
|
|
57041
|
-
params.append("splits",
|
|
57158
|
+
for (const split2 of splits) {
|
|
57159
|
+
params.append("splits", split2);
|
|
57042
57160
|
}
|
|
57043
57161
|
}
|
|
57044
57162
|
if (metadata !== undefined) {
|
|
@@ -67075,17 +67193,45 @@ var removeEmptyItems_default = removeEmptyItems;
|
|
|
67075
67193
|
|
|
67076
67194
|
// src/functions/sign.ts
|
|
67077
67195
|
var sign = async (text, algorithm = "SHA-256", secret, outputFormat = "hex") => {
|
|
67078
|
-
const
|
|
67196
|
+
const upperAlg = String(algorithm ?? "").trim().toUpperCase();
|
|
67079
67197
|
const encoder = new TextEncoder;
|
|
67080
67198
|
const data = encoder.encode(text);
|
|
67081
|
-
|
|
67199
|
+
let signatureBuffer;
|
|
67200
|
+
if (upperAlg === "RS256") {
|
|
67201
|
+
const pemKey = secret?.includes("\\n") ? secret.replace(/\\n/g, `
|
|
67202
|
+
`) : secret;
|
|
67203
|
+
if (!pemKey || !/-----BEGIN PRIVATE KEY-----/.test(pemKey)) {
|
|
67204
|
+
throw new Error("RS256 requires a PKCS#8 PEM private key (BEGIN PRIVATE KEY)");
|
|
67205
|
+
}
|
|
67206
|
+
const keyDataBase64 = pemKey.replace(/-----BEGIN PRIVATE KEY-----/, "").replace(/-----END PRIVATE KEY-----/, "").replace(/\s/g, "");
|
|
67207
|
+
const binaryKey = Uint8Array.from(atob(keyDataBase64), (c) => c.charCodeAt(0));
|
|
67208
|
+
const rsaAlgorithm = {
|
|
67209
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
67210
|
+
hash: { name: "SHA-256" }
|
|
67211
|
+
};
|
|
67212
|
+
let key;
|
|
67213
|
+
try {
|
|
67214
|
+
key = await crypto.subtle.importKey("pkcs8", binaryKey, rsaAlgorithm, false, ["sign"]);
|
|
67215
|
+
} catch (e) {
|
|
67216
|
+
throw new Error(`RS256 key import failed. Ensure an unencrypted PKCS#8 PEM (BEGIN PRIVATE KEY). Underlying: ${e?.message || e}`);
|
|
67217
|
+
}
|
|
67218
|
+
try {
|
|
67219
|
+
signatureBuffer = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", key, data);
|
|
67220
|
+
} catch (e) {
|
|
67221
|
+
throw new Error(`RS256 signing failed. Ensure the key matches RSASSA-PKCS1-v1_5 and data is correctly encoded. Underlying: ${e?.message || e}`);
|
|
67222
|
+
}
|
|
67223
|
+
} else {
|
|
67224
|
+
const hmacHash = upperAlg || "SHA-256";
|
|
67225
|
+
const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: { name: hmacHash } }, false, ["sign"]);
|
|
67226
|
+
signatureBuffer = await crypto.subtle.sign("HMAC", key, data);
|
|
67227
|
+
}
|
|
67082
67228
|
if (outputFormat === "hex") {
|
|
67083
|
-
const
|
|
67084
|
-
return
|
|
67229
|
+
const bytes = Array.from(new Uint8Array(signatureBuffer));
|
|
67230
|
+
return bytes.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
67085
67231
|
} else if (outputFormat === "base64") {
|
|
67086
|
-
return arrayBufferToBase64(
|
|
67232
|
+
return arrayBufferToBase64(signatureBuffer);
|
|
67087
67233
|
} else if (outputFormat === "base64-urlSafe") {
|
|
67088
|
-
return arrayBufferToBase64(
|
|
67234
|
+
return arrayBufferToBase64(signatureBuffer, true);
|
|
67089
67235
|
}
|
|
67090
67236
|
};
|
|
67091
67237
|
var sign_default = sign;
|
|
@@ -67172,1248 +67318,93 @@ function zipSqlResponse(columns, data, key) {
|
|
|
67172
67318
|
}
|
|
67173
67319
|
var zipSqlResponse_default = zipSqlResponse;
|
|
67174
67320
|
|
|
67175
|
-
//
|
|
67176
|
-
|
|
67177
|
-
|
|
67178
|
-
|
|
67179
|
-
|
|
67180
|
-
|
|
67181
|
-
|
|
67182
|
-
|
|
67183
|
-
for (const buffer of buffers) {
|
|
67184
|
-
buf.set(buffer, i3);
|
|
67185
|
-
i3 += buffer.length;
|
|
67186
|
-
}
|
|
67187
|
-
return buf;
|
|
67188
|
-
}
|
|
67189
|
-
|
|
67190
|
-
// node_modules/jose/dist/webapi/lib/base64.js
|
|
67191
|
-
function encodeBase64(input) {
|
|
67192
|
-
if (Uint8Array.prototype.toBase64) {
|
|
67193
|
-
return input.toBase64();
|
|
67194
|
-
}
|
|
67195
|
-
const CHUNK_SIZE = 32768;
|
|
67196
|
-
const arr2 = [];
|
|
67197
|
-
for (let i3 = 0;i3 < input.length; i3 += CHUNK_SIZE) {
|
|
67198
|
-
arr2.push(String.fromCharCode.apply(null, input.subarray(i3, i3 + CHUNK_SIZE)));
|
|
67199
|
-
}
|
|
67200
|
-
return btoa(arr2.join(""));
|
|
67201
|
-
}
|
|
67202
|
-
function decodeBase64(encoded) {
|
|
67203
|
-
if (Uint8Array.fromBase64) {
|
|
67204
|
-
return Uint8Array.fromBase64(encoded);
|
|
67205
|
-
}
|
|
67206
|
-
const binary = atob(encoded);
|
|
67207
|
-
const bytes = new Uint8Array(binary.length);
|
|
67208
|
-
for (let i3 = 0;i3 < binary.length; i3++) {
|
|
67209
|
-
bytes[i3] = binary.charCodeAt(i3);
|
|
67210
|
-
}
|
|
67211
|
-
return bytes;
|
|
67212
|
-
}
|
|
67213
|
-
|
|
67214
|
-
// node_modules/jose/dist/webapi/util/base64url.js
|
|
67215
|
-
function decode(input) {
|
|
67216
|
-
if (Uint8Array.fromBase64) {
|
|
67217
|
-
return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), {
|
|
67218
|
-
alphabet: "base64url"
|
|
67219
|
-
});
|
|
67220
|
-
}
|
|
67221
|
-
let encoded = input;
|
|
67222
|
-
if (encoded instanceof Uint8Array) {
|
|
67223
|
-
encoded = decoder.decode(encoded);
|
|
67224
|
-
}
|
|
67225
|
-
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
67226
|
-
try {
|
|
67227
|
-
return decodeBase64(encoded);
|
|
67228
|
-
} catch {
|
|
67229
|
-
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
67230
|
-
}
|
|
67231
|
-
}
|
|
67232
|
-
function encode(input) {
|
|
67233
|
-
let unencoded = input;
|
|
67234
|
-
if (typeof unencoded === "string") {
|
|
67235
|
-
unencoded = encoder.encode(unencoded);
|
|
67236
|
-
}
|
|
67237
|
-
if (Uint8Array.prototype.toBase64) {
|
|
67238
|
-
return unencoded.toBase64({ alphabet: "base64url", omitPadding: true });
|
|
67239
|
-
}
|
|
67240
|
-
return encodeBase64(unencoded).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
67241
|
-
}
|
|
67242
|
-
|
|
67243
|
-
// node_modules/jose/dist/webapi/util/errors.js
|
|
67244
|
-
class JOSEError extends Error {
|
|
67245
|
-
static code = "ERR_JOSE_GENERIC";
|
|
67246
|
-
code = "ERR_JOSE_GENERIC";
|
|
67247
|
-
constructor(message, options3) {
|
|
67248
|
-
super(message, options3);
|
|
67249
|
-
this.name = this.constructor.name;
|
|
67250
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
67251
|
-
}
|
|
67252
|
-
}
|
|
67253
|
-
class JOSENotSupported extends JOSEError {
|
|
67254
|
-
static code = "ERR_JOSE_NOT_SUPPORTED";
|
|
67255
|
-
code = "ERR_JOSE_NOT_SUPPORTED";
|
|
67256
|
-
}
|
|
67257
|
-
class JWSInvalid extends JOSEError {
|
|
67258
|
-
static code = "ERR_JWS_INVALID";
|
|
67259
|
-
code = "ERR_JWS_INVALID";
|
|
67260
|
-
}
|
|
67261
|
-
|
|
67262
|
-
class JWTInvalid extends JOSEError {
|
|
67263
|
-
static code = "ERR_JWT_INVALID";
|
|
67264
|
-
code = "ERR_JWT_INVALID";
|
|
67265
|
-
}
|
|
67266
|
-
|
|
67267
|
-
// node_modules/jose/dist/webapi/lib/crypto_key.js
|
|
67268
|
-
function unusable(name, prop = "algorithm.name") {
|
|
67269
|
-
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
67270
|
-
}
|
|
67271
|
-
function isAlgorithm(algorithm, name) {
|
|
67272
|
-
return algorithm.name === name;
|
|
67273
|
-
}
|
|
67274
|
-
function getHashLength(hash) {
|
|
67275
|
-
return parseInt(hash.name.slice(4), 10);
|
|
67276
|
-
}
|
|
67277
|
-
function getNamedCurve(alg) {
|
|
67278
|
-
switch (alg) {
|
|
67279
|
-
case "ES256":
|
|
67280
|
-
return "P-256";
|
|
67281
|
-
case "ES384":
|
|
67282
|
-
return "P-384";
|
|
67283
|
-
case "ES512":
|
|
67284
|
-
return "P-521";
|
|
67285
|
-
default:
|
|
67286
|
-
throw new Error("unreachable");
|
|
67287
|
-
}
|
|
67288
|
-
}
|
|
67289
|
-
function checkUsage(key, usage) {
|
|
67290
|
-
if (usage && !key.usages.includes(usage)) {
|
|
67291
|
-
throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
67292
|
-
}
|
|
67293
|
-
}
|
|
67294
|
-
function checkSigCryptoKey(key, alg, usage) {
|
|
67295
|
-
switch (alg) {
|
|
67296
|
-
case "HS256":
|
|
67297
|
-
case "HS384":
|
|
67298
|
-
case "HS512": {
|
|
67299
|
-
if (!isAlgorithm(key.algorithm, "HMAC"))
|
|
67300
|
-
throw unusable("HMAC");
|
|
67301
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
67302
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
67303
|
-
if (actual !== expected)
|
|
67304
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
67305
|
-
break;
|
|
67306
|
-
}
|
|
67307
|
-
case "RS256":
|
|
67308
|
-
case "RS384":
|
|
67309
|
-
case "RS512": {
|
|
67310
|
-
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
67311
|
-
throw unusable("RSASSA-PKCS1-v1_5");
|
|
67312
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
67313
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
67314
|
-
if (actual !== expected)
|
|
67315
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
67316
|
-
break;
|
|
67317
|
-
}
|
|
67318
|
-
case "PS256":
|
|
67319
|
-
case "PS384":
|
|
67320
|
-
case "PS512": {
|
|
67321
|
-
if (!isAlgorithm(key.algorithm, "RSA-PSS"))
|
|
67322
|
-
throw unusable("RSA-PSS");
|
|
67323
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
67324
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
67325
|
-
if (actual !== expected)
|
|
67326
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
67327
|
-
break;
|
|
67328
|
-
}
|
|
67329
|
-
case "Ed25519":
|
|
67330
|
-
case "EdDSA": {
|
|
67331
|
-
if (!isAlgorithm(key.algorithm, "Ed25519"))
|
|
67332
|
-
throw unusable("Ed25519");
|
|
67333
|
-
break;
|
|
67334
|
-
}
|
|
67335
|
-
case "ML-DSA-44":
|
|
67336
|
-
case "ML-DSA-65":
|
|
67337
|
-
case "ML-DSA-87": {
|
|
67338
|
-
if (!isAlgorithm(key.algorithm, alg))
|
|
67339
|
-
throw unusable(alg);
|
|
67340
|
-
break;
|
|
67341
|
-
}
|
|
67342
|
-
case "ES256":
|
|
67343
|
-
case "ES384":
|
|
67344
|
-
case "ES512": {
|
|
67345
|
-
if (!isAlgorithm(key.algorithm, "ECDSA"))
|
|
67346
|
-
throw unusable("ECDSA");
|
|
67347
|
-
const expected = getNamedCurve(alg);
|
|
67348
|
-
const actual = key.algorithm.namedCurve;
|
|
67349
|
-
if (actual !== expected)
|
|
67350
|
-
throw unusable(expected, "algorithm.namedCurve");
|
|
67351
|
-
break;
|
|
67352
|
-
}
|
|
67353
|
-
default:
|
|
67354
|
-
throw new TypeError("CryptoKey does not support this operation");
|
|
67355
|
-
}
|
|
67356
|
-
checkUsage(key, usage);
|
|
67357
|
-
}
|
|
67358
|
-
|
|
67359
|
-
// node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
67360
|
-
function message(msg, actual, ...types3) {
|
|
67361
|
-
types3 = types3.filter(Boolean);
|
|
67362
|
-
if (types3.length > 2) {
|
|
67363
|
-
const last2 = types3.pop();
|
|
67364
|
-
msg += `one of type ${types3.join(", ")}, or ${last2}.`;
|
|
67365
|
-
} else if (types3.length === 2) {
|
|
67366
|
-
msg += `one of type ${types3[0]} or ${types3[1]}.`;
|
|
67367
|
-
} else {
|
|
67368
|
-
msg += `of type ${types3[0]}.`;
|
|
67369
|
-
}
|
|
67370
|
-
if (actual == null) {
|
|
67371
|
-
msg += ` Received ${actual}`;
|
|
67372
|
-
} else if (typeof actual === "function" && actual.name) {
|
|
67373
|
-
msg += ` Received function ${actual.name}`;
|
|
67374
|
-
} else if (typeof actual === "object" && actual != null) {
|
|
67375
|
-
if (actual.constructor?.name) {
|
|
67376
|
-
msg += ` Received an instance of ${actual.constructor.name}`;
|
|
67377
|
-
}
|
|
67378
|
-
}
|
|
67379
|
-
return msg;
|
|
67380
|
-
}
|
|
67381
|
-
var invalid_key_input_default = (actual, ...types3) => {
|
|
67382
|
-
return message("Key must be ", actual, ...types3);
|
|
67383
|
-
};
|
|
67384
|
-
function withAlg(alg, actual, ...types3) {
|
|
67385
|
-
return message(`Key for the ${alg} algorithm must be `, actual, ...types3);
|
|
67386
|
-
}
|
|
67387
|
-
|
|
67388
|
-
// node_modules/jose/dist/webapi/lib/is_key_like.js
|
|
67389
|
-
function isCryptoKey(key) {
|
|
67390
|
-
return key?.[Symbol.toStringTag] === "CryptoKey";
|
|
67391
|
-
}
|
|
67392
|
-
function isKeyObject(key) {
|
|
67393
|
-
return key?.[Symbol.toStringTag] === "KeyObject";
|
|
67394
|
-
}
|
|
67395
|
-
var is_key_like_default = (key) => {
|
|
67396
|
-
return isCryptoKey(key) || isKeyObject(key);
|
|
67397
|
-
};
|
|
67398
|
-
|
|
67399
|
-
// node_modules/jose/dist/webapi/lib/is_disjoint.js
|
|
67400
|
-
var is_disjoint_default = (...headers) => {
|
|
67401
|
-
const sources = headers.filter(Boolean);
|
|
67402
|
-
if (sources.length === 0 || sources.length === 1) {
|
|
67403
|
-
return true;
|
|
67404
|
-
}
|
|
67405
|
-
let acc;
|
|
67406
|
-
for (const header of sources) {
|
|
67407
|
-
const parameters = Object.keys(header);
|
|
67408
|
-
if (!acc || acc.size === 0) {
|
|
67409
|
-
acc = new Set(parameters);
|
|
67410
|
-
continue;
|
|
67411
|
-
}
|
|
67412
|
-
for (const parameter of parameters) {
|
|
67413
|
-
if (acc.has(parameter)) {
|
|
67414
|
-
return false;
|
|
67415
|
-
}
|
|
67416
|
-
acc.add(parameter);
|
|
67417
|
-
}
|
|
67418
|
-
}
|
|
67419
|
-
return true;
|
|
67420
|
-
};
|
|
67421
|
-
|
|
67422
|
-
// node_modules/jose/dist/webapi/lib/is_object.js
|
|
67423
|
-
function isObjectLike2(value) {
|
|
67424
|
-
return typeof value === "object" && value !== null;
|
|
67425
|
-
}
|
|
67426
|
-
var is_object_default = (input) => {
|
|
67427
|
-
if (!isObjectLike2(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
67428
|
-
return false;
|
|
67429
|
-
}
|
|
67430
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
67431
|
-
return true;
|
|
67432
|
-
}
|
|
67433
|
-
let proto = input;
|
|
67434
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
67435
|
-
proto = Object.getPrototypeOf(proto);
|
|
67436
|
-
}
|
|
67437
|
-
return Object.getPrototypeOf(input) === proto;
|
|
67438
|
-
};
|
|
67439
|
-
|
|
67440
|
-
// node_modules/jose/dist/webapi/lib/check_key_length.js
|
|
67441
|
-
var check_key_length_default = (alg, key) => {
|
|
67442
|
-
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
67443
|
-
const { modulusLength } = key.algorithm;
|
|
67444
|
-
if (typeof modulusLength !== "number" || modulusLength < 2048) {
|
|
67445
|
-
throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
67446
|
-
}
|
|
67447
|
-
}
|
|
67448
|
-
};
|
|
67449
|
-
|
|
67450
|
-
// node_modules/jose/dist/webapi/lib/asn1.js
|
|
67451
|
-
var bytesEqual = (a, b) => {
|
|
67452
|
-
if (a.byteLength !== b.length)
|
|
67453
|
-
return false;
|
|
67454
|
-
for (let i3 = 0;i3 < a.byteLength; i3++) {
|
|
67455
|
-
if (a[i3] !== b[i3])
|
|
67456
|
-
return false;
|
|
67457
|
-
}
|
|
67458
|
-
return true;
|
|
67459
|
-
};
|
|
67460
|
-
var createASN1State = (data) => ({ data, pos: 0 });
|
|
67461
|
-
var parseLength = (state) => {
|
|
67462
|
-
const first = state.data[state.pos++];
|
|
67463
|
-
if (first & 128) {
|
|
67464
|
-
const lengthOfLen = first & 127;
|
|
67465
|
-
let length = 0;
|
|
67466
|
-
for (let i3 = 0;i3 < lengthOfLen; i3++) {
|
|
67467
|
-
length = length << 8 | state.data[state.pos++];
|
|
67468
|
-
}
|
|
67469
|
-
return length;
|
|
67470
|
-
}
|
|
67471
|
-
return first;
|
|
67472
|
-
};
|
|
67473
|
-
var expectTag = (state, expectedTag, errorMessage) => {
|
|
67474
|
-
if (state.data[state.pos++] !== expectedTag) {
|
|
67475
|
-
throw new Error(errorMessage);
|
|
67476
|
-
}
|
|
67477
|
-
};
|
|
67478
|
-
var getSubarray = (state, length) => {
|
|
67479
|
-
const result = state.data.subarray(state.pos, state.pos + length);
|
|
67480
|
-
state.pos += length;
|
|
67481
|
-
return result;
|
|
67482
|
-
};
|
|
67483
|
-
var parseAlgorithmOID = (state) => {
|
|
67484
|
-
expectTag(state, 6, "Expected algorithm OID");
|
|
67485
|
-
const oidLen = parseLength(state);
|
|
67486
|
-
return getSubarray(state, oidLen);
|
|
67487
|
-
};
|
|
67488
|
-
function parsePKCS8Header(state) {
|
|
67489
|
-
expectTag(state, 48, "Invalid PKCS#8 structure");
|
|
67490
|
-
parseLength(state);
|
|
67491
|
-
expectTag(state, 2, "Expected version field");
|
|
67492
|
-
const verLen = parseLength(state);
|
|
67493
|
-
state.pos += verLen;
|
|
67494
|
-
expectTag(state, 48, "Expected algorithm identifier");
|
|
67495
|
-
const algIdLen = parseLength(state);
|
|
67496
|
-
const algIdStart = state.pos;
|
|
67497
|
-
return { algIdStart, algIdLength: algIdLen };
|
|
67498
|
-
}
|
|
67499
|
-
var parseECAlgorithmIdentifier = (state) => {
|
|
67500
|
-
const algOid = parseAlgorithmOID(state);
|
|
67501
|
-
if (bytesEqual(algOid, [43, 101, 110])) {
|
|
67502
|
-
return "X25519";
|
|
67503
|
-
}
|
|
67504
|
-
if (!bytesEqual(algOid, [42, 134, 72, 206, 61, 2, 1])) {
|
|
67505
|
-
throw new Error("Unsupported key algorithm");
|
|
67506
|
-
}
|
|
67507
|
-
expectTag(state, 6, "Expected curve OID");
|
|
67508
|
-
const curveOidLen = parseLength(state);
|
|
67509
|
-
const curveOid = getSubarray(state, curveOidLen);
|
|
67510
|
-
for (const { name, oid } of [
|
|
67511
|
-
{ name: "P-256", oid: [42, 134, 72, 206, 61, 3, 1, 7] },
|
|
67512
|
-
{ name: "P-384", oid: [43, 129, 4, 0, 34] },
|
|
67513
|
-
{ name: "P-521", oid: [43, 129, 4, 0, 35] }
|
|
67514
|
-
]) {
|
|
67515
|
-
if (bytesEqual(curveOid, oid)) {
|
|
67516
|
-
return name;
|
|
67517
|
-
}
|
|
67518
|
-
}
|
|
67519
|
-
throw new Error("Unsupported named curve");
|
|
67520
|
-
};
|
|
67521
|
-
var genericImport = async (keyFormat, keyData, alg, options3) => {
|
|
67522
|
-
let algorithm;
|
|
67523
|
-
let keyUsages;
|
|
67524
|
-
const isPublic = keyFormat === "spki";
|
|
67525
|
-
const getSigUsages = () => isPublic ? ["verify"] : ["sign"];
|
|
67526
|
-
const getEncUsages = () => isPublic ? ["encrypt", "wrapKey"] : ["decrypt", "unwrapKey"];
|
|
67527
|
-
switch (alg) {
|
|
67528
|
-
case "PS256":
|
|
67529
|
-
case "PS384":
|
|
67530
|
-
case "PS512":
|
|
67531
|
-
algorithm = { name: "RSA-PSS", hash: `SHA-${alg.slice(-3)}` };
|
|
67532
|
-
keyUsages = getSigUsages();
|
|
67533
|
-
break;
|
|
67534
|
-
case "RS256":
|
|
67535
|
-
case "RS384":
|
|
67536
|
-
case "RS512":
|
|
67537
|
-
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${alg.slice(-3)}` };
|
|
67538
|
-
keyUsages = getSigUsages();
|
|
67539
|
-
break;
|
|
67540
|
-
case "RSA-OAEP":
|
|
67541
|
-
case "RSA-OAEP-256":
|
|
67542
|
-
case "RSA-OAEP-384":
|
|
67543
|
-
case "RSA-OAEP-512":
|
|
67544
|
-
algorithm = {
|
|
67545
|
-
name: "RSA-OAEP",
|
|
67546
|
-
hash: `SHA-${parseInt(alg.slice(-3), 10) || 1}`
|
|
67547
|
-
};
|
|
67548
|
-
keyUsages = getEncUsages();
|
|
67549
|
-
break;
|
|
67550
|
-
case "ES256":
|
|
67551
|
-
case "ES384":
|
|
67552
|
-
case "ES512": {
|
|
67553
|
-
const curveMap = { ES256: "P-256", ES384: "P-384", ES512: "P-521" };
|
|
67554
|
-
algorithm = { name: "ECDSA", namedCurve: curveMap[alg] };
|
|
67555
|
-
keyUsages = getSigUsages();
|
|
67556
|
-
break;
|
|
67557
|
-
}
|
|
67558
|
-
case "ECDH-ES":
|
|
67559
|
-
case "ECDH-ES+A128KW":
|
|
67560
|
-
case "ECDH-ES+A192KW":
|
|
67561
|
-
case "ECDH-ES+A256KW": {
|
|
67321
|
+
// src/functions/convertMdToPdf.ts
|
|
67322
|
+
function getFilenameFromHeaders(resp, fallback) {
|
|
67323
|
+
const cd = resp.headers.get("content-disposition") || "";
|
|
67324
|
+
const matchStar = cd.match(/filename\*=([^;]+)/i);
|
|
67325
|
+
if (matchStar) {
|
|
67326
|
+
const value = trim_default(matchStar[1]);
|
|
67327
|
+
const parts = split_default(value, "''");
|
|
67328
|
+
if (parts.length === 2) {
|
|
67562
67329
|
try {
|
|
67563
|
-
|
|
67564
|
-
|
|
67565
|
-
|
|
67566
|
-
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
67567
|
-
}
|
|
67568
|
-
keyUsages = isPublic ? [] : ["deriveBits"];
|
|
67569
|
-
break;
|
|
67570
|
-
}
|
|
67571
|
-
case "Ed25519":
|
|
67572
|
-
case "EdDSA":
|
|
67573
|
-
algorithm = { name: "Ed25519" };
|
|
67574
|
-
keyUsages = getSigUsages();
|
|
67575
|
-
break;
|
|
67576
|
-
case "ML-DSA-44":
|
|
67577
|
-
case "ML-DSA-65":
|
|
67578
|
-
case "ML-DSA-87":
|
|
67579
|
-
algorithm = { name: alg };
|
|
67580
|
-
keyUsages = getSigUsages();
|
|
67581
|
-
break;
|
|
67582
|
-
default:
|
|
67583
|
-
throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
67584
|
-
}
|
|
67585
|
-
return crypto.subtle.importKey(keyFormat, keyData, algorithm, options3?.extractable ?? (isPublic ? true : false), keyUsages);
|
|
67586
|
-
};
|
|
67587
|
-
var processPEMData = (pem, pattern) => {
|
|
67588
|
-
return decodeBase64(pem.replace(pattern, ""));
|
|
67589
|
-
};
|
|
67590
|
-
var fromPKCS8 = (pem, alg, options3) => {
|
|
67591
|
-
const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
|
|
67592
|
-
let opts = options3;
|
|
67593
|
-
if (alg?.startsWith?.("ECDH-ES")) {
|
|
67594
|
-
opts ||= {};
|
|
67595
|
-
opts.getNamedCurve = (keyData2) => {
|
|
67596
|
-
const state = createASN1State(keyData2);
|
|
67597
|
-
parsePKCS8Header(state);
|
|
67598
|
-
return parseECAlgorithmIdentifier(state);
|
|
67599
|
-
};
|
|
67600
|
-
}
|
|
67601
|
-
return genericImport("pkcs8", keyData, alg, opts);
|
|
67602
|
-
};
|
|
67603
|
-
|
|
67604
|
-
// node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
67605
|
-
function subtleMapping(jwk) {
|
|
67606
|
-
let algorithm;
|
|
67607
|
-
let keyUsages;
|
|
67608
|
-
switch (jwk.kty) {
|
|
67609
|
-
case "AKP": {
|
|
67610
|
-
switch (jwk.alg) {
|
|
67611
|
-
case "ML-DSA-44":
|
|
67612
|
-
case "ML-DSA-65":
|
|
67613
|
-
case "ML-DSA-87":
|
|
67614
|
-
algorithm = { name: jwk.alg };
|
|
67615
|
-
keyUsages = jwk.priv ? ["sign"] : ["verify"];
|
|
67616
|
-
break;
|
|
67617
|
-
default:
|
|
67618
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67619
|
-
}
|
|
67620
|
-
break;
|
|
67621
|
-
}
|
|
67622
|
-
case "RSA": {
|
|
67623
|
-
switch (jwk.alg) {
|
|
67624
|
-
case "PS256":
|
|
67625
|
-
case "PS384":
|
|
67626
|
-
case "PS512":
|
|
67627
|
-
algorithm = { name: "RSA-PSS", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
67628
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67629
|
-
break;
|
|
67630
|
-
case "RS256":
|
|
67631
|
-
case "RS384":
|
|
67632
|
-
case "RS512":
|
|
67633
|
-
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
67634
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67635
|
-
break;
|
|
67636
|
-
case "RSA-OAEP":
|
|
67637
|
-
case "RSA-OAEP-256":
|
|
67638
|
-
case "RSA-OAEP-384":
|
|
67639
|
-
case "RSA-OAEP-512":
|
|
67640
|
-
algorithm = {
|
|
67641
|
-
name: "RSA-OAEP",
|
|
67642
|
-
hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
|
|
67643
|
-
};
|
|
67644
|
-
keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
67645
|
-
break;
|
|
67646
|
-
default:
|
|
67647
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67648
|
-
}
|
|
67649
|
-
break;
|
|
67650
|
-
}
|
|
67651
|
-
case "EC": {
|
|
67652
|
-
switch (jwk.alg) {
|
|
67653
|
-
case "ES256":
|
|
67654
|
-
algorithm = { name: "ECDSA", namedCurve: "P-256" };
|
|
67655
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67656
|
-
break;
|
|
67657
|
-
case "ES384":
|
|
67658
|
-
algorithm = { name: "ECDSA", namedCurve: "P-384" };
|
|
67659
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67660
|
-
break;
|
|
67661
|
-
case "ES512":
|
|
67662
|
-
algorithm = { name: "ECDSA", namedCurve: "P-521" };
|
|
67663
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67664
|
-
break;
|
|
67665
|
-
case "ECDH-ES":
|
|
67666
|
-
case "ECDH-ES+A128KW":
|
|
67667
|
-
case "ECDH-ES+A192KW":
|
|
67668
|
-
case "ECDH-ES+A256KW":
|
|
67669
|
-
algorithm = { name: "ECDH", namedCurve: jwk.crv };
|
|
67670
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
67671
|
-
break;
|
|
67672
|
-
default:
|
|
67673
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67330
|
+
return decodeURIComponent(parts[1]);
|
|
67331
|
+
} catch {
|
|
67332
|
+
return parts[1];
|
|
67674
67333
|
}
|
|
67675
|
-
break;
|
|
67676
67334
|
}
|
|
67677
|
-
|
|
67678
|
-
switch (jwk.alg) {
|
|
67679
|
-
case "Ed25519":
|
|
67680
|
-
case "EdDSA":
|
|
67681
|
-
algorithm = { name: "Ed25519" };
|
|
67682
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67683
|
-
break;
|
|
67684
|
-
case "ECDH-ES":
|
|
67685
|
-
case "ECDH-ES+A128KW":
|
|
67686
|
-
case "ECDH-ES+A192KW":
|
|
67687
|
-
case "ECDH-ES+A256KW":
|
|
67688
|
-
algorithm = { name: jwk.crv };
|
|
67689
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
67690
|
-
break;
|
|
67691
|
-
default:
|
|
67692
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67693
|
-
}
|
|
67694
|
-
break;
|
|
67695
|
-
}
|
|
67696
|
-
default:
|
|
67697
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
67335
|
+
return trim_default(value, `'"`);
|
|
67698
67336
|
}
|
|
67699
|
-
|
|
67337
|
+
const match2 = cd.match(/filename="?([^";]+)"?/i);
|
|
67338
|
+
if (match2)
|
|
67339
|
+
return match2[1];
|
|
67340
|
+
return fallback || "document.pdf";
|
|
67700
67341
|
}
|
|
67701
|
-
|
|
67702
|
-
|
|
67703
|
-
|
|
67704
|
-
|
|
67705
|
-
|
|
67706
|
-
const keyData = { ...jwk };
|
|
67707
|
-
if (keyData.kty !== "AKP") {
|
|
67708
|
-
delete keyData.alg;
|
|
67709
|
-
}
|
|
67710
|
-
delete keyData.use;
|
|
67711
|
-
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
67712
|
-
};
|
|
67713
|
-
|
|
67714
|
-
// node_modules/jose/dist/webapi/key/import.js
|
|
67715
|
-
async function importPKCS8(pkcs8, alg, options3) {
|
|
67716
|
-
if (typeof pkcs8 !== "string" || pkcs8.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) {
|
|
67717
|
-
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
67718
|
-
}
|
|
67719
|
-
return fromPKCS8(pkcs8, alg, options3);
|
|
67720
|
-
}
|
|
67721
|
-
|
|
67722
|
-
// node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
67723
|
-
var validate_crit_default = (Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) => {
|
|
67724
|
-
if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {
|
|
67725
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
67726
|
-
}
|
|
67727
|
-
if (!protectedHeader || protectedHeader.crit === undefined) {
|
|
67728
|
-
return new Set;
|
|
67729
|
-
}
|
|
67730
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
|
|
67731
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
67732
|
-
}
|
|
67733
|
-
let recognized;
|
|
67734
|
-
if (recognizedOption !== undefined) {
|
|
67735
|
-
recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
|
|
67736
|
-
} else {
|
|
67737
|
-
recognized = recognizedDefault;
|
|
67738
|
-
}
|
|
67739
|
-
for (const parameter of protectedHeader.crit) {
|
|
67740
|
-
if (!recognized.has(parameter)) {
|
|
67741
|
-
throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
|
|
67742
|
-
}
|
|
67743
|
-
if (joseHeader[parameter] === undefined) {
|
|
67744
|
-
throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
67745
|
-
}
|
|
67746
|
-
if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {
|
|
67747
|
-
throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
67748
|
-
}
|
|
67749
|
-
}
|
|
67750
|
-
return new Set(protectedHeader.crit);
|
|
67751
|
-
};
|
|
67752
|
-
|
|
67753
|
-
// node_modules/jose/dist/webapi/lib/is_jwk.js
|
|
67754
|
-
function isJWK(key) {
|
|
67755
|
-
return is_object_default(key) && typeof key.kty === "string";
|
|
67756
|
-
}
|
|
67757
|
-
function isPrivateJWK(key) {
|
|
67758
|
-
return key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
67759
|
-
}
|
|
67760
|
-
function isPublicJWK(key) {
|
|
67761
|
-
return key.kty !== "oct" && typeof key.d === "undefined" && typeof key.priv === "undefined";
|
|
67762
|
-
}
|
|
67763
|
-
function isSecretJWK(key) {
|
|
67764
|
-
return key.kty === "oct" && typeof key.k === "string";
|
|
67765
|
-
}
|
|
67766
|
-
|
|
67767
|
-
// node_modules/jose/dist/webapi/lib/normalize_key.js
|
|
67768
|
-
var cache;
|
|
67769
|
-
var handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
67770
|
-
cache ||= new WeakMap;
|
|
67771
|
-
let cached = cache.get(key);
|
|
67772
|
-
if (cached?.[alg]) {
|
|
67773
|
-
return cached[alg];
|
|
67774
|
-
}
|
|
67775
|
-
const cryptoKey = await jwk_to_key_default({ ...jwk, alg });
|
|
67776
|
-
if (freeze)
|
|
67777
|
-
Object.freeze(key);
|
|
67778
|
-
if (!cached) {
|
|
67779
|
-
cache.set(key, { [alg]: cryptoKey });
|
|
67780
|
-
} else {
|
|
67781
|
-
cached[alg] = cryptoKey;
|
|
67342
|
+
async function convertMdToPdf(markdown, options3 = {}, assetHeaders = {}) {
|
|
67343
|
+
const documentParserApiUrl = this.environment.lookup("documentParserApiUrl");
|
|
67344
|
+
const documentParserApiKey = this.environment.lookup("documentParserApiKey");
|
|
67345
|
+
if (!documentParserApiKey) {
|
|
67346
|
+
throw new Error("Document parser API key not found in environment");
|
|
67782
67347
|
}
|
|
67783
|
-
|
|
67784
|
-
|
|
67785
|
-
var handleKeyObject = (keyObject, alg) => {
|
|
67786
|
-
cache ||= new WeakMap;
|
|
67787
|
-
let cached = cache.get(keyObject);
|
|
67788
|
-
if (cached?.[alg]) {
|
|
67789
|
-
return cached[alg];
|
|
67790
|
-
}
|
|
67791
|
-
const isPublic = keyObject.type === "public";
|
|
67792
|
-
const extractable = isPublic ? true : false;
|
|
67793
|
-
let cryptoKey;
|
|
67794
|
-
if (keyObject.asymmetricKeyType === "x25519") {
|
|
67795
|
-
switch (alg) {
|
|
67796
|
-
case "ECDH-ES":
|
|
67797
|
-
case "ECDH-ES+A128KW":
|
|
67798
|
-
case "ECDH-ES+A192KW":
|
|
67799
|
-
case "ECDH-ES+A256KW":
|
|
67800
|
-
break;
|
|
67801
|
-
default:
|
|
67802
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67803
|
-
}
|
|
67804
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
|
|
67348
|
+
if (!documentParserApiUrl) {
|
|
67349
|
+
throw new Error("Document parser API URL not found in environment");
|
|
67805
67350
|
}
|
|
67806
|
-
if (
|
|
67807
|
-
|
|
67808
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67809
|
-
}
|
|
67810
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
67811
|
-
isPublic ? "verify" : "sign"
|
|
67812
|
-
]);
|
|
67351
|
+
if (!markdown || typeof markdown !== "string") {
|
|
67352
|
+
throw new AbortError("Markdown content is required and must be a string");
|
|
67813
67353
|
}
|
|
67814
|
-
|
|
67815
|
-
|
|
67816
|
-
|
|
67817
|
-
|
|
67818
|
-
|
|
67819
|
-
|
|
67354
|
+
const requestBody = {
|
|
67355
|
+
markdown,
|
|
67356
|
+
options: options3,
|
|
67357
|
+
assetHeaders
|
|
67358
|
+
};
|
|
67359
|
+
return await pRetry(async () => {
|
|
67360
|
+
const response = await fetch(`${documentParserApiUrl}/md-to-pdf`, {
|
|
67361
|
+
method: "POST",
|
|
67362
|
+
headers: {
|
|
67363
|
+
Authorization: `Bearer ${documentParserApiKey}`,
|
|
67364
|
+
"Content-Type": "application/json",
|
|
67365
|
+
Accept: "application/pdf",
|
|
67366
|
+
"User-Agent": "truto"
|
|
67367
|
+
},
|
|
67368
|
+
body: JSON.stringify(requestBody)
|
|
67369
|
+
});
|
|
67370
|
+
if (!response.ok) {
|
|
67371
|
+
if (response.status === 429) {
|
|
67372
|
+
throw new Error("Rate limit exceeded");
|
|
67820
67373
|
}
|
|
67821
|
-
|
|
67822
|
-
|
|
67823
|
-
]);
|
|
67824
|
-
}
|
|
67825
|
-
}
|
|
67826
|
-
if (keyObject.asymmetricKeyType === "rsa") {
|
|
67827
|
-
let hash;
|
|
67828
|
-
switch (alg) {
|
|
67829
|
-
case "RSA-OAEP":
|
|
67830
|
-
hash = "SHA-1";
|
|
67831
|
-
break;
|
|
67832
|
-
case "RS256":
|
|
67833
|
-
case "PS256":
|
|
67834
|
-
case "RSA-OAEP-256":
|
|
67835
|
-
hash = "SHA-256";
|
|
67836
|
-
break;
|
|
67837
|
-
case "RS384":
|
|
67838
|
-
case "PS384":
|
|
67839
|
-
case "RSA-OAEP-384":
|
|
67840
|
-
hash = "SHA-384";
|
|
67841
|
-
break;
|
|
67842
|
-
case "RS512":
|
|
67843
|
-
case "PS512":
|
|
67844
|
-
case "RSA-OAEP-512":
|
|
67845
|
-
hash = "SHA-512";
|
|
67846
|
-
break;
|
|
67847
|
-
default:
|
|
67848
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67849
|
-
}
|
|
67850
|
-
if (alg.startsWith("RSA-OAEP")) {
|
|
67851
|
-
return keyObject.toCryptoKey({
|
|
67852
|
-
name: "RSA-OAEP",
|
|
67853
|
-
hash
|
|
67854
|
-
}, extractable, isPublic ? ["encrypt"] : ["decrypt"]);
|
|
67855
|
-
}
|
|
67856
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67857
|
-
name: alg.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
|
|
67858
|
-
hash
|
|
67859
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67860
|
-
}
|
|
67861
|
-
if (keyObject.asymmetricKeyType === "ec") {
|
|
67862
|
-
const nist = new Map([
|
|
67863
|
-
["prime256v1", "P-256"],
|
|
67864
|
-
["secp384r1", "P-384"],
|
|
67865
|
-
["secp521r1", "P-521"]
|
|
67866
|
-
]);
|
|
67867
|
-
const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
|
|
67868
|
-
if (!namedCurve) {
|
|
67869
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67870
|
-
}
|
|
67871
|
-
if (alg === "ES256" && namedCurve === "P-256") {
|
|
67872
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67873
|
-
name: "ECDSA",
|
|
67874
|
-
namedCurve
|
|
67875
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67876
|
-
}
|
|
67877
|
-
if (alg === "ES384" && namedCurve === "P-384") {
|
|
67878
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67879
|
-
name: "ECDSA",
|
|
67880
|
-
namedCurve
|
|
67881
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67882
|
-
}
|
|
67883
|
-
if (alg === "ES512" && namedCurve === "P-521") {
|
|
67884
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67885
|
-
name: "ECDSA",
|
|
67886
|
-
namedCurve
|
|
67887
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67888
|
-
}
|
|
67889
|
-
if (alg.startsWith("ECDH-ES")) {
|
|
67890
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67891
|
-
name: "ECDH",
|
|
67892
|
-
namedCurve
|
|
67893
|
-
}, extractable, isPublic ? [] : ["deriveBits"]);
|
|
67894
|
-
}
|
|
67895
|
-
}
|
|
67896
|
-
if (!cryptoKey) {
|
|
67897
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67898
|
-
}
|
|
67899
|
-
if (!cached) {
|
|
67900
|
-
cache.set(keyObject, { [alg]: cryptoKey });
|
|
67901
|
-
} else {
|
|
67902
|
-
cached[alg] = cryptoKey;
|
|
67903
|
-
}
|
|
67904
|
-
return cryptoKey;
|
|
67905
|
-
};
|
|
67906
|
-
var normalize_key_default = async (key, alg) => {
|
|
67907
|
-
if (key instanceof Uint8Array) {
|
|
67908
|
-
return key;
|
|
67909
|
-
}
|
|
67910
|
-
if (isCryptoKey(key)) {
|
|
67911
|
-
return key;
|
|
67912
|
-
}
|
|
67913
|
-
if (isKeyObject(key)) {
|
|
67914
|
-
if (key.type === "secret") {
|
|
67915
|
-
return key.export();
|
|
67916
|
-
}
|
|
67917
|
-
if ("toCryptoKey" in key && typeof key.toCryptoKey === "function") {
|
|
67918
|
-
try {
|
|
67919
|
-
return handleKeyObject(key, alg);
|
|
67920
|
-
} catch (err) {
|
|
67921
|
-
if (err instanceof TypeError) {
|
|
67922
|
-
throw err;
|
|
67923
|
-
}
|
|
67374
|
+
if (response.status >= 500) {
|
|
67375
|
+
throw new Error(`Server error: ${response.status}`);
|
|
67924
67376
|
}
|
|
67377
|
+
const errorText = await response.text();
|
|
67378
|
+
let errorMessage = `PDF conversion failed (${response.status})`;
|
|
67379
|
+
try {
|
|
67380
|
+
const errorData = JSON.parse(errorText);
|
|
67381
|
+
errorMessage = errorData.error || errorMessage;
|
|
67382
|
+
if (errorData.details) {
|
|
67383
|
+
errorMessage += `: ${errorData.details}`;
|
|
67384
|
+
}
|
|
67385
|
+
} catch {
|
|
67386
|
+
errorMessage += `: ${errorText}`;
|
|
67387
|
+
}
|
|
67388
|
+
throw new AbortError(errorMessage);
|
|
67389
|
+
}
|
|
67390
|
+
const contentType = response.headers.get("content-type");
|
|
67391
|
+
if (!contentType || !includes_default(contentType, "application/pdf")) {
|
|
67392
|
+
throw new AbortError(`Expected PDF but received: ${contentType}`);
|
|
67393
|
+
}
|
|
67394
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
67395
|
+
const filename = getFilenameFromHeaders(response, options3.filename);
|
|
67396
|
+
const blob2 = new Blob([arrayBuffer], { type: "application/pdf" });
|
|
67397
|
+
blob2.name = filename;
|
|
67398
|
+
return blob2;
|
|
67399
|
+
}, {
|
|
67400
|
+
retries: 5,
|
|
67401
|
+
maxTimeout: 30000,
|
|
67402
|
+
minTimeout: 2500,
|
|
67403
|
+
onFailedAttempt: (error) => {
|
|
67404
|
+
console.warn(`PDF conversion attempt ${error.attemptNumber} failed:`, error.message);
|
|
67925
67405
|
}
|
|
67926
|
-
|
|
67927
|
-
return handleJWK(key, jwk, alg);
|
|
67928
|
-
}
|
|
67929
|
-
if (isJWK(key)) {
|
|
67930
|
-
if (key.k) {
|
|
67931
|
-
return decode(key.k);
|
|
67932
|
-
}
|
|
67933
|
-
return handleJWK(key, key, alg, true);
|
|
67934
|
-
}
|
|
67935
|
-
throw new Error("unreachable");
|
|
67936
|
-
};
|
|
67937
|
-
|
|
67938
|
-
// node_modules/jose/dist/webapi/lib/check_key_type.js
|
|
67939
|
-
var tag3 = (key) => key?.[Symbol.toStringTag];
|
|
67940
|
-
var jwkMatchesOp = (alg, key, usage) => {
|
|
67941
|
-
if (key.use !== undefined) {
|
|
67942
|
-
let expected;
|
|
67943
|
-
switch (usage) {
|
|
67944
|
-
case "sign":
|
|
67945
|
-
case "verify":
|
|
67946
|
-
expected = "sig";
|
|
67947
|
-
break;
|
|
67948
|
-
case "encrypt":
|
|
67949
|
-
case "decrypt":
|
|
67950
|
-
expected = "enc";
|
|
67951
|
-
break;
|
|
67952
|
-
}
|
|
67953
|
-
if (key.use !== expected) {
|
|
67954
|
-
throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
|
|
67955
|
-
}
|
|
67956
|
-
}
|
|
67957
|
-
if (key.alg !== undefined && key.alg !== alg) {
|
|
67958
|
-
throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
|
|
67959
|
-
}
|
|
67960
|
-
if (Array.isArray(key.key_ops)) {
|
|
67961
|
-
let expectedKeyOp;
|
|
67962
|
-
switch (true) {
|
|
67963
|
-
case (usage === "sign" || usage === "verify"):
|
|
67964
|
-
case alg === "dir":
|
|
67965
|
-
case alg.includes("CBC-HS"):
|
|
67966
|
-
expectedKeyOp = usage;
|
|
67967
|
-
break;
|
|
67968
|
-
case alg.startsWith("PBES2"):
|
|
67969
|
-
expectedKeyOp = "deriveBits";
|
|
67970
|
-
break;
|
|
67971
|
-
case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
|
|
67972
|
-
if (!alg.includes("GCM") && alg.endsWith("KW")) {
|
|
67973
|
-
expectedKeyOp = usage === "encrypt" ? "wrapKey" : "unwrapKey";
|
|
67974
|
-
} else {
|
|
67975
|
-
expectedKeyOp = usage;
|
|
67976
|
-
}
|
|
67977
|
-
break;
|
|
67978
|
-
case (usage === "encrypt" && alg.startsWith("RSA")):
|
|
67979
|
-
expectedKeyOp = "wrapKey";
|
|
67980
|
-
break;
|
|
67981
|
-
case usage === "decrypt":
|
|
67982
|
-
expectedKeyOp = alg.startsWith("RSA") ? "unwrapKey" : "deriveBits";
|
|
67983
|
-
break;
|
|
67984
|
-
}
|
|
67985
|
-
if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {
|
|
67986
|
-
throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
|
|
67987
|
-
}
|
|
67988
|
-
}
|
|
67989
|
-
return true;
|
|
67990
|
-
};
|
|
67991
|
-
var symmetricTypeCheck = (alg, key, usage) => {
|
|
67992
|
-
if (key instanceof Uint8Array)
|
|
67993
|
-
return;
|
|
67994
|
-
if (isJWK(key)) {
|
|
67995
|
-
if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
67996
|
-
return;
|
|
67997
|
-
throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`);
|
|
67998
|
-
}
|
|
67999
|
-
if (!is_key_like_default(key)) {
|
|
68000
|
-
throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
|
|
68001
|
-
}
|
|
68002
|
-
if (key.type !== "secret") {
|
|
68003
|
-
throw new TypeError(`${tag3(key)} instances for symmetric algorithms must be of type "secret"`);
|
|
68004
|
-
}
|
|
68005
|
-
};
|
|
68006
|
-
var asymmetricTypeCheck = (alg, key, usage) => {
|
|
68007
|
-
if (isJWK(key)) {
|
|
68008
|
-
switch (usage) {
|
|
68009
|
-
case "decrypt":
|
|
68010
|
-
case "sign":
|
|
68011
|
-
if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
68012
|
-
return;
|
|
68013
|
-
throw new TypeError(`JSON Web Key for this operation be a private JWK`);
|
|
68014
|
-
case "encrypt":
|
|
68015
|
-
case "verify":
|
|
68016
|
-
if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
68017
|
-
return;
|
|
68018
|
-
throw new TypeError(`JSON Web Key for this operation be a public JWK`);
|
|
68019
|
-
}
|
|
68020
|
-
}
|
|
68021
|
-
if (!is_key_like_default(key)) {
|
|
68022
|
-
throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
68023
|
-
}
|
|
68024
|
-
if (key.type === "secret") {
|
|
68025
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
68026
|
-
}
|
|
68027
|
-
if (key.type === "public") {
|
|
68028
|
-
switch (usage) {
|
|
68029
|
-
case "sign":
|
|
68030
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm signing must be of type "private"`);
|
|
68031
|
-
case "decrypt":
|
|
68032
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
68033
|
-
default:
|
|
68034
|
-
break;
|
|
68035
|
-
}
|
|
68036
|
-
}
|
|
68037
|
-
if (key.type === "private") {
|
|
68038
|
-
switch (usage) {
|
|
68039
|
-
case "verify":
|
|
68040
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
68041
|
-
case "encrypt":
|
|
68042
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
68043
|
-
default:
|
|
68044
|
-
break;
|
|
68045
|
-
}
|
|
68046
|
-
}
|
|
68047
|
-
};
|
|
68048
|
-
var check_key_type_default = (alg, key, usage) => {
|
|
68049
|
-
const symmetric = alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(alg) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(alg);
|
|
68050
|
-
if (symmetric) {
|
|
68051
|
-
symmetricTypeCheck(alg, key, usage);
|
|
68052
|
-
} else {
|
|
68053
|
-
asymmetricTypeCheck(alg, key, usage);
|
|
68054
|
-
}
|
|
68055
|
-
};
|
|
68056
|
-
|
|
68057
|
-
// node_modules/jose/dist/webapi/lib/subtle_dsa.js
|
|
68058
|
-
var subtle_dsa_default = (alg, algorithm) => {
|
|
68059
|
-
const hash = `SHA-${alg.slice(-3)}`;
|
|
68060
|
-
switch (alg) {
|
|
68061
|
-
case "HS256":
|
|
68062
|
-
case "HS384":
|
|
68063
|
-
case "HS512":
|
|
68064
|
-
return { hash, name: "HMAC" };
|
|
68065
|
-
case "PS256":
|
|
68066
|
-
case "PS384":
|
|
68067
|
-
case "PS512":
|
|
68068
|
-
return { hash, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
|
|
68069
|
-
case "RS256":
|
|
68070
|
-
case "RS384":
|
|
68071
|
-
case "RS512":
|
|
68072
|
-
return { hash, name: "RSASSA-PKCS1-v1_5" };
|
|
68073
|
-
case "ES256":
|
|
68074
|
-
case "ES384":
|
|
68075
|
-
case "ES512":
|
|
68076
|
-
return { hash, name: "ECDSA", namedCurve: algorithm.namedCurve };
|
|
68077
|
-
case "Ed25519":
|
|
68078
|
-
case "EdDSA":
|
|
68079
|
-
return { name: "Ed25519" };
|
|
68080
|
-
case "ML-DSA-44":
|
|
68081
|
-
case "ML-DSA-65":
|
|
68082
|
-
case "ML-DSA-87":
|
|
68083
|
-
return { name: alg };
|
|
68084
|
-
default:
|
|
68085
|
-
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
68086
|
-
}
|
|
68087
|
-
};
|
|
68088
|
-
|
|
68089
|
-
// node_modules/jose/dist/webapi/lib/get_sign_verify_key.js
|
|
68090
|
-
var get_sign_verify_key_default = async (alg, key, usage) => {
|
|
68091
|
-
if (key instanceof Uint8Array) {
|
|
68092
|
-
if (!alg.startsWith("HS")) {
|
|
68093
|
-
throw new TypeError(invalid_key_input_default(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
68094
|
-
}
|
|
68095
|
-
return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
|
|
68096
|
-
}
|
|
68097
|
-
checkSigCryptoKey(key, alg, usage);
|
|
68098
|
-
return key;
|
|
68099
|
-
};
|
|
68100
|
-
|
|
68101
|
-
// node_modules/jose/dist/webapi/lib/epoch.js
|
|
68102
|
-
var epoch_default = (date2) => Math.floor(date2.getTime() / 1000);
|
|
68103
|
-
|
|
68104
|
-
// node_modules/jose/dist/webapi/lib/secs.js
|
|
68105
|
-
var minute = 60;
|
|
68106
|
-
var hour = minute * 60;
|
|
68107
|
-
var day = hour * 24;
|
|
68108
|
-
var week = day * 7;
|
|
68109
|
-
var year = day * 365.25;
|
|
68110
|
-
var REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
|
|
68111
|
-
var secs_default = (str) => {
|
|
68112
|
-
const matched = REGEX.exec(str);
|
|
68113
|
-
if (!matched || matched[4] && matched[1]) {
|
|
68114
|
-
throw new TypeError("Invalid time period format");
|
|
68115
|
-
}
|
|
68116
|
-
const value = parseFloat(matched[2]);
|
|
68117
|
-
const unit = matched[3].toLowerCase();
|
|
68118
|
-
let numericDate;
|
|
68119
|
-
switch (unit) {
|
|
68120
|
-
case "sec":
|
|
68121
|
-
case "secs":
|
|
68122
|
-
case "second":
|
|
68123
|
-
case "seconds":
|
|
68124
|
-
case "s":
|
|
68125
|
-
numericDate = Math.round(value);
|
|
68126
|
-
break;
|
|
68127
|
-
case "minute":
|
|
68128
|
-
case "minutes":
|
|
68129
|
-
case "min":
|
|
68130
|
-
case "mins":
|
|
68131
|
-
case "m":
|
|
68132
|
-
numericDate = Math.round(value * minute);
|
|
68133
|
-
break;
|
|
68134
|
-
case "hour":
|
|
68135
|
-
case "hours":
|
|
68136
|
-
case "hr":
|
|
68137
|
-
case "hrs":
|
|
68138
|
-
case "h":
|
|
68139
|
-
numericDate = Math.round(value * hour);
|
|
68140
|
-
break;
|
|
68141
|
-
case "day":
|
|
68142
|
-
case "days":
|
|
68143
|
-
case "d":
|
|
68144
|
-
numericDate = Math.round(value * day);
|
|
68145
|
-
break;
|
|
68146
|
-
case "week":
|
|
68147
|
-
case "weeks":
|
|
68148
|
-
case "w":
|
|
68149
|
-
numericDate = Math.round(value * week);
|
|
68150
|
-
break;
|
|
68151
|
-
default:
|
|
68152
|
-
numericDate = Math.round(value * year);
|
|
68153
|
-
break;
|
|
68154
|
-
}
|
|
68155
|
-
if (matched[1] === "-" || matched[4] === "ago") {
|
|
68156
|
-
return -numericDate;
|
|
68157
|
-
}
|
|
68158
|
-
return numericDate;
|
|
68159
|
-
};
|
|
68160
|
-
|
|
68161
|
-
// node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
68162
|
-
function validateInput(label, input) {
|
|
68163
|
-
if (!Number.isFinite(input)) {
|
|
68164
|
-
throw new TypeError(`Invalid ${label} input`);
|
|
68165
|
-
}
|
|
68166
|
-
return input;
|
|
68167
|
-
}
|
|
68168
|
-
class JWTClaimsBuilder {
|
|
68169
|
-
#payload;
|
|
68170
|
-
constructor(payload) {
|
|
68171
|
-
if (!is_object_default(payload)) {
|
|
68172
|
-
throw new TypeError("JWT Claims Set MUST be an object");
|
|
68173
|
-
}
|
|
68174
|
-
this.#payload = structuredClone(payload);
|
|
68175
|
-
}
|
|
68176
|
-
data() {
|
|
68177
|
-
return encoder.encode(JSON.stringify(this.#payload));
|
|
68178
|
-
}
|
|
68179
|
-
get iss() {
|
|
68180
|
-
return this.#payload.iss;
|
|
68181
|
-
}
|
|
68182
|
-
set iss(value) {
|
|
68183
|
-
this.#payload.iss = value;
|
|
68184
|
-
}
|
|
68185
|
-
get sub() {
|
|
68186
|
-
return this.#payload.sub;
|
|
68187
|
-
}
|
|
68188
|
-
set sub(value) {
|
|
68189
|
-
this.#payload.sub = value;
|
|
68190
|
-
}
|
|
68191
|
-
get aud() {
|
|
68192
|
-
return this.#payload.aud;
|
|
68193
|
-
}
|
|
68194
|
-
set aud(value) {
|
|
68195
|
-
this.#payload.aud = value;
|
|
68196
|
-
}
|
|
68197
|
-
set jti(value) {
|
|
68198
|
-
this.#payload.jti = value;
|
|
68199
|
-
}
|
|
68200
|
-
set nbf(value) {
|
|
68201
|
-
if (typeof value === "number") {
|
|
68202
|
-
this.#payload.nbf = validateInput("setNotBefore", value);
|
|
68203
|
-
} else if (value instanceof Date) {
|
|
68204
|
-
this.#payload.nbf = validateInput("setNotBefore", epoch_default(value));
|
|
68205
|
-
} else {
|
|
68206
|
-
this.#payload.nbf = epoch_default(new Date) + secs_default(value);
|
|
68207
|
-
}
|
|
68208
|
-
}
|
|
68209
|
-
set exp(value) {
|
|
68210
|
-
if (typeof value === "number") {
|
|
68211
|
-
this.#payload.exp = validateInput("setExpirationTime", value);
|
|
68212
|
-
} else if (value instanceof Date) {
|
|
68213
|
-
this.#payload.exp = validateInput("setExpirationTime", epoch_default(value));
|
|
68214
|
-
} else {
|
|
68215
|
-
this.#payload.exp = epoch_default(new Date) + secs_default(value);
|
|
68216
|
-
}
|
|
68217
|
-
}
|
|
68218
|
-
set iat(value) {
|
|
68219
|
-
if (typeof value === "undefined") {
|
|
68220
|
-
this.#payload.iat = epoch_default(new Date);
|
|
68221
|
-
} else if (value instanceof Date) {
|
|
68222
|
-
this.#payload.iat = validateInput("setIssuedAt", epoch_default(value));
|
|
68223
|
-
} else if (typeof value === "string") {
|
|
68224
|
-
this.#payload.iat = validateInput("setIssuedAt", epoch_default(new Date) + secs_default(value));
|
|
68225
|
-
} else {
|
|
68226
|
-
this.#payload.iat = validateInput("setIssuedAt", value);
|
|
68227
|
-
}
|
|
68228
|
-
}
|
|
68229
|
-
}
|
|
68230
|
-
|
|
68231
|
-
// node_modules/jose/dist/webapi/lib/sign.js
|
|
68232
|
-
var sign_default2 = async (alg, key, data) => {
|
|
68233
|
-
const cryptoKey = await get_sign_verify_key_default(alg, key, "sign");
|
|
68234
|
-
check_key_length_default(alg, cryptoKey);
|
|
68235
|
-
const signature = await crypto.subtle.sign(subtle_dsa_default(alg, cryptoKey.algorithm), cryptoKey, data);
|
|
68236
|
-
return new Uint8Array(signature);
|
|
68237
|
-
};
|
|
68238
|
-
|
|
68239
|
-
// node_modules/jose/dist/webapi/jws/flattened/sign.js
|
|
68240
|
-
class FlattenedSign {
|
|
68241
|
-
#payload;
|
|
68242
|
-
#protectedHeader;
|
|
68243
|
-
#unprotectedHeader;
|
|
68244
|
-
constructor(payload) {
|
|
68245
|
-
if (!(payload instanceof Uint8Array)) {
|
|
68246
|
-
throw new TypeError("payload must be an instance of Uint8Array");
|
|
68247
|
-
}
|
|
68248
|
-
this.#payload = payload;
|
|
68249
|
-
}
|
|
68250
|
-
setProtectedHeader(protectedHeader) {
|
|
68251
|
-
if (this.#protectedHeader) {
|
|
68252
|
-
throw new TypeError("setProtectedHeader can only be called once");
|
|
68253
|
-
}
|
|
68254
|
-
this.#protectedHeader = protectedHeader;
|
|
68255
|
-
return this;
|
|
68256
|
-
}
|
|
68257
|
-
setUnprotectedHeader(unprotectedHeader) {
|
|
68258
|
-
if (this.#unprotectedHeader) {
|
|
68259
|
-
throw new TypeError("setUnprotectedHeader can only be called once");
|
|
68260
|
-
}
|
|
68261
|
-
this.#unprotectedHeader = unprotectedHeader;
|
|
68262
|
-
return this;
|
|
68263
|
-
}
|
|
68264
|
-
async sign(key, options3) {
|
|
68265
|
-
if (!this.#protectedHeader && !this.#unprotectedHeader) {
|
|
68266
|
-
throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
68267
|
-
}
|
|
68268
|
-
if (!is_disjoint_default(this.#protectedHeader, this.#unprotectedHeader)) {
|
|
68269
|
-
throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
68270
|
-
}
|
|
68271
|
-
const joseHeader = {
|
|
68272
|
-
...this.#protectedHeader,
|
|
68273
|
-
...this.#unprotectedHeader
|
|
68274
|
-
};
|
|
68275
|
-
const extensions = validate_crit_default(JWSInvalid, new Map([["b64", true]]), options3?.crit, this.#protectedHeader, joseHeader);
|
|
68276
|
-
let b64 = true;
|
|
68277
|
-
if (extensions.has("b64")) {
|
|
68278
|
-
b64 = this.#protectedHeader.b64;
|
|
68279
|
-
if (typeof b64 !== "boolean") {
|
|
68280
|
-
throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
68281
|
-
}
|
|
68282
|
-
}
|
|
68283
|
-
const { alg } = joseHeader;
|
|
68284
|
-
if (typeof alg !== "string" || !alg) {
|
|
68285
|
-
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
68286
|
-
}
|
|
68287
|
-
check_key_type_default(alg, key, "sign");
|
|
68288
|
-
let payload = this.#payload;
|
|
68289
|
-
if (b64) {
|
|
68290
|
-
payload = encoder.encode(encode(payload));
|
|
68291
|
-
}
|
|
68292
|
-
let protectedHeader;
|
|
68293
|
-
if (this.#protectedHeader) {
|
|
68294
|
-
protectedHeader = encoder.encode(encode(JSON.stringify(this.#protectedHeader)));
|
|
68295
|
-
} else {
|
|
68296
|
-
protectedHeader = encoder.encode("");
|
|
68297
|
-
}
|
|
68298
|
-
const data = concat4(protectedHeader, encoder.encode("."), payload);
|
|
68299
|
-
const k = await normalize_key_default(key, alg);
|
|
68300
|
-
const signature = await sign_default2(alg, k, data);
|
|
68301
|
-
const jws = {
|
|
68302
|
-
signature: encode(signature),
|
|
68303
|
-
payload: ""
|
|
68304
|
-
};
|
|
68305
|
-
if (b64) {
|
|
68306
|
-
jws.payload = decoder.decode(payload);
|
|
68307
|
-
}
|
|
68308
|
-
if (this.#unprotectedHeader) {
|
|
68309
|
-
jws.header = this.#unprotectedHeader;
|
|
68310
|
-
}
|
|
68311
|
-
if (this.#protectedHeader) {
|
|
68312
|
-
jws.protected = decoder.decode(protectedHeader);
|
|
68313
|
-
}
|
|
68314
|
-
return jws;
|
|
68315
|
-
}
|
|
68316
|
-
}
|
|
68317
|
-
|
|
68318
|
-
// node_modules/jose/dist/webapi/jws/compact/sign.js
|
|
68319
|
-
class CompactSign {
|
|
68320
|
-
#flattened;
|
|
68321
|
-
constructor(payload) {
|
|
68322
|
-
this.#flattened = new FlattenedSign(payload);
|
|
68323
|
-
}
|
|
68324
|
-
setProtectedHeader(protectedHeader) {
|
|
68325
|
-
this.#flattened.setProtectedHeader(protectedHeader);
|
|
68326
|
-
return this;
|
|
68327
|
-
}
|
|
68328
|
-
async sign(key, options3) {
|
|
68329
|
-
const jws = await this.#flattened.sign(key, options3);
|
|
68330
|
-
if (jws.payload === undefined) {
|
|
68331
|
-
throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
68332
|
-
}
|
|
68333
|
-
return `${jws.protected}.${jws.payload}.${jws.signature}`;
|
|
68334
|
-
}
|
|
68335
|
-
}
|
|
68336
|
-
|
|
68337
|
-
// node_modules/jose/dist/webapi/jwt/sign.js
|
|
68338
|
-
class SignJWT {
|
|
68339
|
-
#protectedHeader;
|
|
68340
|
-
#jwt;
|
|
68341
|
-
constructor(payload = {}) {
|
|
68342
|
-
this.#jwt = new JWTClaimsBuilder(payload);
|
|
68343
|
-
}
|
|
68344
|
-
setIssuer(issuer) {
|
|
68345
|
-
this.#jwt.iss = issuer;
|
|
68346
|
-
return this;
|
|
68347
|
-
}
|
|
68348
|
-
setSubject(subject) {
|
|
68349
|
-
this.#jwt.sub = subject;
|
|
68350
|
-
return this;
|
|
68351
|
-
}
|
|
68352
|
-
setAudience(audience) {
|
|
68353
|
-
this.#jwt.aud = audience;
|
|
68354
|
-
return this;
|
|
68355
|
-
}
|
|
68356
|
-
setJti(jwtId) {
|
|
68357
|
-
this.#jwt.jti = jwtId;
|
|
68358
|
-
return this;
|
|
68359
|
-
}
|
|
68360
|
-
setNotBefore(input) {
|
|
68361
|
-
this.#jwt.nbf = input;
|
|
68362
|
-
return this;
|
|
68363
|
-
}
|
|
68364
|
-
setExpirationTime(input) {
|
|
68365
|
-
this.#jwt.exp = input;
|
|
68366
|
-
return this;
|
|
68367
|
-
}
|
|
68368
|
-
setIssuedAt(input) {
|
|
68369
|
-
this.#jwt.iat = input;
|
|
68370
|
-
return this;
|
|
68371
|
-
}
|
|
68372
|
-
setProtectedHeader(protectedHeader) {
|
|
68373
|
-
this.#protectedHeader = protectedHeader;
|
|
68374
|
-
return this;
|
|
68375
|
-
}
|
|
68376
|
-
async sign(key, options3) {
|
|
68377
|
-
const sig = new CompactSign(this.#jwt.data());
|
|
68378
|
-
sig.setProtectedHeader(this.#protectedHeader);
|
|
68379
|
-
if (Array.isArray(this.#protectedHeader?.crit) && this.#protectedHeader.crit.includes("b64") && this.#protectedHeader.b64 === false) {
|
|
68380
|
-
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
68381
|
-
}
|
|
68382
|
-
return sig.sign(key, options3);
|
|
68383
|
-
}
|
|
68384
|
-
}
|
|
68385
|
-
// src/functions/signJwt.ts
|
|
68386
|
-
function assertObjectPayload(payload) {
|
|
68387
|
-
if (!isPlainObject_default(payload) || isNull_default(payload)) {
|
|
68388
|
-
throw new Error("Payload must be a non-null object");
|
|
68389
|
-
}
|
|
67406
|
+
});
|
|
68390
67407
|
}
|
|
68391
|
-
var signJwt = async (payload, key, protectHeaders = {}, signOptions) => {
|
|
68392
|
-
assertObjectPayload(payload);
|
|
68393
|
-
try {
|
|
68394
|
-
let signingKey;
|
|
68395
|
-
const alg = protectHeaders.alg;
|
|
68396
|
-
if (!alg) {
|
|
68397
|
-
throw new Error("Algorithm (alg) must be provided in protectHeaders");
|
|
68398
|
-
}
|
|
68399
|
-
const isAsymmetric = alg.startsWith("RS") || alg.startsWith("ES") || alg.startsWith("PS");
|
|
68400
|
-
if (isAsymmetric) {
|
|
68401
|
-
if (!isString_default(key)) {
|
|
68402
|
-
throw new Error("For asymmetric algorithms, key must be a PEM string");
|
|
68403
|
-
}
|
|
68404
|
-
const pemKey = includes_default(key, "\\n") ? replace_default(key, /\\n/g, `
|
|
68405
|
-
`) : key;
|
|
68406
|
-
signingKey = await importPKCS8(pemKey, alg);
|
|
68407
|
-
} else {
|
|
68408
|
-
signingKey = isString_default(key) ? new TextEncoder().encode(key) : key;
|
|
68409
|
-
}
|
|
68410
|
-
const jwtBuilder = new SignJWT(payload).setProtectedHeader({ ...protectHeaders, typ: "JWT" });
|
|
68411
|
-
return await jwtBuilder.sign(signingKey, signOptions);
|
|
68412
|
-
} catch (error) {
|
|
68413
|
-
throw new Error(`JWT signing failed: ${error?.message || String(error)}`);
|
|
68414
|
-
}
|
|
68415
|
-
};
|
|
68416
|
-
var signJwt_default = signJwt;
|
|
68417
67408
|
|
|
68418
67409
|
// src/registerJsonataExtensions.ts
|
|
68419
67410
|
function registerJsonataExtensions(expression) {
|
|
@@ -68440,6 +67431,7 @@ function registerJsonataExtensions(expression) {
|
|
|
68440
67431
|
expression.registerFunction("difference", function(arr1, arr2) {
|
|
68441
67432
|
return difference_default(arr1, arr2);
|
|
68442
67433
|
});
|
|
67434
|
+
expression.registerFunction("convertMdToPdf", convertMdToPdf);
|
|
68443
67435
|
expression.registerFunction("toNumber", toNumber_default2);
|
|
68444
67436
|
expression.registerFunction("jsonParse", jsonParse_default);
|
|
68445
67437
|
expression.registerFunction("getMimeType", getMimeType_default);
|
|
@@ -68452,7 +67444,6 @@ function registerJsonataExtensions(expression) {
|
|
|
68452
67444
|
expression.registerFunction("convertMarkdownToHtml", convertMarkdownToHtml_default);
|
|
68453
67445
|
expression.registerFunction("digest", digest_default);
|
|
68454
67446
|
expression.registerFunction("sign", sign_default);
|
|
68455
|
-
expression.registerFunction("signJwt", signJwt_default);
|
|
68456
67447
|
expression.registerFunction("xmlToJs", xmlToJs);
|
|
68457
67448
|
expression.registerFunction("jsToXml", jsToXml_default);
|
|
68458
67449
|
expression.registerFunction("generateEmbeddingsCohere", generateEmbeddingsCohere_default);
|
|
@@ -68519,4 +67510,4 @@ export {
|
|
|
68519
67510
|
trutoJsonata as default
|
|
68520
67511
|
};
|
|
68521
67512
|
|
|
68522
|
-
//# debugId=
|
|
67513
|
+
//# debugId=B3F4257EBAFAE85064756E2164756E21
|