From edcf5a59b7c3f6bd6006da3456d361e4c5dfe892 Mon Sep 17 00:00:00 2001 From: William Chong Date: Fri, 27 Mar 2026 22:13:16 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Make=20app=20detection=20S?= =?UTF-8?q?SR-ready=20and=20conditionally=20load=20wallet=20connectors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Check user-agent header on server via useRequestHeaders for SSR app detection - Remove MetaMask connector and @metamask/connect-evm dependency - Only add Coinbase Wallet connector in embedded webview contexts - Pass isApp flag to wagmi config to gate connector setup --- composables/use-app-detection.ts | 16 ++- package-lock.json | 187 ++++++++++++++++++++++++++++--- package.json | 1 - plugins/wagmi.ts | 2 + wagmi.ts | 17 ++- 5 files changed, 192 insertions(+), 31 deletions(-) diff --git a/composables/use-app-detection.ts b/composables/use-app-detection.ts index b8afefa65..dadf5a46e 100644 --- a/composables/use-app-detection.ts +++ b/composables/use-app-detection.ts @@ -1,17 +1,15 @@ +const APP_USER_AGENT_PREFIX = '3ook-com-app' + export function useAppDetection() { const getRouteQuery = useRouteQuery() - const isAppUserAgent = ref(false) + const isAppUserAgent = import.meta.server + ? useRequestHeaders(['user-agent'])['user-agent']?.startsWith(APP_USER_AGENT_PREFIX) || false + : navigator.userAgent?.startsWith(APP_USER_AGENT_PREFIX) || false const isApp = computed(() => { - return isAppUserAgent.value || getRouteQuery('app') === '1' - }) - - onMounted(() => { - isAppUserAgent.value = navigator.userAgent?.startsWith('3ook-com-app') || false + return isAppUserAgent || getRouteQuery('app') === '1' }) - return { - isApp: readonly(isApp), - } + return { isApp } } diff --git a/package-lock.json b/package-lock.json index 0c60cf3de..31ccd498e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,6 @@ "@google-cloud/pubsub": "^5.3.0", "@likecoin/epub-ts": "^0.4.9", "@likecoin/wagmi-connector": "2.4.0-like.0", - "@metamask/connect-evm": "~0.9.0", "@nuxt/icon": "^1.11.0", "@nuxt/scripts": "^0.13.1", "@nuxt/ui": "^3.2.0", @@ -2107,6 +2106,8 @@ "resolved": "https://registry.npmjs.org/@ecies/ciphers/-/ciphers-0.2.5.tgz", "integrity": "sha512-GalEZH4JgOMHYYcYmVqnFirFsjZHeoGMDt9IxEnM9F7GRUUyUksJ7Ou53L83WHJq3RWKD3AcBpo0iQh0oMpf8A==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "bun": ">=1", "deno": ">=2", @@ -2886,6 +2887,8 @@ "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-3.2.0.tgz", "integrity": "sha512-pksvzI0VyLgmuEF2FA/JR/4/y6hcPq8OUail3/AvycBaW1d5VSauOZzqGvJ3RTmR4MU35lWE8KseKOsEhrFRBA==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@ethereumjs/util": "^8.1.0", "crc-32": "^1.2.0" @@ -2896,6 +2899,8 @@ "resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-4.0.1.tgz", "integrity": "sha512-tqsQiBQDQdmPWE1xkkBq4rlSW5QZpLOUJ5RJh2/9fug+q9tnUhuZoVLk7s0scUIKTOzEtR72DFBXI4WiZcMpvw==", "license": "MPL-2.0", + "optional": true, + "peer": true, "bin": { "rlp": "bin/rlp" }, @@ -2908,6 +2913,8 @@ "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-4.2.0.tgz", "integrity": "sha512-1nc6VO4jtFd172BbSnTnDQVr9IYBFl1y4xPzZdtkrkKIncBCkdbgfdRV+MiTkJYAtTxvV12GRZLqBFT1PNK6Yw==", "license": "MPL-2.0", + "optional": true, + "peer": true, "dependencies": { "@ethereumjs/common": "^3.2.0", "@ethereumjs/rlp": "^4.0.1", @@ -2923,6 +2930,8 @@ "resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-8.1.0.tgz", "integrity": "sha512-zQ0IqbdX8FZ9aw11vP+dZkKDkS+kgIvQPHnSAXzP9pLu+Rfu3D3XEeLbicvoXJTYnhZiPmsZUxgdzXwNKxRPbA==", "license": "MPL-2.0", + "optional": true, + "peer": true, "dependencies": { "@ethereumjs/rlp": "^4.0.1", "ethereum-cryptography": "^2.0.0", @@ -5416,6 +5425,8 @@ "resolved": "https://registry.npmjs.org/@metamask/analytics/-/analytics-0.4.0.tgz", "integrity": "sha512-QKjVu8RsbjeSfXXhRLvOVdWJ0jUrVdXFwa4I1VyoI7LapWS6T0apTSjM8nLJKN1NADbpSYm7ctyuTyaHlG/0yA==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "openapi-fetch": "^0.13.5" }, @@ -5428,6 +5439,8 @@ "resolved": "https://registry.npmjs.org/@metamask/api-specs/-/api-specs-0.14.0.tgz", "integrity": "sha512-pL3FADJcw/CA5Nsq6k4ePYxrNyscqVJh0XYXStvGPkw9yPdgIRAc+DuMuMMpaahYpKsmWWHpTAuvwVo9DuFXyg==", "license": "Apache-2.0", + "optional": true, + "peer": true, "engines": { "node": "^18.20 || ^20.17 || >=22" } @@ -5437,6 +5450,8 @@ "resolved": "https://registry.npmjs.org/@metamask/approval-controller/-/approval-controller-9.0.0.tgz", "integrity": "sha512-krm31+CpfTQolTcN2bwSrzLBWf334B0E0GS/VRndHbJMXidgXhc9zcdOzNeTg5onBOma6nqarJyV3ziRvQi1pg==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/base-controller": "^9.0.0", "@metamask/messenger": "^0.3.0", @@ -5459,6 +5474,8 @@ } ], "license": "MIT", + "optional": true, + "peer": true, "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -5471,6 +5488,8 @@ "resolved": "https://registry.npmjs.org/@metamask/base-controller/-/base-controller-9.0.0.tgz", "integrity": "sha512-uwGBb3bIFvfWPEBrRk+avV05eRLZKG0ouskKCiwfdRlFse4njpGGLLD0pO42iOLF7N3yUQ28+lO8reIrXwFP8A==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/messenger": "^0.3.0", "@metamask/utils": "^11.8.1", @@ -5485,6 +5504,8 @@ "resolved": "https://registry.npmjs.org/@metamask/chain-agnostic-permission/-/chain-agnostic-permission-1.4.0.tgz", "integrity": "sha512-807Y6JxqeY3tckSRDse96RmHV6atDsSPLD/x9KIync8ccFjOwSZlv0n4NA5Bsi0znjOogU0jEe5hPNIDTFzFRg==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/api-specs": "^0.14.0", "@metamask/controller-utils": "^11.17.0", @@ -5502,6 +5523,8 @@ "resolved": "https://registry.npmjs.org/@metamask/connect-evm/-/connect-evm-0.9.0.tgz", "integrity": "sha512-Ts2WZcCRYTjS8T2HMQiSOwtuqJABApV5DEB6PadwRi94msK95tQtaMOdvq8wo8uW/MrqGyYJWp4li54Mqn/i5g==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/analytics": "^0.4.0", "@metamask/chain-agnostic-permission": "^1.2.2", @@ -5517,6 +5540,8 @@ "resolved": "https://registry.npmjs.org/@metamask/connect-multichain/-/connect-multichain-0.11.0.tgz", "integrity": "sha512-08l/B/Mc27pcYN7jq8+yraliVZdqftkLdv/UomB9lvvQx9Z6+l8igVWVMWziHcyBWa+v7+ExJaWtF+kTk3Y5yA==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/analytics": "^0.4.0", "@metamask/mobile-wallet-protocol-core": "^0.4.0", @@ -5553,6 +5578,8 @@ "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.1.0.tgz", "integrity": "sha512-uKm5PU+MHTootlWEY+mZ4vvXoCn4fLQxT9dSc1sXVMSFkINTJVN8cAQROpwcKm8bJ/c7rgZVIBWzH5T78sNZZw==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "node-fetch": "^2.7.0" } @@ -5561,7 +5588,9 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==", - "license": "(MIT AND Zlib)" + "license": "(MIT AND Zlib)", + "optional": true, + "peer": true }, "node_modules/@metamask/connect-evm/node_modules/uuid": { "version": "11.1.0", @@ -5572,6 +5601,8 @@ "https://github.com/sponsors/ctavan" ], "license": "MIT", + "optional": true, + "peer": true, "bin": { "uuid": "dist/esm/bin/uuid" } @@ -5581,6 +5612,8 @@ "resolved": "https://registry.npmjs.org/@metamask/controller-utils/-/controller-utils-11.19.0.tgz", "integrity": "sha512-obPzdJhxCHcHf3oOq5vDh6w9GochsjIa0FLoTNY3BhGNxJOSmwL8OkQGCp+Hf1nZIX/VBeiiPk3JL1PUDzqCsg==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/eth-query": "^4.0.0", "@metamask/ethjs-unit": "^0.3.0", @@ -5606,6 +5639,8 @@ "resolved": "https://registry.npmjs.org/@metamask/eth-query/-/eth-query-4.0.0.tgz", "integrity": "sha512-j2yPO2axYGyxwdqXRRhk2zBijt1Nd/xKCIXQkzvfWac0sKP0L9mSt1ZxMOe/sOF1SwS2R+NSaq+gsQDsQvrC4Q==", "license": "ISC", + "optional": true, + "peer": true, "dependencies": { "json-rpc-random-id": "^1.0.0", "xtend": "^4.0.1" @@ -5619,6 +5654,8 @@ "resolved": "https://registry.npmjs.org/@metamask/ethjs-unit/-/ethjs-unit-0.3.0.tgz", "integrity": "sha512-HZtg69ODXYS9+ovKUYofZuIAwq4fc2/MGazD4vBQRKWMhPu4ySdmgR0EuzbxEK4uhr18KA4pbL+mCYjyjGxY7w==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/number-to-bn": "^1.7.1", "bn.js": "^5.2.1" @@ -5636,6 +5673,8 @@ "resolved": "https://registry.npmjs.org/@metamask/json-rpc-engine/-/json-rpc-engine-10.2.3.tgz", "integrity": "sha512-NkqDoU4MJ8lHaEAf8rYfzesCNcldHPQeMJRFFVr09zMEgsZyL+oWrM4gGO2QAfsoLVp8U0jANxyHp6nYxJ6L8w==", "license": "ISC", + "optional": true, + "peer": true, "dependencies": { "@metamask/rpc-errors": "^7.0.2", "@metamask/safe-event-emitter": "^3.0.0", @@ -5653,6 +5692,8 @@ "resolved": "https://registry.npmjs.org/@metamask/messenger/-/messenger-0.3.0.tgz", "integrity": "sha512-Wa9ctLwtD2B3ut9bJW0OLhoM4X2J7y7kuiWZbl+s8cuUBPmTS5IoUUUpvCDWOkucUsJ+6ZiqWMl2d5oSqLN28g==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": "^18.18 || >=20" } @@ -5662,6 +5703,8 @@ "resolved": "https://registry.npmjs.org/@metamask/mobile-wallet-protocol-core/-/mobile-wallet-protocol-core-0.4.0.tgz", "integrity": "sha512-rB1wMogvSUsFaxyH/eVUCczIkTxVaPPETlD/wgm+gw7EbWP0LlZPY7Bh+DICSfUCJ0zqnoFuwr77WNJvZ6ZiWw==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "async-mutex": "^0.5.0", "centrifuge": "^5.3.5", @@ -5681,6 +5724,8 @@ "https://github.com/sponsors/ctavan" ], "license": "MIT", + "optional": true, + "peer": true, "bin": { "uuid": "dist/esm/bin/uuid" } @@ -5690,6 +5735,8 @@ "resolved": "https://registry.npmjs.org/@metamask/mobile-wallet-protocol-dapp-client/-/mobile-wallet-protocol-dapp-client-0.3.0.tgz", "integrity": "sha512-rXStrvIa57a8OaeM+3HeR6Z9ETHOvmQi/9s6CLplDwH2hn2MWjI6WW3EUrxq2KGmGuhbO5Oo21ANnD23QKfduw==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/mobile-wallet-protocol-core": "^0.4.0", "@metamask/utils": "^9.1.0", @@ -5704,6 +5751,8 @@ "resolved": "https://registry.npmjs.org/@metamask/utils/-/utils-9.3.0.tgz", "integrity": "sha512-w8CVbdkDrVXFJbfBSlDfafDR6BAkpDmv1bC1UJVCoVny5tW2RKAdn9i68Xf7asYT4TnUhl/hN4zfUiKQq9II4g==", "license": "ISC", + "optional": true, + "peer": true, "dependencies": { "@ethereumjs/tx": "^4.2.0", "@metamask/superstruct": "^3.1.0", @@ -5728,6 +5777,8 @@ "https://github.com/sponsors/ctavan" ], "license": "MIT", + "optional": true, + "peer": true, "bin": { "uuid": "dist/bin/uuid" } @@ -5741,6 +5792,8 @@ "https://github.com/sponsors/ctavan" ], "license": "MIT", + "optional": true, + "peer": true, "bin": { "uuid": "dist/esm/bin/uuid" } @@ -5750,6 +5803,8 @@ "resolved": "https://registry.npmjs.org/@metamask/multichain-api-client/-/multichain-api-client-0.10.1.tgz", "integrity": "sha512-LsqO2SiDcTgOuXyVYEB0zgBaVNhryhP2tYI3L7tLa7PoeDqMkNIreFhDeu8jM5tPWkCimQvMwCkG3DF4P5dD3A==", "license": "ISC", + "optional": true, + "peer": true, "engines": { "node": "^18.20 || ^20.17 || >=22" } @@ -5759,6 +5814,8 @@ "resolved": "https://registry.npmjs.org/@metamask/multichain-ui/-/multichain-ui-0.4.0.tgz", "integrity": "sha512-CaUyPssiJ5bXP5YXBLadAbRwJ+c//cpzYCFS8P8Nq53Qa4lUVhViAzqvM4667SS3YClGNjNY0tWGyGbXkCmWHg==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@paulmillr/qr": "^0.2.1", "qr-code-styling": "^1.9.2" @@ -5772,6 +5829,8 @@ "resolved": "https://registry.npmjs.org/@metamask/number-to-bn/-/number-to-bn-1.7.1.tgz", "integrity": "sha512-qCN+Au4amvcVii2LdOJNndYhdmk5Lk9tlStJhKpZ8tGeYQDJTghqYXJuSUVPHvfl6FUfKY1i1Or2j2EbnEerSQ==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "bn.js": "5.2.1", "strip-hex-prefix": "1.0.0" @@ -5785,13 +5844,17 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/@metamask/onboarding": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@metamask/onboarding/-/onboarding-1.0.1.tgz", "integrity": "sha512-FqHhAsCI+Vacx2qa5mAFcWNSrTcVGMNjzxVgaX8ECSny/BJ9/vgXP9V7WF/8vb9DltPeQkxr+Fnfmm6GHfmdTQ==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "bowser": "^2.9.0" } @@ -5801,6 +5864,8 @@ "resolved": "https://registry.npmjs.org/@metamask/permission-controller/-/permission-controller-12.2.1.tgz", "integrity": "sha512-i2nPMGDm5DNs6dwl9YReVn1Z0igNmgQcHIrM7cVyKwGCOZducfT4yGZsc1UxY/CjxSIeZASU4/SqfgTs8pBCvw==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/approval-controller": "^9.0.0", "@metamask/base-controller": "^9.0.0", @@ -5829,6 +5894,8 @@ } ], "license": "MIT", + "optional": true, + "peer": true, "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -5841,6 +5908,8 @@ "resolved": "https://registry.npmjs.org/@metamask/rpc-errors/-/rpc-errors-7.0.3.tgz", "integrity": "sha512-nrEaeBawm8yFU7hetJKok/CUs0tQsWtTqp3OLbFhPUMXYqU7uI5LAV5vi9o7rTjFkUyof7Nzbw5bea5+1ou+dg==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@metamask/utils": "^11.4.2", "fast-safe-stringify": "^2.0.6" @@ -5854,6 +5923,8 @@ "resolved": "https://registry.npmjs.org/@metamask/safe-event-emitter/-/safe-event-emitter-3.1.2.tgz", "integrity": "sha512-5yb2gMI1BDm0JybZezeoX/3XhPDOtTbcFvpTXM9kxsoZjPZFh4XciqRbpD6N86HYZqWDhEaKUDuOyR0sQHEjMA==", "license": "ISC", + "optional": true, + "peer": true, "engines": { "node": ">=12.0.0" } @@ -5863,6 +5934,8 @@ "resolved": "https://registry.npmjs.org/@metamask/superstruct/-/superstruct-3.2.1.tgz", "integrity": "sha512-fLgJnDOXFmuVlB38rUN5SmU7hAFQcCjrg3Vrxz67KTY7YHFnSNEKvX4avmEBdOI0yTCxZjwMCFEqsC8k2+Wd3g==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">=16.0.0" } @@ -5872,6 +5945,8 @@ "resolved": "https://registry.npmjs.org/@metamask/utils/-/utils-11.10.0.tgz", "integrity": "sha512-+bWmTOANx1MbBW6RFM8Se4ZoigFYGXiuIrkhjj4XnG5Aez8uWaTSZ76yn9srKKClv+PoEVoAuVtcUOogFEMUNA==", "license": "ISC", + "optional": true, + "peer": true, "dependencies": { "@ethereumjs/tx": "^4.2.0", "@metamask/superstruct": "^3.1.0", @@ -5898,6 +5973,8 @@ "https://github.com/sponsors/ctavan" ], "license": "MIT", + "optional": true, + "peer": true, "bin": { "uuid": "dist/bin/uuid" } @@ -9285,6 +9362,8 @@ "integrity": "sha512-IHnV6A+zxU7XwmKFinmYjUcwlyK9+xkG3/s9KcQhI9BjQKycrJ1JRO+FbNYPwZiPKW3je/DR0k7w8/gLa5eaxQ==", "deprecated": "The package is now available as \"qr\": npm install qr", "license": "(MIT OR Apache-2.0)", + "optional": true, + "peer": true, "funding": { "url": "https://paulmillr.com/funding/" } @@ -10772,6 +10851,8 @@ "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.4.0.tgz", "integrity": "sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@noble/curves": "~1.4.0", "@noble/hashes": "~1.4.0", @@ -10786,6 +10867,8 @@ "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@noble/hashes": "1.4.0" }, @@ -10798,6 +10881,8 @@ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">= 16" }, @@ -10810,6 +10895,8 @@ "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.9.tgz", "integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==", "license": "MIT", + "optional": true, + "peer": true, "funding": { "url": "https://paulmillr.com/funding/" } @@ -10819,6 +10906,8 @@ "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.3.0.tgz", "integrity": "sha512-disdg7gHuTDZtY+ZdkmLpPCk7fxZSu3gBiEGuoC1XYxv9cGx3Z6cpTggCgW6odSOOIXCiDjuGejW+aJKCY/pIQ==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@noble/hashes": "~1.4.0", "@scure/base": "~1.1.6" @@ -10832,6 +10921,8 @@ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">= 16" }, @@ -10844,6 +10935,8 @@ "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.9.tgz", "integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==", "license": "MIT", + "optional": true, + "peer": true, "funding": { "url": "https://paulmillr.com/funding/" } @@ -14652,6 +14745,8 @@ "resolved": "https://registry.npmjs.org/@spruceid/siwe-parser/-/siwe-parser-2.1.0.tgz", "integrity": "sha512-tFQwY2oQLa4qvHE6npKsVgVdVLQOCGP1zJM3yjZOHut43LqCwdSwitZndFLrJHZLpqru9FnmYHRakvsPvrI+qA==", "license": "Apache-2.0", + "optional": true, + "peer": true, "dependencies": { "@noble/hashes": "^1.1.2", "apg-js": "^4.1.1", @@ -15146,6 +15241,8 @@ "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.2.0.tgz", "integrity": "sha512-DLbJ1BPqxvQhIGbeu8VbUC1DiAiahHtAYvA0ZEAa4P31F7IaArc8z3C3BRQdWX4mtLQuABG4yzp76ZrS02Ui1Q==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@types/node": "*" } @@ -15198,6 +15295,8 @@ "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@types/ms": "*" } @@ -15213,7 +15312,9 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@types/deep-freeze-strict/-/deep-freeze-strict-1.1.2.tgz", "integrity": "sha512-VvMETBojHvhX4f+ocYTySQlXMZfxKV3Jyb7iCWlWaC+exbedkv6Iv2bZZqI736qXjVguH6IH7bzwMBMfTT+zuQ==", - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/@types/doctrine": { "version": "0.0.9", @@ -15284,7 +15385,9 @@ "version": "4.17.24", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.24.tgz", "integrity": "sha512-gIW7lQLZbue7lRSWEFql49QJJWThrTFFeIMJdp3eH4tKoxm1OvEPg02rm4wCCSHS0cL3/Fizimb35b7k8atwsQ==", - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/@types/long": { "version": "4.0.2", @@ -17473,7 +17576,9 @@ "version": "4.4.0", "resolved": "https://registry.npmjs.org/apg-js/-/apg-js-4.4.0.tgz", "integrity": "sha512-fefmXFknJmtgtNEXfPwZKYkMFX4Fyeyz+fNF6JWp87biGOPslJbCBVU158zvKRZfHBKnJDy8CMM40oLFGkXT8Q==", - "license": "BSD-2-Clause" + "license": "BSD-2-Clause", + "optional": true, + "peer": true }, "node_modules/archiver": { "version": "7.0.1", @@ -17675,6 +17780,8 @@ "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz", "integrity": "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "tslib": "^2.4.0" } @@ -18087,7 +18194,9 @@ "version": "2.14.1", "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.14.1.tgz", "integrity": "sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg==", - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/brace-expansion": { "version": "2.0.2", @@ -18487,6 +18596,8 @@ "resolved": "https://registry.npmjs.org/centrifuge/-/centrifuge-5.5.3.tgz", "integrity": "sha512-LPkWnsAxu7JaE5S738XiREzJIko3Pf/qnWb3kd0q/OR0OJONUbSdnZ5pKsEI2yFi/odQ89SYsHPhLuEeZFhp/g==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "events": "^3.3.0", "protobufjs": "^7.2.5" @@ -18701,6 +18812,8 @@ "resolved": "https://registry.npmjs.org/cockatiel/-/cockatiel-3.2.1.tgz", "integrity": "sha512-gfrHV6ZPkquExvMh9IOkKsBzNDk6sDuZ6DdBGUBkvFnTCqCxzpuq48RySgP0AnaqQkw2zynOFj9yly6T1Q2G5Q==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">=16" } @@ -19442,7 +19555,9 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/deep-freeze-strict/-/deep-freeze-strict-1.1.1.tgz", "integrity": "sha512-QemROZMM2IvhAcCFvahdX2Vbm4S/txeq5rFYU9fh4mQP79WTMW5c/HkQ2ICl1zuzcDZdPZ6zarDxQeQMsVYoNA==", - "license": "public domain" + "license": "public domain", + "optional": true, + "peer": true }, "node_modules/deep-is": { "version": "0.1.4", @@ -19820,6 +19935,8 @@ "resolved": "https://registry.npmjs.org/eciesjs/-/eciesjs-0.4.17.tgz", "integrity": "sha512-TOOURki4G7sD1wDCjj7NfLaXZZ49dFOeEb5y39IXpb8p0hRzVvfvzZHOi5JcT+PpyAbi/Y+lxPb8eTag2WYH8w==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@ecies/ciphers": "^0.2.5", "@noble/ciphers": "^1.3.0", @@ -19837,6 +19954,8 @@ "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@noble/hashes": "1.8.0" }, @@ -21005,6 +21124,8 @@ "resolved": "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz", "integrity": "sha512-VWEI1+KJfz4Km//dadyvBBoBeSQ0MHTXPvr8UIXiLW6IanxvAV+DmlZAijZwAyggqGUfwQBeHf7tc9wzc1piSw==", "license": "ISC", + "optional": true, + "peer": true, "dependencies": { "idna-uts46-hx": "^2.3.1", "js-sha3": "^0.5.7" @@ -21014,13 +21135,17 @@ "version": "0.5.7", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==", - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/ethereum-cryptography": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.2.1.tgz", "integrity": "sha512-r/W8lkHSiTLxUxW8Rf3u4HGB0xQweG2RyETjywylKZSzLWoWAijRz8WCuOtJ6wah+avllXBqZuk29HCCvhEIRg==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@noble/curves": "1.4.2", "@noble/hashes": "1.4.0", @@ -21033,6 +21158,8 @@ "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "@noble/hashes": "1.4.0" }, @@ -21045,6 +21172,8 @@ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">= 16" }, @@ -21258,7 +21387,9 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/fast-stable-stringify": { "version": "1.0.0", @@ -22604,6 +22735,8 @@ "resolved": "https://registry.npmjs.org/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz", "integrity": "sha512-PWoF9Keq6laYdIRwwCdhTPl60xRqAloYNMQLiyUnG42VjT53oW07BXIRM+NK7eQjzXjAk2gUvX9caRxlnF9TAA==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "punycode": "2.1.0" }, @@ -22616,6 +22749,8 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", "integrity": "sha512-Yxz2kRwT90aPiWEMHVYnEf4+rhwF1tBmmZ4KepCP+Wkium9JxtWnUm1nqGwpiAHr/tnTSeHqr3wb++jgSkXjhA==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">=6" } @@ -22666,6 +22801,8 @@ "resolved": "https://registry.npmjs.org/immer/-/immer-9.0.21.tgz", "integrity": "sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA==", "license": "MIT", + "optional": true, + "peer": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/immer" @@ -23097,6 +23234,8 @@ "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", "integrity": "sha512-WvtOiug1VFrE9v1Cydwm+FnXd3+w9GaeVUss5W4v/SLy3UW00vP+6iNF2SdnfiBoLy4bTqVdkftNGTUeOFVsbA==", "license": "MIT", + "optional": true, + "peer": true, "engines": { "node": ">=6.5.0", "npm": ">=3" @@ -23764,7 +23903,9 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-rpc-random-id/-/json-rpc-random-id-1.0.1.tgz", "integrity": "sha512-RJ9YYNCkhVDBuP4zN5BBtYAzEl03yq/jIIsyif0JY9qyJuQQZNeDK7anAPKKlyEtLSj2s8h6hNh2F8zO5q7ScA==", - "license": "ISC" + "license": "ISC", + "optional": true, + "peer": true }, "node_modules/json-schema": { "version": "0.4.0", @@ -24827,7 +24968,9 @@ "version": "0.3.1", "resolved": "https://registry.npmjs.org/micro-ftch/-/micro-ftch-0.3.1.tgz", "integrity": "sha512-/0LLxhzP0tfiR5hcQebtudP56gUurs2CLkGarnCiB/OqEyUFQ6U3paQi/tgLv0hBJYt2rnr9MNpxz4fiiugstg==", - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/micromatch": { "version": "4.0.8", @@ -26185,6 +26328,8 @@ "resolved": "https://registry.npmjs.org/openapi-fetch/-/openapi-fetch-0.13.8.tgz", "integrity": "sha512-yJ4QKRyNxE44baQ9mY5+r/kAzZ8yXMemtNAOFwOzRXJscdjSxxzWSNlyBAr+o5JjkUw9Lc3W7OIoca0cY3PYnQ==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "openapi-typescript-helpers": "^0.0.15" } @@ -26193,7 +26338,9 @@ "version": "0.0.15", "resolved": "https://registry.npmjs.org/openapi-typescript-helpers/-/openapi-typescript-helpers-0.0.15.tgz", "integrity": "sha512-opyTPaunsklCBpTK8JGef6mfPhLSnyy5a0IN9vKtx3+4aExf+KxEqYwIy3hqkedXIB97u357uLMJsOnm3GVjsw==", - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/openid-client": { "version": "6.3.4", @@ -26837,6 +26984,8 @@ "resolved": "https://registry.npmjs.org/pony-cause/-/pony-cause-2.1.11.tgz", "integrity": "sha512-M7LhCsdNbNgiLYiP4WjsfLUuFmCfnjdF6jKe2R9NKl4WFN+HZPGHJZ9lnLP7f9ZnKe3U9nuWD0szirmj+migUg==", "license": "0BSD", + "optional": true, + "peer": true, "engines": { "node": ">=12.0.0" } @@ -27574,6 +27723,8 @@ "resolved": "https://registry.npmjs.org/qr-code-styling/-/qr-code-styling-1.9.2.tgz", "integrity": "sha512-RgJaZJ1/RrXJ6N0j7a+pdw3zMBmzZU4VN2dtAZf8ZggCfRB5stEQ3IoDNGaNhYY3nnZKYlYSLl5YkfWN5dPutg==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "qrcode-generator": "^1.4.4" }, @@ -27603,7 +27754,9 @@ "version": "1.5.2", "resolved": "https://registry.npmjs.org/qrcode-generator/-/qrcode-generator-1.5.2.tgz", "integrity": "sha512-pItrW0Z9HnDBnFmgiNrY1uxRdri32Uh9EjNYLPVC2zZ3ZRIIEqBoDgm4DkvDwNNDHTK7FNkmr8zAa77BYc9xNw==", - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/qrcode/node_modules/ansi-regex": { "version": "5.0.1", @@ -29562,6 +29715,8 @@ "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", "integrity": "sha512-q8d4ue7JGEiVcypji1bALTos+0pWtyGlivAWyPuTkHzuTCJqrK9sWxYQZUq6Nq3cuyv3bm734IhHvHtGGURU6A==", "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "is-hex-prefixed": "1.0.0" }, @@ -31051,7 +31206,9 @@ "node_modules/valid-url": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/valid-url/-/valid-url-1.0.9.tgz", - "integrity": "sha512-QQDsV8OnSf5Uc30CKSwG9lnhMPe6exHtTXLRYX8uMwKENy640pU+2BgBL0LRbDh/eYRahNCS7aewCx0wf3NYVA==" + "integrity": "sha512-QQDsV8OnSf5Uc30CKSwG9lnhMPe6exHtTXLRYX8uMwKENy640pU+2BgBL0LRbDh/eYRahNCS7aewCx0wf3NYVA==", + "optional": true, + "peer": true }, "node_modules/validate-npm-package-license": { "version": "3.0.4", diff --git a/package.json b/package.json index 502be344d..eca92165b 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "@google-cloud/pubsub": "^5.3.0", "@likecoin/epub-ts": "^0.4.9", "@likecoin/wagmi-connector": "2.4.0-like.0", - "@metamask/connect-evm": "~0.9.0", "@nuxt/icon": "^1.11.0", "@nuxt/scripts": "^0.13.1", "@nuxt/ui": "^3.2.0", diff --git a/plugins/wagmi.ts b/plugins/wagmi.ts index 45efabc7b..955610f59 100644 --- a/plugins/wagmi.ts +++ b/plugins/wagmi.ts @@ -7,6 +7,7 @@ import { createWagmiConfig } from '../wagmi' // NOTE: Possibly will move to @wagmi/vue/nuxt nitro plugin export default defineNuxtPlugin((nuxtApp) => { const config = useRuntimeConfig() + const { isApp } = useAppDetection() const wagmiConfig = createWagmiConfig({ apiKey: config.public.magicLinkAPIKey, customLogoURL: config.public.magicLinkCustomLogoURL, @@ -14,6 +15,7 @@ export default defineNuxtPlugin((nuxtApp) => { customRpcUrl: config.public.customRpcUrl, isServer: !!nuxtApp.ssrContext, isTestnet: !!config.public.isTestnet, + isApp: isApp.value, }) nuxtApp.vueApp .use(WagmiPlugin, { config: wagmiConfig as Config }) diff --git a/wagmi.ts b/wagmi.ts index ef1cfae5a..9e2492f9d 100644 --- a/wagmi.ts +++ b/wagmi.ts @@ -1,6 +1,6 @@ import { http, createConfig, type CreateConnectorFn, type Config } from '@wagmi/core' import { base, baseSepolia } from '@wagmi/vue/chains' -import { injected, metaMask, walletConnect, coinbaseWallet } from '@wagmi/vue/connectors' +import { injected, walletConnect, coinbaseWallet } from '@wagmi/vue/connectors' import { dedicatedWalletConnector } from '@likecoin/wagmi-connector' export function createWagmiConfig({ @@ -10,6 +10,7 @@ export function createWagmiConfig({ customRpcUrl, isServer = false, isTestnet = false, + isApp = false, }: { apiKey: string customLogoURL?: string @@ -17,17 +18,21 @@ export function createWagmiConfig({ customRpcUrl?: string isServer?: boolean isTestnet?: boolean + isApp?: boolean }): Config { const chain = isTestnet ? baseSepolia : base const logoURL = customLogoURL || 'https://3ook.com/pwa-64x64.png' const connectors: CreateConnectorFn[] = [ injected(), - metaMask(), - coinbaseWallet({ - appName: '3ook.com', - appLogoUrl: logoURL, - }), ] + if (import.meta.client && window && !isApp && (!!window.ReactNativeWebView || window !== window.parent)) { + connectors.push( + coinbaseWallet({ + appName: '3ook.com', + appLogoUrl: logoURL, + }), + ) + } if (!isServer) { if (walletConnectProjectId) { connectors.push(