@solana-mobile/wallet-standard-mobile 0.4.2 → 0.4.4

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.
@@ -1398,6 +1398,11 @@ function getIsRemoteAssociationSupported() {
1398
1398
  typeof document !== 'undefined' &&
1399
1399
  !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
1400
1400
  }
1401
+ // Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
1402
+ // This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
1403
+ function isWebView(userAgentString) {
1404
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
1405
+ }
1401
1406
 
1402
1407
  function registerMwa(config) {
1403
1408
  if (typeof window === 'undefined') {
@@ -1408,7 +1413,9 @@ function registerMwa(config) {
1408
1413
  console.warn(`MWA not registered: secure context required (https)`);
1409
1414
  return;
1410
1415
  }
1411
- if (getIsLocalAssociationSupported()) {
1416
+ // Local association technically is possible in a webview, but we prevent registration
1417
+ // by default because it usually fails in the most common cases (e.g wallet browsers).
1418
+ if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
1412
1419
  registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
1413
1420
  }
1414
1421
  else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
package/lib/cjs/index.js CHANGED
@@ -1398,6 +1398,11 @@ function getIsRemoteAssociationSupported() {
1398
1398
  typeof document !== 'undefined' &&
1399
1399
  !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
1400
1400
  }
1401
+ // Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
1402
+ // This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
1403
+ function isWebView(userAgentString) {
1404
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
1405
+ }
1401
1406
 
1402
1407
  function registerMwa(config) {
1403
1408
  if (typeof window === 'undefined') {
@@ -1408,7 +1413,9 @@ function registerMwa(config) {
1408
1413
  console.warn(`MWA not registered: secure context required (https)`);
1409
1414
  return;
1410
1415
  }
1411
- if (getIsLocalAssociationSupported()) {
1416
+ // Local association technically is possible in a webview, but we prevent registration
1417
+ // by default because it usually fails in the most common cases (e.g wallet browsers).
1418
+ if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
1412
1419
  registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
1413
1420
  }
1414
1421
  else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
@@ -1391,6 +1391,11 @@ function getIsRemoteAssociationSupported() {
1391
1391
  typeof document !== 'undefined' &&
1392
1392
  !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
1393
1393
  }
1394
+ // Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
1395
+ // This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
1396
+ function isWebView(userAgentString) {
1397
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
1398
+ }
1394
1399
 
1395
1400
  function registerMwa(config) {
1396
1401
  if (typeof window === 'undefined') {
@@ -1401,7 +1406,9 @@ function registerMwa(config) {
1401
1406
  console.warn(`MWA not registered: secure context required (https)`);
1402
1407
  return;
1403
1408
  }
1404
- if (getIsLocalAssociationSupported()) {
1409
+ // Local association technically is possible in a webview, but we prevent registration
1410
+ // by default because it usually fails in the most common cases (e.g wallet browsers).
1411
+ if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
1405
1412
  registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
1406
1413
  }
1407
1414
  else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
@@ -1389,6 +1389,11 @@ function getIsRemoteAssociationSupported() {
1389
1389
  typeof document !== 'undefined' &&
1390
1390
  !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
1391
1391
  }
1392
+ // Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
1393
+ // This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
1394
+ function isWebView(userAgentString) {
1395
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
1396
+ }
1392
1397
 
1393
1398
  function registerMwa(config) {
1394
1399
  if (typeof window === 'undefined') {
@@ -1399,7 +1404,9 @@ function registerMwa(config) {
1399
1404
  console.warn(`MWA not registered: secure context required (https)`);
1400
1405
  return;
1401
1406
  }
1402
- if (getIsLocalAssociationSupported()) {
1407
+ // Local association technically is possible in a webview, but we prevent registration
1408
+ // by default because it usually fails in the most common cases (e.g wallet browsers).
1409
+ if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
1403
1410
  registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
1404
1411
  }
1405
1412
  else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
package/lib/esm/index.js CHANGED
@@ -1389,6 +1389,11 @@ function getIsRemoteAssociationSupported() {
1389
1389
  typeof document !== 'undefined' &&
1390
1390
  !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
1391
1391
  }
1392
+ // Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
1393
+ // This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
1394
+ function isWebView(userAgentString) {
1395
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
1396
+ }
1392
1397
 
1393
1398
  function registerMwa(config) {
1394
1399
  if (typeof window === 'undefined') {
@@ -1399,7 +1404,9 @@ function registerMwa(config) {
1399
1404
  console.warn(`MWA not registered: secure context required (https)`);
1400
1405
  return;
1401
1406
  }
1402
- if (getIsLocalAssociationSupported()) {
1407
+ // Local association technically is possible in a webview, but we prevent registration
1408
+ // by default because it usually fails in the most common cases (e.g wallet browsers).
1409
+ if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
1403
1410
  registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
1404
1411
  }
1405
1412
  else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solana-mobile/wallet-standard-mobile",
3
3
  "description": "A wallet-standard wallet for mobile wallet apps that conform to the Solana Mobile Wallet Adapter protocol",
4
- "version": "0.4.2",
4
+ "version": "0.4.4",
5
5
  "author": "Marco Martinez <marco.martinez@solana.com>",
6
6
  "repository": "https://github.com/solana-mobile/mobile-wallet-adapter",
7
7
  "license": "Apache-2.0",
@@ -50,7 +50,7 @@
50
50
  "prepublishOnly": "agadoo"
51
51
  },
52
52
  "dependencies": {
53
- "@solana-mobile/mobile-wallet-adapter-protocol": "^2.2.4",
53
+ "@solana-mobile/mobile-wallet-adapter-protocol": "^2.2.5",
54
54
  "@solana/wallet-standard-chains": "^1.1.0",
55
55
  "@solana/wallet-standard-features": "^1.2.0",
56
56
  "@wallet-standard/base": "^1.0.1",