-
Notifications
You must be signed in to change notification settings - Fork 324
bug: improve WASM Vertex AI authentication + VSCode env var deletion #2680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
Conversation
This commit fixes two critical issues:
1. **Fix JWT encoding for GCP service account keys in WASM**
- Handle literal `\n` characters in JSON (common in GCP service account files)
- Add support for both PKCS#8 and PKCS#1 format PEM headers
- Validate key length before attempting import (must be >= 100 bytes)
- Improve error messages with actionable troubleshooting steps
- Add new `KeyTooShort` error variant with context
2. **Fix environment variable deletion not persisting**
- `deleteApiKeyAtom` now auto-saves changes to storage
- Deletion behavior now consistent with edit auto-save
- Fixes bug where clicking trash icon only updated local state
Technical details:
- WASM JWT: Added `.replace("\\n", "")` to handle escaped newlines in JSON strings
- WASM JWT: Enhanced error messages for WebCrypto import failures
- WASM Auth: Add early validation for credentials string length
- TypeScript: Modified `deleteApiKeyAtom` to persist deletions immediately
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
🌿 Preview your docs: https://boundary-preview-6be1654d-140a-4815-acf6-f2181d062d50.docs.buildwithfern.com |
|
🌿 Preview your docs: https://boundary-preview-09bd42f3-4e96-410c-990a-05de6d9d9884.docs.buildwithfern.com |
|
🌿 Preview your docs: https://boundary-preview-622fa00b-d91d-48e9-a7c0-ac147a03038c.docs.buildwithfern.com |
|
🌿 Preview your docs: https://boundary-preview-b9261b22-2515-4463-acef-c83e10b81c78.docs.buildwithfern.com |
Summary
This PR fixes two critical issues affecting the VSCode playground:
Changes
1. Fix JWT encoding for GCP service account keys in WASM
Problem: The base64 decoder was producing only 3 bytes instead of 1600+ bytes for RSA keys because literal
\ncharacters in JSON strings weren't being removed.Root cause: GCP service account JSON files contain the private key with escaped newlines like:
{ "private_key": "-----BEGIN PRIVATE KEY-----\nMIIE...\n-----END PRIVATE KEY-----\n" }The code was only removing actual newline characters (
\n) but not the two-character literal string\n.Solution:
.replace("\\n", "")to handle escaped newlines in JSON stringsBEGIN PRIVATE KEY) and PKCS#1 (BEGIN RSA PRIVATE KEY) formats2. Fix environment variable deletion not persisting
Problem: When users clicked the trash icon to delete an env var, it disappeared from the UI but remained in memory after reload.
Root cause: The
deleteApiKeyAtomonly updated local state but didn't call save, unlike the auto-save behavior for edits.Solution:
deleteApiKeyAtomto auto-save deletions immediatelyTesting
Files Changed
engine/baml-runtime/src/internal/wasm_jwt.rs- JWT encoding fixesengine/baml-runtime/src/internal/llm_client/primitive/vertex/wasm_auth.rs- Early validationtypescript/packages/playground-common/src/components/api-keys-dialog/atoms.ts- Auto-save deletions🤖 Generated with Claude Code
Note
Strengthens WASM Vertex AI JWT/key handling and makes API key deletions auto-save in the VSCode playground.
wasm_auth.rsand improve JWT serialization/encoding error contexts.wasm_jwt.rs, normalize PEM input (handle escaped\n, PKCS#8 and PKCS#1 headers), validate key length, and provide clearer WebCrypto/base64 errors.deleteApiKeyAtom: auto-save deletions by syncinglocalApiKeystouserApiKeysAtomand clearinghasLocalChanges.Written by Cursor Bugbot for commit c03040c. This will update automatically on new commits. Configure here.