* @deprecated Use getQuote instead. * @param report_data The report data. * @param hash_algorithm The hash algorithm. * @returns The quote.
(report_data: string | Buffer | Uint8Array, hash_algorithm?: TdxQuoteHashAlgorithms)
| 486 | * @returns The quote. |
| 487 | */ |
| 488 | async tdxQuote(report_data: string | Buffer | Uint8Array, hash_algorithm?: TdxQuoteHashAlgorithms): Promise<GetQuoteResponse> { |
| 489 | console.warn('tdxQuote is deprecated, please use getQuote instead'); |
| 490 | let hex = to_hex(report_data) |
| 491 | if (hash_algorithm === 'raw') { |
| 492 | if (hex.length > 128) { |
| 493 | throw new Error(`Report data is too large, it should less then 64 bytes when hash_algorithm is raw.`) |
| 494 | } |
| 495 | if (hex.length < 128) { |
| 496 | hex = hex.padStart(128, '0') |
| 497 | } |
| 498 | } |
| 499 | const payload = JSON.stringify({ report_data: hex, hash_algorithm }) |
| 500 | const result = await send_rpc_request<GetQuoteResponse>(this.endpoint, '/prpc/Tappd.TdxQuote', payload) |
| 501 | if ('error' in result) { |
| 502 | const err = result['error'] as string |
| 503 | throw new Error(err) |
| 504 | } |
| 505 | Object.defineProperty(result, 'replayRtmrs', { |
| 506 | get: () => () => reply_rtmrs(JSON.parse(result.event_log) as EventLog[]), |
| 507 | enumerable: true, |
| 508 | configurable: false, |
| 509 | }) |
| 510 | return Object.freeze(result) |
| 511 | } |
| 512 | |
| 513 | async isReachable(): Promise<boolean> { |
| 514 | try { |
no test coverage detected