收口移动壳深链域名门禁
移动壳配置检查从共享公开主站 origin 推导 iOS associated domain Expo public config smoke 从共享公开主站 origin 推导 Android App Link host 同步移动壳深链声明文档和共享决策记录
This commit is contained in:
@@ -540,6 +540,12 @@ const sharedPublicWebUrl = extractStringConstExport(
|
||||
sharedContractSource,
|
||||
'HOST_BRIDGE_PUBLIC_WEB_URL',
|
||||
);
|
||||
const sharedPublicWebOriginUrl = new URL(sharedPublicWebOrigin);
|
||||
if (sharedPublicWebOriginUrl.protocol !== 'https:') {
|
||||
throw new Error('shared HostBridge public web origin must use https for mobile app links');
|
||||
}
|
||||
const sharedPublicWebHost = sharedPublicWebOriginUrl.hostname;
|
||||
const sharedPublicWebAssociatedDomain = `applinks:${sharedPublicWebHost}`;
|
||||
const handledMobileMethods = extractMobileBridgeHandledMethods(dispatchSource);
|
||||
const mobileCapabilities = sharedMobileBaseCapabilities;
|
||||
const iosMobileCapabilities = sharedMobileIosCapabilities;
|
||||
@@ -777,7 +783,7 @@ if ('releaseChannel' in appConfig || 'channel' in appConfig) {
|
||||
|
||||
assertSameList(
|
||||
appConfig.ios?.associatedDomains ?? [],
|
||||
['applinks:app.genarrative.world'],
|
||||
[sharedPublicWebAssociatedDomain],
|
||||
'mobile shell iOS associated domains',
|
||||
);
|
||||
|
||||
@@ -862,12 +868,14 @@ const androidFilterData = androidFilter.data ?? [];
|
||||
if (
|
||||
androidFilterData.length !== 1 ||
|
||||
androidFilterData[0]?.scheme !== 'https' ||
|
||||
androidFilterData[0]?.host !== 'app.genarrative.world' ||
|
||||
androidFilterData[0]?.host !== sharedPublicWebHost ||
|
||||
Object.keys(androidFilterData[0] ?? {}).some(
|
||||
(key) => key !== 'scheme' && key !== 'host',
|
||||
)
|
||||
) {
|
||||
throw new Error('mobile shell Android app link data must only bind https://app.genarrative.world');
|
||||
throw new Error(
|
||||
`mobile shell Android app link data must only bind ${sharedPublicWebOrigin}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (appConfig.extra?.genarrativeHostBridgeVersion !== sharedHostBridgeVersion) {
|
||||
|
||||
@@ -97,10 +97,31 @@ function extractNumberConstExport(source, exportName) {
|
||||
return Number(match[1]);
|
||||
}
|
||||
|
||||
function extractStringConstExport(source, exportName) {
|
||||
const match = source.match(
|
||||
new RegExp(`export const ${exportName}\\s*=\\s*'([^']+)';`),
|
||||
);
|
||||
if (!match) {
|
||||
throw new Error(`unable to read ${exportName}`);
|
||||
}
|
||||
|
||||
return match[1];
|
||||
}
|
||||
|
||||
const sharedHostBridgeVersion = extractNumberConstExport(
|
||||
sharedContractSource,
|
||||
'HOST_BRIDGE_VERSION',
|
||||
);
|
||||
const sharedPublicWebOrigin = extractStringConstExport(
|
||||
sharedContractSource,
|
||||
'HOST_BRIDGE_PUBLIC_WEB_ORIGIN',
|
||||
);
|
||||
const sharedPublicWebOriginUrl = new URL(sharedPublicWebOrigin);
|
||||
if (sharedPublicWebOriginUrl.protocol !== 'https:') {
|
||||
throw new Error('shared HostBridge public web origin must use https for mobile app links');
|
||||
}
|
||||
const sharedPublicWebHost = sharedPublicWebOriginUrl.hostname;
|
||||
const sharedPublicWebAssociatedDomain = `applinks:${sharedPublicWebHost}`;
|
||||
|
||||
assertEqual(expoConfig.name, 'Genarrative', 'name');
|
||||
assertEqual(expoConfig.slug, 'genarrative-mobile-shell', 'slug');
|
||||
@@ -138,7 +159,7 @@ assertEqual(
|
||||
assertEqual(expoConfig.ios?.buildNumber, '1', 'iOS build number');
|
||||
assertSameList(
|
||||
expoConfig.ios?.associatedDomains,
|
||||
['applinks:app.genarrative.world'],
|
||||
[sharedPublicWebAssociatedDomain],
|
||||
'iOS associated domains',
|
||||
);
|
||||
assertEqual(
|
||||
@@ -238,12 +259,14 @@ if (
|
||||
!Array.isArray(appLinkFilter.data) ||
|
||||
appLinkFilter.data.length !== 1 ||
|
||||
appLinkFilter.data[0]?.scheme !== 'https' ||
|
||||
appLinkFilter.data[0]?.host !== 'app.genarrative.world' ||
|
||||
appLinkFilter.data[0]?.host !== sharedPublicWebHost ||
|
||||
Object.keys(appLinkFilter.data[0] ?? {}).some(
|
||||
(key) => key !== 'scheme' && key !== 'host',
|
||||
)
|
||||
) {
|
||||
throw new Error('Expo config Android app link data must only bind https://app.genarrative.world');
|
||||
throw new Error(
|
||||
`Expo config Android app link data must only bind ${sharedPublicWebOrigin}`,
|
||||
);
|
||||
}
|
||||
|
||||
const imagePickerPlugin = findPlugin('expo-image-picker');
|
||||
|
||||
Reference in New Issue
Block a user