@compilot/react-sdk 2.0.50-dev → 2.0.53-dev
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/compilot-react-sdk.cjs.dev.js +59 -32
- package/dist/compilot-react-sdk.cjs.prod.js +59 -32
- package/dist/compilot-react-sdk.esm.js +60 -33
- package/dist/declarations/src/hooks/index.d.ts +1 -1
- package/dist/declarations/src/hooks/index.d.ts.map +1 -1
- package/dist/declarations/src/hooks/useAuthenticate.d.ts +12 -0
- package/dist/declarations/src/hooks/useAuthenticate.d.ts.map +1 -0
- package/dist/declarations/src/hooks/useDisconnect.d.ts +2 -3
- package/dist/declarations/src/hooks/useDisconnect.d.ts.map +1 -1
- package/dist/declarations/src/hooks/useGetTxAuthDataSignature.d.ts +3 -4
- package/dist/declarations/src/hooks/useGetTxAuthDataSignature.d.ts.map +1 -1
- package/dist/declarations/src/hooks/useOpenWidget.d.ts +2 -41
- package/dist/declarations/src/hooks/useOpenWidget.d.ts.map +1 -1
- package/dist/declarations/src/utils/useAsyncMutationState.d.ts +14 -14
- package/dist/declarations/src/utils/useAsyncMutationState.d.ts.map +1 -1
- package/dist/declarations/src/utils/useAsyncQueryState.d.ts +2 -0
- package/dist/declarations/src/utils/useAsyncQueryState.d.ts.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +3 -3
- package/dist/declarations/src/hooks/useIsAuthenticated.d.ts +0 -10
- package/dist/declarations/src/hooks/useIsAuthenticated.d.ts.map +0 -1
|
@@ -523,7 +523,8 @@ function _slicedToArray(r, e) {
|
|
|
523
523
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
524
524
|
|
|
525
525
|
var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
526
|
-
var
|
|
526
|
+
var mutationName = _ref.mutationName,
|
|
527
|
+
mutationFn = _ref.mutationFn;
|
|
527
528
|
var _useState = react.useState({
|
|
528
529
|
data: undefined,
|
|
529
530
|
isIdle: true,
|
|
@@ -576,16 +577,13 @@ var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
|
576
577
|
isSuccess: false,
|
|
577
578
|
error: _context.t0 instanceof Error ? _context.t0 : new Error(String(_context.t0))
|
|
578
579
|
});
|
|
579
|
-
|
|
580
|
-
case 13:
|
|
580
|
+
case 12:
|
|
581
581
|
case "end":
|
|
582
582
|
return _context.stop();
|
|
583
583
|
}
|
|
584
584
|
}, _callee, null, [[1, 9]]);
|
|
585
585
|
})), [setState, mutationFn]);
|
|
586
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
587
|
-
mutateAsync: mutateAsync
|
|
588
|
-
});
|
|
586
|
+
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, mutationName, mutateAsync));
|
|
589
587
|
};
|
|
590
588
|
|
|
591
589
|
var useAsyncQueryState = function useAsyncQueryState(defaultValue) {
|
|
@@ -632,11 +630,29 @@ var useAsyncQueryState = function useAsyncQueryState(defaultValue) {
|
|
|
632
630
|
data: undefined
|
|
633
631
|
});
|
|
634
632
|
}, [setState]);
|
|
633
|
+
var stopLoading = react.useCallback(function () {
|
|
634
|
+
setState({
|
|
635
|
+
isLoading: false,
|
|
636
|
+
isError: false,
|
|
637
|
+
isSuccess: false,
|
|
638
|
+
error: null,
|
|
639
|
+
data: undefined
|
|
640
|
+
});
|
|
641
|
+
}, [setState]);
|
|
642
|
+
var setLoading = react.useCallback(function (isLoading) {
|
|
643
|
+
if (isLoading) {
|
|
644
|
+
startLoading();
|
|
645
|
+
} else {
|
|
646
|
+
stopLoading();
|
|
647
|
+
}
|
|
648
|
+
}, [startLoading, stopLoading]);
|
|
635
649
|
return {
|
|
636
650
|
state: state,
|
|
637
651
|
setResult: setResult,
|
|
638
652
|
setError: setError,
|
|
639
|
-
startLoading: startLoading
|
|
653
|
+
startLoading: startLoading,
|
|
654
|
+
stopLoading: stopLoading,
|
|
655
|
+
setLoading: setLoading
|
|
640
656
|
};
|
|
641
657
|
};
|
|
642
658
|
|
|
@@ -654,28 +670,24 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
654
670
|
return webSdk.openWidget(config, loginParams);
|
|
655
671
|
}, [config]);
|
|
656
672
|
var mutationState = useAsyncMutationState({
|
|
673
|
+
mutationName: "openWidget",
|
|
657
674
|
mutationFn: mutationFn
|
|
658
675
|
});
|
|
659
|
-
|
|
660
676
|
// but open state can change without us mutating it
|
|
661
677
|
// that's the only case for now so we don't need another kind of mutation state
|
|
662
678
|
var _useAsyncQueryState = useAsyncQueryState(webSdk.isOpen(config)),
|
|
663
679
|
setResult = _useAsyncQueryState.setResult,
|
|
664
|
-
|
|
680
|
+
setLoading = _useAsyncQueryState.setLoading,
|
|
665
681
|
queryState = _useAsyncQueryState.state;
|
|
666
682
|
react.useEffect(function () {
|
|
667
683
|
var unsubscribe = webSdk.watchWidgetVisibleState(config, {
|
|
668
684
|
onChange: function onChange(isVisible) {
|
|
669
685
|
setResult(isVisible);
|
|
670
686
|
},
|
|
671
|
-
onIsLoadingChange:
|
|
672
|
-
if (isLoading) {
|
|
673
|
-
startLoading();
|
|
674
|
-
}
|
|
675
|
-
}
|
|
687
|
+
onIsLoadingChange: setLoading
|
|
676
688
|
});
|
|
677
689
|
return unsubscribe;
|
|
678
|
-
}, [config, setResult,
|
|
690
|
+
}, [config, setResult, setLoading]);
|
|
679
691
|
return _objectSpread2(_objectSpread2({}, queryState.data === undefined ? mutationState : {
|
|
680
692
|
error: queryState.error,
|
|
681
693
|
isPending: queryState.isLoading,
|
|
@@ -684,7 +696,7 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
684
696
|
isIdle: !queryState.isError && !queryState.isLoading && !queryState.isSuccess,
|
|
685
697
|
data: queryState.data
|
|
686
698
|
}), {}, {
|
|
687
|
-
|
|
699
|
+
openWidget: mutationState.openWidget
|
|
688
700
|
});
|
|
689
701
|
};
|
|
690
702
|
|
|
@@ -712,7 +724,7 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
712
724
|
*
|
|
713
725
|
* const MyComponent = () => {
|
|
714
726
|
*
|
|
715
|
-
* const {
|
|
727
|
+
* const { getTxAuthDataSignature } = useGetTxAuthDataSignature();
|
|
716
728
|
* const walletClient = useWalletClient();
|
|
717
729
|
* const publicClient = usePublicClient();
|
|
718
730
|
*
|
|
@@ -769,7 +781,7 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
769
781
|
* import { RpcClient } from "@taquito/rpc";
|
|
770
782
|
*
|
|
771
783
|
* const MyComponent = () => {
|
|
772
|
-
* const {
|
|
784
|
+
* const { getTxAuthDataSignature } = useGetTxAuthDataSignature();
|
|
773
785
|
* const wallet = useWallet();
|
|
774
786
|
*
|
|
775
787
|
* const signAndSend = async () => {
|
|
@@ -867,39 +879,53 @@ var useGetTxAuthDataSignature = function useGetTxAuthDataSignature() {
|
|
|
867
879
|
};
|
|
868
880
|
}(), [config._internal.widgetStateStore, config._internal.identifier]);
|
|
869
881
|
return useAsyncMutationState({
|
|
882
|
+
mutationName: "getTxAuthDataSignature",
|
|
870
883
|
mutationFn: mutationFn
|
|
871
884
|
});
|
|
872
885
|
};
|
|
873
886
|
|
|
874
887
|
/**
|
|
875
|
-
* A hook that returns
|
|
888
|
+
* A hook that returns a function that authenticates the user without opening the ComPilot ID widget.
|
|
889
|
+
* This will authenticate the user only if they are not already authenticated.
|
|
876
890
|
*
|
|
877
|
-
* @
|
|
891
|
+
* @param loginParams - The login parameters to use when authenticating the user.
|
|
878
892
|
*
|
|
879
|
-
* @
|
|
893
|
+
* @returns The async mutation state of the authentication.
|
|
880
894
|
*/
|
|
881
|
-
var
|
|
895
|
+
var useAuthenticate = function useAuthenticate(loginParams) {
|
|
882
896
|
var config = useComPilotConfig();
|
|
897
|
+
var mutationFn = react.useCallback(function () {
|
|
898
|
+
return webSdk.authenticate(config, loginParams);
|
|
899
|
+
}, [config]);
|
|
900
|
+
var mutationState = useAsyncMutationState({
|
|
901
|
+
mutationName: "authenticate",
|
|
902
|
+
mutationFn: mutationFn
|
|
903
|
+
});
|
|
883
904
|
var _useAsyncQueryState = useAsyncQueryState(webSdk.isAuthenticated(config)),
|
|
884
|
-
|
|
905
|
+
queryState = _useAsyncQueryState.state,
|
|
885
906
|
setResult = _useAsyncQueryState.setResult,
|
|
886
|
-
|
|
907
|
+
setLoading = _useAsyncQueryState.setLoading;
|
|
887
908
|
react.useEffect(function () {
|
|
888
909
|
var unsubscribe = webSdk.watchIsAuthenticated(config, {
|
|
889
910
|
onIsAuthenticatedChange: function onIsAuthenticatedChange(isAuthenticated) {
|
|
890
911
|
setResult(isAuthenticated);
|
|
891
912
|
},
|
|
892
|
-
onIsLoadingChange:
|
|
893
|
-
if (isLoading) {
|
|
894
|
-
startLoading();
|
|
895
|
-
}
|
|
896
|
-
}
|
|
913
|
+
onIsLoadingChange: setLoading
|
|
897
914
|
});
|
|
898
915
|
return function () {
|
|
899
916
|
unsubscribe();
|
|
900
917
|
};
|
|
901
918
|
}, [config._internal.widgetStateStore, config._internal.identifier]);
|
|
902
|
-
return
|
|
919
|
+
return _objectSpread2(_objectSpread2({}, queryState.data === undefined ? mutationState : {
|
|
920
|
+
error: queryState.error,
|
|
921
|
+
isPending: queryState.isLoading,
|
|
922
|
+
isSuccess: queryState.isSuccess,
|
|
923
|
+
isError: queryState.isError,
|
|
924
|
+
isIdle: !queryState.isError && !queryState.isLoading && !queryState.isSuccess,
|
|
925
|
+
data: queryState.data
|
|
926
|
+
}), {}, {
|
|
927
|
+
authenticate: mutationState.authenticate
|
|
928
|
+
});
|
|
903
929
|
};
|
|
904
930
|
|
|
905
931
|
/**
|
|
@@ -983,7 +1009,7 @@ var useCustomerStatus = function useCustomerStatus() {
|
|
|
983
1009
|
* import { useDisconnect } from "@compilot/react-sdk";
|
|
984
1010
|
*
|
|
985
1011
|
* const Logout = () => {
|
|
986
|
-
* const {
|
|
1012
|
+
* const { disconnect, isLoading } = useDisconnect();
|
|
987
1013
|
*
|
|
988
1014
|
* return (
|
|
989
1015
|
* <button
|
|
@@ -1002,16 +1028,17 @@ var useDisconnect = function useDisconnect() {
|
|
|
1002
1028
|
return webSdk.disconnect(config);
|
|
1003
1029
|
}, [config]);
|
|
1004
1030
|
return useAsyncMutationState({
|
|
1031
|
+
mutationName: "disconnect",
|
|
1005
1032
|
mutationFn: mutationFn
|
|
1006
1033
|
});
|
|
1007
1034
|
};
|
|
1008
1035
|
|
|
1009
1036
|
exports.ComPilotProvider = ComPilotProvider;
|
|
1037
|
+
exports.useAuthenticate = useAuthenticate;
|
|
1010
1038
|
exports.useComPilotConfig = useComPilotConfig;
|
|
1011
1039
|
exports.useCustomerStatus = useCustomerStatus;
|
|
1012
1040
|
exports.useDisconnect = useDisconnect;
|
|
1013
1041
|
exports.useGetTxAuthDataSignature = useGetTxAuthDataSignature;
|
|
1014
|
-
exports.useIsAuthenticated = useIsAuthenticated;
|
|
1015
1042
|
exports.useOpenWidget = useOpenWidget;
|
|
1016
1043
|
Object.keys(webSdk).forEach(function (k) {
|
|
1017
1044
|
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
@@ -523,7 +523,8 @@ function _slicedToArray(r, e) {
|
|
|
523
523
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
524
524
|
|
|
525
525
|
var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
526
|
-
var
|
|
526
|
+
var mutationName = _ref.mutationName,
|
|
527
|
+
mutationFn = _ref.mutationFn;
|
|
527
528
|
var _useState = react.useState({
|
|
528
529
|
data: undefined,
|
|
529
530
|
isIdle: true,
|
|
@@ -576,16 +577,13 @@ var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
|
576
577
|
isSuccess: false,
|
|
577
578
|
error: _context.t0 instanceof Error ? _context.t0 : new Error(String(_context.t0))
|
|
578
579
|
});
|
|
579
|
-
|
|
580
|
-
case 13:
|
|
580
|
+
case 12:
|
|
581
581
|
case "end":
|
|
582
582
|
return _context.stop();
|
|
583
583
|
}
|
|
584
584
|
}, _callee, null, [[1, 9]]);
|
|
585
585
|
})), [setState, mutationFn]);
|
|
586
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
587
|
-
mutateAsync: mutateAsync
|
|
588
|
-
});
|
|
586
|
+
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, mutationName, mutateAsync));
|
|
589
587
|
};
|
|
590
588
|
|
|
591
589
|
var useAsyncQueryState = function useAsyncQueryState(defaultValue) {
|
|
@@ -632,11 +630,29 @@ var useAsyncQueryState = function useAsyncQueryState(defaultValue) {
|
|
|
632
630
|
data: undefined
|
|
633
631
|
});
|
|
634
632
|
}, [setState]);
|
|
633
|
+
var stopLoading = react.useCallback(function () {
|
|
634
|
+
setState({
|
|
635
|
+
isLoading: false,
|
|
636
|
+
isError: false,
|
|
637
|
+
isSuccess: false,
|
|
638
|
+
error: null,
|
|
639
|
+
data: undefined
|
|
640
|
+
});
|
|
641
|
+
}, [setState]);
|
|
642
|
+
var setLoading = react.useCallback(function (isLoading) {
|
|
643
|
+
if (isLoading) {
|
|
644
|
+
startLoading();
|
|
645
|
+
} else {
|
|
646
|
+
stopLoading();
|
|
647
|
+
}
|
|
648
|
+
}, [startLoading, stopLoading]);
|
|
635
649
|
return {
|
|
636
650
|
state: state,
|
|
637
651
|
setResult: setResult,
|
|
638
652
|
setError: setError,
|
|
639
|
-
startLoading: startLoading
|
|
653
|
+
startLoading: startLoading,
|
|
654
|
+
stopLoading: stopLoading,
|
|
655
|
+
setLoading: setLoading
|
|
640
656
|
};
|
|
641
657
|
};
|
|
642
658
|
|
|
@@ -654,28 +670,24 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
654
670
|
return webSdk.openWidget(config, loginParams);
|
|
655
671
|
}, [config]);
|
|
656
672
|
var mutationState = useAsyncMutationState({
|
|
673
|
+
mutationName: "openWidget",
|
|
657
674
|
mutationFn: mutationFn
|
|
658
675
|
});
|
|
659
|
-
|
|
660
676
|
// but open state can change without us mutating it
|
|
661
677
|
// that's the only case for now so we don't need another kind of mutation state
|
|
662
678
|
var _useAsyncQueryState = useAsyncQueryState(webSdk.isOpen(config)),
|
|
663
679
|
setResult = _useAsyncQueryState.setResult,
|
|
664
|
-
|
|
680
|
+
setLoading = _useAsyncQueryState.setLoading,
|
|
665
681
|
queryState = _useAsyncQueryState.state;
|
|
666
682
|
react.useEffect(function () {
|
|
667
683
|
var unsubscribe = webSdk.watchWidgetVisibleState(config, {
|
|
668
684
|
onChange: function onChange(isVisible) {
|
|
669
685
|
setResult(isVisible);
|
|
670
686
|
},
|
|
671
|
-
onIsLoadingChange:
|
|
672
|
-
if (isLoading) {
|
|
673
|
-
startLoading();
|
|
674
|
-
}
|
|
675
|
-
}
|
|
687
|
+
onIsLoadingChange: setLoading
|
|
676
688
|
});
|
|
677
689
|
return unsubscribe;
|
|
678
|
-
}, [config, setResult,
|
|
690
|
+
}, [config, setResult, setLoading]);
|
|
679
691
|
return _objectSpread2(_objectSpread2({}, queryState.data === undefined ? mutationState : {
|
|
680
692
|
error: queryState.error,
|
|
681
693
|
isPending: queryState.isLoading,
|
|
@@ -684,7 +696,7 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
684
696
|
isIdle: !queryState.isError && !queryState.isLoading && !queryState.isSuccess,
|
|
685
697
|
data: queryState.data
|
|
686
698
|
}), {}, {
|
|
687
|
-
|
|
699
|
+
openWidget: mutationState.openWidget
|
|
688
700
|
});
|
|
689
701
|
};
|
|
690
702
|
|
|
@@ -712,7 +724,7 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
712
724
|
*
|
|
713
725
|
* const MyComponent = () => {
|
|
714
726
|
*
|
|
715
|
-
* const {
|
|
727
|
+
* const { getTxAuthDataSignature } = useGetTxAuthDataSignature();
|
|
716
728
|
* const walletClient = useWalletClient();
|
|
717
729
|
* const publicClient = usePublicClient();
|
|
718
730
|
*
|
|
@@ -769,7 +781,7 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
769
781
|
* import { RpcClient } from "@taquito/rpc";
|
|
770
782
|
*
|
|
771
783
|
* const MyComponent = () => {
|
|
772
|
-
* const {
|
|
784
|
+
* const { getTxAuthDataSignature } = useGetTxAuthDataSignature();
|
|
773
785
|
* const wallet = useWallet();
|
|
774
786
|
*
|
|
775
787
|
* const signAndSend = async () => {
|
|
@@ -867,39 +879,53 @@ var useGetTxAuthDataSignature = function useGetTxAuthDataSignature() {
|
|
|
867
879
|
};
|
|
868
880
|
}(), [config._internal.widgetStateStore, config._internal.identifier]);
|
|
869
881
|
return useAsyncMutationState({
|
|
882
|
+
mutationName: "getTxAuthDataSignature",
|
|
870
883
|
mutationFn: mutationFn
|
|
871
884
|
});
|
|
872
885
|
};
|
|
873
886
|
|
|
874
887
|
/**
|
|
875
|
-
* A hook that returns
|
|
888
|
+
* A hook that returns a function that authenticates the user without opening the ComPilot ID widget.
|
|
889
|
+
* This will authenticate the user only if they are not already authenticated.
|
|
876
890
|
*
|
|
877
|
-
* @
|
|
891
|
+
* @param loginParams - The login parameters to use when authenticating the user.
|
|
878
892
|
*
|
|
879
|
-
* @
|
|
893
|
+
* @returns The async mutation state of the authentication.
|
|
880
894
|
*/
|
|
881
|
-
var
|
|
895
|
+
var useAuthenticate = function useAuthenticate(loginParams) {
|
|
882
896
|
var config = useComPilotConfig();
|
|
897
|
+
var mutationFn = react.useCallback(function () {
|
|
898
|
+
return webSdk.authenticate(config, loginParams);
|
|
899
|
+
}, [config]);
|
|
900
|
+
var mutationState = useAsyncMutationState({
|
|
901
|
+
mutationName: "authenticate",
|
|
902
|
+
mutationFn: mutationFn
|
|
903
|
+
});
|
|
883
904
|
var _useAsyncQueryState = useAsyncQueryState(webSdk.isAuthenticated(config)),
|
|
884
|
-
|
|
905
|
+
queryState = _useAsyncQueryState.state,
|
|
885
906
|
setResult = _useAsyncQueryState.setResult,
|
|
886
|
-
|
|
907
|
+
setLoading = _useAsyncQueryState.setLoading;
|
|
887
908
|
react.useEffect(function () {
|
|
888
909
|
var unsubscribe = webSdk.watchIsAuthenticated(config, {
|
|
889
910
|
onIsAuthenticatedChange: function onIsAuthenticatedChange(isAuthenticated) {
|
|
890
911
|
setResult(isAuthenticated);
|
|
891
912
|
},
|
|
892
|
-
onIsLoadingChange:
|
|
893
|
-
if (isLoading) {
|
|
894
|
-
startLoading();
|
|
895
|
-
}
|
|
896
|
-
}
|
|
913
|
+
onIsLoadingChange: setLoading
|
|
897
914
|
});
|
|
898
915
|
return function () {
|
|
899
916
|
unsubscribe();
|
|
900
917
|
};
|
|
901
918
|
}, [config._internal.widgetStateStore, config._internal.identifier]);
|
|
902
|
-
return
|
|
919
|
+
return _objectSpread2(_objectSpread2({}, queryState.data === undefined ? mutationState : {
|
|
920
|
+
error: queryState.error,
|
|
921
|
+
isPending: queryState.isLoading,
|
|
922
|
+
isSuccess: queryState.isSuccess,
|
|
923
|
+
isError: queryState.isError,
|
|
924
|
+
isIdle: !queryState.isError && !queryState.isLoading && !queryState.isSuccess,
|
|
925
|
+
data: queryState.data
|
|
926
|
+
}), {}, {
|
|
927
|
+
authenticate: mutationState.authenticate
|
|
928
|
+
});
|
|
903
929
|
};
|
|
904
930
|
|
|
905
931
|
/**
|
|
@@ -983,7 +1009,7 @@ var useCustomerStatus = function useCustomerStatus() {
|
|
|
983
1009
|
* import { useDisconnect } from "@compilot/react-sdk";
|
|
984
1010
|
*
|
|
985
1011
|
* const Logout = () => {
|
|
986
|
-
* const {
|
|
1012
|
+
* const { disconnect, isLoading } = useDisconnect();
|
|
987
1013
|
*
|
|
988
1014
|
* return (
|
|
989
1015
|
* <button
|
|
@@ -1002,16 +1028,17 @@ var useDisconnect = function useDisconnect() {
|
|
|
1002
1028
|
return webSdk.disconnect(config);
|
|
1003
1029
|
}, [config]);
|
|
1004
1030
|
return useAsyncMutationState({
|
|
1031
|
+
mutationName: "disconnect",
|
|
1005
1032
|
mutationFn: mutationFn
|
|
1006
1033
|
});
|
|
1007
1034
|
};
|
|
1008
1035
|
|
|
1009
1036
|
exports.ComPilotProvider = ComPilotProvider;
|
|
1037
|
+
exports.useAuthenticate = useAuthenticate;
|
|
1010
1038
|
exports.useComPilotConfig = useComPilotConfig;
|
|
1011
1039
|
exports.useCustomerStatus = useCustomerStatus;
|
|
1012
1040
|
exports.useDisconnect = useDisconnect;
|
|
1013
1041
|
exports.useGetTxAuthDataSignature = useGetTxAuthDataSignature;
|
|
1014
|
-
exports.useIsAuthenticated = useIsAuthenticated;
|
|
1015
1042
|
exports.useOpenWidget = useOpenWidget;
|
|
1016
1043
|
Object.keys(webSdk).forEach(function (k) {
|
|
1017
1044
|
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useContext, createContext, useState, useCallback } from 'react';
|
|
2
|
-
import { load, openWidget, isOpen, watchWidgetVisibleState, getTxAuthDataSignature, isAuthenticated, watchIsAuthenticated, watchCustomerStatus, getCustomerStatus, disconnect } from '@compilot/web-sdk';
|
|
2
|
+
import { load, openWidget, isOpen, watchWidgetVisibleState, getTxAuthDataSignature, authenticate, isAuthenticated, watchIsAuthenticated, watchCustomerStatus, getCustomerStatus, disconnect } from '@compilot/web-sdk';
|
|
3
3
|
export * from '@compilot/web-sdk';
|
|
4
4
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -520,7 +520,8 @@ function _slicedToArray(r, e) {
|
|
|
520
520
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
521
521
|
|
|
522
522
|
var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
523
|
-
var
|
|
523
|
+
var mutationName = _ref.mutationName,
|
|
524
|
+
mutationFn = _ref.mutationFn;
|
|
524
525
|
var _useState = useState({
|
|
525
526
|
data: undefined,
|
|
526
527
|
isIdle: true,
|
|
@@ -573,16 +574,13 @@ var useAsyncMutationState = function useAsyncMutationState(_ref) {
|
|
|
573
574
|
isSuccess: false,
|
|
574
575
|
error: _context.t0 instanceof Error ? _context.t0 : new Error(String(_context.t0))
|
|
575
576
|
});
|
|
576
|
-
|
|
577
|
-
case 13:
|
|
577
|
+
case 12:
|
|
578
578
|
case "end":
|
|
579
579
|
return _context.stop();
|
|
580
580
|
}
|
|
581
581
|
}, _callee, null, [[1, 9]]);
|
|
582
582
|
})), [setState, mutationFn]);
|
|
583
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
584
|
-
mutateAsync: mutateAsync
|
|
585
|
-
});
|
|
583
|
+
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, mutationName, mutateAsync));
|
|
586
584
|
};
|
|
587
585
|
|
|
588
586
|
var useAsyncQueryState = function useAsyncQueryState(defaultValue) {
|
|
@@ -629,11 +627,29 @@ var useAsyncQueryState = function useAsyncQueryState(defaultValue) {
|
|
|
629
627
|
data: undefined
|
|
630
628
|
});
|
|
631
629
|
}, [setState]);
|
|
630
|
+
var stopLoading = useCallback(function () {
|
|
631
|
+
setState({
|
|
632
|
+
isLoading: false,
|
|
633
|
+
isError: false,
|
|
634
|
+
isSuccess: false,
|
|
635
|
+
error: null,
|
|
636
|
+
data: undefined
|
|
637
|
+
});
|
|
638
|
+
}, [setState]);
|
|
639
|
+
var setLoading = useCallback(function (isLoading) {
|
|
640
|
+
if (isLoading) {
|
|
641
|
+
startLoading();
|
|
642
|
+
} else {
|
|
643
|
+
stopLoading();
|
|
644
|
+
}
|
|
645
|
+
}, [startLoading, stopLoading]);
|
|
632
646
|
return {
|
|
633
647
|
state: state,
|
|
634
648
|
setResult: setResult,
|
|
635
649
|
setError: setError,
|
|
636
|
-
startLoading: startLoading
|
|
650
|
+
startLoading: startLoading,
|
|
651
|
+
stopLoading: stopLoading,
|
|
652
|
+
setLoading: setLoading
|
|
637
653
|
};
|
|
638
654
|
};
|
|
639
655
|
|
|
@@ -651,28 +667,24 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
651
667
|
return openWidget(config, loginParams);
|
|
652
668
|
}, [config]);
|
|
653
669
|
var mutationState = useAsyncMutationState({
|
|
670
|
+
mutationName: "openWidget",
|
|
654
671
|
mutationFn: mutationFn
|
|
655
672
|
});
|
|
656
|
-
|
|
657
673
|
// but open state can change without us mutating it
|
|
658
674
|
// that's the only case for now so we don't need another kind of mutation state
|
|
659
675
|
var _useAsyncQueryState = useAsyncQueryState(isOpen(config)),
|
|
660
676
|
setResult = _useAsyncQueryState.setResult,
|
|
661
|
-
|
|
677
|
+
setLoading = _useAsyncQueryState.setLoading,
|
|
662
678
|
queryState = _useAsyncQueryState.state;
|
|
663
679
|
useEffect(function () {
|
|
664
680
|
var unsubscribe = watchWidgetVisibleState(config, {
|
|
665
681
|
onChange: function onChange(isVisible) {
|
|
666
682
|
setResult(isVisible);
|
|
667
683
|
},
|
|
668
|
-
onIsLoadingChange:
|
|
669
|
-
if (isLoading) {
|
|
670
|
-
startLoading();
|
|
671
|
-
}
|
|
672
|
-
}
|
|
684
|
+
onIsLoadingChange: setLoading
|
|
673
685
|
});
|
|
674
686
|
return unsubscribe;
|
|
675
|
-
}, [config, setResult,
|
|
687
|
+
}, [config, setResult, setLoading]);
|
|
676
688
|
return _objectSpread2(_objectSpread2({}, queryState.data === undefined ? mutationState : {
|
|
677
689
|
error: queryState.error,
|
|
678
690
|
isPending: queryState.isLoading,
|
|
@@ -681,7 +693,7 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
681
693
|
isIdle: !queryState.isError && !queryState.isLoading && !queryState.isSuccess,
|
|
682
694
|
data: queryState.data
|
|
683
695
|
}), {}, {
|
|
684
|
-
|
|
696
|
+
openWidget: mutationState.openWidget
|
|
685
697
|
});
|
|
686
698
|
};
|
|
687
699
|
|
|
@@ -709,7 +721,7 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
709
721
|
*
|
|
710
722
|
* const MyComponent = () => {
|
|
711
723
|
*
|
|
712
|
-
* const {
|
|
724
|
+
* const { getTxAuthDataSignature } = useGetTxAuthDataSignature();
|
|
713
725
|
* const walletClient = useWalletClient();
|
|
714
726
|
* const publicClient = usePublicClient();
|
|
715
727
|
*
|
|
@@ -766,7 +778,7 @@ var useOpenWidget = function useOpenWidget(loginParams) {
|
|
|
766
778
|
* import { RpcClient } from "@taquito/rpc";
|
|
767
779
|
*
|
|
768
780
|
* const MyComponent = () => {
|
|
769
|
-
* const {
|
|
781
|
+
* const { getTxAuthDataSignature } = useGetTxAuthDataSignature();
|
|
770
782
|
* const wallet = useWallet();
|
|
771
783
|
*
|
|
772
784
|
* const signAndSend = async () => {
|
|
@@ -864,39 +876,53 @@ var useGetTxAuthDataSignature = function useGetTxAuthDataSignature() {
|
|
|
864
876
|
};
|
|
865
877
|
}(), [config._internal.widgetStateStore, config._internal.identifier]);
|
|
866
878
|
return useAsyncMutationState({
|
|
879
|
+
mutationName: "getTxAuthDataSignature",
|
|
867
880
|
mutationFn: mutationFn
|
|
868
881
|
});
|
|
869
882
|
};
|
|
870
883
|
|
|
871
884
|
/**
|
|
872
|
-
* A hook that returns
|
|
885
|
+
* A hook that returns a function that authenticates the user without opening the ComPilot ID widget.
|
|
886
|
+
* This will authenticate the user only if they are not already authenticated.
|
|
873
887
|
*
|
|
874
|
-
* @
|
|
888
|
+
* @param loginParams - The login parameters to use when authenticating the user.
|
|
875
889
|
*
|
|
876
|
-
* @
|
|
890
|
+
* @returns The async mutation state of the authentication.
|
|
877
891
|
*/
|
|
878
|
-
var
|
|
892
|
+
var useAuthenticate = function useAuthenticate(loginParams) {
|
|
879
893
|
var config = useComPilotConfig();
|
|
894
|
+
var mutationFn = useCallback(function () {
|
|
895
|
+
return authenticate(config, loginParams);
|
|
896
|
+
}, [config]);
|
|
897
|
+
var mutationState = useAsyncMutationState({
|
|
898
|
+
mutationName: "authenticate",
|
|
899
|
+
mutationFn: mutationFn
|
|
900
|
+
});
|
|
880
901
|
var _useAsyncQueryState = useAsyncQueryState(isAuthenticated(config)),
|
|
881
|
-
|
|
902
|
+
queryState = _useAsyncQueryState.state,
|
|
882
903
|
setResult = _useAsyncQueryState.setResult,
|
|
883
|
-
|
|
904
|
+
setLoading = _useAsyncQueryState.setLoading;
|
|
884
905
|
useEffect(function () {
|
|
885
906
|
var unsubscribe = watchIsAuthenticated(config, {
|
|
886
907
|
onIsAuthenticatedChange: function onIsAuthenticatedChange(isAuthenticated) {
|
|
887
908
|
setResult(isAuthenticated);
|
|
888
909
|
},
|
|
889
|
-
onIsLoadingChange:
|
|
890
|
-
if (isLoading) {
|
|
891
|
-
startLoading();
|
|
892
|
-
}
|
|
893
|
-
}
|
|
910
|
+
onIsLoadingChange: setLoading
|
|
894
911
|
});
|
|
895
912
|
return function () {
|
|
896
913
|
unsubscribe();
|
|
897
914
|
};
|
|
898
915
|
}, [config._internal.widgetStateStore, config._internal.identifier]);
|
|
899
|
-
return
|
|
916
|
+
return _objectSpread2(_objectSpread2({}, queryState.data === undefined ? mutationState : {
|
|
917
|
+
error: queryState.error,
|
|
918
|
+
isPending: queryState.isLoading,
|
|
919
|
+
isSuccess: queryState.isSuccess,
|
|
920
|
+
isError: queryState.isError,
|
|
921
|
+
isIdle: !queryState.isError && !queryState.isLoading && !queryState.isSuccess,
|
|
922
|
+
data: queryState.data
|
|
923
|
+
}), {}, {
|
|
924
|
+
authenticate: mutationState.authenticate
|
|
925
|
+
});
|
|
900
926
|
};
|
|
901
927
|
|
|
902
928
|
/**
|
|
@@ -980,7 +1006,7 @@ var useCustomerStatus = function useCustomerStatus() {
|
|
|
980
1006
|
* import { useDisconnect } from "@compilot/react-sdk";
|
|
981
1007
|
*
|
|
982
1008
|
* const Logout = () => {
|
|
983
|
-
* const {
|
|
1009
|
+
* const { disconnect, isLoading } = useDisconnect();
|
|
984
1010
|
*
|
|
985
1011
|
* return (
|
|
986
1012
|
* <button
|
|
@@ -999,8 +1025,9 @@ var useDisconnect = function useDisconnect() {
|
|
|
999
1025
|
return disconnect(config);
|
|
1000
1026
|
}, [config]);
|
|
1001
1027
|
return useAsyncMutationState({
|
|
1028
|
+
mutationName: "disconnect",
|
|
1002
1029
|
mutationFn: mutationFn
|
|
1003
1030
|
});
|
|
1004
1031
|
};
|
|
1005
1032
|
|
|
1006
|
-
export { ComPilotProvider, useComPilotConfig, useCustomerStatus, useDisconnect, useGetTxAuthDataSignature,
|
|
1033
|
+
export { ComPilotProvider, useAuthenticate, useComPilotConfig, useCustomerStatus, useDisconnect, useGetTxAuthDataSignature, useOpenWidget };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./useOpenWidget.js";
|
|
2
2
|
export * from "./useGetTxAuthDataSignature.js";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./useAuthenticate.js";
|
|
4
4
|
export * from "./useCustomerStatus.js";
|
|
5
5
|
export * from "./useDisconnect.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/hooks","sources":["index.ts"],"names":[],"mappings":"AAAA,mCAAgC;AAChC,+CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../src/hooks","sources":["index.ts"],"names":[],"mappings":"AAAA,mCAAgC;AAChC,+CAA4C;AAC5C,qCAAkC;AAClC,uCAAoC;AACpC,mCAAgC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LoginParams } from "@compilot/web-sdk";
|
|
2
|
+
import type { AsyncMutationState } from "../utils/useAsyncMutationState.js";
|
|
3
|
+
/**
|
|
4
|
+
* A hook that returns a function that authenticates the user without opening the ComPilot ID widget.
|
|
5
|
+
* This will authenticate the user only if they are not already authenticated.
|
|
6
|
+
*
|
|
7
|
+
* @param loginParams - The login parameters to use when authenticating the user.
|
|
8
|
+
*
|
|
9
|
+
* @returns The async mutation state of the authentication.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useAuthenticate: (loginParams?: LoginParams) => AsyncMutationState<() => Promise<boolean>, "authenticate">;
|
|
12
|
+
//# sourceMappingURL=useAuthenticate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuthenticate.d.ts","sourceRoot":"../../../../src/hooks","sources":["useAuthenticate.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EACV,kBAAkB,EAEnB,0CAAuC;AAIxC;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,iBACZ,WAAW,KACxB,kBAAkB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,CAgD3D,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AsyncMutationState } from "../utils/useAsyncMutationState.js";
|
|
2
1
|
/**
|
|
3
2
|
* A hook that returns a function that disconnects the ComPilot SDK.
|
|
4
3
|
*
|
|
@@ -11,7 +10,7 @@ import type { AsyncMutationState } from "../utils/useAsyncMutationState.js";
|
|
|
11
10
|
* import { useDisconnect } from "@compilot/react-sdk";
|
|
12
11
|
*
|
|
13
12
|
* const Logout = () => {
|
|
14
|
-
* const {
|
|
13
|
+
* const { disconnect, isLoading } = useDisconnect();
|
|
15
14
|
*
|
|
16
15
|
* return (
|
|
17
16
|
* <button
|
|
@@ -24,5 +23,5 @@ import type { AsyncMutationState } from "../utils/useAsyncMutationState.js";
|
|
|
24
23
|
* };
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
|
-
export declare const useDisconnect: () => AsyncMutationState<() => Promise<boolean
|
|
26
|
+
export declare const useDisconnect: () => import("../utils/useAsyncMutationState.js").AsyncMutationState<() => Promise<boolean>, "disconnect">;
|
|
28
27
|
//# sourceMappingURL=useDisconnect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDisconnect.d.ts","sourceRoot":"../../../../src/hooks","sources":["useDisconnect.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDisconnect.d.ts","sourceRoot":"../../../../src/hooks","sources":["useDisconnect.tsx"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,aAAa,4GASzB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ExtendedTezosTxAuthDataSignatureResponse, ExtendedTezosTxAuthInput, ExtendedTxAuthDataSignatureResponse, ExtendedTxAuthInput } from "@nexeraid/identity-schemas";
|
|
2
|
-
import type { AsyncMutationState } from "../utils/useAsyncMutationState.js";
|
|
3
2
|
/**
|
|
4
3
|
* A callback that returns a transaction authorization data signature.
|
|
5
4
|
*
|
|
@@ -33,7 +32,7 @@ export type TxAuthDataSignatureCallback = {
|
|
|
33
32
|
*
|
|
34
33
|
* const MyComponent = () => {
|
|
35
34
|
*
|
|
36
|
-
* const {
|
|
35
|
+
* const { getTxAuthDataSignature } = useGetTxAuthDataSignature();
|
|
37
36
|
* const walletClient = useWalletClient();
|
|
38
37
|
* const publicClient = usePublicClient();
|
|
39
38
|
*
|
|
@@ -90,7 +89,7 @@ export type TxAuthDataSignatureCallback = {
|
|
|
90
89
|
* import { RpcClient } from "@taquito/rpc";
|
|
91
90
|
*
|
|
92
91
|
* const MyComponent = () => {
|
|
93
|
-
* const {
|
|
92
|
+
* const { getTxAuthDataSignature } = useGetTxAuthDataSignature();
|
|
94
93
|
* const wallet = useWallet();
|
|
95
94
|
*
|
|
96
95
|
* const signAndSend = async () => {
|
|
@@ -164,5 +163,5 @@ export type TxAuthDataSignatureCallback = {
|
|
|
164
163
|
* ```
|
|
165
164
|
*
|
|
166
165
|
*/
|
|
167
|
-
export declare const useGetTxAuthDataSignature: () => AsyncMutationState<TxAuthDataSignatureCallback>;
|
|
166
|
+
export declare const useGetTxAuthDataSignature: () => import("../utils/useAsyncMutationState.js").AsyncMutationState<TxAuthDataSignatureCallback, "getTxAuthDataSignature">;
|
|
168
167
|
//# sourceMappingURL=useGetTxAuthDataSignature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTxAuthDataSignature.d.ts","sourceRoot":"../../../../src/hooks","sources":["useGetTxAuthDataSignature.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,wCAAwC,EACxC,wBAAwB,EACxB,mCAAmC,EACnC,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"useGetTxAuthDataSignature.d.ts","sourceRoot":"../../../../src/hooks","sources":["useGetTxAuthDataSignature.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,wCAAwC,EACxC,wBAAwB,EACxB,mCAAmC,EACnC,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAKpC;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC;;OAEG;IACH,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;IAC3E;;OAEG;IACH,CACE,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,wCAAwC,CAAC,CAAC;CACtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoJG;AACH,eAAO,MAAM,yBAAyB,6HAerC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LoginParams } from "@compilot/web-sdk";
|
|
2
|
+
import type { AsyncMutationState } from "../utils/useAsyncMutationState.js";
|
|
2
3
|
/**
|
|
3
4
|
* A hook that returns a function that opens the ComPilot ID widget.
|
|
4
5
|
*
|
|
@@ -7,45 +8,5 @@ import type { LoginParams } from "@compilot/web-sdk";
|
|
|
7
8
|
*
|
|
8
9
|
* @category Hook
|
|
9
10
|
*/
|
|
10
|
-
export declare const useOpenWidget: (loginParams?: LoginParams) =>
|
|
11
|
-
mutateAsync: () => Promise<void>;
|
|
12
|
-
data: undefined;
|
|
13
|
-
isIdle: true;
|
|
14
|
-
isPending: false;
|
|
15
|
-
isError: false;
|
|
16
|
-
isSuccess: false;
|
|
17
|
-
error: null;
|
|
18
|
-
} | {
|
|
19
|
-
mutateAsync: () => Promise<void>;
|
|
20
|
-
data: void;
|
|
21
|
-
isIdle: false;
|
|
22
|
-
isPending: false;
|
|
23
|
-
isError: false;
|
|
24
|
-
isSuccess: true;
|
|
25
|
-
error: null;
|
|
26
|
-
} | {
|
|
27
|
-
mutateAsync: () => Promise<void>;
|
|
28
|
-
data: undefined;
|
|
29
|
-
isIdle: false;
|
|
30
|
-
isPending: true;
|
|
31
|
-
isError: false;
|
|
32
|
-
isSuccess: false;
|
|
33
|
-
error: null;
|
|
34
|
-
} | {
|
|
35
|
-
mutateAsync: () => Promise<void>;
|
|
36
|
-
data: void | undefined;
|
|
37
|
-
isIdle: false;
|
|
38
|
-
isPending: false;
|
|
39
|
-
isError: true;
|
|
40
|
-
isSuccess: false;
|
|
41
|
-
error: Error;
|
|
42
|
-
} | {
|
|
43
|
-
mutateAsync: () => Promise<void>;
|
|
44
|
-
error: null;
|
|
45
|
-
isPending: false;
|
|
46
|
-
isSuccess: true;
|
|
47
|
-
isError: false;
|
|
48
|
-
isIdle: false;
|
|
49
|
-
data: boolean;
|
|
50
|
-
};
|
|
11
|
+
export declare const useOpenWidget: (loginParams?: LoginParams) => AsyncMutationState<() => Promise<boolean>, "openWidget">;
|
|
51
12
|
//# sourceMappingURL=useOpenWidget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOpenWidget.d.ts","sourceRoot":"../../../../src/hooks","sources":["useOpenWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"useOpenWidget.d.ts","sourceRoot":"../../../../src/hooks","sources":["useOpenWidget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EACV,kBAAkB,EAEnB,0CAAuC;AAIxC;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,iBACV,WAAW,KACxB,kBAAkB,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,YAAY,CA8CzD,CAAC"}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
type AnyMutation = (...args: any[]) => Promise<any>;
|
|
2
|
-
|
|
2
|
+
type IdleAsyncMutationState = {
|
|
3
3
|
data: undefined;
|
|
4
4
|
isIdle: true;
|
|
5
5
|
isPending: false;
|
|
6
6
|
isError: false;
|
|
7
7
|
isSuccess: false;
|
|
8
8
|
error: null;
|
|
9
|
-
mutateAsync: T;
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
data: Awaited<ReturnType<
|
|
10
|
+
type SuccessAsyncMutationState<TMutationFn extends AnyMutation> = {
|
|
11
|
+
data: Awaited<ReturnType<TMutationFn>>;
|
|
13
12
|
isIdle: false;
|
|
14
13
|
isPending: false;
|
|
15
14
|
isError: false;
|
|
16
15
|
isSuccess: true;
|
|
17
16
|
error: null;
|
|
18
|
-
mutateAsync: T;
|
|
19
17
|
};
|
|
20
|
-
|
|
18
|
+
type LoadingAsyncMutationState = {
|
|
21
19
|
data: undefined;
|
|
22
20
|
isIdle: false;
|
|
23
21
|
isPending: true;
|
|
24
22
|
isError: false;
|
|
25
23
|
isSuccess: false;
|
|
26
24
|
error: null;
|
|
27
|
-
mutateAsync: T;
|
|
28
25
|
};
|
|
29
|
-
|
|
30
|
-
data: Awaited<ReturnType<
|
|
26
|
+
type ErrorAsyncMutationState<TMutationFn extends AnyMutation> = {
|
|
27
|
+
data: Awaited<ReturnType<TMutationFn>> | undefined;
|
|
31
28
|
isIdle: false;
|
|
32
29
|
isPending: false;
|
|
33
30
|
isError: true;
|
|
34
31
|
isSuccess: false;
|
|
35
32
|
error: Error;
|
|
36
|
-
mutateAsync: T;
|
|
37
33
|
};
|
|
38
|
-
export type
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
}
|
|
34
|
+
export type RawAsyncMutationState<TMutationFn extends AnyMutation> = IdleAsyncMutationState | SuccessAsyncMutationState<TMutationFn> | LoadingAsyncMutationState | ErrorAsyncMutationState<TMutationFn>;
|
|
35
|
+
export type AsyncMutationState<TMutationFn extends AnyMutation, TMutationName extends string> = RawAsyncMutationState<TMutationFn> & {
|
|
36
|
+
[k in TMutationName]: TMutationFn;
|
|
37
|
+
};
|
|
38
|
+
export declare const useAsyncMutationState: <TMutationFn extends AnyMutation, TMutationName extends string>({ mutationName, mutationFn, }: {
|
|
39
|
+
mutationName: TMutationName;
|
|
40
|
+
mutationFn: TMutationFn;
|
|
41
|
+
}) => AsyncMutationState<TMutationFn, TMutationName>;
|
|
42
42
|
export {};
|
|
43
43
|
//# sourceMappingURL=useAsyncMutationState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsyncMutationState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncMutationState.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpD,
|
|
1
|
+
{"version":3,"file":"useAsyncMutationState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncMutationState.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEpD,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,yBAAyB,CAAC,WAAW,SAAS,WAAW,IAAI;IAChE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,KAAK,uBAAuB,CAAC,WAAW,SAAS,WAAW,IAAI;IAC9D,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,GAAG,SAAS,CAAC;IACnD,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,WAAW,SAAS,WAAW,IAC7D,sBAAsB,GACtB,yBAAyB,CAAC,WAAW,CAAC,GACtC,yBAAyB,GACzB,uBAAuB,CAAC,WAAW,CAAC,CAAC;AAEzC,MAAM,MAAM,kBAAkB,CAC5B,WAAW,SAAS,WAAW,EAC/B,aAAa,SAAS,MAAM,IAC1B,qBAAqB,CAAC,WAAW,CAAC,GAAG;KACtC,CAAC,IAAI,aAAa,GAAG,WAAW;CAClC,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,WAAW,SAAS,WAAW,EAC/B,aAAa,SAAS,MAAM,iCAI3B;IACD,YAAY,EAAE,aAAa,CAAC;IAC5B,UAAU,EAAE,WAAW,CAAC;CACzB,KAAG,kBAAkB,CAAC,WAAW,EAAE,aAAa,CAsDhD,CAAC"}
|
|
@@ -32,5 +32,7 @@ export declare const useAsyncQueryState: <T>(defaultValue?: T) => {
|
|
|
32
32
|
setResult: (result: T) => void;
|
|
33
33
|
setError: (error: Error) => void;
|
|
34
34
|
startLoading: () => void;
|
|
35
|
+
stopLoading: () => void;
|
|
36
|
+
setLoading: (isLoading: boolean) => void;
|
|
35
37
|
};
|
|
36
38
|
//# sourceMappingURL=useAsyncQueryState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsyncQueryState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncQueryState.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,IACzB,sBAAsB,GACtB,sBAAsB,CAAC,CAAC,CAAC,GACzB,sBAAsB,GACtB,oBAAoB,CAAC;AAEzB,eAAO,MAAM,kBAAkB,GAAI,CAAC,iBAAiB,CAAC;;wBAoBzC,CAAC;sBAaF,KAAK
|
|
1
|
+
{"version":3,"file":"useAsyncQueryState.d.ts","sourceRoot":"../../../../src/utils","sources":["useAsyncQueryState.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,IACzB,sBAAsB,GACtB,sBAAsB,CAAC,CAAC,CAAC,GACzB,sBAAsB,GACtB,oBAAoB,CAAC;AAEzB,eAAO,MAAM,kBAAkB,GAAI,CAAC,iBAAiB,CAAC;;wBAoBzC,CAAC;sBAaF,KAAK;;;4BAiCD,OAAO;CAkBtB,CAAC"}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compilot/react-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.53-dev",
|
|
4
4
|
"description": "ComPilot React SDK",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "ISC",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"pino": "^9.4.0",
|
|
28
28
|
"zod": "^3.23.8",
|
|
29
|
-
"@compilot/web-sdk": "2.0.
|
|
29
|
+
"@compilot/web-sdk": "2.0.46-dev",
|
|
30
|
+
"@nexeraid/identity-schemas": "1.12.42-dev",
|
|
30
31
|
"@nexeraid/identity-api-client": "1.3.215-dev",
|
|
31
|
-
"@nexeraid/identity-schemas": "1.12.40-dev",
|
|
32
32
|
"@nexeraid/logger": "0.1.2-dev"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AsyncQueryState } from "../utils/useAsyncQueryState.js";
|
|
2
|
-
/**
|
|
3
|
-
* A hook that returns whether the user is authenticated.
|
|
4
|
-
*
|
|
5
|
-
* @returns Whether the user is authenticated or not.
|
|
6
|
-
*
|
|
7
|
-
* @category Hook
|
|
8
|
-
*/
|
|
9
|
-
export declare const useIsAuthenticated: () => AsyncQueryState<boolean>;
|
|
10
|
-
//# sourceMappingURL=useIsAuthenticated.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useIsAuthenticated.d.ts","sourceRoot":"../../../../src/hooks","sources":["useIsAuthenticated.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAoC;AAGnE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QAAO,eAAe,CAAC,OAAO,CAyB5D,CAAC"}
|