From 31d55440c13a9838d3587a05a092919919fa8783 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Tue, 15 Sep 2026 13:18:34 -0700 Subject: [PATCH] Import Digest, NTLM, OAuth 1.0, and folder-level auth from Postman collections (#667) Co-authored-by: Claude Opus 5 --- plugins/importer-postman/src/index.ts | 68 ++++- .../tests/fixtures/auth.input.json | 248 ++++++++++++++++++ .../tests/fixtures/auth.output.json | 116 +++++++- .../tests/fixtures/nested.output.json | 22 +- .../tests/fixtures/params.output.json | 2 +- plugins/importer-postman/tests/index.test.ts | 31 +++ 6 files changed, 474 insertions(+), 13 deletions(-) diff --git a/plugins/importer-postman/src/index.ts b/plugins/importer-postman/src/index.ts index 9f05859f..3c720108 100644 --- a/plugins/importer-postman/src/index.ts +++ b/plugins/importer-postman/src/index.ts @@ -16,6 +16,20 @@ const POSTMAN_2_1_0_SCHEMA = "https://schema.getpostman.com/json/collection/v2.1 const POSTMAN_2_0_0_SCHEMA = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"; const VALID_SCHEMAS = [POSTMAN_2_0_0_SCHEMA, POSTMAN_2_1_0_SCHEMA]; +// Both products happen to spell these the same way, but the names are written +// out so anything Yaak's oauth1 plugin can't offer as a select option lands on +// the default instead of being passed straight through. +const OAUTH1_SIGNATURE_METHODS: Record = { + "HMAC-SHA1": "HMAC-SHA1", + "HMAC-SHA256": "HMAC-SHA256", + "HMAC-SHA512": "HMAC-SHA512", + "RSA-SHA1": "RSA-SHA1", + "RSA-SHA256": "RSA-SHA256", + "RSA-SHA512": "RSA-SHA512", + PLAINTEXT: "PLAINTEXT", +}; +const DEFAULT_OAUTH1_SIGNATURE_METHOD = "HMAC-SHA1"; + type AtLeast = Partial & Pick; interface ExportResources { @@ -98,6 +112,7 @@ export function convertPostman(contents: string): ImportPluginResponse | undefin id: generateId("folder"), name: v.name, folderId, + ...importAuth(v.auth), }; trackSourceKey(folder.id, v, "item"); exportResources.folders.push(folder); @@ -222,8 +237,6 @@ function convertUrl(rawUrl: unknown): Pick v += `#${url.hash}`; } - // TODO: Implement url.variables (path variables) - return { url: v, urlParameters: params }; } @@ -274,6 +287,31 @@ function importAuth(rawAuth: unknown): Pick { expect(keyOf(before, before?.resources.workspaces[0]?.id)).toBe("collection:collection-id"); }); + test("Falls back to the default OAuth 1 signature method for unrecognized ones", () => { + const result = convertPostman( + JSON.stringify({ + info: { + name: "OAuth 1 Signature", + schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + }, + item: [ + { + name: "Request", + request: { + method: "GET", + url: "https://yaak.app", + auth: { + type: "oauth1", + oauth1: [{ key: "signatureMethod", value: "HMAC-SHA384" }], + }, + }, + }, + ], + }), + ); + + expect(result?.resources.httpRequests).toEqual([ + expect.objectContaining({ + authenticationType: "oauth1", + authentication: { signatureMethod: "HMAC-SHA1" }, + }), + ]); + }); + test("Omits keys for items the collection never identified", () => { const result = convertPostman( JSON.stringify({