| 81 | return base64String; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Creates a promise that resolves when a matching custom event is received |
| 86 | * |
| 87 | * @param options.eventName Name to match in the custom event |
| 88 | * @param options.timeout Maximum time to wait for response in milliseconds |
| 89 | * @param options.addEventListener Function to add the event listener |
| 90 | * @param options.removeEventListener Function to remove the event listener |
| 91 | * @returns A tuple with [requestId, promise] where requestId should be sent with the request and promise resolves with the event data |
| 92 | */ |
| 93 | export function withCustomEventResponse<T = Record<string, any>>({ |
| 94 | timeout = 10_000, |
| 95 | addEventListener, |