@bitrix24/b24jssdk 0.4.9 → 0.5.1
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 +38 -21
- package/dist/esm/index.d.ts +38 -21
- package/dist/esm/index.mjs +60 -20
- package/dist/esm/index.mjs.map +1 -1
- package/dist/umd/index.js +340 -227
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.min.js +19 -19
- package/dist/umd/index.min.js.map +1 -1
- package/package.json +5 -5
package/dist/esm/index.d.mts
CHANGED
|
@@ -632,6 +632,26 @@ declare const RestrictionManagerParamsBase: TypeRestrictionManagerParams;
|
|
|
632
632
|
*/
|
|
633
633
|
declare const RestrictionManagerParamsForEnterprise: TypeRestrictionManagerParams;
|
|
634
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Special cases of data passed to handlers
|
|
637
|
+
* @todo add docs
|
|
638
|
+
*/
|
|
639
|
+
interface HandlerAuthParams {
|
|
640
|
+
access_token: string;
|
|
641
|
+
expires: string;
|
|
642
|
+
expires_in: string;
|
|
643
|
+
scope: string;
|
|
644
|
+
domain: string;
|
|
645
|
+
server_endpoint: string;
|
|
646
|
+
status: string;
|
|
647
|
+
client_endpoint: string;
|
|
648
|
+
member_id: string;
|
|
649
|
+
user_id: string;
|
|
650
|
+
refresh_token: string;
|
|
651
|
+
application_token: string;
|
|
652
|
+
}
|
|
653
|
+
type PayloadOAuthToken = Pick<HandlerAuthParams, 'access_token' | 'refresh_token' | 'expires' | 'expires_in' | 'client_endpoint' | 'server_endpoint' | 'member_id' | 'status' | 'user_id'>;
|
|
654
|
+
|
|
635
655
|
declare enum LoadDataType {
|
|
636
656
|
App = "app",
|
|
637
657
|
Profile = "profile",
|
|
@@ -864,6 +884,7 @@ interface B24OAuthParams {
|
|
|
864
884
|
status: typeof EnumAppStatus[keyof typeof EnumAppStatus];
|
|
865
885
|
issuer?: 'request' | 'store' | string;
|
|
866
886
|
}
|
|
887
|
+
type HandlerRefreshAuth = Pick<HandlerAuthParams, 'access_token' | 'refresh_token' | 'expires' | 'expires_in' | 'client_endpoint' | 'server_endpoint' | 'member_id' | 'scope' | 'status' | 'domain'>;
|
|
867
888
|
/**
|
|
868
889
|
* Callback called when OAuth authorization is updated
|
|
869
890
|
*/
|
|
@@ -871,6 +892,10 @@ type CallbackRefreshAuth = (params: {
|
|
|
871
892
|
authData: AuthData;
|
|
872
893
|
b24OAuthParams: B24OAuthParams;
|
|
873
894
|
}) => Promise<void>;
|
|
895
|
+
/**
|
|
896
|
+
* Use for custom get new refresh token for OAuth
|
|
897
|
+
*/
|
|
898
|
+
type CustomRefreshAuth = () => Promise<HandlerRefreshAuth>;
|
|
874
899
|
/**
|
|
875
900
|
* Parameters passed from the parent window when calling refreshAuth
|
|
876
901
|
*/
|
|
@@ -902,6 +927,7 @@ type MessageInitData = RefreshAuthData & {
|
|
|
902
927
|
type AuthData = {
|
|
903
928
|
access_token: string;
|
|
904
929
|
refresh_token: string;
|
|
930
|
+
expires: number;
|
|
905
931
|
expires_in: number;
|
|
906
932
|
domain: string;
|
|
907
933
|
member_id: string;
|
|
@@ -1069,26 +1095,6 @@ type StatusClose = {
|
|
|
1069
1095
|
isClose: boolean;
|
|
1070
1096
|
};
|
|
1071
1097
|
|
|
1072
|
-
/**
|
|
1073
|
-
* Special cases of data passed to handlers
|
|
1074
|
-
* @todo add docs
|
|
1075
|
-
*/
|
|
1076
|
-
interface HandlerAuthParams {
|
|
1077
|
-
access_token: string;
|
|
1078
|
-
expires: string;
|
|
1079
|
-
expires_in: string;
|
|
1080
|
-
scope: string;
|
|
1081
|
-
domain: string;
|
|
1082
|
-
server_endpoint: string;
|
|
1083
|
-
status: string;
|
|
1084
|
-
client_endpoint: string;
|
|
1085
|
-
member_id: string;
|
|
1086
|
-
user_id: string;
|
|
1087
|
-
refresh_token: string;
|
|
1088
|
-
application_token: string;
|
|
1089
|
-
}
|
|
1090
|
-
type PayloadOAuthToken = Pick<HandlerAuthParams, 'access_token' | 'refresh_token' | 'expires' | 'expires_in' | 'client_endpoint' | 'server_endpoint' | 'member_id' | 'status' | 'user_id'>;
|
|
1091
|
-
|
|
1092
1098
|
/**
|
|
1093
1099
|
* CRM Entity Types
|
|
1094
1100
|
* @link https://dev.1c-bitrix.ru/rest_help/crm/constants.php
|
|
@@ -2896,6 +2902,15 @@ declare class B24OAuth extends AbstractB24 implements TypeB24 {
|
|
|
2896
2902
|
* Removes Callback to receive updated authorization data
|
|
2897
2903
|
*/
|
|
2898
2904
|
removeCallbackRefreshAuth(): void;
|
|
2905
|
+
/**
|
|
2906
|
+
* Sets an asynchronous function for custom get new refresh token
|
|
2907
|
+
* @param cb
|
|
2908
|
+
*/
|
|
2909
|
+
setCustomRefreshAuth(cb: CustomRefreshAuth): void;
|
|
2910
|
+
/**
|
|
2911
|
+
* Removes function for custom get new refresh token
|
|
2912
|
+
*/
|
|
2913
|
+
removeCustomRefreshAuth(): void;
|
|
2899
2914
|
/**
|
|
2900
2915
|
* Disables warning about client-side query execution
|
|
2901
2916
|
*/
|
|
@@ -2925,6 +2940,8 @@ declare class AuthOAuthManager implements AuthActions {
|
|
|
2925
2940
|
refreshAuth(): Promise<AuthData>;
|
|
2926
2941
|
setCallbackRefreshAuth(cb: CallbackRefreshAuth): void;
|
|
2927
2942
|
removeCallbackRefreshAuth(): void;
|
|
2943
|
+
setCustomRefreshAuth(cb: CustomRefreshAuth): void;
|
|
2944
|
+
removeCustomRefreshAuth(): void;
|
|
2928
2945
|
getUniq(prefix: string): string;
|
|
2929
2946
|
/**
|
|
2930
2947
|
* Get the account address BX24 ( https://name.bitrix24.com )
|
|
@@ -3550,4 +3567,4 @@ declare class PullClient implements ConnectorParent {
|
|
|
3550
3567
|
declare function initializeB24Frame(): Promise<B24Frame>;
|
|
3551
3568
|
|
|
3552
3569
|
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$1 as Text, Type, TypeOption, TypeSpecificUrl, convertBizprocDocumentTypeToCrmEntityTypeId, getDocumentId, getDocumentType, getDocumentTypeForFilter, getEnumCrmEntityTypeShort, getEnumValue, initializeB24Frame, isArrayOfArray, omit, pick, useB24Helper, useFormatter };
|
|
3553
|
-
export type { ActivityConfig, ActivityHandlerParams, ActivityOrRobotConfig, ActivityProperty, ActivityPropertyType, AjaxErrorParams, AjaxQuery, AjaxResultParams, AnswerError, AuthActions, AuthData, B24FrameQueryParams, B24HookParams, B24OAuthParams, B24OAuthSecret, BatchPayload, BoolString, CallbackRefreshAuth, CatalogCatalog, CatalogExtra, CatalogLanguage, CatalogMeasure, CatalogPriceType, CatalogPriceTypeLang, CatalogProduct, CatalogProductImage, CatalogProductOffer, CatalogProductService, CatalogProductSku, CatalogRatio, CatalogRoundingRule, CatalogSection, CatalogStore, CatalogVat, CommandHandlerFunctionV1, CommandHandlerFunctionV2, ConnectorCallbacks, ConnectorConfig, ConnectorParent, CrmItemDelivery, CrmItemPayment, CrmItemProductRow, Currency, CurrencyFormat, EventHandlerParams, EventOnAppInstallHandlerParams, EventOnAppUnInstallHandlerParams, Fields, GenderString, GetPayload, HandlerAuthParams, IPlacementUF, IRequestIdGenerator, IResult, ISODate, JsonRpcRequest, ListPayload, MessageInitData, MultiField, MultiFieldArray, NumberString, Payload, PayloadOAuthToken, PayloadTime, PlacementViewMode, RefreshAuthData, RpcCommand, RpcCommandResult, RpcError, RpcRequest, SelectCRMParams, SelectCRMParamsEntityType, SelectCRMParamsValue, SelectedAccess, SelectedCRM, SelectedCRMEntity, SelectedUser, SendParams, SharedConfigCallbacks, SharedConfigParams, StatusClose, StorageManagerParams, TextType, TypeApp, TypeB24, TypeB24Form, TypeChanel, TypeChannelManagerParams, TypeConnector, TypeDescriptionError, TypeEnumAppStatus, TypeHttp, TypeJsonRpcConfig, TypeLicense, TypePayment, TypePublicIdDescriptor, TypePullClientConfig, TypePullClientEmitConfig, TypePullClientMessageBatch, TypePullClientMessageBody, TypePullClientParams, TypePullClientSession, TypePullMessage, TypeRestrictionManagerParams, TypeRpcResponseAwaiters, TypeSessionEvent, TypeStorageManager, TypeSubscriptionCommandHandler, TypeSubscriptionOptions, TypeUser, UserBasic, UserBrief, UserFieldType, UserStatusCallback };
|
|
3570
|
+
export type { ActivityConfig, ActivityHandlerParams, ActivityOrRobotConfig, ActivityProperty, ActivityPropertyType, AjaxErrorParams, AjaxQuery, AjaxResultParams, AnswerError, AuthActions, AuthData, B24FrameQueryParams, B24HookParams, B24OAuthParams, B24OAuthSecret, BatchPayload, BoolString, CallbackRefreshAuth, CatalogCatalog, CatalogExtra, CatalogLanguage, CatalogMeasure, CatalogPriceType, CatalogPriceTypeLang, CatalogProduct, CatalogProductImage, CatalogProductOffer, CatalogProductService, CatalogProductSku, CatalogRatio, CatalogRoundingRule, CatalogSection, CatalogStore, CatalogVat, CommandHandlerFunctionV1, CommandHandlerFunctionV2, ConnectorCallbacks, ConnectorConfig, ConnectorParent, CrmItemDelivery, CrmItemPayment, CrmItemProductRow, Currency, CurrencyFormat, CustomRefreshAuth, EventHandlerParams, EventOnAppInstallHandlerParams, EventOnAppUnInstallHandlerParams, Fields, GenderString, GetPayload, HandlerAuthParams, HandlerRefreshAuth, IPlacementUF, IRequestIdGenerator, IResult, ISODate, JsonRpcRequest, ListPayload, MessageInitData, MultiField, MultiFieldArray, NumberString, Payload, PayloadOAuthToken, PayloadTime, PlacementViewMode, RefreshAuthData, RpcCommand, RpcCommandResult, RpcError, RpcRequest, SelectCRMParams, SelectCRMParamsEntityType, SelectCRMParamsValue, SelectedAccess, SelectedCRM, SelectedCRMEntity, SelectedUser, SendParams, SharedConfigCallbacks, SharedConfigParams, StatusClose, StorageManagerParams, TextType, TypeApp, TypeB24, TypeB24Form, TypeChanel, TypeChannelManagerParams, TypeConnector, TypeDescriptionError, TypeEnumAppStatus, TypeHttp, TypeJsonRpcConfig, TypeLicense, TypePayment, TypePublicIdDescriptor, TypePullClientConfig, TypePullClientEmitConfig, TypePullClientMessageBatch, TypePullClientMessageBody, TypePullClientParams, TypePullClientSession, TypePullMessage, TypeRestrictionManagerParams, TypeRpcResponseAwaiters, TypeSessionEvent, TypeStorageManager, TypeSubscriptionCommandHandler, TypeSubscriptionOptions, TypeUser, UserBasic, UserBrief, UserFieldType, UserStatusCallback };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -632,6 +632,26 @@ declare const RestrictionManagerParamsBase: TypeRestrictionManagerParams;
|
|
|
632
632
|
*/
|
|
633
633
|
declare const RestrictionManagerParamsForEnterprise: TypeRestrictionManagerParams;
|
|
634
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Special cases of data passed to handlers
|
|
637
|
+
* @todo add docs
|
|
638
|
+
*/
|
|
639
|
+
interface HandlerAuthParams {
|
|
640
|
+
access_token: string;
|
|
641
|
+
expires: string;
|
|
642
|
+
expires_in: string;
|
|
643
|
+
scope: string;
|
|
644
|
+
domain: string;
|
|
645
|
+
server_endpoint: string;
|
|
646
|
+
status: string;
|
|
647
|
+
client_endpoint: string;
|
|
648
|
+
member_id: string;
|
|
649
|
+
user_id: string;
|
|
650
|
+
refresh_token: string;
|
|
651
|
+
application_token: string;
|
|
652
|
+
}
|
|
653
|
+
type PayloadOAuthToken = Pick<HandlerAuthParams, 'access_token' | 'refresh_token' | 'expires' | 'expires_in' | 'client_endpoint' | 'server_endpoint' | 'member_id' | 'status' | 'user_id'>;
|
|
654
|
+
|
|
635
655
|
declare enum LoadDataType {
|
|
636
656
|
App = "app",
|
|
637
657
|
Profile = "profile",
|
|
@@ -864,6 +884,7 @@ interface B24OAuthParams {
|
|
|
864
884
|
status: typeof EnumAppStatus[keyof typeof EnumAppStatus];
|
|
865
885
|
issuer?: 'request' | 'store' | string;
|
|
866
886
|
}
|
|
887
|
+
type HandlerRefreshAuth = Pick<HandlerAuthParams, 'access_token' | 'refresh_token' | 'expires' | 'expires_in' | 'client_endpoint' | 'server_endpoint' | 'member_id' | 'scope' | 'status' | 'domain'>;
|
|
867
888
|
/**
|
|
868
889
|
* Callback called when OAuth authorization is updated
|
|
869
890
|
*/
|
|
@@ -871,6 +892,10 @@ type CallbackRefreshAuth = (params: {
|
|
|
871
892
|
authData: AuthData;
|
|
872
893
|
b24OAuthParams: B24OAuthParams;
|
|
873
894
|
}) => Promise<void>;
|
|
895
|
+
/**
|
|
896
|
+
* Use for custom get new refresh token for OAuth
|
|
897
|
+
*/
|
|
898
|
+
type CustomRefreshAuth = () => Promise<HandlerRefreshAuth>;
|
|
874
899
|
/**
|
|
875
900
|
* Parameters passed from the parent window when calling refreshAuth
|
|
876
901
|
*/
|
|
@@ -902,6 +927,7 @@ type MessageInitData = RefreshAuthData & {
|
|
|
902
927
|
type AuthData = {
|
|
903
928
|
access_token: string;
|
|
904
929
|
refresh_token: string;
|
|
930
|
+
expires: number;
|
|
905
931
|
expires_in: number;
|
|
906
932
|
domain: string;
|
|
907
933
|
member_id: string;
|
|
@@ -1069,26 +1095,6 @@ type StatusClose = {
|
|
|
1069
1095
|
isClose: boolean;
|
|
1070
1096
|
};
|
|
1071
1097
|
|
|
1072
|
-
/**
|
|
1073
|
-
* Special cases of data passed to handlers
|
|
1074
|
-
* @todo add docs
|
|
1075
|
-
*/
|
|
1076
|
-
interface HandlerAuthParams {
|
|
1077
|
-
access_token: string;
|
|
1078
|
-
expires: string;
|
|
1079
|
-
expires_in: string;
|
|
1080
|
-
scope: string;
|
|
1081
|
-
domain: string;
|
|
1082
|
-
server_endpoint: string;
|
|
1083
|
-
status: string;
|
|
1084
|
-
client_endpoint: string;
|
|
1085
|
-
member_id: string;
|
|
1086
|
-
user_id: string;
|
|
1087
|
-
refresh_token: string;
|
|
1088
|
-
application_token: string;
|
|
1089
|
-
}
|
|
1090
|
-
type PayloadOAuthToken = Pick<HandlerAuthParams, 'access_token' | 'refresh_token' | 'expires' | 'expires_in' | 'client_endpoint' | 'server_endpoint' | 'member_id' | 'status' | 'user_id'>;
|
|
1091
|
-
|
|
1092
1098
|
/**
|
|
1093
1099
|
* CRM Entity Types
|
|
1094
1100
|
* @link https://dev.1c-bitrix.ru/rest_help/crm/constants.php
|
|
@@ -2896,6 +2902,15 @@ declare class B24OAuth extends AbstractB24 implements TypeB24 {
|
|
|
2896
2902
|
* Removes Callback to receive updated authorization data
|
|
2897
2903
|
*/
|
|
2898
2904
|
removeCallbackRefreshAuth(): void;
|
|
2905
|
+
/**
|
|
2906
|
+
* Sets an asynchronous function for custom get new refresh token
|
|
2907
|
+
* @param cb
|
|
2908
|
+
*/
|
|
2909
|
+
setCustomRefreshAuth(cb: CustomRefreshAuth): void;
|
|
2910
|
+
/**
|
|
2911
|
+
* Removes function for custom get new refresh token
|
|
2912
|
+
*/
|
|
2913
|
+
removeCustomRefreshAuth(): void;
|
|
2899
2914
|
/**
|
|
2900
2915
|
* Disables warning about client-side query execution
|
|
2901
2916
|
*/
|
|
@@ -2925,6 +2940,8 @@ declare class AuthOAuthManager implements AuthActions {
|
|
|
2925
2940
|
refreshAuth(): Promise<AuthData>;
|
|
2926
2941
|
setCallbackRefreshAuth(cb: CallbackRefreshAuth): void;
|
|
2927
2942
|
removeCallbackRefreshAuth(): void;
|
|
2943
|
+
setCustomRefreshAuth(cb: CustomRefreshAuth): void;
|
|
2944
|
+
removeCustomRefreshAuth(): void;
|
|
2928
2945
|
getUniq(prefix: string): string;
|
|
2929
2946
|
/**
|
|
2930
2947
|
* Get the account address BX24 ( https://name.bitrix24.com )
|
|
@@ -3550,4 +3567,4 @@ declare class PullClient implements ConnectorParent {
|
|
|
3550
3567
|
declare function initializeB24Frame(): Promise<B24Frame>;
|
|
3551
3568
|
|
|
3552
3569
|
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$1 as Text, Type, TypeOption, TypeSpecificUrl, convertBizprocDocumentTypeToCrmEntityTypeId, getDocumentId, getDocumentType, getDocumentTypeForFilter, getEnumCrmEntityTypeShort, getEnumValue, initializeB24Frame, isArrayOfArray, omit, pick, useB24Helper, useFormatter };
|
|
3553
|
-
export type { ActivityConfig, ActivityHandlerParams, ActivityOrRobotConfig, ActivityProperty, ActivityPropertyType, AjaxErrorParams, AjaxQuery, AjaxResultParams, AnswerError, AuthActions, AuthData, B24FrameQueryParams, B24HookParams, B24OAuthParams, B24OAuthSecret, BatchPayload, BoolString, CallbackRefreshAuth, CatalogCatalog, CatalogExtra, CatalogLanguage, CatalogMeasure, CatalogPriceType, CatalogPriceTypeLang, CatalogProduct, CatalogProductImage, CatalogProductOffer, CatalogProductService, CatalogProductSku, CatalogRatio, CatalogRoundingRule, CatalogSection, CatalogStore, CatalogVat, CommandHandlerFunctionV1, CommandHandlerFunctionV2, ConnectorCallbacks, ConnectorConfig, ConnectorParent, CrmItemDelivery, CrmItemPayment, CrmItemProductRow, Currency, CurrencyFormat, EventHandlerParams, EventOnAppInstallHandlerParams, EventOnAppUnInstallHandlerParams, Fields, GenderString, GetPayload, HandlerAuthParams, IPlacementUF, IRequestIdGenerator, IResult, ISODate, JsonRpcRequest, ListPayload, MessageInitData, MultiField, MultiFieldArray, NumberString, Payload, PayloadOAuthToken, PayloadTime, PlacementViewMode, RefreshAuthData, RpcCommand, RpcCommandResult, RpcError, RpcRequest, SelectCRMParams, SelectCRMParamsEntityType, SelectCRMParamsValue, SelectedAccess, SelectedCRM, SelectedCRMEntity, SelectedUser, SendParams, SharedConfigCallbacks, SharedConfigParams, StatusClose, StorageManagerParams, TextType, TypeApp, TypeB24, TypeB24Form, TypeChanel, TypeChannelManagerParams, TypeConnector, TypeDescriptionError, TypeEnumAppStatus, TypeHttp, TypeJsonRpcConfig, TypeLicense, TypePayment, TypePublicIdDescriptor, TypePullClientConfig, TypePullClientEmitConfig, TypePullClientMessageBatch, TypePullClientMessageBody, TypePullClientParams, TypePullClientSession, TypePullMessage, TypeRestrictionManagerParams, TypeRpcResponseAwaiters, TypeSessionEvent, TypeStorageManager, TypeSubscriptionCommandHandler, TypeSubscriptionOptions, TypeUser, UserBasic, UserBrief, UserFieldType, UserStatusCallback };
|
|
3570
|
+
export type { ActivityConfig, ActivityHandlerParams, ActivityOrRobotConfig, ActivityProperty, ActivityPropertyType, AjaxErrorParams, AjaxQuery, AjaxResultParams, AnswerError, AuthActions, AuthData, B24FrameQueryParams, B24HookParams, B24OAuthParams, B24OAuthSecret, BatchPayload, BoolString, CallbackRefreshAuth, CatalogCatalog, CatalogExtra, CatalogLanguage, CatalogMeasure, CatalogPriceType, CatalogPriceTypeLang, CatalogProduct, CatalogProductImage, CatalogProductOffer, CatalogProductService, CatalogProductSku, CatalogRatio, CatalogRoundingRule, CatalogSection, CatalogStore, CatalogVat, CommandHandlerFunctionV1, CommandHandlerFunctionV2, ConnectorCallbacks, ConnectorConfig, ConnectorParent, CrmItemDelivery, CrmItemPayment, CrmItemProductRow, Currency, CurrencyFormat, CustomRefreshAuth, EventHandlerParams, EventOnAppInstallHandlerParams, EventOnAppUnInstallHandlerParams, Fields, GenderString, GetPayload, HandlerAuthParams, HandlerRefreshAuth, IPlacementUF, IRequestIdGenerator, IResult, ISODate, JsonRpcRequest, ListPayload, MessageInitData, MultiField, MultiFieldArray, NumberString, Payload, PayloadOAuthToken, PayloadTime, PlacementViewMode, RefreshAuthData, RpcCommand, RpcCommandResult, RpcError, RpcRequest, SelectCRMParams, SelectCRMParamsEntityType, SelectCRMParamsValue, SelectedAccess, SelectedCRM, SelectedCRMEntity, SelectedUser, SendParams, SharedConfigCallbacks, SharedConfigParams, StatusClose, StorageManagerParams, TextType, TypeApp, TypeB24, TypeB24Form, TypeChanel, TypeChannelManagerParams, TypeConnector, TypeDescriptionError, TypeEnumAppStatus, TypeHttp, TypeJsonRpcConfig, TypeLicense, TypePayment, TypePublicIdDescriptor, TypePullClientConfig, TypePullClientEmitConfig, TypePullClientMessageBatch, TypePullClientMessageBody, TypePullClientParams, TypePullClientSession, TypePullMessage, TypeRestrictionManagerParams, TypeRpcResponseAwaiters, TypeSessionEvent, TypeStorageManager, TypeSubscriptionCommandHandler, TypeSubscriptionOptions, TypeUser, UserBasic, UserBrief, UserFieldType, UserStatusCallback };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @version @bitrix24/b24jssdk v0.
|
|
2
|
+
* @version @bitrix24/b24jssdk v0.5.1
|
|
3
3
|
* @copyright (c) 2025 Bitrix24
|
|
4
4
|
* @licence MIT
|
|
5
5
|
* @links https://github.com/bitrix24/b24jssdk - GitHub
|
|
@@ -1683,7 +1683,7 @@ class Http {
|
|
|
1683
1683
|
#clientSideWarningMessage = "";
|
|
1684
1684
|
constructor(baseURL, authActions, options) {
|
|
1685
1685
|
const defaultHeaders = {
|
|
1686
|
-
// 'X-Sdk': 'b24-js-sdk-v-0.
|
|
1686
|
+
// 'X-Sdk': 'b24-js-sdk-v-0.5.1'
|
|
1687
1687
|
};
|
|
1688
1688
|
this.#clientAxios = axios.create({
|
|
1689
1689
|
baseURL,
|
|
@@ -2111,9 +2111,12 @@ class Http {
|
|
|
2111
2111
|
*/
|
|
2112
2112
|
#prepareMethod(method) {
|
|
2113
2113
|
const baseUrl = `${encodeURIComponent(method)}.json`;
|
|
2114
|
+
if (method.includes("task.")) {
|
|
2115
|
+
return `${baseUrl}`;
|
|
2116
|
+
}
|
|
2114
2117
|
const queryParams = new URLSearchParams({
|
|
2115
2118
|
[this.#requestIdGenerator.getQueryStringParameterName()]: this.#requestIdGenerator.getRequestId(),
|
|
2116
|
-
[this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.
|
|
2119
|
+
[this.#requestIdGenerator.getQueryStringSdkParameterName()]: "0.5.1",
|
|
2117
2120
|
[this.#requestIdGenerator.getQueryStringSdkTypeParameterName()]: "b24-js-sdk"
|
|
2118
2121
|
});
|
|
2119
2122
|
return `${baseUrl}?${queryParams.toString()}`;
|
|
@@ -3164,6 +3167,7 @@ class AuthHookManager {
|
|
|
3164
3167
|
return {
|
|
3165
3168
|
access_token: this.#b24HookParams.secret,
|
|
3166
3169
|
refresh_token: "hook",
|
|
3170
|
+
expires: 0,
|
|
3167
3171
|
expires_in: 0,
|
|
3168
3172
|
domain: this.#domain,
|
|
3169
3173
|
member_id: this.#domain
|
|
@@ -3543,6 +3547,7 @@ class AuthManager {
|
|
|
3543
3547
|
#accessToken = null;
|
|
3544
3548
|
#refreshId = null;
|
|
3545
3549
|
#authExpires = 0;
|
|
3550
|
+
#authExpiresIn = 0;
|
|
3546
3551
|
#memberId = null;
|
|
3547
3552
|
#isAdmin = false;
|
|
3548
3553
|
#appFrame;
|
|
@@ -3559,7 +3564,8 @@ class AuthManager {
|
|
|
3559
3564
|
if (data.AUTH_ID) {
|
|
3560
3565
|
this.#accessToken = data.AUTH_ID;
|
|
3561
3566
|
this.#refreshId = data.REFRESH_ID;
|
|
3562
|
-
this.#
|
|
3567
|
+
this.#authExpiresIn = Number.parseInt(data.AUTH_EXPIRES);
|
|
3568
|
+
this.#authExpires = Date.now() + this.#authExpiresIn * 1e3;
|
|
3563
3569
|
this.#isAdmin = data.IS_ADMIN;
|
|
3564
3570
|
this.#memberId = data.MEMBER_ID || "";
|
|
3565
3571
|
}
|
|
@@ -3574,7 +3580,8 @@ class AuthManager {
|
|
|
3574
3580
|
return this.#authExpires > Date.now() ? {
|
|
3575
3581
|
access_token: this.#accessToken,
|
|
3576
3582
|
refresh_token: this.#refreshId,
|
|
3577
|
-
|
|
3583
|
+
expires: this.#authExpires / 1e3,
|
|
3584
|
+
expires_in: this.#authExpiresIn,
|
|
3578
3585
|
domain: this.#appFrame.getTargetOrigin(),
|
|
3579
3586
|
member_id: this.#memberId
|
|
3580
3587
|
} : false;
|
|
@@ -4391,9 +4398,11 @@ class RefreshTokenError extends AjaxError {
|
|
|
4391
4398
|
class AuthOAuthManager {
|
|
4392
4399
|
#clientAxios;
|
|
4393
4400
|
#callbackRefreshAuth = null;
|
|
4401
|
+
#customRefreshAuth = null;
|
|
4394
4402
|
#authOptions;
|
|
4395
4403
|
#oAuthSecret;
|
|
4396
4404
|
#authExpires = 0;
|
|
4405
|
+
#authExpiresIn = 0;
|
|
4397
4406
|
#domain;
|
|
4398
4407
|
#b24TargetRest;
|
|
4399
4408
|
#b24Target;
|
|
@@ -4408,6 +4417,7 @@ class AuthOAuthManager {
|
|
|
4408
4417
|
this.#b24Target = this.#b24TargetRest.replace("/rest/", "");
|
|
4409
4418
|
this.#oAuthTarget = this.#authOptions.serverEndpoint.replace("/rest/", "");
|
|
4410
4419
|
this.#authExpires = this.#authOptions.expires * 1e3;
|
|
4420
|
+
this.#authExpiresIn = this.#authOptions.expiresIn;
|
|
4411
4421
|
this.#clientAxios = axios.create({
|
|
4412
4422
|
baseURL: this.#oAuthTarget,
|
|
4413
4423
|
headers: {
|
|
@@ -4423,7 +4433,8 @@ class AuthOAuthManager {
|
|
|
4423
4433
|
return this.#authExpires > Date.now() ? {
|
|
4424
4434
|
access_token: this.#authOptions.accessToken,
|
|
4425
4435
|
refresh_token: this.#authOptions.refreshToken,
|
|
4426
|
-
|
|
4436
|
+
expires: this.#authExpires / 1e3,
|
|
4437
|
+
expires_in: this.#authExpiresIn,
|
|
4427
4438
|
domain: this.#domain,
|
|
4428
4439
|
member_id: this.#authOptions.memberId
|
|
4429
4440
|
} : false;
|
|
@@ -4434,24 +4445,32 @@ class AuthOAuthManager {
|
|
|
4434
4445
|
*/
|
|
4435
4446
|
async refreshAuth() {
|
|
4436
4447
|
try {
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4448
|
+
let payload = void 0;
|
|
4449
|
+
if (this.#customRefreshAuth) {
|
|
4450
|
+
payload = await this.#customRefreshAuth();
|
|
4451
|
+
} else {
|
|
4452
|
+
const response = await this.#clientAxios.get(
|
|
4453
|
+
"/oauth/token/",
|
|
4454
|
+
{
|
|
4455
|
+
params: {
|
|
4456
|
+
grant_type: "refresh_token",
|
|
4457
|
+
client_id: this.#oAuthSecret.clientId,
|
|
4458
|
+
client_secret: this.#oAuthSecret.clientSecret,
|
|
4459
|
+
refresh_token: this.#authOptions.refreshToken
|
|
4460
|
+
}
|
|
4445
4461
|
}
|
|
4462
|
+
);
|
|
4463
|
+
if (response.data.error) {
|
|
4464
|
+
throw new Error(`Token update error: ${response.data.error}`);
|
|
4446
4465
|
}
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4466
|
+
if (response.status !== 200) {
|
|
4467
|
+
throw new Error(`Token update error status code: ${response.status}`);
|
|
4468
|
+
}
|
|
4469
|
+
payload = response.data;
|
|
4450
4470
|
}
|
|
4451
|
-
if (
|
|
4452
|
-
throw new Error(
|
|
4471
|
+
if (!payload) {
|
|
4472
|
+
throw new Error("Unable to obtain authorization update data");
|
|
4453
4473
|
}
|
|
4454
|
-
const payload = response.data;
|
|
4455
4474
|
this.#authOptions.accessToken = payload.access_token;
|
|
4456
4475
|
this.#authOptions.refreshToken = payload.refresh_token;
|
|
4457
4476
|
this.#authOptions.expires = Number.parseInt(payload.expires || "0");
|
|
@@ -4502,6 +4521,12 @@ class AuthOAuthManager {
|
|
|
4502
4521
|
removeCallbackRefreshAuth() {
|
|
4503
4522
|
this.#callbackRefreshAuth = null;
|
|
4504
4523
|
}
|
|
4524
|
+
setCustomRefreshAuth(cb) {
|
|
4525
|
+
this.#customRefreshAuth = cb;
|
|
4526
|
+
}
|
|
4527
|
+
removeCustomRefreshAuth() {
|
|
4528
|
+
this.#customRefreshAuth = null;
|
|
4529
|
+
}
|
|
4505
4530
|
// endregion ////
|
|
4506
4531
|
getUniq(prefix) {
|
|
4507
4532
|
return [prefix, this.#authOptions.memberId || ""].join("_");
|
|
@@ -4581,6 +4606,21 @@ class B24OAuth extends AbstractB24 {
|
|
|
4581
4606
|
this._ensureInitialized();
|
|
4582
4607
|
this.#authOAuthManager.removeCallbackRefreshAuth();
|
|
4583
4608
|
}
|
|
4609
|
+
/**
|
|
4610
|
+
* Sets an asynchronous function for custom get new refresh token
|
|
4611
|
+
* @param cb
|
|
4612
|
+
*/
|
|
4613
|
+
setCustomRefreshAuth(cb) {
|
|
4614
|
+
this._ensureInitialized();
|
|
4615
|
+
this.#authOAuthManager.setCustomRefreshAuth(cb);
|
|
4616
|
+
}
|
|
4617
|
+
/**
|
|
4618
|
+
* Removes function for custom get new refresh token
|
|
4619
|
+
*/
|
|
4620
|
+
removeCustomRefreshAuth() {
|
|
4621
|
+
this._ensureInitialized();
|
|
4622
|
+
this.#authOAuthManager.removeCustomRefreshAuth();
|
|
4623
|
+
}
|
|
4584
4624
|
// endregion ////
|
|
4585
4625
|
// region Core ////
|
|
4586
4626
|
/**
|