chore(updater): remove token-bake — repo is public now

После того как репозиторий стал публичным, токен в Authorization
header больше не нужен. Убираю __UPDATE_TOKEN__ define из
electron.vite.config.ts и весь связанный код в updater.ts.

Преимущества:
- Никаких секретов в распространяемом .exe
- Билд не требует UPDATE_TOKEN env переменной
- Любой может склонировать и собрать без доп. конфига

== Действие пользователя ==

Если v0.3.5 .exe был скачан кем-то с публичного репо (был доступен
~30 минут до того как мы это поняли) — токен из него можно
извлечь и использовать для записи в репо. Рекомендую ротировать:

1. Gitea → Settings → Applications → удалить старый токен
2. Создать новый, скопировать
3. PowerShell:
   [Environment]::SetEnvironmentVariable('GITEA_TOKEN', '<новый>', 'User')

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
AnRil
2026-05-17 18:56:13 +07:00
parent 90f2ebeea1
commit 3261e8928e
3 changed files with 1 additions and 22 deletions

View File

@@ -2,18 +2,9 @@ import { resolve } from 'node:path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite' import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
// Bake the Gitea update token into the main bundle at build time so
// electron-updater can fetch latest.yml from the private repo. The token
// only needs read access to releases. Falls back to empty string if not set
// (dev/local builds), in which case auto-update is silently disabled.
const updateToken = JSON.stringify(process.env.UPDATE_TOKEN ?? '')
export default defineConfig({ export default defineConfig({
main: { main: {
plugins: [externalizeDepsPlugin()], plugins: [externalizeDepsPlugin()],
define: {
__UPDATE_TOKEN__: updateToken
},
resolve: { resolve: {
alias: { alias: {
'@shared': resolve('src/shared') '@shared': resolve('src/shared')

View File

@@ -1,6 +1,6 @@
{ {
"name": "laude", "name": "laude",
"version": "0.3.5", "version": "0.3.6",
"description": "Exercise reminder — Windows desktop app", "description": "Exercise reminder — Windows desktop app",
"main": "out/main/index.js", "main": "out/main/index.js",
"author": "AnRil", "author": "AnRil",

View File

@@ -3,10 +3,6 @@ import { autoUpdater } from 'electron-updater'
import { IPC } from '@shared/ipc' import { IPC } from '@shared/ipc'
import type { UpdaterStatus } from '@shared/types' import type { UpdaterStatus } from '@shared/types'
// Build-time defined in electron.vite.config.ts.
// Read-only Gitea token, used to fetch latest.yml from the private repo.
declare const __UPDATE_TOKEN__: string
let currentStatus: UpdaterStatus = { kind: 'idle' } let currentStatus: UpdaterStatus = { kind: 'idle' }
let wired = false let wired = false
let checkInterval: NodeJS.Timeout | null = null let checkInterval: NodeJS.Timeout | null = null
@@ -42,14 +38,6 @@ export function initUpdater(): void {
autoUpdater.autoInstallOnAppQuit = true autoUpdater.autoInstallOnAppQuit = true
autoUpdater.allowDowngrade = false autoUpdater.allowDowngrade = false
// Gitea private-repo release assets require a token in Authorization
// header — without it Gitea responds 404 (not 401) on download URLs.
if (typeof __UPDATE_TOKEN__ === 'string' && __UPDATE_TOKEN__.length > 0) {
autoUpdater.requestHeaders = {
Authorization: `token ${__UPDATE_TOKEN__}`
}
}
autoUpdater.on('checking-for-update', () => setStatus({ kind: 'checking' })) autoUpdater.on('checking-for-update', () => setStatus({ kind: 'checking' }))
autoUpdater.on('update-available', (info) => { autoUpdater.on('update-available', (info) => {