(method: any, requestData: Uint8Array, callback: (err?: Error | null, data?: Uint8Array) => void)
| 63 | } |
| 64 | |
| 65 | const rpcImpl = (method: any, requestData: Uint8Array, callback: (err?: Error | null, data?: Uint8Array) => void) => { |
| 66 | const methodName = resolveMethodName(method); |
| 67 | const payload = normalizeRequestData(requestData); |
| 68 | fetch(`${basePath}/${methodName}`, { |
| 69 | method: 'POST', |
| 70 | headers: { |
| 71 | 'Content-Type': 'application/octet-stream', |
| 72 | }, |
| 73 | body: payload as unknown as BodyInit, |
| 74 | credentials: 'same-origin', |
| 75 | }) |
| 76 | .then(async (response) => { |
| 77 | const buffer = new Uint8Array(await response.arrayBuffer()); |
| 78 | if (!response.ok) { |
| 79 | callback(new Error(decodePrpcError(buffer))); |
| 80 | return; |
| 81 | } |
| 82 | callback(null, buffer); |
| 83 | }) |
| 84 | .catch((error) => { |
| 85 | callback(error); |
| 86 | }); |
| 87 | }; |
| 88 | |
| 89 | cachedClient = vmm.Vmm.create(rpcImpl, false, false); |
| 90 | return cachedClient; |
nothing calls this directly
no test coverage detected