From b759ec45391eebccfede75e3e9a0c285963d507f Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 21 Jan 2023 12:55:38 -0800 Subject: [PATCH] TWA/assetlinks support --- .config/example.yml | 6 ++++++ package.json | 2 +- packages/backend/src/config/types.ts | 6 ++++++ packages/backend/src/server/well-known.ts | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.config/example.yml b/.config/example.yml index 29f4a6229..900ac0905 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -145,6 +145,12 @@ id: 'aid' # '127.0.0.1/32' #] +# TWA +#twa: +# nameSpace: android_app +# packageName: tld.domain.twa +# sha256CertFingerprints: ['AB:CD:EF'] + # Upload or download file size limits (bytes) #maxFileSize: 262144000 diff --git a/package.json b/package.json index b5e3feea0..981c28712 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calckey", - "version": "13.0.8-rc4", + "version": "13.0.9-rc", "codename": "aqua", "repository": { "type": "git", diff --git a/packages/backend/src/config/types.ts b/packages/backend/src/config/types.ts index 0b9c4e8ba..e9c42c08f 100644 --- a/packages/backend/src/config/types.ts +++ b/packages/backend/src/config/types.ts @@ -64,6 +64,12 @@ export type Source = { mediaProxy?: string; proxyRemoteFiles?: boolean; + twa: { + nameSpace?: string; + packageName?: string; + sha256CertFingerprints?: string[]; + }; + // Managed hosting stuff maxUserSignups?: number; isManagedHosting?: boolean; diff --git a/packages/backend/src/server/well-known.ts b/packages/backend/src/server/well-known.ts index 4b839c879..b617e3809 100644 --- a/packages/backend/src/server/well-known.ts +++ b/packages/backend/src/server/well-known.ts @@ -74,6 +74,22 @@ router.get("/.well-known/host-meta.json", async (ctx) => { }; }); +if (config.twa.nameSpace != null) { + router.get("/.well-known/assetlinks.json", async (ctx) => { + ctx.set("Content-Type", "application/json"); + ctx.body = [ + { + relation: ["delegate_permission/common.handle_all_urls"], + target: { + namespace: config.twa.nameSpace, + package_name: config.twa.packageName, + sha256_cert_fingerprints: config.twa.sha256CertFingerprints, + }, + }, + ]; + }); +} + router.get("/.well-known/nodeinfo", async (ctx) => { ctx.body = { links }; });