Skip to content

Commit cd02aa3

Browse files
authored
GCP KMS bugfix (#710)
* replace String.raw`\n` with `\n` in gcp private key * refactor * remove redundant sanitisation
1 parent 1729051 commit cd02aa3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/server/utils/wallets/getGcpKmsAccount.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ export async function getGcpKmsAccount(
4040
): Promise<GcpKmsAccount> {
4141
const { name: unprocessedName, clientOptions, client } = options;
4242

43+
if (clientOptions?.credentials) {
44+
if (
45+
"private_key" in clientOptions.credentials &&
46+
clientOptions.credentials.private_key
47+
) {
48+
// https://stackoverflow.com/questions/74131595/error-error1e08010cdecoder-routinesunsupported-with-google-auth-library
49+
// new keys are stored correctly with newlines, but older keys need this sanitization for backwards compatibility
50+
clientOptions.credentials.private_key =
51+
clientOptions.credentials.private_key.split(String.raw`\n`).join("\n");
52+
}
53+
}
54+
4355
// we had a bug previously where we previously called it "cryptoKeyVersion" instead of "cryptoKeyVersions"
4456
// if we detect that, we'll fix it here
4557
// TODO: remove this as a breaking change

0 commit comments

Comments
 (0)