diff options
Diffstat (limited to 'packages/taler-util/src/http-impl.qtart.ts')
-rw-r--r-- | packages/taler-util/src/http-impl.qtart.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/taler-util/src/http-impl.qtart.ts b/packages/taler-util/src/http-impl.qtart.ts index ee3d1f725..3a963b35a 100644 --- a/packages/taler-util/src/http-impl.qtart.ts +++ b/packages/taler-util/src/http-impl.qtart.ts @@ -41,9 +41,11 @@ const textDecoder = new TextDecoder(); export class HttpLibImpl implements HttpRequestLibrary { private throttle = new RequestThrottler(); private throttlingEnabled = true; + private allowHttp = false; constructor(args?: HttpLibArgs) { this.throttlingEnabled = args?.enableThrottling ?? false; + this.allowHttp = args?.allowHttp ?? false; } /** @@ -70,6 +72,16 @@ export class HttpLibImpl implements HttpRequestLibrary { `request to origin ${parsedUrl.origin} was throttled`, ); } + if (!this.allowHttp && parsedUrl.protocol !== "https") { + throw TalerError.fromDetail( + TalerErrorCode.WALLET_NETWORK_ERROR, + { + requestMethod: method, + requestUrl: url, + }, + `request to ${parsedUrl.origin} is not possible with protocol ${parsedUrl.protocol}`, + ); + } let data: ArrayBuffer | undefined = undefined; const requestHeadersMap = { ...getDefaultHeaders(method), ...opt?.headers }; |