support for ext+taler:// while taler:// is not yet allowed as scheme
This commit is contained in:
parent
5c84c32736
commit
dc002f99a9
@ -26,6 +26,13 @@
|
||||
"https://*/*",
|
||||
"webRequest"
|
||||
],
|
||||
"protocol_handlers": [
|
||||
{
|
||||
"protocol": "ext+taler",
|
||||
"name": "Taler Wallet WebExtension",
|
||||
"uriTemplate": "/static/wallet.html#/cta/withdraw?d=1&talerWithdrawUri=%s"
|
||||
}
|
||||
],
|
||||
"browser_action": {
|
||||
"default_icon": {
|
||||
"16": "static/img/taler-logo-16.png",
|
||||
|
@ -29,6 +29,18 @@
|
||||
"optional_permissions": [
|
||||
"webRequest"
|
||||
],
|
||||
"web_accessible_resources": [
|
||||
{
|
||||
"resources": [
|
||||
"static/wallet.html"
|
||||
],
|
||||
"matches": [
|
||||
"https://*/*",
|
||||
"http://*/*",
|
||||
"file://*/*"
|
||||
]
|
||||
}
|
||||
],
|
||||
"host_permissions": [
|
||||
"http://*/*",
|
||||
"https://*/*"
|
||||
|
@ -90,7 +90,7 @@ export function useComponentStateFromParams({
|
||||
}
|
||||
|
||||
export function useComponentStateFromURI({
|
||||
talerWithdrawUri,
|
||||
talerWithdrawUri: maybeTalerUri,
|
||||
cancel,
|
||||
onSuccess,
|
||||
}: PropsFromURI): RecursiveState<State> {
|
||||
@ -99,7 +99,10 @@ export function useComponentStateFromURI({
|
||||
* Ask the wallet about the withdraw URI
|
||||
*/
|
||||
const uriInfoHook = useAsyncAsHook(async () => {
|
||||
if (!talerWithdrawUri) throw Error("ERROR_NO-URI-FOR-WITHDRAWAL");
|
||||
if (!maybeTalerUri) throw Error("ERROR_NO-URI-FOR-WITHDRAWAL");
|
||||
const talerWithdrawUri = maybeTalerUri.startsWith("ext+")
|
||||
? maybeTalerUri.substring(4)
|
||||
: maybeTalerUri;
|
||||
|
||||
const uriInfo = await api.wallet.call(
|
||||
WalletApiOperation.GetWithdrawalDetailsForUri,
|
||||
|
@ -233,7 +233,10 @@ function notifyWhenAppIsReady(callback: () => void): void {
|
||||
}
|
||||
}
|
||||
|
||||
function openWalletURIFromPopup(talerUri: string): void {
|
||||
function openWalletURIFromPopup(maybeTalerUri: string): void {
|
||||
const talerUri = maybeTalerUri.startsWith("ext+")
|
||||
? maybeTalerUri.substring(4)
|
||||
: maybeTalerUri;
|
||||
const uriType = classifyTalerUri(talerUri);
|
||||
|
||||
let url: string | undefined = undefined;
|
||||
|
@ -170,7 +170,7 @@ export function View({
|
||||
<p>
|
||||
<i18n.Translate>Debug tools</i18n.Translate>:
|
||||
</p>
|
||||
<Grid container justifyContent="space-between" spacing={1}>
|
||||
<Grid container justifyContent="space-between" spacing={1} size={4}>
|
||||
<Grid item>
|
||||
<Button
|
||||
variant="contained"
|
||||
@ -251,6 +251,64 @@ export function View({
|
||||
<i18n.Translate>export database</i18n.Translate>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={async () => {
|
||||
navigator.registerProtocolHandler(
|
||||
"taler",
|
||||
`${window.location.origin}/static/wallet.html#/cta/withdraw?talerWithdrawUri=%s`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<i18n.Translate>Register taler:// handler</i18n.Translate>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={async () => {
|
||||
const n = navigator as any;
|
||||
if ("unregisterProtocolHandler" in n) {
|
||||
n.unregisterProtocolHandler(
|
||||
"taler",
|
||||
`${window.location.origin}/static/wallet.html#/cta/withdraw?talerWithdrawUri=%s`,
|
||||
);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<i18n.Translate>Remove taler:// handler</i18n.Translate>
|
||||
</Button>
|
||||
</Grid>{" "}
|
||||
<Grid item>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={async () => {
|
||||
navigator.registerProtocolHandler(
|
||||
"ext+taler",
|
||||
`${window.location.origin}/static/wallet.html#/cta/withdraw?talerWithdrawUri=%s`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<i18n.Translate>Register ext+taler:// handler</i18n.Translate>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Button
|
||||
variant="contained"
|
||||
onClick={async () => {
|
||||
const n = navigator as any;
|
||||
if ("unregisterProtocolHandler" in n) {
|
||||
n.unregisterProtocolHandler(
|
||||
"ext+taler",
|
||||
`${window.location.origin}/static/wallet.html#/cta/withdraw?talerWithdrawUri=%s`,
|
||||
);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<i18n.Translate>Remove ext+taler:// handler</i18n.Translate>
|
||||
</Button>
|
||||
</Grid>{" "}
|
||||
</Grid>
|
||||
{downloadedDatabase && (
|
||||
<div>
|
||||
|
@ -298,7 +298,10 @@ async function reinitWallet(): Promise<void> {
|
||||
return walletInit.resolve();
|
||||
}
|
||||
|
||||
function parseTalerUriAndRedirect(tabId: number, talerUri: string): void {
|
||||
function parseTalerUriAndRedirect(tabId: number, maybeTalerUri: string): void {
|
||||
const talerUri = maybeTalerUri.startsWith("ext+")
|
||||
? maybeTalerUri.substring(4)
|
||||
: maybeTalerUri;
|
||||
const uriType = classifyTalerUri(talerUri);
|
||||
switch (uriType) {
|
||||
case TalerUriType.TalerWithdraw:
|
||||
|
Loading…
Reference in New Issue
Block a user