@bitrix24/b24jssdk 0.4.1 → 0.4.2
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 +110 -1
- package/dist/esm/index.d.ts +110 -1
- package/dist/esm/index.mjs +172 -81
- package/dist/esm/index.mjs.map +1 -1
- package/dist/umd/index.js +173 -80
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +16 -16
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.d.mts
CHANGED
|
@@ -630,6 +630,67 @@ type B24FrameQueryParams = {
|
|
|
630
630
|
LANG: string | null | undefined;
|
|
631
631
|
APP_SID: string | null | undefined;
|
|
632
632
|
};
|
|
633
|
+
/**
|
|
634
|
+
* Parameters for application for OAuth
|
|
635
|
+
*/
|
|
636
|
+
type B24OAuthSecret = {
|
|
637
|
+
clientId: string;
|
|
638
|
+
clientSecret: string;
|
|
639
|
+
};
|
|
640
|
+
/**
|
|
641
|
+
* Parameters for OAuth
|
|
642
|
+
* @memo We get from b24 event this data
|
|
643
|
+
*/
|
|
644
|
+
interface B24OAuthParams {
|
|
645
|
+
/**
|
|
646
|
+
* @example '1xxxxx1694'
|
|
647
|
+
*/
|
|
648
|
+
applicationToken: string;
|
|
649
|
+
/**
|
|
650
|
+
* @example 1
|
|
651
|
+
*/
|
|
652
|
+
userId: number;
|
|
653
|
+
/**
|
|
654
|
+
* @example '3xx2030386cyy1b'
|
|
655
|
+
*/
|
|
656
|
+
memberId: string;
|
|
657
|
+
/**
|
|
658
|
+
* @example '1xxxxx1694'
|
|
659
|
+
*/
|
|
660
|
+
accessToken: string;
|
|
661
|
+
/**
|
|
662
|
+
* @example '0xxxx4e000011e700000001000000260dc83b47c40e9b5fd501093674c4f5'
|
|
663
|
+
*/
|
|
664
|
+
refreshToken: string;
|
|
665
|
+
/**
|
|
666
|
+
* @example 1745997853
|
|
667
|
+
*/
|
|
668
|
+
expires: number;
|
|
669
|
+
/**
|
|
670
|
+
* @example 3600
|
|
671
|
+
*/
|
|
672
|
+
expiresIn: number;
|
|
673
|
+
/**
|
|
674
|
+
* @example 'crm,catalog,bizproc,placement,user_brief'
|
|
675
|
+
*/
|
|
676
|
+
scope: string;
|
|
677
|
+
/**
|
|
678
|
+
* @example 'xxx.bitrix24.com'
|
|
679
|
+
*/
|
|
680
|
+
domain: string;
|
|
681
|
+
/**
|
|
682
|
+
* @example 'https://xxx.bitrix24.com/rest/'
|
|
683
|
+
*/
|
|
684
|
+
clientEndpoint: string;
|
|
685
|
+
/**
|
|
686
|
+
* @example 'https://oauth.bitrix.info/rest/'
|
|
687
|
+
*/
|
|
688
|
+
serverEndpoint: string;
|
|
689
|
+
/**
|
|
690
|
+
* @example 'L'
|
|
691
|
+
*/
|
|
692
|
+
status: string;
|
|
693
|
+
}
|
|
633
694
|
/**
|
|
634
695
|
* Parameters passed from the parent window when calling refreshAuth
|
|
635
696
|
*/
|
|
@@ -2598,6 +2659,54 @@ declare class AuthManager implements AuthActions {
|
|
|
2598
2659
|
get isAdmin(): boolean;
|
|
2599
2660
|
}
|
|
2600
2661
|
|
|
2662
|
+
/**
|
|
2663
|
+
* B24.OAuth Manager
|
|
2664
|
+
* @todo add docs
|
|
2665
|
+
* @todo add link
|
|
2666
|
+
*/
|
|
2667
|
+
|
|
2668
|
+
declare class B24OAuth extends AbstractB24 implements TypeB24 {
|
|
2669
|
+
#private;
|
|
2670
|
+
constructor(authOptions: B24OAuthParams, oAuthSecret: B24OAuthSecret);
|
|
2671
|
+
initIsAdmin(): Promise<void>;
|
|
2672
|
+
setLogger(logger: LoggerBrowser): void;
|
|
2673
|
+
get auth(): AuthActions;
|
|
2674
|
+
getTargetOrigin(): string;
|
|
2675
|
+
getTargetOriginWithPath(): string;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
/**
|
|
2679
|
+
* OAuth Authorization Manager
|
|
2680
|
+
*/
|
|
2681
|
+
|
|
2682
|
+
declare class AuthOAuthManager implements AuthActions {
|
|
2683
|
+
#private;
|
|
2684
|
+
constructor(b24OAuthParams: B24OAuthParams, oAuthSecret: B24OAuthSecret);
|
|
2685
|
+
/**
|
|
2686
|
+
* Returns authorization data
|
|
2687
|
+
* @see Http.#prepareParams
|
|
2688
|
+
*/
|
|
2689
|
+
getAuthData(): false | AuthData;
|
|
2690
|
+
/**
|
|
2691
|
+
* Updates authorization data
|
|
2692
|
+
*/
|
|
2693
|
+
refreshAuth(): Promise<AuthData>;
|
|
2694
|
+
getUniq(prefix: string): string;
|
|
2695
|
+
/**
|
|
2696
|
+
* Get the account address BX24 ( https://name.bitrix24.com )
|
|
2697
|
+
*/
|
|
2698
|
+
getTargetOrigin(): string;
|
|
2699
|
+
/**
|
|
2700
|
+
* Get the account address BX24 with Path ( https://name.bitrix24.com/rest )
|
|
2701
|
+
*/
|
|
2702
|
+
getTargetOriginWithPath(): string;
|
|
2703
|
+
/**
|
|
2704
|
+
* Determines whether the current user has administrator rights
|
|
2705
|
+
*/
|
|
2706
|
+
get isAdmin(): boolean;
|
|
2707
|
+
initIsAdmin(http: TypeHttp): Promise<void>;
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2601
2710
|
declare abstract class AbstractHelper {
|
|
2602
2711
|
protected _b24: TypeB24;
|
|
2603
2712
|
protected _logger: null | LoggerBrowser;
|
|
@@ -3206,4 +3315,4 @@ declare class PullClient implements ConnectorParent {
|
|
|
3206
3315
|
|
|
3207
3316
|
declare function initializeB24Frame(): Promise<B24Frame>;
|
|
3208
3317
|
|
|
3209
|
-
export { AbstractB24, AjaxError, type AjaxErrorParams, type AjaxQuery, AjaxResult, type AjaxResultParams, type AnswerError, AppFrame, type AuthActions, type AuthData, AuthHookManager, AuthManager, B24Frame, type B24FrameQueryParams, B24Hook, type B24HookParams, B24LangList, PullClient as B24PullClientManager, type BatchPayload, type BoolString, Browser, type CatalogCatalog, type CatalogExtra, type CatalogLanguage, type CatalogMeasure, type CatalogPriceType, type CatalogPriceTypeLang, type CatalogProduct, type CatalogProductImage, CatalogProductImageType, type CatalogProductOffer, type CatalogProductService, type CatalogProductSku, CatalogProductType, type CatalogRatio, type CatalogRoundingRule, CatalogRoundingRuleType, type CatalogSection, type CatalogStore, type CatalogVat, CloseReasons, type CommandHandlerFunctionV1, type CommandHandlerFunctionV2, ConnectionType, type ConnectorCallbacks, type ConnectorConfig, type ConnectorParent, type CrmItemDelivery, type CrmItemPayment, type CrmItemProductRow, type Currency, type CurrencyFormat, DataType, DialogManager, EnumAppStatus, EnumCrmEntityType, EnumCrmEntityTypeId, EnumCrmEntityTypeShort, type Fields, type GenderString, type GetPayload, type IPlacementUF, type IRequestIdGenerator, type IResult, type ISODate, type JsonRpcRequest, type ListPayload, ListRpcError, LoadDataType, LoggerBrowser, LoggerType, LsKeys, MessageCommands, type MessageInitData, MessageManager, type MultiField, type MultiFieldArray, type NumberString, OptionsManager$1 as OptionsManager, ParentManager, type Payload, type PayloadTime, PlacementManager, type PlacementViewMode, ProductRowDiscountTypeId, PullStatus, type RefreshAuthData, RestrictionManagerParamsBase, RestrictionManagerParamsForEnterprise, Result, type RpcCommand, type RpcCommandResult, type RpcError, RpcMethod, type RpcRequest, type SelectCRMParams, type SelectCRMParamsEntityType, type SelectCRMParamsValue, type SelectedAccess, type SelectedCRM, type SelectedCRMEntity, type SelectedUser, type SendParams, SenderType, ServerMode, type SharedConfigCallbacks, type SharedConfigParams, SliderManager, type StatusClose, StatusDescriptions, type StorageManagerParams, SubscriptionType, SystemCommands, Text, type TextType, Type, type TypeApp, type TypeB24, type TypeB24Form, type TypeChanel, type TypeChannelManagerParams, type TypeConnector, type TypeDescriptionError, type TypeEnumAppStatus, type TypeHttp, type TypeJsonRpcConfig, type TypeLicense, TypeOption, type TypePayment, type TypePublicIdDescriptor, type TypePullClientConfig, type TypePullClientEmitConfig, type TypePullClientMessageBatch, type TypePullClientMessageBody, type TypePullClientParams, type TypePullClientSession, type TypePullMessage, type TypeRestrictionManagerParams, type TypeRpcResponseAwaiters, type TypeSessionEvent, TypeSpecificUrl, type TypeStorageManager, type TypeSubscriptionCommandHandler, type TypeSubscriptionOptions, type TypeUser, type UserBasic, type UserBrief, type UserFieldType, type UserStatusCallback, initializeB24Frame, isArrayOfArray, omit, pick, useB24Helper, useFormatter };
|
|
3318
|
+
export { AbstractB24, AjaxError, type AjaxErrorParams, type AjaxQuery, AjaxResult, type AjaxResultParams, type AnswerError, AppFrame, type AuthActions, type AuthData, AuthHookManager, AuthManager, AuthOAuthManager, B24Frame, type B24FrameQueryParams, B24Hook, type B24HookParams, B24LangList, B24OAuth, type B24OAuthParams, type B24OAuthSecret, PullClient as B24PullClientManager, type BatchPayload, type BoolString, Browser, type CatalogCatalog, type CatalogExtra, type CatalogLanguage, type CatalogMeasure, type CatalogPriceType, type CatalogPriceTypeLang, type CatalogProduct, type CatalogProductImage, CatalogProductImageType, type CatalogProductOffer, type CatalogProductService, type CatalogProductSku, CatalogProductType, type CatalogRatio, type CatalogRoundingRule, CatalogRoundingRuleType, type CatalogSection, type CatalogStore, type CatalogVat, CloseReasons, type CommandHandlerFunctionV1, type CommandHandlerFunctionV2, ConnectionType, type ConnectorCallbacks, type ConnectorConfig, type ConnectorParent, type CrmItemDelivery, type CrmItemPayment, type CrmItemProductRow, type Currency, type CurrencyFormat, DataType, DialogManager, EnumAppStatus, EnumCrmEntityType, EnumCrmEntityTypeId, EnumCrmEntityTypeShort, type Fields, type GenderString, type GetPayload, type IPlacementUF, type IRequestIdGenerator, type IResult, type ISODate, type JsonRpcRequest, type ListPayload, ListRpcError, LoadDataType, LoggerBrowser, LoggerType, LsKeys, MessageCommands, type MessageInitData, MessageManager, type MultiField, type MultiFieldArray, type NumberString, OptionsManager$1 as OptionsManager, ParentManager, type Payload, type PayloadTime, PlacementManager, type PlacementViewMode, ProductRowDiscountTypeId, PullStatus, type RefreshAuthData, RestrictionManagerParamsBase, RestrictionManagerParamsForEnterprise, Result, type RpcCommand, type RpcCommandResult, type RpcError, RpcMethod, type RpcRequest, type SelectCRMParams, type SelectCRMParamsEntityType, type SelectCRMParamsValue, type SelectedAccess, type SelectedCRM, type SelectedCRMEntity, type SelectedUser, type SendParams, SenderType, ServerMode, type SharedConfigCallbacks, type SharedConfigParams, SliderManager, type StatusClose, StatusDescriptions, type StorageManagerParams, SubscriptionType, SystemCommands, Text, type TextType, Type, type TypeApp, type TypeB24, type TypeB24Form, type TypeChanel, type TypeChannelManagerParams, type TypeConnector, type TypeDescriptionError, type TypeEnumAppStatus, type TypeHttp, type TypeJsonRpcConfig, type TypeLicense, TypeOption, type TypePayment, type TypePublicIdDescriptor, type TypePullClientConfig, type TypePullClientEmitConfig, type TypePullClientMessageBatch, type TypePullClientMessageBody, type TypePullClientParams, type TypePullClientSession, type TypePullMessage, type TypeRestrictionManagerParams, type TypeRpcResponseAwaiters, type TypeSessionEvent, TypeSpecificUrl, type TypeStorageManager, type TypeSubscriptionCommandHandler, type TypeSubscriptionOptions, type TypeUser, type UserBasic, type UserBrief, type UserFieldType, type UserStatusCallback, initializeB24Frame, isArrayOfArray, omit, pick, useB24Helper, useFormatter };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -630,6 +630,67 @@ type B24FrameQueryParams = {
|
|
|
630
630
|
LANG: string | null | undefined;
|
|
631
631
|
APP_SID: string | null | undefined;
|
|
632
632
|
};
|
|
633
|
+
/**
|
|
634
|
+
* Parameters for application for OAuth
|
|
635
|
+
*/
|
|
636
|
+
type B24OAuthSecret = {
|
|
637
|
+
clientId: string;
|
|
638
|
+
clientSecret: string;
|
|
639
|
+
};
|
|
640
|
+
/**
|
|
641
|
+
* Parameters for OAuth
|
|
642
|
+
* @memo We get from b24 event this data
|
|
643
|
+
*/
|
|
644
|
+
interface B24OAuthParams {
|
|
645
|
+
/**
|
|
646
|
+
* @example '1xxxxx1694'
|
|
647
|
+
*/
|
|
648
|
+
applicationToken: string;
|
|
649
|
+
/**
|
|
650
|
+
* @example 1
|
|
651
|
+
*/
|
|
652
|
+
userId: number;
|
|
653
|
+
/**
|
|
654
|
+
* @example '3xx2030386cyy1b'
|
|
655
|
+
*/
|
|
656
|
+
memberId: string;
|
|
657
|
+
/**
|
|
658
|
+
* @example '1xxxxx1694'
|
|
659
|
+
*/
|
|
660
|
+
accessToken: string;
|
|
661
|
+
/**
|
|
662
|
+
* @example '0xxxx4e000011e700000001000000260dc83b47c40e9b5fd501093674c4f5'
|
|
663
|
+
*/
|
|
664
|
+
refreshToken: string;
|
|
665
|
+
/**
|
|
666
|
+
* @example 1745997853
|
|
667
|
+
*/
|
|
668
|
+
expires: number;
|
|
669
|
+
/**
|
|
670
|
+
* @example 3600
|
|
671
|
+
*/
|
|
672
|
+
expiresIn: number;
|
|
673
|
+
/**
|
|
674
|
+
* @example 'crm,catalog,bizproc,placement,user_brief'
|
|
675
|
+
*/
|
|
676
|
+
scope: string;
|
|
677
|
+
/**
|
|
678
|
+
* @example 'xxx.bitrix24.com'
|
|
679
|
+
*/
|
|
680
|
+
domain: string;
|
|
681
|
+
/**
|
|
682
|
+
* @example 'https://xxx.bitrix24.com/rest/'
|
|
683
|
+
*/
|
|
684
|
+
clientEndpoint: string;
|
|
685
|
+
/**
|
|
686
|
+
* @example 'https://oauth.bitrix.info/rest/'
|
|
687
|
+
*/
|
|
688
|
+
serverEndpoint: string;
|
|
689
|
+
/**
|
|
690
|
+
* @example 'L'
|
|
691
|
+
*/
|
|
692
|
+
status: string;
|
|
693
|
+
}
|
|
633
694
|
/**
|
|
634
695
|
* Parameters passed from the parent window when calling refreshAuth
|
|
635
696
|
*/
|
|
@@ -2598,6 +2659,54 @@ declare class AuthManager implements AuthActions {
|
|
|
2598
2659
|
get isAdmin(): boolean;
|
|
2599
2660
|
}
|
|
2600
2661
|
|
|
2662
|
+
/**
|
|
2663
|
+
* B24.OAuth Manager
|
|
2664
|
+
* @todo add docs
|
|
2665
|
+
* @todo add link
|
|
2666
|
+
*/
|
|
2667
|
+
|
|
2668
|
+
declare class B24OAuth extends AbstractB24 implements TypeB24 {
|
|
2669
|
+
#private;
|
|
2670
|
+
constructor(authOptions: B24OAuthParams, oAuthSecret: B24OAuthSecret);
|
|
2671
|
+
initIsAdmin(): Promise<void>;
|
|
2672
|
+
setLogger(logger: LoggerBrowser): void;
|
|
2673
|
+
get auth(): AuthActions;
|
|
2674
|
+
getTargetOrigin(): string;
|
|
2675
|
+
getTargetOriginWithPath(): string;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
/**
|
|
2679
|
+
* OAuth Authorization Manager
|
|
2680
|
+
*/
|
|
2681
|
+
|
|
2682
|
+
declare class AuthOAuthManager implements AuthActions {
|
|
2683
|
+
#private;
|
|
2684
|
+
constructor(b24OAuthParams: B24OAuthParams, oAuthSecret: B24OAuthSecret);
|
|
2685
|
+
/**
|
|
2686
|
+
* Returns authorization data
|
|
2687
|
+
* @see Http.#prepareParams
|
|
2688
|
+
*/
|
|
2689
|
+
getAuthData(): false | AuthData;
|
|
2690
|
+
/**
|
|
2691
|
+
* Updates authorization data
|
|
2692
|
+
*/
|
|
2693
|
+
refreshAuth(): Promise<AuthData>;
|
|
2694
|
+
getUniq(prefix: string): string;
|
|
2695
|
+
/**
|
|
2696
|
+
* Get the account address BX24 ( https://name.bitrix24.com )
|
|
2697
|
+
*/
|
|
2698
|
+
getTargetOrigin(): string;
|
|
2699
|
+
/**
|
|
2700
|
+
* Get the account address BX24 with Path ( https://name.bitrix24.com/rest )
|
|
2701
|
+
*/
|
|
2702
|
+
getTargetOriginWithPath(): string;
|
|
2703
|
+
/**
|
|
2704
|
+
* Determines whether the current user has administrator rights
|
|
2705
|
+
*/
|
|
2706
|
+
get isAdmin(): boolean;
|
|
2707
|
+
initIsAdmin(http: TypeHttp): Promise<void>;
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2601
2710
|
declare abstract class AbstractHelper {
|
|
2602
2711
|
protected _b24: TypeB24;
|
|
2603
2712
|
protected _logger: null | LoggerBrowser;
|
|
@@ -3206,4 +3315,4 @@ declare class PullClient implements ConnectorParent {
|
|
|
3206
3315
|
|
|
3207
3316
|
declare function initializeB24Frame(): Promise<B24Frame>;
|
|
3208
3317
|
|
|
3209
|
-
export { AbstractB24, AjaxError, type AjaxErrorParams, type AjaxQuery, AjaxResult, type AjaxResultParams, type AnswerError, AppFrame, type AuthActions, type AuthData, AuthHookManager, AuthManager, B24Frame, type B24FrameQueryParams, B24Hook, type B24HookParams, B24LangList, PullClient as B24PullClientManager, type BatchPayload, type BoolString, Browser, type CatalogCatalog, type CatalogExtra, type CatalogLanguage, type CatalogMeasure, type CatalogPriceType, type CatalogPriceTypeLang, type CatalogProduct, type CatalogProductImage, CatalogProductImageType, type CatalogProductOffer, type CatalogProductService, type CatalogProductSku, CatalogProductType, type CatalogRatio, type CatalogRoundingRule, CatalogRoundingRuleType, type CatalogSection, type CatalogStore, type CatalogVat, CloseReasons, type CommandHandlerFunctionV1, type CommandHandlerFunctionV2, ConnectionType, type ConnectorCallbacks, type ConnectorConfig, type ConnectorParent, type CrmItemDelivery, type CrmItemPayment, type CrmItemProductRow, type Currency, type CurrencyFormat, DataType, DialogManager, EnumAppStatus, EnumCrmEntityType, EnumCrmEntityTypeId, EnumCrmEntityTypeShort, type Fields, type GenderString, type GetPayload, type IPlacementUF, type IRequestIdGenerator, type IResult, type ISODate, type JsonRpcRequest, type ListPayload, ListRpcError, LoadDataType, LoggerBrowser, LoggerType, LsKeys, MessageCommands, type MessageInitData, MessageManager, type MultiField, type MultiFieldArray, type NumberString, OptionsManager$1 as OptionsManager, ParentManager, type Payload, type PayloadTime, PlacementManager, type PlacementViewMode, ProductRowDiscountTypeId, PullStatus, type RefreshAuthData, RestrictionManagerParamsBase, RestrictionManagerParamsForEnterprise, Result, type RpcCommand, type RpcCommandResult, type RpcError, RpcMethod, type RpcRequest, type SelectCRMParams, type SelectCRMParamsEntityType, type SelectCRMParamsValue, type SelectedAccess, type SelectedCRM, type SelectedCRMEntity, type SelectedUser, type SendParams, SenderType, ServerMode, type SharedConfigCallbacks, type SharedConfigParams, SliderManager, type StatusClose, StatusDescriptions, type StorageManagerParams, SubscriptionType, SystemCommands, Text, type TextType, Type, type TypeApp, type TypeB24, type TypeB24Form, type TypeChanel, type TypeChannelManagerParams, type TypeConnector, type TypeDescriptionError, type TypeEnumAppStatus, type TypeHttp, type TypeJsonRpcConfig, type TypeLicense, TypeOption, type TypePayment, type TypePublicIdDescriptor, type TypePullClientConfig, type TypePullClientEmitConfig, type TypePullClientMessageBatch, type TypePullClientMessageBody, type TypePullClientParams, type TypePullClientSession, type TypePullMessage, type TypeRestrictionManagerParams, type TypeRpcResponseAwaiters, type TypeSessionEvent, TypeSpecificUrl, type TypeStorageManager, type TypeSubscriptionCommandHandler, type TypeSubscriptionOptions, type TypeUser, type UserBasic, type UserBrief, type UserFieldType, type UserStatusCallback, initializeB24Frame, isArrayOfArray, omit, pick, useB24Helper, useFormatter };
|
|
3318
|
+
export { AbstractB24, AjaxError, type AjaxErrorParams, type AjaxQuery, AjaxResult, type AjaxResultParams, type AnswerError, AppFrame, type AuthActions, type AuthData, AuthHookManager, AuthManager, AuthOAuthManager, B24Frame, type B24FrameQueryParams, B24Hook, type B24HookParams, B24LangList, B24OAuth, type B24OAuthParams, type B24OAuthSecret, PullClient as B24PullClientManager, type BatchPayload, type BoolString, Browser, type CatalogCatalog, type CatalogExtra, type CatalogLanguage, type CatalogMeasure, type CatalogPriceType, type CatalogPriceTypeLang, type CatalogProduct, type CatalogProductImage, CatalogProductImageType, type CatalogProductOffer, type CatalogProductService, type CatalogProductSku, CatalogProductType, type CatalogRatio, type CatalogRoundingRule, CatalogRoundingRuleType, type CatalogSection, type CatalogStore, type CatalogVat, CloseReasons, type CommandHandlerFunctionV1, type CommandHandlerFunctionV2, ConnectionType, type ConnectorCallbacks, type ConnectorConfig, type ConnectorParent, type CrmItemDelivery, type CrmItemPayment, type CrmItemProductRow, type Currency, type CurrencyFormat, DataType, DialogManager, EnumAppStatus, EnumCrmEntityType, EnumCrmEntityTypeId, EnumCrmEntityTypeShort, type Fields, type GenderString, type GetPayload, type IPlacementUF, type IRequestIdGenerator, type IResult, type ISODate, type JsonRpcRequest, type ListPayload, ListRpcError, LoadDataType, LoggerBrowser, LoggerType, LsKeys, MessageCommands, type MessageInitData, MessageManager, type MultiField, type MultiFieldArray, type NumberString, OptionsManager$1 as OptionsManager, ParentManager, type Payload, type PayloadTime, PlacementManager, type PlacementViewMode, ProductRowDiscountTypeId, PullStatus, type RefreshAuthData, RestrictionManagerParamsBase, RestrictionManagerParamsForEnterprise, Result, type RpcCommand, type RpcCommandResult, type RpcError, RpcMethod, type RpcRequest, type SelectCRMParams, type SelectCRMParamsEntityType, type SelectCRMParamsValue, type SelectedAccess, type SelectedCRM, type SelectedCRMEntity, type SelectedUser, type SendParams, SenderType, ServerMode, type SharedConfigCallbacks, type SharedConfigParams, SliderManager, type StatusClose, StatusDescriptions, type StorageManagerParams, SubscriptionType, SystemCommands, Text, type TextType, Type, type TypeApp, type TypeB24, type TypeB24Form, type TypeChanel, type TypeChannelManagerParams, type TypeConnector, type TypeDescriptionError, type TypeEnumAppStatus, type TypeHttp, type TypeJsonRpcConfig, type TypeLicense, TypeOption, type TypePayment, type TypePublicIdDescriptor, type TypePullClientConfig, type TypePullClientEmitConfig, type TypePullClientMessageBatch, type TypePullClientMessageBody, type TypePullClientParams, type TypePullClientSession, type TypePullMessage, type TypeRestrictionManagerParams, type TypeRpcResponseAwaiters, type TypeSessionEvent, TypeSpecificUrl, type TypeStorageManager, type TypeSubscriptionCommandHandler, type TypeSubscriptionOptions, type TypeUser, type UserBasic, type UserBrief, type UserFieldType, type UserStatusCallback, initializeB24Frame, isArrayOfArray, omit, pick, useB24Helper, useFormatter };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @version @bitrix24/b24jssdk v0.4.
|
|
2
|
+
* @version @bitrix24/b24jssdk v0.4.2
|
|
3
3
|
* @copyright (c) 2025 Bitrix24
|
|
4
4
|
* @licence MIT
|
|
5
5
|
* @links https://github.com/bitrix24/b24jssdk - GitHub
|
|
@@ -507,89 +507,44 @@ function isArrayOfArray(item) {
|
|
|
507
507
|
return Array.isArray(item[0]);
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
-
const _state = {};
|
|
511
|
-
function getCrypto() {
|
|
512
|
-
if (typeof window !== "undefined" && window.crypto) {
|
|
513
|
-
return window.crypto;
|
|
514
|
-
}
|
|
515
|
-
if (typeof globalThis.crypto !== "undefined") {
|
|
516
|
-
return globalThis.crypto;
|
|
517
|
-
}
|
|
518
|
-
throw new Error("Crypto API not available");
|
|
519
|
-
}
|
|
520
|
-
function initRng() {
|
|
521
|
-
const crypto = getCrypto();
|
|
522
|
-
if (!crypto?.getRandomValues) {
|
|
523
|
-
throw new Error("Crypto API not available");
|
|
524
|
-
}
|
|
525
|
-
return {
|
|
526
|
-
rng: () => {
|
|
527
|
-
const rnds8 = new Uint8Array(16);
|
|
528
|
-
return crypto.getRandomValues(rnds8);
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
510
|
const byteToHex = [];
|
|
533
511
|
for (let i = 0; i < 256; ++i) {
|
|
534
512
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
535
513
|
}
|
|
536
|
-
function
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
function v7Bytes(randoms, msecs, seq, buf, offset = 0) {
|
|
551
|
-
if (!buf) {
|
|
552
|
-
buf = new Uint8Array(16);
|
|
553
|
-
offset = 0;
|
|
554
|
-
}
|
|
555
|
-
msecs ??= Date.now();
|
|
556
|
-
seq ??= randoms[6] * 127 << 24 | randoms[7] << 16 | randoms[8] << 8 | randoms[9];
|
|
557
|
-
buf[offset++] = msecs / 1099511627776 & 255;
|
|
558
|
-
buf[offset++] = msecs / 4294967296 & 255;
|
|
559
|
-
buf[offset++] = msecs / 16777216 & 255;
|
|
560
|
-
buf[offset++] = msecs / 65536 & 255;
|
|
561
|
-
buf[offset++] = msecs / 256 & 255;
|
|
562
|
-
buf[offset++] = msecs & 255;
|
|
563
|
-
buf[offset++] = 112 | seq >>> 28 & 15;
|
|
564
|
-
buf[offset++] = seq >>> 20 & 255;
|
|
565
|
-
buf[offset++] = 128 | seq >>> 14 & 63;
|
|
566
|
-
buf[offset++] = seq >>> 6 & 255;
|
|
567
|
-
buf[offset++] = seq << 2 & 255 | randoms[10] & 3;
|
|
568
|
-
buf[offset++] = randoms[11];
|
|
569
|
-
buf[offset++] = randoms[12];
|
|
570
|
-
buf[offset++] = randoms[13];
|
|
571
|
-
buf[offset++] = randoms[14];
|
|
572
|
-
buf[offset++] = randoms[15];
|
|
573
|
-
return buf;
|
|
574
|
-
}
|
|
575
|
-
function unsafeStringify(arr, offset = 0) {
|
|
576
|
-
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();
|
|
514
|
+
function sfc32(a, b, c, d) {
|
|
515
|
+
return () => {
|
|
516
|
+
a |= 0;
|
|
517
|
+
b |= 0;
|
|
518
|
+
c |= 0;
|
|
519
|
+
d |= 0;
|
|
520
|
+
const t = (a + b | 0) + d | 0;
|
|
521
|
+
d = d + 1 | 0;
|
|
522
|
+
a = b ^ b >>> 9;
|
|
523
|
+
b = c + (c << 3) | 0;
|
|
524
|
+
c = (c << 21 | c >>> 11) + t | 0;
|
|
525
|
+
return t >>> 0;
|
|
526
|
+
};
|
|
577
527
|
}
|
|
578
528
|
function uuidv7() {
|
|
579
|
-
const
|
|
580
|
-
const
|
|
581
|
-
const
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
);
|
|
592
|
-
|
|
529
|
+
const bytes = new Uint8Array(16);
|
|
530
|
+
const timestamp = BigInt(Date.now());
|
|
531
|
+
const perf = BigInt(Math.floor(performance.now() * 1e3) % 65535);
|
|
532
|
+
const combinedTime = timestamp << 16n | perf;
|
|
533
|
+
bytes[0] = Number(combinedTime >> 40n & 0xffn);
|
|
534
|
+
bytes[1] = Number(combinedTime >> 32n & 0xffn);
|
|
535
|
+
bytes[2] = Number(combinedTime >> 24n & 0xffn);
|
|
536
|
+
bytes[3] = Number(combinedTime >> 16n & 0xffn);
|
|
537
|
+
bytes[4] = Number(combinedTime >> 8n & 0xffn);
|
|
538
|
+
bytes[5] = Number(combinedTime & 0xffn);
|
|
539
|
+
const seed = (Math.random() * 4294967295 ^ Date.now() ^ performance.now()) >>> 0;
|
|
540
|
+
const rand = sfc32(2654435769, 608135816, 3084996962, seed);
|
|
541
|
+
const randView = new DataView(bytes.buffer);
|
|
542
|
+
randView.setUint32(6, rand());
|
|
543
|
+
randView.setUint32(10, rand());
|
|
544
|
+
randView.setUint16(14, rand());
|
|
545
|
+
bytes[6] = 112 | bytes[6] & 15;
|
|
546
|
+
bytes[8] = 128 | bytes[8] & 63;
|
|
547
|
+
return (byteToHex[bytes[0]] + byteToHex[bytes[1]] + byteToHex[bytes[2]] + byteToHex[bytes[3]] + "-" + byteToHex[bytes[4]] + byteToHex[bytes[5]] + "-" + byteToHex[bytes[6]] + byteToHex[bytes[7]] + "-" + byteToHex[bytes[8]] + byteToHex[bytes[9]] + "-" + byteToHex[bytes[10]] + byteToHex[bytes[11]] + byteToHex[bytes[12]] + byteToHex[bytes[13]] + byteToHex[bytes[14]] + byteToHex[bytes[15]]).toLowerCase();
|
|
593
548
|
}
|
|
594
549
|
|
|
595
550
|
const reEscape = /[&<>'"]/g;
|
|
@@ -1547,7 +1502,7 @@ class Http {
|
|
|
1547
1502
|
#clientSideWarningMessage = "";
|
|
1548
1503
|
constructor(baseURL, authActions, options) {
|
|
1549
1504
|
const defaultHeaders = {
|
|
1550
|
-
// 'X-Sdk': 'b24-js-sdk-v-0.4.
|
|
1505
|
+
// 'X-Sdk': 'b24-js-sdk-v-0.4.2'
|
|
1551
1506
|
};
|
|
1552
1507
|
this.#clientAxios = axios.create({
|
|
1553
1508
|
baseURL,
|
|
@@ -1975,7 +1930,7 @@ class Http {
|
|
|
1975
1930
|
const baseUrl = `${encodeURIComponent(method)}.json`;
|
|
1976
1931
|
const queryParams = new URLSearchParams({
|
|
1977
1932
|
[this.#requestIdGenerator.getQueryStringParameterName()]: this.#requestIdGenerator.getRequestId(),
|
|
1978
|
-
[this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.
|
|
1933
|
+
[this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.4.2",
|
|
1979
1934
|
[this.#requestIdGenerator.getQueryStringSdkTypeParameterName()]: "b24-js-sdk"
|
|
1980
1935
|
});
|
|
1981
1936
|
return `${baseUrl}?${queryParams.toString()}`;
|
|
@@ -4191,6 +4146,142 @@ class B24Frame extends AbstractB24 {
|
|
|
4191
4146
|
// endregion ////
|
|
4192
4147
|
}
|
|
4193
4148
|
|
|
4149
|
+
class AuthOAuthManager {
|
|
4150
|
+
#authOptions;
|
|
4151
|
+
#oAuthSecret;
|
|
4152
|
+
#authExpires = 0;
|
|
4153
|
+
#domain;
|
|
4154
|
+
#b24Target;
|
|
4155
|
+
#b24TargetRest;
|
|
4156
|
+
// 'https://oauth.bitrix.info' ////
|
|
4157
|
+
#oAuthTarget;
|
|
4158
|
+
#isAdmin = null;
|
|
4159
|
+
constructor(b24OAuthParams, oAuthSecret) {
|
|
4160
|
+
this.#authOptions = Object.assign({}, b24OAuthParams);
|
|
4161
|
+
this.#oAuthSecret = Object.freeze(Object.assign({}, oAuthSecret));
|
|
4162
|
+
this.#domain = this.#authOptions.domain.replaceAll("https://", "").replaceAll("http://", "").replace(/:(80|443)$/, "");
|
|
4163
|
+
this.#b24TargetRest = this.#authOptions.clientEndpoint;
|
|
4164
|
+
this.#b24Target = this.#b24TargetRest.replace("/rest", "");
|
|
4165
|
+
this.#oAuthTarget = this.#authOptions.serverEndpoint.replace("/rest/", "");
|
|
4166
|
+
this.#authExpires = this.#authOptions.expires * 1e3;
|
|
4167
|
+
}
|
|
4168
|
+
/**
|
|
4169
|
+
* Returns authorization data
|
|
4170
|
+
* @see Http.#prepareParams
|
|
4171
|
+
*/
|
|
4172
|
+
getAuthData() {
|
|
4173
|
+
return this.#authExpires > Date.now() ? {
|
|
4174
|
+
access_token: this.#authOptions.accessToken,
|
|
4175
|
+
refresh_token: this.#authOptions.refreshToken,
|
|
4176
|
+
expires_in: this.#authOptions.expiresIn,
|
|
4177
|
+
domain: this.#domain,
|
|
4178
|
+
member_id: this.#authOptions.memberId
|
|
4179
|
+
} : false;
|
|
4180
|
+
}
|
|
4181
|
+
/**
|
|
4182
|
+
* Updates authorization data
|
|
4183
|
+
*/
|
|
4184
|
+
async refreshAuth() {
|
|
4185
|
+
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({
|
|
4192
|
+
params: {
|
|
4193
|
+
client_id: this.#oAuthSecret.clientId,
|
|
4194
|
+
grant_type: "refresh_token",
|
|
4195
|
+
client_secret: this.#oAuthSecret.clientSecret,
|
|
4196
|
+
refresh_token: this.#authOptions.refreshToken
|
|
4197
|
+
}
|
|
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;
|
|
4210
|
+
} catch (error) {
|
|
4211
|
+
throw new Error(`Token update error: ${error instanceof Error ? error.message : error}`);
|
|
4212
|
+
}
|
|
4213
|
+
return this.getAuthData();
|
|
4214
|
+
}
|
|
4215
|
+
getUniq(prefix) {
|
|
4216
|
+
return [prefix, this.#authOptions.memberId || ""].join("_");
|
|
4217
|
+
}
|
|
4218
|
+
/**
|
|
4219
|
+
* Get the account address BX24 ( https://name.bitrix24.com )
|
|
4220
|
+
*/
|
|
4221
|
+
getTargetOrigin() {
|
|
4222
|
+
return `${this.#b24Target}`;
|
|
4223
|
+
}
|
|
4224
|
+
/**
|
|
4225
|
+
* Get the account address BX24 with Path ( https://name.bitrix24.com/rest )
|
|
4226
|
+
*/
|
|
4227
|
+
getTargetOriginWithPath() {
|
|
4228
|
+
return `${this.#b24TargetRest}`;
|
|
4229
|
+
}
|
|
4230
|
+
/**
|
|
4231
|
+
* Determines whether the current user has administrator rights
|
|
4232
|
+
*/
|
|
4233
|
+
get isAdmin() {
|
|
4234
|
+
if (null === this.#isAdmin) {
|
|
4235
|
+
throw new Error("isAdmin not init. You need call B24OAuth::initIsAdmin().");
|
|
4236
|
+
}
|
|
4237
|
+
return this.#isAdmin;
|
|
4238
|
+
}
|
|
4239
|
+
async initIsAdmin(http) {
|
|
4240
|
+
const response = await http.call("profile", {}, 0);
|
|
4241
|
+
if (!response.isSuccess) {
|
|
4242
|
+
throw new Error(response.getErrorMessages().join(";"));
|
|
4243
|
+
}
|
|
4244
|
+
const data = response.getData().result;
|
|
4245
|
+
if (data?.ADMIN) {
|
|
4246
|
+
this.#isAdmin = true;
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4250
|
+
|
|
4251
|
+
class B24OAuth extends AbstractB24 {
|
|
4252
|
+
#authOAuthManager;
|
|
4253
|
+
constructor(authOptions, oAuthSecret) {
|
|
4254
|
+
super();
|
|
4255
|
+
this.#authOAuthManager = new AuthOAuthManager(authOptions, oAuthSecret);
|
|
4256
|
+
this._http = new Http(
|
|
4257
|
+
this.#authOAuthManager.getTargetOriginWithPath(),
|
|
4258
|
+
this.#authOAuthManager,
|
|
4259
|
+
this._getHttpOptions()
|
|
4260
|
+
);
|
|
4261
|
+
this._isInit = true;
|
|
4262
|
+
}
|
|
4263
|
+
async initIsAdmin() {
|
|
4264
|
+
if (!this._http) {
|
|
4265
|
+
throw new Error("Http Not init");
|
|
4266
|
+
}
|
|
4267
|
+
return this.#authOAuthManager.initIsAdmin(this._http);
|
|
4268
|
+
}
|
|
4269
|
+
setLogger(logger) {
|
|
4270
|
+
super.setLogger(logger);
|
|
4271
|
+
}
|
|
4272
|
+
get auth() {
|
|
4273
|
+
return this.#authOAuthManager;
|
|
4274
|
+
}
|
|
4275
|
+
getTargetOrigin() {
|
|
4276
|
+
this._ensureInitialized();
|
|
4277
|
+
return this.#authOAuthManager.getTargetOrigin();
|
|
4278
|
+
}
|
|
4279
|
+
getTargetOriginWithPath() {
|
|
4280
|
+
this._ensureInitialized();
|
|
4281
|
+
return this.#authOAuthManager.getTargetOriginWithPath();
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
|
|
4194
4285
|
class UnhandledMatchError extends Error {
|
|
4195
4286
|
constructor(value, ...args) {
|
|
4196
4287
|
super(...args);
|
|
@@ -13655,5 +13746,5 @@ async function initializeB24Frame() {
|
|
|
13655
13746
|
});
|
|
13656
13747
|
}
|
|
13657
13748
|
|
|
13658
|
-
export { AbstractB24, AjaxError, AjaxResult, AppFrame, AuthHookManager, AuthManager, B24Frame, B24Hook, B24LangList, 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 };
|
|
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 };
|
|
13659
13750
|
//# sourceMappingURL=index.mjs.map
|