Make wallet handshake conform more to spec.
This commit is contained in:
parent
1089b40b1c
commit
a176c91489
@ -3,18 +3,28 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Listen to messages from the backend.
|
// Install our handshake handlers only once the
|
||||||
chrome.runtime.onMessage.addListener(
|
// document is loaded
|
||||||
function(request, sender, sendResponse) {
|
// TODO: change the spec to do it on the body
|
||||||
// do nothing, yet
|
document.addEventListener("DOMContentLoaded", function(e) {
|
||||||
});
|
console.log("DOM fully loaded and parsed");
|
||||||
|
|
||||||
if (document && document.body)
|
|
||||||
{
|
|
||||||
document.body.addEventListener('taler-checkout-probe', function(e) {
|
document.body.addEventListener('taler-checkout-probe', function(e) {
|
||||||
let evt = new Event('taler-wallet-present');
|
let evt = new Event('taler-wallet-present');
|
||||||
document.body.dispatchEvent(evt);
|
document.body.dispatchEvent(evt);
|
||||||
|
console.log("merchant handshake done");
|
||||||
});
|
});
|
||||||
}
|
document.body.addEventListener('taler-wire-probe', function(e) {
|
||||||
|
let evt = new Event('taler-wallet-present');
|
||||||
|
document.body.dispatchEvent(evt);
|
||||||
|
console.log("bank handshake done");
|
||||||
|
});
|
||||||
|
document.body.addEventListener('taler-create-reserve', function(e) {
|
||||||
|
console.log("reserve creation " + JSON.stringify(e.detail));
|
||||||
|
chrome.runtime.sendMessage({action:'new-reserve-request', detail:e.detail}, function(resp) {
|
||||||
|
console.log("got response");
|
||||||
|
document.location.href = resp.url;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
console.log("Taler wallet: content page loaded");
|
console.log("Taler wallet: content page loaded");
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
"use strict";
|
"use strict";
|
||||||
function talerHandshake() {
|
function talerHandshake() {
|
||||||
document.addEventListener('taler-wallet-present', function(e) {
|
document.body.addEventListener('taler-wallet-present', function(e) {
|
||||||
var x = document.getElementById('indicator');
|
var x = document.getElementById('indicator');
|
||||||
x.innerHTML = 'found!';
|
x.innerHTML = 'found!';
|
||||||
});
|
});
|
||||||
var evt = new Event('taler-checkout-probe');
|
var evt = new Event('taler-checkout-probe');
|
||||||
document.dispatchEvent(evt);
|
document.body.dispatchEvent(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = (e) => talerHandshake();
|
window.onload = (e) => talerHandshake();
|
||||||
|
Loading…
Reference in New Issue
Block a user