Remove v2 view-key payment monitor (privacy concern — nobody should enter their private view key on a website). Replace with TX proof verification where the sender provides TX Hash + TX Key from their wallet. The proof is cryptographically verified client-side and stored with the invoice for persistent "Paid" status. - Remove monitor.js and all view-key monitoring UI/logic - Add TX proof section: sender enters TX Hash + TX Key - Client-side verification via check_tx_key equivalent (noble-curves) - api/verify.php stores/retrieves payment proofs per invoice - Short URL redirect now includes invoice code for status lookup - Invoice link shows "Paid" badge once proof is verified - Deadline badges (7/14/30 days) for payment terms
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
var CACHE_NAME = 'xmrpay-v3';
|
|
var ASSETS = [
|
|
'/',
|
|
'/index.html',
|
|
'/app.js',
|
|
'/i18n.js',
|
|
'/style.css',
|
|
'/lib/qrcode.min.js'
|
|
// xmr-crypto.bundle.js is lazy-loaded and runtime-cached
|
|
];
|
|
|
|
self.addEventListener('install', function (e) {
|
|
e.waitUntil(
|
|
caches.open(CACHE_NAME).then(function (cache) {
|
|
return cache.addAll(ASSETS);
|
|
})
|
|
);
|
|
self.skipWaiting();
|
|
});
|
|
|
|
self.addEventListener('activate', function (e) {
|
|
e.waitUntil(
|
|
caches.keys().then(function (names) {
|
|
return Promise.all(
|
|
names.filter(function (n) { return n !== CACHE_NAME; })
|
|
.map(function (n) { return caches.delete(n); })
|
|
);
|
|
})
|
|
);
|
|
self.clients.claim();
|
|
});
|
|
|
|
self.addEventListener('fetch', function (e) {
|
|
var url = new URL(e.request.url);
|
|
|
|
// External APIs and RPC proxy — network only, don't cache
|
|
if (url.hostname !== location.hostname || url.pathname.startsWith('/api/')) {
|
|
e.respondWith(fetch(e.request));
|
|
return;
|
|
}
|
|
|
|
// App assets — cache first, fallback to network
|
|
e.respondWith(
|
|
caches.match(e.request).then(function (cached) {
|
|
var networkFetch = fetch(e.request).then(function (response) {
|
|
if (response.ok) {
|
|
var clone = response.clone();
|
|
caches.open(CACHE_NAME).then(function (cache) {
|
|
cache.put(e.request, clone);
|
|
});
|
|
}
|
|
return response;
|
|
}).catch(function () {
|
|
return cached;
|
|
});
|
|
return cached || networkFetch;
|
|
})
|
|
);
|
|
});
|