@solana-mobile/wallet-standard-mobile 0.5.1 → 0.5.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/lib/cjs/index.browser.js +38 -33
- package/lib/cjs/index.browser.js.map +1 -1
- package/lib/cjs/index.js +38 -33
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/index.native.js +31 -26
- package/lib/cjs/index.native.js.map +1 -1
- package/lib/esm/index.browser.js +37 -32
- package/lib/esm/index.browser.js.map +1 -1
- package/lib/esm/index.js +37 -32
- package/lib/esm/index.js.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.native.js
CHANGED
|
@@ -22,13 +22,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
24
|
let _solana_wallet_standard_features = require("@solana/wallet-standard-features");
|
|
25
|
-
let qrcode = require("qrcode");
|
|
26
|
-
qrcode = __toESM(qrcode);
|
|
27
25
|
let _solana_mobile_mobile_wallet_adapter_protocol = require("@solana-mobile/mobile-wallet-adapter-protocol");
|
|
28
26
|
let _wallet_standard_features = require("@wallet-standard/features");
|
|
29
|
-
let js_base64 = require("js-base64");
|
|
30
27
|
let bs58 = require("bs58");
|
|
31
28
|
bs58 = __toESM(bs58);
|
|
29
|
+
let js_base64 = require("js-base64");
|
|
30
|
+
let qrcode = require("qrcode");
|
|
31
|
+
qrcode = __toESM(qrcode);
|
|
32
32
|
let _wallet_standard_wallet = require("@wallet-standard/wallet");
|
|
33
33
|
let _react_native_async_storage_async_storage = require("@react-native-async-storage/async-storage");
|
|
34
34
|
_react_native_async_storage_async_storage = __toESM(_react_native_async_storage_async_storage);
|
|
@@ -615,9 +615,6 @@ const css$4 = `
|
|
|
615
615
|
}
|
|
616
616
|
`;
|
|
617
617
|
//#endregion
|
|
618
|
-
//#region src/icon.ts
|
|
619
|
-
const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
|
|
620
|
-
//#endregion
|
|
621
618
|
//#region src/embedded-modal/localConnectionModal.ts
|
|
622
619
|
var LocalConnectionModal = class extends EmbeddedModal {
|
|
623
620
|
contentStyles = css$3;
|
|
@@ -869,7 +866,7 @@ var LoopbackPermissionModal = class extends EmbeddedModal {
|
|
|
869
866
|
launchButton?.removeEventListener("click", listener);
|
|
870
867
|
try {
|
|
871
868
|
await fetch("http://localhost");
|
|
872
|
-
} catch
|
|
869
|
+
} catch {}
|
|
873
870
|
this.close();
|
|
874
871
|
};
|
|
875
872
|
launchButton?.addEventListener("click", listener);
|
|
@@ -973,7 +970,7 @@ function getIsPwaLaunchedAsApp() {
|
|
|
973
970
|
async function checkLocalNetworkAccessPermission() {
|
|
974
971
|
if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
|
|
975
972
|
try {
|
|
976
|
-
|
|
973
|
+
const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
|
|
977
974
|
if (lnaPermission.state === "granted") return;
|
|
978
975
|
else if (lnaPermission.state === "denied") {
|
|
979
976
|
const modal = new LoopbackPermissionBlockedModal();
|
|
@@ -1014,6 +1011,9 @@ async function checkLocalNetworkAccessPermission() {
|
|
|
1014
1011
|
}
|
|
1015
1012
|
}
|
|
1016
1013
|
//#endregion
|
|
1014
|
+
//#region src/icon.ts
|
|
1015
|
+
const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
|
|
1016
|
+
//#endregion
|
|
1017
1017
|
//#region src/wallet.ts
|
|
1018
1018
|
const SolanaMobileWalletAdapterWalletName = "Mobile Wallet Adapter";
|
|
1019
1019
|
const SolanaMobileWalletAdapterRemoteWalletName = "Remote Mobile Wallet Adapter";
|
|
@@ -1025,6 +1025,9 @@ const DEFAULT_FEATURES = [
|
|
|
1025
1025
|
_solana_wallet_standard_features.SolanaSignIn
|
|
1026
1026
|
];
|
|
1027
1027
|
const WALLET_ASSOCIATION_TIMEOUT = 3e4;
|
|
1028
|
+
function getErrorMessage(error) {
|
|
1029
|
+
return error instanceof Error ? error.message : "Unknown error";
|
|
1030
|
+
}
|
|
1028
1031
|
var LocalSolanaMobileWalletAdapterWallet = class {
|
|
1029
1032
|
#listeners = {};
|
|
1030
1033
|
#version = "1.0.0";
|
|
@@ -1141,7 +1144,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1141
1144
|
} else return { accounts: this.accounts };
|
|
1142
1145
|
} else await this.#performAuthorization();
|
|
1143
1146
|
} catch (e) {
|
|
1144
|
-
throw new Error(e
|
|
1147
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1145
1148
|
} finally {
|
|
1146
1149
|
this.#connecting = false;
|
|
1147
1150
|
}
|
|
@@ -1176,7 +1179,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1176
1179
|
return authorization;
|
|
1177
1180
|
});
|
|
1178
1181
|
} catch (e) {
|
|
1179
|
-
throw new Error(e
|
|
1182
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1180
1183
|
}
|
|
1181
1184
|
};
|
|
1182
1185
|
#handleAuthorizationResult = async (authorization) => {
|
|
@@ -1219,7 +1222,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1219
1222
|
Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
|
|
1220
1223
|
} catch (e) {
|
|
1221
1224
|
this.#disconnect();
|
|
1222
|
-
throw new Error(e
|
|
1225
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1223
1226
|
}
|
|
1224
1227
|
};
|
|
1225
1228
|
#disconnect = async () => {
|
|
@@ -1235,10 +1238,12 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1235
1238
|
const currentConnectionGeneration = this.#connectionGeneration;
|
|
1236
1239
|
const loadingSpinner = new EmbeddedLoadingSpinner();
|
|
1237
1240
|
try {
|
|
1241
|
+
let associating = true;
|
|
1238
1242
|
let timeout = void 0;
|
|
1239
1243
|
const result = await Promise.race([checkLocalNetworkAccessPermission().then(async () => {
|
|
1240
1244
|
loadingSpinner.init();
|
|
1241
1245
|
const { wallet, close } = await (0, _solana_mobile_mobile_wallet_adapter_protocol.startScenario)(config);
|
|
1246
|
+
associating = false;
|
|
1242
1247
|
loadingSpinner.addEventListener("close", (event) => {
|
|
1243
1248
|
if (event) close();
|
|
1244
1249
|
});
|
|
@@ -1249,7 +1254,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1249
1254
|
return result;
|
|
1250
1255
|
}), new Promise((_, reject) => {
|
|
1251
1256
|
timeout = setTimeout(() => {
|
|
1252
|
-
reject(new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
|
|
1257
|
+
if (associating) reject(new _solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterError(_solana_mobile_mobile_wallet_adapter_protocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
|
|
1253
1258
|
}, WALLET_ASSOCIATION_TIMEOUT);
|
|
1254
1259
|
})]);
|
|
1255
1260
|
clearTimeout(timeout);
|
|
@@ -1292,14 +1297,14 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1292
1297
|
return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(js_base64.toUint8Array);
|
|
1293
1298
|
});
|
|
1294
1299
|
} catch (e) {
|
|
1295
|
-
throw new Error(e
|
|
1300
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1296
1301
|
}
|
|
1297
1302
|
};
|
|
1298
1303
|
#performSignAndSendTransaction = async (transaction, options) => {
|
|
1299
1304
|
const { authToken, chain } = this.#assertIsAuthorized();
|
|
1300
1305
|
try {
|
|
1301
1306
|
return await this.#transact(async (wallet) => {
|
|
1302
|
-
const [capabilities
|
|
1307
|
+
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
1303
1308
|
if (capabilities.supports_sign_and_send_transactions) {
|
|
1304
1309
|
const base64Transaction = (0, js_base64.fromUint8Array)(transaction);
|
|
1305
1310
|
return (await wallet.signAndSendTransactions({
|
|
@@ -1309,7 +1314,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1309
1314
|
} else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
1310
1315
|
});
|
|
1311
1316
|
} catch (e) {
|
|
1312
|
-
throw new Error(e
|
|
1317
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1313
1318
|
}
|
|
1314
1319
|
};
|
|
1315
1320
|
#signAndSendTransaction = async (...inputs) => {
|
|
@@ -1343,7 +1348,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1343
1348
|
});
|
|
1344
1349
|
});
|
|
1345
1350
|
} catch (e) {
|
|
1346
|
-
throw new Error(e
|
|
1351
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1347
1352
|
}
|
|
1348
1353
|
};
|
|
1349
1354
|
#signIn = async (...inputs) => {
|
|
@@ -1373,7 +1378,7 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
1373
1378
|
signature: (0, js_base64.toUint8Array)(authorizationResult.sign_in_result.signature)
|
|
1374
1379
|
};
|
|
1375
1380
|
} catch (e) {
|
|
1376
|
-
throw new Error(e
|
|
1381
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1377
1382
|
} finally {
|
|
1378
1383
|
this.#connecting = false;
|
|
1379
1384
|
}
|
|
@@ -1486,13 +1491,13 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1486
1491
|
#off(event, listener) {
|
|
1487
1492
|
this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
1488
1493
|
}
|
|
1489
|
-
#connect = async (
|
|
1494
|
+
#connect = async (_input = {}) => {
|
|
1490
1495
|
if (this.#connecting || this.connected) return { accounts: this.accounts };
|
|
1491
1496
|
this.#connecting = true;
|
|
1492
1497
|
try {
|
|
1493
1498
|
await this.#performAuthorization();
|
|
1494
1499
|
} catch (e) {
|
|
1495
|
-
throw new Error(e
|
|
1500
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1496
1501
|
} finally {
|
|
1497
1502
|
this.#connecting = false;
|
|
1498
1503
|
}
|
|
@@ -1528,7 +1533,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1528
1533
|
return authorizationResult;
|
|
1529
1534
|
});
|
|
1530
1535
|
} catch (e) {
|
|
1531
|
-
throw new Error(e
|
|
1536
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1532
1537
|
}
|
|
1533
1538
|
};
|
|
1534
1539
|
#handleAuthorizationResult = async (authorization) => {
|
|
@@ -1571,7 +1576,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1571
1576
|
Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
|
|
1572
1577
|
} catch (e) {
|
|
1573
1578
|
this.#disconnect();
|
|
1574
|
-
throw new Error(e
|
|
1579
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1575
1580
|
}
|
|
1576
1581
|
};
|
|
1577
1582
|
#disconnect = async () => {
|
|
@@ -1642,14 +1647,14 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1642
1647
|
return (await wallet.signTransactions({ payloads: transactions.map(js_base64.fromUint8Array) })).signed_payloads.map(js_base64.toUint8Array);
|
|
1643
1648
|
});
|
|
1644
1649
|
} catch (e) {
|
|
1645
|
-
throw new Error(e
|
|
1650
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1646
1651
|
}
|
|
1647
1652
|
};
|
|
1648
1653
|
#performSignAndSendTransaction = async (transaction, options) => {
|
|
1649
1654
|
const { authToken, chain } = this.#assertIsAuthorized();
|
|
1650
1655
|
try {
|
|
1651
1656
|
return await this.#transact(async (wallet) => {
|
|
1652
|
-
const [capabilities
|
|
1657
|
+
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
1653
1658
|
if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
|
|
1654
1659
|
...options,
|
|
1655
1660
|
payloads: [(0, js_base64.fromUint8Array)(transaction)]
|
|
@@ -1657,7 +1662,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1657
1662
|
else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
1658
1663
|
});
|
|
1659
1664
|
} catch (e) {
|
|
1660
|
-
throw new Error(e
|
|
1665
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1661
1666
|
}
|
|
1662
1667
|
};
|
|
1663
1668
|
#signAndSendTransaction = async (...inputs) => {
|
|
@@ -1691,7 +1696,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1691
1696
|
});
|
|
1692
1697
|
});
|
|
1693
1698
|
} catch (e) {
|
|
1694
|
-
throw new Error(e
|
|
1699
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1695
1700
|
}
|
|
1696
1701
|
};
|
|
1697
1702
|
#signIn = async (...inputs) => {
|
|
@@ -1721,7 +1726,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
1721
1726
|
signature: (0, js_base64.toUint8Array)(authorizationResult.sign_in_result.signature)
|
|
1722
1727
|
};
|
|
1723
1728
|
} catch (e) {
|
|
1724
|
-
throw new Error(e
|
|
1729
|
+
throw new Error(getErrorMessage(e), { cause: e });
|
|
1725
1730
|
} finally {
|
|
1726
1731
|
this.#connecting = false;
|
|
1727
1732
|
}
|