diff --git a/lnbits/extensions/paywall/crud.py b/lnbits/extensions/paywall/crud.py index 2fcf5a0a..529913f3 100644 --- a/lnbits/extensions/paywall/crud.py +++ b/lnbits/extensions/paywall/crud.py @@ -11,10 +11,10 @@ def create_paywall(*, wallet_id: str, url: str, memo: str, amount: int) -> Paywa paywall_id = urlsafe_short_hash() db.execute( """ - INSERT INTO paywalls (id, wallet, url, memo, amount) - VALUES (?, ?, ?, ?, ?) + INSERT INTO paywalls (id, wallet, secret, url, memo, amount) + VALUES (?, ?, ?, ?, ?, ?) """, - (paywall_id, wallet_id, url, memo, amount), + (paywall_id, wallet_id, urlsafe_short_hash(), url, memo, amount), ) return get_paywall(paywall_id) diff --git a/lnbits/extensions/paywall/migrations.py b/lnbits/extensions/paywall/migrations.py index 7fb19b66..74ae6f89 100644 --- a/lnbits/extensions/paywall/migrations.py +++ b/lnbits/extensions/paywall/migrations.py @@ -9,6 +9,7 @@ def m001_initial(db): CREATE TABLE IF NOT EXISTS paywalls ( id TEXT PRIMARY KEY, wallet TEXT NOT NULL, + secret TEXT NOT NULL, url TEXT NOT NULL, memo TEXT NOT NULL, amount INTEGER NOT NULL, @@ -18,5 +19,5 @@ def m001_initial(db): def migrate(): - with open_ext_db("tpos") as db: + with open_ext_db("paywall") as db: m001_initial(db) diff --git a/lnbits/extensions/paywall/models.py b/lnbits/extensions/paywall/models.py index 4f12d7e6..7fd7fb37 100644 --- a/lnbits/extensions/paywall/models.py +++ b/lnbits/extensions/paywall/models.py @@ -1,10 +1,15 @@ +from hashlib import sha256 from typing import NamedTuple class Paywall(NamedTuple): id: str wallet: str + secret: str url: str memo: str amount: int time: int + + def key_for(self, fingerprint: str) -> str: + return sha256(f"{self.secret}{fingerprint}".encode("utf-8")).hexdigest() diff --git a/lnbits/extensions/paywall/static/vendor/fingerprintjs2@2.1.0/fingerprint2.min.js b/lnbits/extensions/paywall/static/vendor/fingerprintjs2@2.1.0/fingerprint2.min.js new file mode 100644 index 00000000..f8b4babe --- /dev/null +++ b/lnbits/extensions/paywall/static/vendor/fingerprintjs2@2.1.0/fingerprint2.min.js @@ -0,0 +1,4 @@ +// Fingerprintjs2 - Copyright (c) 2019 Valentin Vasilyev (valentin.vasilyev@outlook.com) +// Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. + +!function(e,t,a){"use strict";"undefined"!=typeof window&&"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&module.exports?module.exports=a():t.exports?t.exports=a():t.Fingerprint2=a()}(0,this,function(){"use strict";var d=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var a=[0,0,0,0];return a[3]+=e[3]+t[3],a[2]+=a[3]>>>16,a[3]&=65535,a[2]+=e[2]+t[2],a[1]+=a[2]>>>16,a[2]&=65535,a[1]+=e[1]+t[1],a[0]+=a[1]>>>16,a[1]&=65535,a[0]+=e[0]+t[0],a[0]&=65535,[a[0]<<16|a[1],a[2]<<16|a[3]]},g=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var a=[0,0,0,0];return a[3]+=e[3]*t[3],a[2]+=a[3]>>>16,a[3]&=65535,a[2]+=e[2]*t[3],a[1]+=a[2]>>>16,a[2]&=65535,a[2]+=e[3]*t[2],a[1]+=a[2]>>>16,a[2]&=65535,a[1]+=e[1]*t[3],a[0]+=a[1]>>>16,a[1]&=65535,a[1]+=e[2]*t[2],a[0]+=a[1]>>>16,a[1]&=65535,a[1]+=e[3]*t[1],a[0]+=a[1]>>>16,a[1]&=65535,a[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],a[0]&=65535,[a[0]<<16|a[1],a[2]<<16|a[3]]},f=function(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])},h=function(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=g(e,[4283543511,3981806797]),e=m(e,[0,e[0]>>>1]),e=g(e,[3301882366,444984403]),e=m(e,[0,e[0]>>>1])},l=function(e,t){t=t||0;for(var a=(e=e||"").length%16,n=e.length-a,r=[0,t],i=[0,t],o=[0,0],l=[0,0],s=[2277735313,289559509],c=[1291169091,658871167],u=0;u>>0).toString(16)).slice(-8)+("00000000"+(r[1]>>>0).toString(16)).slice(-8)+("00000000"+(i[0]>>>0).toString(16)).slice(-8)+("00000000"+(i[1]>>>0).toString(16)).slice(-8)},e={preprocessor:null,audio:{timeout:1e3,excludeIOS11:!0},fonts:{swfContainerId:"fingerprintjs2",swfPath:"flash/compiled/FontList.swf",userDefinedFonts:[],extendedJsFonts:!1},screen:{detectScreenOrientation:!0},plugins:{sortPluginsFor:[/palemoon/i],excludeIE:!1},extraComponents:[],excludes:{enumerateDevices:!0,pixelRatio:!0,doNotTrack:!0,fontsFlash:!0},NOT_AVAILABLE:"not available",ERROR:"error",EXCLUDED:"excluded"},c=function(e,t){if(Array.prototype.forEach&&e.forEach===Array.prototype.forEach)e.forEach(t);else if(e.length===+e.length)for(var a=0,n=e.length;at.name?1:e.name=a.components.length)n(r.data);else{var t=a.components[i];if(a.excludes[t.key])o(!1);else{if(!e&&t.pauseBefore)return i-=1,void setTimeout(function(){o(!0)},1);try{t.getData(function(e){r.addPreprocessedComponent(t.key,e),o(!1)},a)}catch(e){r.addPreprocessedComponent(t.key,String(e)),o(!1)}}}};o(!1)},U.getPromise=function(a){return new Promise(function(e,t){U.get(a,e)})},U.getV18=function(i,o){return null==o&&(o=i,i={}),U.get(i,function(e){for(var t=[],a=0;a - - - - - - - @@ -18,7 +11,14 @@ - + + + + + + + + diff --git a/lnbits/extensions/paywall/templates/paywall/display.html b/lnbits/extensions/paywall/templates/paywall/display.html new file mode 100644 index 00000000..5b12ffe8 --- /dev/null +++ b/lnbits/extensions/paywall/templates/paywall/display.html @@ -0,0 +1,114 @@ +{% extends "public.html" %} + + +{% block page %} +
+
+ + + + + +
+

You can access the URL behind this paywall:
+ {% raw %}{{ redirectUrl }}{% endraw %}

+
+ Open URL +
+
+
+
+
+
+ + +
LNbits paywall
+
+
+
+
+{% endblock %} + +{% block scripts %} + + + +{% endblock %} diff --git a/lnbits/extensions/paywall/templates/paywall/index.html b/lnbits/extensions/paywall/templates/paywall/index.html index 7db53339..75af2103 100644 --- a/lnbits/extensions/paywall/templates/paywall/index.html +++ b/lnbits/extensions/paywall/templates/paywall/index.html @@ -8,7 +8,7 @@
- New Paywall + New paywall @@ -44,7 +44,7 @@