@dubsdotapp/expo 0.2.46 → 0.2.47

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/index.mjs CHANGED
@@ -1317,6 +1317,32 @@ var styles = StyleSheet.create({
1317
1317
  // src/managed-wallet.tsx
1318
1318
  import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
1319
1319
  var TAG3 = "[Dubs:ManagedWallet]";
1320
+ function getDefaultRedirectUri() {
1321
+ if (Platform.OS !== "ios") return void 0;
1322
+ try {
1323
+ const expoLinking = __require("expo-linking");
1324
+ if (expoLinking.createURL) {
1325
+ const uri = expoLinking.createURL("phantom-callback");
1326
+ console.log(TAG3, "Auto-detected redirect URI via expo-linking:", uri);
1327
+ return uri;
1328
+ }
1329
+ } catch (e) {
1330
+ console.log(TAG3, "expo-linking createURL failed:", e instanceof Error ? e.message : e);
1331
+ }
1332
+ try {
1333
+ const Constants = __require("expo-constants").default;
1334
+ const scheme = Constants.expoConfig?.scheme;
1335
+ if (scheme) {
1336
+ const uri = `${scheme}://phantom-callback`;
1337
+ console.log(TAG3, "Auto-detected redirect URI via expo-constants:", uri);
1338
+ return uri;
1339
+ }
1340
+ } catch (e) {
1341
+ console.log(TAG3, "expo-constants fallback failed:", e instanceof Error ? e.message : e);
1342
+ }
1343
+ console.log(TAG3, "Could not auto-detect redirect URI on iOS \u2014 pass redirectUri to DubsProvider");
1344
+ return void 0;
1345
+ }
1320
1346
  var phantomSingleton = null;
1321
1347
  function getOrCreatePhantomAdapter(config) {
1322
1348
  if (!phantomSingleton) {
@@ -1363,14 +1389,20 @@ function ManagedWalletProvider({
1363
1389
  const [connecting, setConnecting] = useState(false);
1364
1390
  const [isReady, setIsReady] = useState(false);
1365
1391
  const [error, setError] = useState(null);
1366
- const usePhantom = Platform.OS === "ios" && !!redirectUri;
1367
- console.log(TAG3, `Platform: ${Platform.OS}, redirectUri: ${redirectUri ? "provided" : "not set"}, usePhantom: ${usePhantom}`);
1392
+ const usePhantom = Platform.OS === "ios";
1393
+ const resolvedRedirectUri = usePhantom ? redirectUri || getDefaultRedirectUri() : void 0;
1394
+ console.log(TAG3, `Platform: ${Platform.OS}, redirectUri: ${resolvedRedirectUri ?? "none"} (explicit: ${!!redirectUri}), usePhantom: ${usePhantom}`);
1368
1395
  const adapterRef = useRef(null);
1369
1396
  const transactRef = useRef(null);
1370
1397
  if (!adapterRef.current) {
1371
1398
  if (usePhantom) {
1399
+ if (!resolvedRedirectUri) {
1400
+ throw new Error(
1401
+ '@dubsdotapp/expo: Could not auto-detect redirect URI on iOS. Either set a "scheme" in your app.json or pass redirectUri to <DubsProvider>.'
1402
+ );
1403
+ }
1372
1404
  adapterRef.current = getOrCreatePhantomAdapter({
1373
- redirectUri,
1405
+ redirectUri: resolvedRedirectUri,
1374
1406
  appUrl,
1375
1407
  cluster,
1376
1408
  storage