From bb98cf69a10da75d955bbf849c86dfe7f9420904 Mon Sep 17 00:00:00 2001 From: Anant Date: Thu, 8 Oct 2026 17:49:57 +0530 Subject: [PATCH 1/5] fix: serve remote links and iOS association on website --- .../.well-known/apple-app-site-association | 15 ++++++++ client/public/remote-link.html | 29 +++++++++++++++ scripts/native-links.test.mjs | 36 +++++++++++++++++++ vercel.json | 12 +++++++ 4 files changed, 92 insertions(+) create mode 100644 client/public/.well-known/apple-app-site-association create mode 100644 client/public/remote-link.html create mode 100644 scripts/native-links.test.mjs diff --git a/client/public/.well-known/apple-app-site-association b/client/public/.well-known/apple-app-site-association new file mode 100644 index 0000000..505adec --- /dev/null +++ b/client/public/.well-known/apple-app-site-association @@ -0,0 +1,15 @@ +{ + "applinks": { + "apps": [], + "details": [ + { + "appID": "Y5TCB759QL.io.hexawallet.keeper", + "paths": ["/app/prod/remote/*"] + }, + { + "appID": "Y5TCB759QL.io.hexawallet.hexakeeper.dev", + "paths": ["/app/dev/remote/*"] + } + ] + } +} diff --git a/client/public/remote-link.html b/client/public/remote-link.html new file mode 100644 index 0000000..7bfdb81 --- /dev/null +++ b/client/public/remote-link.html @@ -0,0 +1,29 @@ + + + + + + + + Open a remote key link in Bitcoin Keeper + + + + + + + + + +
+

Open this link in Bitcoin Keeper

+

Install Bitcoin Keeper on this device, then open the original link again to continue the remote key exchange.

+

Get Bitcoin Keeper for iPhone

+

Get Bitcoin Keeper for Android

