fix(auth): credenciais DPAPI sem BOM e API key aceita no modo headless - #43
Merged
ImPedro29 merged 2 commits intoAug 28, 2026
Merged
Conversation
O update() escrevia o arquivo .secure.dpapi com WriteAllText usando Encoding.UTF8, que no PowerShell 5.1 emite BOM (EF BB BF). Passa a usar UTF8Encoding($false) e valida a escrita relendo os bytes e comparando com o base64 exato.
graseeel
marked this pull request as draft
August 27, 2026 13:53
O gate de inicialização só aceitava OAuth; uma API key vbk_ válida (já usada pelo desktop no router) não autenticava o agente headless. A chave passa a ser aceita como fallback: validada com Bearer no /router/v1/models (o /api/me não aceita API key), com OAuth continuando primário. Chave inválida gera erro específico. Termos e entitlement usam endpoints OAuth-only e são pulados nesse caminho (ver descrição do PR).
graseeel
marked this pull request as ready for review
August 27, 2026 15:26
ImPedro29
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dois ajustes de autenticação:
1. Windows: arquivo DPAPI sem BOM UTF-8
O
update()dewindowsCredentialStorage.tsgravava comEncoding.UTF8, que no PowerShell 5.1 emite BOM (EF BB BF). Passa a usarUTF8Encoding($false)e valida a escrita relendo os bytes e comparando com o base64 exato.2. API key Verboo como sessão headless
O gate de inicialização aceitava apenas OAuth: uma API key
vbk_válida não autenticava o agente headless (o desktop injeta a chave, mas o gate não a consultava). A chave agora é aceita como fallback de sessão, validada comBearerno/router/v1/models(o/api/merejeita API keys — verificado). OAuth continua sendo o caminho primário; chave inválida gera "API key inválida ou expirada".Nota para revisão: os fluxos de termos e entitlement usam endpoints que só aceitam OAuth; no caminho de API key eles são pulados. Se preferirem impor termos também para API keys, dá para criar uma checagem via router — fica a critério de vocês.
Testes