- 
                Notifications
    
You must be signed in to change notification settings  - Fork 322
 
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
          
     Open
      
      
            hellovai
  wants to merge
  3
  commits into
  canary
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
hellovai/vscode-allow-delete-api-key
  
      
      
   
  
    
  
  
  
 
  
      
    base: canary
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +48
        
        
          −17
        
        
          
        
      
    
  
Conversation
  
    
      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
    
  
  
    
    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. 
  | 
    
| 
           🌿 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  | 
    
  
    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.
  
    
  
    
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