missing files

This commit is contained in:
Florian Dold 2016-11-19 17:37:39 +01:00
parent 2cd4a85ed4
commit 1357271717
5 changed files with 182 additions and 4 deletions

80
src/moduleTrampoline.ts Normal file
View File

@ -0,0 +1,80 @@
/*
This file is part of TALER
(C) 2016 GNUnet e.V.
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.
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
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* Boilerplate to initialize the module system and call main()
*
* @author Florian Dold
*/
"use strict";
if (typeof System === "undefined") {
throw Error("system loader not present (must be included before the" +
" trampoline");
}
System.config({
defaultJSExtensions: true,
map: {
src: "/src/",
},
});
let me = window.location.protocol
+ "//" + window.location.host
+ window.location.pathname.replace(/[.]html$/, ".js");
let domLoaded = false;
document.addEventListener("DOMContentLoaded", function(event) {
domLoaded = true;
});
function execMain(m: any) {
if (m.main) {
console.log("executing module main");
let res = m.main();
} else {
console.warn("module does not export a main() function");
}
}
console.log("loading", me);
System.import("src/logging").then((logging) => {
window.onerror = (m, source, lineno, colno, error) => {
logging.record("error", m + error, source || "(unknown)", undefined, lineno || 0, colno || 0);
};
window.addEventListener('unhandledrejection', (evt: any) => {
logging.recordException("unhandled promise rejection", evt.reason);
});
System.import(me).then((m) => {
if (domLoaded) {
execMain(m);
return;
}
document.addEventListener("DOMContentLoaded", function(event) {
execMain(m);
});
});
})
.catch((e) => {
console.log("trampoline failed");
console.error(e.stack);
});

27
src/pages/error.html Normal file
View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<title>Taler Wallet: Error Occured</title>
<link rel="stylesheet" type="text/css" href="../style/lang.css">
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
<link rel="icon" href="/img/icon.png">
<script src="/src/vendor/URI.js"></script>
<script src="/src/vendor/react.js"></script>
<script src="/src/vendor/react-dom.js"></script>
<!-- i18n -->
<script src="/src/vendor/jed.js"></script>
<script src="/src/i18n.js"></script>
<script src="/src/i18n/strings.js"></script>
<script src="/src/vendor/system-csp-production.src.js"></script>
<script src="/src/moduleTrampoline.js"></script>
<body>
<div id="container"></div>
</body>
</html>

59
src/pages/error.tsx Normal file
View File

@ -0,0 +1,59 @@
/*
This file is part of TALER
(C) 2015-2016 GNUnet e.V.
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.
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
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* Page shown to the user to confirm creation
* of a reserve, usually requested by the bank.
*
* @author Florian Dold
*/
import {ImplicitStateComponent, StateHolder} from "src/components";
"use strict";
interface ErrorProps {
message: string;
}
class ErrorView extends React.Component<ErrorProps, void> {
render(): JSX.Element {
return (
<div>
An error occurred: {this.props.message}
</div>
);
}
}
export async function main() {
try {
const url = URI(document.location.href);
const query: any = URI.parseQuery(url.query());
const message: string = query.message || "unknown error";
ReactDOM.render(<ErrorView message={message} />, document.getElementById(
"container")!);
} catch (e) {
// TODO: provide more context information, maybe factor it out into a
// TODO:generic error reporting function or component.
document.body.innerText = `Fatal error: "${e.message}".`;
console.error(`got error "${e.message}"`, e);
}
}

View File

@ -392,6 +392,17 @@ function handleBankRequest(wallet: Wallet, headerList: chrome.webRequest.HttpHea
console.log("202 not understood (X-Taler-Callback-Url missing)"); console.log("202 not understood (X-Taler-Callback-Url missing)");
return; return;
} }
let amountParsed;
try {
amountParsed = JSON.parse(amount);
} catch (e) {
let uri = URI(chrome.extension.getURL("/src/pages/error.html"));
let p = {
message: `Can't parse amount ("${amount}"): ${e.message}`,
};
let redirectUrl = uri.query(p).href();
return {redirectUrl};
}
let wtTypes = headers["x-taler-wt-types"]; let wtTypes = headers["x-taler-wt-types"];
if (!wtTypes) { if (!wtTypes) {
console.log("202 not understood (X-Taler-Wt-Types missing)"); console.log("202 not understood (X-Taler-Wt-Types missing)");
@ -408,7 +419,7 @@ function handleBankRequest(wallet: Wallet, headerList: chrome.webRequest.HttpHea
let redirectUrl = uri.query(params).href(); let redirectUrl = uri.query(params).href();
return {redirectUrl}; return {redirectUrl};
} }
console.log("202 not understood"); // no known headers found, not a taler request ...
} }
// Useful for debugging ... // Useful for debugging ...

View File

@ -16,14 +16,14 @@
"src/checkable.ts", "src/checkable.ts",
"decl/lib.es6.d.ts", "decl/lib.es6.d.ts",
"src/chromeBadge.ts", "src/chromeBadge.ts",
"decl/urijs/URIjs.d.ts",
"src/cryptoApi-test.ts", "src/cryptoApi-test.ts",
"decl/urijs/URIjs.d.ts",
"src/components.ts", "src/components.ts",
"decl/systemjs/systemjs.d.ts",
"src/emscriptif-test.ts", "src/emscriptif-test.ts",
"decl/systemjs/systemjs.d.ts",
"src/cryptoApi.ts", "src/cryptoApi.ts",
"decl/react-global.d.ts",
"src/helpers-test.ts", "src/helpers-test.ts",
"decl/react-global.d.ts",
"src/cryptoLib.ts", "src/cryptoLib.ts",
"src/types-test.ts", "src/types-test.ts",
"decl/chrome/chrome.d.ts", "decl/chrome/chrome.d.ts",
@ -48,6 +48,7 @@
"src/pages/show-db.ts", "src/pages/show-db.ts",
"src/pages/confirm-contract.tsx", "src/pages/confirm-contract.tsx",
"src/pages/confirm-create-reserve.tsx", "src/pages/confirm-create-reserve.tsx",
"src/pages/error.tsx",
"src/pages/logs.tsx", "src/pages/logs.tsx",
"src/pages/tree.tsx", "src/pages/tree.tsx",
"src/popup/popup.tsx" "src/popup/popup.tsx"