(input: {
url: string
sessionID?: string
directory?: string
fetch?: typeof fetch
headers?: RequestInit["headers"]
})
| 5 | const decodeSessionID = Schema.decodeUnknownSync(SessionID) |
| 6 | |
| 7 | export async function validateSession(input: { |
| 8 | url: string |
| 9 | sessionID?: string |
| 10 | directory?: string |
| 11 | fetch?: typeof fetch |
| 12 | headers?: RequestInit["headers"] |
| 13 | }) { |
| 14 | if (!input.sessionID) return |
| 15 | |
| 16 | let sessionID: SessionID |
| 17 | try { |
| 18 | sessionID = decodeSessionID(input.sessionID) |
| 19 | } catch (error) { |
| 20 | throw new Error(`Invalid session ID: ${error instanceof Error ? error.message : "unknown error"}`, { cause: error }) |
| 21 | } |
| 22 | |
| 23 | await createOpencodeClient({ |
| 24 | baseUrl: input.url, |
| 25 | directory: input.directory, |
| 26 | fetch: input.fetch, |
| 27 | headers: input.headers, |
| 28 | }).session.get({ sessionID }, { throwOnError: true }) |
| 29 | } |
no test coverage detected