Skip to content

Commit 14dc99f

Browse files
committed
Check other token formats when using clientSessionToken
1 parent 1b045ac commit 14dc99f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib/seam/connect/auth.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ const getAuthHeadersForApiKey = ({
5656
const getAuthHeadersForClientSessionToken = ({
5757
clientSessionToken,
5858
}: SeamHttpOptionsWithClientSessionToken): Headers => {
59+
if (isJwt(clientSessionToken)) {
60+
throw new SeamHttpInvalidTokenError(
61+
'A JWT cannot be used as a clientSessionToken',
62+
)
63+
}
64+
65+
if (isAccessToken(clientSessionToken)) {
66+
throw new SeamHttpInvalidTokenError(
67+
'An Access Token cannot be used as a clientSessionToken',
68+
)
69+
}
70+
5971
if (!isClientSessionToken(clientSessionToken)) {
6072
throw new SeamHttpInvalidTokenError(
6173
`Unknown or invalid clientSessionToken format, expected token to start with ${clientSessionTokenPrefix}`,

0 commit comments

Comments
 (0)