@posty5/social-publisher-post 4.1.0 → 5.0.0
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 +273 -15
- package/dist/index.d.mts +833 -54
- package/dist/index.d.ts +833 -54
- package/dist/index.js +1552 -217
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1544 -218
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -11734,6 +11734,12 @@ var require_follow_redirects = __commonJS({
|
|
|
11734
11734
|
RedirectableRequest.prototype._sanitizeOptions = function(options) {
|
|
11735
11735
|
if (!options.headers) {
|
|
11736
11736
|
options.headers = {};
|
|
11737
|
+
} else if (Array.isArray(options.headers)) {
|
|
11738
|
+
var headerList = options.headers;
|
|
11739
|
+
options.headers = {};
|
|
11740
|
+
for (var i = 0; i < headerList.length; i += 2) {
|
|
11741
|
+
options.headers[headerList[i]] = headerList[i + 1];
|
|
11742
|
+
}
|
|
11737
11743
|
}
|
|
11738
11744
|
if (!isArray2(options.sensitiveHeaders)) {
|
|
11739
11745
|
options.sensitiveHeaders = [];
|
|
@@ -12008,7 +12014,7 @@ var require_follow_redirects = __commonJS({
|
|
|
12008
12014
|
return URL2 && value instanceof URL2;
|
|
12009
12015
|
}
|
|
12010
12016
|
function escapeRegex(regex) {
|
|
12011
|
-
return regex.replace(/[\]\\/()
|
|
12017
|
+
return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&");
|
|
12012
12018
|
}
|
|
12013
12019
|
module.exports = wrap({ http: http3, https: https2 });
|
|
12014
12020
|
module.exports.wrap = wrap;
|
|
@@ -12067,22 +12073,82 @@ var { toString } = Object.prototype;
|
|
|
12067
12073
|
var { getPrototypeOf } = Object;
|
|
12068
12074
|
var { iterator, toStringTag } = Symbol;
|
|
12069
12075
|
var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
|
|
12076
|
+
var isUnsafeObjectKey = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
|
|
12077
|
+
var isPrototypeBoundary = (obj, prototype2, source) => obj === Object.prototype || !source && prototype2 === null;
|
|
12078
|
+
var isSafeAndFullyMutable = (obj) => {
|
|
12079
|
+
if (!Object.isExtensible(obj)) {
|
|
12080
|
+
return false;
|
|
12081
|
+
}
|
|
12082
|
+
const props = Object.getOwnPropertyNames(obj);
|
|
12083
|
+
if (Object.getOwnPropertySymbols) {
|
|
12084
|
+
props.push(...Object.getOwnPropertySymbols(obj));
|
|
12085
|
+
}
|
|
12086
|
+
return props.every((prop) => {
|
|
12087
|
+
if (isUnsafeObjectKey(prop)) {
|
|
12088
|
+
return false;
|
|
12089
|
+
}
|
|
12090
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
12091
|
+
return !!descriptor && descriptor.configurable && descriptor.writable === true;
|
|
12092
|
+
});
|
|
12093
|
+
};
|
|
12070
12094
|
var hasOwnInPrototypeChain = (thing, prop) => {
|
|
12071
12095
|
let obj = thing;
|
|
12072
12096
|
const seen = [];
|
|
12073
|
-
while (obj != null
|
|
12097
|
+
while (obj != null) {
|
|
12074
12098
|
if (seen.indexOf(obj) !== -1) {
|
|
12075
12099
|
return false;
|
|
12076
12100
|
}
|
|
12077
12101
|
seen.push(obj);
|
|
12102
|
+
const prototype2 = getPrototypeOf(obj);
|
|
12103
|
+
if (isPrototypeBoundary(obj, prototype2, obj === thing)) {
|
|
12104
|
+
return false;
|
|
12105
|
+
}
|
|
12078
12106
|
if (hasOwnProperty(obj, prop)) {
|
|
12079
12107
|
return true;
|
|
12080
12108
|
}
|
|
12081
|
-
obj =
|
|
12109
|
+
obj = prototype2;
|
|
12082
12110
|
}
|
|
12083
12111
|
return false;
|
|
12084
12112
|
};
|
|
12085
12113
|
var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
|
|
12114
|
+
var toSafeFlatObject = (thing) => {
|
|
12115
|
+
if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
|
|
12116
|
+
return thing;
|
|
12117
|
+
}
|
|
12118
|
+
const sourcePrototype = getPrototypeOf(thing);
|
|
12119
|
+
if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
|
|
12120
|
+
return thing;
|
|
12121
|
+
}
|
|
12122
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
12123
|
+
const merged = /* @__PURE__ */ Object.create(null);
|
|
12124
|
+
const seen = [];
|
|
12125
|
+
let current = thing;
|
|
12126
|
+
while (current != null) {
|
|
12127
|
+
if (seen.indexOf(current) !== -1) {
|
|
12128
|
+
break;
|
|
12129
|
+
}
|
|
12130
|
+
seen.push(current);
|
|
12131
|
+
const prototype2 = current === thing ? sourcePrototype : getPrototypeOf(current);
|
|
12132
|
+
if (isPrototypeBoundary(current, prototype2, current === thing)) {
|
|
12133
|
+
break;
|
|
12134
|
+
}
|
|
12135
|
+
const props = Object.getOwnPropertyNames(current);
|
|
12136
|
+
if (Object.getOwnPropertySymbols) {
|
|
12137
|
+
props.push(...Object.getOwnPropertySymbols(current));
|
|
12138
|
+
}
|
|
12139
|
+
for (const prop of props) {
|
|
12140
|
+
if (isUnsafeObjectKey(prop)) {
|
|
12141
|
+
continue;
|
|
12142
|
+
}
|
|
12143
|
+
if (!hasOwnProperty(merged, prop)) {
|
|
12144
|
+
result[prop] = thing[prop];
|
|
12145
|
+
merged[prop] = true;
|
|
12146
|
+
}
|
|
12147
|
+
}
|
|
12148
|
+
current = prototype2;
|
|
12149
|
+
}
|
|
12150
|
+
return result;
|
|
12151
|
+
};
|
|
12086
12152
|
var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
|
|
12087
12153
|
const str = toString.call(thing);
|
|
12088
12154
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -12117,9 +12183,9 @@ var isPlainObject = (val) => {
|
|
|
12117
12183
|
return false;
|
|
12118
12184
|
}
|
|
12119
12185
|
const prototype2 = getPrototypeOf(val);
|
|
12120
|
-
return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat
|
|
12121
|
-
//
|
|
12122
|
-
//
|
|
12186
|
+
return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
|
|
12187
|
+
// evidence the value is tagged/iterable, while ignoring members reachable
|
|
12188
|
+
// only through shared or terminal prototype boundaries.
|
|
12123
12189
|
!hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
|
|
12124
12190
|
};
|
|
12125
12191
|
var isEmptyObject = (val) => {
|
|
@@ -12140,6 +12206,7 @@ var isReactNativeBlob = (value) => {
|
|
|
12140
12206
|
var isReactNative = (formData) => formData && typeof formData.getParts !== "undefined";
|
|
12141
12207
|
var isBlob = kindOfTest("Blob");
|
|
12142
12208
|
var isFileList = kindOfTest("FileList");
|
|
12209
|
+
var isSet = kindOfTest("Set");
|
|
12143
12210
|
var isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
12144
12211
|
function getGlobal() {
|
|
12145
12212
|
if (typeof globalThis !== "undefined") return globalThis;
|
|
@@ -12435,11 +12502,20 @@ var toJSONObject = (obj) => {
|
|
|
12435
12502
|
}
|
|
12436
12503
|
if (!("toJSON" in source)) {
|
|
12437
12504
|
visited.add(source);
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
|
|
12505
|
+
let target;
|
|
12506
|
+
if (isSet(source)) {
|
|
12507
|
+
target = [];
|
|
12508
|
+
for (const value of source) {
|
|
12509
|
+
const reducedValue = visit(value);
|
|
12510
|
+
!isUndefined(reducedValue) && target.push(reducedValue);
|
|
12511
|
+
}
|
|
12512
|
+
} else {
|
|
12513
|
+
target = isArray(source) ? [] : {};
|
|
12514
|
+
forEach(source, (value, key) => {
|
|
12515
|
+
const reducedValue = visit(value);
|
|
12516
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
12517
|
+
});
|
|
12518
|
+
}
|
|
12443
12519
|
visited.delete(source);
|
|
12444
12520
|
return target;
|
|
12445
12521
|
}
|
|
@@ -12520,6 +12596,7 @@ var utils_default = {
|
|
|
12520
12596
|
// an alias to avoid ESLint no-prototype-builtins detection
|
|
12521
12597
|
hasOwnInPrototypeChain,
|
|
12522
12598
|
getSafeProp,
|
|
12599
|
+
toSafeFlatObject,
|
|
12523
12600
|
reduceDescriptors,
|
|
12524
12601
|
freezeMethods,
|
|
12525
12602
|
toObjectSet,
|
|
@@ -12568,17 +12645,18 @@ var parseHeaders_default = (rawHeaders) => {
|
|
|
12568
12645
|
i = line.indexOf(":");
|
|
12569
12646
|
key = line.substring(0, i).trim().toLowerCase();
|
|
12570
12647
|
val = line.substring(i + 1).trim();
|
|
12571
|
-
|
|
12648
|
+
const hasKey = utils_default.hasOwnProp(parsed, key);
|
|
12649
|
+
if (!key || hasKey && utils_default.hasOwnProp(ignoreDuplicateOf, key)) {
|
|
12572
12650
|
return;
|
|
12573
12651
|
}
|
|
12574
12652
|
if (key === "set-cookie") {
|
|
12575
|
-
if (
|
|
12653
|
+
if (hasKey) {
|
|
12576
12654
|
parsed[key].push(val);
|
|
12577
12655
|
} else {
|
|
12578
12656
|
parsed[key] = [val];
|
|
12579
12657
|
}
|
|
12580
12658
|
} else {
|
|
12581
|
-
parsed[key] =
|
|
12659
|
+
parsed[key] = hasKey ? parsed[key] + ", " + val : val;
|
|
12582
12660
|
}
|
|
12583
12661
|
});
|
|
12584
12662
|
return parsed;
|
|
@@ -12642,6 +12720,90 @@ function parseTokens(str) {
|
|
|
12642
12720
|
}
|
|
12643
12721
|
return tokens;
|
|
12644
12722
|
}
|
|
12723
|
+
var parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
12724
|
+
function trimOWS(value) {
|
|
12725
|
+
let start = 0;
|
|
12726
|
+
let end = value.length;
|
|
12727
|
+
while (start < end) {
|
|
12728
|
+
const code = value.charCodeAt(start);
|
|
12729
|
+
if (code !== 9 && code !== 32) {
|
|
12730
|
+
break;
|
|
12731
|
+
}
|
|
12732
|
+
start += 1;
|
|
12733
|
+
}
|
|
12734
|
+
while (end > start) {
|
|
12735
|
+
const code = value.charCodeAt(end - 1);
|
|
12736
|
+
if (code !== 9 && code !== 32) {
|
|
12737
|
+
break;
|
|
12738
|
+
}
|
|
12739
|
+
end -= 1;
|
|
12740
|
+
}
|
|
12741
|
+
return start === 0 && end === value.length ? value : value.slice(start, end);
|
|
12742
|
+
}
|
|
12743
|
+
function decodeQuotedString(value) {
|
|
12744
|
+
const last = value.length - 1;
|
|
12745
|
+
if (last < 1 || value.charCodeAt(0) !== 34 || value.charCodeAt(last) !== 34) {
|
|
12746
|
+
return value;
|
|
12747
|
+
}
|
|
12748
|
+
let decoded = "";
|
|
12749
|
+
for (let i = 1; i < last; i++) {
|
|
12750
|
+
const code = value.charCodeAt(i);
|
|
12751
|
+
if (code === 34) {
|
|
12752
|
+
return value;
|
|
12753
|
+
}
|
|
12754
|
+
if (code === 92) {
|
|
12755
|
+
i += 1;
|
|
12756
|
+
if (i >= last) {
|
|
12757
|
+
return value;
|
|
12758
|
+
}
|
|
12759
|
+
}
|
|
12760
|
+
decoded += value[i];
|
|
12761
|
+
}
|
|
12762
|
+
return decoded;
|
|
12763
|
+
}
|
|
12764
|
+
function parseParameters(value) {
|
|
12765
|
+
const parameters = /* @__PURE__ */ Object.create(null);
|
|
12766
|
+
const str = String(value);
|
|
12767
|
+
let start = 0;
|
|
12768
|
+
let quoted = false;
|
|
12769
|
+
let escaped = false;
|
|
12770
|
+
function parseParameter(end) {
|
|
12771
|
+
const part = trimOWS(str.slice(start, end));
|
|
12772
|
+
const equals = part.indexOf("=");
|
|
12773
|
+
if (equals < 1) {
|
|
12774
|
+
return;
|
|
12775
|
+
}
|
|
12776
|
+
const name = trimOWS(part.slice(0, equals));
|
|
12777
|
+
if (!parameterNameRE.test(name)) {
|
|
12778
|
+
return;
|
|
12779
|
+
}
|
|
12780
|
+
const normalizedName = name.toLowerCase();
|
|
12781
|
+
if (normalizedName === "__proto__" || normalizedName === "constructor" || normalizedName === "prototype") {
|
|
12782
|
+
return;
|
|
12783
|
+
}
|
|
12784
|
+
const parameterValue = trimOWS(part.slice(equals + 1));
|
|
12785
|
+
parameters[normalizedName] = decodeQuotedString(parameterValue);
|
|
12786
|
+
}
|
|
12787
|
+
for (let i = 0; i < str.length; i++) {
|
|
12788
|
+
const code = str.charCodeAt(i);
|
|
12789
|
+
if (quoted) {
|
|
12790
|
+
if (escaped) {
|
|
12791
|
+
escaped = false;
|
|
12792
|
+
} else if (code === 92) {
|
|
12793
|
+
escaped = true;
|
|
12794
|
+
} else if (code === 34) {
|
|
12795
|
+
quoted = false;
|
|
12796
|
+
}
|
|
12797
|
+
} else if (code === 34) {
|
|
12798
|
+
quoted = true;
|
|
12799
|
+
} else if (code === 44 || code === 59) {
|
|
12800
|
+
parseParameter(i);
|
|
12801
|
+
start = i + 1;
|
|
12802
|
+
}
|
|
12803
|
+
}
|
|
12804
|
+
parseParameter(str.length);
|
|
12805
|
+
return parameters;
|
|
12806
|
+
}
|
|
12645
12807
|
var isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
12646
12808
|
function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
|
|
12647
12809
|
if (utils_default.isFunction(filter2)) {
|
|
@@ -12817,7 +12979,8 @@ var AxiosHeaders = class {
|
|
|
12817
12979
|
return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
|
|
12818
12980
|
}
|
|
12819
12981
|
getSetCookie() {
|
|
12820
|
-
|
|
12982
|
+
const value = this.get("set-cookie");
|
|
12983
|
+
return utils_default.isArray(value) ? value : value == null || value === false ? [] : [value];
|
|
12821
12984
|
}
|
|
12822
12985
|
get [Symbol.toStringTag]() {
|
|
12823
12986
|
return "AxiosHeaders";
|
|
@@ -12825,6 +12988,9 @@ var AxiosHeaders = class {
|
|
|
12825
12988
|
static from(thing) {
|
|
12826
12989
|
return thing instanceof this ? thing : new this(thing);
|
|
12827
12990
|
}
|
|
12991
|
+
static parseParameters(value) {
|
|
12992
|
+
return parseParameters(value);
|
|
12993
|
+
}
|
|
12828
12994
|
static concat(first, ...targets) {
|
|
12829
12995
|
const computed = new this(first);
|
|
12830
12996
|
targets.forEach((target) => computed.set(target));
|
|
@@ -12920,9 +13086,30 @@ function redactConfig(config, redactKeys) {
|
|
|
12920
13086
|
};
|
|
12921
13087
|
return visit(config);
|
|
12922
13088
|
}
|
|
13089
|
+
function stringifySafely(value) {
|
|
13090
|
+
try {
|
|
13091
|
+
return String(value);
|
|
13092
|
+
} catch (err) {
|
|
13093
|
+
return "";
|
|
13094
|
+
}
|
|
13095
|
+
}
|
|
13096
|
+
function aggregateErrorMessage(error) {
|
|
13097
|
+
const message = error.errors.map((entry) => {
|
|
13098
|
+
try {
|
|
13099
|
+
return entry && entry.message ? stringifySafely(entry.message) : stringifySafely(entry);
|
|
13100
|
+
} catch (err) {
|
|
13101
|
+
return "";
|
|
13102
|
+
}
|
|
13103
|
+
}).filter(Boolean).join("; ");
|
|
13104
|
+
return message || error.name || "AggregateError";
|
|
13105
|
+
}
|
|
12923
13106
|
var AxiosError = class _AxiosError extends Error {
|
|
12924
13107
|
static from(error, code, config, request, response, customProps) {
|
|
12925
|
-
|
|
13108
|
+
let message = error.message;
|
|
13109
|
+
if (!message && utils_default.isArray(error.errors) && error.errors.length) {
|
|
13110
|
+
message = aggregateErrorMessage(error);
|
|
13111
|
+
}
|
|
13112
|
+
const axiosError = new _AxiosError(message, code || error.code, config, request, response);
|
|
12926
13113
|
Object.defineProperty(axiosError, "cause", {
|
|
12927
13114
|
__proto__: null,
|
|
12928
13115
|
value: error,
|
|
@@ -13012,6 +13199,16 @@ var AxiosError_default = AxiosError;
|
|
|
13012
13199
|
var import_form_data = __toESM(require_form_data());
|
|
13013
13200
|
var FormData_default = import_form_data.default;
|
|
13014
13201
|
|
|
13202
|
+
// ../node_modules/axios/lib/platform/node/classes/Buffer.js
|
|
13203
|
+
var Buffer_default = {
|
|
13204
|
+
isBufferAvailable() {
|
|
13205
|
+
return typeof Buffer !== "undefined";
|
|
13206
|
+
},
|
|
13207
|
+
from(value) {
|
|
13208
|
+
return Buffer.from(value);
|
|
13209
|
+
}
|
|
13210
|
+
};
|
|
13211
|
+
|
|
13015
13212
|
// ../node_modules/axios/lib/helpers/toFormData.js
|
|
13016
13213
|
var DEFAULT_FORM_DATA_MAX_DEPTH = 100;
|
|
13017
13214
|
function isVisitable(thing) {
|
|
@@ -13038,24 +13235,16 @@ function toFormData(obj, formData, options) {
|
|
|
13038
13235
|
throw new TypeError("target must be an object");
|
|
13039
13236
|
}
|
|
13040
13237
|
formData = formData || new (FormData_default || FormData)();
|
|
13041
|
-
|
|
13042
|
-
options,
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
}
|
|
13052
|
-
);
|
|
13053
|
-
const metaTokens = options.metaTokens;
|
|
13054
|
-
const visitor = options.visitor || defaultVisitor;
|
|
13055
|
-
const dots = options.dots;
|
|
13056
|
-
const indexes = options.indexes;
|
|
13057
|
-
const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
|
|
13058
|
-
const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
|
|
13238
|
+
const option = (name, fallback) => {
|
|
13239
|
+
const value = utils_default.getSafeProp(options, name);
|
|
13240
|
+
return utils_default.isUndefined(value) ? fallback : value;
|
|
13241
|
+
};
|
|
13242
|
+
const metaTokens = option("metaTokens", true);
|
|
13243
|
+
const visitor = option("visitor") || defaultVisitor;
|
|
13244
|
+
const dots = option("dots", false);
|
|
13245
|
+
const indexes = option("indexes", false);
|
|
13246
|
+
const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
|
|
13247
|
+
const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH);
|
|
13059
13248
|
const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
|
|
13060
13249
|
const stack = [];
|
|
13061
13250
|
if (!utils_default.isFunction(visitor)) {
|
|
@@ -13076,10 +13265,13 @@ function toFormData(obj, formData, options) {
|
|
|
13076
13265
|
if (useBlob && typeof _Blob === "function") {
|
|
13077
13266
|
return new _Blob([value]);
|
|
13078
13267
|
}
|
|
13079
|
-
if (
|
|
13080
|
-
return
|
|
13268
|
+
if (Buffer_default && Buffer_default.isBufferAvailable()) {
|
|
13269
|
+
return Buffer_default.from(value);
|
|
13081
13270
|
}
|
|
13082
|
-
throw new AxiosError_default(
|
|
13271
|
+
throw new AxiosError_default(
|
|
13272
|
+
"Blob is not supported. Use a Buffer instead.",
|
|
13273
|
+
AxiosError_default.ERR_NOT_SUPPORT
|
|
13274
|
+
);
|
|
13083
13275
|
}
|
|
13084
13276
|
return value;
|
|
13085
13277
|
}
|
|
@@ -13225,9 +13417,47 @@ function buildURL(url2, params, options) {
|
|
|
13225
13417
|
}
|
|
13226
13418
|
|
|
13227
13419
|
// ../node_modules/axios/lib/core/InterceptorManager.js
|
|
13420
|
+
var $internals2 = /* @__PURE__ */ Symbol("internals");
|
|
13421
|
+
function countHandlers(handlers) {
|
|
13422
|
+
return handlers ? handlers.length : 0;
|
|
13423
|
+
}
|
|
13424
|
+
function trimHandlers(handlers) {
|
|
13425
|
+
if (!handlers) {
|
|
13426
|
+
return;
|
|
13427
|
+
}
|
|
13428
|
+
while (handlers.length && handlers[handlers.length - 1] === null) {
|
|
13429
|
+
handlers.pop();
|
|
13430
|
+
}
|
|
13431
|
+
}
|
|
13432
|
+
function syncHandlerEntries(manager, internals) {
|
|
13433
|
+
const handlers = manager.handlers;
|
|
13434
|
+
const length = countHandlers(handlers);
|
|
13435
|
+
if (handlers !== internals.handlersRef) {
|
|
13436
|
+
internals.handlersRef = handlers;
|
|
13437
|
+
internals.handlerEntries.clear();
|
|
13438
|
+
} else if (length !== internals.handlersLength) {
|
|
13439
|
+
if (!length) {
|
|
13440
|
+
internals.handlerEntries.clear();
|
|
13441
|
+
} else {
|
|
13442
|
+
internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
|
|
13443
|
+
if (handlers[entry.index] !== entry.handler) {
|
|
13444
|
+
internals.handlerEntries.delete(id);
|
|
13445
|
+
}
|
|
13446
|
+
});
|
|
13447
|
+
}
|
|
13448
|
+
}
|
|
13449
|
+
internals.handlersLength = length;
|
|
13450
|
+
}
|
|
13228
13451
|
var InterceptorManager = class {
|
|
13229
13452
|
constructor() {
|
|
13230
13453
|
this.handlers = [];
|
|
13454
|
+
this[$internals2] = {
|
|
13455
|
+
handlersRef: this.handlers,
|
|
13456
|
+
handlersLength: this.handlers.length,
|
|
13457
|
+
handlerEntries: /* @__PURE__ */ new Map(),
|
|
13458
|
+
iterationDepth: 0,
|
|
13459
|
+
nextId: 0
|
|
13460
|
+
};
|
|
13231
13461
|
}
|
|
13232
13462
|
/**
|
|
13233
13463
|
* Add a new interceptor to the stack
|
|
@@ -13239,13 +13469,25 @@ var InterceptorManager = class {
|
|
|
13239
13469
|
* @return {Number} An ID used to remove interceptor later
|
|
13240
13470
|
*/
|
|
13241
13471
|
use(fulfilled, rejected, options) {
|
|
13242
|
-
|
|
13472
|
+
const handler = {
|
|
13243
13473
|
fulfilled,
|
|
13244
13474
|
rejected,
|
|
13245
13475
|
synchronous: options ? options.synchronous : false,
|
|
13246
13476
|
runWhen: options ? options.runWhen : null
|
|
13477
|
+
};
|
|
13478
|
+
const internals = this[$internals2];
|
|
13479
|
+
if (this.handlers == null) {
|
|
13480
|
+
this.handlers = [];
|
|
13481
|
+
}
|
|
13482
|
+
syncHandlerEntries(this, internals);
|
|
13483
|
+
const id = internals.nextId++;
|
|
13484
|
+
this.handlers.push(handler);
|
|
13485
|
+
internals.handlerEntries.set(id, {
|
|
13486
|
+
handler,
|
|
13487
|
+
index: this.handlers.length - 1
|
|
13247
13488
|
});
|
|
13248
|
-
|
|
13489
|
+
internals.handlersLength = this.handlers.length;
|
|
13490
|
+
return id;
|
|
13249
13491
|
}
|
|
13250
13492
|
/**
|
|
13251
13493
|
* Remove an interceptor from the stack
|
|
@@ -13255,8 +13497,19 @@ var InterceptorManager = class {
|
|
|
13255
13497
|
* @returns {void}
|
|
13256
13498
|
*/
|
|
13257
13499
|
eject(id) {
|
|
13258
|
-
|
|
13259
|
-
|
|
13500
|
+
const internals = this[$internals2];
|
|
13501
|
+
syncHandlerEntries(this, internals);
|
|
13502
|
+
const entry = internals.handlerEntries.get(id);
|
|
13503
|
+
if (entry) {
|
|
13504
|
+
internals.handlerEntries.delete(id);
|
|
13505
|
+
if (this.handlers[entry.index] !== entry.handler) {
|
|
13506
|
+
return;
|
|
13507
|
+
}
|
|
13508
|
+
this.handlers[entry.index] = null;
|
|
13509
|
+
if (!internals.iterationDepth) {
|
|
13510
|
+
trimHandlers(this.handlers);
|
|
13511
|
+
internals.handlersLength = this.handlers.length;
|
|
13512
|
+
}
|
|
13260
13513
|
}
|
|
13261
13514
|
}
|
|
13262
13515
|
/**
|
|
@@ -13267,6 +13520,7 @@ var InterceptorManager = class {
|
|
|
13267
13520
|
clear() {
|
|
13268
13521
|
if (this.handlers) {
|
|
13269
13522
|
this.handlers = [];
|
|
13523
|
+
syncHandlerEntries(this, this[$internals2]);
|
|
13270
13524
|
}
|
|
13271
13525
|
}
|
|
13272
13526
|
/**
|
|
@@ -13280,11 +13534,22 @@ var InterceptorManager = class {
|
|
|
13280
13534
|
* @returns {void}
|
|
13281
13535
|
*/
|
|
13282
13536
|
forEach(fn) {
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13537
|
+
const internals = this[$internals2];
|
|
13538
|
+
syncHandlerEntries(this, internals);
|
|
13539
|
+
internals.iterationDepth++;
|
|
13540
|
+
try {
|
|
13541
|
+
utils_default.forEach(this.handlers, function forEachHandler(h) {
|
|
13542
|
+
if (h !== null) {
|
|
13543
|
+
fn(h);
|
|
13544
|
+
}
|
|
13545
|
+
});
|
|
13546
|
+
} finally {
|
|
13547
|
+
if (!--internals.iterationDepth) {
|
|
13548
|
+
syncHandlerEntries(this, internals);
|
|
13549
|
+
trimHandlers(this.handlers);
|
|
13550
|
+
internals.handlersLength = countHandlers(this.handlers);
|
|
13286
13551
|
}
|
|
13287
|
-
}
|
|
13552
|
+
}
|
|
13288
13553
|
}
|
|
13289
13554
|
};
|
|
13290
13555
|
var InterceptorManager_default = InterceptorManager;
|
|
@@ -13380,7 +13645,7 @@ function throwIfDepthExceeded(index) {
|
|
|
13380
13645
|
}
|
|
13381
13646
|
function parsePropPath(name) {
|
|
13382
13647
|
const path = [];
|
|
13383
|
-
const pattern =
|
|
13648
|
+
const pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
|
|
13384
13649
|
let match;
|
|
13385
13650
|
while ((match = pattern.exec(name)) !== null) {
|
|
13386
13651
|
throwIfDepthExceeded(path.length);
|
|
@@ -13436,9 +13701,25 @@ function formDataToJSON(formData) {
|
|
|
13436
13701
|
}
|
|
13437
13702
|
var formDataToJSON_default = formDataToJSON;
|
|
13438
13703
|
|
|
13704
|
+
// ../node_modules/axios/lib/core/methodList.js
|
|
13705
|
+
var methodList = Object.freeze([
|
|
13706
|
+
"get",
|
|
13707
|
+
"delete",
|
|
13708
|
+
"head",
|
|
13709
|
+
"options",
|
|
13710
|
+
"post",
|
|
13711
|
+
"put",
|
|
13712
|
+
"patch",
|
|
13713
|
+
"purge",
|
|
13714
|
+
"link",
|
|
13715
|
+
"unlink",
|
|
13716
|
+
"query"
|
|
13717
|
+
]);
|
|
13718
|
+
var methodList_default = methodList;
|
|
13719
|
+
|
|
13439
13720
|
// ../node_modules/axios/lib/defaults/index.js
|
|
13440
13721
|
var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
|
|
13441
|
-
function
|
|
13722
|
+
function stringifySafely2(rawValue, parser, encoder) {
|
|
13442
13723
|
if (utils_default.isString(rawValue)) {
|
|
13443
13724
|
try {
|
|
13444
13725
|
(parser || JSON.parse)(rawValue);
|
|
@@ -13494,7 +13775,7 @@ var defaults = {
|
|
|
13494
13775
|
}
|
|
13495
13776
|
if (isObjectPayload || hasJSONContentType) {
|
|
13496
13777
|
headers.setContentType("application/json", false);
|
|
13497
|
-
return
|
|
13778
|
+
return stringifySafely2(data);
|
|
13498
13779
|
}
|
|
13499
13780
|
return data;
|
|
13500
13781
|
}
|
|
@@ -13548,7 +13829,7 @@ var defaults = {
|
|
|
13548
13829
|
}
|
|
13549
13830
|
}
|
|
13550
13831
|
};
|
|
13551
|
-
utils_default.forEach(
|
|
13832
|
+
utils_default.forEach(methodList_default, (method) => {
|
|
13552
13833
|
defaults.headers[method] = {};
|
|
13553
13834
|
});
|
|
13554
13835
|
var defaults_default = defaults;
|
|
@@ -13616,29 +13897,62 @@ function isAbsoluteURL(url2) {
|
|
|
13616
13897
|
|
|
13617
13898
|
// ../node_modules/axios/lib/helpers/combineURLs.js
|
|
13618
13899
|
function combineURLs(baseURL, relativeURL) {
|
|
13619
|
-
|
|
13900
|
+
if (!relativeURL) {
|
|
13901
|
+
return baseURL;
|
|
13902
|
+
}
|
|
13903
|
+
let end = baseURL.length;
|
|
13904
|
+
while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
|
|
13905
|
+
end--;
|
|
13906
|
+
}
|
|
13907
|
+
return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
|
|
13908
|
+
}
|
|
13909
|
+
|
|
13910
|
+
// ../node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js
|
|
13911
|
+
var urlParserControlCharacters = /[\t\n\r]/g;
|
|
13912
|
+
function normalizeURLForProtocolCheck(url2) {
|
|
13913
|
+
if (typeof url2 !== "string") {
|
|
13914
|
+
return url2;
|
|
13915
|
+
}
|
|
13916
|
+
let start = 0;
|
|
13917
|
+
while (start < url2.length && url2.charCodeAt(start) <= 32) {
|
|
13918
|
+
start++;
|
|
13919
|
+
}
|
|
13920
|
+
return url2.slice(start).replace(urlParserControlCharacters, "");
|
|
13620
13921
|
}
|
|
13621
13922
|
|
|
13622
13923
|
// ../node_modules/axios/lib/core/buildFullPath.js
|
|
13623
13924
|
var malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
while (i < url2.length && url2.charCodeAt(i) <= 32) {
|
|
13628
|
-
i++;
|
|
13925
|
+
function redactFragment(fragment) {
|
|
13926
|
+
if (!fragment) {
|
|
13927
|
+
return fragment;
|
|
13629
13928
|
}
|
|
13630
|
-
return
|
|
13929
|
+
return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, (match, separator, parameterName = "") => {
|
|
13930
|
+
return `${separator}${parameterName}${REDACTED}`;
|
|
13931
|
+
});
|
|
13631
13932
|
}
|
|
13632
|
-
function
|
|
13633
|
-
|
|
13933
|
+
function redactSensitiveURLParts(url2) {
|
|
13934
|
+
const redactedURL = url2.replace(/^(https?:\/{0,2})[^/?#]*@/i, `$1${REDACTED}@`);
|
|
13935
|
+
const fragmentIndex = redactedURL.indexOf("#");
|
|
13936
|
+
const urlWithoutFragment = fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
|
|
13937
|
+
const redactedURLWithoutFragment = urlWithoutFragment.replace(
|
|
13938
|
+
/([?&][^=&#]*=)[^&#]*/g,
|
|
13939
|
+
`$1${REDACTED}`
|
|
13940
|
+
);
|
|
13941
|
+
if (fragmentIndex === -1) {
|
|
13942
|
+
return redactedURLWithoutFragment;
|
|
13943
|
+
}
|
|
13944
|
+
return `${redactedURLWithoutFragment}#${redactFragment(redactedURL.slice(fragmentIndex + 1))}`;
|
|
13634
13945
|
}
|
|
13635
13946
|
function assertValidHttpProtocolURL(url2, config) {
|
|
13636
|
-
if (typeof url2 === "string"
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
AxiosError_default
|
|
13640
|
-
|
|
13641
|
-
|
|
13947
|
+
if (typeof url2 === "string") {
|
|
13948
|
+
const normalizedURL = normalizeURLForProtocolCheck(url2);
|
|
13949
|
+
if (malformedHttpProtocol.test(normalizedURL)) {
|
|
13950
|
+
throw new AxiosError_default(
|
|
13951
|
+
`Invalid URL ${JSON.stringify(redactSensitiveURLParts(normalizedURL))}: missing "//" after protocol`,
|
|
13952
|
+
AxiosError_default.ERR_INVALID_URL,
|
|
13953
|
+
config
|
|
13954
|
+
);
|
|
13955
|
+
}
|
|
13642
13956
|
}
|
|
13643
13957
|
}
|
|
13644
13958
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
|
|
@@ -13723,7 +14037,7 @@ var import_https_proxy_agent = __toESM(require_dist());
|
|
|
13723
14037
|
var import_follow_redirects = __toESM(require_follow_redirects());
|
|
13724
14038
|
|
|
13725
14039
|
// ../node_modules/axios/lib/env/data.js
|
|
13726
|
-
var VERSION = "1.
|
|
14040
|
+
var VERSION = "1.20.0";
|
|
13727
14041
|
|
|
13728
14042
|
// ../node_modules/axios/lib/helpers/parseProtocol.js
|
|
13729
14043
|
function parseProtocol(url2) {
|
|
@@ -13732,7 +14046,7 @@ function parseProtocol(url2) {
|
|
|
13732
14046
|
}
|
|
13733
14047
|
|
|
13734
14048
|
// ../node_modules/axios/lib/helpers/fromDataURI.js
|
|
13735
|
-
var DATA_URL_PATTERN = /^([
|
|
14049
|
+
var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
|
|
13736
14050
|
function fromDataURI(uri, asBlob, options) {
|
|
13737
14051
|
const _Blob = options && options.Blob || platform_default.classes.Blob;
|
|
13738
14052
|
const protocol = parseProtocol(uri);
|
|
@@ -13766,6 +14080,20 @@ function fromDataURI(uri, asBlob, options) {
|
|
|
13766
14080
|
}
|
|
13767
14081
|
throw new AxiosError_default("Unsupported protocol " + protocol, AxiosError_default.ERR_NOT_SUPPORT);
|
|
13768
14082
|
}
|
|
14083
|
+
|
|
14084
|
+
// ../node_modules/axios/lib/core/setFormDataHeaders.js
|
|
14085
|
+
var FORM_DATA_CONTENT_HEADERS = ["content-type", "content-length"];
|
|
14086
|
+
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
14087
|
+
if (policy !== "content-only") {
|
|
14088
|
+
headers.set(formHeaders);
|
|
14089
|
+
return;
|
|
14090
|
+
}
|
|
14091
|
+
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
14092
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
14093
|
+
headers.set(key, val);
|
|
14094
|
+
}
|
|
14095
|
+
});
|
|
14096
|
+
}
|
|
13769
14097
|
var kInternals = /* @__PURE__ */ Symbol("internals");
|
|
13770
14098
|
var AxiosTransformStream = class extends stream3.Transform {
|
|
13771
14099
|
constructor(options) {
|
|
@@ -14011,6 +14339,7 @@ var Http2Sessions = class {
|
|
|
14011
14339
|
}
|
|
14012
14340
|
getSession(authority, options) {
|
|
14013
14341
|
options = Object.assign(
|
|
14342
|
+
/* @__PURE__ */ Object.create(null),
|
|
14014
14343
|
{
|
|
14015
14344
|
sessionTimeout: 1e3
|
|
14016
14345
|
},
|
|
@@ -14076,6 +14405,7 @@ var Http2Sessions = class {
|
|
|
14076
14405
|
};
|
|
14077
14406
|
}
|
|
14078
14407
|
session.once("close", removeSession);
|
|
14408
|
+
session.once("error", removeSession);
|
|
14079
14409
|
let entry = [session, options];
|
|
14080
14410
|
authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
|
|
14081
14411
|
return session;
|
|
@@ -14100,12 +14430,73 @@ var callbackify_default = callbackify;
|
|
|
14100
14430
|
|
|
14101
14431
|
// ../node_modules/axios/lib/helpers/shouldBypassProxy.js
|
|
14102
14432
|
var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
|
|
14433
|
+
var trimTrailingDots = (value) => {
|
|
14434
|
+
let end = value.length;
|
|
14435
|
+
while (end && value.charCodeAt(end - 1) === 46) {
|
|
14436
|
+
end--;
|
|
14437
|
+
}
|
|
14438
|
+
return end === value.length ? value : value.slice(0, end);
|
|
14439
|
+
};
|
|
14103
14440
|
var isIPv4Loopback = (host) => {
|
|
14104
14441
|
const parts = host.split(".");
|
|
14105
14442
|
if (parts.length !== 4) return false;
|
|
14106
14443
|
if (parts[0] !== "127") return false;
|
|
14107
14444
|
return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
|
|
14108
14445
|
};
|
|
14446
|
+
var parseIPv4Octet = (text) => {
|
|
14447
|
+
if (/^0[xX][0-9a-fA-F]+$/.test(text)) {
|
|
14448
|
+
const n = parseInt(text.slice(2), 16);
|
|
14449
|
+
return Number.isFinite(n) ? n : null;
|
|
14450
|
+
}
|
|
14451
|
+
if (text.length > 1 && /^0[0-7]+$/.test(text)) {
|
|
14452
|
+
const n = parseInt(text, 8);
|
|
14453
|
+
return Number.isFinite(n) ? n : null;
|
|
14454
|
+
}
|
|
14455
|
+
if (text.length > 1 && /^0[0-9]+$/.test(text)) {
|
|
14456
|
+
return null;
|
|
14457
|
+
}
|
|
14458
|
+
if (/^[0-9]+$/.test(text)) {
|
|
14459
|
+
const n = parseInt(text, 10);
|
|
14460
|
+
return Number.isFinite(n) ? n : null;
|
|
14461
|
+
}
|
|
14462
|
+
return null;
|
|
14463
|
+
};
|
|
14464
|
+
var normalizeIPAddress = (host) => {
|
|
14465
|
+
if (typeof host !== "string" || !host || host.indexOf(":") !== -1) {
|
|
14466
|
+
return host;
|
|
14467
|
+
}
|
|
14468
|
+
let h = host;
|
|
14469
|
+
if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
|
|
14470
|
+
h = h.slice(1, -1);
|
|
14471
|
+
}
|
|
14472
|
+
h = trimTrailingDots(h);
|
|
14473
|
+
if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
|
|
14474
|
+
const parts = h.split(".");
|
|
14475
|
+
if (parts.some((p) => p === "")) return host;
|
|
14476
|
+
if (parts.length === 4) {
|
|
14477
|
+
const octets = parts.map(parseIPv4Octet);
|
|
14478
|
+
if (octets.some((n) => n === null || n < 0 || n > 255)) return host;
|
|
14479
|
+
return octets.join(".");
|
|
14480
|
+
}
|
|
14481
|
+
if (parts.length > 4) {
|
|
14482
|
+
return host;
|
|
14483
|
+
}
|
|
14484
|
+
if (parts.length === 1) return host;
|
|
14485
|
+
const literalOctets = parts.slice(0, -1);
|
|
14486
|
+
const tail = parts[parts.length - 1];
|
|
14487
|
+
const tailSlots = 4 - literalOctets.length;
|
|
14488
|
+
const tailValue = parseIPv4Octet(tail);
|
|
14489
|
+
if (tailValue === null) return host;
|
|
14490
|
+
const maxTail = (1 << 8 * tailSlots) - 1;
|
|
14491
|
+
if (tailValue < 0 || tailValue > maxTail) return host;
|
|
14492
|
+
const tailOctets = new Array(tailSlots).fill(0);
|
|
14493
|
+
for (let i = tailSlots - 1, v = tailValue; i >= 0; i--, v >>= 8) {
|
|
14494
|
+
tailOctets[i] = v & 255;
|
|
14495
|
+
}
|
|
14496
|
+
const literal = literalOctets.map(parseIPv4Octet);
|
|
14497
|
+
if (literal.some((n) => n === null || n < 0 || n > 255)) return host;
|
|
14498
|
+
return [...literal, ...tailOctets].join(".");
|
|
14499
|
+
};
|
|
14109
14500
|
var isIPv6ZeroGroup = (group) => /^0{1,4}$/.test(group);
|
|
14110
14501
|
var isIPv6Unspecified = (host) => {
|
|
14111
14502
|
if (host === "::") return true;
|
|
@@ -14190,6 +14581,40 @@ var unmapIPv4MappedIPv6 = (host) => {
|
|
|
14190
14581
|
}
|
|
14191
14582
|
return host;
|
|
14192
14583
|
};
|
|
14584
|
+
var IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
|
|
14585
|
+
var ipv4ToBytes = (host) => {
|
|
14586
|
+
const parts = host.split(".");
|
|
14587
|
+
return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
|
|
14588
|
+
};
|
|
14589
|
+
var IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
|
|
14590
|
+
var ipv6ToBytes = (host) => {
|
|
14591
|
+
const halves = host.split("::");
|
|
14592
|
+
if (halves.length > 2) {
|
|
14593
|
+
return null;
|
|
14594
|
+
}
|
|
14595
|
+
const groups = halves[0] ? halves[0].split(":") : [];
|
|
14596
|
+
if (halves.length === 2) {
|
|
14597
|
+
const rear = halves[1] ? halves[1].split(":") : [];
|
|
14598
|
+
const missing = 8 - groups.length - rear.length;
|
|
14599
|
+
if (missing < 1) {
|
|
14600
|
+
return null;
|
|
14601
|
+
}
|
|
14602
|
+
groups.push(...new Array(missing).fill("0"), ...rear);
|
|
14603
|
+
}
|
|
14604
|
+
if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
|
|
14605
|
+
return null;
|
|
14606
|
+
}
|
|
14607
|
+
return groups.flatMap((group) => {
|
|
14608
|
+
const value = Number.parseInt(group, 16);
|
|
14609
|
+
return [value >> 8 & 255, value & 255];
|
|
14610
|
+
});
|
|
14611
|
+
};
|
|
14612
|
+
var ipToBytes = (host) => {
|
|
14613
|
+
if (typeof host !== "string" || !host) {
|
|
14614
|
+
return null;
|
|
14615
|
+
}
|
|
14616
|
+
return host.indexOf(":") !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
|
|
14617
|
+
};
|
|
14193
14618
|
var normalizeNoProxyHost = (hostname) => {
|
|
14194
14619
|
if (!hostname) {
|
|
14195
14620
|
return hostname;
|
|
@@ -14197,7 +14622,89 @@ var normalizeNoProxyHost = (hostname) => {
|
|
|
14197
14622
|
if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
|
|
14198
14623
|
hostname = hostname.slice(1, -1);
|
|
14199
14624
|
}
|
|
14200
|
-
|
|
14625
|
+
const trimmed = trimTrailingDots(hostname);
|
|
14626
|
+
const ipv4 = normalizeIPAddress(trimmed);
|
|
14627
|
+
if (ipv4 !== trimmed) {
|
|
14628
|
+
return ipv4;
|
|
14629
|
+
}
|
|
14630
|
+
return unmapIPv4MappedIPv6(trimmed);
|
|
14631
|
+
};
|
|
14632
|
+
var normalizeCidrBase = (input) => {
|
|
14633
|
+
let base = input;
|
|
14634
|
+
const startsBracket = base.charAt(0) === "[";
|
|
14635
|
+
const endsBracket = base.charAt(base.length - 1) === "]";
|
|
14636
|
+
const hasBracket = base.includes("[") || base.includes("]");
|
|
14637
|
+
if (startsBracket || endsBracket) {
|
|
14638
|
+
if (!startsBracket || !endsBracket) {
|
|
14639
|
+
return null;
|
|
14640
|
+
}
|
|
14641
|
+
base = base.slice(1, -1);
|
|
14642
|
+
if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
|
|
14643
|
+
return null;
|
|
14644
|
+
}
|
|
14645
|
+
} else if (hasBracket) {
|
|
14646
|
+
return null;
|
|
14647
|
+
}
|
|
14648
|
+
if (!base || base.charAt(base.length - 1) === ".") {
|
|
14649
|
+
return null;
|
|
14650
|
+
}
|
|
14651
|
+
const wasIPv6 = base.indexOf(":") !== -1;
|
|
14652
|
+
if (wasIPv6) {
|
|
14653
|
+
try {
|
|
14654
|
+
base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
|
|
14655
|
+
} catch (_err) {
|
|
14656
|
+
return null;
|
|
14657
|
+
}
|
|
14658
|
+
} else {
|
|
14659
|
+
base = normalizeIPAddress(base);
|
|
14660
|
+
if (!ipv4ToBytes(base)) {
|
|
14661
|
+
return null;
|
|
14662
|
+
}
|
|
14663
|
+
}
|
|
14664
|
+
return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
|
|
14665
|
+
};
|
|
14666
|
+
var CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
|
|
14667
|
+
var parseCidrEntry = (entry) => {
|
|
14668
|
+
if (entry.indexOf("/") === -1) {
|
|
14669
|
+
return void 0;
|
|
14670
|
+
}
|
|
14671
|
+
const match = CIDR_ENTRY_RE.exec(entry);
|
|
14672
|
+
if (!match) {
|
|
14673
|
+
return null;
|
|
14674
|
+
}
|
|
14675
|
+
let prefix = Number(match[2]);
|
|
14676
|
+
const parsedBase = normalizeCidrBase(match[1]);
|
|
14677
|
+
if (!parsedBase) {
|
|
14678
|
+
return null;
|
|
14679
|
+
}
|
|
14680
|
+
const { normalized, wasIPv6 } = parsedBase;
|
|
14681
|
+
if (wasIPv6 && normalized.indexOf(":") === -1) {
|
|
14682
|
+
if (prefix < 96) {
|
|
14683
|
+
return null;
|
|
14684
|
+
}
|
|
14685
|
+
prefix -= 96;
|
|
14686
|
+
}
|
|
14687
|
+
const bytes = ipToBytes(normalized);
|
|
14688
|
+
if (!bytes || prefix > bytes.length * 8) {
|
|
14689
|
+
return null;
|
|
14690
|
+
}
|
|
14691
|
+
return { bytes, prefix };
|
|
14692
|
+
};
|
|
14693
|
+
var isInSubnet = (addressBytes, networkBytes, prefix) => {
|
|
14694
|
+
const fullBytes = prefix >> 3;
|
|
14695
|
+
for (let i = 0; i < fullBytes; i++) {
|
|
14696
|
+
if (addressBytes[i] !== networkBytes[i]) {
|
|
14697
|
+
return false;
|
|
14698
|
+
}
|
|
14699
|
+
}
|
|
14700
|
+
const remainingBits = prefix & 7;
|
|
14701
|
+
if (remainingBits) {
|
|
14702
|
+
const mask = 255 << 8 - remainingBits & 255;
|
|
14703
|
+
if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
|
|
14704
|
+
return false;
|
|
14705
|
+
}
|
|
14706
|
+
}
|
|
14707
|
+
return true;
|
|
14201
14708
|
};
|
|
14202
14709
|
function shouldBypassProxy(location) {
|
|
14203
14710
|
let parsed;
|
|
@@ -14215,10 +14722,18 @@ function shouldBypassProxy(location) {
|
|
|
14215
14722
|
}
|
|
14216
14723
|
const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
|
|
14217
14724
|
const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
|
|
14725
|
+
const hostnameBytes = ipToBytes(hostname);
|
|
14218
14726
|
return noProxy.split(/[\s,]+/).some((entry) => {
|
|
14219
14727
|
if (!entry) {
|
|
14220
14728
|
return false;
|
|
14221
14729
|
}
|
|
14730
|
+
if (entry === "*") {
|
|
14731
|
+
return true;
|
|
14732
|
+
}
|
|
14733
|
+
const cidr = parseCidrEntry(entry);
|
|
14734
|
+
if (cidr !== void 0) {
|
|
14735
|
+
return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
|
|
14736
|
+
}
|
|
14222
14737
|
let [entryHost, entryPort] = parseNoProxyEntry(entry);
|
|
14223
14738
|
entryHost = normalizeNoProxyHost(entryHost);
|
|
14224
14739
|
if (!entryHost) {
|
|
@@ -14304,7 +14819,8 @@ function throttle(fn, freq) {
|
|
|
14304
14819
|
}
|
|
14305
14820
|
};
|
|
14306
14821
|
const flush = () => lastArgs && invoke(lastArgs);
|
|
14307
|
-
|
|
14822
|
+
const flushWith = (...args) => invoke(args);
|
|
14823
|
+
return [throttled, flush, flushWith];
|
|
14308
14824
|
}
|
|
14309
14825
|
var throttle_default = throttle;
|
|
14310
14826
|
|
|
@@ -14313,12 +14829,12 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
14313
14829
|
let bytesNotified = 0;
|
|
14314
14830
|
const _speedometer = speedometer_default(50, 250);
|
|
14315
14831
|
return throttle_default((e) => {
|
|
14316
|
-
if (!e ||
|
|
14832
|
+
if (!e || !utils_default.isNumber(e.loaded)) {
|
|
14317
14833
|
return;
|
|
14318
14834
|
}
|
|
14319
14835
|
const rawLoaded = e.loaded;
|
|
14320
14836
|
const total = e.lengthComputable ? e.total : void 0;
|
|
14321
|
-
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
14837
|
+
const loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
|
|
14322
14838
|
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
14323
14839
|
const rate = _speedometer(progressBytes);
|
|
14324
14840
|
bytesNotified = Math.max(bytesNotified, loaded);
|
|
@@ -14347,12 +14863,66 @@ var progressEventDecorator = (total, throttled) => {
|
|
|
14347
14863
|
throttled[1]
|
|
14348
14864
|
];
|
|
14349
14865
|
};
|
|
14350
|
-
var asyncDecorator = (fn) => (...args) =>
|
|
14866
|
+
var asyncDecorator = (fn, scheduler = utils_default.asap) => (...args) => scheduler(() => fn(...args));
|
|
14351
14867
|
|
|
14352
14868
|
// ../node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js
|
|
14353
14869
|
var isHexDigit = (charCode) => charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
|
|
14354
14870
|
var isPercentEncodedByte = (str, i, len) => i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
14355
|
-
|
|
14871
|
+
var hexValue = (charCode) => charCode <= 57 ? charCode - 48 : (charCode & 223) - 55;
|
|
14872
|
+
var isBase64Char = (charCode) => charCode >= 65 && charCode <= 90 || // A-Z
|
|
14873
|
+
charCode >= 97 && charCode <= 122 || // a-z
|
|
14874
|
+
charCode >= 48 && charCode <= 57 || // 0-9
|
|
14875
|
+
charCode === 43 || // +
|
|
14876
|
+
charCode === 47 || // /
|
|
14877
|
+
charCode === 45 || // - (base64url)
|
|
14878
|
+
charCode === 95;
|
|
14879
|
+
var isBase64Whitespace = (charCode) => charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
|
|
14880
|
+
var base64Bytes = (significant) => {
|
|
14881
|
+
const groups = Math.floor(significant / 4);
|
|
14882
|
+
const remainder = significant % 4;
|
|
14883
|
+
return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
|
|
14884
|
+
};
|
|
14885
|
+
var estimateBase64BufferAllocation = (body) => {
|
|
14886
|
+
const len = body.length;
|
|
14887
|
+
let padding = 0;
|
|
14888
|
+
if (len > 0 && body.charCodeAt(len - 1) === 61) {
|
|
14889
|
+
padding++;
|
|
14890
|
+
if (len > 1 && body.charCodeAt(len - 2) === 61) {
|
|
14891
|
+
padding++;
|
|
14892
|
+
}
|
|
14893
|
+
}
|
|
14894
|
+
return Math.floor((len - padding) * 3 / 4);
|
|
14895
|
+
};
|
|
14896
|
+
var estimatePercentDecodedBase64Bytes = (body) => {
|
|
14897
|
+
const len = body.length;
|
|
14898
|
+
let significant = 0;
|
|
14899
|
+
let padding = 0;
|
|
14900
|
+
let invalid = false;
|
|
14901
|
+
for (let i = 0; i < len; i++) {
|
|
14902
|
+
let code = body.charCodeAt(i);
|
|
14903
|
+
if (code === 37 && isPercentEncodedByte(body, i, len)) {
|
|
14904
|
+
code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
|
|
14905
|
+
i += 2;
|
|
14906
|
+
}
|
|
14907
|
+
if (isBase64Whitespace(code)) {
|
|
14908
|
+
continue;
|
|
14909
|
+
}
|
|
14910
|
+
if (code === 61) {
|
|
14911
|
+
padding++;
|
|
14912
|
+
continue;
|
|
14913
|
+
}
|
|
14914
|
+
if (!isBase64Char(code) || padding > 0) {
|
|
14915
|
+
invalid = true;
|
|
14916
|
+
continue;
|
|
14917
|
+
}
|
|
14918
|
+
significant++;
|
|
14919
|
+
}
|
|
14920
|
+
if (invalid || padding > 2 || padding > 0 && (significant + padding) % 4 !== 0 || significant % 4 === 1) {
|
|
14921
|
+
return estimateBase64BufferAllocation(body);
|
|
14922
|
+
}
|
|
14923
|
+
return base64Bytes(significant);
|
|
14924
|
+
};
|
|
14925
|
+
var estimateDataURLBytes = (url2, estimateBase64) => {
|
|
14356
14926
|
if (!url2 || typeof url2 !== "string") return 0;
|
|
14357
14927
|
if (!url2.startsWith("data:")) return 0;
|
|
14358
14928
|
const comma = url2.indexOf(",");
|
|
@@ -14361,43 +14931,7 @@ function estimateDataURLDecodedBytes(url2) {
|
|
|
14361
14931
|
const body = url2.slice(comma + 1);
|
|
14362
14932
|
const isBase64 = /;base64/i.test(meta);
|
|
14363
14933
|
if (isBase64) {
|
|
14364
|
-
|
|
14365
|
-
const len = body.length;
|
|
14366
|
-
for (let i = 0; i < len; i++) {
|
|
14367
|
-
if (body.charCodeAt(i) === 37 && i + 2 < len) {
|
|
14368
|
-
const a = body.charCodeAt(i + 1);
|
|
14369
|
-
const b = body.charCodeAt(i + 2);
|
|
14370
|
-
const isHex = isHexDigit(a) && isHexDigit(b);
|
|
14371
|
-
if (isHex) {
|
|
14372
|
-
effectiveLen -= 2;
|
|
14373
|
-
i += 2;
|
|
14374
|
-
}
|
|
14375
|
-
}
|
|
14376
|
-
}
|
|
14377
|
-
let pad = 0;
|
|
14378
|
-
let idx = len - 1;
|
|
14379
|
-
const tailIsPct3D = (j) => j >= 2 && body.charCodeAt(j - 2) === 37 && // '%'
|
|
14380
|
-
body.charCodeAt(j - 1) === 51 && // '3'
|
|
14381
|
-
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
|
|
14382
|
-
if (idx >= 0) {
|
|
14383
|
-
if (body.charCodeAt(idx) === 61) {
|
|
14384
|
-
pad++;
|
|
14385
|
-
idx--;
|
|
14386
|
-
} else if (tailIsPct3D(idx)) {
|
|
14387
|
-
pad++;
|
|
14388
|
-
idx -= 3;
|
|
14389
|
-
}
|
|
14390
|
-
}
|
|
14391
|
-
if (pad === 1 && idx >= 0) {
|
|
14392
|
-
if (body.charCodeAt(idx) === 61) {
|
|
14393
|
-
pad++;
|
|
14394
|
-
} else if (tailIsPct3D(idx)) {
|
|
14395
|
-
pad++;
|
|
14396
|
-
}
|
|
14397
|
-
}
|
|
14398
|
-
const groups = Math.floor(effectiveLen / 4);
|
|
14399
|
-
const bytes2 = groups * 3 - (pad || 0);
|
|
14400
|
-
return bytes2 > 0 ? bytes2 : 0;
|
|
14934
|
+
return estimateBase64(body);
|
|
14401
14935
|
}
|
|
14402
14936
|
let bytes = 0;
|
|
14403
14937
|
for (let i = 0, len = body.length; i < len; i++) {
|
|
@@ -14422,6 +14956,16 @@ function estimateDataURLDecodedBytes(url2) {
|
|
|
14422
14956
|
}
|
|
14423
14957
|
}
|
|
14424
14958
|
return bytes;
|
|
14959
|
+
};
|
|
14960
|
+
function estimateDataURLDecodedBytes(url2) {
|
|
14961
|
+
const fragmentIndex = typeof url2 === "string" ? url2.indexOf("#") : -1;
|
|
14962
|
+
return estimateDataURLBytes(
|
|
14963
|
+
fragmentIndex === -1 ? url2 : url2.slice(0, fragmentIndex),
|
|
14964
|
+
estimatePercentDecodedBase64Bytes
|
|
14965
|
+
);
|
|
14966
|
+
}
|
|
14967
|
+
function estimateDataURLBufferAllocation(url2) {
|
|
14968
|
+
return estimateDataURLBytes(url2, estimateBase64BufferAllocation);
|
|
14425
14969
|
}
|
|
14426
14970
|
|
|
14427
14971
|
// ../node_modules/axios/lib/adapters/http.js
|
|
@@ -14441,22 +14985,17 @@ var isBrotliSupported = utils_default.isFunction(zlib.createBrotliDecompress);
|
|
|
14441
14985
|
var isZstdSupported = utils_default.isFunction(zlib.createZstdDecompress);
|
|
14442
14986
|
var ACCEPT_ENCODING = "gzip, compress, deflate" + (isBrotliSupported ? ", br" : "");
|
|
14443
14987
|
var ACCEPT_ENCODING_WITH_ZSTD = ACCEPT_ENCODING + (isZstdSupported ? ", zstd" : "");
|
|
14988
|
+
var scheduleProgress = typeof process !== "undefined" && process.nextTick ? process.nextTick.bind(process) : utils_default.asap;
|
|
14444
14989
|
var { http: httpFollow, https: httpsFollow } = import_follow_redirects.default;
|
|
14445
14990
|
var isHttps = /https:?/;
|
|
14446
|
-
var FORM_DATA_CONTENT_HEADERS = ["content-type", "content-length"];
|
|
14447
|
-
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
14448
|
-
if (policy !== "content-only") {
|
|
14449
|
-
headers.set(formHeaders);
|
|
14450
|
-
return;
|
|
14451
|
-
}
|
|
14452
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
14453
|
-
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
14454
|
-
headers.set(key, val);
|
|
14455
|
-
}
|
|
14456
|
-
});
|
|
14457
|
-
}
|
|
14458
14991
|
var kAxiosSocketListener = /* @__PURE__ */ Symbol("axios.http.socketListener");
|
|
14459
14992
|
var kAxiosCurrentReq = /* @__PURE__ */ Symbol("axios.http.currentReq");
|
|
14993
|
+
function handleSocketError(err) {
|
|
14994
|
+
const current = this[kAxiosCurrentReq];
|
|
14995
|
+
if (current && !current.destroyed) {
|
|
14996
|
+
current.destroy(err);
|
|
14997
|
+
}
|
|
14998
|
+
}
|
|
14460
14999
|
var kAxiosInstalledTunnel = /* @__PURE__ */ Symbol("axios.http.installedTunnel");
|
|
14461
15000
|
var tunnelingAgentCache = /* @__PURE__ */ new Map();
|
|
14462
15001
|
var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
|
|
@@ -14559,10 +15098,10 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
|
|
|
14559
15098
|
return false;
|
|
14560
15099
|
}
|
|
14561
15100
|
}
|
|
14562
|
-
function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
|
|
15101
|
+
function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
|
|
14563
15102
|
let proxy = configProxy;
|
|
14564
15103
|
const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
|
|
14565
|
-
if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
|
|
15104
|
+
if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
|
|
14566
15105
|
const proxyUrl = getProxyForUrl(location);
|
|
14567
15106
|
if (proxyUrl) {
|
|
14568
15107
|
if (!shouldBypassProxy(location)) {
|
|
@@ -14659,9 +15198,13 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
|
|
|
14659
15198
|
redirectOptions.href,
|
|
14660
15199
|
true,
|
|
14661
15200
|
configHttpsAgent,
|
|
14662
|
-
configHttpAgent
|
|
15201
|
+
configHttpAgent,
|
|
15202
|
+
allowEnvProxy
|
|
14663
15203
|
);
|
|
14664
15204
|
};
|
|
15205
|
+
return Boolean(
|
|
15206
|
+
proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent)
|
|
15207
|
+
);
|
|
14665
15208
|
}
|
|
14666
15209
|
var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
|
|
14667
15210
|
var wrapAsync = (asyncExecutor) => {
|
|
@@ -14686,7 +15229,7 @@ var wrapAsync = (asyncExecutor) => {
|
|
|
14686
15229
|
};
|
|
14687
15230
|
var resolveFamily = ({ address, family }) => {
|
|
14688
15231
|
if (!utils_default.isString(address)) {
|
|
14689
|
-
throw
|
|
15232
|
+
throw new AxiosError_default("address must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE);
|
|
14690
15233
|
}
|
|
14691
15234
|
return {
|
|
14692
15235
|
address,
|
|
@@ -14694,12 +15237,36 @@ var resolveFamily = ({ address, family }) => {
|
|
|
14694
15237
|
};
|
|
14695
15238
|
};
|
|
14696
15239
|
var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
|
|
14697
|
-
var
|
|
14698
|
-
|
|
14699
|
-
|
|
14700
|
-
|
|
14701
|
-
|
|
14702
|
-
|
|
15240
|
+
var normalizedLookupCache = /* @__PURE__ */ new WeakMap();
|
|
15241
|
+
var normalizeLookup = (lookup) => {
|
|
15242
|
+
let normalized = normalizedLookupCache.get(lookup);
|
|
15243
|
+
if (normalized) {
|
|
15244
|
+
return normalized;
|
|
15245
|
+
}
|
|
15246
|
+
const callbackLookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
|
|
15247
|
+
normalized = (hostname, opt, cb) => {
|
|
15248
|
+
callbackLookup(hostname, opt, (err, arg0, arg1) => {
|
|
15249
|
+
if (err) {
|
|
15250
|
+
return cb(err);
|
|
15251
|
+
}
|
|
15252
|
+
let addresses;
|
|
15253
|
+
try {
|
|
15254
|
+
addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
|
|
15255
|
+
} catch (error) {
|
|
15256
|
+
return cb(error);
|
|
15257
|
+
}
|
|
15258
|
+
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
|
|
15259
|
+
});
|
|
15260
|
+
};
|
|
15261
|
+
normalizedLookupCache.set(lookup, normalized);
|
|
15262
|
+
return normalized;
|
|
15263
|
+
};
|
|
15264
|
+
var http2Transport = {
|
|
15265
|
+
request(options, cb) {
|
|
15266
|
+
const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
|
|
15267
|
+
const { http2Options, headers } = options;
|
|
15268
|
+
const session = http2Sessions.getSession(authority, http2Options);
|
|
15269
|
+
const { HTTP2_HEADER_SCHEME, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_STATUS } = http2.constants;
|
|
14703
15270
|
const http2Headers = {
|
|
14704
15271
|
[HTTP2_HEADER_SCHEME]: options.protocol.replace(":", ""),
|
|
14705
15272
|
[HTTP2_HEADER_METHOD]: options.method,
|
|
@@ -14730,6 +15297,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
14730
15297
|
let family = own2("family");
|
|
14731
15298
|
let httpVersion = own2("httpVersion");
|
|
14732
15299
|
if (httpVersion === void 0) httpVersion = 1;
|
|
15300
|
+
const rawHttpVersion = httpVersion;
|
|
14733
15301
|
let http2Options = own2("http2Options");
|
|
14734
15302
|
const httpAgent = own2("httpAgent");
|
|
14735
15303
|
const httpsAgent = own2("httpsAgent");
|
|
@@ -14746,25 +15314,32 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
14746
15314
|
let rejected = false;
|
|
14747
15315
|
let req;
|
|
14748
15316
|
let connectPhaseTimer;
|
|
14749
|
-
|
|
15317
|
+
try {
|
|
15318
|
+
httpVersion = +httpVersion;
|
|
15319
|
+
} catch (err) {
|
|
15320
|
+
throw new AxiosError_default(
|
|
15321
|
+
"Invalid protocol version: value is not a number",
|
|
15322
|
+
AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
15323
|
+
config
|
|
15324
|
+
);
|
|
15325
|
+
}
|
|
14750
15326
|
if (Number.isNaN(httpVersion)) {
|
|
14751
|
-
throw
|
|
15327
|
+
throw new AxiosError_default(
|
|
15328
|
+
`Invalid protocol version: '${rawHttpVersion}' is not a number`,
|
|
15329
|
+
AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
15330
|
+
config
|
|
15331
|
+
);
|
|
14752
15332
|
}
|
|
14753
15333
|
if (httpVersion !== 1 && httpVersion !== 2) {
|
|
14754
|
-
throw
|
|
15334
|
+
throw new AxiosError_default(
|
|
15335
|
+
`Unsupported protocol version '${httpVersion}'`,
|
|
15336
|
+
AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
15337
|
+
config
|
|
15338
|
+
);
|
|
14755
15339
|
}
|
|
14756
15340
|
const isHttp2 = httpVersion === 2;
|
|
14757
15341
|
if (lookup) {
|
|
14758
|
-
|
|
14759
|
-
lookup = (hostname, opt, cb) => {
|
|
14760
|
-
_lookup(hostname, opt, (err, arg0, arg1) => {
|
|
14761
|
-
if (err) {
|
|
14762
|
-
return cb(err);
|
|
14763
|
-
}
|
|
14764
|
-
const addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
|
|
14765
|
-
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
|
|
14766
|
-
});
|
|
14767
|
-
};
|
|
15342
|
+
lookup = normalizeLookup(lookup);
|
|
14768
15343
|
}
|
|
14769
15344
|
const abortEmitter = new EventEmitter();
|
|
14770
15345
|
function abort(reason) {
|
|
@@ -14838,7 +15413,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
14838
15413
|
if (protocol === "data:") {
|
|
14839
15414
|
if (maxContentLength > -1) {
|
|
14840
15415
|
const dataUrl = String(own2("url") || fullPath || "");
|
|
14841
|
-
const estimated =
|
|
15416
|
+
const estimated = estimateDataURLBufferAllocation(dataUrl);
|
|
14842
15417
|
if (estimated > maxContentLength) {
|
|
14843
15418
|
return reject(
|
|
14844
15419
|
new AxiosError_default(
|
|
@@ -14968,7 +15543,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
14968
15543
|
data,
|
|
14969
15544
|
progressEventDecorator(
|
|
14970
15545
|
contentLength,
|
|
14971
|
-
progressEventReducer(asyncDecorator(onUploadProgress), false, 3)
|
|
15546
|
+
progressEventReducer(asyncDecorator(onUploadProgress, scheduleProgress), false, 3)
|
|
14972
15547
|
)
|
|
14973
15548
|
)
|
|
14974
15549
|
);
|
|
@@ -15006,6 +15581,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15006
15581
|
utils_default.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
|
|
15007
15582
|
false
|
|
15008
15583
|
);
|
|
15584
|
+
if (isHttp2 && lookup) {
|
|
15585
|
+
http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, { lookup });
|
|
15586
|
+
}
|
|
15009
15587
|
const options = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
15010
15588
|
path,
|
|
15011
15589
|
method,
|
|
@@ -15016,9 +15594,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15016
15594
|
family,
|
|
15017
15595
|
beforeRedirect: dispatchBeforeRedirect,
|
|
15018
15596
|
beforeRedirects: /* @__PURE__ */ Object.create(null),
|
|
15019
|
-
http2Options
|
|
15597
|
+
http2Options,
|
|
15598
|
+
createConnection: void 0
|
|
15020
15599
|
});
|
|
15021
15600
|
!utils_default.isUndefined(lookup) && (options.lookup = lookup);
|
|
15601
|
+
let proxyApplied = false;
|
|
15022
15602
|
if (socketPath) {
|
|
15023
15603
|
if (typeof socketPath !== "string") {
|
|
15024
15604
|
return reject(
|
|
@@ -15046,13 +15626,17 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15046
15626
|
} else {
|
|
15047
15627
|
options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
15048
15628
|
options.port = parsed.port;
|
|
15049
|
-
setProxy(
|
|
15629
|
+
proxyApplied = setProxy(
|
|
15050
15630
|
options,
|
|
15051
15631
|
configProxy,
|
|
15052
15632
|
protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
|
|
15053
15633
|
false,
|
|
15054
15634
|
httpsAgent,
|
|
15055
|
-
httpAgent
|
|
15635
|
+
httpAgent,
|
|
15636
|
+
// The HTTP/2 transport connects independently of HTTP/1 agents, so it
|
|
15637
|
+
// cannot apply either axios-resolved or agent-local environment proxies.
|
|
15638
|
+
// Explicit proxy config is still processed and rejected below.
|
|
15639
|
+
!isHttp2
|
|
15056
15640
|
);
|
|
15057
15641
|
}
|
|
15058
15642
|
let transport;
|
|
@@ -15063,6 +15647,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15063
15647
|
options.agent = isHttpsRequest ? httpsAgent : httpAgent;
|
|
15064
15648
|
}
|
|
15065
15649
|
if (isHttp2) {
|
|
15650
|
+
if (proxyApplied) {
|
|
15651
|
+
return reject(
|
|
15652
|
+
new AxiosError_default(
|
|
15653
|
+
"HTTP/2 requests with a proxy are not supported",
|
|
15654
|
+
AxiosError_default.ERR_NOT_SUPPORT,
|
|
15655
|
+
config
|
|
15656
|
+
)
|
|
15657
|
+
);
|
|
15658
|
+
}
|
|
15066
15659
|
transport = http2Transport;
|
|
15067
15660
|
} else {
|
|
15068
15661
|
const configTransport = own2("transport");
|
|
@@ -15150,7 +15743,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15150
15743
|
transformStream,
|
|
15151
15744
|
progressEventDecorator(
|
|
15152
15745
|
responseLength,
|
|
15153
|
-
progressEventReducer(
|
|
15746
|
+
progressEventReducer(
|
|
15747
|
+
asyncDecorator(onDownloadProgress, scheduleProgress),
|
|
15748
|
+
true,
|
|
15749
|
+
3
|
|
15750
|
+
)
|
|
15154
15751
|
)
|
|
15155
15752
|
)
|
|
15156
15753
|
);
|
|
@@ -15299,12 +15896,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15299
15896
|
socket.setKeepAlive(true, 1e3 * 60);
|
|
15300
15897
|
}
|
|
15301
15898
|
if (!socket[kAxiosSocketListener]) {
|
|
15302
|
-
socket.on("error",
|
|
15303
|
-
const current = socket[kAxiosCurrentReq];
|
|
15304
|
-
if (current && !current.destroyed) {
|
|
15305
|
-
current.destroy(err);
|
|
15306
|
-
}
|
|
15307
|
-
});
|
|
15899
|
+
socket.on("error", handleSocketError);
|
|
15308
15900
|
socket[kAxiosSocketListener] = true;
|
|
15309
15901
|
}
|
|
15310
15902
|
socket[kAxiosCurrentReq] = req;
|
|
@@ -15464,6 +16056,16 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? (
|
|
|
15464
16056
|
|
|
15465
16057
|
// ../node_modules/axios/lib/core/mergeConfig.js
|
|
15466
16058
|
var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
|
|
16059
|
+
var ownEnumerableKeys = (thing) => {
|
|
16060
|
+
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
16061
|
+
return Object.keys(thing).concat(
|
|
16062
|
+
Object.getOwnPropertySymbols(thing).filter(
|
|
16063
|
+
(symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
|
|
16064
|
+
)
|
|
16065
|
+
);
|
|
16066
|
+
}
|
|
16067
|
+
return Object.keys(thing);
|
|
16068
|
+
};
|
|
15467
16069
|
function mergeConfig(config1, config2) {
|
|
15468
16070
|
config1 = config1 || {};
|
|
15469
16071
|
config2 = config2 || {};
|
|
@@ -15539,7 +16141,7 @@ function mergeConfig(config1, config2) {
|
|
|
15539
16141
|
transformResponse: defaultToConfig2,
|
|
15540
16142
|
paramsSerializer: defaultToConfig2,
|
|
15541
16143
|
timeout: defaultToConfig2,
|
|
15542
|
-
|
|
16144
|
+
timeoutErrorMessage: defaultToConfig2,
|
|
15543
16145
|
withCredentials: defaultToConfig2,
|
|
15544
16146
|
withXSRFToken: defaultToConfig2,
|
|
15545
16147
|
adapter: defaultToConfig2,
|
|
@@ -15562,7 +16164,7 @@ function mergeConfig(config1, config2) {
|
|
|
15562
16164
|
validateStatus: mergeDirectKeys,
|
|
15563
16165
|
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
15564
16166
|
};
|
|
15565
|
-
utils_default.forEach(
|
|
16167
|
+
utils_default.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
15566
16168
|
if (prop === "__proto__" || prop === "constructor" || prop === "prototype") return;
|
|
15567
16169
|
const merge2 = utils_default.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
15568
16170
|
const a = utils_default.hasOwnProp(config1, prop) ? config1[prop] : void 0;
|
|
@@ -15581,18 +16183,6 @@ function mergeConfig(config1, config2) {
|
|
|
15581
16183
|
}
|
|
15582
16184
|
|
|
15583
16185
|
// ../node_modules/axios/lib/helpers/resolveConfig.js
|
|
15584
|
-
var FORM_DATA_CONTENT_HEADERS2 = ["content-type", "content-length"];
|
|
15585
|
-
function setFormDataHeaders2(headers, formHeaders, policy) {
|
|
15586
|
-
if (policy !== "content-only") {
|
|
15587
|
-
headers.set(formHeaders);
|
|
15588
|
-
return;
|
|
15589
|
-
}
|
|
15590
|
-
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
15591
|
-
if (FORM_DATA_CONTENT_HEADERS2.includes(key.toLowerCase())) {
|
|
15592
|
-
headers.set(key, val);
|
|
15593
|
-
}
|
|
15594
|
-
});
|
|
15595
|
-
}
|
|
15596
16186
|
var encodeUTF8 = (str) => encodeURIComponent(str).replace(
|
|
15597
16187
|
/%([0-9A-F]{2})/gi,
|
|
15598
16188
|
(_, hex) => String.fromCharCode(parseInt(hex, 16))
|
|
@@ -15628,10 +16218,11 @@ function resolveConfig(config) {
|
|
|
15628
16218
|
}
|
|
15629
16219
|
}
|
|
15630
16220
|
if (utils_default.isFormData(data)) {
|
|
16221
|
+
const getHeaders = utils_default.getSafeProp(data, "getHeaders");
|
|
15631
16222
|
if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
|
|
15632
16223
|
headers.setContentType(void 0);
|
|
15633
|
-
} else if (utils_default.isFunction(
|
|
15634
|
-
|
|
16224
|
+
} else if (utils_default.isFunction(getHeaders)) {
|
|
16225
|
+
setFormDataHeaders(headers, getHeaders.call(data), own2("formDataHeaderPolicy"));
|
|
15635
16226
|
}
|
|
15636
16227
|
}
|
|
15637
16228
|
if (platform_default.hasStandardBrowserEnv) {
|
|
@@ -15660,7 +16251,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
15660
16251
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
15661
16252
|
let onCanceled;
|
|
15662
16253
|
let uploadThrottled, downloadThrottled;
|
|
15663
|
-
let flushUpload, flushDownload;
|
|
16254
|
+
let flushUpload, flushDownload, flushDownloadWithEvent;
|
|
15664
16255
|
function done() {
|
|
15665
16256
|
flushUpload && flushUpload();
|
|
15666
16257
|
flushDownload && flushDownload();
|
|
@@ -15670,7 +16261,27 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
15670
16261
|
let request = new XMLHttpRequest();
|
|
15671
16262
|
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
15672
16263
|
request.timeout = _config.timeout;
|
|
15673
|
-
function onloadend() {
|
|
16264
|
+
function onloadend(event) {
|
|
16265
|
+
if (!request) {
|
|
16266
|
+
return;
|
|
16267
|
+
}
|
|
16268
|
+
if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform_default.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
|
|
16269
|
+
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
|
|
16270
|
+
done();
|
|
16271
|
+
request = null;
|
|
16272
|
+
return;
|
|
16273
|
+
}
|
|
16274
|
+
try {
|
|
16275
|
+
if (event) {
|
|
16276
|
+
flushDownloadWithEvent && flushDownloadWithEvent(event);
|
|
16277
|
+
} else {
|
|
16278
|
+
flushDownload && flushDownload();
|
|
16279
|
+
}
|
|
16280
|
+
} catch (err) {
|
|
16281
|
+
setTimeout(() => {
|
|
16282
|
+
throw err;
|
|
16283
|
+
});
|
|
16284
|
+
}
|
|
15674
16285
|
if (!request) {
|
|
15675
16286
|
return;
|
|
15676
16287
|
}
|
|
@@ -15758,7 +16369,10 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
15758
16369
|
request.responseType = _config.responseType;
|
|
15759
16370
|
}
|
|
15760
16371
|
if (onDownloadProgress) {
|
|
15761
|
-
[downloadThrottled, flushDownload] = progressEventReducer(
|
|
16372
|
+
[downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
|
|
16373
|
+
onDownloadProgress,
|
|
16374
|
+
true
|
|
16375
|
+
);
|
|
15762
16376
|
request.addEventListener("progress", downloadThrottled);
|
|
15763
16377
|
}
|
|
15764
16378
|
if (onUploadProgress && request.upload) {
|
|
@@ -15830,7 +16444,16 @@ var composeSignals = (signals, timeout) => {
|
|
|
15830
16444
|
});
|
|
15831
16445
|
signals = null;
|
|
15832
16446
|
};
|
|
15833
|
-
signals.forEach((signal2) =>
|
|
16447
|
+
signals.forEach((signal2) => {
|
|
16448
|
+
if (aborted) {
|
|
16449
|
+
return;
|
|
16450
|
+
}
|
|
16451
|
+
if (signal2.aborted) {
|
|
16452
|
+
onabort.call(signal2);
|
|
16453
|
+
return;
|
|
16454
|
+
}
|
|
16455
|
+
signal2.addEventListener("abort", onabort, { once: true });
|
|
16456
|
+
});
|
|
15834
16457
|
const { signal } = controller;
|
|
15835
16458
|
signal.unsubscribe = () => utils_default.asap(unsubscribe);
|
|
15836
16459
|
return signal;
|
|
@@ -15919,6 +16542,17 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
|
|
|
15919
16542
|
|
|
15920
16543
|
// ../node_modules/axios/lib/adapters/fetch.js
|
|
15921
16544
|
var DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
16545
|
+
var DEFAULT_REQUEST_OPTIONS = {
|
|
16546
|
+
cache: "default",
|
|
16547
|
+
redirect: "follow",
|
|
16548
|
+
referrer: "about:client",
|
|
16549
|
+
referrerPolicy: "",
|
|
16550
|
+
mode: "cors",
|
|
16551
|
+
integrity: "",
|
|
16552
|
+
keepalive: false,
|
|
16553
|
+
priority: "auto",
|
|
16554
|
+
window: null
|
|
16555
|
+
};
|
|
15922
16556
|
var { isFunction: isFunction2 } = utils_default;
|
|
15923
16557
|
var encodeUTF82 = (str) => encodeURIComponent(str).replace(
|
|
15924
16558
|
/%([0-9A-F]{2})/gi,
|
|
@@ -16049,7 +16683,8 @@ var factory = (env) => {
|
|
|
16049
16683
|
withCredentials = "same-origin",
|
|
16050
16684
|
fetchOptions,
|
|
16051
16685
|
maxContentLength,
|
|
16052
|
-
maxBodyLength
|
|
16686
|
+
maxBodyLength,
|
|
16687
|
+
maxRedirects
|
|
16053
16688
|
} = resolveConfig_default(config);
|
|
16054
16689
|
const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
|
|
16055
16690
|
const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
@@ -16179,17 +16814,44 @@ var factory = (env) => {
|
|
|
16179
16814
|
}
|
|
16180
16815
|
}
|
|
16181
16816
|
headers.set("User-Agent", "axios/" + VERSION, false);
|
|
16182
|
-
const
|
|
16183
|
-
|
|
16817
|
+
const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
|
|
16818
|
+
if (safeFetchOptions) {
|
|
16819
|
+
delete safeFetchOptions.body;
|
|
16820
|
+
delete safeFetchOptions.headers;
|
|
16821
|
+
delete safeFetchOptions.method;
|
|
16822
|
+
delete safeFetchOptions.signal;
|
|
16823
|
+
delete safeFetchOptions.duplex;
|
|
16824
|
+
delete safeFetchOptions.credentials;
|
|
16825
|
+
}
|
|
16826
|
+
const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
|
|
16184
16827
|
signal: composedSignal,
|
|
16185
16828
|
method: method.toUpperCase(),
|
|
16186
16829
|
headers: toByteStringHeaderObject(headers.normalize()),
|
|
16187
16830
|
body: data,
|
|
16188
16831
|
duplex: "half",
|
|
16189
16832
|
credentials: isCredentialsSupported ? withCredentials : void 0
|
|
16190
|
-
};
|
|
16833
|
+
});
|
|
16834
|
+
if (isRequestSupported) {
|
|
16835
|
+
utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
|
|
16836
|
+
if (resolvedOptions[key] === void 0) {
|
|
16837
|
+
resolvedOptions[key] = value;
|
|
16838
|
+
}
|
|
16839
|
+
});
|
|
16840
|
+
if (resolvedOptions.signal === void 0) {
|
|
16841
|
+
resolvedOptions.signal = null;
|
|
16842
|
+
}
|
|
16843
|
+
if (resolvedOptions.body === void 0) {
|
|
16844
|
+
resolvedOptions.body = null;
|
|
16845
|
+
}
|
|
16846
|
+
}
|
|
16847
|
+
if (maxRedirects === 0) {
|
|
16848
|
+
resolvedOptions.redirect = "manual";
|
|
16849
|
+
if (safeFetchOptions) {
|
|
16850
|
+
safeFetchOptions.redirect = "manual";
|
|
16851
|
+
}
|
|
16852
|
+
}
|
|
16191
16853
|
request = isRequestSupported && new Request(url2, resolvedOptions);
|
|
16192
|
-
let response = await (isRequestSupported ? _fetch(request,
|
|
16854
|
+
let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url2, resolvedOptions));
|
|
16193
16855
|
const responseHeaders = AxiosHeaders_default.from(response.headers);
|
|
16194
16856
|
if (hasMaxContentLength) {
|
|
16195
16857
|
const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
|
|
@@ -16408,9 +17070,10 @@ function throwIfCancellationRequested(config) {
|
|
|
16408
17070
|
throw new CanceledError_default(null, config);
|
|
16409
17071
|
}
|
|
16410
17072
|
}
|
|
16411
|
-
function dispatchRequest(
|
|
17073
|
+
function dispatchRequest(_config) {
|
|
17074
|
+
const config = utils_default.toSafeFlatObject(_config);
|
|
16412
17075
|
throwIfCancellationRequested(config);
|
|
16413
|
-
config.headers = AxiosHeaders_default.from(config
|
|
17076
|
+
config.headers = AxiosHeaders_default.from(utils_default.getSafeProp(config, "headers"));
|
|
16414
17077
|
config.data = transformData.call(config, config.transformRequest);
|
|
16415
17078
|
if (["post", "put", "patch"].indexOf(config.method) !== -1) {
|
|
16416
17079
|
config.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
@@ -16540,16 +17203,15 @@ var Axios = class {
|
|
|
16540
17203
|
return await this._request(configOrUrl, config);
|
|
16541
17204
|
} catch (err) {
|
|
16542
17205
|
if (err instanceof Error) {
|
|
16543
|
-
let dummy = {};
|
|
16544
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|
16545
|
-
const stack = (() => {
|
|
16546
|
-
if (!dummy.stack) {
|
|
16547
|
-
return "";
|
|
16548
|
-
}
|
|
16549
|
-
const firstNewlineIndex = dummy.stack.indexOf("\n");
|
|
16550
|
-
return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
|
|
16551
|
-
})();
|
|
16552
17206
|
try {
|
|
17207
|
+
let dummy = {};
|
|
17208
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|
17209
|
+
const dummyStack = dummy.stack;
|
|
17210
|
+
let stack = "";
|
|
17211
|
+
if (typeof dummyStack === "string") {
|
|
17212
|
+
const firstNewlineIndex = dummyStack.indexOf("\n");
|
|
17213
|
+
stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
|
|
17214
|
+
}
|
|
16553
17215
|
if (!err.stack) {
|
|
16554
17216
|
err.stack = stack;
|
|
16555
17217
|
} else if (stack) {
|
|
@@ -16618,9 +17280,9 @@ var Axios = class {
|
|
|
16618
17280
|
},
|
|
16619
17281
|
true
|
|
16620
17282
|
);
|
|
16621
|
-
config.method = (config
|
|
17283
|
+
config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
|
|
16622
17284
|
let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
|
|
16623
|
-
headers && utils_default.forEach(
|
|
17285
|
+
headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
|
|
16624
17286
|
delete headers[method];
|
|
16625
17287
|
});
|
|
16626
17288
|
config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
|
|
@@ -16663,16 +17325,31 @@ var Axios = class {
|
|
|
16663
17325
|
const onFulfilled = requestInterceptorChain[i++];
|
|
16664
17326
|
const onRejected = requestInterceptorChain[i++];
|
|
16665
17327
|
try {
|
|
16666
|
-
newConfig = onFulfilled(newConfig);
|
|
17328
|
+
newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
|
|
16667
17329
|
} catch (error) {
|
|
16668
|
-
onRejected
|
|
17330
|
+
if (!onRejected) {
|
|
17331
|
+
promise = Promise.reject(error);
|
|
17332
|
+
break;
|
|
17333
|
+
}
|
|
17334
|
+
try {
|
|
17335
|
+
const rejectedResult = onRejected.call(this, error);
|
|
17336
|
+
if (utils_default.isThenable(rejectedResult)) {
|
|
17337
|
+
promise = Promise.resolve(rejectedResult).then(
|
|
17338
|
+
() => dispatchRequest.call(this, newConfig)
|
|
17339
|
+
);
|
|
17340
|
+
}
|
|
17341
|
+
} catch (rejectedError) {
|
|
17342
|
+
promise = Promise.reject(rejectedError);
|
|
17343
|
+
}
|
|
16669
17344
|
break;
|
|
16670
17345
|
}
|
|
16671
17346
|
}
|
|
16672
|
-
|
|
16673
|
-
|
|
16674
|
-
|
|
16675
|
-
|
|
17347
|
+
if (!promise) {
|
|
17348
|
+
try {
|
|
17349
|
+
promise = dispatchRequest.call(this, newConfig);
|
|
17350
|
+
} catch (error) {
|
|
17351
|
+
promise = Promise.reject(error);
|
|
17352
|
+
}
|
|
16676
17353
|
}
|
|
16677
17354
|
i = 0;
|
|
16678
17355
|
len = responseInterceptorChain.length;
|
|
@@ -16868,14 +17545,22 @@ var HttpStatusCode = {
|
|
|
16868
17545
|
Gone: 410,
|
|
16869
17546
|
LengthRequired: 411,
|
|
16870
17547
|
PreconditionFailed: 412,
|
|
17548
|
+
/**
|
|
17549
|
+
* @deprecated Use `ContentTooLarge` instead.
|
|
17550
|
+
*/
|
|
16871
17551
|
PayloadTooLarge: 413,
|
|
17552
|
+
ContentTooLarge: 413,
|
|
16872
17553
|
UriTooLong: 414,
|
|
16873
17554
|
UnsupportedMediaType: 415,
|
|
16874
17555
|
RangeNotSatisfiable: 416,
|
|
16875
17556
|
ExpectationFailed: 417,
|
|
16876
17557
|
ImATeapot: 418,
|
|
16877
17558
|
MisdirectedRequest: 421,
|
|
17559
|
+
/**
|
|
17560
|
+
* @deprecated Use `UnprocessableContent` instead.
|
|
17561
|
+
*/
|
|
16878
17562
|
UnprocessableEntity: 422,
|
|
17563
|
+
UnprocessableContent: 422,
|
|
16879
17564
|
Locked: 423,
|
|
16880
17565
|
FailedDependency: 424,
|
|
16881
17566
|
TooEarly: 425,
|
|
@@ -16895,6 +17580,7 @@ var HttpStatusCode = {
|
|
|
16895
17580
|
LoopDetected: 508,
|
|
16896
17581
|
NotExtended: 510,
|
|
16897
17582
|
NetworkAuthenticationRequired: 511,
|
|
17583
|
+
WebServerReturnsAnUnknownError: 520,
|
|
16898
17584
|
WebServerIsDown: 521,
|
|
16899
17585
|
ConnectionTimedOut: 522,
|
|
16900
17586
|
OriginIsUnreachable: 523,
|
|
@@ -16903,7 +17589,9 @@ var HttpStatusCode = {
|
|
|
16903
17589
|
InvalidSslCertificate: 526
|
|
16904
17590
|
};
|
|
16905
17591
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
16906
|
-
HttpStatusCode[value]
|
|
17592
|
+
if (HttpStatusCode[value] === void 0) {
|
|
17593
|
+
HttpStatusCode[value] = key;
|
|
17594
|
+
}
|
|
16907
17595
|
});
|
|
16908
17596
|
var HttpStatusCode_default = HttpStatusCode;
|
|
16909
17597
|
|
|
@@ -17199,6 +17887,20 @@ var ServerError = class extends Posty5Error {
|
|
|
17199
17887
|
this.name = "ServerError";
|
|
17200
17888
|
}
|
|
17201
17889
|
};
|
|
17890
|
+
var ConflictError = class extends Posty5Error {
|
|
17891
|
+
constructor(message = "The document was changed by someone else", currentVersion = -1, resourceId = "", details) {
|
|
17892
|
+
super(message, "VERSION_CONFLICT", 409, details);
|
|
17893
|
+
this.name = "ConflictError";
|
|
17894
|
+
this.currentVersion = currentVersion;
|
|
17895
|
+
this.resourceId = resourceId;
|
|
17896
|
+
}
|
|
17897
|
+
};
|
|
17898
|
+
var VersionRequiredError = class extends Posty5Error {
|
|
17899
|
+
constructor(message = "The document version is required", details) {
|
|
17900
|
+
super(message, "VERSION_REQUIRED", 428, details);
|
|
17901
|
+
this.name = "VersionRequiredError";
|
|
17902
|
+
}
|
|
17903
|
+
};
|
|
17202
17904
|
function transformError(error) {
|
|
17203
17905
|
if (error instanceof Posty5Error) {
|
|
17204
17906
|
return error;
|
|
@@ -17223,6 +17925,22 @@ function transformError(error) {
|
|
|
17223
17925
|
return new AuthorizationError(message, details);
|
|
17224
17926
|
case 404:
|
|
17225
17927
|
return new NotFoundError(message, details);
|
|
17928
|
+
case 409: {
|
|
17929
|
+
const body = data;
|
|
17930
|
+
if (body?.code === "VERSION_CONFLICT") {
|
|
17931
|
+
const result = body?.result ?? {};
|
|
17932
|
+
const current = Number(result.currentVersion ?? body?.currentVersion);
|
|
17933
|
+
return new ConflictError(
|
|
17934
|
+
message,
|
|
17935
|
+
Number.isFinite(current) ? current : -1,
|
|
17936
|
+
String(result._id ?? body?._id ?? ""),
|
|
17937
|
+
details
|
|
17938
|
+
);
|
|
17939
|
+
}
|
|
17940
|
+
return new Posty5Error(message, body?.code, status, details);
|
|
17941
|
+
}
|
|
17942
|
+
case 428:
|
|
17943
|
+
return new VersionRequiredError(message, details);
|
|
17226
17944
|
case 429:
|
|
17227
17945
|
const retryAfter2 = axiosError.response.headers["retry-after"];
|
|
17228
17946
|
return new RateLimitError(
|
|
@@ -17244,31 +17962,101 @@ function transformError(error) {
|
|
|
17244
17962
|
}
|
|
17245
17963
|
return new Posty5Error("An unknown error occurred", void 0, void 0, { originalError: error });
|
|
17246
17964
|
}
|
|
17965
|
+
var CORE_VERSION = "5.0.0";
|
|
17966
|
+
var DEFAULT_BASE_URL = "https://api.posty5.com";
|
|
17967
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
17968
|
+
var DEFAULT_MAX_RETRIES = 3;
|
|
17969
|
+
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
17970
|
+
var CLIENT_HEADER_NAME = "X-Posty5-Client";
|
|
17971
|
+
var SDK_CLIENT_NAME = "posty5-npm";
|
|
17972
|
+
var SDK_CLIENT_ID = `${SDK_CLIENT_NAME}/${CORE_VERSION}`;
|
|
17973
|
+
var DEFAULT_CREATED_FROM = "npmPackage";
|
|
17974
|
+
var IDEMPOTENT_METHODS = ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"];
|
|
17975
|
+
var NEVER_CONNECTED_ERROR_CODES = ["ECONNREFUSED", "ENOTFOUND", "EAI_AGAIN", "ENETUNREACH", "EHOSTUNREACH"];
|
|
17976
|
+
var IF_MATCH_HEADER = "If-Match";
|
|
17977
|
+
var CONCURRENCY_REPORT_HEADER = "X-Posty5-Concurrency";
|
|
17978
|
+
var CONCURRENCY_REPORT_MISSING_VERSION = "missing-version";
|
|
17979
|
+
var NON_RETRYABLE_VERSION_STATUSES = [409, 428];
|
|
17980
|
+
function assertVersion(version, name = "version") {
|
|
17981
|
+
if (typeof version !== "number" || !Number.isInteger(version) || version < 0) {
|
|
17982
|
+
throw new TypeError(`Posty5: \`${name}\` must be a non-negative integer (the document's __v), got ${String(version)}`);
|
|
17983
|
+
}
|
|
17984
|
+
}
|
|
17985
|
+
function ifMatchHeader(version) {
|
|
17986
|
+
assertVersion(version);
|
|
17987
|
+
return `"${version}"`;
|
|
17988
|
+
}
|
|
17989
|
+
function hasIfMatch(headers) {
|
|
17990
|
+
if (!headers) return false;
|
|
17991
|
+
if (typeof headers.get === "function") {
|
|
17992
|
+
const value = headers.get(IF_MATCH_HEADER);
|
|
17993
|
+
if (value !== void 0 && value !== null) return true;
|
|
17994
|
+
}
|
|
17995
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === IF_MATCH_HEADER.toLowerCase());
|
|
17996
|
+
}
|
|
17997
|
+
function withVersion(response, id) {
|
|
17998
|
+
const result = response.result && typeof response.result === "object" ? { ...response.result } : {};
|
|
17999
|
+
if (id !== void 0 && result._id === void 0) result._id = id;
|
|
18000
|
+
if (typeof response.version === "number") result.__v = response.version;
|
|
18001
|
+
return result;
|
|
18002
|
+
}
|
|
18003
|
+
var missingVersionWarned = false;
|
|
18004
|
+
function warnOnMissingVersion(headers, method, url2) {
|
|
18005
|
+
if (missingVersionWarned || !headers) return false;
|
|
18006
|
+
const value = typeof headers.get === "function" ? headers.get(CONCURRENCY_REPORT_HEADER) : headers[CONCURRENCY_REPORT_HEADER.toLowerCase()];
|
|
18007
|
+
if (String(value ?? "").toLowerCase() !== CONCURRENCY_REPORT_MISSING_VERSION) return false;
|
|
18008
|
+
missingVersionWarned = true;
|
|
18009
|
+
console.warn(
|
|
18010
|
+
`[Posty5 SDK] ${String(method || "").toUpperCase()} ${url2 ?? ""} was sent without a document version; the API will refuse it once versions are enforced. Please report this SDK bug.`
|
|
18011
|
+
);
|
|
18012
|
+
return true;
|
|
18013
|
+
}
|
|
18014
|
+
function shouldRetryRequest(error) {
|
|
18015
|
+
const method = String(error?.config?.method || "").toUpperCase();
|
|
18016
|
+
const idempotent = IDEMPOTENT_METHODS.includes(method);
|
|
18017
|
+
const status = error?.response?.status;
|
|
18018
|
+
if (hasIfMatch(error?.config?.headers)) return false;
|
|
18019
|
+
if (status !== void 0 && NON_RETRYABLE_VERSION_STATUSES.includes(status)) return false;
|
|
18020
|
+
if (status === void 0) {
|
|
18021
|
+
if (idempotent) return esm_default.isNetworkError(error);
|
|
18022
|
+
return NEVER_CONNECTED_ERROR_CODES.includes(String(error?.code || ""));
|
|
18023
|
+
}
|
|
18024
|
+
return idempotent && status >= 500;
|
|
18025
|
+
}
|
|
18026
|
+
function parseFileName(disposition) {
|
|
18027
|
+
if (!disposition) return void 0;
|
|
18028
|
+
const match = /filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(disposition);
|
|
18029
|
+
if (!match) return void 0;
|
|
18030
|
+
try {
|
|
18031
|
+
return decodeURIComponent(match[1]);
|
|
18032
|
+
} catch {
|
|
18033
|
+
return match[1];
|
|
18034
|
+
}
|
|
18035
|
+
}
|
|
17247
18036
|
var HttpClient = class {
|
|
17248
18037
|
constructor(config = {}) {
|
|
17249
18038
|
this.config = {
|
|
17250
|
-
timeout:
|
|
17251
|
-
maxRetries:
|
|
17252
|
-
retryDelay:
|
|
18039
|
+
timeout: DEFAULT_TIMEOUT_MS,
|
|
18040
|
+
maxRetries: DEFAULT_MAX_RETRIES,
|
|
18041
|
+
retryDelay: DEFAULT_RETRY_DELAY_MS,
|
|
17253
18042
|
...config,
|
|
17254
|
-
baseUrl: config.baseUrl || process.env.POSTY5_BASE_URL ||
|
|
18043
|
+
baseUrl: config.baseUrl || process.env.POSTY5_BASE_URL || DEFAULT_BASE_URL
|
|
17255
18044
|
};
|
|
17256
18045
|
this.axiosInstance = axios_default.create({
|
|
17257
18046
|
baseURL: this.config.baseUrl,
|
|
17258
18047
|
timeout: this.config.timeout,
|
|
17259
18048
|
headers: {
|
|
17260
18049
|
"Content-Type": "application/json",
|
|
18050
|
+
[CLIENT_HEADER_NAME]: SDK_CLIENT_ID,
|
|
17261
18051
|
...this.config.headers
|
|
17262
18052
|
}
|
|
17263
18053
|
});
|
|
17264
18054
|
esm_default(this.axiosInstance, {
|
|
17265
|
-
retries: this.config.maxRetries
|
|
18055
|
+
retries: this.config.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
17266
18056
|
retryDelay: (retryCount) => {
|
|
17267
|
-
return retryCount * (this.config.retryDelay
|
|
18057
|
+
return retryCount * (this.config.retryDelay ?? DEFAULT_RETRY_DELAY_MS);
|
|
17268
18058
|
},
|
|
17269
|
-
retryCondition:
|
|
17270
|
-
return esm_default.isNetworkOrIdempotentRequestError(error) || error.response?.status !== void 0 && error.response.status >= 500;
|
|
17271
|
-
}
|
|
18059
|
+
retryCondition: shouldRetryRequest
|
|
17272
18060
|
});
|
|
17273
18061
|
this.axiosInstance.interceptors.request.use(
|
|
17274
18062
|
(config2) => {
|
|
@@ -17297,6 +18085,7 @@ var HttpClient = class {
|
|
|
17297
18085
|
);
|
|
17298
18086
|
this.axiosInstance.interceptors.response.use(
|
|
17299
18087
|
(response) => {
|
|
18088
|
+
warnOnMissingVersion(response.headers, response.config?.method, response.config?.url);
|
|
17300
18089
|
if (this.config.debug) {
|
|
17301
18090
|
console.log("[Posty5 SDK] Response:", {
|
|
17302
18091
|
status: response.status,
|
|
@@ -17313,6 +18102,10 @@ var HttpClient = class {
|
|
|
17313
18102
|
}
|
|
17314
18103
|
);
|
|
17315
18104
|
}
|
|
18105
|
+
/** The `createdFrom` label the clients stamp on records they create. */
|
|
18106
|
+
get createdFrom() {
|
|
18107
|
+
return this.config.createdFrom || DEFAULT_CREATED_FROM;
|
|
18108
|
+
}
|
|
17316
18109
|
/**
|
|
17317
18110
|
* Set or update the API key
|
|
17318
18111
|
*/
|
|
@@ -17386,6 +18179,28 @@ var HttpClient = class {
|
|
|
17386
18179
|
throw transformError(error);
|
|
17387
18180
|
}
|
|
17388
18181
|
}
|
|
18182
|
+
/**
|
|
18183
|
+
* Make a GET request for a file download.
|
|
18184
|
+
*
|
|
18185
|
+
* Separate from `get` rather than a flag on it: a download answers with the
|
|
18186
|
+
* file itself, not with the `{ message, result }` envelope every other
|
|
18187
|
+
* endpoint uses, so it cannot share the return type.
|
|
18188
|
+
*/
|
|
18189
|
+
async getBinary(url2, config) {
|
|
18190
|
+
try {
|
|
18191
|
+
const response = await this.axiosInstance.get(url2, {
|
|
18192
|
+
...this.buildConfig(config),
|
|
18193
|
+
responseType: "arraybuffer"
|
|
18194
|
+
});
|
|
18195
|
+
return {
|
|
18196
|
+
data: response.data,
|
|
18197
|
+
contentType: String(response.headers?.["content-type"] || "application/octet-stream"),
|
|
18198
|
+
fileName: parseFileName(response.headers?.["content-disposition"])
|
|
18199
|
+
};
|
|
18200
|
+
} catch (error) {
|
|
18201
|
+
throw transformError(error);
|
|
18202
|
+
}
|
|
18203
|
+
}
|
|
17389
18204
|
/**
|
|
17390
18205
|
* Build axios config from request config
|
|
17391
18206
|
*/
|
|
@@ -17395,11 +18210,18 @@ var HttpClient = class {
|
|
|
17395
18210
|
}
|
|
17396
18211
|
const axiosConfig = {};
|
|
17397
18212
|
if (config.headers) {
|
|
17398
|
-
axiosConfig.headers = config.headers;
|
|
18213
|
+
axiosConfig.headers = { ...config.headers };
|
|
18214
|
+
}
|
|
18215
|
+
if (config.version !== void 0) {
|
|
18216
|
+
axiosConfig.headers = { ...axiosConfig.headers || {}, [IF_MATCH_HEADER]: ifMatchHeader(config.version) };
|
|
18217
|
+
axiosConfig["axios-retry"] = { retries: 0 };
|
|
17399
18218
|
}
|
|
17400
18219
|
if (config.params) {
|
|
17401
18220
|
axiosConfig.params = config.params;
|
|
17402
18221
|
}
|
|
18222
|
+
if (config.data !== void 0) {
|
|
18223
|
+
axiosConfig.data = config.data;
|
|
18224
|
+
}
|
|
17403
18225
|
if (config.timeout) {
|
|
17404
18226
|
axiosConfig.timeout = config.timeout;
|
|
17405
18227
|
}
|
|
@@ -17460,6 +18282,169 @@ async function uploadToR2(presignedUrl, fileOrBlob, options = {}) {
|
|
|
17460
18282
|
}
|
|
17461
18283
|
}
|
|
17462
18284
|
|
|
18285
|
+
// src/resumable-upload.ts
|
|
18286
|
+
var TUS_VERSION = "1.0.0";
|
|
18287
|
+
var DEFAULT_CHUNK_SIZE2 = 8 * 1024 * 1024;
|
|
18288
|
+
var RETRY_DELAYS = [0, 1e3, 3e3, 5e3, 1e4];
|
|
18289
|
+
var MAX_CONSECUTIVE_STALLS = 3;
|
|
18290
|
+
function encodeMetadata(pairs) {
|
|
18291
|
+
return Object.entries(pairs).filter(([, value]) => value !== void 0 && value !== null && value !== "").map(([key, value]) => `${key} ${toBase64(value)}`).join(",");
|
|
18292
|
+
}
|
|
18293
|
+
function toBase64(value) {
|
|
18294
|
+
if (typeof btoa === "function") {
|
|
18295
|
+
return btoa(String.fromCharCode(...new TextEncoder().encode(value)));
|
|
18296
|
+
}
|
|
18297
|
+
return Buffer.from(value, "utf8").toString("base64");
|
|
18298
|
+
}
|
|
18299
|
+
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
18300
|
+
function isAborted(signal) {
|
|
18301
|
+
return !!signal?.aborted;
|
|
18302
|
+
}
|
|
18303
|
+
function abortError() {
|
|
18304
|
+
const error = new Error("Upload aborted");
|
|
18305
|
+
error.name = "AbortError";
|
|
18306
|
+
return error;
|
|
18307
|
+
}
|
|
18308
|
+
function supportsResumableUpload(target) {
|
|
18309
|
+
return !!target.tusEndpoint && !!target.ticket;
|
|
18310
|
+
}
|
|
18311
|
+
async function createUpload(target, size, filename, filetype, signal) {
|
|
18312
|
+
const response = await fetch(target.tusEndpoint, {
|
|
18313
|
+
method: "POST",
|
|
18314
|
+
headers: {
|
|
18315
|
+
"Tus-Resumable": TUS_VERSION,
|
|
18316
|
+
"Upload-Length": String(size),
|
|
18317
|
+
"Upload-Metadata": encodeMetadata({ ticket: target.ticket, filename, filetype })
|
|
18318
|
+
},
|
|
18319
|
+
signal
|
|
18320
|
+
});
|
|
18321
|
+
if (response.status !== 201) {
|
|
18322
|
+
throw new Error(`Could not start the upload (${response.status}): ${await safeText(response)}`);
|
|
18323
|
+
}
|
|
18324
|
+
const location = response.headers.get("Location");
|
|
18325
|
+
if (!location) {
|
|
18326
|
+
throw new Error("Upload was created but the server returned no Location header.");
|
|
18327
|
+
}
|
|
18328
|
+
return new URL(location, target.tusEndpoint).toString();
|
|
18329
|
+
}
|
|
18330
|
+
async function getOffset(uploadUrl, signal) {
|
|
18331
|
+
const response = await fetch(uploadUrl, {
|
|
18332
|
+
method: "HEAD",
|
|
18333
|
+
headers: { "Tus-Resumable": TUS_VERSION },
|
|
18334
|
+
signal
|
|
18335
|
+
});
|
|
18336
|
+
if (response.status === 404 || response.status === 410) {
|
|
18337
|
+
throw new Error("This upload has expired on the server and cannot be resumed.");
|
|
18338
|
+
}
|
|
18339
|
+
if (!response.ok) {
|
|
18340
|
+
throw new Error(`Could not read the upload's progress (${response.status}).`);
|
|
18341
|
+
}
|
|
18342
|
+
return Number(response.headers.get("Upload-Offset") ?? 0);
|
|
18343
|
+
}
|
|
18344
|
+
async function terminateUpload(uploadUrl) {
|
|
18345
|
+
try {
|
|
18346
|
+
const response = await fetch(uploadUrl, {
|
|
18347
|
+
method: "DELETE",
|
|
18348
|
+
headers: { "Tus-Resumable": TUS_VERSION }
|
|
18349
|
+
});
|
|
18350
|
+
return response.status === 204 || response.status === 404 || response.status === 410;
|
|
18351
|
+
} catch {
|
|
18352
|
+
return false;
|
|
18353
|
+
}
|
|
18354
|
+
}
|
|
18355
|
+
async function safeText(response) {
|
|
18356
|
+
try {
|
|
18357
|
+
return (await response.text()).slice(0, 300);
|
|
18358
|
+
} catch {
|
|
18359
|
+
return "";
|
|
18360
|
+
}
|
|
18361
|
+
}
|
|
18362
|
+
async function patchChunk(uploadUrl, chunk, offset, signal) {
|
|
18363
|
+
let lastError;
|
|
18364
|
+
for (let attempt = 0; attempt < RETRY_DELAYS.length; attempt++) {
|
|
18365
|
+
if (isAborted(signal)) throw abortError();
|
|
18366
|
+
if (RETRY_DELAYS[attempt]) await wait(RETRY_DELAYS[attempt]);
|
|
18367
|
+
try {
|
|
18368
|
+
const response = await fetch(uploadUrl, {
|
|
18369
|
+
method: "PATCH",
|
|
18370
|
+
headers: {
|
|
18371
|
+
"Tus-Resumable": TUS_VERSION,
|
|
18372
|
+
"Upload-Offset": String(offset),
|
|
18373
|
+
"Content-Type": "application/offset+octet-stream"
|
|
18374
|
+
},
|
|
18375
|
+
body: chunk,
|
|
18376
|
+
signal
|
|
18377
|
+
});
|
|
18378
|
+
if (response.status === 204) {
|
|
18379
|
+
return Number(response.headers.get("Upload-Offset") ?? offset + chunk.size);
|
|
18380
|
+
}
|
|
18381
|
+
if (response.status === 409) {
|
|
18382
|
+
return await getOffset(uploadUrl, signal);
|
|
18383
|
+
}
|
|
18384
|
+
if (response.status >= 400 && response.status < 500) {
|
|
18385
|
+
throw new Error(`Upload rejected (${response.status}): ${await safeText(response)}`);
|
|
18386
|
+
}
|
|
18387
|
+
lastError = new Error(`Upload failed (${response.status})`);
|
|
18388
|
+
} catch (error) {
|
|
18389
|
+
if (error?.name === "AbortError") throw error;
|
|
18390
|
+
if (/^Upload rejected/.test(error?.message || "")) throw error;
|
|
18391
|
+
lastError = error;
|
|
18392
|
+
}
|
|
18393
|
+
}
|
|
18394
|
+
throw lastError instanceof Error ? lastError : new Error("Upload failed");
|
|
18395
|
+
}
|
|
18396
|
+
async function uploadResumable(target, file, options = {}) {
|
|
18397
|
+
const { onProgress, onUploadUrl, chunkSize = DEFAULT_CHUNK_SIZE2, signal, fallbackType = "application/octet-stream", terminateOnAbort = false } = options;
|
|
18398
|
+
if (!supportsResumableUpload(target)) {
|
|
18399
|
+
throw new Error("This upload target does not support resumable uploads.");
|
|
18400
|
+
}
|
|
18401
|
+
if (target.maxSize && file.size > target.maxSize) {
|
|
18402
|
+
const limitMb = Math.round(target.maxSize / (1024 * 1024));
|
|
18403
|
+
throw new Error(`This file is larger than the ${limitMb}MB limit.`);
|
|
18404
|
+
}
|
|
18405
|
+
if (isAborted(signal)) throw abortError();
|
|
18406
|
+
const filename = file.name || "upload";
|
|
18407
|
+
const filetype = file.type || fallbackType;
|
|
18408
|
+
let uploadUrl = options.uploadUrl;
|
|
18409
|
+
let offset = 0;
|
|
18410
|
+
if (uploadUrl) {
|
|
18411
|
+
offset = await getOffset(uploadUrl, signal);
|
|
18412
|
+
} else {
|
|
18413
|
+
uploadUrl = await createUpload(target, file.size, filename, filetype, signal);
|
|
18414
|
+
onUploadUrl?.(uploadUrl);
|
|
18415
|
+
}
|
|
18416
|
+
const discardIfAsked = async () => {
|
|
18417
|
+
if (terminateOnAbort && uploadUrl) await terminateUpload(uploadUrl);
|
|
18418
|
+
};
|
|
18419
|
+
onProgress?.(file.size ? Math.round(offset / file.size * 100) : 0);
|
|
18420
|
+
let consecutiveStalls = 0;
|
|
18421
|
+
while (offset < file.size) {
|
|
18422
|
+
if (isAborted(signal)) {
|
|
18423
|
+
await discardIfAsked();
|
|
18424
|
+
throw abortError();
|
|
18425
|
+
}
|
|
18426
|
+
const end = Math.min(offset + chunkSize, file.size);
|
|
18427
|
+
let next;
|
|
18428
|
+
try {
|
|
18429
|
+
next = await patchChunk(uploadUrl, file.slice(offset, end), offset, signal);
|
|
18430
|
+
} catch (error) {
|
|
18431
|
+
if (error?.name === "AbortError") await discardIfAsked();
|
|
18432
|
+
throw error;
|
|
18433
|
+
}
|
|
18434
|
+
if (next <= offset) {
|
|
18435
|
+
if (++consecutiveStalls >= MAX_CONSECUTIVE_STALLS) {
|
|
18436
|
+
throw new Error("The upload stopped making progress and was abandoned.");
|
|
18437
|
+
}
|
|
18438
|
+
continue;
|
|
18439
|
+
}
|
|
18440
|
+
consecutiveStalls = 0;
|
|
18441
|
+
offset = next;
|
|
18442
|
+
onProgress?.(Math.round(offset / file.size * 100));
|
|
18443
|
+
}
|
|
18444
|
+
onProgress?.(100);
|
|
18445
|
+
return target.fileURL;
|
|
18446
|
+
}
|
|
18447
|
+
|
|
17463
18448
|
// src/social-publisher-post.client.ts
|
|
17464
18449
|
var SocialPublisherPostClient = class {
|
|
17465
18450
|
constructor(http3) {
|
|
@@ -17505,6 +18490,32 @@ var SocialPublisherPostClient = class {
|
|
|
17505
18490
|
const response = await this.http.post(`${this.basePath}/generate-upload-urls`, data);
|
|
17506
18491
|
return response.result;
|
|
17507
18492
|
}
|
|
18493
|
+
/**
|
|
18494
|
+
* Remove (delete) a post's published media directly from the connected
|
|
18495
|
+
* platform pages. Runs synchronously on the server — the media is deleted
|
|
18496
|
+
* from the platform immediately, not via a background job.
|
|
18497
|
+
*
|
|
18498
|
+
* Cost: 50 credits, charged ONLY when the removal succeeds (at least one
|
|
18499
|
+
* platform cleared and no delete-capable platform failed). Instagram and
|
|
18500
|
+
* TikTok expose no delete API, so a post published only to those platforms
|
|
18501
|
+
* cannot be removed programmatically and no credits are charged.
|
|
18502
|
+
*
|
|
18503
|
+
* @param id - Post ID
|
|
18504
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
18505
|
+
* @returns Per-platform removal results, `__v` set to the post's new version
|
|
18506
|
+
*
|
|
18507
|
+
* @example
|
|
18508
|
+
* ```ts
|
|
18509
|
+
* const post = await client.getStatus("post_123");
|
|
18510
|
+
* const { results } = await client.removePost("post_123", post.__v);
|
|
18511
|
+
* // results.youtube?.success === true
|
|
18512
|
+
* ```
|
|
18513
|
+
*/
|
|
18514
|
+
async removePost(id, version) {
|
|
18515
|
+
assertVersion(version);
|
|
18516
|
+
const response = await this.http.post(`${this.basePath}/${id}/remove`, {}, { version });
|
|
18517
|
+
return withVersion(response, id);
|
|
18518
|
+
}
|
|
17508
18519
|
/**
|
|
17509
18520
|
* Get next and previous post IDs
|
|
17510
18521
|
* @param id - Current Post ID
|
|
@@ -17522,7 +18533,7 @@ var SocialPublisherPostClient = class {
|
|
|
17522
18533
|
const url2 = id ? `${this.basePath}/short-video/workspace/by-file/${id}` : `${this.basePath}/short-video/workspace/by-file`;
|
|
17523
18534
|
const response = await this.http.post(url2, {
|
|
17524
18535
|
...data,
|
|
17525
|
-
createdFrom:
|
|
18536
|
+
createdFrom: this.http.createdFrom
|
|
17526
18537
|
});
|
|
17527
18538
|
return response.result?._id;
|
|
17528
18539
|
}
|
|
@@ -17535,7 +18546,7 @@ var SocialPublisherPostClient = class {
|
|
|
17535
18546
|
const url2 = id ? `${this.basePath}/short-video/workspace/by-url/${id}` : `${this.basePath}/short-video/workspace/by-url`;
|
|
17536
18547
|
const response = await this.http.post(url2, {
|
|
17537
18548
|
...data,
|
|
17538
|
-
createdFrom:
|
|
18549
|
+
createdFrom: this.http.createdFrom
|
|
17539
18550
|
});
|
|
17540
18551
|
return response.result?._id;
|
|
17541
18552
|
}
|
|
@@ -17548,7 +18559,7 @@ var SocialPublisherPostClient = class {
|
|
|
17548
18559
|
const url2 = id ? `${this.basePath}/short-video/account/by-file/${id}` : `${this.basePath}/short-video/account/by-file`;
|
|
17549
18560
|
const response = await this.http.post(url2, {
|
|
17550
18561
|
...data,
|
|
17551
|
-
createdFrom:
|
|
18562
|
+
createdFrom: this.http.createdFrom
|
|
17552
18563
|
});
|
|
17553
18564
|
return response.result?._id;
|
|
17554
18565
|
}
|
|
@@ -17561,7 +18572,7 @@ var SocialPublisherPostClient = class {
|
|
|
17561
18572
|
const url2 = id ? `${this.basePath}/short-video/account/by-url/${id}` : `${this.basePath}/short-video/account/by-url`;
|
|
17562
18573
|
const response = await this.http.post(url2, {
|
|
17563
18574
|
...data,
|
|
17564
|
-
createdFrom:
|
|
18575
|
+
createdFrom: this.http.createdFrom
|
|
17565
18576
|
});
|
|
17566
18577
|
return response.result?._id;
|
|
17567
18578
|
}
|
|
@@ -17585,7 +18596,7 @@ var SocialPublisherPostClient = class {
|
|
|
17585
18596
|
const url2 = id ? `${this.basePath}/image/workspace/${id}` : `${this.basePath}/image/workspace`;
|
|
17586
18597
|
const response = await this.http.post(url2, {
|
|
17587
18598
|
...data,
|
|
17588
|
-
createdFrom:
|
|
18599
|
+
createdFrom: this.http.createdFrom
|
|
17589
18600
|
});
|
|
17590
18601
|
return response.result?._id;
|
|
17591
18602
|
}
|
|
@@ -17598,10 +18609,50 @@ var SocialPublisherPostClient = class {
|
|
|
17598
18609
|
const url2 = id ? `${this.basePath}/image/account/${id}` : `${this.basePath}/image/account`;
|
|
17599
18610
|
const response = await this.http.post(url2, {
|
|
17600
18611
|
...data,
|
|
17601
|
-
createdFrom:
|
|
18612
|
+
createdFrom: this.http.createdFrom
|
|
17602
18613
|
});
|
|
17603
18614
|
return response.result?._id;
|
|
17604
18615
|
}
|
|
18616
|
+
/**
|
|
18617
|
+
* Publish a text-only post to every text-capable account in a workspace
|
|
18618
|
+
* (Facebook, Threads, X). Platforms that cannot take text are reported in
|
|
18619
|
+
* `skippedPlatforms`; X below the Pro plan is dropped into `refusedTargets`.
|
|
18620
|
+
*/
|
|
18621
|
+
async createTextPostToWorkspace(data) {
|
|
18622
|
+
const response = await this.http.post(`${this.basePath}/text/workspace`, {
|
|
18623
|
+
...data,
|
|
18624
|
+
createdFrom: this.http.createdFrom
|
|
18625
|
+
});
|
|
18626
|
+
return response.result;
|
|
18627
|
+
}
|
|
18628
|
+
/** Publish a text-only post to one account. */
|
|
18629
|
+
async createTextPostToAccount(data) {
|
|
18630
|
+
const response = await this.http.post(`${this.basePath}/text/account`, {
|
|
18631
|
+
...data,
|
|
18632
|
+
createdFrom: this.http.createdFrom
|
|
18633
|
+
});
|
|
18634
|
+
return response.result;
|
|
18635
|
+
}
|
|
18636
|
+
/**
|
|
18637
|
+
* Publish a story to every story-capable account in a workspace. Media by URL
|
|
18638
|
+
* only in this release: `image: { source: "image-url", externalUrl }`, or
|
|
18639
|
+
* `source: "video-url"` with `videoURL`.
|
|
18640
|
+
*/
|
|
18641
|
+
async createStoryPostToWorkspace(data) {
|
|
18642
|
+
const response = await this.http.post(`${this.basePath}/story/workspace`, {
|
|
18643
|
+
...data,
|
|
18644
|
+
createdFrom: this.http.createdFrom
|
|
18645
|
+
});
|
|
18646
|
+
return response.result;
|
|
18647
|
+
}
|
|
18648
|
+
/** Publish a story to one account. Media by URL only, as for the workspace form. */
|
|
18649
|
+
async createStoryPostToAccount(data) {
|
|
18650
|
+
const response = await this.http.post(`${this.basePath}/story/account`, {
|
|
18651
|
+
...data,
|
|
18652
|
+
createdFrom: this.http.createdFrom
|
|
18653
|
+
});
|
|
18654
|
+
return response.result;
|
|
18655
|
+
}
|
|
17605
18656
|
/**
|
|
17606
18657
|
* Handle thumbnail upload - accepts either File or URL string
|
|
17607
18658
|
* @param thumb - Thumbnail as File (will be uploaded) or URL string (will be passed directly)
|
|
@@ -17850,6 +18901,274 @@ var SocialPublisherPostClient = class {
|
|
|
17850
18901
|
async publishShortVideo(options) {
|
|
17851
18902
|
return this.publishShortVideoToWorkspace(options);
|
|
17852
18903
|
}
|
|
18904
|
+
// ─── Long video (up to 60 minutes) ───────────────────────────────────────
|
|
18905
|
+
/**
|
|
18906
|
+
* Price a long video before publishing it. Neither creates nor charges
|
|
18907
|
+
* anything.
|
|
18908
|
+
*
|
|
18909
|
+
* The server reads the video, measures its duration, and returns the exact
|
|
18910
|
+
* cost plus what each platform would do with a video that long. Show this
|
|
18911
|
+
* before the user commits — the units come from the same function the create
|
|
18912
|
+
* call charges with, so the quote and the bill cannot disagree.
|
|
18913
|
+
*
|
|
18914
|
+
* @param videoURL - URL of an uploaded or externally hosted video
|
|
18915
|
+
*
|
|
18916
|
+
* @example
|
|
18917
|
+
* ```ts
|
|
18918
|
+
* const quote = await client.getLongVideoQuote(fileURL);
|
|
18919
|
+
* if (!quote.withinLimit) throw new Error(quote.reason);
|
|
18920
|
+
* console.log(`${quote.durationSeconds}s costs ${quote.credits} credits`);
|
|
18921
|
+
* const blocked = quote.platforms.filter((p) => !p.accepted);
|
|
18922
|
+
* ```
|
|
18923
|
+
*/
|
|
18924
|
+
async getLongVideoQuote(videoURL) {
|
|
18925
|
+
if (!videoURL) {
|
|
18926
|
+
throw new Error("videoURL is required");
|
|
18927
|
+
}
|
|
18928
|
+
const response = await this.http.post(`${this.basePath}/long-video/quote`, { videoURL });
|
|
18929
|
+
return response.result;
|
|
18930
|
+
}
|
|
18931
|
+
/**
|
|
18932
|
+
* Publish a video of up to 60 minutes to every account connected to a
|
|
18933
|
+
* workspace.
|
|
18934
|
+
*
|
|
18935
|
+
* Handles the whole sequence for an uploaded file: request an upload
|
|
18936
|
+
* destination, push the bytes, then create the post. Pass a URL instead of a
|
|
18937
|
+
* `File` to publish something already hosted elsewhere.
|
|
18938
|
+
*
|
|
18939
|
+
* Cost is duration-based — 50 credits per started 5 minutes — so a 12-minute
|
|
18940
|
+
* video costs 150. Call {@link getLongVideoQuote} first if you need to show
|
|
18941
|
+
* the price. The duration is measured server-side; there is no duration
|
|
18942
|
+
* option here because a client-supplied one would be a client-supplied price.
|
|
18943
|
+
*
|
|
18944
|
+
* Platforms differ on what they accept: a 40-minute video publishes to
|
|
18945
|
+
* YouTube and Facebook but is refused by Instagram, whose Reels cap at 15
|
|
18946
|
+
* minutes. Those targets come back in `refusedTargets` — the post still
|
|
18947
|
+
* publishes to the rest.
|
|
18948
|
+
*
|
|
18949
|
+
* @example
|
|
18950
|
+
* ```ts
|
|
18951
|
+
* const result = await client.publishLongVideoToWorkspace({
|
|
18952
|
+
* workspaceId: "ws_123",
|
|
18953
|
+
* video: recordingFile,
|
|
18954
|
+
* youtube: { title: "Full session", description: "...", tags: ["workshop"] },
|
|
18955
|
+
* onProgress: (p) => console.log(`${p}%`),
|
|
18956
|
+
* });
|
|
18957
|
+
* console.log(`Charged ${result.credits} credits for ${result.durationSeconds}s`);
|
|
18958
|
+
* for (const t of result.refusedTargets) console.warn(t.reason);
|
|
18959
|
+
* ```
|
|
18960
|
+
*/
|
|
18961
|
+
async publishLongVideoToWorkspace(options) {
|
|
18962
|
+
if (!options.workspaceId) {
|
|
18963
|
+
throw new Error("workspaceId is required");
|
|
18964
|
+
}
|
|
18965
|
+
if (!options.video) {
|
|
18966
|
+
throw new Error("video is required");
|
|
18967
|
+
}
|
|
18968
|
+
if (!options.youtube && !options.tiktok && !options.facebook && !options.instagram) {
|
|
18969
|
+
throw new Error("Provide at least one platform configuration (youtube / tiktok / facebook / instagram)");
|
|
18970
|
+
}
|
|
18971
|
+
const isFile2 = this.detectVideoSource(options.video) === "file";
|
|
18972
|
+
const upload = isFile2 ? await this.uploadLongVideo(
|
|
18973
|
+
options.video,
|
|
18974
|
+
options.thumbnail,
|
|
18975
|
+
{
|
|
18976
|
+
onProgress: options.onProgress,
|
|
18977
|
+
onUploadUrl: options.onUploadUrl,
|
|
18978
|
+
resumeFrom: options.resumeFrom,
|
|
18979
|
+
signal: options.signal,
|
|
18980
|
+
terminateOnAbort: options.terminateOnAbort
|
|
18981
|
+
}
|
|
18982
|
+
) : void 0;
|
|
18983
|
+
const videoURL = upload ? upload.videoURL : options.video;
|
|
18984
|
+
const postId = upload?.postId;
|
|
18985
|
+
const thumb = await this.handleThumbnailUpload(options.thumbnail, upload?.uploadUrls);
|
|
18986
|
+
const body = {
|
|
18987
|
+
workspaceId: options.workspaceId,
|
|
18988
|
+
youtube: options.youtube,
|
|
18989
|
+
tiktok: options.tiktok,
|
|
18990
|
+
facebook: options.facebook,
|
|
18991
|
+
instagram: options.instagram,
|
|
18992
|
+
schedule: this.buildSchedule(options.schedule),
|
|
18993
|
+
source: isFile2 ? "video-file" : "video-url",
|
|
18994
|
+
videoURL,
|
|
18995
|
+
thumbURL: thumb?.thumbFileURL,
|
|
18996
|
+
tag: options.tag,
|
|
18997
|
+
refId: options.refId,
|
|
18998
|
+
comment: options.comment
|
|
18999
|
+
};
|
|
19000
|
+
const target = isFile2 ? "by-file" : "by-url";
|
|
19001
|
+
const id = postId ?? thumb?.postId;
|
|
19002
|
+
const url2 = id ? `${this.basePath}/long-video/workspace/${target}/${id}` : `${this.basePath}/long-video/workspace/${target}`;
|
|
19003
|
+
const response = await this.http.post(url2, { ...body, createdFrom: this.http.createdFrom });
|
|
19004
|
+
return this.normaliseLongVideoResult(response.result);
|
|
19005
|
+
}
|
|
19006
|
+
/**
|
|
19007
|
+
* Publish a video of up to 60 minutes to a single connected account.
|
|
19008
|
+
*
|
|
19009
|
+
* With one target there is no partial success: if that platform will not take
|
|
19010
|
+
* a video this long, the whole call is refused and nothing is charged. See
|
|
19011
|
+
* {@link publishLongVideoToWorkspace} for the cost model.
|
|
19012
|
+
*/
|
|
19013
|
+
async publishLongVideoToAccount(options) {
|
|
19014
|
+
if (!options.accountId) {
|
|
19015
|
+
throw new Error("accountId is required");
|
|
19016
|
+
}
|
|
19017
|
+
if (!options.video) {
|
|
19018
|
+
throw new Error("video is required");
|
|
19019
|
+
}
|
|
19020
|
+
if (!options.youtube && !options.tiktok && !options.facebook && !options.instagram) {
|
|
19021
|
+
throw new Error("Provide the platform configuration matching the account (youtube / tiktok / facebook / instagram)");
|
|
19022
|
+
}
|
|
19023
|
+
const isFile2 = this.detectVideoSource(options.video) === "file";
|
|
19024
|
+
const upload = isFile2 ? await this.uploadLongVideo(
|
|
19025
|
+
options.video,
|
|
19026
|
+
options.thumbnail,
|
|
19027
|
+
{
|
|
19028
|
+
onProgress: options.onProgress,
|
|
19029
|
+
onUploadUrl: options.onUploadUrl,
|
|
19030
|
+
resumeFrom: options.resumeFrom,
|
|
19031
|
+
signal: options.signal,
|
|
19032
|
+
terminateOnAbort: options.terminateOnAbort
|
|
19033
|
+
}
|
|
19034
|
+
) : void 0;
|
|
19035
|
+
const videoURL = upload ? upload.videoURL : options.video;
|
|
19036
|
+
const postId = upload?.postId;
|
|
19037
|
+
const thumb = await this.handleThumbnailUpload(options.thumbnail, upload?.uploadUrls);
|
|
19038
|
+
const body = {
|
|
19039
|
+
accountId: options.accountId,
|
|
19040
|
+
youtube: options.youtube,
|
|
19041
|
+
tiktok: options.tiktok,
|
|
19042
|
+
facebook: options.facebook,
|
|
19043
|
+
instagram: options.instagram,
|
|
19044
|
+
schedule: this.buildSchedule(options.schedule),
|
|
19045
|
+
source: isFile2 ? "video-file" : "video-url",
|
|
19046
|
+
videoURL,
|
|
19047
|
+
thumbURL: thumb?.thumbFileURL,
|
|
19048
|
+
tag: options.tag,
|
|
19049
|
+
refId: options.refId,
|
|
19050
|
+
comment: options.comment
|
|
19051
|
+
};
|
|
19052
|
+
const target = isFile2 ? "by-file" : "by-url";
|
|
19053
|
+
const id = postId ?? thumb?.postId;
|
|
19054
|
+
const url2 = id ? `${this.basePath}/long-video/account/${target}/${id}` : `${this.basePath}/long-video/account/${target}`;
|
|
19055
|
+
const response = await this.http.post(url2, { ...body, createdFrom: this.http.createdFrom });
|
|
19056
|
+
return this.normaliseLongVideoResult(response.result);
|
|
19057
|
+
}
|
|
19058
|
+
/**
|
|
19059
|
+
* Re-schedule a post that has not published yet, or send it out now.
|
|
19060
|
+
*
|
|
19061
|
+
* Free — this costs no credits. Only posts still pending with a future
|
|
19062
|
+
* publish time are eligible; anything that has started publishing is refused
|
|
19063
|
+
* by the server with a reason.
|
|
19064
|
+
*
|
|
19065
|
+
* @example
|
|
19066
|
+
* ```ts
|
|
19067
|
+
* const post = await client.getStatus("post_123");
|
|
19068
|
+
* const { __v } = await client.reschedulePost("post_123", { schedule: new Date("2026-09-01T09:00:00Z") }, post.__v);
|
|
19069
|
+
* await client.reschedulePost("post_123", { schedule: "now" }, __v);
|
|
19070
|
+
* ```
|
|
19071
|
+
*
|
|
19072
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
19073
|
+
* @returns `{ _id, __v }`, `__v` being the new version
|
|
19074
|
+
*/
|
|
19075
|
+
async reschedulePost(id, data, version) {
|
|
19076
|
+
if (!id) {
|
|
19077
|
+
throw new Error("id is required");
|
|
19078
|
+
}
|
|
19079
|
+
assertVersion(version);
|
|
19080
|
+
const response = await this.http.put(
|
|
19081
|
+
`${this.basePath}/${id}`,
|
|
19082
|
+
{
|
|
19083
|
+
...data.schedule === "now" ? { scheduleType: "now" } : { scheduleType: "schedule", scheduledAt: data.schedule.toISOString() },
|
|
19084
|
+
...data.caption !== void 0 ? { caption: data.caption } : {}
|
|
19085
|
+
},
|
|
19086
|
+
{ version }
|
|
19087
|
+
);
|
|
19088
|
+
const updated = withVersion(response, id);
|
|
19089
|
+
return { _id: updated._id, __v: updated.__v };
|
|
19090
|
+
}
|
|
19091
|
+
/**
|
|
19092
|
+
* Delete a post that has not published yet, releasing its uploaded media in
|
|
19093
|
+
* the same request.
|
|
19094
|
+
*
|
|
19095
|
+
* Free, and nothing is refunded — nothing was charged for a post that never
|
|
19096
|
+
* went out. A post that HAS published is refused; use {@link removePost} to
|
|
19097
|
+
* take down media that is already live.
|
|
19098
|
+
*
|
|
19099
|
+
* @example
|
|
19100
|
+
* ```ts
|
|
19101
|
+
* await client.deletePost("post_123", post.__v);
|
|
19102
|
+
* ```
|
|
19103
|
+
*
|
|
19104
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
19105
|
+
*/
|
|
19106
|
+
async deletePost(id, version) {
|
|
19107
|
+
if (!id) {
|
|
19108
|
+
throw new Error("id is required");
|
|
19109
|
+
}
|
|
19110
|
+
assertVersion(version);
|
|
19111
|
+
await this.http.delete(`${this.basePath}/${id}`, { version });
|
|
19112
|
+
}
|
|
19113
|
+
/**
|
|
19114
|
+
* Upload a long video and return the URL to publish from.
|
|
19115
|
+
*
|
|
19116
|
+
* Declares `postType: "longVideo"` so the server refuses now — on plan gating
|
|
19117
|
+
* or an empty balance — rather than after an hour of transfer.
|
|
19118
|
+
*/
|
|
19119
|
+
async uploadLongVideo(video, thumb, controls = {}) {
|
|
19120
|
+
const { onProgress, onUploadUrl, resumeFrom, signal, terminateOnAbort } = controls;
|
|
19121
|
+
if (video.size > this.maxVideoUploadSizeBytes) {
|
|
19122
|
+
throw new Error(`Video file size (${video.size} bytes) exceeds maximum allowed size (${this.maxVideoUploadSizeBytes} bytes)`);
|
|
19123
|
+
}
|
|
19124
|
+
const allowedVideoTypes = [".mp4", ".mov", ".avi", ".mkv", ".webm"];
|
|
19125
|
+
const videoExtension = "." + video.name.split(".").pop()?.toLowerCase();
|
|
19126
|
+
if (!allowedVideoTypes.includes(videoExtension)) {
|
|
19127
|
+
throw new Error(`Invalid video file type. Allowed types: ${allowedVideoTypes.join(", ")}`);
|
|
19128
|
+
}
|
|
19129
|
+
const uploadUrls = await this.generateUploadUrls({
|
|
19130
|
+
videoFileType: video.type,
|
|
19131
|
+
thumbFileType: thumb instanceof File ? thumb.type : void 0,
|
|
19132
|
+
postType: "longVideo"
|
|
19133
|
+
});
|
|
19134
|
+
if (supportsResumableUpload(uploadUrls.video)) {
|
|
19135
|
+
await uploadResumable(uploadUrls.video, video, {
|
|
19136
|
+
onProgress,
|
|
19137
|
+
onUploadUrl,
|
|
19138
|
+
uploadUrl: resumeFrom,
|
|
19139
|
+
signal,
|
|
19140
|
+
terminateOnAbort
|
|
19141
|
+
});
|
|
19142
|
+
} else {
|
|
19143
|
+
await uploadToR2(uploadUrls.video.uploadFileURL, video, {
|
|
19144
|
+
contentType: video.type,
|
|
19145
|
+
onProgress
|
|
19146
|
+
});
|
|
19147
|
+
}
|
|
19148
|
+
return { videoURL: uploadUrls.video.fileURL, postId: uploadUrls.postId, uploadUrls };
|
|
19149
|
+
}
|
|
19150
|
+
/** Translate the friendly `"now" | Date` form into the wire shape. */
|
|
19151
|
+
buildSchedule(schedule) {
|
|
19152
|
+
if (!schedule) return void 0;
|
|
19153
|
+
return {
|
|
19154
|
+
type: schedule === "now" ? "now" : "schedule",
|
|
19155
|
+
scheduledAt: schedule instanceof Date ? schedule : void 0
|
|
19156
|
+
};
|
|
19157
|
+
}
|
|
19158
|
+
/**
|
|
19159
|
+
* Guarantee the shape callers destructure. An older server that does not yet
|
|
19160
|
+
* return the duration fields would otherwise hand back `undefined` where the
|
|
19161
|
+
* types promise numbers.
|
|
19162
|
+
*/
|
|
19163
|
+
normaliseLongVideoResult(result) {
|
|
19164
|
+
return {
|
|
19165
|
+
_id: result?._id,
|
|
19166
|
+
durationSeconds: result?.durationSeconds ?? 0,
|
|
19167
|
+
creditUnits: result?.creditUnits ?? 0,
|
|
19168
|
+
credits: result?.credits ?? 0,
|
|
19169
|
+
refusedTargets: result?.refusedTargets ?? []
|
|
19170
|
+
};
|
|
19171
|
+
}
|
|
17853
19172
|
/**
|
|
17854
19173
|
* Auto-detect video source type.
|
|
17855
19174
|
*
|
|
@@ -17866,6 +19185,13 @@ var SocialPublisherPostClient = class {
|
|
|
17866
19185
|
throw new Error("Invalid video type. Must be File or string URL");
|
|
17867
19186
|
}
|
|
17868
19187
|
};
|
|
19188
|
+
|
|
19189
|
+
// src/interfaces/requests/index.ts
|
|
19190
|
+
var MAX_POST_COMMENTS = 5;
|
|
19191
|
+
var MAX_COMMENT_LENGTH = 2200;
|
|
19192
|
+
var MAX_COMMENT_DELAY_MINUTES = 24 * 60;
|
|
19193
|
+
var LONG_VIDEO_MAX_DURATION_SECONDS = 3600;
|
|
19194
|
+
var LONG_VIDEO_CREDIT_UNIT_SECONDS = 300;
|
|
17869
19195
|
/*! Bundled license information:
|
|
17870
19196
|
|
|
17871
19197
|
mime-db/index.js:
|
|
@@ -17885,6 +19211,6 @@ mime-types/index.js:
|
|
|
17885
19211
|
*)
|
|
17886
19212
|
*/
|
|
17887
19213
|
|
|
17888
|
-
export { HttpClient, SocialPublisherPostClient, uploadToR2 };
|
|
19214
|
+
export { DEFAULT_CHUNK_SIZE2 as DEFAULT_CHUNK_SIZE, HttpClient, LONG_VIDEO_CREDIT_UNIT_SECONDS, LONG_VIDEO_MAX_DURATION_SECONDS, MAX_COMMENT_DELAY_MINUTES, MAX_COMMENT_LENGTH, MAX_POST_COMMENTS, SocialPublisherPostClient, supportsResumableUpload, terminateUpload, uploadResumable, uploadToR2 };
|
|
17889
19215
|
//# sourceMappingURL=index.mjs.map
|
|
17890
19216
|
//# sourceMappingURL=index.mjs.map
|