mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
Use blob URL instead of query string API key for APK download
Fetches APK using X-API-Key header and returns blob URL instead of exposing API key in the download URL query string. This is more secure as API keys are not logged or leaked via Referer headers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
1 parent
c7bbbe5659
commit
a3a019a1fd
1 file changed
+22
-2
@@ -108,10 +108,11 @@ export class APKBuilderAdapter implements DeployAdapter {
|
||||
}
|
||||
|
||||
if (status.status === 'complete') {
|
||||
const downloadUrl = `${this.buildServerUrl}/api/build/${buildId}/download?apiKey=${encodeURIComponent(this.apiKey)}`;
|
||||
// Fetch APK with header auth and create blob URL
|
||||
const apkBlobUrl = await this.downloadApk(buildId);
|
||||
|
||||
return {
|
||||
url: downloadUrl,
|
||||
url: apkBlobUrl,
|
||||
metadata: {
|
||||
buildId,
|
||||
type: 'apk',
|
||||
@@ -137,6 +138,25 @@ export class APKBuilderAdapter implements DeployAdapter {
|
||||
throw new Error('APK build timed out after 10 minutes');
|
||||
}
|
||||
|
||||
private async downloadApk(buildId: string): Promise<string> {
|
||||
const url = `${this.buildServerUrl}/api/build/${buildId}/download`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-API-Key': this.apiKey,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to download APK: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
const blob = await response.blob();
|
||||
return URL.createObjectURL(blob);
|
||||
}
|
||||
|
||||
private async getStatus(buildId: string): Promise<APKBuildStatus> {
|
||||
const url = `${this.buildServerUrl}/api/build/${buildId}/status`;
|
||||
const targetUrl = this.corsProxy ? proxyUrl(this.corsProxy, url) : url;
|
||||
|
||||
Reference in new issue
Block a user