From 49ac5332027eb97169ebdd907766d846fc85df0c Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Thu, 27 Jul 2023 21:09:57 +0000 Subject: [PATCH 1/3] fix: Use authorization header over client-session-token --- src/seam-connect/client.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/seam-connect/client.ts b/src/seam-connect/client.ts index 913bebbd..d76fb274 100644 --- a/src/seam-connect/client.ts +++ b/src/seam-connect/client.ts @@ -216,7 +216,10 @@ const getAuthHeaders = ({ if (!clientSessionToken.startsWith("seam_cst")) { throw new Error("clientSessionToken must start with seam_cst") } - return { "client-session-token": clientSessionToken } + return { + authorization: `Bearer ${clientSessionToken}`, + "client-session-token": clientSessionToken, + } } if (apiKey) { @@ -224,7 +227,7 @@ const getAuthHeaders = ({ console.warn( "Using API Key as Client Session Token is deprecated. Please use the clientSessionToken option instead." ) - return { "client-session-token": apiKey } + return { authorization: `Bearer ${apiKey}` } } if (!isValueUsedForBearerAuthentication(apiKey) && workspaceId) throw new Error( From 4f3b20b03fd12ac2b991ece8d58df136dee6b0ac Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Thu, 27 Jul 2023 21:12:21 +0000 Subject: [PATCH 2/3] feat: Throw if a Client Session Token is passed as apiKey --- src/seam-connect/client.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/seam-connect/client.ts b/src/seam-connect/client.ts index d76fb274..542f4de9 100644 --- a/src/seam-connect/client.ts +++ b/src/seam-connect/client.ts @@ -224,10 +224,7 @@ const getAuthHeaders = ({ if (apiKey) { if (apiKey.startsWith("seam_cst")) { - console.warn( - "Using API Key as Client Session Token is deprecated. Please use the clientSessionToken option instead." - ) - return { authorization: `Bearer ${apiKey}` } + throw new Error("You can't use a Client Session Token as an apiKey.") } if (!isValueUsedForBearerAuthentication(apiKey) && workspaceId) throw new Error( From 1340e7f758d74172ab3afa6e0ab4c49f31a40654 Mon Sep 17 00:00:00 2001 From: Evan Sosenko Date: Thu, 27 Jul 2023 21:40:16 +0000 Subject: [PATCH 3/3] fix: Set withCredentials if using clientSessionToken --- docs/classes/Seam.md | 4 ++-- src/seam-connect/client.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/classes/Seam.md b/docs/classes/Seam.md index 32754ca7..0821cb7f 100644 --- a/docs/classes/Seam.md +++ b/docs/classes/Seam.md @@ -403,7 +403,7 @@ Routes.makeRequest #### Defined in -[src/seam-connect/client.ts:107](https://github.com/seamapi/javascript/blob/main/src/seam-connect/client.ts#L107) +[src/seam-connect/client.ts:108](https://github.com/seamapi/javascript/blob/main/src/seam-connect/client.ts#L108) ___ @@ -428,4 +428,4 @@ ___ #### Defined in -[src/seam-connect/client.ts:113](https://github.com/seamapi/javascript/blob/main/src/seam-connect/client.ts#L113) +[src/seam-connect/client.ts:114](https://github.com/seamapi/javascript/blob/main/src/seam-connect/client.ts#L114) diff --git a/src/seam-connect/client.ts b/src/seam-connect/client.ts index 542f4de9..c145815b 100644 --- a/src/seam-connect/client.ts +++ b/src/seam-connect/client.ts @@ -93,6 +93,7 @@ export class Seam extends Routes { ] = `Javascript SDK v${version}, Node.js mode, (https://github.com/seamapi/javascript)` } this.client = axios.create({ + withCredentials: clientSessionToken ? true : false, ...axiosOptions, baseURL: endpoint, headers,