feat(server): add .well-known/assetlinks.json for Android deeplinks (#1772)
Co-authored-by: RainbowBird <rbxin2003@outlook.com>
This commit is contained in:
@@ -20,3 +20,8 @@ API_SERVER_URL=""
|
||||
GATEWAY_BASE_URL="http://localhost:18080"
|
||||
DEFAULT_CHAT_MODEL="openai/gpt-5-mini"
|
||||
DEFAULT_TTS_MODEL="microsoft/v1"
|
||||
|
||||
|
||||
ASSETLINKS_PACKAGE_NAME="ai.moeru.airi_pocket"
|
||||
ASSETLINKS_SHA256_FINGERPRINTS="1D:E5:2D:DC:89:DA:C9:C1:4B:5F:4A:48:E4:2D:62:E5:52:82:B7:41:D3:96:73:13:91:C8:41:D2:84:DF:84:55"
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import { createFluxRoutes } from './routes/flux'
|
||||
import { createV1CompletionsRoutes } from './routes/openai/v1'
|
||||
import { createProviderRoutes } from './routes/providers'
|
||||
import { createStripeRoutes } from './routes/stripe'
|
||||
import { createWellKnownRoutes } from './routes/well-known'
|
||||
import { createBillingMq } from './services/billing/billing-events'
|
||||
import { createBillingService } from './services/billing/billing-service'
|
||||
import { createFluxMeter } from './services/billing/flux-meter'
|
||||
@@ -184,6 +185,7 @@ export async function buildApp(deps: AppDeps) {
|
||||
env: deps.env,
|
||||
configKV: deps.configKV,
|
||||
}))
|
||||
.route('/.well-known', createWellKnownRoutes({ env: deps.env }))
|
||||
|
||||
/**
|
||||
* Character routes are handled by the character service.
|
||||
|
||||
@@ -89,6 +89,11 @@ const EnvSchema = object({
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: optional(string()),
|
||||
OTEL_EXPORTER_OTLP_HEADERS: optional(string()),
|
||||
OTEL_DEBUG: optional(string()),
|
||||
// Asset Links (Android deep link delegation)
|
||||
// Example: ASSETLINKS_PACKAGE_NAME=com.example.app
|
||||
// ASSETLINKS_SHA256_FINGERPRINTS=AB:CD:... ,EF:12:...
|
||||
ASSETLINKS_PACKAGE_NAME: optional(string(), 'ai.moeru.airi_pocket'),
|
||||
ASSETLINKS_SHA256_FINGERPRINTS: optional(string(), ''),
|
||||
})
|
||||
|
||||
export type Env = InferOutput<typeof EnvSchema>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { Env } from '../../libs/env'
|
||||
import type { HonoEnv } from '../../types/hono'
|
||||
|
||||
import { Hono } from 'hono'
|
||||
|
||||
export interface WellKnownDeps {
|
||||
env: Env
|
||||
}
|
||||
|
||||
export function createWellKnownRoutes(deps: WellKnownDeps) {
|
||||
return new Hono<HonoEnv>()
|
||||
.get('/assetlinks.json', (c) => {
|
||||
const pkg = deps.env.ASSETLINKS_PACKAGE_NAME
|
||||
const fingerprintsRaw = deps.env.ASSETLINKS_SHA256_FINGERPRINTS
|
||||
|
||||
const fingerprints = fingerprintsRaw
|
||||
.split(',')
|
||||
.map(s => s.trim())
|
||||
.filter(Boolean)
|
||||
|
||||
const payload = [
|
||||
{
|
||||
relation: ['delegate_permission/common.handle_all_urls'],
|
||||
target: {
|
||||
namespace: 'android_app',
|
||||
package_name: pkg,
|
||||
sha256_cert_fingerprints: fingerprints,
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
return c.json(payload)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user