@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.
package/dist/umd/index.js CHANGED
@@ -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
@@ -14230,7 +14230,7 @@ ${this.stack}`;
14230
14230
  #clientSideWarningMessage = "";
14231
14231
  constructor(baseURL, authActions, options) {
14232
14232
  const defaultHeaders = {
14233
- // 'X-Sdk': 'b24-js-sdk-v-0.4.3'
14233
+ // 'X-Sdk': 'b24-js-sdk-v-0.4.4'
14234
14234
  };
14235
14235
  this.#clientAxios = axios.create({
14236
14236
  baseURL,
@@ -14658,7 +14658,7 @@ ${this.stack}`;
14658
14658
  const baseUrl = `${encodeURIComponent(method)}.json`;
14659
14659
  const queryParams = new URLSearchParams({
14660
14660
  [this.#requestIdGenerator.getQueryStringParameterName()]: this.#requestIdGenerator.getRequestId(),
14661
- [this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.3",
14661
+ [this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.4",
14662
14662
  [this.#requestIdGenerator.getQueryStringSdkTypeParameterName()]: "b24-js-sdk"
14663
14663
  });
14664
14664
  return `${baseUrl}?${queryParams.toString()}`;
@@ -15798,6 +15798,35 @@ ${this.stack}`;
15798
15798
  }
15799
15799
  // endregion ////
15800
15800
  // region Tools ////
15801
+ static fromWebhookUrl(url) {
15802
+ if (!url.trim()) {
15803
+ throw new Error("Webhook URL cannot be empty");
15804
+ }
15805
+ let parsedUrl;
15806
+ try {
15807
+ parsedUrl = new URL(url);
15808
+ } catch {
15809
+ throw new Error(`Invalid webhook URL format: ${url}`);
15810
+ }
15811
+ if (parsedUrl.protocol !== "https:") {
15812
+ throw new Error("Webhook requires HTTPS protocol");
15813
+ }
15814
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
15815
+ if (pathParts.length < 3 || pathParts[0] !== "rest") {
15816
+ throw new Error("Webhook URL must follow format: /rest/<userId>/<secret>");
15817
+ }
15818
+ const userIdStr = pathParts[1];
15819
+ const secret = pathParts[2];
15820
+ if (!/^\d+$/.test(userIdStr)) {
15821
+ throw new Error(`User ID must be numeric in webhook URL, received: ${userIdStr}`);
15822
+ }
15823
+ const userId = Number.parseInt(userIdStr, 10);
15824
+ return new B24Hook({
15825
+ b24Url: parsedUrl.origin,
15826
+ userId,
15827
+ secret
15828
+ });
15829
+ }
15801
15830
  // endregion ////
15802
15831
  }
15803
15832