Files
inzerosight/dist/web/assets/index-DlLeEfTp.js

5 lines
15 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))p(l);new MutationObserver(l=>{for(const f of l)if(f.type==="childList")for(const s of f.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&p(s)}).observe(document,{childList:!0,subtree:!0});function i(l){const f={};return l.integrity&&(f.integrity=l.integrity),l.referrerPolicy&&(f.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?f.credentials="include":l.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function p(l){if(l.ep)return;l.ep=!0;const f=i(l);fetch(l.href,f)}})();const w={3:{unifier:"­",0:"",1:"",2:""},6:{unifier:"",0:"",1:"",2:"­",3:"",4:"",5:""},7:{unifier:"",0:"",1:"",2:"­",3:"",4:"",5:"",6:"\uFEFF"},encodeString:(e,t=7)=>Array.from(e,i=>(+t==7?be(i):i.codePointAt(0)).toString(t).split("").map(p=>w[t][p]).join("")).join(w[t].unifier),encodeNumberArray:(e,t=7)=>e.map(i=>i.toString(t).split("").map(p=>w[t][p]).join("")).join(w[t].unifier),decodeToString:(e,t=7)=>w.decodeToNumberArray(e,t).map(i=>String.fromCodePoint(+t==7?ye(i):i)).join(""),decodeToNumberArray:(e,t=7)=>e.split(w[t].unifier).map(i=>Array.from(i).map(p=>Object.keys(w[t]).find(l=>w[t][l]===p)).join("")).filter(Boolean).map(i=>parseInt(i,t))},pe="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",J=[...new Set([...pe,...Array.from({length:95},(e,t)=>String.fromCharCode(t+32))])],he=new Map(J.map((e,t)=>[e,t])),be=e=>he.get(e)??(e.codePointAt(0)<32?e.codePointAt(0)+95:e.codePointAt(0)),ye=e=>e<95?J[e].codePointAt(0):e<127?e-95:e,Q=65536;function ee(e,t,i){const p=[];for(let l=0;l<e.length;){let f=Math.min(l+Q,e.length);typeof e=="string"&&f<e.length&&e.charCodeAt(f-1)>=55296&&e.charCodeAt(f-1)<=56319&&f--,p.push(w[i](e.slice(l,f),t)),l=f}return p.join(w[t].unifier)}function te(e,t,i){const p=[],l=w[t].unifier;for(let f=0;f<e.length;){let s=Math.min(f+Q,e.length);if(s<e.length){const n=e.lastIndexOf(l,s-1);s=n>=f?n+1:e.indexOf(l,s)+1||e.length}p.push(w[i](e.slice(f,s),t)),f=s}return i==="decodeToString"?p.join(""):p.flat()}const me=(e,t)=>ee(e,t,"encodeString"),M=(e,t)=>ee(e,t,"encodeNumberArray"),Ae=(e,t)=>te(e,t,"decodeToString"),v=(e,t)=>te(e,t,"decodeToNumberArray");function we(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var P,G;function Ie(){if(G)return P;G=1;function e(t={}){const i=t.bits||16,p=t.rounds||22,l=t.rightRotations||7,f=t.leftRotations||2,s=2**i,n=s-1,u=(a,o)=>a>>o|a<<i-o&n,y=(a,o)=>a<<o&n|a>>i-o,A=(a,o,r)=>(a=u(a,l),a=a+o&n,a^=r,o=y(o,f),o^=a,[a,o]),I=(a,o,r)=>(o^=a,o=u(o,f),a^=r,a=a-o&n,a=y(a,l),[a,o]);function S(a,o){let r=a[0],d=a[1],c=o[0],h=o.slice(1);[d,r]=A(d,r,c);for(let b=0;b<p-1;b++){const m=b%h.length;[h[m],c]=A(h[m],c,b),[d,r]=A(d,r,c)}return[r,d]}function E(a,o){let r=a[0],d=a[1],c=o[0],h=o.slice(1);for(let b=0;b<p-1;b++){const m=b%h.length;[h[m],c]=A(h[m],c,b)}for(let b=0;b<p;b++){const m=(p-2-b)%h.length;[d,r]=I(d,r,c),[h[m],c]=I(h[m],c,p-2-b)}return[r,d]}function g(a){return(o,r)=>{const d=a([o/s|0,o&n],r);return d[0]*s+d[1]}}return{encrypt:g(S),decrypt:g(E),encryptRaw:S,decryptRaw:E}}return P=e,P}var Se=Ie();const ne=we(Se);var R,$;function re(){if($)return R;$=1;const e="Input must be an string, Buffer or Uint8Array";function t(s){let n;if(s instanceof Uint8Array)n=s;else if(typeof s=="string")n=new TextEncoder().encode(s);else throw new Error(e);return n}function i(s){return Array.prototype.map.call(s,function(n){return(n<16?"0":"")+n.toString(16)}).join("")}function p(s){return(4294967296+s).toString(16).substring(1)}function l(s,n,u){let y=`
`+s+" = ";for(let A=0;A<n.length;A+=2){if(u===32)y+=p(n[A]).toUpperCase(),y+=" ",y+=p(n[A+1]).toUpperCase();else if(u===64)y+=p(n[A+1]).toUpperCase(),y+=p(n[A]).toUpperCase();else throw new Error("Invalid size "+u);A%6===4?y+=`
`+new Array(s.length+4).join(" "):A<n.length-2&&(y+=" ")}console.log(y)}function f(s,n,u){let y=new Date().getTime();const A=new Uint8Array(n);for(let S=0;S<n;S++)A[S]=S%256;const I=new Date().getTime();console.log("Generated random input in "+(I-y)+"ms"),y=I;for(let S=0;S<u;S++){const E=s(A),g=new Date().getTime(),a=g-y;y=g,console.log("Hashed in "+a+"ms: "+E.substring(0,20)+"..."),console.log(Math.round(n/(1<<20)/(a/1e3)*100)/100+" MB PER SECOND")}}return R={normalizeInput:t,toHex:i,debugPrint:l,testSpeed:f},R}var F,K;function Ee(){if(K)return F;K=1;const e=re();function t(r,d,c){const h=r[d]+r[c];let b=r[d+1]+r[c+1];h>=4294967296&&b++,r[d]=h,r[d+1]=b}function i(r,d,c,h){let b=r[d]+c;c<0&&(b+=4294967296);let m=r[d+1]+h;b>=4294967296&&m++,r[d]=b,r[d+1]=m}function p(r,d){return r[d]^r[d+1]<<8^r[d+2]<<16^r[d+3]<<24}function l(r,d,c,h,b,m){const ue=y[b],fe=y[b+1],de=y[m],ge=y[m+1];t(u,r,d),i(u,r,ue,fe);let k=u[h]^u[r],C=u[h+1]^u[r+1];u[h]=C,u[h+1]=k,t(u,c,h),k=u[d]^u[c],C=u[d+1]^u[c+1],u[d]=k>>>24^C<<8,u[d+1]=C>>>24^k<<8,t(u,r,d),i(u,r,de,ge),k=u[h]^u[r],C=u[h+1]^u[r+1],u[h]=k>>>16^C<<16,u[h+1]=C>>>16^k<<16,t(u,c,h),k=u[d]^u[c],C=u[d+1]^u[c+1],u[d]=C>>>31^k<<1,u[d+1]=k>>>31^C<<1}const f=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],n=new Uint8Array(s.map(function(r){return r*2})),u=new Uint32Array(32),y=new Uint32Array(32);function A(r,d){let c=0;for(c=0;c<16;c++)u[c]=r.h[c],u[c+16]=f[c];for(u[24]=u[24]^r.t,u[25]=u[25]^r.t/4294967296,d&&(u[28]=~u[28],u[29]=~u[29]),c=0;c<32;c++)y[c]=p(r.b,4*c);for(c=0;c<12;c++)l(0,8,16,24,n[c*16+0],n[c*16+1]),l(2,10,18,26,n[c*16+2],n[c*16+3]),l(4,12,20,28,n[c*16+4],n[c*16+5]),l(6,14,22,30,n[c*16+6],n[c*16+7]),l(0,10,20,30,n[c*16+8],n[c*16+9]),l(2,12,22,24,n[c*16+10],n[c*16+11]),l(4,14,16,26,n[c*16+12],n[c*16+13]),l(6,8,18,28,n[c*16+14],n[c*16+15]);for(c=0;c<16;c++)r.h[c]=r.h[c]^u[c]^u[c+16]}const I=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function S(r,d,c,h){if(r===0||r>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(d&&d.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(c&&c.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(h&&h.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const b={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:r};I.fill(0),I[0]=r,d&&(I[1]=d.length),I[2]=1,I[3]=1,c&&I.set(c,32),h&&I.set(h,48);for(let m=0;m<16;m++)b.h[m]=f[m]^p(I,m*4);return d&&(E(b,d),b.c=128),b}function E(r,d){for(let c=0;c<d.length;c++)r.c===128&&(r.t+=r.c,A(r,!1),r.c=0),r.b[r.c++]=d[c]}function g(r){for(r.t+=r.c;r.c<128;)r.b[r.c++]=0;A(r,!0);const d=new Uint8Array(r.outlen);for(let c=0;c<r.outlen;c++)d[c]=r.h[c>>2]>>8*(c&3);return d}function a(r,d,c,h,b){c=c||64,r=e.normalizeInput(r),h&&(h=e.normalizeInput(h)),b&&(b=e.normalizeInput(b));const m=S(c,d,h,b);return E(m,r),g(m)}function o(r,d,c,h,b){const m=a(r,d,c,h,b);return e.toHex(m)}return F={blake2b:a,blake2bHex:o,blake2bInit:S,blake2bUpdate:E,blake2bFinal:g},F}var D,q;function ke(){if(q)return D;q=1;const e=re();function t(g,a){return g[a]^g[a+1]<<8^g[a+2]<<16^g[a+3]<<24}function i(g,a,o,r,d,c){s[g]=s[g]+s[a]+d,s[r]=p(s[r]^s[g],16),s[o]=s[o]+s[r],s[a]=p(s[a]^s[o],12),s[g]=s[g]+s[a]+c,s[r]=p(s[r]^s[g],8),s[o]=s[o]+s[r],s[a]=p(s[a]^s[o],7)}function p(g,a){return g>>>a^g<<32-a}const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),f=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),s=new Uint32Array(16),n=new Uint32Array(16);function u(g,a){let o=0;for(o=0;o<8;o++)s[o]=g.h[o],s[o+8]=l[o];for(s[12]^=g.t,s[13]^=g.t/4294967296,a&&(s[14]=~s[14]),o=0;o<16;o++)n[o]=t(g.b,4*o);for(o=0;o<10;o++)i(0,4,8,12,n[f[o*16+0]],n[f[o*16+1]]),i(1,5,9,13,n[f[o*16+2]],n[f[o*16+3]]),i(2,6,10,14,n[f[o*16+4]],n[f[o*16+5]]),i(3,7,11,15,n[f[o*16+6]],n[f[o*16+7]]),i(0,5,10,15,n[f[o*16+8]],n[f[o*16+9]]),i(1,6,11,12,n[f[o*16+10]],n[f[o*16+11]]),i(2,7,8,13,n[f[o*16+12]],n[f[o*16+13]]),i(3,4,9,14,n[f[o*16+14]],n[f[o*16+15]]);for(o=0;o<8;o++)g.h[o]^=s[o]^s[o+8]}function y(g,a){if(!(g>0&&g<=32))throw new Error("Incorrect output length, should be in [1, 32]");const o=a?a.length:0;if(a&&!(o>0&&o<=32))throw new Error("Incorrect key length, should be in [1, 32]");const r={h:new Uint32Array(l),b:new Uint8Array(64),c:0,t:0,outlen:g};return r.h[0]^=16842752^o<<8^g,o>0&&(A(r,a),r.c=64),r}function A(g,a){for(let o=0;o<a.length;o++)g.c===64&&(g.t+=g.c,u(g,!1),g.c=0),g.b[g.c++]=a[o]}function I(g){for(g.t+=g.c;g.c<64;)g.b[g.c++]=0;u(g,!0);const a=new Uint8Array(g.outlen);for(let o=0;o<g.outlen;o++)a[o]=g.h[o>>2]>>8*(o&3)&255;return a}function S(g,a,o){o=o||32,g=e.normalizeInput(g);const r=y(o,a);return A(r,g),I(r)}function E(g,a,o){const r=S(g,a,o);return e.toHex(r)}return D={blake2s:S,blake2sHex:E,blake2sInit:y,blake2sUpdate:A,blake2sFinal:I},D}var O,z;function Ce(){if(z)return O;z=1;const e=Ee(),t=ke();return O={blake2b:e.blake2b,blake2bHex:e.blake2bHex,blake2bInit:e.blake2bInit,blake2bUpdate:e.blake2bUpdate,blake2bFinal:e.blake2bFinal,blake2s:t.blake2s,blake2sHex:t.blake2sHex,blake2sInit:t.blake2sInit,blake2sUpdate:t.blake2sUpdate,blake2sFinal:t.blake2sFinal},O}var oe=Ce();const ie=ne({bits:24,rounds:23,rightRotations:8,leftRotations:3});function W(e){const t=oe.blake2bHex(e,null,12);return[parseInt(t.slice(0,6),16),parseInt(t.slice(6,12),16),parseInt(t.slice(12,18),16),parseInt(t.slice(18,24),16)]}function Be(e,t){const i=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]&16777215,p=Array.from(e,(l,f)=>{const s=i*16777216+(f&16777215),n=ie.encrypt(s,t);return(l.codePointAt(0)^n)>>>0});return[i,...p]}function Ue(e,t){if(!e||e.length===0)return"";const i=e[0];return e.slice(1).map((l,f)=>{const s=i*16777216+(f&16777215),n=ie.encrypt(s,t),u=(l^n)>>>0;try{return String.fromCodePoint(u)}catch{return""}}).join("")}const ce=ne();function Y(e){const t=oe.blake2bHex(e,null,8);return[parseInt(t.slice(0,4),16),parseInt(t.slice(4,8),16),parseInt(t.slice(8,12),16),parseInt(t.slice(12,16),16)]}function Te(e,t){return Array.from(e,i=>ce.encrypt(i.codePointAt(0),t))}function Pe(e,t){return e.map(i=>{try{return String.fromCodePoint(ce.decrypt(i,t))}catch{return""}}).join("")}const Z="­",N={3:"­",6:"­",7:"­"},_={0:"PLAIN",1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(_).map(([e,t])=>[t,+e]));const se=Object.entries(N).flatMap(([e,t])=>Object.entries(_).map(([i,p])=>{const l=(+i).toString(e).padStart(4,"0");if(l.length!==4)throw new RangeError(`Cipher ID ${i} exceeds ZWUS-${e}'s signature capacity`);const f=t+w[e].unifier+w[e][0]+Array.from(l,s=>w[e][s]).join("");if(f.length!==11)throw new RangeError("Signatures must contain exactly 11 characters");return{base:e,cipher:p,sig:f,legacy:!1}}));function Re(e,t){const i=se.find(p=>p.base===String(e)&&p.cipher===t);if(!i)throw new RangeError(`Unsupported signature: ZWUS-${e}, ${t}`);return i.sig}function le(e,t){let i=e.indexOf(Z);for(;i!==-1;){const p=t.find(l=>e.startsWith(l.sig,i)&&(!l.legacyPlain||e[i+l.sig.length]!==w[l.base].unifier));if(p){const{base:l,cipher:f,sig:s,legacy:n}=p;return{base:l,cipher:f,payload:e.slice(i+s.length),sigIdx:i,sigLen:s.length,legacy:n}}i=e.indexOf(Z,i+1)}return null}const Fe=e=>le(e,se),De=[3,6,7].flatMap(e=>[...[1,2].map(t=>({base:String(e),cipher:_[t],legacy:!0,sig:N[e]+w[e].unifier+w[e][0].repeat(3)+w[e][t]})),{base:String(e),cipher:"PLAIN",sig:N[e],legacy:!0,legacyPlain:!0}]),Oe=e=>le(e,De);function xe(e){const t=Fe(e),i=Oe(e);return!t||i&&i.sigIdx<t.sigIdx&&Ne(e,i.base,i.sigIdx+i.sigLen)<t.sigIdx?i:t}function Ne(e,t,i){const p=new Set(Object.values(w[t]));let l=i;for(;l<e.length&&p.has(e[l]);)l++;return l}const B=document.getElementById("textarea"),j=document.getElementById("encoder"),L=document.getElementById("cipher"),H=document.getElementById("sign"),T=document.getElementById("sigDetect"),U=document.getElementById("notice"),je=["encodeButton","decodeButton"].map(e=>document.getElementById(e)),V=[...je,j,L,H];document.getElementById("encodeButton").addEventListener("click",ae);document.getElementById("decodeButton").addEventListener("click",ae);H.addEventListener("click",e=>e.target.classList.toggle("on"));let X,x=!1;async function ae(e){if(x)return;if(clearTimeout(X),T.className="",B.value===""){B.value="The text box is empty.";return}const t=e.target.id==="encodeButton"?"NO":"YES";let i=Le(),p=j.value.split("-")[1],l=B.value;if(t==="YES"){const n=xe(l);if(n){if(n.base!==p||n.cipher&&n.cipher!==i){const u=n.cipher&&n.cipher!=="PLAIN"?` (${n.cipher})`:"";T.textContent=`ZWUS-${n.base}${u} signature detected`,T.className="show",X=setTimeout(()=>T.className="",2e3)}p=n.base,j.value="ZWUS-"+p,n.cipher&&(i=n.cipher,L.value=i),l=l.slice(0,n.sigIdx)+n.payload}}const f=i!=="PLAIN",s=f&&prompt("enter password.");if(!(f&&!s)){x=!0,V.forEach(n=>n.disabled=!0),U.textContent="Processing…";try{let n=await He[t][i](l,p,s);if(t==="NO"&&H.classList.contains("on")&&(n=Re(p,i)+n),B.value=n,t==="NO"){U.textContent="Copying…";const u=await _e(n);u&&n.length<=65536&&(B.value=`Copied to your clipboard.
A copy has been placed between these brackets [`+n+"]"),U.textContent=u?`Copied ${n.length.toLocaleString()} characters.`:"Copy failed. The encoded text is in the box; select and copy it manually."}else U.textContent=`Decoded ${n.length.toLocaleString()} characters.`}catch(n){console.error(n),U.textContent=`Could not ${t==="NO"?"encode":"decode"}: ${n.message}`}finally{x=!1,V.forEach(n=>n.disabled=!1)}}}async function _e(e){var t;if((t=navigator.clipboard)!=null&&t.writeText){let i;try{return await Promise.race([navigator.clipboard.writeText(e),new Promise((p,l)=>i=setTimeout(()=>l(new Error("Copy timed out")),5e3))]),!0}catch(p){console.warn("Clipboard copy failed",p)}finally{clearTimeout(i)}}if(e.length>65536)return!1;B.select();try{return document.execCommand("copy")}catch(i){return console.warn("Clipboard copy failed",i),!1}}function Le(){return L.value}const He={NO:{PLAIN:(e,t)=>me(e,t),SPECK48_96CTR:(e,t,i)=>M(Be(e,W(i)),t),"SPECK32_64ECB (insecure)":(e,t,i)=>M(Te(e,Y(i)),t)},YES:{PLAIN:(e,t)=>Ae(e,t),SPECK48_96CTR:async(e,t,i)=>Ue(await v(e,t),W(i)),"SPECK32_64ECB (insecure)":async(e,t,i)=>Pe(await v(e,t),Y(i))}};