@bitrix24/b24jssdk 0.2.3 → 0.4.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/dist/esm/index.d.mts +3 -3
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.mjs +60 -21
- package/dist/esm/index.mjs.map +1 -1
- package/dist/umd/index.js +63 -32
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +13 -13
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +20 -19
- package/dist/commonjs/index.cjs +0 -13705
- package/dist/commonjs/index.cjs.map +0 -1
- package/dist/commonjs/index.d.cts +0 -3209
- package/dist/commonjs/index.d.mts +0 -3209
- package/dist/commonjs/index.d.ts +0 -3209
package/dist/esm/index.d.mts
CHANGED
|
@@ -2825,9 +2825,6 @@ declare class PullClient implements ConnectorParent {
|
|
|
2825
2825
|
private _debug;
|
|
2826
2826
|
private _connectionAttempt;
|
|
2827
2827
|
private _connectionType;
|
|
2828
|
-
private _reconnectTimeout;
|
|
2829
|
-
private _restartTimeout;
|
|
2830
|
-
private _restoreWebSocketTimeout;
|
|
2831
2828
|
private _skipStorageInit;
|
|
2832
2829
|
private _skipCheckRevision;
|
|
2833
2830
|
private _subscribers;
|
|
@@ -2846,6 +2843,9 @@ declare class PullClient implements ConnectorParent {
|
|
|
2846
2843
|
/**
|
|
2847
2844
|
* @depricate
|
|
2848
2845
|
*/
|
|
2846
|
+
private _reconnectTimeout;
|
|
2847
|
+
private _restartTimeout;
|
|
2848
|
+
private _restoreWebSocketTimeout;
|
|
2849
2849
|
private _checkInterval;
|
|
2850
2850
|
private _offlineTimeout;
|
|
2851
2851
|
private _watchUpdateTimeout;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2825,9 +2825,6 @@ declare class PullClient implements ConnectorParent {
|
|
|
2825
2825
|
private _debug;
|
|
2826
2826
|
private _connectionAttempt;
|
|
2827
2827
|
private _connectionType;
|
|
2828
|
-
private _reconnectTimeout;
|
|
2829
|
-
private _restartTimeout;
|
|
2830
|
-
private _restoreWebSocketTimeout;
|
|
2831
2828
|
private _skipStorageInit;
|
|
2832
2829
|
private _skipCheckRevision;
|
|
2833
2830
|
private _subscribers;
|
|
@@ -2846,6 +2843,9 @@ declare class PullClient implements ConnectorParent {
|
|
|
2846
2843
|
/**
|
|
2847
2844
|
* @depricate
|
|
2848
2845
|
*/
|
|
2846
|
+
private _reconnectTimeout;
|
|
2847
|
+
private _restartTimeout;
|
|
2848
|
+
private _restoreWebSocketTimeout;
|
|
2849
2849
|
private _checkInterval;
|
|
2850
2850
|
private _offlineTimeout;
|
|
2851
2851
|
private _watchUpdateTimeout;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @version @bitrix24/b24jssdk v0.
|
|
2
|
+
* @version @bitrix24/b24jssdk v0.4.0
|
|
3
3
|
* @copyright (c) 2025 Bitrix24
|
|
4
4
|
* @licence MIT
|
|
5
5
|
* @links https://github.com/bitrix24/b24jssdk - GitHub
|
|
6
6
|
* @links https://bitrix24.github.io/b24jssdk/ - Documentation
|
|
7
7
|
*/
|
|
8
8
|
import { DateTime } from 'luxon';
|
|
9
|
+
import { randomFillSync } from 'node:crypto';
|
|
9
10
|
import axios, { AxiosError } from 'axios';
|
|
10
11
|
import * as qs from 'qs-esm';
|
|
11
12
|
|
|
@@ -508,8 +509,36 @@ function isArrayOfArray(item) {
|
|
|
508
509
|
}
|
|
509
510
|
|
|
510
511
|
const _state = {};
|
|
511
|
-
|
|
512
|
-
|
|
512
|
+
const isBrowser = typeof window !== "undefined";
|
|
513
|
+
function initRng() {
|
|
514
|
+
try {
|
|
515
|
+
const rnds8Pool = new Uint8Array(256);
|
|
516
|
+
let poolPtr = rnds8Pool.length;
|
|
517
|
+
return {
|
|
518
|
+
rng: () => {
|
|
519
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
|
520
|
+
randomFillSync(rnds8Pool);
|
|
521
|
+
poolPtr = 0;
|
|
522
|
+
}
|
|
523
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
} catch {
|
|
527
|
+
throw new Error("Node.js crypto module not available");
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
function initRngBrowser() {
|
|
531
|
+
const crypto = window.crypto || window.msCrypto;
|
|
532
|
+
if (!crypto?.getRandomValues) {
|
|
533
|
+
throw new Error("Web Crypto API not available");
|
|
534
|
+
}
|
|
535
|
+
return {
|
|
536
|
+
rng: () => {
|
|
537
|
+
const rnds8 = new Uint8Array(16);
|
|
538
|
+
return crypto.getRandomValues(rnds8);
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
}
|
|
513
542
|
const byteToHex = [];
|
|
514
543
|
for (let i = 0; i < 256; ++i) {
|
|
515
544
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
@@ -556,17 +585,19 @@ function v7Bytes(randoms, msecs, seq, buf, offset = 0) {
|
|
|
556
585
|
function unsafeStringify(arr, offset = 0) {
|
|
557
586
|
return (byteToHex[arr[offset]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
558
587
|
}
|
|
559
|
-
function
|
|
588
|
+
function uuidv7Node() {
|
|
560
589
|
const buf = void 0;
|
|
561
590
|
const offset = void 0;
|
|
591
|
+
let rngFunction;
|
|
562
592
|
const now = Date.now();
|
|
563
|
-
if (
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
593
|
+
if (isBrowser) {
|
|
594
|
+
const { rng } = initRngBrowser();
|
|
595
|
+
rngFunction = rng;
|
|
596
|
+
} else {
|
|
597
|
+
const { rng } = initRng();
|
|
598
|
+
rngFunction = rng;
|
|
568
599
|
}
|
|
569
|
-
const randoms =
|
|
600
|
+
const randoms = rngFunction();
|
|
570
601
|
updateV7State(_state, now, randoms);
|
|
571
602
|
const bytes = v7Bytes(
|
|
572
603
|
randoms,
|
|
@@ -618,7 +649,7 @@ class TextManager {
|
|
|
618
649
|
* @return {string}
|
|
619
650
|
*/
|
|
620
651
|
getUuidRfc4122() {
|
|
621
|
-
return
|
|
652
|
+
return uuidv7Node();
|
|
622
653
|
}
|
|
623
654
|
/**
|
|
624
655
|
* Encodes all unsafe entities
|
|
@@ -1498,13 +1529,17 @@ class RestrictionManager {
|
|
|
1498
1529
|
|
|
1499
1530
|
const DEFAULT_REQUEST_ID_HEADER_FIELD_NAME = "X-Request-ID";
|
|
1500
1531
|
const DEFAULT_QUERY_STRING_PARAMETER_NAME = "bx24_request_id";
|
|
1501
|
-
const
|
|
1532
|
+
const DEFAULT_QUERY_STRING_SDK_VER_PARAMETER_NAME = "bx24_sdk_ver";
|
|
1533
|
+
const DEFAULT_QUERY_STRING_SDK_TYPE_PARAMETER_NAME = "bx24_sdk_type";
|
|
1502
1534
|
class DefaultRequestIdGenerator {
|
|
1503
1535
|
getQueryStringParameterName() {
|
|
1504
1536
|
return DEFAULT_QUERY_STRING_PARAMETER_NAME;
|
|
1505
1537
|
}
|
|
1506
1538
|
getQueryStringSdkParameterName() {
|
|
1507
|
-
return
|
|
1539
|
+
return DEFAULT_QUERY_STRING_SDK_VER_PARAMETER_NAME;
|
|
1540
|
+
}
|
|
1541
|
+
getQueryStringSdkTypeParameterName() {
|
|
1542
|
+
return DEFAULT_QUERY_STRING_SDK_TYPE_PARAMETER_NAME;
|
|
1508
1543
|
}
|
|
1509
1544
|
generate() {
|
|
1510
1545
|
return Text.getUuidRfc4122();
|
|
@@ -1529,7 +1564,7 @@ class Http {
|
|
|
1529
1564
|
#clientSideWarningMessage = "";
|
|
1530
1565
|
constructor(baseURL, authActions, options) {
|
|
1531
1566
|
const defaultHeaders = {
|
|
1532
|
-
// 'X-Sdk': 'b24-js-sdk-v-0.
|
|
1567
|
+
// 'X-Sdk': 'b24-js-sdk-v-0.4.0'
|
|
1533
1568
|
};
|
|
1534
1569
|
this.#clientAxios = axios.create({
|
|
1535
1570
|
baseURL,
|
|
@@ -1938,8 +1973,6 @@ class Http {
|
|
|
1938
1973
|
if (this.#logTag.length > 0) {
|
|
1939
1974
|
result.logTag = this.#logTag;
|
|
1940
1975
|
}
|
|
1941
|
-
result[this.#requestIdGenerator.getQueryStringParameterName()] = this.#requestIdGenerator.getRequestId();
|
|
1942
|
-
result[this.#requestIdGenerator.getQueryStringSdkParameterName()] = "0.2.3";
|
|
1943
1976
|
if (!!result.data && !!result.data.start) {
|
|
1944
1977
|
delete result.data.start;
|
|
1945
1978
|
}
|
|
@@ -1956,7 +1989,13 @@ class Http {
|
|
|
1956
1989
|
* @private
|
|
1957
1990
|
*/
|
|
1958
1991
|
#prepareMethod(method) {
|
|
1959
|
-
|
|
1992
|
+
const baseUrl = `${encodeURIComponent(method)}.json`;
|
|
1993
|
+
const queryParams = new URLSearchParams({
|
|
1994
|
+
[this.#requestIdGenerator.getQueryStringParameterName()]: this.#requestIdGenerator.getRequestId(),
|
|
1995
|
+
[this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.0",
|
|
1996
|
+
[this.#requestIdGenerator.getQueryStringSdkTypeParameterName()]: "b24-js-sdk"
|
|
1997
|
+
});
|
|
1998
|
+
return `${baseUrl}?${queryParams.toString()}`;
|
|
1960
1999
|
}
|
|
1961
2000
|
/**
|
|
1962
2001
|
* @inheritDoc
|
|
@@ -11073,9 +11112,6 @@ class PullClient {
|
|
|
11073
11112
|
_debug = false;
|
|
11074
11113
|
_connectionAttempt = 0;
|
|
11075
11114
|
_connectionType = ConnectionType.WebSocket;
|
|
11076
|
-
_reconnectTimeout = null;
|
|
11077
|
-
_restartTimeout = null;
|
|
11078
|
-
_restoreWebSocketTimeout = null;
|
|
11079
11115
|
_skipStorageInit;
|
|
11080
11116
|
_skipCheckRevision;
|
|
11081
11117
|
_subscribers = {};
|
|
@@ -11107,6 +11143,9 @@ class PullClient {
|
|
|
11107
11143
|
*/
|
|
11108
11144
|
// private _notificationPopup: null = null
|
|
11109
11145
|
// timers ////
|
|
11146
|
+
_reconnectTimeout = null;
|
|
11147
|
+
_restartTimeout = null;
|
|
11148
|
+
_restoreWebSocketTimeout = null;
|
|
11110
11149
|
_checkInterval = null;
|
|
11111
11150
|
_offlineTimeout = null;
|
|
11112
11151
|
_watchUpdateTimeout = null;
|
|
@@ -12402,7 +12441,7 @@ class PullClient {
|
|
|
12402
12441
|
return;
|
|
12403
12442
|
}
|
|
12404
12443
|
this._restoreWebSocketTimeout = setTimeout(() => {
|
|
12405
|
-
this._restoreWebSocketTimeout =
|
|
12444
|
+
this._restoreWebSocketTimeout = null;
|
|
12406
12445
|
this.restoreWebSocketConnection();
|
|
12407
12446
|
}, RESTORE_WEBSOCKET_TIMEOUT * 1e3);
|
|
12408
12447
|
}
|