Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/services/clients/claude/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Claude {
* @param {function} [options.fetch] - Fetch function
* @example
* const claude = new Claude({
* sessionKey: 'sk-ant-sid01-*****',
* sessionKey: 'sk-ant-sidXX-*****',
* fetch: globalThis.fetch
* })
*
Expand Down Expand Up @@ -74,8 +74,8 @@ export class Claude {
if (!sessionKey) {
throw new Error('Session key required')
}
if (!sessionKey.startsWith('sk-ant-sid01')) {
throw new Error('Session key invalid: Must be in the format sk-ant-sid01-*****')
if (!/^sk-ant-sid\d+-/.test(sessionKey)) {
throw new Error('Session key invalid: Must be in the format sk-ant-sidXX-*****')
}
if (fetch) {
this.fetch = fetch
Expand Down Expand Up @@ -164,7 +164,7 @@ export class Claude {
// Can't figure out a way to test this so I'm just assuming it works
if (!(this.fetch || globalThis.fetch)) {
throw new Error(
`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-*****"});`,
`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-sidXX-*****"});`,
)
}
if (!this.proxy) {
Expand Down