Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/lib/ssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ async function readFileOrKey(keyOrFile: string): Promise<string> {
throw new Error("File not found");
}
const file = await fileContent.text();

if (!isPubkey(file)) {
throw new Error("The file content does not look like a valid public key");
}
Expand Down Expand Up @@ -83,17 +82,19 @@ export async function getSSHKeys() {
export async function postSSHKeys(key: string) {
const res = await fetch(await getApiUrl("credentials_create"), {
method: "POST",
headers: await getAuthorizationHeader(),
headers: {
...(await getAuthorizationHeader()),
"Content-Type": "application/json",
},
body: JSON.stringify({
pubkey: key,
user: "sf",
username: "sf",
}),
});
if (!res.ok) {
console.error(await res.text());
throw new Error("Failed to add SSH key");
}

const data = await res.json();
return data as SSHCredential;
}