Skip to content

🔑 feat: Base64 Google Service Keys and Reliable Private Key Formats #8385

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

Merged
merged 1 commit into from
Jul 11, 2025

Conversation

danny-avila
Copy link
Owner

Summary

I improved the loadServiceKey utility to support base64-encoded keys, robust private key formatting, and expanded corresponding unit tests.

  • Add detection and parsing for base64-encoded service keys, enabling secret management compatibility
  • Ensure private_key fields are converted from escaped newlines (\n, \n) to actual newlines for PEM compliance
  • Implement fallback formatting for private keys without newlines, restoring valid PEM structure
  • Expand key.test.ts with new scenarios: escaped/double-escaped newlines, base64 inputs, proper/poor formatting, and invalid cases for greater test coverage
  • Maintain backward compatibility for all existing uses of loadServiceKey

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Testing

I added unit tests covering all new branches, including various newline encodings, malformed and well-formed base64 payloads, valid/invalid formatting, and legacy-support edge cases. Run pnpm run test in the api package to confirm comprehensive coverage. You can also set a base64-encoded credential in the environment to verify live usage.

Test Configuration:

  • Node.js v20 LTS
  • pnpm 8.x
  • Run in packages/api: pnpm run test

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

@danny-avila danny-avila merged commit 19320f2 into dev Jul 11, 2025
3 checks passed
@danny-avila danny-avila deleted the feat/google-key-file-loading-from-various-sources branch July 11, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant