@cavos/kit 0.0.1 → 0.0.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/README.md +113 -42
- package/dist/Cavos-C2KHZxxu.d.mts +590 -0
- package/dist/Cavos-C2KHZxxu.d.ts +590 -0
- package/dist/{chunk-XWBX2ZIO.mjs → chunk-PEUQQZB5.mjs} +690 -79
- package/dist/chunk-PEUQQZB5.mjs.map +1 -0
- package/dist/index.d.mts +36 -242
- package/dist/index.d.ts +36 -242
- package/dist/index.js +703 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react/index.d.mts +18 -5
- package/dist/react/index.d.ts +18 -5
- package/dist/react/index.js +718 -82
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +28 -7
- package/dist/react/index.mjs.map +1 -1
- package/package.json +2 -1
- package/dist/chunk-XWBX2ZIO.mjs.map +0 -1
- package/dist/constants-C530TZFF.d.mts +0 -89
- package/dist/constants-C530TZFF.d.ts +0 -89
package/dist/react/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CavosAuth, HttpRecoveryClient, Cavos, generateRecoveryCode } from '../chunk-
|
|
1
|
+
import { CavosAuth, HttpRecoveryClient, Cavos, generateRecoveryCode, CavosSolana } from '../chunk-PEUQQZB5.mjs';
|
|
2
2
|
import { createContext, useState, useRef, useEffect, useCallback, useContext } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
|
|
@@ -791,7 +791,7 @@ function CavosProvider({ config, modal, children }) {
|
|
|
791
791
|
const closeModal = useCallback(() => setModalOpen(false), []);
|
|
792
792
|
const clearAuthError = useCallback(() => setAuthError(null), []);
|
|
793
793
|
const resendDeviceApproval = useCallback(async () => {
|
|
794
|
-
if (!identity || !cavos || !cavos.pendingRequestId) return;
|
|
794
|
+
if (!identity || !cavos || cavos.chain !== "starknet" || !cavos.pendingRequestId) return;
|
|
795
795
|
const backendUrl = configRef.current.authBackendUrl ?? "https://cavos.xyz";
|
|
796
796
|
if (!configRef.current.appId) return;
|
|
797
797
|
const recovery = new HttpRecoveryClient({ baseUrl: backendUrl, appId: configRef.current.appId });
|
|
@@ -805,22 +805,24 @@ function CavosProvider({ config, modal, children }) {
|
|
|
805
805
|
const connect = useCallback(async (id) => {
|
|
806
806
|
setWalletStatus({ ...INITIAL_STATUS, isDeploying: true });
|
|
807
807
|
const c = await Cavos.connect({
|
|
808
|
+
chain: configRef.current.chain ?? "starknet",
|
|
808
809
|
network: configRef.current.network,
|
|
809
810
|
identity: id,
|
|
810
811
|
appSalt: configRef.current.appSalt,
|
|
811
|
-
paymasterApiKey: configRef.current.paymasterApiKey,
|
|
812
|
+
...configRef.current.paymasterApiKey ? { paymasterApiKey: configRef.current.paymasterApiKey } : {},
|
|
812
813
|
...configRef.current.appId ? { appId: configRef.current.appId } : {},
|
|
813
814
|
...configRef.current.authBackendUrl ? { backendUrl: configRef.current.authBackendUrl } : {},
|
|
814
815
|
...configRef.current.rpcUrl ? { rpcUrl: configRef.current.rpcUrl } : {}
|
|
815
816
|
});
|
|
816
817
|
setCavos(c);
|
|
817
818
|
setIdentity(id);
|
|
819
|
+
const pendingRequestId = c.chain === "starknet" ? c.pendingRequestId : null;
|
|
818
820
|
setWalletStatus({
|
|
819
821
|
isDeploying: false,
|
|
820
822
|
isReady: c.status === "ready",
|
|
821
823
|
needsDeviceApproval: c.status === "needs-device-approval",
|
|
822
|
-
awaitingApproval: c.status === "needs-device-approval" && !!
|
|
823
|
-
pendingRequestId
|
|
824
|
+
awaitingApproval: c.status === "needs-device-approval" && !!pendingRequestId,
|
|
825
|
+
pendingRequestId
|
|
824
826
|
});
|
|
825
827
|
modal?.onSuccess?.(c.address);
|
|
826
828
|
return c;
|
|
@@ -876,11 +878,19 @@ function CavosProvider({ config, modal, children }) {
|
|
|
876
878
|
}, [auth, connect]);
|
|
877
879
|
const execute = useCallback(async (calls) => {
|
|
878
880
|
if (!cavos) throw new Error("Not logged in");
|
|
881
|
+
if (cavos.chain !== "starknet") {
|
|
882
|
+
throw new Error(
|
|
883
|
+
"kit: useCavos().execute(calls) is Starknet-only. On Solana use the `wallet` handle: wallet.execute(amount, dest)."
|
|
884
|
+
);
|
|
885
|
+
}
|
|
879
886
|
return cavos.execute(calls);
|
|
880
887
|
}, [cavos]);
|
|
881
888
|
const addSigner = useCallback(
|
|
882
889
|
async (pubkey) => {
|
|
883
890
|
if (!cavos) throw new Error("Not logged in");
|
|
891
|
+
if (cavos.chain !== "starknet") {
|
|
892
|
+
throw new Error("kit: addSigner via useCavos() is Starknet-only; use the `wallet` handle on Solana.");
|
|
893
|
+
}
|
|
884
894
|
return cavos.addSigner(pubkey);
|
|
885
895
|
},
|
|
886
896
|
[cavos]
|
|
@@ -896,12 +906,21 @@ function CavosProvider({ config, modal, children }) {
|
|
|
896
906
|
setAuthError(null);
|
|
897
907
|
setWalletStatus({ ...INITIAL_STATUS, isDeploying: true });
|
|
898
908
|
try {
|
|
899
|
-
const
|
|
909
|
+
const chain = configRef.current.chain ?? "starknet";
|
|
910
|
+
const c = chain === "solana" ? await CavosSolana.recover({
|
|
911
|
+
code,
|
|
912
|
+
identity,
|
|
913
|
+
network: configRef.current.network === "mainnet" ? "solana-mainnet" : "solana-devnet",
|
|
914
|
+
appSalt: configRef.current.appSalt,
|
|
915
|
+
...configRef.current.appId ? { appId: configRef.current.appId } : {},
|
|
916
|
+
...configRef.current.authBackendUrl ? { backendUrl: configRef.current.authBackendUrl } : {},
|
|
917
|
+
...configRef.current.rpcUrl ? { rpcUrl: configRef.current.rpcUrl } : {}
|
|
918
|
+
}) : await Cavos.recover({
|
|
900
919
|
code,
|
|
901
920
|
identity,
|
|
902
921
|
network: configRef.current.network,
|
|
903
922
|
appSalt: configRef.current.appSalt,
|
|
904
|
-
paymasterApiKey: configRef.current.paymasterApiKey,
|
|
923
|
+
paymasterApiKey: configRef.current.paymasterApiKey ?? "",
|
|
905
924
|
...configRef.current.appId ? { appId: configRef.current.appId } : {},
|
|
906
925
|
...configRef.current.authBackendUrl ? { backendUrl: configRef.current.authBackendUrl } : {},
|
|
907
926
|
...configRef.current.rpcUrl ? { rpcUrl: configRef.current.rpcUrl } : {}
|
|
@@ -954,6 +973,8 @@ function CavosProvider({ config, modal, children }) {
|
|
|
954
973
|
closeModal,
|
|
955
974
|
isAuthenticated: !!cavos,
|
|
956
975
|
user: identity ? { userId: identity.userId, email: identity.email, provider: identity.provider } : null,
|
|
976
|
+
chain: config.chain ?? "starknet",
|
|
977
|
+
wallet: cavos,
|
|
957
978
|
address: cavos?.address ?? null,
|
|
958
979
|
walletStatus,
|
|
959
980
|
isLoading,
|