@dubsdotapp/expo 0.2.19 → 0.2.21

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
@@ -490,7 +490,7 @@ function createSecureStoreStorage() {
490
490
 
491
491
  // src/provider.tsx
492
492
  import { createContext as createContext3, useContext as useContext3, useMemo, useCallback as useCallback12, useState as useState12, useEffect as useEffect7 } from "react";
493
- import { Connection } from "@solana/web3.js";
493
+ import { Connection as Connection2 } from "@solana/web3.js";
494
494
 
495
495
  // src/managed-wallet.tsx
496
496
  import { createContext, useContext, useState, useEffect, useRef, useCallback } from "react";
@@ -907,38 +907,6 @@ var PhantomDeeplinkAdapter = class {
907
907
  console.log(TAG2, "Decrypted signed transaction, length:", data.transaction?.length);
908
908
  return Transaction2.from(bs582.decode(data.transaction));
909
909
  }
910
- async signAndSendTransaction(transaction) {
911
- this.assertConnected();
912
- console.log(TAG2, "signAndSendTransaction() \u2014 serializing transaction");
913
- const serializedTx = bs582.encode(
914
- transaction.serialize({ requireAllSignatures: false, verifySignatures: false })
915
- );
916
- console.log(TAG2, "Transaction serialized, length:", serializedTx.length);
917
- const { nonce, ciphertext } = encryptPayload(
918
- { transaction: serializedTx, session: this._sessionToken },
919
- this._sharedSecret
920
- );
921
- const requestId = nextRequestId();
922
- const redirectLink = this.config.redirectUri;
923
- console.log(TAG2, `signAndSendTransaction() requestId=${requestId}`);
924
- const params = new URLSearchParams({
925
- dapp_encryption_public_key: bs582.encode(this._dappKeyPair.publicKey),
926
- nonce,
927
- payload: ciphertext,
928
- redirect_link: redirectLink
929
- });
930
- const url = `https://phantom.app/ul/v1/signAndSendTransaction?${params.toString()}`;
931
- console.log(TAG2, "Opening Phantom signAndSendTransaction deeplink...");
932
- const response = await this.handler.send(url, requestId, this.timeout);
933
- console.log(TAG2, "Received signAndSendTransaction response");
934
- const data = decryptPayload(
935
- response.params.data,
936
- response.params.nonce,
937
- this._sharedSecret
938
- );
939
- console.log(TAG2, "Transaction sent! Signature:", data.signature);
940
- return data.signature;
941
- }
942
910
  async signMessage(message) {
943
911
  this.assertConnected();
944
912
  console.log(TAG2, "signMessage() \u2014 message length:", message.length);
@@ -1270,12 +1238,23 @@ function ManagedWalletProvider({
1270
1238
  }
1271
1239
  return;
1272
1240
  }
1273
- console.log(TAG3, "Phantom path \u2014 clearing any saved session, will require fresh connect");
1274
- await storage.deleteItem(STORAGE_KEYS.PHANTOM_SESSION).catch(() => {
1275
- });
1276
1241
  try {
1242
+ const savedSession = await storage.getItem(STORAGE_KEYS.PHANTOM_SESSION);
1243
+ if (savedSession && !cancelled) {
1244
+ const session = JSON.parse(savedSession);
1245
+ console.log(TAG3, "Found saved Phantom session, restoring for wallet:", session.walletPublicKey);
1246
+ phantom.restoreSession(session);
1247
+ if (!cancelled) {
1248
+ console.log(TAG3, "Phantom reconnected from saved session");
1249
+ setConnected(true);
1250
+ }
1251
+ } else {
1252
+ console.log(TAG3, "No saved Phantom session");
1253
+ }
1277
1254
  } catch (err) {
1278
- console.log(TAG3, "Unexpected error during Phantom init:", err instanceof Error ? err.message : err);
1255
+ console.log(TAG3, "Phantom session restore failed:", err instanceof Error ? err.message : err);
1256
+ await storage.deleteItem(STORAGE_KEYS.PHANTOM_SESSION).catch(() => {
1257
+ });
1279
1258
  } finally {
1280
1259
  if (!cancelled) {
1281
1260
  console.log(TAG3, "Phantom init complete, marking ready");
@@ -1390,7 +1369,7 @@ import {
1390
1369
  StyleSheet as StyleSheet2,
1391
1370
  Keyboard,
1392
1371
  KeyboardAvoidingView,
1393
- Platform as Platform2,
1372
+ Platform as Platform3,
1394
1373
  Image as Image2,
1395
1374
  Animated,
1396
1375
  ScrollView
@@ -1505,7 +1484,7 @@ import { useState as useState6, useCallback as useCallback6 } from "react";
1505
1484
 
1506
1485
  // src/utils/transaction.ts
1507
1486
  import { Transaction as Transaction3 } from "@solana/web3.js";
1508
- async function signAndSendBase64Transaction(base64Tx, wallet) {
1487
+ async function signAndSendBase64Transaction(base64Tx, wallet, connection) {
1509
1488
  if (!wallet.publicKey) throw new Error("Wallet not connected");
1510
1489
  const binaryStr = atob(base64Tx);
1511
1490
  const bytes = new Uint8Array(binaryStr.length);
@@ -1516,12 +1495,14 @@ async function signAndSendBase64Transaction(base64Tx, wallet) {
1516
1495
  if (wallet.signAndSendTransaction) {
1517
1496
  return wallet.signAndSendTransaction(transaction);
1518
1497
  }
1519
- throw new Error("Wallet does not support signAndSendTransaction");
1498
+ const signed = await wallet.signTransaction(transaction);
1499
+ const signature = await connection.sendRawTransaction(signed.serialize());
1500
+ return signature;
1520
1501
  }
1521
1502
 
1522
1503
  // src/hooks/useCreateGame.ts
1523
1504
  function useCreateGame() {
1524
- const { client, wallet } = useDubs();
1505
+ const { client, wallet, connection } = useDubs();
1525
1506
  const [status, setStatus] = useState6("idle");
1526
1507
  const [error, setError] = useState6(null);
1527
1508
  const [data, setData] = useState6(null);
@@ -1542,7 +1523,8 @@ function useCreateGame() {
1542
1523
  console.log("[useCreateGame] Step 2: Signing and sending...");
1543
1524
  const signature = await signAndSendBase64Transaction(
1544
1525
  createResult.transaction,
1545
- wallet
1526
+ wallet,
1527
+ connection
1546
1528
  );
1547
1529
  console.log("[useCreateGame] Step 2 done. Signature:", signature);
1548
1530
  setStatus("confirming");
@@ -1582,7 +1564,7 @@ function useCreateGame() {
1582
1564
  // src/hooks/useJoinGame.ts
1583
1565
  import { useState as useState7, useCallback as useCallback7 } from "react";
1584
1566
  function useJoinGame() {
1585
- const { client, wallet } = useDubs();
1567
+ const { client, wallet, connection } = useDubs();
1586
1568
  const [status, setStatus] = useState7("idle");
1587
1569
  const [error, setError] = useState7(null);
1588
1570
  const [data, setData] = useState7(null);
@@ -1603,7 +1585,8 @@ function useJoinGame() {
1603
1585
  console.log("[useJoinGame] Step 2: Signing and sending transaction...");
1604
1586
  const signature = await signAndSendBase64Transaction(
1605
1587
  joinResult.transaction,
1606
- wallet
1588
+ wallet,
1589
+ connection
1607
1590
  );
1608
1591
  console.log("[useJoinGame] Step 2 done. Signature:", signature);
1609
1592
  setStatus("confirming");
@@ -1644,7 +1627,7 @@ function useJoinGame() {
1644
1627
  // src/hooks/useClaim.ts
1645
1628
  import { useState as useState8, useCallback as useCallback8 } from "react";
1646
1629
  function useClaim() {
1647
- const { client, wallet } = useDubs();
1630
+ const { client, wallet, connection } = useDubs();
1648
1631
  const [status, setStatus] = useState8("idle");
1649
1632
  const [error, setError] = useState8(null);
1650
1633
  const [data, setData] = useState8(null);
@@ -1665,7 +1648,8 @@ function useClaim() {
1665
1648
  console.log("[useClaim] Step 2: Signing and sending...");
1666
1649
  const signature = await signAndSendBase64Transaction(
1667
1650
  claimResult.transaction,
1668
- wallet
1651
+ wallet,
1652
+ connection
1669
1653
  );
1670
1654
  console.log("[useClaim] Step 2 done. Signature:", signature);
1671
1655
  const explorerUrl = `https://solscan.io/tx/${signature}`;
@@ -1692,7 +1676,7 @@ function useClaim() {
1692
1676
  // src/hooks/useCreateCustomGame.ts
1693
1677
  import { useState as useState9, useCallback as useCallback9 } from "react";
1694
1678
  function useCreateCustomGame() {
1695
- const { client, wallet } = useDubs();
1679
+ const { client, wallet, connection } = useDubs();
1696
1680
  const [status, setStatus] = useState9("idle");
1697
1681
  const [error, setError] = useState9(null);
1698
1682
  const [data, setData] = useState9(null);
@@ -1713,7 +1697,8 @@ function useCreateCustomGame() {
1713
1697
  console.log("[useCreateCustomGame] Step 2: Signing and sending...");
1714
1698
  const signature = await signAndSendBase64Transaction(
1715
1699
  createResult.transaction,
1716
- wallet
1700
+ wallet,
1701
+ connection
1717
1702
  );
1718
1703
  console.log("[useCreateCustomGame] Step 2 done. Signature:", signature);
1719
1704
  setStatus("confirming");
@@ -1759,6 +1744,45 @@ import bs583 from "bs58";
1759
1744
  import { createContext as createContext2 } from "react";
1760
1745
  var AuthContext = createContext2(null);
1761
1746
 
1747
+ // src/utils/device.ts
1748
+ import { Platform as Platform2 } from "react-native";
1749
+ async function getDeviceInfo() {
1750
+ try {
1751
+ const Device = __require("expo-device");
1752
+ return {
1753
+ platform: Platform2.OS,
1754
+ modelName: Device.modelName,
1755
+ brand: Device.brand,
1756
+ manufacturer: Device.manufacturer,
1757
+ osName: Device.osName,
1758
+ osVersion: Device.osVersion,
1759
+ deviceType: Device.deviceType,
1760
+ deviceName: Device.deviceName,
1761
+ totalMemory: Device.totalMemory,
1762
+ modelId: Device.modelId,
1763
+ designName: Device.designName,
1764
+ productName: Device.productName,
1765
+ isDevice: Device.isDevice
1766
+ };
1767
+ } catch {
1768
+ return {
1769
+ platform: Platform2.OS,
1770
+ modelName: null,
1771
+ brand: null,
1772
+ manufacturer: null,
1773
+ osName: null,
1774
+ osVersion: null,
1775
+ deviceType: null,
1776
+ deviceName: null,
1777
+ totalMemory: null,
1778
+ modelId: null,
1779
+ designName: null,
1780
+ productName: null,
1781
+ isDevice: null
1782
+ };
1783
+ }
1784
+ }
1785
+
1762
1786
  // src/hooks/useAuth.ts
1763
1787
  function useAuth() {
1764
1788
  const sharedAuth = useContext2(AuthContext);
@@ -1787,15 +1811,17 @@ function useAuth() {
1787
1811
  setStatus("authenticating");
1788
1812
  setError(null);
1789
1813
  const walletAddress = wallet.publicKey.toBase58();
1814
+ const deviceInfo = await getDeviceInfo();
1815
+ console.log("[useAuth] Device info:", JSON.stringify(deviceInfo, null, 2));
1790
1816
  const { nonce, message } = await client.getNonce(walletAddress);
1791
1817
  setStatus("signing");
1792
1818
  const messageBytes = new TextEncoder().encode(message);
1793
1819
  const signatureBytes = await wallet.signMessage(messageBytes);
1794
1820
  const signature = bs583.encode(signatureBytes);
1795
1821
  setStatus("verifying");
1796
- const result = await client.authenticate({ walletAddress, signature, nonce });
1822
+ const result = await client.authenticate({ walletAddress, signature, nonce, deviceInfo });
1797
1823
  if (result.needsRegistration) {
1798
- pendingAuth.current = { walletAddress, nonce, signature };
1824
+ pendingAuth.current = { walletAddress, nonce, signature, deviceInfo };
1799
1825
  setStatus("needsRegistration");
1800
1826
  return;
1801
1827
  }
@@ -1821,7 +1847,8 @@ function useAuth() {
1821
1847
  nonce: pending.nonce,
1822
1848
  username,
1823
1849
  referralCode,
1824
- avatarUrl
1850
+ avatarUrl,
1851
+ deviceInfo: pending.deviceInfo
1825
1852
  });
1826
1853
  pendingAuth.current = null;
1827
1854
  const user2 = avatarUrl && !result.user.avatar ? { ...result.user, avatar: avatarUrl } : result.user;
@@ -2292,7 +2319,7 @@ function DefaultRegistrationScreen({
2292
2319
  KeyboardAvoidingView,
2293
2320
  {
2294
2321
  style: [s.container, { backgroundColor: t.background }],
2295
- behavior: Platform2.OS === "ios" ? "padding" : void 0,
2322
+ behavior: Platform3.OS === "ios" ? "padding" : void 0,
2296
2323
  children: /* @__PURE__ */ jsx3(
2297
2324
  ScrollView,
2298
2325
  {
@@ -2402,7 +2429,7 @@ function DubsProvider({
2402
2429
  const rpcUrl = rpcUrlOverride || config.rpcUrl;
2403
2430
  const cluster = config.cluster;
2404
2431
  const client = useMemo(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
2405
- const connection = useMemo(() => new Connection(rpcUrl, { commitment: "confirmed" }), [rpcUrl]);
2432
+ const connection = useMemo(() => new Connection2(rpcUrl, { commitment: "confirmed" }), [rpcUrl]);
2406
2433
  const storage = useMemo(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
2407
2434
  const [uiConfig, setUiConfig] = useState12(null);
2408
2435
  useEffect7(() => {
@@ -3266,7 +3293,7 @@ import {
3266
3293
  Animated as Animated2,
3267
3294
  StyleSheet as StyleSheet10,
3268
3295
  KeyboardAvoidingView as KeyboardAvoidingView2,
3269
- Platform as Platform3
3296
+ Platform as Platform4
3270
3297
  } from "react-native";
3271
3298
  import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
3272
3299
  var STATUS_LABELS2 = {
@@ -3378,7 +3405,7 @@ function CreateCustomGameSheet({
3378
3405
  KeyboardAvoidingView2,
3379
3406
  {
3380
3407
  style: styles9.keyboardView,
3381
- behavior: Platform3.OS === "ios" ? "padding" : void 0,
3408
+ behavior: Platform4.OS === "ios" ? "padding" : void 0,
3382
3409
  children: /* @__PURE__ */ jsx12(View10, { style: styles9.sheetPositioner, children: /* @__PURE__ */ jsxs10(View10, { style: [styles9.sheet, { backgroundColor: t.background }], children: [
3383
3410
  /* @__PURE__ */ jsx12(View10, { style: styles9.handleRow, children: /* @__PURE__ */ jsx12(View10, { style: [styles9.handle, { backgroundColor: t.textMuted }] }) }),
3384
3411
  /* @__PURE__ */ jsxs10(View10, { style: styles9.header, children: [
@@ -3638,6 +3665,7 @@ export {
3638
3665
  SettingsSheet,
3639
3666
  UserProfileCard,
3640
3667
  createSecureStoreStorage,
3668
+ getDeviceInfo,
3641
3669
  mergeTheme,
3642
3670
  parseSolanaError,
3643
3671
  signAndSendBase64Transaction,