@bitrix24/b24jssdk 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.d.mts +37 -21
- package/dist/esm/index.d.ts +37 -21
- package/dist/esm/index.mjs +50 -17
- package/dist/esm/index.mjs.map +1 -1
- package/dist/umd/index.js +330 -224
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +19 -19
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +5 -5
package/dist/umd/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @version @bitrix24/b24jssdk v0.4.
|
|
2
|
+
* @version @bitrix24/b24jssdk v0.4.10
|
|
3
3
|
* @copyright (c) 2025 Bitrix24
|
|
4
4
|
* @licence MIT
|
|
5
5
|
* @links https://github.com/bitrix24/b24jssdk - GitHub
|
|
@@ -9853,7 +9853,7 @@ ${this.stack}`;
|
|
|
9853
9853
|
*/
|
|
9854
9854
|
function isBuffer$1(val) {
|
|
9855
9855
|
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
|
9856
|
-
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
9856
|
+
&& isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
9857
9857
|
}
|
|
9858
9858
|
|
|
9859
9859
|
/**
|
|
@@ -9898,7 +9898,7 @@ ${this.stack}`;
|
|
|
9898
9898
|
* @param {*} val The value to test
|
|
9899
9899
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
9900
9900
|
*/
|
|
9901
|
-
const isFunction = typeOfTest('function');
|
|
9901
|
+
const isFunction$1 = typeOfTest('function');
|
|
9902
9902
|
|
|
9903
9903
|
/**
|
|
9904
9904
|
* Determine if a value is a Number
|
|
@@ -9954,7 +9954,7 @@ ${this.stack}`;
|
|
|
9954
9954
|
if (!isObject(val) || isBuffer$1(val)) {
|
|
9955
9955
|
return false;
|
|
9956
9956
|
}
|
|
9957
|
-
|
|
9957
|
+
|
|
9958
9958
|
try {
|
|
9959
9959
|
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
9960
9960
|
} catch (e) {
|
|
@@ -10006,7 +10006,7 @@ ${this.stack}`;
|
|
|
10006
10006
|
*
|
|
10007
10007
|
* @returns {boolean} True if value is a Stream, otherwise false
|
|
10008
10008
|
*/
|
|
10009
|
-
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
10009
|
+
const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
10010
10010
|
|
|
10011
10011
|
/**
|
|
10012
10012
|
* Determine if a value is a FormData
|
|
@@ -10019,10 +10019,10 @@ ${this.stack}`;
|
|
|
10019
10019
|
let kind;
|
|
10020
10020
|
return thing && (
|
|
10021
10021
|
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
10022
|
-
isFunction(thing.append) && (
|
|
10022
|
+
isFunction$1(thing.append) && (
|
|
10023
10023
|
(kind = kindOf(thing)) === 'formdata' ||
|
|
10024
10024
|
// detect form-data instance
|
|
10025
|
-
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
|
10025
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
10026
10026
|
)
|
|
10027
10027
|
)
|
|
10028
10028
|
)
|
|
@@ -10147,7 +10147,7 @@ ${this.stack}`;
|
|
|
10147
10147
|
* @returns {Object} Result of all merge properties
|
|
10148
10148
|
*/
|
|
10149
10149
|
function merge$1(/* obj1, obj2, obj3, ... */) {
|
|
10150
|
-
const {caseless} = isContextDefined(this) && this || {};
|
|
10150
|
+
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
10151
10151
|
const result = {};
|
|
10152
10152
|
const assignValue = (val, key) => {
|
|
10153
10153
|
const targetKey = caseless && findKey(result, key) || key;
|
|
@@ -10157,7 +10157,7 @@ ${this.stack}`;
|
|
|
10157
10157
|
result[targetKey] = merge$1({}, val);
|
|
10158
10158
|
} else if (isArray$3(val)) {
|
|
10159
10159
|
result[targetKey] = val.slice();
|
|
10160
|
-
} else {
|
|
10160
|
+
} else if (!skipUndefined || !isUndefined(val)) {
|
|
10161
10161
|
result[targetKey] = val;
|
|
10162
10162
|
}
|
|
10163
10163
|
};
|
|
@@ -10180,7 +10180,7 @@ ${this.stack}`;
|
|
|
10180
10180
|
*/
|
|
10181
10181
|
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
10182
10182
|
forEach(b, (val, key) => {
|
|
10183
|
-
if (thisArg && isFunction(val)) {
|
|
10183
|
+
if (thisArg && isFunction$1(val)) {
|
|
10184
10184
|
a[key] = bind(val, thisArg);
|
|
10185
10185
|
} else {
|
|
10186
10186
|
a[key] = val;
|
|
@@ -10396,13 +10396,13 @@ ${this.stack}`;
|
|
|
10396
10396
|
const freezeMethods = (obj) => {
|
|
10397
10397
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
10398
10398
|
// skip restricted props in strict mode
|
|
10399
|
-
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
10399
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
10400
10400
|
return false;
|
|
10401
10401
|
}
|
|
10402
10402
|
|
|
10403
10403
|
const value = obj[name];
|
|
10404
10404
|
|
|
10405
|
-
if (!isFunction(value)) return;
|
|
10405
|
+
if (!isFunction$1(value)) return;
|
|
10406
10406
|
|
|
10407
10407
|
descriptor.enumerable = false;
|
|
10408
10408
|
|
|
@@ -10439,6 +10439,8 @@ ${this.stack}`;
|
|
|
10439
10439
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
10440
10440
|
};
|
|
10441
10441
|
|
|
10442
|
+
|
|
10443
|
+
|
|
10442
10444
|
/**
|
|
10443
10445
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
10444
10446
|
*
|
|
@@ -10447,7 +10449,7 @@ ${this.stack}`;
|
|
|
10447
10449
|
* @returns {boolean}
|
|
10448
10450
|
*/
|
|
10449
10451
|
function isSpecCompliantForm(thing) {
|
|
10450
|
-
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
10452
|
+
return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
10451
10453
|
}
|
|
10452
10454
|
|
|
10453
10455
|
const toJSONObject = (obj) => {
|
|
@@ -10489,7 +10491,7 @@ ${this.stack}`;
|
|
|
10489
10491
|
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
10490
10492
|
|
|
10491
10493
|
const isThenable = (thing) =>
|
|
10492
|
-
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
10494
|
+
thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
10493
10495
|
|
|
10494
10496
|
// original code
|
|
10495
10497
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -10513,7 +10515,7 @@ ${this.stack}`;
|
|
|
10513
10515
|
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
10514
10516
|
})(
|
|
10515
10517
|
typeof setImmediate === 'function',
|
|
10516
|
-
isFunction(_global.postMessage)
|
|
10518
|
+
isFunction$1(_global.postMessage)
|
|
10517
10519
|
);
|
|
10518
10520
|
|
|
10519
10521
|
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
@@ -10522,7 +10524,7 @@ ${this.stack}`;
|
|
|
10522
10524
|
// *********************
|
|
10523
10525
|
|
|
10524
10526
|
|
|
10525
|
-
const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
|
|
10527
|
+
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
10526
10528
|
|
|
10527
10529
|
|
|
10528
10530
|
const utils$1 = {
|
|
@@ -10546,7 +10548,7 @@ ${this.stack}`;
|
|
|
10546
10548
|
isFile,
|
|
10547
10549
|
isBlob,
|
|
10548
10550
|
isRegExp,
|
|
10549
|
-
isFunction,
|
|
10551
|
+
isFunction: isFunction$1,
|
|
10550
10552
|
isStream,
|
|
10551
10553
|
isURLSearchParams,
|
|
10552
10554
|
isTypedArray,
|
|
@@ -10672,11 +10674,18 @@ ${this.stack}`;
|
|
|
10672
10674
|
return prop !== 'isAxiosError';
|
|
10673
10675
|
});
|
|
10674
10676
|
|
|
10675
|
-
|
|
10677
|
+
const msg = error && error.message ? error.message : 'Error';
|
|
10676
10678
|
|
|
10677
|
-
|
|
10679
|
+
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
10680
|
+
const errCode = code == null && error ? error.code : code;
|
|
10681
|
+
AxiosError$1.call(axiosError, msg, errCode, config, request, response);
|
|
10678
10682
|
|
|
10679
|
-
|
|
10683
|
+
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
10684
|
+
if (error && axiosError.cause == null) {
|
|
10685
|
+
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
10686
|
+
}
|
|
10687
|
+
|
|
10688
|
+
axiosError.name = (error && error.name) || 'Error';
|
|
10680
10689
|
|
|
10681
10690
|
customProps && Object.assign(axiosError, customProps);
|
|
10682
10691
|
|
|
@@ -10967,9 +10976,7 @@ ${this.stack}`;
|
|
|
10967
10976
|
replace(/%3A/gi, ':').
|
|
10968
10977
|
replace(/%24/g, '$').
|
|
10969
10978
|
replace(/%2C/gi, ',').
|
|
10970
|
-
replace(/%20/g, '+')
|
|
10971
|
-
replace(/%5B/gi, '[').
|
|
10972
|
-
replace(/%5D/gi, ']');
|
|
10979
|
+
replace(/%20/g, '+');
|
|
10973
10980
|
}
|
|
10974
10981
|
|
|
10975
10982
|
/**
|
|
@@ -11372,7 +11379,7 @@ ${this.stack}`;
|
|
|
11372
11379
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
11373
11380
|
|
|
11374
11381
|
try {
|
|
11375
|
-
return JSON.parse(data);
|
|
11382
|
+
return JSON.parse(data, this.parseReviver);
|
|
11376
11383
|
} catch (e) {
|
|
11377
11384
|
if (strictJSONParsing) {
|
|
11378
11385
|
if (e.name === 'SyntaxError') {
|
|
@@ -12193,7 +12200,7 @@ ${this.stack}`;
|
|
|
12193
12200
|
const resolveConfig = (config) => {
|
|
12194
12201
|
const newConfig = mergeConfig$1({}, config);
|
|
12195
12202
|
|
|
12196
|
-
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
12203
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
12197
12204
|
|
|
12198
12205
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
12199
12206
|
|
|
@@ -12206,17 +12213,21 @@ ${this.stack}`;
|
|
|
12206
12213
|
);
|
|
12207
12214
|
}
|
|
12208
12215
|
|
|
12209
|
-
let contentType;
|
|
12210
|
-
|
|
12211
12216
|
if (utils$1.isFormData(data)) {
|
|
12212
12217
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
12213
|
-
headers.setContentType(undefined); //
|
|
12214
|
-
} else if ((
|
|
12215
|
-
//
|
|
12216
|
-
const
|
|
12217
|
-
headers
|
|
12218
|
+
headers.setContentType(undefined); // browser handles it
|
|
12219
|
+
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
12220
|
+
// Node.js FormData (like form-data package)
|
|
12221
|
+
const formHeaders = data.getHeaders();
|
|
12222
|
+
// Only set safe headers to avoid overwriting security headers
|
|
12223
|
+
const allowedHeaders = ['content-type', 'content-length'];
|
|
12224
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
12225
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
12226
|
+
headers.set(key, val);
|
|
12227
|
+
}
|
|
12228
|
+
});
|
|
12218
12229
|
}
|
|
12219
|
-
}
|
|
12230
|
+
}
|
|
12220
12231
|
|
|
12221
12232
|
// Add xsrf header
|
|
12222
12233
|
// This is only done if running in a standard browser environment.
|
|
@@ -12333,15 +12344,18 @@ ${this.stack}`;
|
|
|
12333
12344
|
};
|
|
12334
12345
|
|
|
12335
12346
|
// Handle low level network errors
|
|
12336
|
-
|
|
12337
|
-
|
|
12338
|
-
|
|
12339
|
-
|
|
12340
|
-
|
|
12341
|
-
|
|
12342
|
-
|
|
12347
|
+
request.onerror = function handleError(event) {
|
|
12348
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
12349
|
+
// (message may be empty; when present, surface it)
|
|
12350
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
12351
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
12352
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
12353
|
+
// attach the underlying event for consumers who want details
|
|
12354
|
+
err.event = event || null;
|
|
12355
|
+
reject(err);
|
|
12356
|
+
request = null;
|
|
12343
12357
|
};
|
|
12344
|
-
|
|
12358
|
+
|
|
12345
12359
|
// Handle timeout
|
|
12346
12360
|
request.ontimeout = function handleTimeout() {
|
|
12347
12361
|
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
@@ -12555,14 +12569,18 @@ ${this.stack}`;
|
|
|
12555
12569
|
})
|
|
12556
12570
|
};
|
|
12557
12571
|
|
|
12558
|
-
const
|
|
12559
|
-
|
|
12572
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
12573
|
+
|
|
12574
|
+
const {isFunction} = utils$1;
|
|
12575
|
+
|
|
12576
|
+
const globalFetchAPI = (({Request, Response}) => ({
|
|
12577
|
+
Request, Response
|
|
12578
|
+
}))(utils$1.global);
|
|
12579
|
+
|
|
12580
|
+
const {
|
|
12581
|
+
ReadableStream: ReadableStream$1, TextEncoder
|
|
12582
|
+
} = utils$1.global;
|
|
12560
12583
|
|
|
12561
|
-
// used only inside the fetch adapter
|
|
12562
|
-
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
12563
|
-
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
12564
|
-
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
12565
|
-
);
|
|
12566
12584
|
|
|
12567
12585
|
const test = (fn, ...args) => {
|
|
12568
12586
|
try {
|
|
@@ -12572,211 +12590,268 @@ ${this.stack}`;
|
|
|
12572
12590
|
}
|
|
12573
12591
|
};
|
|
12574
12592
|
|
|
12575
|
-
const
|
|
12576
|
-
|
|
12593
|
+
const factory = (env) => {
|
|
12594
|
+
env = utils$1.merge.call({
|
|
12595
|
+
skipUndefined: true
|
|
12596
|
+
}, globalFetchAPI, env);
|
|
12577
12597
|
|
|
12578
|
-
const
|
|
12579
|
-
|
|
12580
|
-
|
|
12581
|
-
|
|
12582
|
-
duplexAccessed = true;
|
|
12583
|
-
return 'half';
|
|
12584
|
-
},
|
|
12585
|
-
}).headers.has('Content-Type');
|
|
12598
|
+
const {fetch: envFetch, Request, Response} = env;
|
|
12599
|
+
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
12600
|
+
const isRequestSupported = isFunction(Request);
|
|
12601
|
+
const isResponseSupported = isFunction(Response);
|
|
12586
12602
|
|
|
12587
|
-
|
|
12588
|
-
|
|
12603
|
+
if (!isFetchSupported) {
|
|
12604
|
+
return false;
|
|
12605
|
+
}
|
|
12589
12606
|
|
|
12590
|
-
|
|
12607
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
12591
12608
|
|
|
12592
|
-
|
|
12593
|
-
|
|
12609
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
12610
|
+
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
|
|
12611
|
+
async (str) => new Uint8Array(await new Request(str).arrayBuffer())
|
|
12612
|
+
);
|
|
12594
12613
|
|
|
12614
|
+
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
12615
|
+
let duplexAccessed = false;
|
|
12595
12616
|
|
|
12596
|
-
|
|
12597
|
-
|
|
12598
|
-
|
|
12617
|
+
const hasContentType = new Request(platform.origin, {
|
|
12618
|
+
body: new ReadableStream$1(),
|
|
12619
|
+
method: 'POST',
|
|
12620
|
+
get duplex() {
|
|
12621
|
+
duplexAccessed = true;
|
|
12622
|
+
return 'half';
|
|
12623
|
+
},
|
|
12624
|
+
}).headers.has('Content-Type');
|
|
12599
12625
|
|
|
12600
|
-
|
|
12601
|
-
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
12602
|
-
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
12603
|
-
(_, config) => {
|
|
12604
|
-
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
|
12605
|
-
});
|
|
12626
|
+
return duplexAccessed && !hasContentType;
|
|
12606
12627
|
});
|
|
12607
|
-
})(new Response));
|
|
12608
12628
|
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
return 0;
|
|
12612
|
-
}
|
|
12629
|
+
const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
|
|
12630
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
12613
12631
|
|
|
12614
|
-
|
|
12615
|
-
|
|
12616
|
-
}
|
|
12632
|
+
const resolvers = {
|
|
12633
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
12634
|
+
};
|
|
12617
12635
|
|
|
12618
|
-
|
|
12619
|
-
|
|
12620
|
-
|
|
12621
|
-
|
|
12636
|
+
isFetchSupported && ((() => {
|
|
12637
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
12638
|
+
!resolvers[type] && (resolvers[type] = (res, config) => {
|
|
12639
|
+
let method = res && res[type];
|
|
12640
|
+
|
|
12641
|
+
if (method) {
|
|
12642
|
+
return method.call(res);
|
|
12643
|
+
}
|
|
12644
|
+
|
|
12645
|
+
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
|
12646
|
+
});
|
|
12622
12647
|
});
|
|
12623
|
-
|
|
12624
|
-
}
|
|
12648
|
+
})());
|
|
12625
12649
|
|
|
12626
|
-
|
|
12627
|
-
|
|
12628
|
-
|
|
12650
|
+
const getBodyLength = async (body) => {
|
|
12651
|
+
if (body == null) {
|
|
12652
|
+
return 0;
|
|
12653
|
+
}
|
|
12629
12654
|
|
|
12630
|
-
|
|
12631
|
-
|
|
12632
|
-
|
|
12655
|
+
if (utils$1.isBlob(body)) {
|
|
12656
|
+
return body.size;
|
|
12657
|
+
}
|
|
12633
12658
|
|
|
12634
|
-
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12659
|
+
if (utils$1.isSpecCompliantForm(body)) {
|
|
12660
|
+
const _request = new Request(platform.origin, {
|
|
12661
|
+
method: 'POST',
|
|
12662
|
+
body,
|
|
12663
|
+
});
|
|
12664
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
12665
|
+
}
|
|
12638
12666
|
|
|
12639
|
-
|
|
12640
|
-
|
|
12667
|
+
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
12668
|
+
return body.byteLength;
|
|
12669
|
+
}
|
|
12641
12670
|
|
|
12642
|
-
|
|
12643
|
-
|
|
12671
|
+
if (utils$1.isURLSearchParams(body)) {
|
|
12672
|
+
body = body + '';
|
|
12673
|
+
}
|
|
12644
12674
|
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12675
|
+
if (utils$1.isString(body)) {
|
|
12676
|
+
return (await encodeText(body)).byteLength;
|
|
12677
|
+
}
|
|
12678
|
+
};
|
|
12679
|
+
|
|
12680
|
+
const resolveBodyLength = async (headers, body) => {
|
|
12681
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
12682
|
+
|
|
12683
|
+
return length == null ? getBodyLength(body) : length;
|
|
12684
|
+
};
|
|
12685
|
+
|
|
12686
|
+
return async (config) => {
|
|
12687
|
+
let {
|
|
12688
|
+
url,
|
|
12689
|
+
method,
|
|
12690
|
+
data,
|
|
12691
|
+
signal,
|
|
12692
|
+
cancelToken,
|
|
12693
|
+
timeout,
|
|
12694
|
+
onDownloadProgress,
|
|
12695
|
+
onUploadProgress,
|
|
12696
|
+
responseType,
|
|
12697
|
+
headers,
|
|
12698
|
+
withCredentials = 'same-origin',
|
|
12699
|
+
fetchOptions
|
|
12700
|
+
} = resolveConfig(config);
|
|
12701
|
+
|
|
12702
|
+
let _fetch = envFetch || fetch;
|
|
12660
12703
|
|
|
12661
|
-
|
|
12704
|
+
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
12662
12705
|
|
|
12663
|
-
|
|
12706
|
+
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
12664
12707
|
|
|
12665
|
-
|
|
12708
|
+
let request = null;
|
|
12666
12709
|
|
|
12667
|
-
|
|
12710
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
12668
12711
|
composedSignal.unsubscribe();
|
|
12669
|
-
|
|
12712
|
+
});
|
|
12670
12713
|
|
|
12671
|
-
|
|
12714
|
+
let requestContentLength;
|
|
12672
12715
|
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12716
|
+
try {
|
|
12717
|
+
if (
|
|
12718
|
+
onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
|
|
12719
|
+
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
12720
|
+
) {
|
|
12721
|
+
let _request = new Request(url, {
|
|
12722
|
+
method: 'POST',
|
|
12723
|
+
body: data,
|
|
12724
|
+
duplex: "half"
|
|
12725
|
+
});
|
|
12683
12726
|
|
|
12684
|
-
|
|
12727
|
+
let contentTypeHeader;
|
|
12685
12728
|
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12729
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
12730
|
+
headers.setContentType(contentTypeHeader);
|
|
12731
|
+
}
|
|
12689
12732
|
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12733
|
+
if (_request.body) {
|
|
12734
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
12735
|
+
requestContentLength,
|
|
12736
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
12737
|
+
);
|
|
12695
12738
|
|
|
12696
|
-
|
|
12739
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
12740
|
+
}
|
|
12697
12741
|
}
|
|
12698
|
-
}
|
|
12699
12742
|
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
|
|
12743
|
+
if (!utils$1.isString(withCredentials)) {
|
|
12744
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
12745
|
+
}
|
|
12703
12746
|
|
|
12704
|
-
|
|
12705
|
-
|
|
12706
|
-
|
|
12707
|
-
request = new Request(url, {
|
|
12708
|
-
...fetchOptions,
|
|
12709
|
-
signal: composedSignal,
|
|
12710
|
-
method: method.toUpperCase(),
|
|
12711
|
-
headers: headers.normalize().toJSON(),
|
|
12712
|
-
body: data,
|
|
12713
|
-
duplex: "half",
|
|
12714
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
12715
|
-
});
|
|
12747
|
+
// Cloudflare Workers throws when credentials are defined
|
|
12748
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
12749
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
12716
12750
|
|
|
12717
|
-
|
|
12751
|
+
const resolvedOptions = {
|
|
12752
|
+
...fetchOptions,
|
|
12753
|
+
signal: composedSignal,
|
|
12754
|
+
method: method.toUpperCase(),
|
|
12755
|
+
headers: headers.normalize().toJSON(),
|
|
12756
|
+
body: data,
|
|
12757
|
+
duplex: "half",
|
|
12758
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
12759
|
+
};
|
|
12718
12760
|
|
|
12719
|
-
|
|
12761
|
+
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
12720
12762
|
|
|
12721
|
-
|
|
12722
|
-
const options = {};
|
|
12763
|
+
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
12723
12764
|
|
|
12724
|
-
|
|
12725
|
-
options[prop] = response[prop];
|
|
12726
|
-
});
|
|
12765
|
+
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
12727
12766
|
|
|
12728
|
-
|
|
12767
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
12768
|
+
const options = {};
|
|
12729
12769
|
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
) || [];
|
|
12770
|
+
['status', 'statusText', 'headers'].forEach(prop => {
|
|
12771
|
+
options[prop] = response[prop];
|
|
12772
|
+
});
|
|
12734
12773
|
|
|
12735
|
-
|
|
12736
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
12737
|
-
flush && flush();
|
|
12738
|
-
unsubscribe && unsubscribe();
|
|
12739
|
-
}),
|
|
12740
|
-
options
|
|
12741
|
-
);
|
|
12742
|
-
}
|
|
12774
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
12743
12775
|
|
|
12744
|
-
|
|
12776
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
12777
|
+
responseContentLength,
|
|
12778
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
12779
|
+
) || [];
|
|
12745
12780
|
|
|
12746
|
-
|
|
12781
|
+
response = new Response(
|
|
12782
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
12783
|
+
flush && flush();
|
|
12784
|
+
unsubscribe && unsubscribe();
|
|
12785
|
+
}),
|
|
12786
|
+
options
|
|
12787
|
+
);
|
|
12788
|
+
}
|
|
12747
12789
|
|
|
12748
|
-
|
|
12790
|
+
responseType = responseType || 'text';
|
|
12749
12791
|
|
|
12750
|
-
|
|
12751
|
-
settle(resolve, reject, {
|
|
12752
|
-
data: responseData,
|
|
12753
|
-
headers: AxiosHeaders$1.from(response.headers),
|
|
12754
|
-
status: response.status,
|
|
12755
|
-
statusText: response.statusText,
|
|
12756
|
-
config,
|
|
12757
|
-
request
|
|
12758
|
-
});
|
|
12759
|
-
})
|
|
12760
|
-
} catch (err) {
|
|
12761
|
-
unsubscribe && unsubscribe();
|
|
12792
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
12762
12793
|
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
{
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12794
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
12795
|
+
|
|
12796
|
+
return await new Promise((resolve, reject) => {
|
|
12797
|
+
settle(resolve, reject, {
|
|
12798
|
+
data: responseData,
|
|
12799
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
12800
|
+
status: response.status,
|
|
12801
|
+
statusText: response.statusText,
|
|
12802
|
+
config,
|
|
12803
|
+
request
|
|
12804
|
+
});
|
|
12805
|
+
})
|
|
12806
|
+
} catch (err) {
|
|
12807
|
+
unsubscribe && unsubscribe();
|
|
12808
|
+
|
|
12809
|
+
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
12810
|
+
throw Object.assign(
|
|
12811
|
+
new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
|
|
12812
|
+
{
|
|
12813
|
+
cause: err.cause || err
|
|
12814
|
+
}
|
|
12815
|
+
)
|
|
12816
|
+
}
|
|
12817
|
+
|
|
12818
|
+
throw AxiosError$1.from(err, err && err.code, config, request);
|
|
12770
12819
|
}
|
|
12820
|
+
}
|
|
12821
|
+
};
|
|
12822
|
+
|
|
12823
|
+
const seedCache = new Map();
|
|
12824
|
+
|
|
12825
|
+
const getFetch = (config) => {
|
|
12826
|
+
let env = config ? config.env : {};
|
|
12827
|
+
const {fetch, Request, Response} = env;
|
|
12828
|
+
const seeds = [
|
|
12829
|
+
Request, Response, fetch
|
|
12830
|
+
];
|
|
12831
|
+
|
|
12832
|
+
let len = seeds.length, i = len,
|
|
12833
|
+
seed, target, map = seedCache;
|
|
12834
|
+
|
|
12835
|
+
while (i--) {
|
|
12836
|
+
seed = seeds[i];
|
|
12837
|
+
target = map.get(seed);
|
|
12771
12838
|
|
|
12772
|
-
|
|
12839
|
+
target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
|
|
12840
|
+
|
|
12841
|
+
map = target;
|
|
12773
12842
|
}
|
|
12774
|
-
|
|
12843
|
+
|
|
12844
|
+
return target;
|
|
12845
|
+
};
|
|
12846
|
+
|
|
12847
|
+
getFetch();
|
|
12775
12848
|
|
|
12776
12849
|
const knownAdapters = {
|
|
12777
12850
|
http: httpAdapter,
|
|
12778
12851
|
xhr: xhrAdapter,
|
|
12779
|
-
fetch:
|
|
12852
|
+
fetch: {
|
|
12853
|
+
get: getFetch,
|
|
12854
|
+
}
|
|
12780
12855
|
};
|
|
12781
12856
|
|
|
12782
12857
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
@@ -12795,7 +12870,7 @@ ${this.stack}`;
|
|
|
12795
12870
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
12796
12871
|
|
|
12797
12872
|
const adapters = {
|
|
12798
|
-
getAdapter: (adapters) => {
|
|
12873
|
+
getAdapter: (adapters, config) => {
|
|
12799
12874
|
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
12800
12875
|
|
|
12801
12876
|
const {length} = adapters;
|
|
@@ -12818,7 +12893,7 @@ ${this.stack}`;
|
|
|
12818
12893
|
}
|
|
12819
12894
|
}
|
|
12820
12895
|
|
|
12821
|
-
if (adapter) {
|
|
12896
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
12822
12897
|
break;
|
|
12823
12898
|
}
|
|
12824
12899
|
|
|
@@ -12886,7 +12961,7 @@ ${this.stack}`;
|
|
|
12886
12961
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
12887
12962
|
}
|
|
12888
12963
|
|
|
12889
|
-
const adapter = adapters.getAdapter(config.adapter || defaults$2.adapter);
|
|
12964
|
+
const adapter = adapters.getAdapter(config.adapter || defaults$2.adapter, config);
|
|
12890
12965
|
|
|
12891
12966
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
12892
12967
|
throwIfCancellationRequested(config);
|
|
@@ -12920,7 +12995,7 @@ ${this.stack}`;
|
|
|
12920
12995
|
});
|
|
12921
12996
|
}
|
|
12922
12997
|
|
|
12923
|
-
const VERSION$1 = "1.
|
|
12998
|
+
const VERSION$1 = "1.12.2";
|
|
12924
12999
|
|
|
12925
13000
|
const validators$1 = {};
|
|
12926
13001
|
|
|
@@ -13176,8 +13251,6 @@ ${this.stack}`;
|
|
|
13176
13251
|
|
|
13177
13252
|
let newConfig = config;
|
|
13178
13253
|
|
|
13179
|
-
i = 0;
|
|
13180
|
-
|
|
13181
13254
|
while (i < len) {
|
|
13182
13255
|
const onFulfilled = requestInterceptorChain[i++];
|
|
13183
13256
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -14376,7 +14449,7 @@ ${this.stack}`;
|
|
|
14376
14449
|
#clientSideWarningMessage = "";
|
|
14377
14450
|
constructor(baseURL, authActions, options) {
|
|
14378
14451
|
const defaultHeaders = {
|
|
14379
|
-
// 'X-Sdk': 'b24-js-sdk-v-0.4.
|
|
14452
|
+
// 'X-Sdk': 'b24-js-sdk-v-0.4.10'
|
|
14380
14453
|
};
|
|
14381
14454
|
this.#clientAxios = axios.create({
|
|
14382
14455
|
baseURL,
|
|
@@ -14804,9 +14877,12 @@ ${this.stack}`;
|
|
|
14804
14877
|
*/
|
|
14805
14878
|
#prepareMethod(method) {
|
|
14806
14879
|
const baseUrl = `${encodeURIComponent(method)}.json`;
|
|
14880
|
+
if (method.includes("task.")) {
|
|
14881
|
+
return `${baseUrl}`;
|
|
14882
|
+
}
|
|
14807
14883
|
const queryParams = new URLSearchParams({
|
|
14808
14884
|
[this.#requestIdGenerator.getQueryStringParameterName()]: this.#requestIdGenerator.getRequestId(),
|
|
14809
|
-
[this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.
|
|
14885
|
+
[this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.10",
|
|
14810
14886
|
[this.#requestIdGenerator.getQueryStringSdkTypeParameterName()]: "b24-js-sdk"
|
|
14811
14887
|
});
|
|
14812
14888
|
return `${baseUrl}?${queryParams.toString()}`;
|
|
@@ -17084,6 +17160,7 @@ ${this.stack}`;
|
|
|
17084
17160
|
class AuthOAuthManager {
|
|
17085
17161
|
#clientAxios;
|
|
17086
17162
|
#callbackRefreshAuth = null;
|
|
17163
|
+
#customRefreshAuth = null;
|
|
17087
17164
|
#authOptions;
|
|
17088
17165
|
#oAuthSecret;
|
|
17089
17166
|
#authExpires = 0;
|
|
@@ -17127,24 +17204,32 @@ ${this.stack}`;
|
|
|
17127
17204
|
*/
|
|
17128
17205
|
async refreshAuth() {
|
|
17129
17206
|
try {
|
|
17130
|
-
|
|
17131
|
-
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
|
|
17136
|
-
|
|
17137
|
-
|
|
17207
|
+
let payload = void 0;
|
|
17208
|
+
if (this.#customRefreshAuth) {
|
|
17209
|
+
payload = await this.#customRefreshAuth();
|
|
17210
|
+
} else {
|
|
17211
|
+
const response = await this.#clientAxios.get(
|
|
17212
|
+
"/oauth/token/",
|
|
17213
|
+
{
|
|
17214
|
+
params: {
|
|
17215
|
+
grant_type: "refresh_token",
|
|
17216
|
+
client_id: this.#oAuthSecret.clientId,
|
|
17217
|
+
client_secret: this.#oAuthSecret.clientSecret,
|
|
17218
|
+
refresh_token: this.#authOptions.refreshToken
|
|
17219
|
+
}
|
|
17138
17220
|
}
|
|
17221
|
+
);
|
|
17222
|
+
if (response.data.error) {
|
|
17223
|
+
throw new Error(`Token update error: ${response.data.error}`);
|
|
17139
17224
|
}
|
|
17140
|
-
|
|
17141
|
-
|
|
17142
|
-
|
|
17225
|
+
if (response.status !== 200) {
|
|
17226
|
+
throw new Error(`Token update error status code: ${response.status}`);
|
|
17227
|
+
}
|
|
17228
|
+
payload = response.data;
|
|
17143
17229
|
}
|
|
17144
|
-
if (
|
|
17145
|
-
throw new Error(
|
|
17230
|
+
if (!payload) {
|
|
17231
|
+
throw new Error("Unable to obtain authorization update data");
|
|
17146
17232
|
}
|
|
17147
|
-
const payload = response.data;
|
|
17148
17233
|
this.#authOptions.accessToken = payload.access_token;
|
|
17149
17234
|
this.#authOptions.refreshToken = payload.refresh_token;
|
|
17150
17235
|
this.#authOptions.expires = Number.parseInt(payload.expires || "0");
|
|
@@ -17195,6 +17280,12 @@ ${this.stack}`;
|
|
|
17195
17280
|
removeCallbackRefreshAuth() {
|
|
17196
17281
|
this.#callbackRefreshAuth = null;
|
|
17197
17282
|
}
|
|
17283
|
+
setCustomRefreshAuth(cb) {
|
|
17284
|
+
this.#customRefreshAuth = cb;
|
|
17285
|
+
}
|
|
17286
|
+
removeCustomRefreshAuth() {
|
|
17287
|
+
this.#customRefreshAuth = null;
|
|
17288
|
+
}
|
|
17198
17289
|
// endregion ////
|
|
17199
17290
|
getUniq(prefix) {
|
|
17200
17291
|
return [prefix, this.#authOptions.memberId || ""].join("_");
|
|
@@ -17274,6 +17365,21 @@ ${this.stack}`;
|
|
|
17274
17365
|
this._ensureInitialized();
|
|
17275
17366
|
this.#authOAuthManager.removeCallbackRefreshAuth();
|
|
17276
17367
|
}
|
|
17368
|
+
/**
|
|
17369
|
+
* Sets an asynchronous function for custom get new refresh token
|
|
17370
|
+
* @param cb
|
|
17371
|
+
*/
|
|
17372
|
+
setCustomRefreshAuth(cb) {
|
|
17373
|
+
this._ensureInitialized();
|
|
17374
|
+
this.#authOAuthManager.setCustomRefreshAuth(cb);
|
|
17375
|
+
}
|
|
17376
|
+
/**
|
|
17377
|
+
* Removes function for custom get new refresh token
|
|
17378
|
+
*/
|
|
17379
|
+
removeCustomRefreshAuth() {
|
|
17380
|
+
this._ensureInitialized();
|
|
17381
|
+
this.#authOAuthManager.removeCustomRefreshAuth();
|
|
17382
|
+
}
|
|
17277
17383
|
// endregion ////
|
|
17278
17384
|
// region Core ////
|
|
17279
17385
|
/**
|