Skip to content

Commit 1d3a1ca

Browse files
careful-cat8480gemini-code-assist[bot]devin-ai-integration[bot]
authored
Accept sk-ant-sid02 session keys for Claude Web (#960)
Anthropic changed Claude Web session keys from sk-ant-sid01-* to sk-ant-sid02-*. The previous validation only accepted the older sid01 prefix, causing "Session key invalid" errors for users with newer keys. Accept numeric sk-ant-sid versions in the Claude client validation so sk-ant-sid01-*, sk-ant-sid02-*, sk-ant-sid03-*, and future numeric sid versions can pass the upfront format check. Update the JSDoc example and related error messages to match the newer session key format. Fix #935 Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent cd5c92f commit 1d3a1ca

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/services/clients/claude/index.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Claude {
4444
* @param {function} [options.fetch] - Fetch function
4545
* @example
4646
* const claude = new Claude({
47-
* sessionKey: 'sk-ant-sid01-*****',
47+
* sessionKey: 'sk-ant-sid02-*****',
4848
* fetch: globalThis.fetch
4949
* })
5050
*
@@ -74,8 +74,8 @@ export class Claude {
7474
if (!sessionKey) {
7575
throw new Error('Session key required')
7676
}
77-
if (!sessionKey.startsWith('sk-ant-sid01')) {
78-
throw new Error('Session key invalid: Must be in the format sk-ant-sid01-*****')
77+
if (!/^sk-ant-sid\d+-/.test(sessionKey)) {
78+
throw new Error('Session key invalid: Must be in the format sk-ant-sid02-*****')
7979
}
8080
if (fetch) {
8181
this.fetch = fetch
@@ -164,7 +164,7 @@ export class Claude {
164164
// Can't figure out a way to test this so I'm just assuming it works
165165
if (!(this.fetch || globalThis.fetch)) {
166166
throw new Error(
167-
`No fetch available in your environment. Use node-18 or later, a modern browser, or add the following code to your project:\n\nimport "isomorphic-fetch";\nconst claude = new Claude({fetch: fetch, sessionKey: "sk-ant-sid01-*****"});`,
167+
`No fetch available in your environment. Use node-18 or later, a modern browser, or add the following code to your project:\n\nimport "isomorphic-fetch";\nconst claude = new Claude({fetch: fetch, sessionKey: "sk-ant-sid02-*****"});`,
168168
)
169169
}
170170
if (!this.proxy) {

0 commit comments

Comments
 (0)