check for contract freshness
This commit is contained in:
parent
08d4a5b625
commit
d143ba9500
@ -173,7 +173,9 @@ namespace TalerNotify {
|
|||||||
(detail: any, sendResponse: (msg: any) => void): void;
|
(detail: any, sendResponse: (msg: any) => void): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadContract(url: string): Promise<any> {
|
function downloadContract(url: string, nonce: string): Promise<any> {
|
||||||
|
let parsed_url = URI(url);
|
||||||
|
url = parsed_url.setQuery({nonce}).href();
|
||||||
// FIXME: include and check nonce!
|
// FIXME: include and check nonce!
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const contract_request = new XMLHttpRequest();
|
const contract_request = new XMLHttpRequest();
|
||||||
@ -356,7 +358,11 @@ namespace TalerNotify {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg.contract_url) {
|
if (msg.contract_url) {
|
||||||
let proposal = await downloadContract(msg.contract_url);
|
let nonce = Math.round(Math.random() * 0xFFFF).toString()
|
||||||
|
let proposal = await downloadContract(msg.contract_url, nonce);
|
||||||
|
if (proposal.data.nonce != nonce) {
|
||||||
|
console.error("stale contract");
|
||||||
|
}
|
||||||
await processProposal(proposal);
|
await processProposal(proposal);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -444,6 +444,9 @@ export class Contract {
|
|||||||
@Checkable.Optional(Checkable.String)
|
@Checkable.Optional(Checkable.String)
|
||||||
summary?: string;
|
summary?: string;
|
||||||
|
|
||||||
|
@Checkable.Optional(Checkable.String)
|
||||||
|
nonce?: string;
|
||||||
|
|
||||||
@Checkable.Value(AmountJson)
|
@Checkable.Value(AmountJson)
|
||||||
amount: AmountJson;
|
amount: AmountJson;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user