Skip to content

Commit 643ff3c

Browse files
committed
replace String.raw\n with \n in gcp private key
1 parent 921449d commit 643ff3c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/server/utils/wallets/getGcpKmsAccount.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,28 @@ export async function getGcpKmsAccount(
4040
): Promise<GcpKmsAccount> {
4141
const { name: unprocessedName, clientOptions, client } = options;
4242

43+
let rawPrivateKey: string | undefined;
44+
if (clientOptions?.credentials) {
45+
if ("private_key" in clientOptions.credentials) {
46+
rawPrivateKey = clientOptions.credentials.private_key;
47+
}
48+
}
49+
4350
// we had a bug previously where we previously called it "cryptoKeyVersion" instead of "cryptoKeyVersions"
4451
// if we detect that, we'll fix it here
4552
// TODO: remove this as a breaking change
4653
const name = unprocessedName.includes("cryptoKeyVersions")
4754
? unprocessedName
4855
: unprocessedName.replace("cryptoKeyVersion", "cryptoKeyVersions");
4956

50-
const signer = new CloudKmsSigner(name, clientOptions);
57+
const signer = new CloudKmsSigner(name, {
58+
...clientOptions,
59+
credentials: {
60+
...clientOptions?.credentials,
61+
// https://stackoverflow.com/questions/74131595/error-error1e08010cdecoder-routinesunsupported-with-google-auth-library
62+
private_key: rawPrivateKey?.split(String.raw`\n`).join("\n"),
63+
},
64+
});
5165

5266
// Populate address immediately
5367
const publicKey = await signer.getPublicKey();

src/utils/account.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ export const getAccount = async (args: {
126126
clientOptions: {
127127
credentials: {
128128
client_email: gcpApplicationCredentialEmail,
129-
private_key: gcpApplicationCredentialPrivateKey,
129+
// https://stackoverflow.com/questions/74131595/error-error1e08010cdecoder-routinesunsupported-with-google-auth-library
130+
private_key: gcpApplicationCredentialPrivateKey
131+
.split(String.raw`\n`)
132+
.join("\n"),
130133
},
131134
},
132135
});

0 commit comments

Comments
 (0)