From bac8634aa33afbb1ccc922cfa9743b0ca3d29770 Mon Sep 17 00:00:00 2001 From: Alex Risch Date: Thu, 14 Nov 2024 09:14:01 -0500 Subject: [PATCH] Allow ethereum deeplinks inside frames (#1198) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Allow ethereum deeplinks inside frames * Set and new file * Bump app json * [create-pull-request] automated change (#1195) Co-authored-by: alexrisch * [create-pull-request] automated change (#1197) Co-authored-by: alexrisch --------- Co-authored-by: Noé Malzieu Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: alexrisch --- app.json | 6 +++--- components/Chat/Frame/FramePreview.tsx | 5 ++--- components/Chat/Frame/urlProtocols.ts | 6 ++++++ config.ts | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 components/Chat/Frame/urlProtocols.ts diff --git a/app.json b/app.json index e8f07bf46..611eb33dc 100644 --- a/app.json +++ b/app.json @@ -1,11 +1,11 @@ { "expo": { - "version": "2.0.7", + "version": "2.0.8", "ios": { - "buildNumber": "16" + "buildNumber": "31" }, "android": { - "versionCode": 223 + "versionCode": 229 } } } diff --git a/components/Chat/Frame/FramePreview.tsx b/components/Chat/Frame/FramePreview.tsx index 873e6a395..26acd9821 100644 --- a/components/Chat/Frame/FramePreview.tsx +++ b/components/Chat/Frame/FramePreview.tsx @@ -26,6 +26,7 @@ import { validateFrame, } from "../../../utils/frames"; import { MessageToDisplay } from "../Message/Message"; +import { AUTHORIZED_URL_PROTOCOLS } from "./urlProtocols"; export default function FramePreview({ initialFrame, @@ -155,9 +156,7 @@ export default function FramePreview({ try { const url = new URL(link); if ( - (url.protocol === "http:" || - url.protocol === "https:" || - url.protocol === `${config.scheme}:`) && + AUTHORIZED_URL_PROTOCOLS.has(url.protocol) && (await Linking.canOpenURL(link)) ) { Linking.openURL(link); diff --git a/components/Chat/Frame/urlProtocols.ts b/components/Chat/Frame/urlProtocols.ts new file mode 100644 index 000000000..da1fb6a02 --- /dev/null +++ b/components/Chat/Frame/urlProtocols.ts @@ -0,0 +1,6 @@ +import config from "../../../config"; + +export const AUTHORIZED_URL_PROTOCOLS = new Set([ + `${config.scheme}:`, + ...config.framesAllowedSchemes.map((s) => `${s}:`), +]); diff --git a/config.ts b/config.ts index 0ee21e257..3c4962d2c 100644 --- a/config.ts +++ b/config.ts @@ -45,6 +45,7 @@ const defaultConfig = { rpcEndpoint: process.env.EXPO_PUBLIC_EVM_RPC_ENDPOINT, }, splitScreenThreshold: 600, + framesAllowedSchemes: ["http", "https", "ethereum"], }; const isAndroid = Platform.OS === "android";