Socket
Socket
Sign inDemoInstall

pagecrypt

Package Overview
Dependencies
3
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.2.0 to 5.3.0

pagecrypt-5.3.0.tgz

17

CHANGELOG.md
# Changelog for `pagecrypt`
## 5.3.0 - 2021-08-31
### Features
- feature(ui): Add submit button to simplify mobile usage.
- feature(ui): Build and use the latest decrypt template with new submit button
### Fixes
- fix(deps): Update deps to latest minor and patch releases.
- fix(build): Update build script with improved html template transformations
- fix(build): Improve removal of the vite module inline script.
- fix(build): Simplify build process to remove the steps no longer necessary.
- fix(dev): Update dev template.
---
## 5.2.0 - 2021-08-15

@@ -4,0 +21,0 @@

34

cli.js

@@ -27,33 +27,3 @@ #!/usr/bin/env node

// src/decrypt-template.html
var decrypt_template_default = `<!DOCTYPE html>\r
<html>\r
<head>\r
<meta charset="utf-8">\r
<meta name="viewport" content="width=device-width, initial-scale=1">\r
<meta name="robots" content="noindex, nofollow">
<title>Protected Page</title>\r
<script type="module">var e,t;var n={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},a=function(e,t){return function(e,t,n){var a;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var r=0;r<t.chars.length;++r)t.codes[t.chars[r]]=r}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var o=new(null!=(a=n.out)?a:Uint8Array)(i*t.bits/8|0),s=0,c=0,d=0,l=0;l<i;++l){var u=t.codes[e[l]];if(void 0===u)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|u,(s+=t.bits)>=8&&(s-=8,o[d++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return o}(e,n,t)};const r=document.querySelector.bind(document),[i,o,s,c,d]=["input","header","#msg","form","#load"].map(r);let l,u,w;document.addEventListener("DOMContentLoaded",(async()=>{const e=r("pre").innerText;if(!e)return i.disabled=!0,void v("No encrypted payload.");const t=a(e);if(l=t.slice(0,32),u=t.slice(32,48),w=t.slice(48),location.hash){const e=new URL(window.location.href);i.value=e.hash.slice(1),e.hash="",history.replaceState(null,"",e.toString())}sessionStorage.k||i.value?await p():(y(d),f(c),o.classList.replace("hidden","flex"),i.focus())}));const h=(null==(e=window.crypto)?void 0:e.subtle)||(null==(t=window.crypto)?void 0:t.webkitSubtle);function f(e){e.classList.remove("hidden")}function y(e){e.classList.add("hidden")}function v(e){s.innerText=e,o.classList.add("text-red-600")}async function p(){d.lastElementChild.innerText="Decrypting...",y(o),y(c),f(d),await async function(e){return new Promise((t=>setTimeout(t,e)))}(60);try{const e=await async function({salt:e,iv:t,ciphertext:n},a){const r=new TextDecoder,i=sessionStorage.k?await async function(e){return h.importKey("jwk",e,"AES-GCM",!0,["decrypt"])}(JSON.parse(sessionStorage.k)):await async function(e,t){const n=new TextEncoder,a=await h.importKey("raw",n.encode(t),"PBKDF2",!1,["deriveKey"]);return await h.deriveKey({name:"PBKDF2",salt:e,iterations:2e6,hash:"SHA-256"},a,{name:"AES-GCM",length:256},!0,["decrypt"])}(e,a),o=new Uint8Array(await h.decrypt({name:"AES-GCM",iv:t},i,n));if(!o)throw"Malformed data";return sessionStorage.k=JSON.stringify(await h.exportKey("jwk",i)),r.decode(o)}({salt:l,iv:u,ciphertext:w},i.value);document.write(e),document.close()}catch(e){y(d),f(c),o.classList.replace("hidden","flex"),sessionStorage.k?sessionStorage.removeItem("k"):v("Wrong password."),i.value="",i.focus()}}h||(v("Please use a modern browser."),i.disabled=!0),c.addEventListener("submit",(async e=>{e.preventDefault(),await p()}));<\/script>
<style>/*! tailwindcss v2.2.7 | MIT License | https://tailwindcss.com *//*! modern-normalize v1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */*,::after,::before{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji'}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Consolas,'Liberation Mono',Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}::-moz-focus-inner{border-style:none;padding:0}:-moz-focusring{outline:1px dotted ButtonText}:-moz-ui-invalid{box-shadow:none}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,::after,::before{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a8a29e}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a8a29e}input::placeholder,textarea::placeholder{opacity:1;color:#a8a29e}[role=button],button{cursor:pointer}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::after,::before{--tw-border-opacity:1;border-color:rgba(231,229,228,var(--tw-border-opacity));--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}.fixed{position:fixed}.bottom-0{bottom:0}.right-0{right:0}.mx-auto{margin-left:auto;margin-right:auto}.mr-4{margin-right:1rem}.mb-4{margin-bottom:1rem}.flex{display:flex}.table{display:table}.hidden{display:none}.h-screen{height:100vh}.h-28{height:7rem}.h-full{height:100%}.h-6{height:1.5rem}.w-full{width:100%}.w-6{width:1.5rem}.max-w-sm{max-width:24rem}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-gray-700{--tw-border-opacity:1;border-color:rgba(68,64,60,var(--tw-border-opacity))}.bg-black{--tw-bg-opacity:1;background-color:rgba(0,0,0,var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity:1;background-color:rgba(41,37,36,var(--tw-bg-opacity))}.bg-yellow-200{--tw-bg-opacity:1;background-color:rgba(254,240,138,var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity:1;background-color:rgba(250,250,249,var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity:1;background-color:rgba(231,229,228,var(--tw-bg-opacity))}.p-4{padding:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.pt-40{padding-top:10rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-light{font-weight:300}.font-extralight{font-weight:200}.font-semibold{font-weight:600}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-white{--tw-text-opacity:1;color:rgba(255,255,255,var(--tw-text-opacity))}.text-red-600{--tw-text-opacity:1;color:rgba(220,38,38,var(--tw-text-opacity))}.text-black{--tw-text-opacity:1;color:rgba(0,0,0,var(--tw-text-opacity))}.text-opacity-100{--tw-text-opacity:1}.shadow-2xl{--tw-shadow:0 25px 50px -12px rgba(0, 0, 0, 0.25);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.loading{pointer-events:none;width:2em;height:2em;border:.15em solid transparent;border-color:#fff;border-right-width:.1em;border-radius:50%;-webkit-animation:spin .5s linear infinite;animation:spin .5s linear infinite}@-webkit-keyframes spin{100%{transform:rotate(360deg)}}@keyframes spin{100%{transform:rotate(360deg)}}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}@media (min-width:475px){.xs\\:text-base{font-size:1rem;line-height:1.5rem}}</style>
</head>\r
<body>\r
<main class="bg-black w-full h-screen items-start tracking-wide p-4 pt-40 font-light text-white">\r
<div class="max-w-sm w-full bg-gray-800 p-4 rounded-sm mx-auto h-28">\r
<div id="load" class="flex items-center justify-center h-full">\r
<p class="loading w-6 h-6 mr-4"></p><p class="text-lg">Loading...</p>\r
</div>\r
<header class="hidden gap-2 mb-4 items-center">\r
<svg id="locked" class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\r
<path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd"></path>\r
</svg>\r
<p id="msg" class="text-sm xs:text-base">This page is password protected.</p>\r
</header>\r
<form class="hidden">\r
<input type="password" id="pwd" name="pwd" aria-label="Password" autofocus class="font-extralight flex w-full py-2 px-4 tracking-wider rounded-sm focus:outline-none border border-gray-700 bg-gray-800" />\r
</form>\r
</div>\r
<a href="https://github.com/Greenheart/pagecrypt" class="fixed bottom-0 right-0 p-4">Created with <span class="font-semibold">PageCrypt</span></a>\r
</main>
<!--ENCRYPTED PAYLOAD-->\r
</body>\r
</html>`;
var decrypt_template_default = '<!DOCTYPE html>\r\n<html>\r\n<head>\r\n <meta charset="utf-8">\r\n <meta name="viewport" content="width=device-width, initial-scale=1">\r\n <meta name="robots" content="noindex, nofollow">\n <title>Protected Page</title>\r\n <script type="module">var e,t;var n={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},r=function(e,t){return function(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var s=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),a=0,c=0,d=0,l=0;l<i;++l){var u=t.codes[e[l]];if(void 0===u)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|u,(a+=t.bits)>=8&&(a-=8,s[d++]=255&c>>a)}if(a>=t.bits||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}(e,n,t)};const o=document.querySelector.bind(document),[i,s,a,c,d]=["input","header","#msg","form","#load"].map(o);let l,u,f;document.addEventListener("DOMContentLoaded",(async()=>{const e=o("pre").innerText;if(!e)return i.disabled=!0,void p("No encrypted payload.");const t=r(e);if(l=t.slice(0,32),u=t.slice(32,48),f=t.slice(48),location.hash){const e=new URL(window.location.href);i.value=e.hash.slice(1),e.hash="",history.replaceState(null,"",e.toString())}sessionStorage.k||i.value?await m():(h(d),y(c),s.classList.replace("hidden","flex"),i.focus())}));const w=(null==(e=window.crypto)?void 0:e.subtle)||(null==(t=window.crypto)?void 0:t.webkitSubtle);function y(e){e.classList.remove("hidden")}function h(e){e.classList.add("hidden")}function p(e){a.innerText=e,s.classList.add("text-red-600")}async function m(){d.lastElementChild.innerText="Decrypting...",h(s),h(c),y(d),await async function(e){return new Promise((t=>setTimeout(t,e)))}(60);try{const e=await async function({salt:e,iv:t,ciphertext:n},r){const o=new TextDecoder,i=sessionStorage.k?await async function(e){return w.importKey("jwk",e,"AES-GCM",!0,["decrypt"])}(JSON.parse(sessionStorage.k)):await async function(e,t){const n=new TextEncoder,r=await w.importKey("raw",n.encode(t),"PBKDF2",!1,["deriveKey"]);return await w.deriveKey({name:"PBKDF2",salt:e,iterations:2e6,hash:"SHA-256"},r,{name:"AES-GCM",length:256},!0,["decrypt"])}(e,r),s=new Uint8Array(await w.decrypt({name:"AES-GCM",iv:t},i,n));if(!s)throw"Malformed data";return sessionStorage.k=JSON.stringify(await w.exportKey("jwk",i)),o.decode(s)}({salt:l,iv:u,ciphertext:f},i.value);document.write(e),document.close()}catch(e){h(d),y(c),s.classList.replace("hidden","flex"),sessionStorage.k?sessionStorage.removeItem("k"):p("Wrong password."),i.value="",i.focus()}}w||(p("Please use a modern browser."),i.disabled=!0),c.addEventListener("submit",(async e=>{e.preventDefault(),await m()}));<\/script>\n <style>*,:before,:after{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}::-moz-focus-inner{border-style:none;padding:0}:-moz-focusring{outline:1px dotted ButtonText}:-moz-ui-invalid{box-shadow:none}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a8a29e}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a8a29e}input::placeholder,textarea::placeholder{opacity:1;color:#a8a29e}button,[role=button]{cursor:pointer}:-moz-focusring{outline:auto}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}pre,code,kbd,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-opacity: 1;border-color:rgba(231,229,228,var(--tw-border-opacity))}.fixed{position:fixed}.bottom-0{bottom:0px}.right-0{right:0px}.mx-auto{margin-left:auto;margin-right:auto}.mr-4{margin-right:1rem}.mb-4{margin-bottom:1rem}.mt-4{margin-top:1rem}.flex{display:flex}.table{display:table}.hidden{display:none}.h-screen{height:100vh}.h-\\[10\\.625rem\\]{height:10.625rem}.h-full{height:100%}.h-6{height:1.5rem}.w-full{width:100%}.w-6{width:1.5rem}.max-w-sm{max-width:24rem}.cursor-pointer{cursor:pointer}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-gray-700{--tw-border-opacity: 1;border-color:rgba(68,64,60,var(--tw-border-opacity))}.bg-black{--tw-bg-opacity: 1;background-color:rgba(0,0,0,var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity: 1;background-color:rgba(41,37,36,var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgba(255,255,255,var(--tw-bg-opacity))}.p-4{padding:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.pt-16{padding-top:4rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-light{font-weight:300}.font-extralight{font-weight:200}.font-semibold{font-weight:600}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-white{--tw-text-opacity: 1;color:rgba(255,255,255,var(--tw-text-opacity))}.text-black{--tw-text-opacity: 1;color:rgba(0,0,0,var(--tw-text-opacity))}.text-red-600{--tw-text-opacity: 1;color:rgba(220,38,38,var(--tw-text-opacity))}.loading{pointer-events:none;width:2em;height:2em;border:.15em solid transparent;border-color:#fff;border-right-width:.1em;border-radius:50%;-webkit-animation:spin .5s linear infinite;animation:spin .5s linear infinite}@-webkit-keyframes spin{to{transform:rotate(360deg)}}@keyframes spin{to{transform:rotate(360deg)}}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}@media (min-width: 475px){.xs\\:pt-40{padding-top:10rem}.xs\\:text-base{font-size:1rem;line-height:1.5rem}}</style>\n</head>\r\n<body>\r\n <main class="bg-black w-full h-screen items-start tracking-wide p-4 pt-16 xs:pt-40 font-light text-white">\r\n <div class="max-w-sm w-full bg-gray-800 p-4 rounded-sm mx-auto h-[10.625rem]">\r\n <div id="load" class="flex items-center justify-center h-full">\r\n <p class="loading w-6 h-6 mr-4"></p><p class="text-lg">Loading...</p>\r\n </div>\r\n <header class="hidden gap-2 mb-4 items-center">\r\n <svg id="locked" class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\r\n <path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd"></path>\r\n </svg>\r\n <p id="msg" class="text-sm xs:text-base">This page is password protected.</p>\r\n </header>\r\n <form class="hidden">\r\n <input type="password" id="pwd" name="pwd" aria-label="Password" autofocus class="font-extralight flex w-full py-2 px-4 tracking-wider rounded-sm focus:outline-none border border-gray-700 bg-gray-800" />\r\n <input type="submit" value="Submit" class="text-black w-full py-2 mt-4 cursor-pointer bg-white rounded-sm">\r\n </form>\r\n </div>\r\n <a href="https://github.com/Greenheart/pagecrypt" class="fixed bottom-0 right-0 p-4 text-sm xs:text-base">Created with <span class="font-semibold">PageCrypt</span></a>\r\n </main>\n <!--ENCRYPTED PAYLOAD-->\r\n</body>\r\n</html>';

