@cavos/kit 0.0.4 → 0.0.5

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.
@@ -1,4 +1,4 @@
1
- import { CavosAuth, PasskeySigner, HttpRecoveryClient, Cavos, generateRecoveryCode, CavosSolana, CavosStellar } from '../chunk-F2J25XSL.mjs';
1
+ import { CavosAuth, PasskeySigner, HttpRecoveryClient, Cavos, PasskeyPrf, generateRecoveryCode, CavosSolana } from '../chunk-M5BGBODC.mjs';
2
2
  import { createContext, useState, useRef, useEffect, useCallback, useContext } from 'react';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
 
@@ -1065,14 +1065,14 @@ function CavosProvider({ config, modal, children }) {
1065
1065
  const id = await auth.verifyOtp(email, code);
1066
1066
  await connect(id);
1067
1067
  }, [auth, connect]);
1068
- const execute = useCallback(async (calls) => {
1068
+ const execute = useCallback(async (calls, opts) => {
1069
1069
  if (!wallet) throw new Error("Not logged in");
1070
1070
  if (wallet.chain !== "starknet") {
1071
1071
  throw new Error(
1072
1072
  "kit: useCavos().execute(calls) is Starknet-only. On Solana/Stellar use the `wallet` handle: wallet.execute(amount, dest)."
1073
1073
  );
1074
1074
  }
1075
- return wallet.execute(calls);
1075
+ return wallet.execute(calls, opts);
1076
1076
  }, [wallet]);
1077
1077
  const addSigner = useCallback(
1078
1078
  async (pubkey) => {
@@ -1087,6 +1087,11 @@ function CavosProvider({ config, modal, children }) {
1087
1087
  const enrollPasskey = useCallback(
1088
1088
  async (passkey, params) => {
1089
1089
  if (!wallet) throw new Error("Not logged in");
1090
+ if (wallet.chain === "stellar") {
1091
+ throw new Error(
1092
+ "kit: on Stellar, use enrollPasskeyDefault() \u2014 the passkey factor is a WebAuthn PRF secret, not a signer object."
1093
+ );
1094
+ }
1090
1095
  return wallet.enrollPasskey(passkey, params);
1091
1096
  },
1092
1097
  [wallet]
@@ -1095,6 +1100,16 @@ function CavosProvider({ config, modal, children }) {
1095
1100
  const enrollPasskeyDefault = useCallback(async () => {
1096
1101
  if (!wallet || !identity) throw new Error("Not logged in");
1097
1102
  if (wallet.status !== "ready") throw new Error("kit: no ready device to enroll a passkey on");
1103
+ if (wallet.chain === "stellar") {
1104
+ const prf = new PasskeyPrf({ rpName });
1105
+ const { secret } = await prf.enroll({
1106
+ userId: identity.userId,
1107
+ userName: identity.email ?? identity.userId,
1108
+ ...identity.email ? { displayName: identity.email } : {}
1109
+ });
1110
+ await wallet.enrollPasskey(secret ?? await prf.getSecret());
1111
+ return;
1112
+ }
1098
1113
  const passkey = new PasskeySigner({ rpName });
1099
1114
  await wallet.enrollPasskey(passkey, {
1100
1115
  userId: identity.userId,
@@ -1108,10 +1123,14 @@ function CavosProvider({ config, modal, children }) {
1108
1123
  await connect(identity);
1109
1124
  return;
1110
1125
  }
1111
- const passkey = new PasskeySigner({ rpName });
1112
- if (wallet.chain === "starknet") {
1126
+ if (wallet.chain === "stellar") {
1127
+ const prf = new PasskeyPrf({ rpName });
1128
+ await wallet.approveThisDeviceWithPasskey(await prf.getSecret());
1129
+ } else if (wallet.chain === "starknet") {
1130
+ const passkey = new PasskeySigner({ rpName });
1113
1131
  await wallet.approveThisDeviceWithPasskey({ passkey });
1114
1132
  } else {
1133
+ const passkey = new PasskeySigner({ rpName });
1115
1134
  await wallet.approveThisDeviceWithPasskey(passkey);
1116
1135
  }
1117
1136
  setWalletStatus((s) => ({ ...s, isDeploying: true, needsDeviceApproval: false, awaitingApproval: false }));
@@ -1158,15 +1177,18 @@ function CavosProvider({ config, modal, children }) {
1158
1177
  ...cfg.rpcUrl ? { rpcUrl: cfg.rpcUrl } : {}
1159
1178
  });
1160
1179
  } else if (chain === "stellar") {
1161
- w = await CavosStellar.recover({
1162
- code,
1180
+ const sw = await Cavos.connect({
1181
+ chain: "stellar",
1182
+ network: cfg.network,
1163
1183
  identity,
1164
- network: cfg.network === "mainnet" ? "stellar-mainnet" : "stellar-testnet",
1165
1184
  appSalt: cfg.appSalt,
1166
1185
  ...cfg.appId ? { appId: cfg.appId } : {},
1167
- ...cfg.authBackendUrl ? { backendUrl: cfg.authBackendUrl } : {},
1168
- ...cfg.rpcUrl ? { rpcUrl: cfg.rpcUrl } : {}
1186
+ ...cfg.authBackendUrl ? { backendUrl: cfg.authBackendUrl } : {}
1169
1187
  });
1188
+ if (sw.chain === "stellar" && sw.status === "needs-device-approval") {
1189
+ await sw.approveThisDeviceWithRecovery(code);
1190
+ }
1191
+ w = sw;
1170
1192
  } else {
1171
1193
  w = await Cavos.recover({
1172
1194
  code,