MCPcopy Create free account
hub / github.com/tiann/hapi / bind

Method bind

web/src/api/client.ts:170–185  ·  view source on GitHub ↗
(auth: { initData: string; accessToken: string })

Source from the content-addressed store, hash-verified

168 }
169
170 async bind(auth: { initData: string; accessToken: string }): Promise<AuthResponse> {
171 const res = await fetch(this.buildUrl('/api/bind'), {
172 method: 'POST',
173 headers: { 'content-type': 'application/json' },
174 body: JSON.stringify(auth)
175 })
176
177 if (!res.ok) {
178 const body = await res.text().catch(() => '')
179 const code = parseErrorCode(body)
180 const detail = body ? `: ${body}` : ''
181 throw new ApiError(`Bind failed: HTTP ${res.status} ${res.statusText}${detail}`, res.status, code, body || undefined)
182 }
183
184 return await res.json() as AuthResponse
185 }
186
187 async getSessions(): Promise<SessionsResponse> {
188 return await this.request<SessionsResponse>('/api/sessions')

Callers 6

useAuthFunction · 0.95
runMainLoopMethod · 0.80
createSocketServerFunction · 0.80

Calls 2

buildUrlMethod · 0.95
parseErrorCodeFunction · 0.85

Tested by

no test coverage detected