@bitrix24/b24jssdk 0.4.2 → 0.4.4

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @version @bitrix24/b24jssdk v0.4.2
2
+ * @version @bitrix24/b24jssdk v0.4.4
3
3
  * @copyright (c) 2025 Bitrix24
4
4
  * @licence MIT
5
5
  * @links https://github.com/bitrix24/b24jssdk - GitHub
@@ -506,6 +506,9 @@ function omit(data, keys) {
506
506
  function isArrayOfArray(item) {
507
507
  return Array.isArray(item[0]);
508
508
  }
509
+ function getEnumValue(enumObj, value) {
510
+ return Object.values(enumObj).includes(value) ? value : void 0;
511
+ }
509
512
 
510
513
  const byteToHex = [];
511
514
  for (let i = 0; i < 256; ++i) {
@@ -913,6 +916,10 @@ var EnumCrmEntityTypeShort = /* @__PURE__ */ ((EnumCrmEntityTypeShort2) => {
913
916
  EnumCrmEntityTypeShort2["order"] = "O";
914
917
  return EnumCrmEntityTypeShort2;
915
918
  })(EnumCrmEntityTypeShort || {});
919
+ function getEnumCrmEntityTypeShort(id) {
920
+ const key = EnumCrmEntityTypeId[id];
921
+ return EnumCrmEntityTypeShort[key] || "?" /* undefined */;
922
+ }
916
923
 
917
924
  var ProductRowDiscountTypeId = /* @__PURE__ */ ((ProductRowDiscountTypeId2) => {
918
925
  ProductRowDiscountTypeId2[ProductRowDiscountTypeId2["undefined"] = 0] = "undefined";
@@ -946,6 +953,175 @@ var CatalogRoundingRuleType = /* @__PURE__ */ ((CatalogRoundingRuleType2) => {
946
953
  return CatalogRoundingRuleType2;
947
954
  })(CatalogRoundingRuleType || {});
948
955
 
956
+ var EnumBitrix24Edition = /* @__PURE__ */ ((EnumBitrix24Edition2) => {
957
+ EnumBitrix24Edition2["undefined"] = "undefined";
958
+ EnumBitrix24Edition2["b24"] = "b24";
959
+ EnumBitrix24Edition2["box"] = "box";
960
+ return EnumBitrix24Edition2;
961
+ })(EnumBitrix24Edition || {});
962
+ var EnumBizprocBaseType = /* @__PURE__ */ ((EnumBizprocBaseType2) => {
963
+ EnumBizprocBaseType2["undefined"] = "undefined";
964
+ EnumBizprocBaseType2["crm"] = "crm";
965
+ EnumBizprocBaseType2["disk"] = "disk";
966
+ EnumBizprocBaseType2["lists"] = "lists";
967
+ return EnumBizprocBaseType2;
968
+ })(EnumBizprocBaseType || {});
969
+ var EnumBizprocDocumentType = /* @__PURE__ */ ((EnumBizprocDocumentType2) => {
970
+ EnumBizprocDocumentType2["undefined"] = "undefined";
971
+ EnumBizprocDocumentType2["lead"] = "CCrmDocumentLead";
972
+ EnumBizprocDocumentType2["company"] = "CCrmDocumentCompany";
973
+ EnumBizprocDocumentType2["contact"] = "CCrmDocumentContact";
974
+ EnumBizprocDocumentType2["deal"] = "CCrmDocumentDeal";
975
+ EnumBizprocDocumentType2["invoice"] = "Bitrix\\Crm\\Integration\\BizProc\\Document\\SmartInvoice";
976
+ EnumBizprocDocumentType2["quote"] = "Bitrix\\Crm\\Integration\\BizProc\\Document\\Quote";
977
+ EnumBizprocDocumentType2["order"] = "Bitrix\\Crm\\Integration\\BizProc\\Document\\Order";
978
+ EnumBizprocDocumentType2["dynamic"] = "Bitrix\\Crm\\Integration\\BizProc\\Document\\Dynamic";
979
+ EnumBizprocDocumentType2["disk"] = "Bitrix\\Disk\\BizProcDocument";
980
+ EnumBizprocDocumentType2["lists"] = "BizprocDocument";
981
+ EnumBizprocDocumentType2["listsList"] = "Bitrix\\Lists\\BizprocDocumentLists";
982
+ return EnumBizprocDocumentType2;
983
+ })(EnumBizprocDocumentType || {});
984
+ function convertBizprocDocumentTypeToCrmEntityTypeId(documentType) {
985
+ switch (documentType) {
986
+ case "CCrmDocumentLead" /* lead */:
987
+ return EnumCrmEntityTypeId.lead;
988
+ case "CCrmDocumentCompany" /* company */:
989
+ return EnumCrmEntityTypeId.company;
990
+ case "CCrmDocumentContact" /* contact */:
991
+ return EnumCrmEntityTypeId.contact;
992
+ case "CCrmDocumentDeal" /* deal */:
993
+ return EnumCrmEntityTypeId.deal;
994
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\SmartInvoice" /* invoice */:
995
+ return EnumCrmEntityTypeId.invoice;
996
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\Quote" /* quote */:
997
+ return EnumCrmEntityTypeId.quote;
998
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\Order" /* order */:
999
+ return EnumCrmEntityTypeId.order;
1000
+ }
1001
+ return EnumCrmEntityTypeId.undefined;
1002
+ }
1003
+ function getDocumentType(documentType, entityId) {
1004
+ let entityIdFormatted = "";
1005
+ let base = "undefined" /* undefined */;
1006
+ switch (documentType) {
1007
+ case "CCrmDocumentLead" /* lead */:
1008
+ base = "crm" /* crm */;
1009
+ entityIdFormatted = "LEAD";
1010
+ break;
1011
+ case "CCrmDocumentCompany" /* company */:
1012
+ base = "crm" /* crm */;
1013
+ entityIdFormatted = "COMPANY";
1014
+ break;
1015
+ case "CCrmDocumentContact" /* contact */:
1016
+ base = "crm" /* crm */;
1017
+ entityIdFormatted = "CONTACT";
1018
+ break;
1019
+ case "CCrmDocumentDeal" /* deal */:
1020
+ base = "crm" /* crm */;
1021
+ entityIdFormatted = "DEAL";
1022
+ break;
1023
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\SmartInvoice" /* invoice */:
1024
+ base = "crm" /* crm */;
1025
+ entityIdFormatted = "SMART_INVOICE";
1026
+ break;
1027
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\Quote" /* quote */:
1028
+ base = "crm" /* crm */;
1029
+ entityIdFormatted = "QUOTE";
1030
+ break;
1031
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\Order" /* order */:
1032
+ base = "crm" /* crm */;
1033
+ entityIdFormatted = "ORDER";
1034
+ break;
1035
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\Dynamic" /* dynamic */:
1036
+ base = "crm" /* crm */;
1037
+ entityIdFormatted = `DYNAMIC_${entityId || 0}`;
1038
+ if ((entityId || 0) < 1) {
1039
+ throw new Error("Need set entityId");
1040
+ }
1041
+ break;
1042
+ case "Bitrix\\Disk\\BizProcDocument" /* disk */:
1043
+ base = "disk" /* disk */;
1044
+ entityIdFormatted = `STORAGE_${entityId || 0}`;
1045
+ if ((entityId || 0) < 1) {
1046
+ throw new Error("Need set entityId");
1047
+ }
1048
+ break;
1049
+ case "BizprocDocument" /* lists */:
1050
+ base = "lists" /* lists */;
1051
+ entityIdFormatted = `iblock_${entityId || 0}`;
1052
+ if ((entityId || 0) < 1) {
1053
+ throw new Error("Need set entityId");
1054
+ }
1055
+ break;
1056
+ case "Bitrix\\Lists\\BizprocDocumentLists" /* listsList */:
1057
+ base = "lists" /* lists */;
1058
+ entityIdFormatted = `iblock_${entityId || 0}`;
1059
+ if ((entityId || 0) < 1) {
1060
+ throw new Error("Need set entityId");
1061
+ }
1062
+ break;
1063
+ }
1064
+ return [
1065
+ base,
1066
+ documentType,
1067
+ entityIdFormatted
1068
+ ];
1069
+ }
1070
+ function getDocumentId(documentType, id, dynamicId) {
1071
+ let entityIdFormatted = "";
1072
+ const tmp = getDocumentType(documentType, 1);
1073
+ switch (documentType) {
1074
+ case "CCrmDocumentLead" /* lead */:
1075
+ entityIdFormatted = `LEAD_${id}`;
1076
+ break;
1077
+ case "CCrmDocumentCompany" /* company */:
1078
+ entityIdFormatted = `COMPANY_${id}`;
1079
+ break;
1080
+ case "CCrmDocumentContact" /* contact */:
1081
+ entityIdFormatted = `CONTACT_${id}`;
1082
+ break;
1083
+ case "CCrmDocumentDeal" /* deal */:
1084
+ entityIdFormatted = `DEAL_${id}`;
1085
+ break;
1086
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\SmartInvoice" /* invoice */:
1087
+ entityIdFormatted = `SMART_INVOICE_${id}`;
1088
+ break;
1089
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\Quote" /* quote */:
1090
+ entityIdFormatted = `QUOTE_${id}`;
1091
+ break;
1092
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\Order" /* order */:
1093
+ entityIdFormatted = `ORDER_${id}`;
1094
+ break;
1095
+ case "Bitrix\\Crm\\Integration\\BizProc\\Document\\Dynamic" /* dynamic */:
1096
+ entityIdFormatted = `DYNAMIC_${dynamicId || 0}_${id}`;
1097
+ if ((dynamicId || 0) < 1) {
1098
+ throw new Error("Need set dynamicId");
1099
+ }
1100
+ break;
1101
+ case "Bitrix\\Disk\\BizProcDocument" /* disk */:
1102
+ entityIdFormatted = `${id}`;
1103
+ break;
1104
+ case "BizprocDocument" /* lists */:
1105
+ entityIdFormatted = `${id}`;
1106
+ break;
1107
+ case "Bitrix\\Lists\\BizprocDocumentLists" /* listsList */:
1108
+ entityIdFormatted = `${id}`;
1109
+ break;
1110
+ }
1111
+ return [
1112
+ tmp[0],
1113
+ tmp[1],
1114
+ entityIdFormatted
1115
+ ];
1116
+ }
1117
+ function getDocumentTypeForFilter(documentType) {
1118
+ const result = getDocumentType(documentType, 1);
1119
+ return [
1120
+ result[0],
1121
+ result[1]
1122
+ ];
1123
+ }
1124
+
949
1125
  var LoadDataType = /* @__PURE__ */ ((LoadDataType2) => {
950
1126
  LoadDataType2["App"] = "app";
951
1127
  LoadDataType2["Profile"] = "profile";
@@ -1502,7 +1678,7 @@ class Http {
1502
1678
  #clientSideWarningMessage = "";
1503
1679
  constructor(baseURL, authActions, options) {
1504
1680
  const defaultHeaders = {
1505
- // 'X-Sdk': 'b24-js-sdk-v-0.4.2'
1681
+ // 'X-Sdk': 'b24-js-sdk-v-0.4.4'
1506
1682
  };
1507
1683
  this.#clientAxios = axios.create({
1508
1684
  baseURL,
@@ -1930,7 +2106,7 @@ class Http {
1930
2106
  const baseUrl = `${encodeURIComponent(method)}.json`;
1931
2107
  const queryParams = new URLSearchParams({
1932
2108
  [this.#requestIdGenerator.getQueryStringParameterName()]: this.#requestIdGenerator.getRequestId(),
1933
- [this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.2",
2109
+ [this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.4",
1934
2110
  [this.#requestIdGenerator.getQueryStringSdkTypeParameterName()]: "b24-js-sdk"
1935
2111
  });
1936
2112
  return `${baseUrl}?${queryParams.toString()}`;
@@ -2153,6 +2329,26 @@ var B24LangList = /* @__PURE__ */ ((B24LangList2) => {
2153
2329
  B24LangList2["ar"] = "ar";
2154
2330
  return B24LangList2;
2155
2331
  })(B24LangList || {});
2332
+ const B24LocaleMap = {
2333
+ ["en" /* en */]: "en-EN",
2334
+ ["de" /* de */]: "de-DE",
2335
+ ["la" /* la */]: "es-ES",
2336
+ ["br" /* br */]: "pt-BR",
2337
+ ["fr" /* fr */]: "fr-FR",
2338
+ ["it" /* it */]: "it-IT",
2339
+ ["pl" /* pl */]: "pl-PL",
2340
+ ["ru" /* ru */]: "ru-RU",
2341
+ ["ua" /* ua */]: "uk-UA",
2342
+ ["tr" /* tr */]: "tr-TR",
2343
+ ["sc" /* sc */]: "zh-CN",
2344
+ ["tc" /* tc */]: "zh-TW",
2345
+ ["ja" /* ja */]: "ja-JP",
2346
+ ["vn" /* vn */]: "vi-VN",
2347
+ ["id" /* id */]: "id-ID",
2348
+ ["ms" /* ms */]: "ms-MY",
2349
+ ["th" /* th */]: "th-TH",
2350
+ ["ar" /* ar */]: "ar-SA"
2351
+ };
2156
2352
 
2157
2353
  const useScrollSize = () => {
2158
2354
  return {
@@ -2950,20 +3146,25 @@ const useFormatter = () => {
2950
3146
 
2951
3147
  class AuthHookManager {
2952
3148
  #b24HookParams;
3149
+ #domain;
3150
+ #b24TargetRest;
3151
+ #b24Target;
2953
3152
  constructor(b24HookParams) {
2954
3153
  this.#b24HookParams = Object.freeze(Object.assign({}, b24HookParams));
3154
+ this.#domain = this.#b24HookParams.b24Url.replaceAll("https://", "").replaceAll("http://", "").replace(/:(80|443)$/, "");
3155
+ this.#b24TargetRest = `https://${this.#domain}/rest`;
3156
+ this.#b24Target = `https://${this.#domain}`;
2955
3157
  }
2956
3158
  /**
2957
3159
  * @see Http.#prepareParams
2958
3160
  */
2959
3161
  getAuthData() {
2960
- const domain = this.#b24HookParams.b24Url.replaceAll("https://", "").replaceAll("http://", "").replace(/:(80|443)$/, "");
2961
3162
  return {
2962
3163
  access_token: this.#b24HookParams.secret,
2963
3164
  refresh_token: "hook",
2964
3165
  expires_in: 0,
2965
- domain,
2966
- member_id: domain
3166
+ domain: this.#domain,
3167
+ member_id: this.#domain
2967
3168
  };
2968
3169
  }
2969
3170
  refreshAuth() {
@@ -2980,13 +3181,13 @@ class AuthHookManager {
2980
3181
  * Get the account address BX24 ( https://name.bitrix24.com )
2981
3182
  */
2982
3183
  getTargetOrigin() {
2983
- return `${this.#b24HookParams.b24Url}`;
3184
+ return `${this.#b24Target}`;
2984
3185
  }
2985
3186
  /**
2986
3187
  * Get the account address BX24 with Path ( https://name.bitrix24.com/rest/1/xxxxx )
2987
3188
  */
2988
3189
  getTargetOriginWithPath() {
2989
- return `${this.#b24HookParams.b24Url}/rest/${this.#b24HookParams.userId}/${this.#b24HookParams.secret}`;
3190
+ return `${this.#b24TargetRest}/${this.#b24HookParams.userId}/${this.#b24HookParams.secret}`;
2990
3191
  }
2991
3192
  /**
2992
3193
  * We believe that hooks are created only by the admin
@@ -3045,6 +3246,35 @@ class B24Hook extends AbstractB24 {
3045
3246
  }
3046
3247
  // endregion ////
3047
3248
  // region Tools ////
3249
+ static fromWebhookUrl(url) {
3250
+ if (!url.trim()) {
3251
+ throw new Error("Webhook URL cannot be empty");
3252
+ }
3253
+ let parsedUrl;
3254
+ try {
3255
+ parsedUrl = new URL(url);
3256
+ } catch {
3257
+ throw new Error(`Invalid webhook URL format: ${url}`);
3258
+ }
3259
+ if (parsedUrl.protocol !== "https:") {
3260
+ throw new Error("Webhook requires HTTPS protocol");
3261
+ }
3262
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
3263
+ if (pathParts.length < 3 || pathParts[0] !== "rest") {
3264
+ throw new Error("Webhook URL must follow format: /rest/<userId>/<secret>");
3265
+ }
3266
+ const userIdStr = pathParts[1];
3267
+ const secret = pathParts[2];
3268
+ if (!/^\d+$/.test(userIdStr)) {
3269
+ throw new Error(`User ID must be numeric in webhook URL, received: ${userIdStr}`);
3270
+ }
3271
+ const userId = Number.parseInt(userIdStr, 10);
3272
+ return new B24Hook({
3273
+ b24Url: parsedUrl.origin,
3274
+ userId,
3275
+ secret
3276
+ });
3277
+ }
3048
3278
  // endregion ////
3049
3279
  }
3050
3280
 
@@ -4146,13 +4376,18 @@ class B24Frame extends AbstractB24 {
4146
4376
  // endregion ////
4147
4377
  }
4148
4378
 
4379
+ class RefreshTokenError extends AjaxError {
4380
+ }
4381
+
4149
4382
  class AuthOAuthManager {
4383
+ #clientAxios;
4384
+ #callbackRefreshAuth = null;
4150
4385
  #authOptions;
4151
4386
  #oAuthSecret;
4152
4387
  #authExpires = 0;
4153
4388
  #domain;
4154
- #b24Target;
4155
4389
  #b24TargetRest;
4390
+ #b24Target;
4156
4391
  // 'https://oauth.bitrix.info' ////
4157
4392
  #oAuthTarget;
4158
4393
  #isAdmin = null;
@@ -4161,9 +4396,15 @@ class AuthOAuthManager {
4161
4396
  this.#oAuthSecret = Object.freeze(Object.assign({}, oAuthSecret));
4162
4397
  this.#domain = this.#authOptions.domain.replaceAll("https://", "").replaceAll("http://", "").replace(/:(80|443)$/, "");
4163
4398
  this.#b24TargetRest = this.#authOptions.clientEndpoint;
4164
- this.#b24Target = this.#b24TargetRest.replace("/rest", "");
4399
+ this.#b24Target = this.#b24TargetRest.replace("/rest/", "");
4165
4400
  this.#oAuthTarget = this.#authOptions.serverEndpoint.replace("/rest/", "");
4166
4401
  this.#authExpires = this.#authOptions.expires * 1e3;
4402
+ this.#clientAxios = axios.create({
4403
+ baseURL: this.#oAuthTarget,
4404
+ headers: {
4405
+ "Content-Type": "application/json"
4406
+ }
4407
+ });
4167
4408
  }
4168
4409
  /**
4169
4410
  * Returns authorization data
@@ -4178,40 +4419,81 @@ class AuthOAuthManager {
4178
4419
  member_id: this.#authOptions.memberId
4179
4420
  } : false;
4180
4421
  }
4422
+ // region RefreshAuth ////
4181
4423
  /**
4182
4424
  * Updates authorization data
4183
4425
  */
4184
4426
  async refreshAuth() {
4185
4427
  try {
4186
- const response = await fetch(`${this.#oAuthTarget}/oauth/token/`, {
4187
- method: "POST",
4188
- headers: {
4189
- "Content-Type": "application/json"
4190
- },
4191
- body: JSON.stringify({
4428
+ const response = await this.#clientAxios.get(
4429
+ "/oauth/token/",
4430
+ {
4192
4431
  params: {
4193
- client_id: this.#oAuthSecret.clientId,
4194
4432
  grant_type: "refresh_token",
4433
+ client_id: this.#oAuthSecret.clientId,
4195
4434
  client_secret: this.#oAuthSecret.clientSecret,
4196
4435
  refresh_token: this.#authOptions.refreshToken
4197
4436
  }
4198
- })
4199
- });
4200
- if (!response.ok) {
4201
- throw new Error(`Token update error: ${response.statusText}`);
4202
- }
4203
- const data = await response.json();
4204
- if (data.error) {
4205
- throw new Error(`Token update error: ${data.error}`);
4206
- }
4207
- this.#authOptions.accessToken = data.access_token;
4208
- this.#authOptions.refreshToken = data.refresh_token;
4209
- this.#authExpires = data.expires * 1e3;
4437
+ }
4438
+ );
4439
+ if (response.data.error) {
4440
+ throw new Error(`Token update error: ${response.data.error}`);
4441
+ }
4442
+ if (response.status !== 200) {
4443
+ throw new Error(`Token update error status code: ${response.status}`);
4444
+ }
4445
+ const payload = response.data;
4446
+ this.#authOptions.accessToken = payload.access_token;
4447
+ this.#authOptions.refreshToken = payload.refresh_token;
4448
+ this.#authOptions.expires = Number.parseInt(payload.expires || "0");
4449
+ this.#authOptions.expiresIn = Number.parseInt(payload.expires_in || "3600");
4450
+ this.#authOptions.clientEndpoint = payload.client_endpoint;
4451
+ this.#authOptions.serverEndpoint = payload.server_endpoint;
4452
+ this.#authOptions.scope = payload.scope;
4453
+ this.#authOptions.status = Object.values(EnumAppStatus).find((value) => value === payload.status) || EnumAppStatus.Free;
4454
+ this.#authExpires = this.#authOptions.expires * 1e3;
4455
+ const authData = this.getAuthData();
4456
+ if (this.#callbackRefreshAuth) {
4457
+ await this.#callbackRefreshAuth({ authData, b24OAuthParams: this.#authOptions });
4458
+ }
4459
+ return authData;
4210
4460
  } catch (error) {
4211
- throw new Error(`Token update error: ${error instanceof Error ? error.message : error}`);
4461
+ if (error instanceof AxiosError) {
4462
+ let answerError = {
4463
+ error: error?.code || 0,
4464
+ errorDescription: error?.message || ""
4465
+ };
4466
+ if (error.response && error.response.data && !Type.isUndefined(error.response.data.error)) {
4467
+ const response = error.response.data;
4468
+ answerError = {
4469
+ error: response.error,
4470
+ errorDescription: response.error_description
4471
+ };
4472
+ }
4473
+ throw new RefreshTokenError({
4474
+ code: String(answerError.error),
4475
+ description: answerError.errorDescription,
4476
+ status: error.response?.status || 0,
4477
+ requestInfo: {
4478
+ method: "/oauth/token/"
4479
+ }
4480
+ });
4481
+ } else if (error instanceof Error) {
4482
+ throw error;
4483
+ }
4484
+ throw new Error(
4485
+ `Strange error: ${error instanceof Error ? error.message : error}`,
4486
+ { cause: error }
4487
+ );
4212
4488
  }
4213
- return this.getAuthData();
4214
4489
  }
4490
+ setCallbackRefreshAuth(cb) {
4491
+ this.#callbackRefreshAuth = cb;
4492
+ }
4493
+ removeCallbackRefreshAuth() {
4494
+ this.#callbackRefreshAuth = null;
4495
+ }
4496
+ // endregion ////
4215
4497
  getUniq(prefix) {
4216
4498
  return [prefix, this.#authOptions.memberId || ""].join("_");
4217
4499
  }
@@ -4250,6 +4532,7 @@ class AuthOAuthManager {
4250
4532
 
4251
4533
  class B24OAuth extends AbstractB24 {
4252
4534
  #authOAuthManager;
4535
+ // region Init ////
4253
4536
  constructor(authOptions, oAuthSecret) {
4254
4537
  super();
4255
4538
  this.#authOAuthManager = new AuthOAuthManager(authOptions, oAuthSecret);
@@ -4258,28 +4541,67 @@ class B24OAuth extends AbstractB24 {
4258
4541
  this.#authOAuthManager,
4259
4542
  this._getHttpOptions()
4260
4543
  );
4544
+ this._http.setClientSideWarning(
4545
+ true,
4546
+ "It is not safe to use oauth requests on the client side"
4547
+ );
4261
4548
  this._isInit = true;
4262
4549
  }
4550
+ setLogger(logger) {
4551
+ super.setLogger(logger);
4552
+ }
4553
+ /**
4554
+ * Used to initialize information about the current user.
4555
+ */
4263
4556
  async initIsAdmin() {
4264
- if (!this._http) {
4265
- throw new Error("Http Not init");
4266
- }
4557
+ this._ensureInitialized();
4267
4558
  return this.#authOAuthManager.initIsAdmin(this._http);
4268
4559
  }
4269
- setLogger(logger) {
4270
- super.setLogger(logger);
4560
+ /**
4561
+ * Sets an asynchronous Callback to receive updated authorization data
4562
+ * @param cb
4563
+ */
4564
+ setCallbackRefreshAuth(cb) {
4565
+ this._ensureInitialized();
4566
+ this.#authOAuthManager.setCallbackRefreshAuth(cb);
4271
4567
  }
4568
+ /**
4569
+ * Removes Callback to receive updated authorization data
4570
+ */
4571
+ removeCallbackRefreshAuth() {
4572
+ this._ensureInitialized();
4573
+ this.#authOAuthManager.removeCallbackRefreshAuth();
4574
+ }
4575
+ // endregion ////
4576
+ // region Core ////
4577
+ /**
4578
+ * Disables warning about client-side query execution
4579
+ */
4580
+ offClientSideWarning() {
4581
+ this.getHttpClient().setClientSideWarning(false, "");
4582
+ }
4583
+ // endregion ////
4272
4584
  get auth() {
4273
4585
  return this.#authOAuthManager;
4274
4586
  }
4587
+ // region Get ////
4588
+ /**
4589
+ * Get the account address BX24 ( https://name.bitrix24.com )
4590
+ */
4275
4591
  getTargetOrigin() {
4276
4592
  this._ensureInitialized();
4277
4593
  return this.#authOAuthManager.getTargetOrigin();
4278
4594
  }
4595
+ /**
4596
+ * Get the account address BX24 with Path ( https://name.bitrix24.com/rest/1/xxxxx )
4597
+ */
4279
4598
  getTargetOriginWithPath() {
4280
4599
  this._ensureInitialized();
4281
4600
  return this.#authOAuthManager.getTargetOriginWithPath();
4282
4601
  }
4602
+ // endregion ////
4603
+ // region Tools ////
4604
+ // endregion ////
4283
4605
  }
4284
4606
 
4285
4607
  class UnhandledMatchError extends Error {
@@ -13746,5 +14068,5 @@ async function initializeB24Frame() {
13746
14068
  });
13747
14069
  }
13748
14070
 
13749
- export { AbstractB24, AjaxError, AjaxResult, AppFrame, AuthHookManager, AuthManager, AuthOAuthManager, B24Frame, B24Hook, B24LangList, B24OAuth, PullClient as B24PullClientManager, Browser, CatalogProductImageType, CatalogProductType, CatalogRoundingRuleType, CloseReasons, ConnectionType, DataType, DialogManager, EnumAppStatus, EnumCrmEntityType, EnumCrmEntityTypeId, EnumCrmEntityTypeShort, ListRpcError, LoadDataType, LoggerBrowser, LoggerType, LsKeys, MessageCommands, MessageManager, OptionsManager$1 as OptionsManager, ParentManager, PlacementManager, ProductRowDiscountTypeId, PullStatus, RestrictionManagerParamsBase, RestrictionManagerParamsForEnterprise, Result, RpcMethod, SenderType, ServerMode, SliderManager, StatusDescriptions, SubscriptionType, SystemCommands, Text, Type, TypeOption, TypeSpecificUrl, initializeB24Frame, isArrayOfArray, omit, pick, useB24Helper, useFormatter };
14071
+ export { AbstractB24, AjaxError, AjaxResult, AppFrame, AuthHookManager, AuthManager, AuthOAuthManager, B24Frame, B24Hook, B24LangList, B24LocaleMap, B24OAuth, PullClient as B24PullClientManager, Browser, CatalogProductImageType, CatalogProductType, CatalogRoundingRuleType, CloseReasons, ConnectionType, DataType, DialogManager, EnumAppStatus, EnumBitrix24Edition, EnumBizprocBaseType, EnumBizprocDocumentType, EnumCrmEntityType, EnumCrmEntityTypeId, EnumCrmEntityTypeShort, ListRpcError, LoadDataType, LoggerBrowser, LoggerType, LsKeys, MessageCommands, MessageManager, OptionsManager$1 as OptionsManager, ParentManager, PlacementManager, ProductRowDiscountTypeId, PullStatus, RestrictionManagerParamsBase, RestrictionManagerParamsForEnterprise, Result, RpcMethod, SenderType, ServerMode, SliderManager, StatusDescriptions, SubscriptionType, SystemCommands, Text, Type, TypeOption, TypeSpecificUrl, convertBizprocDocumentTypeToCrmEntityTypeId, getDocumentId, getDocumentType, getDocumentTypeForFilter, getEnumCrmEntityTypeShort, getEnumValue, initializeB24Frame, isArrayOfArray, omit, pick, useB24Helper, useFormatter };
13750
14072
  //# sourceMappingURL=index.mjs.map