From 32d8b6675ae9836fce3dceaea4e9cb230526fe35 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 19 Dec 2024 14:39:49 +0100 Subject: [PATCH 1/2] Update PR to use SDK --- .../importers/onepassword/onepassword-1pux-importer.ts | 10 ++++++---- package-lock.json | 8 ++++---- package.json | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libs/importer/src/importers/onepassword/onepassword-1pux-importer.ts b/libs/importer/src/importers/onepassword/onepassword-1pux-importer.ts index 7db33d4cb16..4f0bc1e5c8a 100644 --- a/libs/importer/src/importers/onepassword/onepassword-1pux-importer.ts +++ b/libs/importer/src/importers/onepassword/onepassword-1pux-importer.ts @@ -9,6 +9,7 @@ import { LoginView } from "@bitwarden/common/vault/models/view/login.view"; import { PasswordHistoryView } from "@bitwarden/common/vault/models/view/password-history.view"; import { SecureNoteView } from "@bitwarden/common/vault/models/view/secure-note.view"; import { SshKeyView } from "@bitwarden/common/vault/models/view/ssh-key.view"; +import { import_ssh_key } from "@bitwarden/sdk-internal"; import { ImportResult } from "../../models/import-result"; import { BaseImporter } from "../base-importer"; @@ -323,10 +324,11 @@ export class OnePassword1PuxImporter extends BaseImporter implements Importer { } } else if (cipher.type === CipherType.SshKey) { if (valueKey === "sshKey") { - const { privateKey, metadata } = field.value.sshKey; - cipher.sshKey.privateKey = privateKey; - cipher.sshKey.publicKey = metadata.publicKey; - cipher.sshKey.keyFingerprint = metadata.fingerprint; + const { privateKey } = field.value.sshKey; + const sshKey = import_ssh_key(privateKey); + cipher.sshKey.privateKey = sshKey.private_key; + cipher.sshKey.publicKey = sshKey.public_key; + cipher.sshKey.keyFingerprint = sshKey.key_fingerprint; return; } } diff --git a/package-lock.json b/package-lock.json index 0d743316bd4..2be4178254c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "@angular/platform-browser": "17.3.12", "@angular/platform-browser-dynamic": "17.3.12", "@angular/router": "17.3.12", - "@bitwarden/sdk-internal": "0.2.0-main.38", + "@bitwarden/sdk-internal": "0.2.0-main.47", "@electron/fuses": "1.8.0", "@koa/multer": "3.0.2", "@koa/router": "13.1.0", @@ -4298,9 +4298,9 @@ "link": true }, "node_modules/@bitwarden/sdk-internal": { - "version": "0.2.0-main.38", - "resolved": "https://registry.npmjs.org/@bitwarden/sdk-internal/-/sdk-internal-0.2.0-main.38.tgz", - "integrity": "sha512-bkN+BZC0YA4k0To8QiT33UTZX8peKDXud8Gzq3UHNPlU/vMSkP3Wn8q0GezzmYN3UNNIWXfreNCS0mJ+S51j/Q==", + "version": "0.2.0-main.47", + "resolved": "https://registry.npmjs.org/@bitwarden/sdk-internal/-/sdk-internal-0.2.0-main.47.tgz", + "integrity": "sha512-alISSoMpAEJD/4+vwjv8kwK4/skd+yqA8pXjZJqMlkVSnp1rtT0ZN+6TC91WmHsJTjjjDwt7DrT8YOkCuwmdnQ==", "license": "GPL-3.0" }, "node_modules/@bitwarden/vault": { diff --git a/package.json b/package.json index 10799b9e451..7c1af569387 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,7 @@ "@angular/platform-browser": "17.3.12", "@angular/platform-browser-dynamic": "17.3.12", "@angular/router": "17.3.12", - "@bitwarden/sdk-internal": "0.2.0-main.38", + "@bitwarden/sdk-internal": "0.2.0-main.47", "@electron/fuses": "1.8.0", "@koa/multer": "3.0.2", "@koa/router": "13.1.0", From fbd69aeba66e17c697e19fd102a9f02cbbc4ee7d Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Mon, 23 Dec 2024 11:43:17 +0100 Subject: [PATCH 2/2] Fix tests --- libs/importer/spec/onepassword-1pux-importer.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/importer/spec/onepassword-1pux-importer.spec.ts b/libs/importer/spec/onepassword-1pux-importer.spec.ts index 9e987de3aea..96fd29c9ac0 100644 --- a/libs/importer/spec/onepassword-1pux-importer.spec.ts +++ b/libs/importer/spec/onepassword-1pux-importer.spec.ts @@ -679,7 +679,7 @@ describe("1Password 1Pux Importer", () => { expect(cipher.name).toEqual("Some SSH Key"); expect(cipher.notes).toEqual("SSH Key Note"); expect(cipher.sshKey.privateKey).toEqual( - "-----BEGIN PRIVATE KEY-----\nMFECAQEwBQYDK2VwBCIEIDn1BgTbZ/5UUeGLIfVV+qLBOvEsS3XMK6Twzw2Dkukq\ngSEAlrKdxRVVQrBndt4bHEZAz3xsymfM9Vf2QfZ823QxUbM=\n-----END PRIVATE KEY-----\n", + "-----BEGIN OPENSSH PRIVATE KEY-----\nb3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW\nQyNTUxOQAAACCWsp3FFVVCsGd23hscRkDPfGzKZ8z1V/ZB9nzbdDFRswAAAIjrC5Lz6wuS\n8wAAAAtzc2gtZWQyNTUxOQAAACCWsp3FFVVCsGd23hscRkDPfGzKZ8z1V/ZB9nzbdDFRsw\nAAAEA59QYE22f+VFHhiyH1VfqiwTrxLEt1zCuk8M8Ng5LpKpayncUVVUKwZ3beGxxGQM98\nbMpnzPVX9kH2fNt0MVGzAAAAAAECAwQF\n-----END OPENSSH PRIVATE KEY-----\n", ); expect(cipher.sshKey.publicKey).toEqual( "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJayncUVVUKwZ3beGxxGQM98bMpnzPVX9kH2fNt0MVGz",