missing globalThis Polyfill, remove duplicate url util
This commit is contained in:
parent
221e71b916
commit
7f3ce304cb
@ -19,3 +19,4 @@ export * from "./transactionsTypes.js";
|
|||||||
export * from "./walletTypes.js";
|
export * from "./walletTypes.js";
|
||||||
export * from "./i18n.js";
|
export * from "./i18n.js";
|
||||||
export * from "./logging.js";
|
export * from "./logging.js";
|
||||||
|
export * from "./url.js";
|
||||||
|
@ -56,6 +56,21 @@ export interface URLCtor {
|
|||||||
new (url: string, base?: string | URL): URL;
|
new (url: string, base?: string | URL): URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// globalThis polyfill, see https://mathiasbynens.be/notes/globalthis
|
||||||
|
(function () {
|
||||||
|
if (typeof globalThis === "object") return;
|
||||||
|
Object.defineProperty(Object.prototype, "__magic__", {
|
||||||
|
get: function () {
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
configurable: true, // This makes it possible to `delete` the getter later.
|
||||||
|
});
|
||||||
|
// @ts-ignore: polyfill magic
|
||||||
|
__magic__.globalThis = __magic__; // lolwat
|
||||||
|
// @ts-ignore: polyfill magic
|
||||||
|
delete Object.prototype.__magic__;
|
||||||
|
})();
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const _URL = globalThis.URL;
|
const _URL = globalThis.URL;
|
||||||
if (!_URL) {
|
if (!_URL) {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { URL } from "@gnu-taler/taler-wallet-core";
|
import { URL } from "@gnu-taler/taler-util";
|
||||||
import { getRandomIban, getRandomString } from "./helpers";
|
import { getRandomIban, getRandomString } from "./helpers";
|
||||||
import {
|
import {
|
||||||
GlobalTestState,
|
GlobalTestState,
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { URL } from "@gnu-taler/taler-wallet-core";
|
import { URL } from "@gnu-taler/taler-util";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as util from "util";
|
import * as util from "util";
|
||||||
import {
|
import {
|
||||||
|
@ -27,8 +27,8 @@ import {
|
|||||||
BankApi,
|
BankApi,
|
||||||
BankAccessApi,
|
BankAccessApi,
|
||||||
} from "./harness";
|
} from "./harness";
|
||||||
import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
import { ExchangesListRespose, TalerErrorCode } from "@gnu-taler/taler-util";
|
import { ExchangesListRespose, URL, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
FaultInjectedExchangeService,
|
FaultInjectedExchangeService,
|
||||||
FaultInjectionResponseContext,
|
FaultInjectionResponseContext,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { URL } from "@gnu-taler/taler-wallet-core";
|
import { URL } from "@gnu-taler/taler-util";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
ExchangeService,
|
ExchangeService,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { URL } from "@gnu-taler/taler-wallet-core";
|
import { URL } from "@gnu-taler/taler-util";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
ExchangeService,
|
ExchangeService,
|
||||||
|
@ -23,9 +23,10 @@ import {
|
|||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
codecForMerchantOrderStatusUnpaid,
|
codecForMerchantOrderStatusUnpaid,
|
||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
|
URL
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for basic, bank-integrated withdrawal.
|
* Run test for basic, bank-integrated withdrawal.
|
||||||
|
@ -30,9 +30,9 @@ import {
|
|||||||
withdrawViaBank,
|
withdrawViaBank,
|
||||||
SimpleTestEnvironment,
|
SimpleTestEnvironment,
|
||||||
} from "./helpers";
|
} from "./helpers";
|
||||||
import { durationFromSpec, PreparePayResultType } from "@gnu-taler/taler-util";
|
import { URL, durationFromSpec, PreparePayResultType } from "@gnu-taler/taler-util";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
async function testRefundApiWithFulfillmentUrl(
|
async function testRefundApiWithFulfillmentUrl(
|
||||||
t: GlobalTestState,
|
t: GlobalTestState,
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
/**
|
/**
|
||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
|
import { URL, PreparePayResultType, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||||
import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
import {
|
import {
|
||||||
FaultInjectionRequestContext,
|
FaultInjectionRequestContext,
|
||||||
FaultInjectionResponseContext,
|
FaultInjectionResponseContext,
|
||||||
|
@ -26,10 +26,11 @@ import {
|
|||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
codecForMerchantOrderStatusUnpaid,
|
codecForMerchantOrderStatusUnpaid,
|
||||||
ConfirmPayResultType,
|
ConfirmPayResultType,
|
||||||
|
URL,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { FaultInjectionRequestContext } from "./faultInjection";
|
import { FaultInjectionRequestContext } from "./faultInjection";
|
||||||
import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for the wallets repurchase detection mechanism
|
* Run test for the wallets repurchase detection mechanism
|
||||||
|
@ -33,8 +33,9 @@ import {
|
|||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
TalerErrorCode,
|
TalerErrorCode,
|
||||||
TalerErrorDetails,
|
TalerErrorDetails,
|
||||||
|
URL,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { URL, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run test for a payment where the merchant has a transient
|
* Run test for a payment where the merchant has a transient
|
||||||
|
@ -28,10 +28,9 @@ import {
|
|||||||
import { RequestThrottler } from "../util/RequestThrottler.js";
|
import { RequestThrottler } from "../util/RequestThrottler.js";
|
||||||
import Axios, { AxiosResponse } from "axios";
|
import Axios, { AxiosResponse } from "axios";
|
||||||
import { OperationFailedError, makeErrorDetails } from "../errors.js";
|
import { OperationFailedError, makeErrorDetails } from "../errors.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import { Logger } from "@gnu-taler/taler-util";
|
import { Logger } from "@gnu-taler/taler-util";
|
||||||
import { bytesToString } from "../crypto/talerCrypto.js";
|
import { bytesToString } from "../crypto/talerCrypto.js";
|
||||||
import { TalerErrorCode } from "@gnu-taler/taler-util";
|
import { TalerErrorCode, URL } from "@gnu-taler/taler-util";
|
||||||
|
|
||||||
const logger = new Logger("NodeHttpLib.ts");
|
const logger = new Logger("NodeHttpLib.ts");
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
export * from "./errors.js";
|
export * from "./errors.js";
|
||||||
|
|
||||||
// Util functionality
|
// Util functionality
|
||||||
export { URL } from "./util/url.js";
|
|
||||||
export * from "./util/promiseUtils.js";
|
export * from "./util/promiseUtils.js";
|
||||||
export * from "./util/query.js";
|
export * from "./util/query.js";
|
||||||
export * from "./util/http.js";
|
export * from "./util/http.js";
|
||||||
|
@ -59,8 +59,8 @@ import {
|
|||||||
getTimestampNow,
|
getTimestampNow,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
timestampAddDuration,
|
timestampAddDuration,
|
||||||
|
URL
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { URL } from "../../util/url.js";
|
|
||||||
import {
|
import {
|
||||||
buildCodecForObject,
|
buildCodecForObject,
|
||||||
Codec,
|
Codec,
|
||||||
|
@ -36,6 +36,7 @@ import {
|
|||||||
timestampTruncateToSecond,
|
timestampTruncateToSecond,
|
||||||
TrackDepositGroupRequest,
|
TrackDepositGroupRequest,
|
||||||
TrackDepositGroupResponse,
|
TrackDepositGroupResponse,
|
||||||
|
URL
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { InternalWalletState } from "../common.js";
|
import { InternalWalletState } from "../common.js";
|
||||||
import { kdf } from "../crypto/primitives/kdf.js";
|
import { kdf } from "../crypto/primitives/kdf.js";
|
||||||
@ -49,7 +50,6 @@ import { guardOperationException } from "../errors.js";
|
|||||||
import { selectPayCoins } from "../util/coinSelection.js";
|
import { selectPayCoins } from "../util/coinSelection.js";
|
||||||
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
|
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
|
||||||
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import { getExchangeDetails } from "./exchanges.js";
|
import { getExchangeDetails } from "./exchanges.js";
|
||||||
import {
|
import {
|
||||||
applyCoinSpend,
|
applyCoinSpend,
|
||||||
|
@ -37,6 +37,7 @@ import {
|
|||||||
parsePaytoUri,
|
parsePaytoUri,
|
||||||
Recoup,
|
Recoup,
|
||||||
TalerErrorCode,
|
TalerErrorCode,
|
||||||
|
URL,
|
||||||
TalerErrorDetails,
|
TalerErrorDetails,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
@ -59,7 +60,6 @@ import {
|
|||||||
} from "../util/http.js";
|
} from "../util/http.js";
|
||||||
import { DbAccess, GetReadOnlyAccess } from "../util/query.js";
|
import { DbAccess, GetReadOnlyAccess } from "../util/query.js";
|
||||||
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import {
|
import {
|
||||||
guardOperationException,
|
guardOperationException,
|
||||||
makeErrorDetails,
|
makeErrorDetails,
|
||||||
|
@ -51,6 +51,7 @@ import {
|
|||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
parsePayUri,
|
parsePayUri,
|
||||||
Logger,
|
Logger,
|
||||||
|
URL,
|
||||||
getDurationRemaining,
|
getDurationRemaining,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto.js";
|
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto.js";
|
||||||
@ -99,7 +100,6 @@ import {
|
|||||||
OperationFailedAndReportedError,
|
OperationFailedAndReportedError,
|
||||||
OperationFailedError,
|
OperationFailedError,
|
||||||
} from "../errors.js";
|
} from "../errors.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger.
|
* Logger.
|
||||||
|
@ -45,9 +45,8 @@ import {
|
|||||||
} from "../db.js";
|
} from "../db.js";
|
||||||
|
|
||||||
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
|
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
|
||||||
import { Logger } from "@gnu-taler/taler-util";
|
import { Logger, URL } from "@gnu-taler/taler-util";
|
||||||
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import { guardOperationException } from "../errors.js";
|
import { guardOperationException } from "../errors.js";
|
||||||
import { createRefreshGroup, processRefreshGroup } from "./refresh.js";
|
import { createRefreshGroup, processRefreshGroup } from "./refresh.js";
|
||||||
import { getReserveRequestTimeout, processReserve } from "./reserves.js";
|
import { getReserveRequestTimeout, processReserve } from "./reserves.js";
|
||||||
|
@ -50,8 +50,8 @@ import {
|
|||||||
timestampAddDuration,
|
timestampAddDuration,
|
||||||
timestampDifference,
|
timestampDifference,
|
||||||
timestampMin,
|
timestampMin,
|
||||||
|
URL,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import { guardOperationException } from "../errors.js";
|
import { guardOperationException } from "../errors.js";
|
||||||
import { updateExchangeFromUrl } from "./exchanges.js";
|
import { updateExchangeFromUrl } from "./exchanges.js";
|
||||||
import { EXCHANGE_COINS_LOCK, InternalWalletState } from "../common.js";
|
import { EXCHANGE_COINS_LOCK, InternalWalletState } from "../common.js";
|
||||||
|
@ -42,6 +42,7 @@ import {
|
|||||||
RefreshReason,
|
RefreshReason,
|
||||||
TalerErrorCode,
|
TalerErrorCode,
|
||||||
TalerErrorDetails,
|
TalerErrorDetails,
|
||||||
|
URL,
|
||||||
timestampAddDuration,
|
timestampAddDuration,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
@ -56,7 +57,6 @@ import { readSuccessResponseJsonOrThrow } from "../util/http.js";
|
|||||||
import { checkDbInvariant } from "../util/invariants.js";
|
import { checkDbInvariant } from "../util/invariants.js";
|
||||||
import { GetReadWriteAccess } from "../util/query.js";
|
import { GetReadWriteAccess } from "../util/query.js";
|
||||||
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import { guardOperationException } from "../errors.js";
|
import { guardOperationException } from "../errors.js";
|
||||||
import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js";
|
import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js";
|
||||||
import { InternalWalletState } from "../common.js";
|
import { InternalWalletState } from "../common.js";
|
||||||
|
@ -64,13 +64,12 @@ import {
|
|||||||
getBankWithdrawalInfo,
|
getBankWithdrawalInfo,
|
||||||
} from "./withdraw.js";
|
} from "./withdraw.js";
|
||||||
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto.js";
|
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto.js";
|
||||||
import { Logger } from "@gnu-taler/taler-util";
|
import { Logger, URL } from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
readSuccessResponseJsonOrErrorCode,
|
readSuccessResponseJsonOrErrorCode,
|
||||||
readSuccessResponseJsonOrThrow,
|
readSuccessResponseJsonOrThrow,
|
||||||
throwUnexpectedRequestError,
|
throwUnexpectedRequestError,
|
||||||
} from "../util/http.js";
|
} from "../util/http.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import { GetReadOnlyAccess } from "../util/query.js";
|
import { GetReadOnlyAccess } from "../util/query.js";
|
||||||
|
|
||||||
const logger = new Logger("reserves.ts");
|
const logger = new Logger("reserves.ts");
|
||||||
|
@ -31,11 +31,11 @@ import {
|
|||||||
IntegrationTestArgs,
|
IntegrationTestArgs,
|
||||||
Amounts,
|
Amounts,
|
||||||
TestPayArgs,
|
TestPayArgs,
|
||||||
|
URL,
|
||||||
PreparePayResultType,
|
PreparePayResultType,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { createTalerWithdrawReserve } from "./reserves.js";
|
import { createTalerWithdrawReserve } from "./reserves.js";
|
||||||
import { InternalWalletState } from "../common.js";
|
import { InternalWalletState } from "../common.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import { confirmPay, preparePayForUri } from "./pay.js";
|
import { confirmPay, preparePayForUri } from "./pay.js";
|
||||||
import { getBalances } from "./balance.js";
|
import { getBalances } from "./balance.js";
|
||||||
import { runUntilDone } from "../wallet.js";
|
import { runUntilDone } from "../wallet.js";
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
TalerErrorCode,
|
TalerErrorCode,
|
||||||
codecForTipResponse,
|
codecForTipResponse,
|
||||||
Logger,
|
Logger,
|
||||||
|
URL,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { DerivedTipPlanchet } from "../crypto/cryptoTypes.js";
|
import { DerivedTipPlanchet } from "../crypto/cryptoTypes.js";
|
||||||
import {
|
import {
|
||||||
@ -50,7 +51,6 @@ import {
|
|||||||
selectWithdrawalDenominations,
|
selectWithdrawalDenominations,
|
||||||
denomSelectionInfoToState,
|
denomSelectionInfoToState,
|
||||||
} from "./withdraw.js";
|
} from "./withdraw.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import {
|
import {
|
||||||
getHttpResponseErrorDetails,
|
getHttpResponseErrorDetails,
|
||||||
readSuccessResponseJsonOrThrow,
|
readSuccessResponseJsonOrThrow,
|
||||||
|
@ -39,6 +39,7 @@ import {
|
|||||||
timestampCmp,
|
timestampCmp,
|
||||||
timestampSubtractDuraction,
|
timestampSubtractDuraction,
|
||||||
WithdrawResponse,
|
WithdrawResponse,
|
||||||
|
URL,
|
||||||
WithdrawUriInfoResponse,
|
WithdrawUriInfoResponse,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
@ -56,7 +57,6 @@ import {
|
|||||||
import { walletCoreDebugFlags } from "../util/debugFlags.js";
|
import { walletCoreDebugFlags } from "../util/debugFlags.js";
|
||||||
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
|
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
|
||||||
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
|
||||||
import { URL } from "../util/url.js";
|
|
||||||
import {
|
import {
|
||||||
guardOperationException,
|
guardOperationException,
|
||||||
makeErrorDetails,
|
makeErrorDetails,
|
||||||
|
@ -26,8 +26,8 @@ import {
|
|||||||
timestampDifference,
|
timestampDifference,
|
||||||
timestampCmp,
|
timestampCmp,
|
||||||
Logger,
|
Logger,
|
||||||
|
URL,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { URL } from "./url.js";
|
|
||||||
|
|
||||||
const logger = new Logger("RequestThrottler.ts");
|
const logger = new Logger("RequestThrottler.ts");
|
||||||
|
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of GNU Taler
|
|
||||||
(C) 2020 Taler Systems S.A.
|
|
||||||
|
|
||||||
GNU Taler is free software; you can redistribute it and/or modify it under the
|
|
||||||
terms of the GNU General Public License as published by the Free Software
|
|
||||||
Foundation; either version 3, or (at your option) any later version.
|
|
||||||
|
|
||||||
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with
|
|
||||||
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
interface URL {
|
|
||||||
hash: string;
|
|
||||||
host: string;
|
|
||||||
hostname: string;
|
|
||||||
href: string;
|
|
||||||
toString(): string;
|
|
||||||
readonly origin: string;
|
|
||||||
password: string;
|
|
||||||
pathname: string;
|
|
||||||
port: string;
|
|
||||||
protocol: string;
|
|
||||||
search: string;
|
|
||||||
readonly searchParams: URLSearchParams;
|
|
||||||
username: string;
|
|
||||||
toJSON(): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface URLSearchParams {
|
|
||||||
append(name: string, value: string): void;
|
|
||||||
delete(name: string): void;
|
|
||||||
get(name: string): string | null;
|
|
||||||
getAll(name: string): string[];
|
|
||||||
has(name: string): boolean;
|
|
||||||
set(name: string, value: string): void;
|
|
||||||
sort(): void;
|
|
||||||
toString(): string;
|
|
||||||
forEach(
|
|
||||||
callbackfn: (value: string, key: string, parent: URLSearchParams) => void,
|
|
||||||
thisArg?: any,
|
|
||||||
): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface URLSearchParamsCtor {
|
|
||||||
new (
|
|
||||||
init?: string[][] | Record<string, string> | string | URLSearchParams,
|
|
||||||
): URLSearchParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface URLCtor {
|
|
||||||
new (url: string, base?: string | URL): URL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const _URL = globalThis.URL;
|
|
||||||
if (!_URL) {
|
|
||||||
throw Error("FATAL: URL not available");
|
|
||||||
}
|
|
||||||
|
|
||||||
export const URL: URLCtor = _URL;
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const _URLSearchParams = globalThis.URLSearchParams;
|
|
||||||
|
|
||||||
if (!_URLSearchParams) {
|
|
||||||
throw Error("FATAL: URLSearchParams not available");
|
|
||||||
}
|
|
||||||
|
|
||||||
export const URLSearchParams: URLSearchParamsCtor = _URLSearchParams;
|
|
@ -19,6 +19,21 @@
|
|||||||
* WebExtension APIs consistently.
|
* WebExtension APIs consistently.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// globalThis polyfill, see https://mathiasbynens.be/notes/globalthis
|
||||||
|
(function () {
|
||||||
|
if (typeof globalThis === "object") return;
|
||||||
|
Object.defineProperty(Object.prototype, "__magic__", {
|
||||||
|
get: function () {
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
configurable: true, // This makes it possible to `delete` the getter later.
|
||||||
|
});
|
||||||
|
// @ts-ignore: polyfill magic
|
||||||
|
__magic__.globalThis = __magic__; // lolwat
|
||||||
|
// @ts-ignore: polyfill magic
|
||||||
|
delete Object.prototype.__magic__;
|
||||||
|
})();
|
||||||
|
|
||||||
export function isFirefox(): boolean {
|
export function isFirefox(): boolean {
|
||||||
const rt = chrome.runtime as any;
|
const rt = chrome.runtime as any;
|
||||||
if (typeof rt.getBrowserInfo === "function") {
|
if (typeof rt.getBrowserInfo === "function") {
|
||||||
|
Loading…
Reference in New Issue
Block a user