@bitrix24/b24jssdk 0.4.3 → 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.
@@ -1572,8 +1572,18 @@ interface EventOnAppInstallHandlerParams extends EventHandlerParams {
1572
1572
  * @todo fix this application_token
1573
1573
  * @see https://apidocs.bitrix24.com/api-reference/events/safe-event-handlers.html
1574
1574
  */
1575
- interface EventOnAppUnInstallHandlerParams extends EventHandlerParams {
1575
+ interface EventOnAppUnInstallHandlerParams {
1576
+ event: string;
1577
+ event_handler_id: string;
1578
+ ts: string;
1576
1579
  [key: string]: any;
1580
+ auth: {
1581
+ domain: string;
1582
+ client_endpoint: string;
1583
+ server_endpoint: string;
1584
+ member_id: string;
1585
+ application_token: string;
1586
+ };
1577
1587
  }
1578
1588
 
1579
1589
  type TypePullMessage = {
@@ -2207,6 +2217,7 @@ declare class B24Hook extends AbstractB24 implements TypeB24 {
2207
2217
  * Get the account address BX24 with Path ( https://name.bitrix24.com/rest/1/xxxxx )
2208
2218
  */
2209
2219
  getTargetOriginWithPath(): string;
2220
+ static fromWebhookUrl(url: string): B24Hook;
2210
2221
  }
2211
2222
 
2212
2223
  /**
@@ -1572,8 +1572,18 @@ interface EventOnAppInstallHandlerParams extends EventHandlerParams {
1572
1572
  * @todo fix this application_token
1573
1573
  * @see https://apidocs.bitrix24.com/api-reference/events/safe-event-handlers.html
1574
1574
  */
1575
- interface EventOnAppUnInstallHandlerParams extends EventHandlerParams {
1575
+ interface EventOnAppUnInstallHandlerParams {
1576
+ event: string;
1577
+ event_handler_id: string;
1578
+ ts: string;
1576
1579
  [key: string]: any;
1580
+ auth: {
1581
+ domain: string;
1582
+ client_endpoint: string;
1583
+ server_endpoint: string;
1584
+ member_id: string;
1585
+ application_token: string;
1586
+ };
1577
1587
  }
1578
1588
 
1579
1589
  type TypePullMessage = {
@@ -2207,6 +2217,7 @@ declare class B24Hook extends AbstractB24 implements TypeB24 {
2207
2217
  * Get the account address BX24 with Path ( https://name.bitrix24.com/rest/1/xxxxx )
2208
2218
  */
2209
2219
  getTargetOriginWithPath(): string;
2220
+ static fromWebhookUrl(url: string): B24Hook;
2210
2221
  }
2211
2222
 
2212
2223
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @version @bitrix24/b24jssdk v0.4.3
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
@@ -1678,7 +1678,7 @@ class Http {
1678
1678
  #clientSideWarningMessage = "";
1679
1679
  constructor(baseURL, authActions, options) {
1680
1680
  const defaultHeaders = {
1681
- // 'X-Sdk': 'b24-js-sdk-v-0.4.3'
1681
+ // 'X-Sdk': 'b24-js-sdk-v-0.4.4'
1682
1682
  };
1683
1683
  this.#clientAxios = axios.create({
1684
1684
  baseURL,
@@ -2106,7 +2106,7 @@ class Http {
2106
2106
  const baseUrl = `${encodeURIComponent(method)}.json`;
2107
2107
  const queryParams = new URLSearchParams({
2108
2108
  [this.#requestIdGenerator.getQueryStringParameterName()]: this.#requestIdGenerator.getRequestId(),
2109
- [this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.3",
2109
+ [this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.4",
2110
2110
  [this.#requestIdGenerator.getQueryStringSdkTypeParameterName()]: "b24-js-sdk"
2111
2111
  });
2112
2112
  return `${baseUrl}?${queryParams.toString()}`;
@@ -3246,6 +3246,35 @@ class B24Hook extends AbstractB24 {
3246
3246
  }
3247
3247
  // endregion ////
3248
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
+ }
3249
3278
  // endregion ////
3250
3279
  }
3251
3280