@dubsdotapp/expo 0.2.28 → 0.2.29
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.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +31 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/managed-wallet.tsx +17 -12
- package/src/storage.ts +1 -0
- package/src/wallet/mwa-adapter.ts +11 -0
package/dist/index.d.mts
CHANGED
|
@@ -428,6 +428,7 @@ interface TokenStorage {
|
|
|
428
428
|
}
|
|
429
429
|
declare const STORAGE_KEYS: {
|
|
430
430
|
readonly MWA_AUTH_TOKEN: "dubs_mwa_auth_token";
|
|
431
|
+
readonly MWA_WALLET_ADDRESS: "dubs_mwa_wallet_address";
|
|
431
432
|
readonly JWT_TOKEN: "dubs_jwt_token";
|
|
432
433
|
readonly PHANTOM_SESSION: "dubs_phantom_session";
|
|
433
434
|
readonly PHANTOM_CONNECT_IN_FLIGHT: "dubs_phantom_connect_in_flight";
|
|
@@ -576,6 +577,12 @@ declare class MwaWalletAdapter implements WalletAdapter {
|
|
|
576
577
|
get connected(): boolean;
|
|
577
578
|
get authToken(): string | null;
|
|
578
579
|
setAuthToken(token: string | null): void;
|
|
580
|
+
/**
|
|
581
|
+
* Restore a previous session silently (no wallet interaction).
|
|
582
|
+
* Sets the public key and auth token so the adapter appears connected.
|
|
583
|
+
* The next signing operation will reauthorize with Phantom.
|
|
584
|
+
*/
|
|
585
|
+
restoreSession(token: string, walletAddressBase58: string): void;
|
|
579
586
|
/**
|
|
580
587
|
* Connect to a mobile wallet. Call this before any signing.
|
|
581
588
|
* Tries reauthorize first (if we have a saved token), then falls back to
|
package/dist/index.d.ts
CHANGED
|
@@ -428,6 +428,7 @@ interface TokenStorage {
|
|
|
428
428
|
}
|
|
429
429
|
declare const STORAGE_KEYS: {
|
|
430
430
|
readonly MWA_AUTH_TOKEN: "dubs_mwa_auth_token";
|
|
431
|
+
readonly MWA_WALLET_ADDRESS: "dubs_mwa_wallet_address";
|
|
431
432
|
readonly JWT_TOKEN: "dubs_jwt_token";
|
|
432
433
|
readonly PHANTOM_SESSION: "dubs_phantom_session";
|
|
433
434
|
readonly PHANTOM_CONNECT_IN_FLIGHT: "dubs_phantom_connect_in_flight";
|
|
@@ -576,6 +577,12 @@ declare class MwaWalletAdapter implements WalletAdapter {
|
|
|
576
577
|
get connected(): boolean;
|
|
577
578
|
get authToken(): string | null;
|
|
578
579
|
setAuthToken(token: string | null): void;
|
|
580
|
+
/**
|
|
581
|
+
* Restore a previous session silently (no wallet interaction).
|
|
582
|
+
* Sets the public key and auth token so the adapter appears connected.
|
|
583
|
+
* The next signing operation will reauthorize with Phantom.
|
|
584
|
+
*/
|
|
585
|
+
restoreSession(token: string, walletAddressBase58: string): void;
|
|
579
586
|
/**
|
|
580
587
|
* Connect to a mobile wallet. Call this before any signing.
|
|
581
588
|
* Tries reauthorize first (if we have a saved token), then falls back to
|
package/dist/index.js
CHANGED
|
@@ -521,6 +521,7 @@ var DubsClient = class {
|
|
|
521
521
|
// src/storage.ts
|
|
522
522
|
var STORAGE_KEYS = {
|
|
523
523
|
MWA_AUTH_TOKEN: "dubs_mwa_auth_token",
|
|
524
|
+
MWA_WALLET_ADDRESS: "dubs_mwa_wallet_address",
|
|
524
525
|
JWT_TOKEN: "dubs_jwt_token",
|
|
525
526
|
PHANTOM_SESSION: "dubs_phantom_session",
|
|
526
527
|
PHANTOM_CONNECT_IN_FLIGHT: "dubs_phantom_connect_in_flight"
|
|
@@ -594,6 +595,16 @@ var MwaWalletAdapter = class {
|
|
|
594
595
|
setAuthToken(token) {
|
|
595
596
|
this._authToken = token;
|
|
596
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* Restore a previous session silently (no wallet interaction).
|
|
600
|
+
* Sets the public key and auth token so the adapter appears connected.
|
|
601
|
+
* The next signing operation will reauthorize with Phantom.
|
|
602
|
+
*/
|
|
603
|
+
restoreSession(token, walletAddressBase58) {
|
|
604
|
+
this._authToken = token;
|
|
605
|
+
this._publicKey = new import_web3.PublicKey(walletAddressBase58);
|
|
606
|
+
this._connected = true;
|
|
607
|
+
}
|
|
597
608
|
/**
|
|
598
609
|
* Connect to a mobile wallet. Call this before any signing.
|
|
599
610
|
* Tries reauthorize first (if we have a saved token), then falls back to
|
|
@@ -1457,19 +1468,20 @@ function ManagedWalletProvider({
|
|
|
1457
1468
|
}
|
|
1458
1469
|
try {
|
|
1459
1470
|
const savedToken = await storage.getItem(STORAGE_KEYS.MWA_AUTH_TOKEN);
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
console.log(TAG3, "MWA reconnected from saved token");
|
|
1466
|
-
setConnected(true);
|
|
1467
|
-
}
|
|
1471
|
+
const savedAddress = await storage.getItem(STORAGE_KEYS.MWA_WALLET_ADDRESS);
|
|
1472
|
+
if (savedToken && savedAddress && !cancelled) {
|
|
1473
|
+
console.log(TAG3, "Found saved MWA session, restoring silently for wallet:", savedAddress);
|
|
1474
|
+
adapter.restoreSession(savedToken, savedAddress);
|
|
1475
|
+
setConnected(true);
|
|
1468
1476
|
} else {
|
|
1469
|
-
console.log(TAG3, "No saved MWA
|
|
1477
|
+
console.log(TAG3, "No saved MWA session (token or address missing)");
|
|
1470
1478
|
}
|
|
1471
1479
|
} catch (err) {
|
|
1472
|
-
console.log(TAG3, "MWA
|
|
1480
|
+
console.log(TAG3, "MWA session restore failed:", err instanceof Error ? err.message : err);
|
|
1481
|
+
await storage.deleteItem(STORAGE_KEYS.MWA_AUTH_TOKEN).catch(() => {
|
|
1482
|
+
});
|
|
1483
|
+
await storage.deleteItem(STORAGE_KEYS.MWA_WALLET_ADDRESS).catch(() => {
|
|
1484
|
+
});
|
|
1473
1485
|
} finally {
|
|
1474
1486
|
if (!cancelled) {
|
|
1475
1487
|
console.log(TAG3, "MWA init complete, marking ready");
|
|
@@ -1488,7 +1500,12 @@ function ManagedWalletProvider({
|
|
|
1488
1500
|
setError(null);
|
|
1489
1501
|
try {
|
|
1490
1502
|
await adapter.connect();
|
|
1491
|
-
|
|
1503
|
+
const walletAddress = adapter.publicKey?.toBase58();
|
|
1504
|
+
console.log(TAG3, "handleConnect() \u2014 success, wallet:", walletAddress);
|
|
1505
|
+
if (!usePhantom && walletAddress) {
|
|
1506
|
+
storage.setItem(STORAGE_KEYS.MWA_WALLET_ADDRESS, walletAddress).catch(() => {
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1492
1509
|
setConnected(true);
|
|
1493
1510
|
} catch (err) {
|
|
1494
1511
|
const message = err instanceof Error ? err.message : "Connection failed";
|
|
@@ -1497,7 +1514,7 @@ function ManagedWalletProvider({
|
|
|
1497
1514
|
} finally {
|
|
1498
1515
|
setConnecting(false);
|
|
1499
1516
|
}
|
|
1500
|
-
}, [adapter]);
|
|
1517
|
+
}, [adapter, storage, usePhantom]);
|
|
1501
1518
|
const disconnect = (0, import_react.useCallback)(async () => {
|
|
1502
1519
|
console.log(TAG3, "disconnect() \u2014 clearing all state");
|
|
1503
1520
|
adapter.disconnect?.();
|
|
@@ -1509,6 +1526,8 @@ function ManagedWalletProvider({
|
|
|
1509
1526
|
}
|
|
1510
1527
|
await storage.deleteItem(STORAGE_KEYS.MWA_AUTH_TOKEN).catch(() => {
|
|
1511
1528
|
});
|
|
1529
|
+
await storage.deleteItem(STORAGE_KEYS.MWA_WALLET_ADDRESS).catch(() => {
|
|
1530
|
+
});
|
|
1512
1531
|
await storage.deleteItem(STORAGE_KEYS.PHANTOM_SESSION).catch(() => {
|
|
1513
1532
|
});
|
|
1514
1533
|
await storage.deleteItem(STORAGE_KEYS.JWT_TOKEN).catch(() => {
|