You've already forked agentic-coding-workflow
改动
This commit is contained in:
@@ -11,13 +11,16 @@ interface RequestOptions {
|
||||
|
||||
let authTokenProvider: () => string | null = () => null
|
||||
let onUnauthorized: () => void = () => {}
|
||||
let onForbidden: () => void = () => {}
|
||||
|
||||
export function configure(opts: {
|
||||
tokenProvider: () => string | null
|
||||
onUnauthorized: () => void
|
||||
onForbidden?: () => void
|
||||
}) {
|
||||
authTokenProvider = opts.tokenProvider
|
||||
onUnauthorized = opts.onUnauthorized
|
||||
if (opts.onForbidden) onForbidden = opts.onForbidden
|
||||
}
|
||||
|
||||
export async function request<T>(path: string, opts: RequestOptions = {}): Promise<T> {
|
||||
@@ -55,6 +58,8 @@ export async function request<T>(path: string, opts: RequestOptions = {}): Promi
|
||||
|
||||
if (resp.status === 401) {
|
||||
onUnauthorized()
|
||||
} else if (resp.status === 403) {
|
||||
onForbidden()
|
||||
}
|
||||
|
||||
if (resp.status === 204) {
|
||||
|
||||
Reference in New Issue
Block a user