| 276 | } |
| 277 | |
| 278 | async attest(report_data: string | Buffer | Uint8Array): Promise<AttestResponse> { |
| 279 | let hex = to_hex(report_data) |
| 280 | if (hex.length > 128) { |
| 281 | throw new Error(`Report data is too large, it should be less than 64 bytes.`) |
| 282 | } |
| 283 | const payload = JSON.stringify({ report_data: hex }) |
| 284 | const result = await send_rpc_request<{ attestation: string }>(this.endpoint, '/Attest', payload) |
| 285 | if ('error' in (result as any)) { |
| 286 | const err = (result as any)['error'] as string |
| 287 | throw new Error(err) |
| 288 | } |
| 289 | return Object.freeze({ |
| 290 | __name__: 'AttestResponse', |
| 291 | attestation: result.attestation as Hex, |
| 292 | }) |
| 293 | } |
| 294 | |
| 295 | async info(): Promise<InfoResponse<T>> { |
| 296 | const result = await send_rpc_request<Omit<InfoResponse<TcbInfo>, 'tcb_info'> & { tcb_info: string }>(this.endpoint, '/Info', '{}') |