@@ -115,3 +85,3 @@ // src/core.ts

var name = "pagecrypt";
var version = "5.2.0";
var version = "5.3.0";

@@ -118,0 +88,0 @@ // src/cli.ts

@@ -18,33 +18,3 @@ // src/core.ts

// src/decrypt-template.html
var decrypt_template_default = `<!DOCTYPE html>\r
<html>\r
<head>\r
<meta charset="utf-8">\r
<meta name="viewport" content="width=device-width, initial-scale=1">\r
<meta name="robots" content="noindex, nofollow">
<title>Protected Page</title>\r
<script type="module">var e,t;var n={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},a=function(e,t){return function(e,t,n){var a;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var r=0;r<t.chars.length;++r)t.codes[t.chars[r]]=r}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var o=new(null!=(a=n.out)?a:Uint8Array)(i*t.bits/8|0),s=0,c=0,d=0,l=0;l<i;++l){var u=t.codes[e[l]];if(void 0===u)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|u,(s+=t.bits)>=8&&(s-=8,o[d++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return o}(e,n,t)};const r=document.querySelector.bind(document),[i,o,s,c,d]=["input","header","#msg","form","#load"].map(r);let l,u,w;document.addEventListener("DOMContentLoaded",(async()=>{const e=r("pre").innerText;if(!e)return i.disabled=!0,void v("No encrypted payload.");const t=a(e);if(l=t.slice(0,32),u=t.slice(32,48),w=t.slice(48),location.hash){const e=new URL(window.location.href);i.value=e.hash.slice(1),e.hash="",history.replaceState(null,"",e.toString())}sessionStorage.k||i.value?await p():(y(d),f(c),o.classList.replace("hidden","flex"),i.focus())}));const h=(null==(e=window.crypto)?void 0:e.subtle)||(null==(t=window.crypto)?void 0:t.webkitSubtle);function f(e){e.classList.remove("hidden")}function y(e){e.classList.add("hidden")}function v(e){s.innerText=e,o.classList.add("text-red-600")}async function p(){d.lastElementChild.innerText="Decrypting...",y(o),y(c),f(d),await async function(e){return new Promise((t=>setTimeout(t,e)))}(60);try{const e=await async function({salt:e,iv:t,ciphertext:n},a){const r=new TextDecoder,i=sessionStorage.k?await async function(e){return h.importKey("jwk",e,"AES-GCM",!0,["decrypt"])}(JSON.parse(sessionStorage.k)):await async function(e,t){const n=new TextEncoder,a=await h.importKey("raw",n.encode(t),"PBKDF2",!1,["deriveKey"]);return await h.deriveKey({name:"PBKDF2",salt:e,iterations:2e6,hash:"SHA-256"},a,{name:"AES-GCM",length:256},!0,["decrypt"])}(e,a),o=new Uint8Array(await h.decrypt({name:"AES-GCM",iv:t},i,n));if(!o)throw"Malformed data";return sessionStorage.k=JSON.stringify(await h.exportKey("jwk",i)),r.decode(o)}({salt:l,iv:u,ciphertext:w},i.value);document.write(e),document.close()}catch(e){y(d),f(c),o.classList.replace("hidden","flex"),sessionStorage.k?sessionStorage.removeItem("k"):v("Wrong password."),i.value="",i.focus()}}h||(v("Please use a modern browser."),i.disabled=!0),c.addEventListener("submit",(async e=>{e.preventDefault(),await p()}));<\/script>
<style>/*! tailwindcss v2.2.7 | MIT License | https://tailwindcss.com *//*! modern-normalize v1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */*,::after,::before{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji'}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Consolas,'Liberation Mono',Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}::-moz-focus-inner{border-style:none;padding:0}:-moz-focusring{outline:1px dotted ButtonText}:-moz-ui-invalid{box-shadow:none}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,::after,::before{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a8a29e}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a8a29e}input::placeholder,textarea::placeholder{opacity:1;color:#a8a29e}[role=button],button{cursor:pointer}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::after,::before{--tw-border-opacity:1;border-color:rgba(231,229,228,var(--tw-border-opacity));--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}.fixed{position:fixed}.bottom-0{bottom:0}.right-0{right:0}.mx-auto{margin-left:auto;margin-right:auto}.mr-4{margin-right:1rem}.mb-4{margin-bottom:1rem}.flex{display:flex}.table{display:table}.hidden{display:none}.h-screen{height:100vh}.h-28{height:7rem}.h-full{height:100%}.h-6{height:1.5rem}.w-full{width:100%}.w-6{width:1.5rem}.max-w-sm{max-width:24rem}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-gray-700{--tw-border-opacity:1;border-color:rgba(68,64,60,var(--tw-border-opacity))}.bg-black{--tw-bg-opacity:1;background-color:rgba(0,0,0,var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity:1;background-color:rgba(41,37,36,var(--tw-bg-opacity))}.bg-yellow-200{--tw-bg-opacity:1;background-color:rgba(254,240,138,var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity:1;background-color:rgba(250,250,249,var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity:1;background-color:rgba(231,229,228,var(--tw-bg-opacity))}.p-4{padding:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.pt-40{padding-top:10rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-light{font-weight:300}.font-extralight{font-weight:200}.font-semibold{font-weight:600}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-white{--tw-text-opacity:1;color:rgba(255,255,255,var(--tw-text-opacity))}.text-red-600{--tw-text-opacity:1;color:rgba(220,38,38,var(--tw-text-opacity))}.text-black{--tw-text-opacity:1;color:rgba(0,0,0,var(--tw-text-opacity))}.text-opacity-100{--tw-text-opacity:1}.shadow-2xl{--tw-shadow:0 25px 50px -12px rgba(0, 0, 0, 0.25);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.loading{pointer-events:none;width:2em;height:2em;border:.15em solid transparent;border-color:#fff;border-right-width:.1em;border-radius:50%;-webkit-animation:spin .5s linear infinite;animation:spin .5s linear infinite}@-webkit-keyframes spin{100%{transform:rotate(360deg)}}@keyframes spin{100%{transform:rotate(360deg)}}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}@media (min-width:475px){.xs\\:text-base{font-size:1rem;line-height:1.5rem}}</style>
</head>\r
<body>\r
<main class="bg-black w-full h-screen items-start tracking-wide p-4 pt-40 font-light text-white">\r
<div class="max-w-sm w-full bg-gray-800 p-4 rounded-sm mx-auto h-28">\r
<div id="load" class="flex items-center justify-center h-full">\r
<p class="loading w-6 h-6 mr-4"></p><p class="text-lg">Loading...</p>\r
</div>\r
<header class="hidden gap-2 mb-4 items-center">\r
<svg id="locked" class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\r
<path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd"></path>\r
</svg>\r
<p id="msg" class="text-sm xs:text-base">This page is password protected.</p>\r
</header>\r
<form class="hidden">\r
<input type="password" id="pwd" name="pwd" aria-label="Password" autofocus class="font-extralight flex w-full py-2 px-4 tracking-wider rounded-sm focus:outline-none border border-gray-700 bg-gray-800" />\r
</form>\r
</div>\r
<a href="https://github.com/Greenheart/pagecrypt" class="fixed bottom-0 right-0 p-4">Created with <span class="font-semibold">PageCrypt</span></a>\r
</main>
<!--ENCRYPTED PAYLOAD-->\r
</body>\r
</html>`;
var decrypt_template_default = '<!DOCTYPE html>\r\n<html>\r\n<head>\r\n <meta charset="utf-8">\r\n <meta name="viewport" content="width=device-width, initial-scale=1">\r\n <meta name="robots" content="noindex, nofollow">\n <title>Protected Page</title>\r\n <script type="module">var e,t;var n={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},r=function(e,t){return function(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var s=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),a=0,c=0,d=0,l=0;l<i;++l){var u=t.codes[e[l]];if(void 0===u)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|u,(a+=t.bits)>=8&&(a-=8,s[d++]=255&c>>a)}if(a>=t.bits||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}(e,n,t)};const o=document.querySelector.bind(document),[i,s,a,c,d]=["input","header","#msg","form","#load"].map(o);let l,u,f;document.addEventListener("DOMContentLoaded",(async()=>{const e=o("pre").innerText;if(!e)return i.disabled=!0,void p("No encrypted payload.");const t=r(e);if(l=t.slice(0,32),u=t.slice(32,48),f=t.slice(48),location.hash){const e=new URL(window.location.href);i.value=e.hash.slice(1),e.hash="",history.replaceState(null,"",e.toString())}sessionStorage.k||i.value?await m():(h(d),y(c),s.classList.replace("hidden","flex"),i.focus())}));const w=(null==(e=window.crypto)?void 0:e.subtle)||(null==(t=window.crypto)?void 0:t.webkitSubtle);function y(e){e.classList.remove("hidden")}function h(e){e.classList.add("hidden")}function p(e){a.innerText=e,s.classList.add("text-red-600")}async function m(){d.lastElementChild.innerText="Decrypting...",h(s),h(c),y(d),await async function(e){return new Promise((t=>setTimeout(t,e)))}(60);try{const e=await async function({salt:e,iv:t,ciphertext:n},r){const o=new TextDecoder,i=sessionStorage.k?await async function(e){return w.importKey("jwk",e,"AES-GCM",!0,["decrypt"])}(JSON.parse(sessionStorage.k)):await async function(e,t){const n=new TextEncoder,r=await w.importKey("raw",n.encode(t),"PBKDF2",!1,["deriveKey"]);return await w.deriveKey({name:"PBKDF2",salt:e,iterations:2e6,hash:"SHA-256"},r,{name:"AES-GCM",length:256},!0,["decrypt"])}(e,r),s=new Uint8Array(await w.decrypt({name:"AES-GCM",iv:t},i,n));if(!s)throw"Malformed data";return sessionStorage.k=JSON.stringify(await w.exportKey("jwk",i)),o.decode(s)}({salt:l,iv:u,ciphertext:f},i.value);document.write(e),document.close()}catch(e){h(d),y(c),s.classList.replace("hidden","flex"),sessionStorage.k?sessionStorage.removeItem("k"):p("Wrong password."),i.value="",i.focus()}}w||(p("Please use a modern browser."),i.disabled=!0),c.addEventListener("submit",(async e=>{e.preventDefault(),await m()}));<\/script>\n <style>*,:before,:after{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}::-moz-focus-inner{border-style:none;padding:0}:-moz-focusring{outline:1px dotted ButtonText}:-moz-ui-invalid{box-shadow:none}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a8a29e}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a8a29e}input::placeholder,textarea::placeholder{opacity:1;color:#a8a29e}button,[role=button]{cursor:pointer}:-moz-focusring{outline:auto}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}pre,code,kbd,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-opacity: 1;border-color:rgba(231,229,228,var(--tw-border-opacity))}.fixed{position:fixed}.bottom-0{bottom:0px}.right-0{right:0px}.mx-auto{margin-left:auto;margin-right:auto}.mr-4{margin-right:1rem}.mb-4{margin-bottom:1rem}.mt-4{margin-top:1rem}.flex{display:flex}.table{display:table}.hidden{display:none}.h-screen{height:100vh}.h-\\[10\\.625rem\\]{height:10.625rem}.h-full{height:100%}.h-6{height:1.5rem}.w-full{width:100%}.w-6{width:1.5rem}.max-w-sm{max-width:24rem}.cursor-pointer{cursor:pointer}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-gray-700{--tw-border-opacity: 1;border-color:rgba(68,64,60,var(--tw-border-opacity))}.bg-black{--tw-bg-opacity: 1;background-color:rgba(0,0,0,var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity: 1;background-color:rgba(41,37,36,var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgba(255,255,255,var(--tw-bg-opacity))}.p-4{padding:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.pt-16{padding-top:4rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-light{font-weight:300}.font-extralight{font-weight:200}.font-semibold{font-weight:600}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-white{--tw-text-opacity: 1;color:rgba(255,255,255,var(--tw-text-opacity))}.text-black{--tw-text-opacity: 1;color:rgba(0,0,0,var(--tw-text-opacity))}.text-red-600{--tw-text-opacity: 1;color:rgba(220,38,38,var(--tw-text-opacity))}.loading{pointer-events:none;width:2em;height:2em;border:.15em solid transparent;border-color:#fff;border-right-width:.1em;border-radius:50%;-webkit-animation:spin .5s linear infinite;animation:spin .5s linear infinite}@-webkit-keyframes spin{to{transform:rotate(360deg)}}@keyframes spin{to{transform:rotate(360deg)}}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}@media (min-width: 475px){.xs\\:pt-40{padding-top:10rem}.xs\\:text-base{font-size:1rem;line-height:1.5rem}}</style>\n</head>\r\n<body>\r\n <main class="bg-black w-full h-screen items-start tracking-wide p-4 pt-16 xs:pt-40 font-light text-white">\r\n <div class="max-w-sm w-full bg-gray-800 p-4 rounded-sm mx-auto h-[10.625rem]">\r\n <div id="load" class="flex items-center justify-center h-full">\r\n <p class="loading w-6 h-6 mr-4"></p><p class="text-lg">Loading...</p>\r\n </div>\r\n <header class="hidden gap-2 mb-4 items-center">\r\n <svg id="locked" class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\r\n <path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd"></path>\r\n </svg>\r\n <p id="msg" class="text-sm xs:text-base">This page is password protected.</p>\r\n </header>\r\n <form class="hidden">\r\n <input type="password" id="pwd" name="pwd" aria-label="Password" autofocus class="font-extralight flex w-full py-2 px-4 tracking-wider rounded-sm focus:outline-none border border-gray-700 bg-gray-800" />\r\n <input type="submit" value="Submit" class="text-black w-full py-2 mt-4 cursor-pointer bg-white rounded-sm">\r\n </form>\r\n </div>\r\n <a href="https://github.com/Greenheart/pagecrypt" class="fixed bottom-0 right-0 p-4 text-sm xs:text-base">Created with <span class="font-semibold">PageCrypt</span></a>\r\n </main>\n <!--ENCRYPTED PAYLOAD-->\r\n</body>\r\n</html>';

