diff --git a/src/server/utils/wallets/getGcpKmsAccount.ts b/src/server/utils/wallets/getGcpKmsAccount.ts index 7160415b9..6337ba3fc 100644 --- a/src/server/utils/wallets/getGcpKmsAccount.ts +++ b/src/server/utils/wallets/getGcpKmsAccount.ts @@ -40,6 +40,18 @@ export async function getGcpKmsAccount( ): Promise { const { name: unprocessedName, clientOptions, client } = options; + if (clientOptions?.credentials) { + if ( + "private_key" in clientOptions.credentials && + clientOptions.credentials.private_key + ) { + // https://stackoverflow.com/questions/74131595/error-error1e08010cdecoder-routinesunsupported-with-google-auth-library + // new keys are stored correctly with newlines, but older keys need this sanitization for backwards compatibility + clientOptions.credentials.private_key = + clientOptions.credentials.private_key.split(String.raw`\n`).join("\n"); + } + } + // we had a bug previously where we previously called it "cryptoKeyVersion" instead of "cryptoKeyVersions" // if we detect that, we'll fix it here // TODO: remove this as a breaking change