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

Method authenticate

web/src/api/client.ts:153–168  ·  view source on GitHub ↗
(auth: { initData: string } | { accessToken: string })

Source from the content-addressed store, hash-verified

151 }
152
153 async authenticate(auth: { initData: string } | { accessToken: string }): Promise<AuthResponse> {
154 const res = await fetch(this.buildUrl('/api/auth'), {
155 method: 'POST',
156 headers: { 'content-type': 'application/json' },
157 body: JSON.stringify(auth)
158 })
159
160 if (!res.ok) {
161 const body = await res.text().catch(() => '')
162 const code = parseErrorCode(body)
163 const detail = body ? `: ${body}` : ''
164 throw new ApiError(`Auth failed: HTTP ${res.status} ${res.statusText}${detail}`, res.status, code, body || undefined)
165 }
166
167 return await res.json() as AuthResponse
168 }
169
170 async bind(auth: { initData: string; accessToken: string }): Promise<AuthResponse> {
171 const res = await fetch(this.buildUrl('/api/bind'), {

Callers 2

LoginPromptFunction · 0.95
runFunction · 0.95

Calls 2

buildUrlMethod · 0.95
parseErrorCodeFunction · 0.85

Tested by

no test coverage detected