@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/cjs/index.cjs
CHANGED
|
@@ -7711,7 +7711,7 @@ var require_select = __commonJS((exports2, module2) => {
|
|
|
7711
7711
|
var regex = rules.inside.source.replace(/</g, start).replace(/>/g, end);
|
|
7712
7712
|
return new RegExp(regex);
|
|
7713
7713
|
};
|
|
7714
|
-
var
|
|
7714
|
+
var replace = function(regex, name, val) {
|
|
7715
7715
|
regex = regex.source;
|
|
7716
7716
|
regex = regex.replace(name, val.source || val);
|
|
7717
7717
|
return new RegExp(regex);
|
|
@@ -8136,20 +8136,20 @@ var require_select = __commonJS((exports2, module2) => {
|
|
|
8136
8136
|
inside: /(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|<[^"'>]*>|\\["'>]|[^"'>])*/,
|
|
8137
8137
|
ident: /^(cssid)$/
|
|
8138
8138
|
};
|
|
8139
|
-
rules.cssid =
|
|
8140
|
-
rules.cssid =
|
|
8141
|
-
rules.qname =
|
|
8142
|
-
rules.simple =
|
|
8143
|
-
rules.ref =
|
|
8144
|
-
rules.attr =
|
|
8145
|
-
rules.pseudo =
|
|
8146
|
-
rules.inside =
|
|
8147
|
-
rules.attr =
|
|
8148
|
-
rules.pseudo =
|
|
8149
|
-
rules.simple =
|
|
8150
|
-
rules.simple =
|
|
8151
|
-
rules.ident =
|
|
8152
|
-
rules.str_escape =
|
|
8139
|
+
rules.cssid = replace(rules.cssid, "nonascii", rules.nonascii);
|
|
8140
|
+
rules.cssid = replace(rules.cssid, "escape", rules.escape);
|
|
8141
|
+
rules.qname = replace(rules.qname, "cssid", rules.cssid);
|
|
8142
|
+
rules.simple = replace(rules.simple, "cssid", rules.cssid);
|
|
8143
|
+
rules.ref = replace(rules.ref, "cssid", rules.cssid);
|
|
8144
|
+
rules.attr = replace(rules.attr, "cssid", rules.cssid);
|
|
8145
|
+
rules.pseudo = replace(rules.pseudo, "cssid", rules.cssid);
|
|
8146
|
+
rules.inside = replace(rules.inside, `[^"'>]*`, rules.inside);
|
|
8147
|
+
rules.attr = replace(rules.attr, "inside", makeInside("\\[", "\\]"));
|
|
8148
|
+
rules.pseudo = replace(rules.pseudo, "inside", makeInside("\\(", "\\)"));
|
|
8149
|
+
rules.simple = replace(rules.simple, "pseudo", rules.pseudo);
|
|
8150
|
+
rules.simple = replace(rules.simple, "attr", rules.attr);
|
|
8151
|
+
rules.ident = replace(rules.ident, "cssid", rules.cssid);
|
|
8152
|
+
rules.str_escape = replace(rules.str_escape, "escape", rules.escape);
|
|
8153
8153
|
var compile = function(sel_) {
|
|
8154
8154
|
var sel = sel_.replace(/^\s+|\s+$/g, ""), test, filter2 = [], buff = [], subject, qname, cap, op, ref;
|
|
8155
8155
|
while (sel) {
|
|
@@ -30385,7 +30385,7 @@ var require_object_inspect = __commonJS((exports2, module2) => {
|
|
|
30385
30385
|
}
|
|
30386
30386
|
return inspect_(value, opts, depth + 1, seen);
|
|
30387
30387
|
}
|
|
30388
|
-
if (typeof obj === "function" && !
|
|
30388
|
+
if (typeof obj === "function" && !isRegExp2(obj)) {
|
|
30389
30389
|
var name = nameOf(obj);
|
|
30390
30390
|
var keys2 = arrObjKeys(obj, inspect2);
|
|
30391
30391
|
return "[Function" + (name ? ": " + name : " (anonymous)") + "]" + (keys2.length > 0 ? " { " + $join.call(keys2, ", ") + " }" : "");
|
|
@@ -30479,7 +30479,7 @@ var require_object_inspect = __commonJS((exports2, module2) => {
|
|
|
30479
30479
|
if (typeof globalThis !== "undefined" && obj === globalThis || typeof global !== "undefined" && obj === global) {
|
|
30480
30480
|
return "{ [object globalThis] }";
|
|
30481
30481
|
}
|
|
30482
|
-
if (!isDate2(obj) && !
|
|
30482
|
+
if (!isDate2(obj) && !isRegExp2(obj)) {
|
|
30483
30483
|
var ys = arrObjKeys(obj, inspect2);
|
|
30484
30484
|
var isPlainObject3 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
30485
30485
|
var protoTag = obj instanceof Object ? "" : "null prototype";
|
|
@@ -30513,7 +30513,7 @@ var require_object_inspect = __commonJS((exports2, module2) => {
|
|
|
30513
30513
|
function isDate2(obj) {
|
|
30514
30514
|
return toStr(obj) === "[object Date]" && canTrustToString(obj);
|
|
30515
30515
|
}
|
|
30516
|
-
function
|
|
30516
|
+
function isRegExp2(obj) {
|
|
30517
30517
|
return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
|
|
30518
30518
|
}
|
|
30519
30519
|
function isError2(obj) {
|
|
@@ -31703,7 +31703,7 @@ var require_side_channel = __commonJS((exports2, module2) => {
|
|
|
31703
31703
|
|
|
31704
31704
|
// node_modules/qs/lib/formats.js
|
|
31705
31705
|
var require_formats = __commonJS((exports2, module2) => {
|
|
31706
|
-
var
|
|
31706
|
+
var replace = String.prototype.replace;
|
|
31707
31707
|
var percentTwenties = /%20/g;
|
|
31708
31708
|
var Format = {
|
|
31709
31709
|
RFC1738: "RFC1738",
|
|
@@ -31713,7 +31713,7 @@ var require_formats = __commonJS((exports2, module2) => {
|
|
|
31713
31713
|
default: Format.RFC3986,
|
|
31714
31714
|
formatters: {
|
|
31715
31715
|
RFC1738: function(value) {
|
|
31716
|
-
return
|
|
31716
|
+
return replace.call(value, percentTwenties, "+");
|
|
31717
31717
|
},
|
|
31718
31718
|
RFC3986: function(value) {
|
|
31719
31719
|
return String(value);
|
|
@@ -31890,7 +31890,7 @@ var require_utils2 = __commonJS((exports2, module2) => {
|
|
|
31890
31890
|
compactQueue(queue);
|
|
31891
31891
|
return value;
|
|
31892
31892
|
};
|
|
31893
|
-
var
|
|
31893
|
+
var isRegExp2 = function isRegExp(obj) {
|
|
31894
31894
|
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
31895
31895
|
};
|
|
31896
31896
|
var isBuffer3 = function isBuffer(obj) {
|
|
@@ -31920,7 +31920,7 @@ var require_utils2 = __commonJS((exports2, module2) => {
|
|
|
31920
31920
|
decode,
|
|
31921
31921
|
encode,
|
|
31922
31922
|
isBuffer: isBuffer3,
|
|
31923
|
-
isRegExp,
|
|
31923
|
+
isRegExp: isRegExp2,
|
|
31924
31924
|
maybeMap,
|
|
31925
31925
|
merge
|
|
31926
31926
|
};
|
|
@@ -36323,6 +36323,66 @@ function baseSlice(array, start, end) {
|
|
|
36323
36323
|
}
|
|
36324
36324
|
var _baseSlice_default = baseSlice;
|
|
36325
36325
|
|
|
36326
|
+
// node_modules/lodash-es/_castSlice.js
|
|
36327
|
+
function castSlice(array, start, end) {
|
|
36328
|
+
var length = array.length;
|
|
36329
|
+
end = end === undefined ? length : end;
|
|
36330
|
+
return !start && end >= length ? array : _baseSlice_default(array, start, end);
|
|
36331
|
+
}
|
|
36332
|
+
var _castSlice_default = castSlice;
|
|
36333
|
+
|
|
36334
|
+
// node_modules/lodash-es/_hasUnicode.js
|
|
36335
|
+
var rsAstralRange = "\\ud800-\\udfff";
|
|
36336
|
+
var rsComboMarksRange = "\\u0300-\\u036f";
|
|
36337
|
+
var reComboHalfMarksRange = "\\ufe20-\\ufe2f";
|
|
36338
|
+
var rsComboSymbolsRange = "\\u20d0-\\u20ff";
|
|
36339
|
+
var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
|
|
36340
|
+
var rsVarRange = "\\ufe0e\\ufe0f";
|
|
36341
|
+
var rsZWJ = "\\u200d";
|
|
36342
|
+
var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + "]");
|
|
36343
|
+
function hasUnicode(string) {
|
|
36344
|
+
return reHasUnicode.test(string);
|
|
36345
|
+
}
|
|
36346
|
+
var _hasUnicode_default = hasUnicode;
|
|
36347
|
+
|
|
36348
|
+
// node_modules/lodash-es/_asciiToArray.js
|
|
36349
|
+
function asciiToArray(string) {
|
|
36350
|
+
return string.split("");
|
|
36351
|
+
}
|
|
36352
|
+
var _asciiToArray_default = asciiToArray;
|
|
36353
|
+
|
|
36354
|
+
// node_modules/lodash-es/_unicodeToArray.js
|
|
36355
|
+
var rsAstralRange2 = "\\ud800-\\udfff";
|
|
36356
|
+
var rsComboMarksRange2 = "\\u0300-\\u036f";
|
|
36357
|
+
var reComboHalfMarksRange2 = "\\ufe20-\\ufe2f";
|
|
36358
|
+
var rsComboSymbolsRange2 = "\\u20d0-\\u20ff";
|
|
36359
|
+
var rsComboRange2 = rsComboMarksRange2 + reComboHalfMarksRange2 + rsComboSymbolsRange2;
|
|
36360
|
+
var rsVarRange2 = "\\ufe0e\\ufe0f";
|
|
36361
|
+
var rsAstral = "[" + rsAstralRange2 + "]";
|
|
36362
|
+
var rsCombo = "[" + rsComboRange2 + "]";
|
|
36363
|
+
var rsFitz = "\\ud83c[\\udffb-\\udfff]";
|
|
36364
|
+
var rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")";
|
|
36365
|
+
var rsNonAstral = "[^" + rsAstralRange2 + "]";
|
|
36366
|
+
var rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}";
|
|
36367
|
+
var rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]";
|
|
36368
|
+
var rsZWJ2 = "\\u200d";
|
|
36369
|
+
var reOptMod = rsModifier + "?";
|
|
36370
|
+
var rsOptVar = "[" + rsVarRange2 + "]?";
|
|
36371
|
+
var rsOptJoin = "(?:" + rsZWJ2 + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*";
|
|
36372
|
+
var rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
|
36373
|
+
var rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
|
|
36374
|
+
var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
|
|
36375
|
+
function unicodeToArray(string) {
|
|
36376
|
+
return string.match(reUnicode) || [];
|
|
36377
|
+
}
|
|
36378
|
+
var _unicodeToArray_default = unicodeToArray;
|
|
36379
|
+
|
|
36380
|
+
// node_modules/lodash-es/_stringToArray.js
|
|
36381
|
+
function stringToArray(string) {
|
|
36382
|
+
return _hasUnicode_default(string) ? _unicodeToArray_default(string) : _asciiToArray_default(string);
|
|
36383
|
+
}
|
|
36384
|
+
var _stringToArray_default = stringToArray;
|
|
36385
|
+
|
|
36326
36386
|
// node_modules/lodash-es/_arrayReduce.js
|
|
36327
36387
|
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
|
36328
36388
|
var index = -1, length = array == null ? 0 : array.length;
|
|
@@ -37610,11 +37670,17 @@ function isNil(value) {
|
|
|
37610
37670
|
return value == null;
|
|
37611
37671
|
}
|
|
37612
37672
|
var isNil_default = isNil;
|
|
37613
|
-
// node_modules/lodash-es/
|
|
37614
|
-
|
|
37615
|
-
|
|
37673
|
+
// node_modules/lodash-es/_baseIsRegExp.js
|
|
37674
|
+
var regexpTag5 = "[object RegExp]";
|
|
37675
|
+
function baseIsRegExp(value) {
|
|
37676
|
+
return isObjectLike_default(value) && _baseGetTag_default(value) == regexpTag5;
|
|
37616
37677
|
}
|
|
37617
|
-
var
|
|
37678
|
+
var _baseIsRegExp_default = baseIsRegExp;
|
|
37679
|
+
|
|
37680
|
+
// node_modules/lodash-es/isRegExp.js
|
|
37681
|
+
var nodeIsRegExp = _nodeUtil_default && _nodeUtil_default.isRegExp;
|
|
37682
|
+
var isRegExp = nodeIsRegExp ? _baseUnary_default(nodeIsRegExp) : _baseIsRegExp_default;
|
|
37683
|
+
var isRegExp_default = isRegExp;
|
|
37618
37684
|
// node_modules/lodash-es/join.js
|
|
37619
37685
|
var arrayProto2 = Array.prototype;
|
|
37620
37686
|
var nativeJoin = arrayProto2.join;
|
|
@@ -37881,12 +37947,6 @@ function repeat(string, n, guard) {
|
|
|
37881
37947
|
return _baseRepeat_default(toString_default(string), n);
|
|
37882
37948
|
}
|
|
37883
37949
|
var repeat_default = repeat;
|
|
37884
|
-
// node_modules/lodash-es/replace.js
|
|
37885
|
-
function replace() {
|
|
37886
|
-
var args = arguments, string = toString_default(args[0]);
|
|
37887
|
-
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
|
37888
|
-
}
|
|
37889
|
-
var replace_default = replace;
|
|
37890
37950
|
// node_modules/lodash-es/set.js
|
|
37891
37951
|
function set(object, path, value) {
|
|
37892
37952
|
return object == null ? object : _baseSet_default(object, path, value);
|
|
@@ -37906,6 +37966,55 @@ var sortBy = _baseRest_default(function(collection, iteratees) {
|
|
|
37906
37966
|
return _baseOrderBy_default(collection, _baseFlatten_default(iteratees, 1), []);
|
|
37907
37967
|
});
|
|
37908
37968
|
var sortBy_default = sortBy;
|
|
37969
|
+
// node_modules/lodash-es/split.js
|
|
37970
|
+
var MAX_ARRAY_LENGTH = 4294967295;
|
|
37971
|
+
function split(string, separator, limit) {
|
|
37972
|
+
if (limit && typeof limit != "number" && _isIterateeCall_default(string, separator, limit)) {
|
|
37973
|
+
separator = limit = undefined;
|
|
37974
|
+
}
|
|
37975
|
+
limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
|
|
37976
|
+
if (!limit) {
|
|
37977
|
+
return [];
|
|
37978
|
+
}
|
|
37979
|
+
string = toString_default(string);
|
|
37980
|
+
if (string && (typeof separator == "string" || separator != null && !isRegExp_default(separator))) {
|
|
37981
|
+
separator = _baseToString_default(separator);
|
|
37982
|
+
if (!separator && _hasUnicode_default(string)) {
|
|
37983
|
+
return _castSlice_default(_stringToArray_default(string), 0, limit);
|
|
37984
|
+
}
|
|
37985
|
+
}
|
|
37986
|
+
return string.split(separator, limit);
|
|
37987
|
+
}
|
|
37988
|
+
var split_default = split;
|
|
37989
|
+
// node_modules/lodash-es/_charsEndIndex.js
|
|
37990
|
+
function charsEndIndex(strSymbols, chrSymbols) {
|
|
37991
|
+
var index = strSymbols.length;
|
|
37992
|
+
while (index-- && _baseIndexOf_default(chrSymbols, strSymbols[index], 0) > -1) {}
|
|
37993
|
+
return index;
|
|
37994
|
+
}
|
|
37995
|
+
var _charsEndIndex_default = charsEndIndex;
|
|
37996
|
+
|
|
37997
|
+
// node_modules/lodash-es/_charsStartIndex.js
|
|
37998
|
+
function charsStartIndex(strSymbols, chrSymbols) {
|
|
37999
|
+
var index = -1, length = strSymbols.length;
|
|
38000
|
+
while (++index < length && _baseIndexOf_default(chrSymbols, strSymbols[index], 0) > -1) {}
|
|
38001
|
+
return index;
|
|
38002
|
+
}
|
|
38003
|
+
var _charsStartIndex_default = charsStartIndex;
|
|
38004
|
+
|
|
38005
|
+
// node_modules/lodash-es/trim.js
|
|
38006
|
+
function trim(string, chars, guard) {
|
|
38007
|
+
string = toString_default(string);
|
|
38008
|
+
if (string && (guard || chars === undefined)) {
|
|
38009
|
+
return _baseTrim_default(string);
|
|
38010
|
+
}
|
|
38011
|
+
if (!string || !(chars = _baseToString_default(chars))) {
|
|
38012
|
+
return string;
|
|
38013
|
+
}
|
|
38014
|
+
var strSymbols = _stringToArray_default(string), chrSymbols = _stringToArray_default(chars), start = _charsStartIndex_default(strSymbols, chrSymbols), end = _charsEndIndex_default(strSymbols, chrSymbols) + 1;
|
|
38015
|
+
return _castSlice_default(strSymbols, start, end).join("");
|
|
38016
|
+
}
|
|
38017
|
+
var trim_default = trim;
|
|
37909
38018
|
// src/functions/base64decode.ts
|
|
37910
38019
|
function base64decode(base64, urlSafe = false) {
|
|
37911
38020
|
if (urlSafe) {
|
|
@@ -45533,7 +45642,7 @@ var formatPlainText = (x) => {
|
|
|
45533
45642
|
return textToReturn;
|
|
45534
45643
|
}
|
|
45535
45644
|
};
|
|
45536
|
-
var convertNotionToMd = function(block3, level = 1) {
|
|
45645
|
+
var convertNotionToMd = function(block3, level = 1, linkChildPages = false) {
|
|
45537
45646
|
const n = `
|
|
45538
45647
|
|
|
45539
45648
|
`;
|
|
@@ -45545,16 +45654,16 @@ var convertNotionToMd = function(block3, level = 1) {
|
|
|
45545
45654
|
case "bookmark":
|
|
45546
45655
|
return `[${data.url}](data.url)${n}`;
|
|
45547
45656
|
case "bulleted_list_item":
|
|
45548
|
-
childData = map_default(block3.children, (child) => convertNotionToMd(child, level + 1))
|
|
45549
|
-
return `- ${plainText
|
|
45657
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level + 1, linkChildPages)), repeat_default("\t", level));
|
|
45658
|
+
return `- ${join_default(plainText, "")}
|
|
45550
45659
|
` + (childData ? `${repeat_default("\t", level)}${childData}` : "");
|
|
45551
45660
|
case "numbered_list_item":
|
|
45552
|
-
childData = map_default(block3.children, (child) => convertNotionToMd(child, level + 1))
|
|
45553
|
-
return `${block3.number}. ${plainText
|
|
45661
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level + 1, linkChildPages)), repeat_default("\t", level));
|
|
45662
|
+
return `${block3.number}. ${join_default(plainText, "")}
|
|
45554
45663
|
` + (childData ? `${repeat_default("\t", level)}${childData}` : "");
|
|
45555
45664
|
case "quote":
|
|
45556
45665
|
case "callout":
|
|
45557
|
-
return `> ${plainText
|
|
45666
|
+
return `> ${join_default(plainText, "")}${n}`;
|
|
45558
45667
|
case "code":
|
|
45559
45668
|
return `\`\`\`${data.language}
|
|
45560
45669
|
${plainText}
|
|
@@ -45566,51 +45675,60 @@ ${plainText}
|
|
|
45566
45675
|
case "equation":
|
|
45567
45676
|
return data.expression;
|
|
45568
45677
|
case "paragraph":
|
|
45569
|
-
return plainText
|
|
45678
|
+
return join_default(plainText, "") + n;
|
|
45570
45679
|
case "video":
|
|
45571
45680
|
case "pdf":
|
|
45572
45681
|
case "file":
|
|
45573
45682
|
return `[${caption.length ? caption : "File"}](${data.file ? data.file.url : data.external ? data.external.url : ""})${n}`;
|
|
45574
45683
|
case "heading_1":
|
|
45575
|
-
return `# ${plainText
|
|
45684
|
+
return `# ${join_default(plainText, "")}${n}`;
|
|
45576
45685
|
case "heading_2":
|
|
45577
|
-
return `## ${plainText
|
|
45686
|
+
return `## ${join_default(plainText, "")}${n}`;
|
|
45578
45687
|
case "heading_3":
|
|
45579
|
-
return `### ${plainText
|
|
45688
|
+
return `### ${join_default(plainText, "")}${n}`;
|
|
45580
45689
|
case "heading_4":
|
|
45581
|
-
return `#### ${plainText
|
|
45690
|
+
return `#### ${join_default(plainText, "")}${n}`;
|
|
45582
45691
|
case "heading_5":
|
|
45583
|
-
return `##### ${plainText
|
|
45692
|
+
return `##### ${join_default(plainText, "")}${n}`;
|
|
45584
45693
|
case "heading_6":
|
|
45585
|
-
return `###### ${plainText
|
|
45694
|
+
return `###### ${join_default(plainText, "")}${n}`;
|
|
45586
45695
|
case "image":
|
|
45587
45696
|
return `${n}`;
|
|
45697
|
+
case "child_page":
|
|
45698
|
+
if (linkChildPages) {
|
|
45699
|
+
const pageTitle = data.title || "Untitled Page";
|
|
45700
|
+
const pageUrl = `https://www.notion.so/${block3.id.replace(/-/g, "")}`;
|
|
45701
|
+
return `[${pageTitle}](${pageUrl})${n}`;
|
|
45702
|
+
} else {
|
|
45703
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level, linkChildPages)), "");
|
|
45704
|
+
return (data.title || "Untitled Page") + n + childData;
|
|
45705
|
+
}
|
|
45588
45706
|
case "table":
|
|
45589
45707
|
if (block3.children) {
|
|
45590
45708
|
const firstChild = block3.children[0];
|
|
45591
45709
|
const remainingChildren = block3.children.slice(1);
|
|
45592
|
-
const header = `| ${firstChild.table_row.cells.map((x) => x.map((y) => formatPlainText(y))
|
|
45710
|
+
const header = `| ${join_default(firstChild.table_row.cells.map((x) => join_default(x.map((y) => formatPlainText(y)), "")), " | ")} |
|
|
45593
45711
|
`;
|
|
45594
45712
|
const divider = `|${repeat_default("---|", data.table_width)}
|
|
45595
45713
|
`;
|
|
45596
|
-
const rows = remainingChildren.map((row) => {
|
|
45597
|
-
return `| ${row.table_row.cells.map((x) => x.map((y) => formatPlainText(y))
|
|
45598
|
-
})
|
|
45714
|
+
const rows = join_default(remainingChildren.map((row) => {
|
|
45715
|
+
return `| ${join_default(row.table_row.cells.map((x) => join_default(x.map((y) => formatPlainText(y)), "")), " | ")} |`;
|
|
45716
|
+
}), `
|
|
45599
45717
|
`);
|
|
45600
45718
|
return `${header}${divider}${rows}${n}`;
|
|
45601
45719
|
}
|
|
45602
45720
|
return `Table as CSV
|
|
45603
45721
|
`;
|
|
45604
45722
|
case "table_row":
|
|
45605
|
-
return `| ${data.cells.map((x) => x.map((y) => formatPlainText(y))
|
|
45723
|
+
return `| ${join_default(data.cells.map((x) => join_default(x.map((y) => formatPlainText(y)), "")), " | ")} |
|
|
45606
45724
|
`;
|
|
45607
45725
|
case "to_do":
|
|
45608
|
-
childData = map_default(block3.children, (child) => convertNotionToMd(child, level + 1))
|
|
45609
|
-
return `- [${data.checked ? "X" : " "}] ${plainText
|
|
45726
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level + 1, linkChildPages)), repeat_default("\t", level));
|
|
45727
|
+
return `- [${data.checked ? "X" : " "}] ${join_default(plainText, "")}
|
|
45610
45728
|
` + (childData ? `${repeat_default("\t", level)}${childData}` : "");
|
|
45611
45729
|
default:
|
|
45612
|
-
childData = map_default(block3.children, (child) => convertNotionToMd(child))
|
|
45613
|
-
return plainText
|
|
45730
|
+
childData = join_default(map_default(block3.children, (child) => convertNotionToMd(child, level, linkChildPages)), "");
|
|
45731
|
+
return join_default(plainText, "") + n + childData;
|
|
45614
45732
|
}
|
|
45615
45733
|
};
|
|
45616
45734
|
var resolveChildren = function(block3, blocks) {
|
|
@@ -45660,13 +45778,13 @@ var insertNewLinesBetweenLists = function(blocks) {
|
|
|
45660
45778
|
return block3;
|
|
45661
45779
|
}));
|
|
45662
45780
|
};
|
|
45663
|
-
var convertNotionToMarkdown = function(blocks) {
|
|
45781
|
+
var convertNotionToMarkdown = function(blocks, linkChildPages = false) {
|
|
45664
45782
|
const arrayBlocks = insertNewLinesBetweenLists(castArray_default(blocks));
|
|
45665
45783
|
const parentBlocks = reject_default(arrayBlocks, (block3) => block3.parent?.type === "block_id");
|
|
45666
45784
|
const blocksWithChildren = numberOrderedLists(parentBlocks.map((block3) => {
|
|
45667
45785
|
return resolveChildren(block3, arrayBlocks);
|
|
45668
45786
|
}));
|
|
45669
|
-
return blocksWithChildren.map((block3) => convertNotionToMd(block3))
|
|
45787
|
+
return join_default(blocksWithChildren.map((block3) => convertNotionToMd(block3, 1, linkChildPages)), "");
|
|
45670
45788
|
};
|
|
45671
45789
|
var convertNotionToMarkdown_default = convertNotionToMarkdown;
|
|
45672
45790
|
|
|
@@ -55277,17 +55395,17 @@ function stringify(obj, replacer, spacer, options3) {
|
|
|
55277
55395
|
return res;
|
|
55278
55396
|
}
|
|
55279
55397
|
}
|
|
55280
|
-
function setReplace(
|
|
55398
|
+
function setReplace(replace, val, k, parent2) {
|
|
55281
55399
|
var propertyDescriptor = Object.getOwnPropertyDescriptor(parent2, k);
|
|
55282
55400
|
if (propertyDescriptor.get !== undefined) {
|
|
55283
55401
|
if (propertyDescriptor.configurable) {
|
|
55284
|
-
Object.defineProperty(parent2, k, { value:
|
|
55402
|
+
Object.defineProperty(parent2, k, { value: replace });
|
|
55285
55403
|
arr.push([parent2, k, val, propertyDescriptor]);
|
|
55286
55404
|
} else {
|
|
55287
|
-
replacerStack.push([val, k,
|
|
55405
|
+
replacerStack.push([val, k, replace]);
|
|
55288
55406
|
}
|
|
55289
55407
|
} else {
|
|
55290
|
-
parent2[k] =
|
|
55408
|
+
parent2[k] = replace;
|
|
55291
55409
|
arr.push([parent2, k, val]);
|
|
55292
55410
|
}
|
|
55293
55411
|
}
|
|
@@ -56959,7 +57077,7 @@ Message: ${result.detail.join(`
|
|
|
56959
57077
|
const result = await response.json();
|
|
56960
57078
|
return result["examples"];
|
|
56961
57079
|
}
|
|
56962
|
-
async createExample(inputs, outputs, { datasetId, datasetName, createdAt, exampleId, metadata, split, sourceRunId }) {
|
|
57080
|
+
async createExample(inputs, outputs, { datasetId, datasetName, createdAt, exampleId, metadata, split: split2, sourceRunId }) {
|
|
56963
57081
|
let datasetId_ = datasetId;
|
|
56964
57082
|
if (datasetId_ === undefined && datasetName === undefined) {
|
|
56965
57083
|
throw new Error("Must provide either datasetName or datasetId");
|
|
@@ -56977,7 +57095,7 @@ Message: ${result.detail.join(`
|
|
|
56977
57095
|
created_at: createdAt_?.toISOString(),
|
|
56978
57096
|
id: exampleId,
|
|
56979
57097
|
metadata,
|
|
56980
|
-
split,
|
|
57098
|
+
split: split2,
|
|
56981
57099
|
source_run_id: sourceRunId
|
|
56982
57100
|
};
|
|
56983
57101
|
const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/examples`, {
|
|
@@ -57079,8 +57197,8 @@ Message: ${result.detail.join(`
|
|
|
57079
57197
|
}
|
|
57080
57198
|
}
|
|
57081
57199
|
if (splits !== undefined) {
|
|
57082
|
-
for (const
|
|
57083
|
-
params.append("splits",
|
|
57200
|
+
for (const split2 of splits) {
|
|
57201
|
+
params.append("splits", split2);
|
|
57084
57202
|
}
|
|
57085
57203
|
}
|
|
57086
57204
|
if (metadata !== undefined) {
|
|
@@ -67117,17 +67235,45 @@ var removeEmptyItems_default = removeEmptyItems;
|
|
|
67117
67235
|
|
|
67118
67236
|
// src/functions/sign.ts
|
|
67119
67237
|
var sign = async (text, algorithm = "SHA-256", secret, outputFormat = "hex") => {
|
|
67120
|
-
const
|
|
67238
|
+
const upperAlg = String(algorithm ?? "").trim().toUpperCase();
|
|
67121
67239
|
const encoder = new TextEncoder;
|
|
67122
67240
|
const data = encoder.encode(text);
|
|
67123
|
-
|
|
67241
|
+
let signatureBuffer;
|
|
67242
|
+
if (upperAlg === "RS256") {
|
|
67243
|
+
const pemKey = secret?.includes("\\n") ? secret.replace(/\\n/g, `
|
|
67244
|
+
`) : secret;
|
|
67245
|
+
if (!pemKey || !/-----BEGIN PRIVATE KEY-----/.test(pemKey)) {
|
|
67246
|
+
throw new Error("RS256 requires a PKCS#8 PEM private key (BEGIN PRIVATE KEY)");
|
|
67247
|
+
}
|
|
67248
|
+
const keyDataBase64 = pemKey.replace(/-----BEGIN PRIVATE KEY-----/, "").replace(/-----END PRIVATE KEY-----/, "").replace(/\s/g, "");
|
|
67249
|
+
const binaryKey = Uint8Array.from(atob(keyDataBase64), (c) => c.charCodeAt(0));
|
|
67250
|
+
const rsaAlgorithm = {
|
|
67251
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
67252
|
+
hash: { name: "SHA-256" }
|
|
67253
|
+
};
|
|
67254
|
+
let key;
|
|
67255
|
+
try {
|
|
67256
|
+
key = await crypto.subtle.importKey("pkcs8", binaryKey, rsaAlgorithm, false, ["sign"]);
|
|
67257
|
+
} catch (e) {
|
|
67258
|
+
throw new Error(`RS256 key import failed. Ensure an unencrypted PKCS#8 PEM (BEGIN PRIVATE KEY). Underlying: ${e?.message || e}`);
|
|
67259
|
+
}
|
|
67260
|
+
try {
|
|
67261
|
+
signatureBuffer = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", key, data);
|
|
67262
|
+
} catch (e) {
|
|
67263
|
+
throw new Error(`RS256 signing failed. Ensure the key matches RSASSA-PKCS1-v1_5 and data is correctly encoded. Underlying: ${e?.message || e}`);
|
|
67264
|
+
}
|
|
67265
|
+
} else {
|
|
67266
|
+
const hmacHash = upperAlg || "SHA-256";
|
|
67267
|
+
const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: { name: hmacHash } }, false, ["sign"]);
|
|
67268
|
+
signatureBuffer = await crypto.subtle.sign("HMAC", key, data);
|
|
67269
|
+
}
|
|
67124
67270
|
if (outputFormat === "hex") {
|
|
67125
|
-
const
|
|
67126
|
-
return
|
|
67271
|
+
const bytes = Array.from(new Uint8Array(signatureBuffer));
|
|
67272
|
+
return bytes.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
67127
67273
|
} else if (outputFormat === "base64") {
|
|
67128
|
-
return arrayBufferToBase64(
|
|
67274
|
+
return arrayBufferToBase64(signatureBuffer);
|
|
67129
67275
|
} else if (outputFormat === "base64-urlSafe") {
|
|
67130
|
-
return arrayBufferToBase64(
|
|
67276
|
+
return arrayBufferToBase64(signatureBuffer, true);
|
|
67131
67277
|
}
|
|
67132
67278
|
};
|
|
67133
67279
|
var sign_default = sign;
|
|
@@ -67214,1248 +67360,93 @@ function zipSqlResponse(columns, data, key) {
|
|
|
67214
67360
|
}
|
|
67215
67361
|
var zipSqlResponse_default = zipSqlResponse;
|
|
67216
67362
|
|
|
67217
|
-
//
|
|
67218
|
-
|
|
67219
|
-
|
|
67220
|
-
|
|
67221
|
-
|
|
67222
|
-
|
|
67223
|
-
|
|
67224
|
-
|
|
67225
|
-
for (const buffer of buffers) {
|
|
67226
|
-
buf.set(buffer, i3);
|
|
67227
|
-
i3 += buffer.length;
|
|
67228
|
-
}
|
|
67229
|
-
return buf;
|
|
67230
|
-
}
|
|
67231
|
-
|
|
67232
|
-
// node_modules/jose/dist/webapi/lib/base64.js
|
|
67233
|
-
function encodeBase64(input) {
|
|
67234
|
-
if (Uint8Array.prototype.toBase64) {
|
|
67235
|
-
return input.toBase64();
|
|
67236
|
-
}
|
|
67237
|
-
const CHUNK_SIZE = 32768;
|
|
67238
|
-
const arr2 = [];
|
|
67239
|
-
for (let i3 = 0;i3 < input.length; i3 += CHUNK_SIZE) {
|
|
67240
|
-
arr2.push(String.fromCharCode.apply(null, input.subarray(i3, i3 + CHUNK_SIZE)));
|
|
67241
|
-
}
|
|
67242
|
-
return btoa(arr2.join(""));
|
|
67243
|
-
}
|
|
67244
|
-
function decodeBase64(encoded) {
|
|
67245
|
-
if (Uint8Array.fromBase64) {
|
|
67246
|
-
return Uint8Array.fromBase64(encoded);
|
|
67247
|
-
}
|
|
67248
|
-
const binary = atob(encoded);
|
|
67249
|
-
const bytes = new Uint8Array(binary.length);
|
|
67250
|
-
for (let i3 = 0;i3 < binary.length; i3++) {
|
|
67251
|
-
bytes[i3] = binary.charCodeAt(i3);
|
|
67252
|
-
}
|
|
67253
|
-
return bytes;
|
|
67254
|
-
}
|
|
67255
|
-
|
|
67256
|
-
// node_modules/jose/dist/webapi/util/base64url.js
|
|
67257
|
-
function decode(input) {
|
|
67258
|
-
if (Uint8Array.fromBase64) {
|
|
67259
|
-
return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), {
|
|
67260
|
-
alphabet: "base64url"
|
|
67261
|
-
});
|
|
67262
|
-
}
|
|
67263
|
-
let encoded = input;
|
|
67264
|
-
if (encoded instanceof Uint8Array) {
|
|
67265
|
-
encoded = decoder.decode(encoded);
|
|
67266
|
-
}
|
|
67267
|
-
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
67268
|
-
try {
|
|
67269
|
-
return decodeBase64(encoded);
|
|
67270
|
-
} catch {
|
|
67271
|
-
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
67272
|
-
}
|
|
67273
|
-
}
|
|
67274
|
-
function encode(input) {
|
|
67275
|
-
let unencoded = input;
|
|
67276
|
-
if (typeof unencoded === "string") {
|
|
67277
|
-
unencoded = encoder.encode(unencoded);
|
|
67278
|
-
}
|
|
67279
|
-
if (Uint8Array.prototype.toBase64) {
|
|
67280
|
-
return unencoded.toBase64({ alphabet: "base64url", omitPadding: true });
|
|
67281
|
-
}
|
|
67282
|
-
return encodeBase64(unencoded).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
67283
|
-
}
|
|
67284
|
-
|
|
67285
|
-
// node_modules/jose/dist/webapi/util/errors.js
|
|
67286
|
-
class JOSEError extends Error {
|
|
67287
|
-
static code = "ERR_JOSE_GENERIC";
|
|
67288
|
-
code = "ERR_JOSE_GENERIC";
|
|
67289
|
-
constructor(message, options3) {
|
|
67290
|
-
super(message, options3);
|
|
67291
|
-
this.name = this.constructor.name;
|
|
67292
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
67293
|
-
}
|
|
67294
|
-
}
|
|
67295
|
-
class JOSENotSupported extends JOSEError {
|
|
67296
|
-
static code = "ERR_JOSE_NOT_SUPPORTED";
|
|
67297
|
-
code = "ERR_JOSE_NOT_SUPPORTED";
|
|
67298
|
-
}
|
|
67299
|
-
class JWSInvalid extends JOSEError {
|
|
67300
|
-
static code = "ERR_JWS_INVALID";
|
|
67301
|
-
code = "ERR_JWS_INVALID";
|
|
67302
|
-
}
|
|
67303
|
-
|
|
67304
|
-
class JWTInvalid extends JOSEError {
|
|
67305
|
-
static code = "ERR_JWT_INVALID";
|
|
67306
|
-
code = "ERR_JWT_INVALID";
|
|
67307
|
-
}
|
|
67308
|
-
|
|
67309
|
-
// node_modules/jose/dist/webapi/lib/crypto_key.js
|
|
67310
|
-
function unusable(name, prop = "algorithm.name") {
|
|
67311
|
-
return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
67312
|
-
}
|
|
67313
|
-
function isAlgorithm(algorithm, name) {
|
|
67314
|
-
return algorithm.name === name;
|
|
67315
|
-
}
|
|
67316
|
-
function getHashLength(hash) {
|
|
67317
|
-
return parseInt(hash.name.slice(4), 10);
|
|
67318
|
-
}
|
|
67319
|
-
function getNamedCurve(alg) {
|
|
67320
|
-
switch (alg) {
|
|
67321
|
-
case "ES256":
|
|
67322
|
-
return "P-256";
|
|
67323
|
-
case "ES384":
|
|
67324
|
-
return "P-384";
|
|
67325
|
-
case "ES512":
|
|
67326
|
-
return "P-521";
|
|
67327
|
-
default:
|
|
67328
|
-
throw new Error("unreachable");
|
|
67329
|
-
}
|
|
67330
|
-
}
|
|
67331
|
-
function checkUsage(key, usage) {
|
|
67332
|
-
if (usage && !key.usages.includes(usage)) {
|
|
67333
|
-
throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
67334
|
-
}
|
|
67335
|
-
}
|
|
67336
|
-
function checkSigCryptoKey(key, alg, usage) {
|
|
67337
|
-
switch (alg) {
|
|
67338
|
-
case "HS256":
|
|
67339
|
-
case "HS384":
|
|
67340
|
-
case "HS512": {
|
|
67341
|
-
if (!isAlgorithm(key.algorithm, "HMAC"))
|
|
67342
|
-
throw unusable("HMAC");
|
|
67343
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
67344
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
67345
|
-
if (actual !== expected)
|
|
67346
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
67347
|
-
break;
|
|
67348
|
-
}
|
|
67349
|
-
case "RS256":
|
|
67350
|
-
case "RS384":
|
|
67351
|
-
case "RS512": {
|
|
67352
|
-
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
67353
|
-
throw unusable("RSASSA-PKCS1-v1_5");
|
|
67354
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
67355
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
67356
|
-
if (actual !== expected)
|
|
67357
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
67358
|
-
break;
|
|
67359
|
-
}
|
|
67360
|
-
case "PS256":
|
|
67361
|
-
case "PS384":
|
|
67362
|
-
case "PS512": {
|
|
67363
|
-
if (!isAlgorithm(key.algorithm, "RSA-PSS"))
|
|
67364
|
-
throw unusable("RSA-PSS");
|
|
67365
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
67366
|
-
const actual = getHashLength(key.algorithm.hash);
|
|
67367
|
-
if (actual !== expected)
|
|
67368
|
-
throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
67369
|
-
break;
|
|
67370
|
-
}
|
|
67371
|
-
case "Ed25519":
|
|
67372
|
-
case "EdDSA": {
|
|
67373
|
-
if (!isAlgorithm(key.algorithm, "Ed25519"))
|
|
67374
|
-
throw unusable("Ed25519");
|
|
67375
|
-
break;
|
|
67376
|
-
}
|
|
67377
|
-
case "ML-DSA-44":
|
|
67378
|
-
case "ML-DSA-65":
|
|
67379
|
-
case "ML-DSA-87": {
|
|
67380
|
-
if (!isAlgorithm(key.algorithm, alg))
|
|
67381
|
-
throw unusable(alg);
|
|
67382
|
-
break;
|
|
67383
|
-
}
|
|
67384
|
-
case "ES256":
|
|
67385
|
-
case "ES384":
|
|
67386
|
-
case "ES512": {
|
|
67387
|
-
if (!isAlgorithm(key.algorithm, "ECDSA"))
|
|
67388
|
-
throw unusable("ECDSA");
|
|
67389
|
-
const expected = getNamedCurve(alg);
|
|
67390
|
-
const actual = key.algorithm.namedCurve;
|
|
67391
|
-
if (actual !== expected)
|
|
67392
|
-
throw unusable(expected, "algorithm.namedCurve");
|
|
67393
|
-
break;
|
|
67394
|
-
}
|
|
67395
|
-
default:
|
|
67396
|
-
throw new TypeError("CryptoKey does not support this operation");
|
|
67397
|
-
}
|
|
67398
|
-
checkUsage(key, usage);
|
|
67399
|
-
}
|
|
67400
|
-
|
|
67401
|
-
// node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
67402
|
-
function message(msg, actual, ...types3) {
|
|
67403
|
-
types3 = types3.filter(Boolean);
|
|
67404
|
-
if (types3.length > 2) {
|
|
67405
|
-
const last2 = types3.pop();
|
|
67406
|
-
msg += `one of type ${types3.join(", ")}, or ${last2}.`;
|
|
67407
|
-
} else if (types3.length === 2) {
|
|
67408
|
-
msg += `one of type ${types3[0]} or ${types3[1]}.`;
|
|
67409
|
-
} else {
|
|
67410
|
-
msg += `of type ${types3[0]}.`;
|
|
67411
|
-
}
|
|
67412
|
-
if (actual == null) {
|
|
67413
|
-
msg += ` Received ${actual}`;
|
|
67414
|
-
} else if (typeof actual === "function" && actual.name) {
|
|
67415
|
-
msg += ` Received function ${actual.name}`;
|
|
67416
|
-
} else if (typeof actual === "object" && actual != null) {
|
|
67417
|
-
if (actual.constructor?.name) {
|
|
67418
|
-
msg += ` Received an instance of ${actual.constructor.name}`;
|
|
67419
|
-
}
|
|
67420
|
-
}
|
|
67421
|
-
return msg;
|
|
67422
|
-
}
|
|
67423
|
-
var invalid_key_input_default = (actual, ...types3) => {
|
|
67424
|
-
return message("Key must be ", actual, ...types3);
|
|
67425
|
-
};
|
|
67426
|
-
function withAlg(alg, actual, ...types3) {
|
|
67427
|
-
return message(`Key for the ${alg} algorithm must be `, actual, ...types3);
|
|
67428
|
-
}
|
|
67429
|
-
|
|
67430
|
-
// node_modules/jose/dist/webapi/lib/is_key_like.js
|
|
67431
|
-
function isCryptoKey(key) {
|
|
67432
|
-
return key?.[Symbol.toStringTag] === "CryptoKey";
|
|
67433
|
-
}
|
|
67434
|
-
function isKeyObject(key) {
|
|
67435
|
-
return key?.[Symbol.toStringTag] === "KeyObject";
|
|
67436
|
-
}
|
|
67437
|
-
var is_key_like_default = (key) => {
|
|
67438
|
-
return isCryptoKey(key) || isKeyObject(key);
|
|
67439
|
-
};
|
|
67440
|
-
|
|
67441
|
-
// node_modules/jose/dist/webapi/lib/is_disjoint.js
|
|
67442
|
-
var is_disjoint_default = (...headers) => {
|
|
67443
|
-
const sources = headers.filter(Boolean);
|
|
67444
|
-
if (sources.length === 0 || sources.length === 1) {
|
|
67445
|
-
return true;
|
|
67446
|
-
}
|
|
67447
|
-
let acc;
|
|
67448
|
-
for (const header of sources) {
|
|
67449
|
-
const parameters = Object.keys(header);
|
|
67450
|
-
if (!acc || acc.size === 0) {
|
|
67451
|
-
acc = new Set(parameters);
|
|
67452
|
-
continue;
|
|
67453
|
-
}
|
|
67454
|
-
for (const parameter of parameters) {
|
|
67455
|
-
if (acc.has(parameter)) {
|
|
67456
|
-
return false;
|
|
67457
|
-
}
|
|
67458
|
-
acc.add(parameter);
|
|
67459
|
-
}
|
|
67460
|
-
}
|
|
67461
|
-
return true;
|
|
67462
|
-
};
|
|
67463
|
-
|
|
67464
|
-
// node_modules/jose/dist/webapi/lib/is_object.js
|
|
67465
|
-
function isObjectLike2(value) {
|
|
67466
|
-
return typeof value === "object" && value !== null;
|
|
67467
|
-
}
|
|
67468
|
-
var is_object_default = (input) => {
|
|
67469
|
-
if (!isObjectLike2(input) || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
67470
|
-
return false;
|
|
67471
|
-
}
|
|
67472
|
-
if (Object.getPrototypeOf(input) === null) {
|
|
67473
|
-
return true;
|
|
67474
|
-
}
|
|
67475
|
-
let proto = input;
|
|
67476
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
67477
|
-
proto = Object.getPrototypeOf(proto);
|
|
67478
|
-
}
|
|
67479
|
-
return Object.getPrototypeOf(input) === proto;
|
|
67480
|
-
};
|
|
67481
|
-
|
|
67482
|
-
// node_modules/jose/dist/webapi/lib/check_key_length.js
|
|
67483
|
-
var check_key_length_default = (alg, key) => {
|
|
67484
|
-
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
67485
|
-
const { modulusLength } = key.algorithm;
|
|
67486
|
-
if (typeof modulusLength !== "number" || modulusLength < 2048) {
|
|
67487
|
-
throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
67488
|
-
}
|
|
67489
|
-
}
|
|
67490
|
-
};
|
|
67491
|
-
|
|
67492
|
-
// node_modules/jose/dist/webapi/lib/asn1.js
|
|
67493
|
-
var bytesEqual = (a, b) => {
|
|
67494
|
-
if (a.byteLength !== b.length)
|
|
67495
|
-
return false;
|
|
67496
|
-
for (let i3 = 0;i3 < a.byteLength; i3++) {
|
|
67497
|
-
if (a[i3] !== b[i3])
|
|
67498
|
-
return false;
|
|
67499
|
-
}
|
|
67500
|
-
return true;
|
|
67501
|
-
};
|
|
67502
|
-
var createASN1State = (data) => ({ data, pos: 0 });
|
|
67503
|
-
var parseLength = (state) => {
|
|
67504
|
-
const first = state.data[state.pos++];
|
|
67505
|
-
if (first & 128) {
|
|
67506
|
-
const lengthOfLen = first & 127;
|
|
67507
|
-
let length = 0;
|
|
67508
|
-
for (let i3 = 0;i3 < lengthOfLen; i3++) {
|
|
67509
|
-
length = length << 8 | state.data[state.pos++];
|
|
67510
|
-
}
|
|
67511
|
-
return length;
|
|
67512
|
-
}
|
|
67513
|
-
return first;
|
|
67514
|
-
};
|
|
67515
|
-
var expectTag = (state, expectedTag, errorMessage) => {
|
|
67516
|
-
if (state.data[state.pos++] !== expectedTag) {
|
|
67517
|
-
throw new Error(errorMessage);
|
|
67518
|
-
}
|
|
67519
|
-
};
|
|
67520
|
-
var getSubarray = (state, length) => {
|
|
67521
|
-
const result = state.data.subarray(state.pos, state.pos + length);
|
|
67522
|
-
state.pos += length;
|
|
67523
|
-
return result;
|
|
67524
|
-
};
|
|
67525
|
-
var parseAlgorithmOID = (state) => {
|
|
67526
|
-
expectTag(state, 6, "Expected algorithm OID");
|
|
67527
|
-
const oidLen = parseLength(state);
|
|
67528
|
-
return getSubarray(state, oidLen);
|
|
67529
|
-
};
|
|
67530
|
-
function parsePKCS8Header(state) {
|
|
67531
|
-
expectTag(state, 48, "Invalid PKCS#8 structure");
|
|
67532
|
-
parseLength(state);
|
|
67533
|
-
expectTag(state, 2, "Expected version field");
|
|
67534
|
-
const verLen = parseLength(state);
|
|
67535
|
-
state.pos += verLen;
|
|
67536
|
-
expectTag(state, 48, "Expected algorithm identifier");
|
|
67537
|
-
const algIdLen = parseLength(state);
|
|
67538
|
-
const algIdStart = state.pos;
|
|
67539
|
-
return { algIdStart, algIdLength: algIdLen };
|
|
67540
|
-
}
|
|
67541
|
-
var parseECAlgorithmIdentifier = (state) => {
|
|
67542
|
-
const algOid = parseAlgorithmOID(state);
|
|
67543
|
-
if (bytesEqual(algOid, [43, 101, 110])) {
|
|
67544
|
-
return "X25519";
|
|
67545
|
-
}
|
|
67546
|
-
if (!bytesEqual(algOid, [42, 134, 72, 206, 61, 2, 1])) {
|
|
67547
|
-
throw new Error("Unsupported key algorithm");
|
|
67548
|
-
}
|
|
67549
|
-
expectTag(state, 6, "Expected curve OID");
|
|
67550
|
-
const curveOidLen = parseLength(state);
|
|
67551
|
-
const curveOid = getSubarray(state, curveOidLen);
|
|
67552
|
-
for (const { name, oid } of [
|
|
67553
|
-
{ name: "P-256", oid: [42, 134, 72, 206, 61, 3, 1, 7] },
|
|
67554
|
-
{ name: "P-384", oid: [43, 129, 4, 0, 34] },
|
|
67555
|
-
{ name: "P-521", oid: [43, 129, 4, 0, 35] }
|
|
67556
|
-
]) {
|
|
67557
|
-
if (bytesEqual(curveOid, oid)) {
|
|
67558
|
-
return name;
|
|
67559
|
-
}
|
|
67560
|
-
}
|
|
67561
|
-
throw new Error("Unsupported named curve");
|
|
67562
|
-
};
|
|
67563
|
-
var genericImport = async (keyFormat, keyData, alg, options3) => {
|
|
67564
|
-
let algorithm;
|
|
67565
|
-
let keyUsages;
|
|
67566
|
-
const isPublic = keyFormat === "spki";
|
|
67567
|
-
const getSigUsages = () => isPublic ? ["verify"] : ["sign"];
|
|
67568
|
-
const getEncUsages = () => isPublic ? ["encrypt", "wrapKey"] : ["decrypt", "unwrapKey"];
|
|
67569
|
-
switch (alg) {
|
|
67570
|
-
case "PS256":
|
|
67571
|
-
case "PS384":
|
|
67572
|
-
case "PS512":
|
|
67573
|
-
algorithm = { name: "RSA-PSS", hash: `SHA-${alg.slice(-3)}` };
|
|
67574
|
-
keyUsages = getSigUsages();
|
|
67575
|
-
break;
|
|
67576
|
-
case "RS256":
|
|
67577
|
-
case "RS384":
|
|
67578
|
-
case "RS512":
|
|
67579
|
-
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${alg.slice(-3)}` };
|
|
67580
|
-
keyUsages = getSigUsages();
|
|
67581
|
-
break;
|
|
67582
|
-
case "RSA-OAEP":
|
|
67583
|
-
case "RSA-OAEP-256":
|
|
67584
|
-
case "RSA-OAEP-384":
|
|
67585
|
-
case "RSA-OAEP-512":
|
|
67586
|
-
algorithm = {
|
|
67587
|
-
name: "RSA-OAEP",
|
|
67588
|
-
hash: `SHA-${parseInt(alg.slice(-3), 10) || 1}`
|
|
67589
|
-
};
|
|
67590
|
-
keyUsages = getEncUsages();
|
|
67591
|
-
break;
|
|
67592
|
-
case "ES256":
|
|
67593
|
-
case "ES384":
|
|
67594
|
-
case "ES512": {
|
|
67595
|
-
const curveMap = { ES256: "P-256", ES384: "P-384", ES512: "P-521" };
|
|
67596
|
-
algorithm = { name: "ECDSA", namedCurve: curveMap[alg] };
|
|
67597
|
-
keyUsages = getSigUsages();
|
|
67598
|
-
break;
|
|
67599
|
-
}
|
|
67600
|
-
case "ECDH-ES":
|
|
67601
|
-
case "ECDH-ES+A128KW":
|
|
67602
|
-
case "ECDH-ES+A192KW":
|
|
67603
|
-
case "ECDH-ES+A256KW": {
|
|
67363
|
+
// src/functions/convertMdToPdf.ts
|
|
67364
|
+
function getFilenameFromHeaders(resp, fallback) {
|
|
67365
|
+
const cd = resp.headers.get("content-disposition") || "";
|
|
67366
|
+
const matchStar = cd.match(/filename\*=([^;]+)/i);
|
|
67367
|
+
if (matchStar) {
|
|
67368
|
+
const value = trim_default(matchStar[1]);
|
|
67369
|
+
const parts = split_default(value, "''");
|
|
67370
|
+
if (parts.length === 2) {
|
|
67604
67371
|
try {
|
|
67605
|
-
|
|
67606
|
-
|
|
67607
|
-
|
|
67608
|
-
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
67609
|
-
}
|
|
67610
|
-
keyUsages = isPublic ? [] : ["deriveBits"];
|
|
67611
|
-
break;
|
|
67612
|
-
}
|
|
67613
|
-
case "Ed25519":
|
|
67614
|
-
case "EdDSA":
|
|
67615
|
-
algorithm = { name: "Ed25519" };
|
|
67616
|
-
keyUsages = getSigUsages();
|
|
67617
|
-
break;
|
|
67618
|
-
case "ML-DSA-44":
|
|
67619
|
-
case "ML-DSA-65":
|
|
67620
|
-
case "ML-DSA-87":
|
|
67621
|
-
algorithm = { name: alg };
|
|
67622
|
-
keyUsages = getSigUsages();
|
|
67623
|
-
break;
|
|
67624
|
-
default:
|
|
67625
|
-
throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
67626
|
-
}
|
|
67627
|
-
return crypto.subtle.importKey(keyFormat, keyData, algorithm, options3?.extractable ?? (isPublic ? true : false), keyUsages);
|
|
67628
|
-
};
|
|
67629
|
-
var processPEMData = (pem, pattern) => {
|
|
67630
|
-
return decodeBase64(pem.replace(pattern, ""));
|
|
67631
|
-
};
|
|
67632
|
-
var fromPKCS8 = (pem, alg, options3) => {
|
|
67633
|
-
const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
|
|
67634
|
-
let opts = options3;
|
|
67635
|
-
if (alg?.startsWith?.("ECDH-ES")) {
|
|
67636
|
-
opts ||= {};
|
|
67637
|
-
opts.getNamedCurve = (keyData2) => {
|
|
67638
|
-
const state = createASN1State(keyData2);
|
|
67639
|
-
parsePKCS8Header(state);
|
|
67640
|
-
return parseECAlgorithmIdentifier(state);
|
|
67641
|
-
};
|
|
67642
|
-
}
|
|
67643
|
-
return genericImport("pkcs8", keyData, alg, opts);
|
|
67644
|
-
};
|
|
67645
|
-
|
|
67646
|
-
// node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
67647
|
-
function subtleMapping(jwk) {
|
|
67648
|
-
let algorithm;
|
|
67649
|
-
let keyUsages;
|
|
67650
|
-
switch (jwk.kty) {
|
|
67651
|
-
case "AKP": {
|
|
67652
|
-
switch (jwk.alg) {
|
|
67653
|
-
case "ML-DSA-44":
|
|
67654
|
-
case "ML-DSA-65":
|
|
67655
|
-
case "ML-DSA-87":
|
|
67656
|
-
algorithm = { name: jwk.alg };
|
|
67657
|
-
keyUsages = jwk.priv ? ["sign"] : ["verify"];
|
|
67658
|
-
break;
|
|
67659
|
-
default:
|
|
67660
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67661
|
-
}
|
|
67662
|
-
break;
|
|
67663
|
-
}
|
|
67664
|
-
case "RSA": {
|
|
67665
|
-
switch (jwk.alg) {
|
|
67666
|
-
case "PS256":
|
|
67667
|
-
case "PS384":
|
|
67668
|
-
case "PS512":
|
|
67669
|
-
algorithm = { name: "RSA-PSS", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
67670
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67671
|
-
break;
|
|
67672
|
-
case "RS256":
|
|
67673
|
-
case "RS384":
|
|
67674
|
-
case "RS512":
|
|
67675
|
-
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${jwk.alg.slice(-3)}` };
|
|
67676
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67677
|
-
break;
|
|
67678
|
-
case "RSA-OAEP":
|
|
67679
|
-
case "RSA-OAEP-256":
|
|
67680
|
-
case "RSA-OAEP-384":
|
|
67681
|
-
case "RSA-OAEP-512":
|
|
67682
|
-
algorithm = {
|
|
67683
|
-
name: "RSA-OAEP",
|
|
67684
|
-
hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`
|
|
67685
|
-
};
|
|
67686
|
-
keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
67687
|
-
break;
|
|
67688
|
-
default:
|
|
67689
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67690
|
-
}
|
|
67691
|
-
break;
|
|
67692
|
-
}
|
|
67693
|
-
case "EC": {
|
|
67694
|
-
switch (jwk.alg) {
|
|
67695
|
-
case "ES256":
|
|
67696
|
-
algorithm = { name: "ECDSA", namedCurve: "P-256" };
|
|
67697
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67698
|
-
break;
|
|
67699
|
-
case "ES384":
|
|
67700
|
-
algorithm = { name: "ECDSA", namedCurve: "P-384" };
|
|
67701
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67702
|
-
break;
|
|
67703
|
-
case "ES512":
|
|
67704
|
-
algorithm = { name: "ECDSA", namedCurve: "P-521" };
|
|
67705
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67706
|
-
break;
|
|
67707
|
-
case "ECDH-ES":
|
|
67708
|
-
case "ECDH-ES+A128KW":
|
|
67709
|
-
case "ECDH-ES+A192KW":
|
|
67710
|
-
case "ECDH-ES+A256KW":
|
|
67711
|
-
algorithm = { name: "ECDH", namedCurve: jwk.crv };
|
|
67712
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
67713
|
-
break;
|
|
67714
|
-
default:
|
|
67715
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67372
|
+
return decodeURIComponent(parts[1]);
|
|
67373
|
+
} catch {
|
|
67374
|
+
return parts[1];
|
|
67716
67375
|
}
|
|
67717
|
-
break;
|
|
67718
67376
|
}
|
|
67719
|
-
|
|
67720
|
-
switch (jwk.alg) {
|
|
67721
|
-
case "Ed25519":
|
|
67722
|
-
case "EdDSA":
|
|
67723
|
-
algorithm = { name: "Ed25519" };
|
|
67724
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
67725
|
-
break;
|
|
67726
|
-
case "ECDH-ES":
|
|
67727
|
-
case "ECDH-ES+A128KW":
|
|
67728
|
-
case "ECDH-ES+A192KW":
|
|
67729
|
-
case "ECDH-ES+A256KW":
|
|
67730
|
-
algorithm = { name: jwk.crv };
|
|
67731
|
-
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
67732
|
-
break;
|
|
67733
|
-
default:
|
|
67734
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
67735
|
-
}
|
|
67736
|
-
break;
|
|
67737
|
-
}
|
|
67738
|
-
default:
|
|
67739
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
67377
|
+
return trim_default(value, `'"`);
|
|
67740
67378
|
}
|
|
67741
|
-
|
|
67379
|
+
const match2 = cd.match(/filename="?([^";]+)"?/i);
|
|
67380
|
+
if (match2)
|
|
67381
|
+
return match2[1];
|
|
67382
|
+
return fallback || "document.pdf";
|
|
67742
67383
|
}
|
|
67743
|
-
|
|
67744
|
-
|
|
67745
|
-
|
|
67746
|
-
|
|
67747
|
-
|
|
67748
|
-
const keyData = { ...jwk };
|
|
67749
|
-
if (keyData.kty !== "AKP") {
|
|
67750
|
-
delete keyData.alg;
|
|
67751
|
-
}
|
|
67752
|
-
delete keyData.use;
|
|
67753
|
-
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
67754
|
-
};
|
|
67755
|
-
|
|
67756
|
-
// node_modules/jose/dist/webapi/key/import.js
|
|
67757
|
-
async function importPKCS8(pkcs8, alg, options3) {
|
|
67758
|
-
if (typeof pkcs8 !== "string" || pkcs8.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) {
|
|
67759
|
-
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
67760
|
-
}
|
|
67761
|
-
return fromPKCS8(pkcs8, alg, options3);
|
|
67762
|
-
}
|
|
67763
|
-
|
|
67764
|
-
// node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
67765
|
-
var validate_crit_default = (Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) => {
|
|
67766
|
-
if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {
|
|
67767
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
67768
|
-
}
|
|
67769
|
-
if (!protectedHeader || protectedHeader.crit === undefined) {
|
|
67770
|
-
return new Set;
|
|
67771
|
-
}
|
|
67772
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) {
|
|
67773
|
-
throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
67774
|
-
}
|
|
67775
|
-
let recognized;
|
|
67776
|
-
if (recognizedOption !== undefined) {
|
|
67777
|
-
recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
|
|
67778
|
-
} else {
|
|
67779
|
-
recognized = recognizedDefault;
|
|
67780
|
-
}
|
|
67781
|
-
for (const parameter of protectedHeader.crit) {
|
|
67782
|
-
if (!recognized.has(parameter)) {
|
|
67783
|
-
throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
|
|
67784
|
-
}
|
|
67785
|
-
if (joseHeader[parameter] === undefined) {
|
|
67786
|
-
throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
67787
|
-
}
|
|
67788
|
-
if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {
|
|
67789
|
-
throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
67790
|
-
}
|
|
67791
|
-
}
|
|
67792
|
-
return new Set(protectedHeader.crit);
|
|
67793
|
-
};
|
|
67794
|
-
|
|
67795
|
-
// node_modules/jose/dist/webapi/lib/is_jwk.js
|
|
67796
|
-
function isJWK(key) {
|
|
67797
|
-
return is_object_default(key) && typeof key.kty === "string";
|
|
67798
|
-
}
|
|
67799
|
-
function isPrivateJWK(key) {
|
|
67800
|
-
return key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
67801
|
-
}
|
|
67802
|
-
function isPublicJWK(key) {
|
|
67803
|
-
return key.kty !== "oct" && typeof key.d === "undefined" && typeof key.priv === "undefined";
|
|
67804
|
-
}
|
|
67805
|
-
function isSecretJWK(key) {
|
|
67806
|
-
return key.kty === "oct" && typeof key.k === "string";
|
|
67807
|
-
}
|
|
67808
|
-
|
|
67809
|
-
// node_modules/jose/dist/webapi/lib/normalize_key.js
|
|
67810
|
-
var cache;
|
|
67811
|
-
var handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
67812
|
-
cache ||= new WeakMap;
|
|
67813
|
-
let cached = cache.get(key);
|
|
67814
|
-
if (cached?.[alg]) {
|
|
67815
|
-
return cached[alg];
|
|
67816
|
-
}
|
|
67817
|
-
const cryptoKey = await jwk_to_key_default({ ...jwk, alg });
|
|
67818
|
-
if (freeze)
|
|
67819
|
-
Object.freeze(key);
|
|
67820
|
-
if (!cached) {
|
|
67821
|
-
cache.set(key, { [alg]: cryptoKey });
|
|
67822
|
-
} else {
|
|
67823
|
-
cached[alg] = cryptoKey;
|
|
67384
|
+
async function convertMdToPdf(markdown, options3 = {}, assetHeaders = {}) {
|
|
67385
|
+
const documentParserApiUrl = this.environment.lookup("documentParserApiUrl");
|
|
67386
|
+
const documentParserApiKey = this.environment.lookup("documentParserApiKey");
|
|
67387
|
+
if (!documentParserApiKey) {
|
|
67388
|
+
throw new Error("Document parser API key not found in environment");
|
|
67824
67389
|
}
|
|
67825
|
-
|
|
67826
|
-
|
|
67827
|
-
var handleKeyObject = (keyObject, alg) => {
|
|
67828
|
-
cache ||= new WeakMap;
|
|
67829
|
-
let cached = cache.get(keyObject);
|
|
67830
|
-
if (cached?.[alg]) {
|
|
67831
|
-
return cached[alg];
|
|
67832
|
-
}
|
|
67833
|
-
const isPublic = keyObject.type === "public";
|
|
67834
|
-
const extractable = isPublic ? true : false;
|
|
67835
|
-
let cryptoKey;
|
|
67836
|
-
if (keyObject.asymmetricKeyType === "x25519") {
|
|
67837
|
-
switch (alg) {
|
|
67838
|
-
case "ECDH-ES":
|
|
67839
|
-
case "ECDH-ES+A128KW":
|
|
67840
|
-
case "ECDH-ES+A192KW":
|
|
67841
|
-
case "ECDH-ES+A256KW":
|
|
67842
|
-
break;
|
|
67843
|
-
default:
|
|
67844
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67845
|
-
}
|
|
67846
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
|
|
67390
|
+
if (!documentParserApiUrl) {
|
|
67391
|
+
throw new Error("Document parser API URL not found in environment");
|
|
67847
67392
|
}
|
|
67848
|
-
if (
|
|
67849
|
-
|
|
67850
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67851
|
-
}
|
|
67852
|
-
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [
|
|
67853
|
-
isPublic ? "verify" : "sign"
|
|
67854
|
-
]);
|
|
67393
|
+
if (!markdown || typeof markdown !== "string") {
|
|
67394
|
+
throw new AbortError("Markdown content is required and must be a string");
|
|
67855
67395
|
}
|
|
67856
|
-
|
|
67857
|
-
|
|
67858
|
-
|
|
67859
|
-
|
|
67860
|
-
|
|
67861
|
-
|
|
67396
|
+
const requestBody = {
|
|
67397
|
+
markdown,
|
|
67398
|
+
options: options3,
|
|
67399
|
+
assetHeaders
|
|
67400
|
+
};
|
|
67401
|
+
return await pRetry(async () => {
|
|
67402
|
+
const response = await fetch(`${documentParserApiUrl}/md-to-pdf`, {
|
|
67403
|
+
method: "POST",
|
|
67404
|
+
headers: {
|
|
67405
|
+
Authorization: `Bearer ${documentParserApiKey}`,
|
|
67406
|
+
"Content-Type": "application/json",
|
|
67407
|
+
Accept: "application/pdf",
|
|
67408
|
+
"User-Agent": "truto"
|
|
67409
|
+
},
|
|
67410
|
+
body: JSON.stringify(requestBody)
|
|
67411
|
+
});
|
|
67412
|
+
if (!response.ok) {
|
|
67413
|
+
if (response.status === 429) {
|
|
67414
|
+
throw new Error("Rate limit exceeded");
|
|
67862
67415
|
}
|
|
67863
|
-
|
|
67864
|
-
|
|
67865
|
-
]);
|
|
67866
|
-
}
|
|
67867
|
-
}
|
|
67868
|
-
if (keyObject.asymmetricKeyType === "rsa") {
|
|
67869
|
-
let hash;
|
|
67870
|
-
switch (alg) {
|
|
67871
|
-
case "RSA-OAEP":
|
|
67872
|
-
hash = "SHA-1";
|
|
67873
|
-
break;
|
|
67874
|
-
case "RS256":
|
|
67875
|
-
case "PS256":
|
|
67876
|
-
case "RSA-OAEP-256":
|
|
67877
|
-
hash = "SHA-256";
|
|
67878
|
-
break;
|
|
67879
|
-
case "RS384":
|
|
67880
|
-
case "PS384":
|
|
67881
|
-
case "RSA-OAEP-384":
|
|
67882
|
-
hash = "SHA-384";
|
|
67883
|
-
break;
|
|
67884
|
-
case "RS512":
|
|
67885
|
-
case "PS512":
|
|
67886
|
-
case "RSA-OAEP-512":
|
|
67887
|
-
hash = "SHA-512";
|
|
67888
|
-
break;
|
|
67889
|
-
default:
|
|
67890
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67891
|
-
}
|
|
67892
|
-
if (alg.startsWith("RSA-OAEP")) {
|
|
67893
|
-
return keyObject.toCryptoKey({
|
|
67894
|
-
name: "RSA-OAEP",
|
|
67895
|
-
hash
|
|
67896
|
-
}, extractable, isPublic ? ["encrypt"] : ["decrypt"]);
|
|
67897
|
-
}
|
|
67898
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67899
|
-
name: alg.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5",
|
|
67900
|
-
hash
|
|
67901
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67902
|
-
}
|
|
67903
|
-
if (keyObject.asymmetricKeyType === "ec") {
|
|
67904
|
-
const nist = new Map([
|
|
67905
|
-
["prime256v1", "P-256"],
|
|
67906
|
-
["secp384r1", "P-384"],
|
|
67907
|
-
["secp521r1", "P-521"]
|
|
67908
|
-
]);
|
|
67909
|
-
const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);
|
|
67910
|
-
if (!namedCurve) {
|
|
67911
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67912
|
-
}
|
|
67913
|
-
if (alg === "ES256" && namedCurve === "P-256") {
|
|
67914
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67915
|
-
name: "ECDSA",
|
|
67916
|
-
namedCurve
|
|
67917
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67918
|
-
}
|
|
67919
|
-
if (alg === "ES384" && namedCurve === "P-384") {
|
|
67920
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67921
|
-
name: "ECDSA",
|
|
67922
|
-
namedCurve
|
|
67923
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67924
|
-
}
|
|
67925
|
-
if (alg === "ES512" && namedCurve === "P-521") {
|
|
67926
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67927
|
-
name: "ECDSA",
|
|
67928
|
-
namedCurve
|
|
67929
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
67930
|
-
}
|
|
67931
|
-
if (alg.startsWith("ECDH-ES")) {
|
|
67932
|
-
cryptoKey = keyObject.toCryptoKey({
|
|
67933
|
-
name: "ECDH",
|
|
67934
|
-
namedCurve
|
|
67935
|
-
}, extractable, isPublic ? [] : ["deriveBits"]);
|
|
67936
|
-
}
|
|
67937
|
-
}
|
|
67938
|
-
if (!cryptoKey) {
|
|
67939
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
67940
|
-
}
|
|
67941
|
-
if (!cached) {
|
|
67942
|
-
cache.set(keyObject, { [alg]: cryptoKey });
|
|
67943
|
-
} else {
|
|
67944
|
-
cached[alg] = cryptoKey;
|
|
67945
|
-
}
|
|
67946
|
-
return cryptoKey;
|
|
67947
|
-
};
|
|
67948
|
-
var normalize_key_default = async (key, alg) => {
|
|
67949
|
-
if (key instanceof Uint8Array) {
|
|
67950
|
-
return key;
|
|
67951
|
-
}
|
|
67952
|
-
if (isCryptoKey(key)) {
|
|
67953
|
-
return key;
|
|
67954
|
-
}
|
|
67955
|
-
if (isKeyObject(key)) {
|
|
67956
|
-
if (key.type === "secret") {
|
|
67957
|
-
return key.export();
|
|
67958
|
-
}
|
|
67959
|
-
if ("toCryptoKey" in key && typeof key.toCryptoKey === "function") {
|
|
67960
|
-
try {
|
|
67961
|
-
return handleKeyObject(key, alg);
|
|
67962
|
-
} catch (err) {
|
|
67963
|
-
if (err instanceof TypeError) {
|
|
67964
|
-
throw err;
|
|
67965
|
-
}
|
|
67416
|
+
if (response.status >= 500) {
|
|
67417
|
+
throw new Error(`Server error: ${response.status}`);
|
|
67966
67418
|
}
|
|
67419
|
+
const errorText = await response.text();
|
|
67420
|
+
let errorMessage = `PDF conversion failed (${response.status})`;
|
|
67421
|
+
try {
|
|
67422
|
+
const errorData = JSON.parse(errorText);
|
|
67423
|
+
errorMessage = errorData.error || errorMessage;
|
|
67424
|
+
if (errorData.details) {
|
|
67425
|
+
errorMessage += `: ${errorData.details}`;
|
|
67426
|
+
}
|
|
67427
|
+
} catch {
|
|
67428
|
+
errorMessage += `: ${errorText}`;
|
|
67429
|
+
}
|
|
67430
|
+
throw new AbortError(errorMessage);
|
|
67431
|
+
}
|
|
67432
|
+
const contentType = response.headers.get("content-type");
|
|
67433
|
+
if (!contentType || !includes_default(contentType, "application/pdf")) {
|
|
67434
|
+
throw new AbortError(`Expected PDF but received: ${contentType}`);
|
|
67435
|
+
}
|
|
67436
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
67437
|
+
const filename = getFilenameFromHeaders(response, options3.filename);
|
|
67438
|
+
const blob2 = new Blob([arrayBuffer], { type: "application/pdf" });
|
|
67439
|
+
blob2.name = filename;
|
|
67440
|
+
return blob2;
|
|
67441
|
+
}, {
|
|
67442
|
+
retries: 5,
|
|
67443
|
+
maxTimeout: 30000,
|
|
67444
|
+
minTimeout: 2500,
|
|
67445
|
+
onFailedAttempt: (error) => {
|
|
67446
|
+
console.warn(`PDF conversion attempt ${error.attemptNumber} failed:`, error.message);
|
|
67967
67447
|
}
|
|
67968
|
-
|
|
67969
|
-
return handleJWK(key, jwk, alg);
|
|
67970
|
-
}
|
|
67971
|
-
if (isJWK(key)) {
|
|
67972
|
-
if (key.k) {
|
|
67973
|
-
return decode(key.k);
|
|
67974
|
-
}
|
|
67975
|
-
return handleJWK(key, key, alg, true);
|
|
67976
|
-
}
|
|
67977
|
-
throw new Error("unreachable");
|
|
67978
|
-
};
|
|
67979
|
-
|
|
67980
|
-
// node_modules/jose/dist/webapi/lib/check_key_type.js
|
|
67981
|
-
var tag3 = (key) => key?.[Symbol.toStringTag];
|
|
67982
|
-
var jwkMatchesOp = (alg, key, usage) => {
|
|
67983
|
-
if (key.use !== undefined) {
|
|
67984
|
-
let expected;
|
|
67985
|
-
switch (usage) {
|
|
67986
|
-
case "sign":
|
|
67987
|
-
case "verify":
|
|
67988
|
-
expected = "sig";
|
|
67989
|
-
break;
|
|
67990
|
-
case "encrypt":
|
|
67991
|
-
case "decrypt":
|
|
67992
|
-
expected = "enc";
|
|
67993
|
-
break;
|
|
67994
|
-
}
|
|
67995
|
-
if (key.use !== expected) {
|
|
67996
|
-
throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
|
|
67997
|
-
}
|
|
67998
|
-
}
|
|
67999
|
-
if (key.alg !== undefined && key.alg !== alg) {
|
|
68000
|
-
throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
|
|
68001
|
-
}
|
|
68002
|
-
if (Array.isArray(key.key_ops)) {
|
|
68003
|
-
let expectedKeyOp;
|
|
68004
|
-
switch (true) {
|
|
68005
|
-
case (usage === "sign" || usage === "verify"):
|
|
68006
|
-
case alg === "dir":
|
|
68007
|
-
case alg.includes("CBC-HS"):
|
|
68008
|
-
expectedKeyOp = usage;
|
|
68009
|
-
break;
|
|
68010
|
-
case alg.startsWith("PBES2"):
|
|
68011
|
-
expectedKeyOp = "deriveBits";
|
|
68012
|
-
break;
|
|
68013
|
-
case /^A\d{3}(?:GCM)?(?:KW)?$/.test(alg):
|
|
68014
|
-
if (!alg.includes("GCM") && alg.endsWith("KW")) {
|
|
68015
|
-
expectedKeyOp = usage === "encrypt" ? "wrapKey" : "unwrapKey";
|
|
68016
|
-
} else {
|
|
68017
|
-
expectedKeyOp = usage;
|
|
68018
|
-
}
|
|
68019
|
-
break;
|
|
68020
|
-
case (usage === "encrypt" && alg.startsWith("RSA")):
|
|
68021
|
-
expectedKeyOp = "wrapKey";
|
|
68022
|
-
break;
|
|
68023
|
-
case usage === "decrypt":
|
|
68024
|
-
expectedKeyOp = alg.startsWith("RSA") ? "unwrapKey" : "deriveBits";
|
|
68025
|
-
break;
|
|
68026
|
-
}
|
|
68027
|
-
if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {
|
|
68028
|
-
throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
|
|
68029
|
-
}
|
|
68030
|
-
}
|
|
68031
|
-
return true;
|
|
68032
|
-
};
|
|
68033
|
-
var symmetricTypeCheck = (alg, key, usage) => {
|
|
68034
|
-
if (key instanceof Uint8Array)
|
|
68035
|
-
return;
|
|
68036
|
-
if (isJWK(key)) {
|
|
68037
|
-
if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
68038
|
-
return;
|
|
68039
|
-
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`);
|
|
68040
|
-
}
|
|
68041
|
-
if (!is_key_like_default(key)) {
|
|
68042
|
-
throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
|
|
68043
|
-
}
|
|
68044
|
-
if (key.type !== "secret") {
|
|
68045
|
-
throw new TypeError(`${tag3(key)} instances for symmetric algorithms must be of type "secret"`);
|
|
68046
|
-
}
|
|
68047
|
-
};
|
|
68048
|
-
var asymmetricTypeCheck = (alg, key, usage) => {
|
|
68049
|
-
if (isJWK(key)) {
|
|
68050
|
-
switch (usage) {
|
|
68051
|
-
case "decrypt":
|
|
68052
|
-
case "sign":
|
|
68053
|
-
if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
68054
|
-
return;
|
|
68055
|
-
throw new TypeError(`JSON Web Key for this operation be a private JWK`);
|
|
68056
|
-
case "encrypt":
|
|
68057
|
-
case "verify":
|
|
68058
|
-
if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage))
|
|
68059
|
-
return;
|
|
68060
|
-
throw new TypeError(`JSON Web Key for this operation be a public JWK`);
|
|
68061
|
-
}
|
|
68062
|
-
}
|
|
68063
|
-
if (!is_key_like_default(key)) {
|
|
68064
|
-
throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
68065
|
-
}
|
|
68066
|
-
if (key.type === "secret") {
|
|
68067
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
68068
|
-
}
|
|
68069
|
-
if (key.type === "public") {
|
|
68070
|
-
switch (usage) {
|
|
68071
|
-
case "sign":
|
|
68072
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm signing must be of type "private"`);
|
|
68073
|
-
case "decrypt":
|
|
68074
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
68075
|
-
default:
|
|
68076
|
-
break;
|
|
68077
|
-
}
|
|
68078
|
-
}
|
|
68079
|
-
if (key.type === "private") {
|
|
68080
|
-
switch (usage) {
|
|
68081
|
-
case "verify":
|
|
68082
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
68083
|
-
case "encrypt":
|
|
68084
|
-
throw new TypeError(`${tag3(key)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
68085
|
-
default:
|
|
68086
|
-
break;
|
|
68087
|
-
}
|
|
68088
|
-
}
|
|
68089
|
-
};
|
|
68090
|
-
var check_key_type_default = (alg, key, usage) => {
|
|
68091
|
-
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);
|
|
68092
|
-
if (symmetric) {
|
|
68093
|
-
symmetricTypeCheck(alg, key, usage);
|
|
68094
|
-
} else {
|
|
68095
|
-
asymmetricTypeCheck(alg, key, usage);
|
|
68096
|
-
}
|
|
68097
|
-
};
|
|
68098
|
-
|
|
68099
|
-
// node_modules/jose/dist/webapi/lib/subtle_dsa.js
|
|
68100
|
-
var subtle_dsa_default = (alg, algorithm) => {
|
|
68101
|
-
const hash = `SHA-${alg.slice(-3)}`;
|
|
68102
|
-
switch (alg) {
|
|
68103
|
-
case "HS256":
|
|
68104
|
-
case "HS384":
|
|
68105
|
-
case "HS512":
|
|
68106
|
-
return { hash, name: "HMAC" };
|
|
68107
|
-
case "PS256":
|
|
68108
|
-
case "PS384":
|
|
68109
|
-
case "PS512":
|
|
68110
|
-
return { hash, name: "RSA-PSS", saltLength: parseInt(alg.slice(-3), 10) >> 3 };
|
|
68111
|
-
case "RS256":
|
|
68112
|
-
case "RS384":
|
|
68113
|
-
case "RS512":
|
|
68114
|
-
return { hash, name: "RSASSA-PKCS1-v1_5" };
|
|
68115
|
-
case "ES256":
|
|
68116
|
-
case "ES384":
|
|
68117
|
-
case "ES512":
|
|
68118
|
-
return { hash, name: "ECDSA", namedCurve: algorithm.namedCurve };
|
|
68119
|
-
case "Ed25519":
|
|
68120
|
-
case "EdDSA":
|
|
68121
|
-
return { name: "Ed25519" };
|
|
68122
|
-
case "ML-DSA-44":
|
|
68123
|
-
case "ML-DSA-65":
|
|
68124
|
-
case "ML-DSA-87":
|
|
68125
|
-
return { name: alg };
|
|
68126
|
-
default:
|
|
68127
|
-
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
68128
|
-
}
|
|
68129
|
-
};
|
|
68130
|
-
|
|
68131
|
-
// node_modules/jose/dist/webapi/lib/get_sign_verify_key.js
|
|
68132
|
-
var get_sign_verify_key_default = async (alg, key, usage) => {
|
|
68133
|
-
if (key instanceof Uint8Array) {
|
|
68134
|
-
if (!alg.startsWith("HS")) {
|
|
68135
|
-
throw new TypeError(invalid_key_input_default(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
68136
|
-
}
|
|
68137
|
-
return crypto.subtle.importKey("raw", key, { hash: `SHA-${alg.slice(-3)}`, name: "HMAC" }, false, [usage]);
|
|
68138
|
-
}
|
|
68139
|
-
checkSigCryptoKey(key, alg, usage);
|
|
68140
|
-
return key;
|
|
68141
|
-
};
|
|
68142
|
-
|
|
68143
|
-
// node_modules/jose/dist/webapi/lib/epoch.js
|
|
68144
|
-
var epoch_default = (date2) => Math.floor(date2.getTime() / 1000);
|
|
68145
|
-
|
|
68146
|
-
// node_modules/jose/dist/webapi/lib/secs.js
|
|
68147
|
-
var minute = 60;
|
|
68148
|
-
var hour = minute * 60;
|
|
68149
|
-
var day = hour * 24;
|
|
68150
|
-
var week = day * 7;
|
|
68151
|
-
var year = day * 365.25;
|
|
68152
|
-
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;
|
|
68153
|
-
var secs_default = (str) => {
|
|
68154
|
-
const matched = REGEX.exec(str);
|
|
68155
|
-
if (!matched || matched[4] && matched[1]) {
|
|
68156
|
-
throw new TypeError("Invalid time period format");
|
|
68157
|
-
}
|
|
68158
|
-
const value = parseFloat(matched[2]);
|
|
68159
|
-
const unit = matched[3].toLowerCase();
|
|
68160
|
-
let numericDate;
|
|
68161
|
-
switch (unit) {
|
|
68162
|
-
case "sec":
|
|
68163
|
-
case "secs":
|
|
68164
|
-
case "second":
|
|
68165
|
-
case "seconds":
|
|
68166
|
-
case "s":
|
|
68167
|
-
numericDate = Math.round(value);
|
|
68168
|
-
break;
|
|
68169
|
-
case "minute":
|
|
68170
|
-
case "minutes":
|
|
68171
|
-
case "min":
|
|
68172
|
-
case "mins":
|
|
68173
|
-
case "m":
|
|
68174
|
-
numericDate = Math.round(value * minute);
|
|
68175
|
-
break;
|
|
68176
|
-
case "hour":
|
|
68177
|
-
case "hours":
|
|
68178
|
-
case "hr":
|
|
68179
|
-
case "hrs":
|
|
68180
|
-
case "h":
|
|
68181
|
-
numericDate = Math.round(value * hour);
|
|
68182
|
-
break;
|
|
68183
|
-
case "day":
|
|
68184
|
-
case "days":
|
|
68185
|
-
case "d":
|
|
68186
|
-
numericDate = Math.round(value * day);
|
|
68187
|
-
break;
|
|
68188
|
-
case "week":
|
|
68189
|
-
case "weeks":
|
|
68190
|
-
case "w":
|
|
68191
|
-
numericDate = Math.round(value * week);
|
|
68192
|
-
break;
|
|
68193
|
-
default:
|
|
68194
|
-
numericDate = Math.round(value * year);
|
|
68195
|
-
break;
|
|
68196
|
-
}
|
|
68197
|
-
if (matched[1] === "-" || matched[4] === "ago") {
|
|
68198
|
-
return -numericDate;
|
|
68199
|
-
}
|
|
68200
|
-
return numericDate;
|
|
68201
|
-
};
|
|
68202
|
-
|
|
68203
|
-
// node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
68204
|
-
function validateInput(label, input) {
|
|
68205
|
-
if (!Number.isFinite(input)) {
|
|
68206
|
-
throw new TypeError(`Invalid ${label} input`);
|
|
68207
|
-
}
|
|
68208
|
-
return input;
|
|
68209
|
-
}
|
|
68210
|
-
class JWTClaimsBuilder {
|
|
68211
|
-
#payload;
|
|
68212
|
-
constructor(payload) {
|
|
68213
|
-
if (!is_object_default(payload)) {
|
|
68214
|
-
throw new TypeError("JWT Claims Set MUST be an object");
|
|
68215
|
-
}
|
|
68216
|
-
this.#payload = structuredClone(payload);
|
|
68217
|
-
}
|
|
68218
|
-
data() {
|
|
68219
|
-
return encoder.encode(JSON.stringify(this.#payload));
|
|
68220
|
-
}
|
|
68221
|
-
get iss() {
|
|
68222
|
-
return this.#payload.iss;
|
|
68223
|
-
}
|
|
68224
|
-
set iss(value) {
|
|
68225
|
-
this.#payload.iss = value;
|
|
68226
|
-
}
|
|
68227
|
-
get sub() {
|
|
68228
|
-
return this.#payload.sub;
|
|
68229
|
-
}
|
|
68230
|
-
set sub(value) {
|
|
68231
|
-
this.#payload.sub = value;
|
|
68232
|
-
}
|
|
68233
|
-
get aud() {
|
|
68234
|
-
return this.#payload.aud;
|
|
68235
|
-
}
|
|
68236
|
-
set aud(value) {
|
|
68237
|
-
this.#payload.aud = value;
|
|
68238
|
-
}
|
|
68239
|
-
set jti(value) {
|
|
68240
|
-
this.#payload.jti = value;
|
|
68241
|
-
}
|
|
68242
|
-
set nbf(value) {
|
|
68243
|
-
if (typeof value === "number") {
|
|
68244
|
-
this.#payload.nbf = validateInput("setNotBefore", value);
|
|
68245
|
-
} else if (value instanceof Date) {
|
|
68246
|
-
this.#payload.nbf = validateInput("setNotBefore", epoch_default(value));
|
|
68247
|
-
} else {
|
|
68248
|
-
this.#payload.nbf = epoch_default(new Date) + secs_default(value);
|
|
68249
|
-
}
|
|
68250
|
-
}
|
|
68251
|
-
set exp(value) {
|
|
68252
|
-
if (typeof value === "number") {
|
|
68253
|
-
this.#payload.exp = validateInput("setExpirationTime", value);
|
|
68254
|
-
} else if (value instanceof Date) {
|
|
68255
|
-
this.#payload.exp = validateInput("setExpirationTime", epoch_default(value));
|
|
68256
|
-
} else {
|
|
68257
|
-
this.#payload.exp = epoch_default(new Date) + secs_default(value);
|
|
68258
|
-
}
|
|
68259
|
-
}
|
|
68260
|
-
set iat(value) {
|
|
68261
|
-
if (typeof value === "undefined") {
|
|
68262
|
-
this.#payload.iat = epoch_default(new Date);
|
|
68263
|
-
} else if (value instanceof Date) {
|
|
68264
|
-
this.#payload.iat = validateInput("setIssuedAt", epoch_default(value));
|
|
68265
|
-
} else if (typeof value === "string") {
|
|
68266
|
-
this.#payload.iat = validateInput("setIssuedAt", epoch_default(new Date) + secs_default(value));
|
|
68267
|
-
} else {
|
|
68268
|
-
this.#payload.iat = validateInput("setIssuedAt", value);
|
|
68269
|
-
}
|
|
68270
|
-
}
|
|
68271
|
-
}
|
|
68272
|
-
|
|
68273
|
-
// node_modules/jose/dist/webapi/lib/sign.js
|
|
68274
|
-
var sign_default2 = async (alg, key, data) => {
|
|
68275
|
-
const cryptoKey = await get_sign_verify_key_default(alg, key, "sign");
|
|
68276
|
-
check_key_length_default(alg, cryptoKey);
|
|
68277
|
-
const signature = await crypto.subtle.sign(subtle_dsa_default(alg, cryptoKey.algorithm), cryptoKey, data);
|
|
68278
|
-
return new Uint8Array(signature);
|
|
68279
|
-
};
|
|
68280
|
-
|
|
68281
|
-
// node_modules/jose/dist/webapi/jws/flattened/sign.js
|
|
68282
|
-
class FlattenedSign {
|
|
68283
|
-
#payload;
|
|
68284
|
-
#protectedHeader;
|
|
68285
|
-
#unprotectedHeader;
|
|
68286
|
-
constructor(payload) {
|
|
68287
|
-
if (!(payload instanceof Uint8Array)) {
|
|
68288
|
-
throw new TypeError("payload must be an instance of Uint8Array");
|
|
68289
|
-
}
|
|
68290
|
-
this.#payload = payload;
|
|
68291
|
-
}
|
|
68292
|
-
setProtectedHeader(protectedHeader) {
|
|
68293
|
-
if (this.#protectedHeader) {
|
|
68294
|
-
throw new TypeError("setProtectedHeader can only be called once");
|
|
68295
|
-
}
|
|
68296
|
-
this.#protectedHeader = protectedHeader;
|
|
68297
|
-
return this;
|
|
68298
|
-
}
|
|
68299
|
-
setUnprotectedHeader(unprotectedHeader) {
|
|
68300
|
-
if (this.#unprotectedHeader) {
|
|
68301
|
-
throw new TypeError("setUnprotectedHeader can only be called once");
|
|
68302
|
-
}
|
|
68303
|
-
this.#unprotectedHeader = unprotectedHeader;
|
|
68304
|
-
return this;
|
|
68305
|
-
}
|
|
68306
|
-
async sign(key, options3) {
|
|
68307
|
-
if (!this.#protectedHeader && !this.#unprotectedHeader) {
|
|
68308
|
-
throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
68309
|
-
}
|
|
68310
|
-
if (!is_disjoint_default(this.#protectedHeader, this.#unprotectedHeader)) {
|
|
68311
|
-
throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
68312
|
-
}
|
|
68313
|
-
const joseHeader = {
|
|
68314
|
-
...this.#protectedHeader,
|
|
68315
|
-
...this.#unprotectedHeader
|
|
68316
|
-
};
|
|
68317
|
-
const extensions = validate_crit_default(JWSInvalid, new Map([["b64", true]]), options3?.crit, this.#protectedHeader, joseHeader);
|
|
68318
|
-
let b64 = true;
|
|
68319
|
-
if (extensions.has("b64")) {
|
|
68320
|
-
b64 = this.#protectedHeader.b64;
|
|
68321
|
-
if (typeof b64 !== "boolean") {
|
|
68322
|
-
throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
68323
|
-
}
|
|
68324
|
-
}
|
|
68325
|
-
const { alg } = joseHeader;
|
|
68326
|
-
if (typeof alg !== "string" || !alg) {
|
|
68327
|
-
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
68328
|
-
}
|
|
68329
|
-
check_key_type_default(alg, key, "sign");
|
|
68330
|
-
let payload = this.#payload;
|
|
68331
|
-
if (b64) {
|
|
68332
|
-
payload = encoder.encode(encode(payload));
|
|
68333
|
-
}
|
|
68334
|
-
let protectedHeader;
|
|
68335
|
-
if (this.#protectedHeader) {
|
|
68336
|
-
protectedHeader = encoder.encode(encode(JSON.stringify(this.#protectedHeader)));
|
|
68337
|
-
} else {
|
|
68338
|
-
protectedHeader = encoder.encode("");
|
|
68339
|
-
}
|
|
68340
|
-
const data = concat4(protectedHeader, encoder.encode("."), payload);
|
|
68341
|
-
const k = await normalize_key_default(key, alg);
|
|
68342
|
-
const signature = await sign_default2(alg, k, data);
|
|
68343
|
-
const jws = {
|
|
68344
|
-
signature: encode(signature),
|
|
68345
|
-
payload: ""
|
|
68346
|
-
};
|
|
68347
|
-
if (b64) {
|
|
68348
|
-
jws.payload = decoder.decode(payload);
|
|
68349
|
-
}
|
|
68350
|
-
if (this.#unprotectedHeader) {
|
|
68351
|
-
jws.header = this.#unprotectedHeader;
|
|
68352
|
-
}
|
|
68353
|
-
if (this.#protectedHeader) {
|
|
68354
|
-
jws.protected = decoder.decode(protectedHeader);
|
|
68355
|
-
}
|
|
68356
|
-
return jws;
|
|
68357
|
-
}
|
|
68358
|
-
}
|
|
68359
|
-
|
|
68360
|
-
// node_modules/jose/dist/webapi/jws/compact/sign.js
|
|
68361
|
-
class CompactSign {
|
|
68362
|
-
#flattened;
|
|
68363
|
-
constructor(payload) {
|
|
68364
|
-
this.#flattened = new FlattenedSign(payload);
|
|
68365
|
-
}
|
|
68366
|
-
setProtectedHeader(protectedHeader) {
|
|
68367
|
-
this.#flattened.setProtectedHeader(protectedHeader);
|
|
68368
|
-
return this;
|
|
68369
|
-
}
|
|
68370
|
-
async sign(key, options3) {
|
|
68371
|
-
const jws = await this.#flattened.sign(key, options3);
|
|
68372
|
-
if (jws.payload === undefined) {
|
|
68373
|
-
throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
68374
|
-
}
|
|
68375
|
-
return `${jws.protected}.${jws.payload}.${jws.signature}`;
|
|
68376
|
-
}
|
|
68377
|
-
}
|
|
68378
|
-
|
|
68379
|
-
// node_modules/jose/dist/webapi/jwt/sign.js
|
|
68380
|
-
class SignJWT {
|
|
68381
|
-
#protectedHeader;
|
|
68382
|
-
#jwt;
|
|
68383
|
-
constructor(payload = {}) {
|
|
68384
|
-
this.#jwt = new JWTClaimsBuilder(payload);
|
|
68385
|
-
}
|
|
68386
|
-
setIssuer(issuer) {
|
|
68387
|
-
this.#jwt.iss = issuer;
|
|
68388
|
-
return this;
|
|
68389
|
-
}
|
|
68390
|
-
setSubject(subject) {
|
|
68391
|
-
this.#jwt.sub = subject;
|
|
68392
|
-
return this;
|
|
68393
|
-
}
|
|
68394
|
-
setAudience(audience) {
|
|
68395
|
-
this.#jwt.aud = audience;
|
|
68396
|
-
return this;
|
|
68397
|
-
}
|
|
68398
|
-
setJti(jwtId) {
|
|
68399
|
-
this.#jwt.jti = jwtId;
|
|
68400
|
-
return this;
|
|
68401
|
-
}
|
|
68402
|
-
setNotBefore(input) {
|
|
68403
|
-
this.#jwt.nbf = input;
|
|
68404
|
-
return this;
|
|
68405
|
-
}
|
|
68406
|
-
setExpirationTime(input) {
|
|
68407
|
-
this.#jwt.exp = input;
|
|
68408
|
-
return this;
|
|
68409
|
-
}
|
|
68410
|
-
setIssuedAt(input) {
|
|
68411
|
-
this.#jwt.iat = input;
|
|
68412
|
-
return this;
|
|
68413
|
-
}
|
|
68414
|
-
setProtectedHeader(protectedHeader) {
|
|
68415
|
-
this.#protectedHeader = protectedHeader;
|
|
68416
|
-
return this;
|
|
68417
|
-
}
|
|
68418
|
-
async sign(key, options3) {
|
|
68419
|
-
const sig = new CompactSign(this.#jwt.data());
|
|
68420
|
-
sig.setProtectedHeader(this.#protectedHeader);
|
|
68421
|
-
if (Array.isArray(this.#protectedHeader?.crit) && this.#protectedHeader.crit.includes("b64") && this.#protectedHeader.b64 === false) {
|
|
68422
|
-
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
68423
|
-
}
|
|
68424
|
-
return sig.sign(key, options3);
|
|
68425
|
-
}
|
|
68426
|
-
}
|
|
68427
|
-
// src/functions/signJwt.ts
|
|
68428
|
-
function assertObjectPayload(payload) {
|
|
68429
|
-
if (!isPlainObject_default(payload) || isNull_default(payload)) {
|
|
68430
|
-
throw new Error("Payload must be a non-null object");
|
|
68431
|
-
}
|
|
67448
|
+
});
|
|
68432
67449
|
}
|
|
68433
|
-
var signJwt = async (payload, key, protectHeaders = {}, signOptions) => {
|
|
68434
|
-
assertObjectPayload(payload);
|
|
68435
|
-
try {
|
|
68436
|
-
let signingKey;
|
|
68437
|
-
const alg = protectHeaders.alg;
|
|
68438
|
-
if (!alg) {
|
|
68439
|
-
throw new Error("Algorithm (alg) must be provided in protectHeaders");
|
|
68440
|
-
}
|
|
68441
|
-
const isAsymmetric = alg.startsWith("RS") || alg.startsWith("ES") || alg.startsWith("PS");
|
|
68442
|
-
if (isAsymmetric) {
|
|
68443
|
-
if (!isString_default(key)) {
|
|
68444
|
-
throw new Error("For asymmetric algorithms, key must be a PEM string");
|
|
68445
|
-
}
|
|
68446
|
-
const pemKey = includes_default(key, "\\n") ? replace_default(key, /\\n/g, `
|
|
68447
|
-
`) : key;
|
|
68448
|
-
signingKey = await importPKCS8(pemKey, alg);
|
|
68449
|
-
} else {
|
|
68450
|
-
signingKey = isString_default(key) ? new TextEncoder().encode(key) : key;
|
|
68451
|
-
}
|
|
68452
|
-
const jwtBuilder = new SignJWT(payload).setProtectedHeader({ ...protectHeaders, typ: "JWT" });
|
|
68453
|
-
return await jwtBuilder.sign(signingKey, signOptions);
|
|
68454
|
-
} catch (error) {
|
|
68455
|
-
throw new Error(`JWT signing failed: ${error?.message || String(error)}`);
|
|
68456
|
-
}
|
|
68457
|
-
};
|
|
68458
|
-
var signJwt_default = signJwt;
|
|
68459
67450
|
|
|
68460
67451
|
// src/registerJsonataExtensions.ts
|
|
68461
67452
|
function registerJsonataExtensions(expression) {
|
|
@@ -68482,6 +67473,7 @@ function registerJsonataExtensions(expression) {
|
|
|
68482
67473
|
expression.registerFunction("difference", function(arr1, arr2) {
|
|
68483
67474
|
return difference_default(arr1, arr2);
|
|
68484
67475
|
});
|
|
67476
|
+
expression.registerFunction("convertMdToPdf", convertMdToPdf);
|
|
68485
67477
|
expression.registerFunction("toNumber", toNumber_default2);
|
|
68486
67478
|
expression.registerFunction("jsonParse", jsonParse_default);
|
|
68487
67479
|
expression.registerFunction("getMimeType", getMimeType_default);
|
|
@@ -68494,7 +67486,6 @@ function registerJsonataExtensions(expression) {
|
|
|
68494
67486
|
expression.registerFunction("convertMarkdownToHtml", convertMarkdownToHtml_default);
|
|
68495
67487
|
expression.registerFunction("digest", digest_default);
|
|
68496
67488
|
expression.registerFunction("sign", sign_default);
|
|
68497
|
-
expression.registerFunction("signJwt", signJwt_default);
|
|
68498
67489
|
expression.registerFunction("xmlToJs", xmlToJs);
|
|
68499
67490
|
expression.registerFunction("jsToXml", jsToXml_default);
|
|
68500
67491
|
expression.registerFunction("generateEmbeddingsCohere", generateEmbeddingsCohere_default);
|
|
@@ -68558,4 +67549,4 @@ function trutoJsonata(expression) {
|
|
|
68558
67549
|
return registerJsonataExtensions(import_jsonata.default(expression));
|
|
68559
67550
|
}
|
|
68560
67551
|
|
|
68561
|
-
//# debugId=
|
|
67552
|
+
//# debugId=CAD6369D5675943D64756E2164756E21
|