+
+ + diff --git a/scripts/native-links.test.mjs b/scripts/native-links.test.mjs new file mode 100644 index 0000000..ff61fee --- /dev/null +++ b/scripts/native-links.test.mjs @@ -0,0 +1,36 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; + +const config = JSON.parse(readFileSync(new URL("../vercel.json", import.meta.url), "utf8")); +const association = JSON.parse( + readFileSync(new URL("../client/public/.well-known/apple-app-site-association", import.meta.url), "utf8"), +); +const fallback = readFileSync(new URL("../client/public/remote-link.html", import.meta.url), "utf8"); + +test("iOS association maps production and development links to their apps", () => { + assert.deepEqual(association.applinks.details, [ + { appID: "Y5TCB759QL.io.hexawallet.keeper", paths: ["/app/prod/remote/*"] }, + { appID: "Y5TCB759QL.io.hexawallet.hexakeeper.dev", paths: ["/app/dev/remote/*"] }, + ]); + assert.equal( + config.headers.find((entry) => entry.source === "/.well-known/apple-app-site-association") + ?.headers.find((entry) => entry.key === "Content-Type")?.value, + "application/json", + ); +}); + +test("remote links reach a generic preview rather than the 404 route", () => { + const remoteRoute = config.routes.find((entry) => entry.dest === "/remote-link.html"); + const catchAllIndex = config.routes.findIndex((entry) => entry.dest === "/404.html"); + assert.ok(remoteRoute); + assert.ok(config.routes.indexOf(remoteRoute) < catchAllIndex); + const matches = new RegExp(remoteRoute.src); + const key = "0123456789abcdef01234567"; + assert.ok(matches.test(`/app/prod/remote/${key}`)); + assert.ok(matches.test(`/app/dev/remote/${key}`)); + assert.ok(!matches.test(`/app/prod/remote/${key}/unexpected`)); + assert.match(fallback, /property="og:image"/); + assert.match(fallback, /name="robots" content="noindex,nofollow"/); + assert.doesNotMatch(fallback, /location\.pathname|location\.href|document\.URL/); +}); diff --git a/vercel.json b/vercel.json index d054dc4..acb702d 100644 --- a/vercel.json +++ b/vercel.json @@ -3,6 +3,14 @@ "installCommand": "pnpm install --frozen-lockfile", "buildCommand": "pnpm run build", "outputDirectory": "dist/public", + "headers": [ + { + "source": "/.well-known/apple-app-site-association", + "headers": [ + { "key": "Content-Type", "value": "application/json" } + ] + } + ], "routes": [ { "handle": "filesystem" @@ -36,6 +44,10 @@ "src": "/(features|contributors|ask-keeper|privacy-policy|terms-of-service)/?", "dest": "/$1/index.html" }, + { + "src": "^/app/(dev|prod)/remote/[0-9a-f]{24}/?$", + "dest": "/remote-link.html" + }, { "src": "/", "dest": "/index.html" From ecd08af9c654fa0a0c2c12f571fe04f9b37d1f8d Mon Sep 17 00:00:00 2001 From: Anant Date: Thu, 8 Oct 2026 18:01:47 +0530 Subject: [PATCH 2/5] feat: associate public Android release APK with website links --- client/public/.well-known/assetlinks.json | 12 ++++++++++++ scripts/native-links.test.mjs | 24 +++++++++++++++++++++++ vercel.json | 6 ++++++ 3 files changed, 42 insertions(+) create mode 100644 client/public/.well-known/assetlinks.json diff --git a/client/public/.well-known/assetlinks.json b/client/public/.well-known/assetlinks.json new file mode 100644 index 0000000..c9ddb93 --- /dev/null +++ b/client/public/.well-known/assetlinks.json @@ -0,0 +1,12 @@ +[ + { + "relation": ["delegate_permission/common.handle_all_urls"], + "target": { + "namespace": "android_app", + "package_name": "io.hexawallet.bitcoinkeeper", + "sha256_cert_fingerprints": [ + "BF:A0:23:D9:9F:AC:EB:AF:A4:A9:AF:22:B9:E4:9A:13:DB:BF:A3:EE:82:5B:E3:DA:16:CC:A9:E3:EA:1B:24:3A" + ] + } + } +] diff --git a/scripts/native-links.test.mjs b/scripts/native-links.test.mjs index ff61fee..396de37 100644 --- a/scripts/native-links.test.mjs +++ b/scripts/native-links.test.mjs @@ -6,6 +6,9 @@ const config = JSON.parse(readFileSync(new URL("../vercel.json", import.meta.url const association = JSON.parse( readFileSync(new URL("../client/public/.well-known/apple-app-site-association", import.meta.url), "utf8"), ); +const assetLinks = JSON.parse( + readFileSync(new URL("../client/public/.well-known/assetlinks.json", import.meta.url), "utf8"), +); const fallback = readFileSync(new URL("../client/public/remote-link.html", import.meta.url), "utf8"); test("iOS association maps production and development links to their apps", () => { @@ -20,6 +23,27 @@ test("iOS association maps production and development links to their apps", () = ); }); +test("Android association matches the published 2.6.3 APK certificate", () => { + // Source: https://github.com/KeeperCommunity/bitcoin-keeper/releases/tag/v2.6.3 + // The release APK SHA-256 is a20d934ebd80ece779d3c171c7906bb4aff010337989ec1b826cab55c50eba46. + // apksigner reports this package and certificate; Play Store signing must be checked separately. + assert.deepEqual(assetLinks, [{ + relation: ["delegate_permission/common.handle_all_urls"], + target: { + namespace: "android_app", + package_name: "io.hexawallet.bitcoinkeeper", + sha256_cert_fingerprints: [ + "BF:A0:23:D9:9F:AC:EB:AF:A4:A9:AF:22:B9:E4:9A:13:DB:BF:A3:EE:82:5B:E3:DA:16:CC:A9:E3:EA:1B:24:3A", + ], + }, + }]); + assert.equal( + config.headers.find((entry) => entry.source === "/.well-known/assetlinks.json") + ?.headers.find((entry) => entry.key === "Content-Type")?.value, + "application/json", + ); +}); + test("remote links reach a generic preview rather than the 404 route", () => { const remoteRoute = config.routes.find((entry) => entry.dest === "/remote-link.html"); const catchAllIndex = config.routes.findIndex((entry) => entry.dest === "/404.html"); diff --git a/vercel.json b/vercel.json index acb702d..19c944c 100644 --- a/vercel.json +++ b/vercel.json @@ -9,6 +9,12 @@ "headers": [ { "key": "Content-Type", "value": "application/json" } ] + }, + { + "source": "/.well-known/assetlinks.json", + "headers": [ + { "key": "Content-Type", "value": "application/json" } + ] } ], "routes": [ From 56ae39736524f76e22d4daea9b3d1856b8154e27 Mon Sep 17 00:00:00 2001 From: Anant Date: Thu, 8 Oct 2026 18:10:10 +0530 Subject: [PATCH 3/5] fix: associate development Android remote links --- client/public/.well-known/assetlinks.json | 10 +++++++ scripts/native-links.test.mjs | 33 ++++++++++++++++------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/client/public/.well-known/assetlinks.json b/client/public/.well-known/assetlinks.json index c9ddb93..533ec76 100644 --- a/client/public/.well-known/assetlinks.json +++ b/client/public/.well-known/assetlinks.json @@ -8,5 +8,15 @@ "BF:A0:23:D9:9F:AC:EB:AF:A4:A9:AF:22:B9:E4:9A:13:DB:BF:A3:EE:82:5B:E3:DA:16:CC:A9:E3:EA:1B:24:3A" ] } + }, + { + "relation": ["delegate_permission/common.handle_all_urls"], + "target": { + "namespace": "android_app", + "package_name": "io.hexawallet.bitcoinkeeper.development", + "sha256_cert_fingerprints": [ + "FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C" + ] + } } ] diff --git a/scripts/native-links.test.mjs b/scripts/native-links.test.mjs index 396de37..c2d1384 100644 --- a/scripts/native-links.test.mjs +++ b/scripts/native-links.test.mjs @@ -23,20 +23,33 @@ test("iOS association maps production and development links to their apps", () = ); }); -test("Android association matches the published 2.6.3 APK certificate", () => { +test("Android association matches the published APK and development debug certificates", () => { // Source: https://github.com/KeeperCommunity/bitcoin-keeper/releases/tag/v2.6.3 // The release APK SHA-256 is a20d934ebd80ece779d3c171c7906bb4aff010337989ec1b826cab55c50eba46. // apksigner reports this package and certificate; Play Store signing must be checked separately. - assert.deepEqual(assetLinks, [{ - relation: ["delegate_permission/common.handle_all_urls"], - target: { - namespace: "android_app", - package_name: "io.hexawallet.bitcoinkeeper", - sha256_cert_fingerprints: [ - "BF:A0:23:D9:9F:AC:EB:AF:A4:A9:AF:22:B9:E4:9A:13:DB:BF:A3:EE:82:5B:E3:DA:16:CC:A9:E3:EA:1B:24:3A", - ], + // Development fingerprint: keytool on the tracked android/app/debug.keystore. + assert.deepEqual(assetLinks, [ + { + relation: ["delegate_permission/common.handle_all_urls"], + target: { + namespace: "android_app", + package_name: "io.hexawallet.bitcoinkeeper", + sha256_cert_fingerprints: [ + "BF:A0:23:D9:9F:AC:EB:AF:A4:A9:AF:22:B9:E4:9A:13:DB:BF:A3:EE:82:5B:E3:DA:16:CC:A9:E3:EA:1B:24:3A", + ], + }, }, - }]); + { + relation: ["delegate_permission/common.handle_all_urls"], + target: { + namespace: "android_app", + package_name: "io.hexawallet.bitcoinkeeper.development", + sha256_cert_fingerprints: [ + "FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C", + ], + }, + }, + ]); assert.equal( config.headers.find((entry) => entry.source === "/.well-known/assetlinks.json") ?.headers.find((entry) => entry.key === "Content-Type")?.value, From cfe7b15631cd71c827cd1c78096fe30295e75acd Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Tue, 13 Oct 2026 04:05:01 +0000 Subject: [PATCH 4/5] fix: match Android development links to the actual app package --- .github/workflows/native-links.yml | 56 ++++++++ client/public/.well-known/assetlinks.json | 2 +- .../android-development-association.test.mjs | 134 ++++++++++++++++++ scripts/native-links.test.mjs | 3 +- 4 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/native-links.yml create mode 100644 scripts/android-development-association.test.mjs diff --git a/.github/workflows/native-links.yml b/.github/workflows/native-links.yml new file mode 100644 index 0000000..f1e65a6 --- /dev/null +++ b/.github/workflows/native-links.yml @@ -0,0 +1,56 @@ +name: Native link associations + +on: + pull_request: + paths: + - client/public/.well-known/** + - client/public/remote-link.html + - vercel.json + - scripts/native-links.test.mjs + - scripts/android-development-association.test.mjs + - .github/workflows/native-links.yml + push: + branches: [main] + paths: + - client/public/.well-known/** + - client/public/remote-link.html + - vercel.json + - scripts/native-links.test.mjs + - scripts/android-development-association.test.mjs + - .github/workflows/native-links.yml + +permissions: + contents: read + +jobs: + native-links: + name: Native link source and certificate checks + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + with: + path: website + persist-credentials: false + - uses: actions/checkout@v4 + with: + repository: KeeperCommunity/bitcoin-keeper + ref: bb66cea459fbb00ec33c5c4ebd601d07c0d7c125 + path: keeper-android-source + sparse-checkout: | + android/app/build.gradle + android/app/debug.keystore + sparse-checkout-cone-mode: false + persist-credentials: false + - uses: actions/setup-node@v4 + with: + node-version: 22 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + - name: Verify native associations against the pinned mobile inputs + working-directory: website + env: + KEEPER_ANDROID_SOURCE: ${{ github.workspace }}/keeper-android-source + run: node --test scripts/native-links.test.mjs scripts/android-development-association.test.mjs diff --git a/client/public/.well-known/assetlinks.json b/client/public/.well-known/assetlinks.json index 533ec76..81bf42a 100644 --- a/client/public/.well-known/assetlinks.json +++ b/client/public/.well-known/assetlinks.json @@ -13,7 +13,7 @@ "relation": ["delegate_permission/common.handle_all_urls"], "target": { "namespace": "android_app", - "package_name": "io.hexawallet.bitcoinkeeper.development", + "package_name": "io.hexawallet.keeper.development", "sha256_cert_fingerprints": [ "FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C" ] diff --git a/scripts/android-development-association.test.mjs b/scripts/android-development-association.test.mjs new file mode 100644 index 0000000..5ac21d8 --- /dev/null +++ b/scripts/android-development-association.test.mjs @@ -0,0 +1,134 @@ +import assert from "node:assert/strict"; +import { execFileSync } from "node:child_process"; +import { createHash, X509Certificate } from "node:crypto"; +import { readFileSync } from "node:fs"; +import { resolve } from "node:path"; +import test from "node:test"; + +// Public R4 source already integrated in mobile PR #7045. No native build or +// production-signing credentials are needed to check these tracked inputs. +const keeperSourceSha = "bb66cea459fbb00ec33c5c4ebd601d07c0d7c125"; +const source = process.env.KEEPER_ANDROID_SOURCE; +assert.ok( + source, + "Set KEEPER_ANDROID_SOURCE to an isolated Keeper checkout at the pinned SHA" +); +assert.equal( + execFileSync("git", ["-C", source, "rev-parse", "HEAD"], { + encoding: "utf8", + }).trim(), + keeperSourceSha, + "Use the pinned public mobile source, without changing an existing checkout" +); +assert.equal( + execFileSync( + "git", + [ + "-C", + source, + "status", + "--porcelain", + "--", + "android/app/build.gradle", + "android/app/debug.keystore", + ], + { encoding: "utf8" } + ).trim(), + "", + "The association source inputs must have no local changes" +); + +const gradleBytes = readFileSync(resolve(source, "android/app/build.gradle")); +const keystore = resolve(source, "android/app/debug.keystore"); +assert.equal( + createHash("sha256").update(gradleBytes).digest("hex"), + "a5a0d18b8fb3c4fee645bb8ab4400de4cc760ab83fc7ba3b08bc4e9d807336ee" +); +assert.equal( + createHash("sha256").update(readFileSync(keystore)).digest("hex"), + "221e0a3106aa4c3ccc154e0a418b55020b3f9ea6e84f92e8749cd9e2f39f5e58" +); +const gradle = gradleBytes.toString("utf8"); +const assetLinks = JSON.parse( + readFileSync( + new URL("../client/public/.well-known/assetlinks.json", import.meta.url), + "utf8" + ) +); + +// Read the pinned file's literal sections. This deliberately fails if its +// structure or inputs change; it does not try to evaluate arbitrary Gradle. +function section(text, name) { + const match = new RegExp(`\\b${name}\\s*\\{`).exec(text); + assert.ok(match, `Missing Gradle section ${name}`); + let depth = 1; + const start = match.index + match[0].length; + for (let end = start; end < text.length; end += 1) { + if (text[end] === "{") depth += 1; + if (text[end] === "}" && --depth === 0) return text.slice(start, end); + } + assert.fail(`Unclosed Gradle section ${name}`); +} + +function literal(text, name) { + const match = new RegExp(`^\\s*${name}\\s+["']([^"']+)["']\\s*$`, "m").exec( + text + ); + assert.ok(match, `Missing literal Gradle ${name}`); + return match[1]; +} + +test("development association uses the actual mobile flavor package and debug certificate", () => { + const defaults = section(gradle, "defaultConfig"); + const development = section(section(gradle, "productFlavors"), "development"); + assert.doesNotMatch(development, /^\s*applicationId\s/m); + assert.doesNotMatch(defaults, /^\s*applicationIdSuffix\s/m); + const packageName = + literal(defaults, "applicationId") + + literal(development, "applicationIdSuffix"); + const debugSigning = section(section(gradle, "signingConfigs"), "debug"); + assert.match(debugSigning, /storeFile\s+file\('debug\.keystore'\)/); + assert.equal(literal(debugSigning, "keyAlias"), "androiddebugkey"); + assert.match( + section(section(gradle, "buildTypes"), "debug"), + /signingConfig\s+signingConfigs\.debug/ + ); + + // Export only the public certificate from the tracked, publicly known debug + // keystore. Neither a private key nor a release signing identity is loaded. + const certificate = new X509Certificate( + execFileSync( + "keytool", + [ + "-exportcert", + "-keystore", + keystore, + "-alias", + "androiddebugkey", + "-storepass", + "android", + ], + { stdio: ["ignore", "pipe", "pipe"] } + ) + ); + const developmentLinks = assetLinks.filter(entry => + entry.target.package_name.endsWith(".development") + ); + assert.deepEqual(developmentLinks, [ + { + relation: ["delegate_permission/common.handle_all_urls"], + target: { + namespace: "android_app", + package_name: packageName, + sha256_cert_fingerprints: [certificate.fingerprint256], + }, + }, + ]); + + const productionPackage = literal( + section(section(gradle, "productFlavors"), "production"), + "applicationId" + ); + assert.equal(assetLinks[0].target.package_name, productionPackage); + assert.notEqual(packageName, `${productionPackage}.development`); +}); diff --git a/scripts/native-links.test.mjs b/scripts/native-links.test.mjs index c2d1384..f50568a 100644 --- a/scripts/native-links.test.mjs +++ b/scripts/native-links.test.mjs @@ -27,6 +27,7 @@ test("Android association matches the published APK and development debug certif // Source: https://github.com/KeeperCommunity/bitcoin-keeper/releases/tag/v2.6.3 // The release APK SHA-256 is a20d934ebd80ece779d3c171c7906bb4aff010337989ec1b826cab55c50eba46. // apksigner reports this package and certificate; Play Store signing must be checked separately. + // Development package: Keeper defaultConfig applicationId plus development applicationIdSuffix. // Development fingerprint: keytool on the tracked android/app/debug.keystore. assert.deepEqual(assetLinks, [ { @@ -43,7 +44,7 @@ test("Android association matches the published APK and development debug certif relation: ["delegate_permission/common.handle_all_urls"], target: { namespace: "android_app", - package_name: "io.hexawallet.bitcoinkeeper.development", + package_name: "io.hexawallet.keeper.development", sha256_cert_fingerprints: [ "FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C", ], From 4da972aff8248f09acfd7949bfbfb01e473cdbbf Mon Sep 17 00:00:00 2001 From: Antuz tap Date: Thu, 22 Oct 2026 05:02:03 +0000 Subject: [PATCH 5/5] fix: publish production-safe native link associations --- .github/workflows/native-links.yml | 4 +- client/public/.well-known/assetlinks.json | 13 +--- client/public/remote-link-dev.html | 27 ++++++++ .../android-development-association.test.mjs | 21 +++---- scripts/native-links.test.mjs | 62 +++++++++++++------ vercel.json | 26 ++++---- 6 files changed, 96 insertions(+), 57 deletions(-) create mode 100644 client/public/remote-link-dev.html diff --git a/.github/workflows/native-links.yml b/.github/workflows/native-links.yml index f1e65a6..3e47d0e 100644 --- a/.github/workflows/native-links.yml +++ b/.github/workflows/native-links.yml @@ -5,6 +5,7 @@ on: paths: - client/public/.well-known/** - client/public/remote-link.html + - client/public/remote-link-dev.html - vercel.json - scripts/native-links.test.mjs - scripts/android-development-association.test.mjs @@ -14,6 +15,7 @@ on: paths: - client/public/.well-known/** - client/public/remote-link.html + - client/public/remote-link-dev.html - vercel.json - scripts/native-links.test.mjs - scripts/android-development-association.test.mjs @@ -35,7 +37,7 @@ jobs: - uses: actions/checkout@v4 with: repository: KeeperCommunity/bitcoin-keeper - ref: bb66cea459fbb00ec33c5c4ebd601d07c0d7c125 + ref: 1d8a86a7462d935cbd0e28b857934b5718c152fc path: keeper-android-source sparse-checkout: | android/app/build.gradle diff --git a/client/public/.well-known/assetlinks.json b/client/public/.well-known/assetlinks.json index 81bf42a..0a83700 100644 --- a/client/public/.well-known/assetlinks.json +++ b/client/public/.well-known/assetlinks.json @@ -5,17 +5,8 @@ "namespace": "android_app", "package_name": "io.hexawallet.bitcoinkeeper", "sha256_cert_fingerprints": [ - "BF:A0:23:D9:9F:AC:EB:AF:A4:A9:AF:22:B9:E4:9A:13:DB:BF:A3:EE:82:5B:E3:DA:16:CC:A9:E3:EA:1B:24:3A" - ] - } - }, - { - "relation": ["delegate_permission/common.handle_all_urls"], - "target": { - "namespace": "android_app", - "package_name": "io.hexawallet.keeper.development", - "sha256_cert_fingerprints": [ - "FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C" + "BF:A0:23:D9:9F:AC:EB:AF:A4:A9:AF:22:B9:E4:9A:13:DB:BF:A3:EE:82:5B:E3:DA:16:CC:A9:E3:EA:1B:24:3A", + "66:56:8F:D4:FB:14:C0:13:4F:F4:05:57:62:60:70:38:AD:40:0B:A5:CB:C8:E2:3E:5E:25:26:5A:02:34:46:5C" ] } } diff --git a/client/public/remote-link-dev.html b/client/public/remote-link-dev.html new file mode 100644 index 0000000..bdd13d8 --- /dev/null +++ b/client/public/remote-link-dev.html @@ -0,0 +1,27 @@ + + + + + + + + Development remote key link + + + + + + + + + +
+

This link is for a development build

+

Ask the person coordinating this test for the matching Bitcoin Keeper development build and instructions for opening the original link.

+

Android development links do not open the app automatically from this website. The public store app cannot open this development link.

+
+ + diff --git a/scripts/android-development-association.test.mjs b/scripts/android-development-association.test.mjs index 5ac21d8..4929b2e 100644 --- a/scripts/android-development-association.test.mjs +++ b/scripts/android-development-association.test.mjs @@ -7,7 +7,7 @@ import test from "node:test"; // Public R4 source already integrated in mobile PR #7045. No native build or // production-signing credentials are needed to check these tracked inputs. -const keeperSourceSha = "bb66cea459fbb00ec33c5c4ebd601d07c0d7c125"; +const keeperSourceSha = "1d8a86a7462d935cbd0e28b857934b5718c152fc"; const source = process.env.KEEPER_ANDROID_SOURCE; assert.ok( source, @@ -42,7 +42,7 @@ const gradleBytes = readFileSync(resolve(source, "android/app/build.gradle")); const keystore = resolve(source, "android/app/debug.keystore"); assert.equal( createHash("sha256").update(gradleBytes).digest("hex"), - "a5a0d18b8fb3c4fee645bb8ab4400de4cc760ab83fc7ba3b08bc4e9d807336ee" + "5935b7aa340c5640f52a84b700d72aab5fb2c454b2431ba50f1d9bae158aa7dc" ); assert.equal( createHash("sha256").update(readFileSync(keystore)).digest("hex"), @@ -78,7 +78,7 @@ function literal(text, name) { return match[1]; } -test("development association uses the actual mobile flavor package and debug certificate", () => { +test("production host excludes the actual mobile development package and public debug certificate", () => { const defaults = section(gradle, "defaultConfig"); const development = section(section(gradle, "productFlavors"), "development"); assert.doesNotMatch(development, /^\s*applicationId\s/m); @@ -114,16 +114,11 @@ test("development association uses the actual mobile flavor package and debug ce const developmentLinks = assetLinks.filter(entry => entry.target.package_name.endsWith(".development") ); - assert.deepEqual(developmentLinks, [ - { - relation: ["delegate_permission/common.handle_all_urls"], - target: { - namespace: "android_app", - package_name: packageName, - sha256_cert_fingerprints: [certificate.fingerprint256], - }, - }, - ]); + assert.deepEqual(developmentLinks, []); + for (const entry of assetLinks) { + assert.notEqual(entry.target.package_name, packageName); + assert.ok(!entry.target.sha256_cert_fingerprints.includes(certificate.fingerprint256)); + } const productionPackage = literal( section(section(gradle, "productFlavors"), "production"), diff --git a/scripts/native-links.test.mjs b/scripts/native-links.test.mjs index f50568a..2a27983 100644 --- a/scripts/native-links.test.mjs +++ b/scripts/native-links.test.mjs @@ -10,6 +10,18 @@ const assetLinks = JSON.parse( readFileSync(new URL("../client/public/.well-known/assetlinks.json", import.meta.url), "utf8"), ); const fallback = readFileSync(new URL("../client/public/remote-link.html", import.meta.url), "utf8"); +const developmentFallback = readFileSync(new URL("../client/public/remote-link-dev.html", import.meta.url), "utf8"); + +function associationRoute(path) { + const index = config.routes.findIndex(entry => entry.src && new RegExp(entry.src).test(path)); + assert.ok(index >= 0 && index < config.routes.findIndex(entry => entry.handle === "filesystem")); + const route = config.routes[index]; + assert.equal(route.dest, path); + assert.equal(route.headers.Location, undefined); + assert.ok(route.status === undefined || route.status === 200); + assert.equal(new RegExp(route.src).test(`${path}/unexpected`), false); + return route; +} test("iOS association maps production and development links to their apps", () => { assert.deepEqual(association.applinks.details, [ @@ -17,18 +29,16 @@ test("iOS association maps production and development links to their apps", () = { appID: "Y5TCB759QL.io.hexawallet.hexakeeper.dev", paths: ["/app/dev/remote/*"] }, ]); assert.equal( - config.headers.find((entry) => entry.source === "/.well-known/apple-app-site-association") - ?.headers.find((entry) => entry.key === "Content-Type")?.value, + associationRoute("/.well-known/apple-app-site-association").headers["Content-Type"], "application/json", ); }); -test("Android association matches the published APK and development debug certificates", () => { +test("Android association trusts only verified standalone and Play production certificates", () => { // Source: https://github.com/KeeperCommunity/bitcoin-keeper/releases/tag/v2.6.3 // The release APK SHA-256 is a20d934ebd80ece779d3c171c7906bb4aff010337989ec1b826cab55c50eba46. - // apksigner reports this package and certificate; Play Store signing must be checked separately. - // Development package: Keeper defaultConfig applicationId plus development applicationIdSuffix. - // Development fingerprint: keytool on the tracked android/app/debug.keystore. + // This standalone identity was also verified against 2.6.4 in Backlog232. + // Play App Signing identity: authenticated Console receipt, 21 Oct 2026 11:38 UTC, Backlog232. assert.deepEqual(assetLinks, [ { relation: ["delegate_permission/common.handle_all_urls"], @@ -37,38 +47,52 @@ test("Android association matches the published APK and development debug certif package_name: "io.hexawallet.bitcoinkeeper", sha256_cert_fingerprints: [ "BF:A0:23:D9:9F:AC:EB:AF:A4:A9:AF:22:B9:E4:9A:13:DB:BF:A3:EE:82:5B:E3:DA:16:CC:A9:E3:EA:1B:24:3A", - ], - }, - }, - { - relation: ["delegate_permission/common.handle_all_urls"], - target: { - namespace: "android_app", - package_name: "io.hexawallet.keeper.development", - sha256_cert_fingerprints: [ - "FA:C6:17:45:DC:09:03:78:6F:B9:ED:E6:2A:96:2B:39:9F:73:48:F0:BB:6F:89:9B:83:32:66:75:91:03:3B:9C", + "66:56:8F:D4:FB:14:C0:13:4F:F4:05:57:62:60:70:38:AD:40:0B:A5:CB:C8:E2:3E:5E:25:26:5A:02:34:46:5C", ], }, }, ]); assert.equal( - config.headers.find((entry) => entry.source === "/.well-known/assetlinks.json") - ?.headers.find((entry) => entry.key === "Content-Type")?.value, + associationRoute("/.well-known/assetlinks.json").headers["Content-Type"], "application/json", ); }); test("remote links reach a generic preview rather than the 404 route", () => { const remoteRoute = config.routes.find((entry) => entry.dest === "/remote-link.html"); + const developmentRoute = config.routes.find((entry) => entry.dest === "/remote-link-dev.html"); const catchAllIndex = config.routes.findIndex((entry) => entry.dest === "/404.html"); assert.ok(remoteRoute); + assert.ok(developmentRoute); assert.ok(config.routes.indexOf(remoteRoute) < catchAllIndex); + assert.ok(config.routes.indexOf(developmentRoute) < catchAllIndex); const matches = new RegExp(remoteRoute.src); const key = "0123456789abcdef01234567"; assert.ok(matches.test(`/app/prod/remote/${key}`)); - assert.ok(matches.test(`/app/dev/remote/${key}`)); + assert.ok(!matches.test(`/app/dev/remote/${key}`)); assert.ok(!matches.test(`/app/prod/remote/${key}/unexpected`)); + assert.ok(!matches.test(`/app/prod/remote/${key.slice(1)}`)); + assert.ok(!matches.test(`/app/prod/remote/${key}0`)); + assert.ok(!matches.test(`/app/prod/remote/${key.toUpperCase()}`)); + const developmentMatches = new RegExp(developmentRoute.src); + assert.ok(developmentMatches.test(`/app/dev/remote/${key}`)); + assert.ok(!developmentMatches.test(`/app/prod/remote/${key}`)); + assert.ok(!developmentMatches.test(`/app/dev/remote/${key}/unexpected`)); assert.match(fallback, /property="og:image"/); assert.match(fallback, /name="robots" content="noindex,nofollow"/); assert.doesNotMatch(fallback, /location\.pathname|location\.href|document\.URL/); + for (const html of [fallback, developmentFallback]) { + assert.match(html, /name="referrer" content="no-referrer"/); + assert.match(html, /name="robots" content="noindex,nofollow"/); + assert.doesNotMatch(html, / { + for (const key of ["headers", "rewrites", "redirects", "cleanUrls", "trailingSlash"]) { + assert.equal(Object.hasOwn(config, key), false, `Do not mix routes with ${key}`); + } }); diff --git a/vercel.json b/vercel.json index 19c944c..5ce0a82 100644 --- a/vercel.json +++ b/vercel.json @@ -3,21 +3,17 @@ "installCommand": "pnpm install --frozen-lockfile", "buildCommand": "pnpm run build", "outputDirectory": "dist/public", - "headers": [ + "routes": [ { - "source": "/.well-known/apple-app-site-association", - "headers": [ - { "key": "Content-Type", "value": "application/json" } - ] + "src": "^/\\.well-known/apple-app-site-association$", + "dest": "/.well-known/apple-app-site-association", + "headers": { "Content-Type": "application/json" } }, { - "source": "/.well-known/assetlinks.json", - "headers": [ - { "key": "Content-Type", "value": "application/json" } - ] - } - ], - "routes": [ + "src": "^/\\.well-known/assetlinks\\.json$", + "dest": "/.well-known/assetlinks.json", + "headers": { "Content-Type": "application/json" } + }, { "handle": "filesystem" }, @@ -51,9 +47,13 @@ "dest": "/$1/index.html" }, { - "src": "^/app/(dev|prod)/remote/[0-9a-f]{24}/?$", + "src": "^/app/prod/remote/[0-9a-f]{24}/?$", "dest": "/remote-link.html" }, + { + "src": "^/app/dev/remote/[0-9a-f]{24}/?$", + "dest": "/remote-link-dev.html" + }, { "src": "/", "dest": "/index.html"