fix(android): share public legal URLs with cloud builds
This commit is contained in:
@@ -13,11 +13,38 @@ $ErrorActionPreference = 'Stop'
|
||||
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$projectRoot = Split-Path -Parent $scriptDirectory
|
||||
|
||||
function Get-ProjectEnvValue {
|
||||
param([string]$Name)
|
||||
|
||||
$publicEnvPath = Join-Path $projectRoot '.env'
|
||||
if (-not (Test-Path -LiteralPath $publicEnvPath -PathType Leaf)) {
|
||||
return ''
|
||||
}
|
||||
$prefix = "$Name="
|
||||
foreach ($line in Get-Content -LiteralPath $publicEnvPath) {
|
||||
$trimmed = $line.Trim()
|
||||
if ($trimmed.StartsWith($prefix, [StringComparison]::Ordinal)) {
|
||||
return $trimmed.Substring($prefix.Length).Trim().Trim('"').Trim("'")
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($ExpectedTermsUrl)) {
|
||||
$ExpectedTermsUrl = $env:VITE_APP_TERMS_URL
|
||||
$ExpectedTermsUrl = if (-not [string]::IsNullOrWhiteSpace($env:VITE_APP_TERMS_URL)) {
|
||||
$env:VITE_APP_TERMS_URL
|
||||
}
|
||||
else {
|
||||
Get-ProjectEnvValue -Name 'VITE_APP_TERMS_URL'
|
||||
}
|
||||
}
|
||||
if ([string]::IsNullOrWhiteSpace($ExpectedPrivacyUrl)) {
|
||||
$ExpectedPrivacyUrl = $env:VITE_APP_PRIVACY_URL
|
||||
$ExpectedPrivacyUrl = if (-not [string]::IsNullOrWhiteSpace($env:VITE_APP_PRIVACY_URL)) {
|
||||
$env:VITE_APP_PRIVACY_URL
|
||||
}
|
||||
else {
|
||||
Get-ProjectEnvValue -Name 'VITE_APP_PRIVACY_URL'
|
||||
}
|
||||
}
|
||||
if (
|
||||
[string]::IsNullOrWhiteSpace($ExpectedTermsUrl) -xor
|
||||
@@ -25,6 +52,17 @@ if (
|
||||
) {
|
||||
throw 'ExpectedTermsUrl and ExpectedPrivacyUrl must be provided together.'
|
||||
}
|
||||
$uncheckedConsentMessage = -join @(
|
||||
[char]0x8BF7,
|
||||
[char]0x5148,
|
||||
[char]0x9605,
|
||||
[char]0x8BFB,
|
||||
[char]0x5E76,
|
||||
[char]0x52FE,
|
||||
[char]0x9009,
|
||||
[char]0x540C,
|
||||
[char]0x610F
|
||||
)
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($ApkPath)) {
|
||||
$ApkPath = Join-Path $projectRoot 'dist\debug\android_debug.apk'
|
||||
@@ -163,14 +201,20 @@ try {
|
||||
if ($legalAppServiceFiles.Count -ne 1) {
|
||||
throw "Expected exactly one App service for login legal-link verification, found $($legalAppServiceFiles.Count)."
|
||||
}
|
||||
$legalAppService = Get-Content -Raw -Encoding UTF8 -LiteralPath $legalAppServiceFiles[0]
|
||||
$legalAppServicePath = if ($legalAppServiceFiles[0] -is [IO.FileInfo]) {
|
||||
$legalAppServiceFiles[0].FullName
|
||||
}
|
||||
else {
|
||||
[string]$legalAppServiceFiles[0]
|
||||
}
|
||||
$legalAppService = Get-Content -Raw -Encoding UTF8 -LiteralPath $legalAppServicePath
|
||||
if (-not $legalAppService.Contains($ExpectedTermsUrl)) {
|
||||
throw 'Packaged login flow is missing the expected service agreement URL.'
|
||||
}
|
||||
if (-not $legalAppService.Contains($ExpectedPrivacyUrl)) {
|
||||
throw 'Packaged login flow is missing the expected privacy policy URL.'
|
||||
}
|
||||
if (-not $legalAppService.Contains('请先阅读并勾选同意')) {
|
||||
if (-not $legalAppService.Contains($uncheckedConsentMessage)) {
|
||||
throw 'Packaged login flow is missing the unchecked-consent failure message.'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user