@@ -51,0 +21,0 @@ // src/core.ts

@@ -22,33 +22,3 @@ // src/index.ts

// src/decrypt-template.html
var decrypt_template_default = `<!DOCTYPE html>\r
<html>\r
<head>\r
<meta charset="utf-8">\r
<meta name="viewport" content="width=device-width, initial-scale=1">\r
<meta name="robots" content="noindex, nofollow">
<title>Protected Page</title>\r
<script type="module">var e,t;var n={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},a=function(e,t){return function(e,t,n){var a;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var r=0;r<t.chars.length;++r)t.codes[t.chars[r]]=r}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var o=new(null!=(a=n.out)?a:Uint8Array)(i*t.bits/8|0),s=0,c=0,d=0,l=0;l<i;++l){var u=t.codes[e[l]];if(void 0===u)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|u,(s+=t.bits)>=8&&(s-=8,o[d++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return o}(e,n,t)};const r=document.querySelector.bind(document),[i,o,s,c,d]=["input","header","#msg","form","#load"].map(r);let l,u,w;document.addEventListener("DOMContentLoaded",(async()=>{const e=r("pre").innerText;if(!e)return i.disabled=!0,void v("No encrypted payload.");const t=a(e);if(l=t.slice(0,32),u=t.slice(32,48),w=t.slice(48),location.hash){const e=new URL(window.location.href);i.value=e.hash.slice(1),e.hash="",history.replaceState(null,"",e.toString())}sessionStorage.k||i.value?await p():(y(d),f(c),o.classList.replace("hidden","flex"),i.focus())}));const h=(null==(e=window.crypto)?void 0:e.subtle)||(null==(t=window.crypto)?void 0:t.webkitSubtle);function f(e){e.classList.remove("hidden")}function y(e){e.classList.add("hidden")}function v(e){s.innerText=e,o.classList.add("text-red-600")}async function p(){d.lastElementChild.innerText="Decrypting...",y(o),y(c),f(d),await async function(e){return new Promise((t=>setTimeout(t,e)))}(60);try{const e=await async function({salt:e,iv:t,ciphertext:n},a){const r=new TextDecoder,i=sessionStorage.k?await async function(e){return h.importKey("jwk",e,"AES-GCM",!0,["decrypt"])}(JSON.parse(sessionStorage.k)):await async function(e,t){const n=new TextEncoder,a=await h.importKey("raw",n.encode(t),"PBKDF2",!1,["deriveKey"]);return await h.deriveKey({name:"PBKDF2",salt:e,iterations:2e6,hash:"SHA-256"},a,{name:"AES-GCM",length:256},!0,["decrypt"])}(e,a),o=new Uint8Array(await h.decrypt({name:"AES-GCM",iv:t},i,n));if(!o)throw"Malformed data";return sessionStorage.k=JSON.stringify(await h.exportKey("jwk",i)),r.decode(o)}({salt:l,iv:u,ciphertext:w},i.value);document.write(e),document.close()}catch(e){y(d),f(c),o.classList.replace("hidden","flex"),sessionStorage.k?sessionStorage.removeItem("k"):v("Wrong password."),i.value="",i.focus()}}h||(v("Please use a modern browser."),i.disabled=!0),c.addEventListener("submit",(async e=>{e.preventDefault(),await p()}));<\/script>
<style>/*! tailwindcss v2.2.7 | MIT License | https://tailwindcss.com *//*! modern-normalize v1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */*,::after,::before{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji'}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Consolas,'Liberation Mono',Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}::-moz-focus-inner{border-style:none;padding:0}:-moz-focusring{outline:1px dotted ButtonText}:-moz-ui-invalid{box-shadow:none}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,::after,::before{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a8a29e}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a8a29e}input::placeholder,textarea::placeholder{opacity:1;color:#a8a29e}[role=button],button{cursor:pointer}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::after,::before{--tw-border-opacity:1;border-color:rgba(231,229,228,var(--tw-border-opacity));--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}.fixed{position:fixed}.bottom-0{bottom:0}.right-0{right:0}.mx-auto{margin-left:auto;margin-right:auto}.mr-4{margin-right:1rem}.mb-4{margin-bottom:1rem}.flex{display:flex}.table{display:table}.hidden{display:none}.h-screen{height:100vh}.h-28{height:7rem}.h-full{height:100%}.h-6{height:1.5rem}.w-full{width:100%}.w-6{width:1.5rem}.max-w-sm{max-width:24rem}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-gray-700{--tw-border-opacity:1;border-color:rgba(68,64,60,var(--tw-border-opacity))}.bg-black{--tw-bg-opacity:1;background-color:rgba(0,0,0,var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity:1;background-color:rgba(41,37,36,var(--tw-bg-opacity))}.bg-yellow-200{--tw-bg-opacity:1;background-color:rgba(254,240,138,var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity:1;background-color:rgba(250,250,249,var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity:1;background-color:rgba(231,229,228,var(--tw-bg-opacity))}.p-4{padding:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.pt-40{padding-top:10rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-light{font-weight:300}.font-extralight{font-weight:200}.font-semibold{font-weight:600}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-white{--tw-text-opacity:1;color:rgba(255,255,255,var(--tw-text-opacity))}.text-red-600{--tw-text-opacity:1;color:rgba(220,38,38,var(--tw-text-opacity))}.text-black{--tw-text-opacity:1;color:rgba(0,0,0,var(--tw-text-opacity))}.text-opacity-100{--tw-text-opacity:1}.shadow-2xl{--tw-shadow:0 25px 50px -12px rgba(0, 0, 0, 0.25);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.loading{pointer-events:none;width:2em;height:2em;border:.15em solid transparent;border-color:#fff;border-right-width:.1em;border-radius:50%;-webkit-animation:spin .5s linear infinite;animation:spin .5s linear infinite}@-webkit-keyframes spin{100%{transform:rotate(360deg)}}@keyframes spin{100%{transform:rotate(360deg)}}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}@media (min-width:475px){.xs\\:text-base{font-size:1rem;line-height:1.5rem}}</style>
</head>\r
<body>\r
<main class="bg-black w-full h-screen items-start tracking-wide p-4 pt-40 font-light text-white">\r
<div class="max-w-sm w-full bg-gray-800 p-4 rounded-sm mx-auto h-28">\r
<div id="load" class="flex items-center justify-center h-full">\r
<p class="loading w-6 h-6 mr-4"></p><p class="text-lg">Loading...</p>\r
</div>\r
<header class="hidden gap-2 mb-4 items-center">\r
<svg id="locked" class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\r
<path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd"></path>\r
</svg>\r
<p id="msg" class="text-sm xs:text-base">This page is password protected.</p>\r
</header>\r
<form class="hidden">\r
<input type="password" id="pwd" name="pwd" aria-label="Password" autofocus class="font-extralight flex w-full py-2 px-4 tracking-wider rounded-sm focus:outline-none border border-gray-700 bg-gray-800" />\r
</form>\r
</div>\r
<a href="https://github.com/Greenheart/pagecrypt" class="fixed bottom-0 right-0 p-4">Created with <span class="font-semibold">PageCrypt</span></a>\r
</main>
<!--ENCRYPTED PAYLOAD-->\r
</body>\r
</html>`;
var decrypt_template_default = '<!DOCTYPE html>\r\n<html>\r\n<head>\r\n <meta charset="utf-8">\r\n <meta name="viewport" content="width=device-width, initial-scale=1">\r\n <meta name="robots" content="noindex, nofollow">\n <title>Protected Page</title>\r\n <script type="module">var e,t;var n={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},r=function(e,t){return function(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var s=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),a=0,c=0,d=0,l=0;l<i;++l){var u=t.codes[e[l]];if(void 0===u)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|u,(a+=t.bits)>=8&&(a-=8,s[d++]=255&c>>a)}if(a>=t.bits||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}(e,n,t)};const o=document.querySelector.bind(document),[i,s,a,c,d]=["input","header","#msg","form","#load"].map(o);let l,u,f;document.addEventListener("DOMContentLoaded",(async()=>{const e=o("pre").innerText;if(!e)return i.disabled=!0,void p("No encrypted payload.");const t=r(e);if(l=t.slice(0,32),u=t.slice(32,48),f=t.slice(48),location.hash){const e=new URL(window.location.href);i.value=e.hash.slice(1),e.hash="",history.replaceState(null,"",e.toString())}sessionStorage.k||i.value?await m():(h(d),y(c),s.classList.replace("hidden","flex"),i.focus())}));const w=(null==(e=window.crypto)?void 0:e.subtle)||(null==(t=window.crypto)?void 0:t.webkitSubtle);function y(e){e.classList.remove("hidden")}function h(e){e.classList.add("hidden")}function p(e){a.innerText=e,s.classList.add("text-red-600")}async function m(){d.lastElementChild.innerText="Decrypting...",h(s),h(c),y(d),await async function(e){return new Promise((t=>setTimeout(t,e)))}(60);try{const e=await async function({salt:e,iv:t,ciphertext:n},r){const o=new TextDecoder,i=sessionStorage.k?await async function(e){return w.importKey("jwk",e,"AES-GCM",!0,["decrypt"])}(JSON.parse(sessionStorage.k)):await async function(e,t){const n=new TextEncoder,r=await w.importKey("raw",n.encode(t),"PBKDF2",!1,["deriveKey"]);return await w.deriveKey({name:"PBKDF2",salt:e,iterations:2e6,hash:"SHA-256"},r,{name:"AES-GCM",length:256},!0,["decrypt"])}(e,r),s=new Uint8Array(await w.decrypt({name:"AES-GCM",iv:t},i,n));if(!s)throw"Malformed data";return sessionStorage.k=JSON.stringify(await w.exportKey("jwk",i)),o.decode(s)}({salt:l,iv:u,ciphertext:f},i.value);document.write(e),document.close()}catch(e){h(d),y(c),s.classList.replace("hidden","flex"),sessionStorage.k?sessionStorage.removeItem("k"):p("Wrong password."),i.value="",i.focus()}}w||(p("Please use a modern browser."),i.disabled=!0),c.addEventListener("submit",(async e=>{e.preventDefault(),await m()}));<\/script>\n <style>*,:before,:after{box-sizing:border-box}html{-moz-tab-size:4;-o-tab-size:4;tab-size:4}html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"}hr{height:0;color:inherit}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}::-moz-focus-inner{border-style:none;padding:0}:-moz-focusring{outline:1px dotted ButtonText}:-moz-ui-invalid{box-shadow:none}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}button{background-color:transparent;background-image:none}fieldset{margin:0;padding:0}ol,ul{list-style:none;margin:0;padding:0}html{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}body{font-family:inherit;line-height:inherit}*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#a8a29e}input:-ms-input-placeholder,textarea:-ms-input-placeholder{opacity:1;color:#a8a29e}input::placeholder,textarea::placeholder{opacity:1;color:#a8a29e}button,[role=button]{cursor:pointer}:-moz-focusring{outline:auto}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}pre,code,kbd,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-opacity: 1;border-color:rgba(231,229,228,var(--tw-border-opacity))}.fixed{position:fixed}.bottom-0{bottom:0px}.right-0{right:0px}.mx-auto{margin-left:auto;margin-right:auto}.mr-4{margin-right:1rem}.mb-4{margin-bottom:1rem}.mt-4{margin-top:1rem}.flex{display:flex}.table{display:table}.hidden{display:none}.h-screen{height:100vh}.h-\\[10\\.625rem\\]{height:10.625rem}.h-full{height:100%}.h-6{height:1.5rem}.w-full{width:100%}.w-6{width:1.5rem}.max-w-sm{max-width:24rem}.cursor-pointer{cursor:pointer}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-gray-700{--tw-border-opacity: 1;border-color:rgba(68,64,60,var(--tw-border-opacity))}.bg-black{--tw-bg-opacity: 1;background-color:rgba(0,0,0,var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity: 1;background-color:rgba(41,37,36,var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity: 1;background-color:rgba(255,255,255,var(--tw-bg-opacity))}.p-4{padding:1rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.pt-16{padding-top:4rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-light{font-weight:300}.font-extralight{font-weight:200}.font-semibold{font-weight:600}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-white{--tw-text-opacity: 1;color:rgba(255,255,255,var(--tw-text-opacity))}.text-black{--tw-text-opacity: 1;color:rgba(0,0,0,var(--tw-text-opacity))}.text-red-600{--tw-text-opacity: 1;color:rgba(220,38,38,var(--tw-text-opacity))}.loading{pointer-events:none;width:2em;height:2em;border:.15em solid transparent;border-color:#fff;border-right-width:.1em;border-radius:50%;-webkit-animation:spin .5s linear infinite;animation:spin .5s linear infinite}@-webkit-keyframes spin{to{transform:rotate(360deg)}}@keyframes spin{to{transform:rotate(360deg)}}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}@media (min-width: 475px){.xs\\:pt-40{padding-top:10rem}.xs\\:text-base{font-size:1rem;line-height:1.5rem}}</style>\n</head>\r\n<body>\r\n <main class="bg-black w-full h-screen items-start tracking-wide p-4 pt-16 xs:pt-40 font-light text-white">\r\n <div class="max-w-sm w-full bg-gray-800 p-4 rounded-sm mx-auto h-[10.625rem]">\r\n <div id="load" class="flex items-center justify-center h-full">\r\n <p class="loading w-6 h-6 mr-4"></p><p class="text-lg">Loading...</p>\r\n </div>\r\n <header class="hidden gap-2 mb-4 items-center">\r\n <svg id="locked" class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\r\n <path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd"></path>\r\n </svg>\r\n <p id="msg" class="text-sm xs:text-base">This page is password protected.</p>\r\n </header>\r\n <form class="hidden">\r\n <input type="password" id="pwd" name="pwd" aria-label="Password" autofocus class="font-extralight flex w-full py-2 px-4 tracking-wider rounded-sm focus:outline-none border border-gray-700 bg-gray-800" />\r\n <input type="submit" value="Submit" class="text-black w-full py-2 mt-4 cursor-pointer bg-white rounded-sm">\r\n </form>\r\n </div>\r\n <a href="https://github.com/Greenheart/pagecrypt" class="fixed bottom-0 right-0 p-4 text-sm xs:text-base">Created with <span class="font-semibold">PageCrypt</span></a>\r\n </main>\n <!--ENCRYPTED PAYLOAD-->\r\n</body>\r\n</html>';

@@ -55,0 +25,0 @@ // src/core.ts

{
"name": "pagecrypt",
"version": "5.2.0",
"version": "5.3.0",
"description": "Easily add client-side password-protection to your Single Page Applications and HTML files.",

@@ -5,0 +5,0 @@ "main": "./index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc