diff --git a/BUILD.md b/BUILD.md deleted file mode 100644 index a88e083..0000000 --- a/BUILD.md +++ /dev/null @@ -1,18 +0,0 @@ -# Building inØsight - -## Prerequisites -- Node.js (v20+ or v22+) -- npm (v10+) - -## Step-by-Step Build Instructions -1. Install dependencies: - ```bash - npm ci - ``` - -2. Build the Firefox extension: - ```bash - npm run build:firefox - ``` - -3. The generated add-on files will be in `dist/firefox/`. diff --git a/content.js b/content.js index 63f692b..9831f31 100644 --- a/content.js +++ b/content.js @@ -199,41 +199,44 @@ function onAction(entry, parsed) { } } -function getPayloadRange(node, base, start) { - let endNode = node; - let end = getPayloadEnd(node.nodeValue, base, start); - - // Gmail inserts elements into long zero-width runs, splitting one payload across text nodes. - while (end === endNode.nodeValue.length) { - let next = endNode.nextSibling; - let hasWbr = false; - while (next?.nodeType === Node.ELEMENT_NODE && next.tagName === 'WBR') { - hasWbr = true; - next = next.nextSibling; - } - if (!hasWbr || next?.nodeType !== Node.TEXT_NODE) break; - const nextEnd = getPayloadEnd(next.nodeValue, base, 0); - if (!nextEnd) break; - endNode = next; - end = nextEnd; +function acrossWbr(node, side) { + let sibling = node[side], hasWbr = false; + while (sibling?.nodeType === Node.ELEMENT_NODE && sibling.tagName === 'WBR') { + hasWbr = true; + sibling = sibling[side]; } - return { endNode, end }; + return hasWbr && sibling?.nodeType === Node.TEXT_NODE ? sibling : null; } function scanNode(node) { if (!node || node.nodeType !== Node.TEXT_NODE) return; - const val = node.nodeValue; + for (let prev; (prev = acrossWbr(node, 'previousSibling'));) node = prev; + const nodes = [node]; + let val = node.nodeValue; + for (let next; (next = acrossWbr(nodes.at(-1), 'nextSibling'));) { + nodes.push(next); + val += next.nodeValue; + } if (!val || !val.includes(SIG_PREFIX)) return; + const point = (offset, atEnd) => { + for (const current of nodes) { + if (offset < current.nodeValue.length || (atEnd && offset === current.nodeValue.length)) + return { node: current, offset }; + offset -= current.nodeValue.length; + } + return { node: nodes.at(-1), offset: nodes.at(-1).nodeValue.length }; + }; + let idx = 0; while (idx < val.length) { - const sub = val.slice(idx); - const p = parseSig(sub); + const p = parseSig(val.slice(idx)); if (!p) break; const start = idx + p.sigIdx; - const { endNode, end } = getPayloadRange(node, p.base, start + p.sigLen); - createOverlay(node, p, start, endNode, end); - idx = endNode === node ? end + 1 : val.length; + const end = getPayloadEnd(val, p.base, start + p.sigLen); + const from = point(start, false), to = point(end, true); + createOverlay(from.node, p, from.offset, to.node, to.offset); + idx = end + 1; } } @@ -244,7 +247,7 @@ function scanTree(root) { acceptNode: n => (ign[n.parentElement?.tagName] ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT) }); let n; - while ((n = walker.nextNode())) scanNode(n); + while ((n = walker.nextNode())) if (!acrossWbr(n, 'previousSibling')) scanNode(n); } scanTree(document.body); @@ -260,7 +263,10 @@ function scheduleUpdate() { const obs = new MutationObserver(muts => { for (const e of [...active]) { - if (!e.node.isConnected || !e.node.nodeValue?.startsWith(SIG_PREFIX, e.start)) { + let prefix = e.node.nodeValue?.slice(e.start) || ''; + for (let next = e.node; prefix.length < SIG_PREFIX.length && + (next = acrossWbr(next, 'nextSibling'));) prefix += next.nodeValue; + if (!e.node.isConnected || !prefix.startsWith(SIG_PREFIX)) { e.wrap.remove(); active.delete(e); } @@ -269,7 +275,10 @@ const obs = new MutationObserver(muts => { if (m.type === 'characterData') scanNode(m.target); else for (const an of m.addedNodes) { if (an.nodeType === Node.TEXT_NODE) scanNode(an); - else if (an.nodeType === Node.ELEMENT_NODE && an.id !== 'in0-host') scanTree(an); + else if (an.nodeType === Node.ELEMENT_NODE && an.tagName === 'WBR') { + scanNode(an.previousSibling); + scanNode(an.nextSibling); + } else if (an.nodeType === Node.ELEMENT_NODE && an.id !== 'in0-host') scanTree(an); } } scheduleUpdate(); diff --git a/content.test.js b/content.test.js new file mode 100644 index 0000000..6819872 --- /dev/null +++ b/content.test.js @@ -0,0 +1,89 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import zwus from 'zwus'; +import { makeSig } from './sig.js'; + +test('page overlay detects headers split by WBR and decodes across the split', async () => { + const buttons = [], inserted = [], fixtures = [], texts = []; + const rect = { top: 10, bottom: 20, left: 10, right: 20, width: 10, height: 10 }; + const body = { tagName: 'BODY', appendChild() {} }; + const parent = { tagName: 'DIV', parentElement: body, getBoundingClientRect: () => rect }; + let observer; + + const element = tag => ({ + tagName: tag.toUpperCase(), nodeType: 1, style: {}, offsetWidth: 0, offsetHeight: 0, + appendChild(child) { child.parentElement = this; }, + attachShadow() { return element('shadow'); }, + getBoundingClientRect: () => rect, + remove() { this.removed = true; } + }); + const addRun = (encoded, cut, cipher) => { + const parts = [encoded.slice(0, cut), encoded.slice(cut, 13), encoded.slice(13)]; + const nodes = parts.flatMap((part, i) => i ? [element('wbr'), { + nodeType: 3, nodeValue: part, parentElement: parent, isConnected: true + }] : [{ nodeType: 3, nodeValue: part, parentElement: parent, isConnected: true }]); + nodes.forEach((node, i) => { + node.previousSibling = nodes[i - 1] || null; + node.nextSibling = nodes[i + 1] || null; + if (node.nodeType === 3) texts.push(node); + }); + fixtures.push({ nodes, cipher }); + }; + + for (const base of [3, 6, 7]) for (const cipher of + ['PLAIN', 'SPECK48_96CTR', 'SPECK32_64ECB (insecure)']) { + const payload = cipher === 'PLAIN' ? zwus.encodeString('hello', base) : + zwus.encodeNumberArray([1, 2, 3], base); + for (const cut of [1, 2, 3, 5, 6, 10]) addRun(makeSig(base, cipher) + payload, cut, cipher); + } + + globalThis.Node = { ELEMENT_NODE: 1, TEXT_NODE: 3 }; + globalThis.NodeFilter = { SHOW_TEXT: 4, FILTER_ACCEPT: 1, FILTER_REJECT: 2 }; + globalThis.document = { + body, documentElement: body, + createElement(tag) { const node = element(tag); if (tag === 'button') buttons.push(node); return node; }, + createTreeWalker() { + let i = 0; + return { nextNode: () => texts[i++] || null }; + }, + createRange() { + return { + setStart(node, offset) { this.startNode = node; this.start = offset; }, + setEnd(node, offset) { this.endNode = node; this.end = offset; }, + getBoundingClientRect: () => rect, + toString() { + let value = '', node = this.startNode; + while (node) { + if (node.nodeType === 3) value += node.nodeValue.slice( + node === this.startNode ? this.start : 0, + node === this.endNode ? this.end : undefined + ); + if (node === this.endNode) break; + node = node.nextSibling; + } + return value; + }, + deleteContents() {}, + insertNode(node) { inserted.push(node); } + }; + } + }; + globalThis.window = { + innerHeight: 100, innerWidth: 100, addEventListener() {}, + getComputedStyle: () => ({ overflow: 'visible', overflowX: 'visible', overflowY: 'visible' }) + }; + globalThis.MutationObserver = class { + constructor(callback) { this.callback = callback; observer = this; } + observe() {} + }; + globalThis.requestAnimationFrame = callback => { callback(); return 1; }; + + await import('./content.js'); + assert.equal(buttons.length, fixtures.length); + fixtures.forEach(({ cipher }, i) => + assert.equal(buttons[i].textContent, cipher === 'PLAIN' ? 'Decode' : 'Decrypt')); + observer.callback([{ type: 'childList', addedNodes: [] }]); + assert.equal(buttons.some(button => button.parentElement.removed), false); + buttons[0].onclick(); + assert.equal(inserted[0].textContent, ' hello '); +}); diff --git a/dist/chrome/content.js b/dist/chrome/content.js index 6f63110..c165703 100644 --- a/dist/chrome/content.js +++ b/dist/chrome/content.js @@ -1,6 +1,6 @@ -(function(){"use strict";const A={3:{unifier:"­",0:"᠎",1:"​",2:"‍"},6:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎"},7:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎",6:"\uFEFF"},encodeString:(n,e=7)=>Array.from(n,l=>(+e==7?ee(l):l.codePointAt(0)).toString(e).split("").map(p=>A[e][p]).join("")).join(A[e].unifier),encodeNumberArray:(n,e=7)=>n.map(l=>l.toString(e).split("").map(p=>A[e][p]).join("")).join(A[e].unifier),decodeToString:(n,e=7)=>A.decodeToNumberArray(n,e).map(l=>String.fromCodePoint(+e==7?te(l):l)).join(""),decodeToNumberArray:(n,e=7)=>n.split(A[e].unifier).map(l=>Array.from(l).map(p=>Object.keys(A[e]).find(b=>A[e][b]===p)).join("")).filter(Boolean).map(l=>parseInt(l,e))},Q="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",H=[...new Set([...Q,...Array.from({length:95},(n,e)=>String.fromCharCode(e+32))])],Z=new Map(H.map((n,e)=>[n,e])),ee=n=>Z.get(n)??(n.codePointAt(0)<32?n.codePointAt(0)+95:n.codePointAt(0)),te=n=>n<95?H[n].codePointAt(0):n<127?n-95:n;function ne(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var D,L;function oe(){if(L)return D;L=1;function n(e={}){const l=e.bits||16,p=e.rounds||22,b=e.rightRotations||7,d=e.leftRotations||2,c=2**l,i=c-1,s=(a,o)=>a>>o|a<a<>l-o,g=(a,o,t)=>(a=s(a,b),a=a+o&i,a^=t,o=h(o,d),o^=a,[a,o]),y=(a,o,t)=>(o^=a,o=s(o,d),a^=t,a=a-o&i,a=h(a,b),[a,o]);function k(a,o){let t=a[0],u=a[1],r=o[0],m=o.slice(1);[u,t]=g(u,t,r);for(let w=0;w{const u=a([o/c|0,o&i],t);return u[0]*c+u[1]}}return{encrypt:f(k),decrypt:f(I),encryptRaw:k,decryptRaw:I}}return D=n,D}var re=oe();const M=ne(re);var U,z;function G(){if(z)return U;z=1;const n="Input must be an string, Buffer or Uint8Array";function e(c){let i;if(c instanceof Uint8Array)i=c;else if(typeof c=="string")i=new TextEncoder().encode(c);else throw new Error(n);return i}function l(c){return Array.prototype.map.call(c,function(i){return(i<16?"0":"")+i.toString(16)}).join("")}function p(c){return(4294967296+c).toString(16).substring(1)}function b(c,i,s){let h=` -`+c+" = ";for(let g=0;g=4294967296&&w++,t[u]=m,t[u+1]=w}function l(t,u,r,m){let w=t[u]+r;r<0&&(w+=4294967296);let E=t[u+1]+m;w>=4294967296&&E++,t[u]=w,t[u+1]=E}function p(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function b(t,u,r,m,w,E){const ye=h[w],Ee=h[w+1],ke=h[E],Ae=h[E+1];e(s,t,u),l(s,t,ye,Ee);let S=s[m]^s[t],T=s[m+1]^s[t+1];s[m]=T,s[m+1]=S,e(s,r,m),S=s[u]^s[r],T=s[u+1]^s[r+1],s[u]=S>>>24^T<<8,s[u+1]=T>>>24^S<<8,e(s,t,u),l(s,t,ke,Ae),S=s[m]^s[t],T=s[m+1]^s[t+1],s[m]=S>>>16^T<<16,s[m+1]=T>>>16^S<<16,e(s,r,m),S=s[u]^s[r],T=s[u+1]^s[r+1],s[u]=T>>>31^S<<1,s[u+1]=S>>>31^T<<1}const d=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=[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],i=new Uint8Array(c.map(function(t){return t*2})),s=new Uint32Array(32),h=new Uint32Array(32);function g(t,u){let r=0;for(r=0;r<16;r++)s[r]=t.h[r],s[r+16]=d[r];for(s[24]=s[24]^t.t,s[25]=s[25]^t.t/4294967296,u&&(s[28]=~s[28],s[29]=~s[29]),r=0;r<32;r++)h[r]=p(t.b,4*r);for(r=0;r<12;r++)b(0,8,16,24,i[r*16+0],i[r*16+1]),b(2,10,18,26,i[r*16+2],i[r*16+3]),b(4,12,20,28,i[r*16+4],i[r*16+5]),b(6,14,22,30,i[r*16+6],i[r*16+7]),b(0,10,20,30,i[r*16+8],i[r*16+9]),b(2,12,22,24,i[r*16+10],i[r*16+11]),b(4,14,16,26,i[r*16+12],i[r*16+13]),b(6,8,18,28,i[r*16+14],i[r*16+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^s[r]^s[r+16]}const y=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 k(t,u,r,m){if(t===0||t>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(u&&u.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(r&&r.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(m&&m.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const w={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};y.fill(0),y[0]=t,u&&(y[1]=u.length),y[2]=1,y[3]=1,r&&y.set(r,32),m&&y.set(m,48);for(let E=0;E<16;E++)w.h[E]=d[E]^p(y,E*4);return u&&(I(w,u),w.c=128),w}function I(t,u){for(let r=0;r>2]>>8*(r&3);return u}function a(t,u,r,m,w){r=r||64,t=n.normalizeInput(t),m&&(m=n.normalizeInput(m)),w&&(w=n.normalizeInput(w));const E=k(r,u,m,w);return I(E,t),f(E)}function o(t,u,r,m,w){const E=a(t,u,r,m,w);return n.toHex(E)}return B={blake2b:a,blake2bHex:o,blake2bInit:k,blake2bUpdate:I,blake2bFinal:f},B}var O,V;function se(){if(V)return O;V=1;const n=G();function e(f,a){return f[a]^f[a+1]<<8^f[a+2]<<16^f[a+3]<<24}function l(f,a,o,t,u,r){c[f]=c[f]+c[a]+u,c[t]=p(c[t]^c[f],16),c[o]=c[o]+c[t],c[a]=p(c[a]^c[o],12),c[f]=c[f]+c[a]+r,c[t]=p(c[t]^c[f],8),c[o]=c[o]+c[t],c[a]=p(c[a]^c[o],7)}function p(f,a){return f>>>a^f<<32-a}const b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),d=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]),c=new Uint32Array(16),i=new Uint32Array(16);function s(f,a){let o=0;for(o=0;o<8;o++)c[o]=f.h[o],c[o+8]=b[o];for(c[12]^=f.t,c[13]^=f.t/4294967296,a&&(c[14]=~c[14]),o=0;o<16;o++)i[o]=e(f.b,4*o);for(o=0;o<10;o++)l(0,4,8,12,i[d[o*16+0]],i[d[o*16+1]]),l(1,5,9,13,i[d[o*16+2]],i[d[o*16+3]]),l(2,6,10,14,i[d[o*16+4]],i[d[o*16+5]]),l(3,7,11,15,i[d[o*16+6]],i[d[o*16+7]]),l(0,5,10,15,i[d[o*16+8]],i[d[o*16+9]]),l(1,6,11,12,i[d[o*16+10]],i[d[o*16+11]]),l(2,7,8,13,i[d[o*16+12]],i[d[o*16+13]]),l(3,4,9,14,i[d[o*16+14]],i[d[o*16+15]]);for(o=0;o<8;o++)f.h[o]^=c[o]^c[o+8]}function h(f,a){if(!(f>0&&f<=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 t={h:new Uint32Array(b),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^o<<8^f,o>0&&(g(t,a),t.c=64),t}function g(f,a){for(let o=0;o>2]>>8*(o&3)&255;return a}function k(f,a,o){o=o||32,f=n.normalizeInput(f);const t=h(o,a);return g(t,f),y(t)}function I(f,a,o){const t=k(f,a,o);return n.toHex(t)}return O={blake2s:k,blake2sHex:I,blake2sInit:h,blake2sUpdate:g,blake2sFinal:y},O}var _,W;function le(){if(W)return _;W=1;const n=ie(),e=se();return _={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},_}var X=le();const ce=M({bits:24,rounds:23,rightRotations:8,leftRotations:3});function ae(n){const e=X.blake2bHex(n,null,12);return[parseInt(e.slice(0,6),16),parseInt(e.slice(6,12),16),parseInt(e.slice(12,18),16),parseInt(e.slice(18,24),16)]}function ue(n,e){if(!n||n.length===0)return"";const l=n[0];return n.slice(1).map((b,d)=>{const c=l*16777216+(d&16777215),i=ce.encrypt(c,e),s=(b^i)>>>0;try{return String.fromCodePoint(s)}catch{return""}}).join("")}const fe=M();function de(n){const e=X.blake2bHex(n,null,8);return[parseInt(e.slice(0,4),16),parseInt(e.slice(4,8),16),parseInt(e.slice(8,12),16),parseInt(e.slice(12,16),16)]}function pe(n,e){return n.map(l=>{try{return String.fromCodePoint(fe.decrypt(l,e))}catch{return""}}).join("")}const N="‍​­",x={3:"‍​­᠎‍",6:"‍​­‌‍",7:"‍​­‌‌"},K={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(K).map(([n,e])=>[e,+n]));function be(n){let e=n.indexOf(N),l;for(;e!==-1&&(l=Object.keys(x).find(d=>n.startsWith(x[d],e)),!l);)e=n.indexOf(N,e+N.length);if(!l)return null;const p=n.slice(e+x[l].length),b=A[l].unifier+A[l][0];if(p.startsWith(b)){const c=Array.from(p.slice(b.length,b.length+3)).map(g=>Object.keys(A[l]).find(y=>A[l][y]===g)).join(""),i=K[parseInt(c,l)];if(!i)return{base:l,cipher:"PLAIN",payload:p,sigIdx:e,sigLen:x[l].length};const s=p.slice(b.length+3),h=x[l].length+b.length+3;return{base:l,cipher:i,payload:s,sigIdx:e,sigLen:h}}return{base:l,cipher:"PLAIN",payload:p,sigIdx:e,sigLen:x[l].length}}function $(n,e,l){const p=new Set(Object.values(A[e]));let b=l;for(;bArray.from(e,r=>(+t==7?ne(r):r.codePointAt(0)).toString(t).split("").map(u=>S[t][u]).join("")).join(S[t].unifier),encodeNumberArray:(e,t=7)=>e.map(r=>r.toString(t).split("").map(u=>S[t][u]).join("")).join(S[t].unifier),decodeToString:(e,t=7)=>S.decodeToNumberArray(e,t).map(r=>String.fromCodePoint(+t==7?re(r):r)).join(""),decodeToNumberArray:(e,t=7)=>e.split(S[t].unifier).map(r=>Array.from(r).map(u=>Object.keys(S[t]).find(h=>S[t][h]===u)).join("")).filter(Boolean).map(r=>parseInt(r,t))},ee="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",M=[...new Set([...ee,...Array.from({length:95},(e,t)=>String.fromCharCode(t+32))])],te=new Map(M.map((e,t)=>[e,t])),ne=e=>te.get(e)??(e.codePointAt(0)<32?e.codePointAt(0)+95:e.codePointAt(0)),re=e=>e<95?M[e].codePointAt(0):e<127?e-95:e;function oe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var D,G;function ie(){if(G)return D;G=1;function e(t={}){const r=t.bits||16,u=t.rounds||22,h=t.rightRotations||7,f=t.leftRotations||2,c=2**r,s=c-1,l=(a,o)=>a>>o|a<a<>r-o,b=(a,o,n)=>(a=l(a,h),a=a+o&s,a^=n,o=g(o,f),o^=a,[a,o]),E=(a,o,n)=>(o^=a,o=l(o,f),a^=n,a=a-o&s,a=g(a,h),[a,o]);function k(a,o){let n=a[0],d=a[1],i=o[0],m=o.slice(1);[d,n]=b(d,n,i);for(let w=0;w{const d=a([o/c|0,o&s],n);return d[0]*c+d[1]}}return{encrypt:p(k),decrypt:p(A),encryptRaw:k,decryptRaw:A}}return D=e,D}var se=ie();const V=oe(se);var B,z;function W(){if(z)return B;z=1;const e="Input must be an string, Buffer or Uint8Array";function t(c){let s;if(c instanceof Uint8Array)s=c;else if(typeof c=="string")s=new TextEncoder().encode(c);else throw new Error(e);return s}function r(c){return Array.prototype.map.call(c,function(s){return(s<16?"0":"")+s.toString(16)}).join("")}function u(c){return(4294967296+c).toString(16).substring(1)}function h(c,s,l){let g=` +`+c+" = ";for(let b=0;b=4294967296&&w++,n[d]=m,n[d+1]=w}function r(n,d,i,m){let w=n[d]+i;i<0&&(w+=4294967296);let y=n[d+1]+m;w>=4294967296&&y++,n[d]=w,n[d+1]=y}function u(n,d){return n[d]^n[d+1]<<8^n[d+2]<<16^n[d+3]<<24}function h(n,d,i,m,w,y){const Ie=g[w],Te=g[w+1],xe=g[y],Ce=g[y+1];t(l,n,d),r(l,n,Ie,Te);let I=l[m]^l[n],T=l[m+1]^l[n+1];l[m]=T,l[m+1]=I,t(l,i,m),I=l[d]^l[i],T=l[d+1]^l[i+1],l[d]=I>>>24^T<<8,l[d+1]=T>>>24^I<<8,t(l,n,d),r(l,n,xe,Ce),I=l[m]^l[n],T=l[m+1]^l[n+1],l[m]=I>>>16^T<<16,l[m+1]=T>>>16^I<<16,t(l,i,m),I=l[d]^l[i],T=l[d+1]^l[i+1],l[d]=T>>>31^I<<1,l[d+1]=I>>>31^T<<1}const f=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=[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],s=new Uint8Array(c.map(function(n){return n*2})),l=new Uint32Array(32),g=new Uint32Array(32);function b(n,d){let i=0;for(i=0;i<16;i++)l[i]=n.h[i],l[i+16]=f[i];for(l[24]=l[24]^n.t,l[25]=l[25]^n.t/4294967296,d&&(l[28]=~l[28],l[29]=~l[29]),i=0;i<32;i++)g[i]=u(n.b,4*i);for(i=0;i<12;i++)h(0,8,16,24,s[i*16+0],s[i*16+1]),h(2,10,18,26,s[i*16+2],s[i*16+3]),h(4,12,20,28,s[i*16+4],s[i*16+5]),h(6,14,22,30,s[i*16+6],s[i*16+7]),h(0,10,20,30,s[i*16+8],s[i*16+9]),h(2,12,22,24,s[i*16+10],s[i*16+11]),h(4,14,16,26,s[i*16+12],s[i*16+13]),h(6,8,18,28,s[i*16+14],s[i*16+15]);for(i=0;i<16;i++)n.h[i]=n.h[i]^l[i]^l[i+16]}const E=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 k(n,d,i,m){if(n===0||n>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(i&&i.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(m&&m.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const w={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:n};E.fill(0),E[0]=n,d&&(E[1]=d.length),E[2]=1,E[3]=1,i&&E.set(i,32),m&&E.set(m,48);for(let y=0;y<16;y++)w.h[y]=f[y]^u(E,y*4);return d&&(A(w,d),w.c=128),w}function A(n,d){for(let i=0;i>2]>>8*(i&3);return d}function a(n,d,i,m,w){i=i||64,n=e.normalizeInput(n),m&&(m=e.normalizeInput(m)),w&&(w=e.normalizeInput(w));const y=k(i,d,m,w);return A(y,n),p(y)}function o(n,d,i,m,w){const y=a(n,d,i,m,w);return e.toHex(y)}return v={blake2b:a,blake2bHex:o,blake2bInit:k,blake2bUpdate:A,blake2bFinal:p},v}var O,X;function ce(){if(X)return O;X=1;const e=W();function t(p,a){return p[a]^p[a+1]<<8^p[a+2]<<16^p[a+3]<<24}function r(p,a,o,n,d,i){c[p]=c[p]+c[a]+d,c[n]=u(c[n]^c[p],16),c[o]=c[o]+c[n],c[a]=u(c[a]^c[o],12),c[p]=c[p]+c[a]+i,c[n]=u(c[n]^c[p],8),c[o]=c[o]+c[n],c[a]=u(c[a]^c[o],7)}function u(p,a){return p>>>a^p<<32-a}const h=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]),c=new Uint32Array(16),s=new Uint32Array(16);function l(p,a){let o=0;for(o=0;o<8;o++)c[o]=p.h[o],c[o+8]=h[o];for(c[12]^=p.t,c[13]^=p.t/4294967296,a&&(c[14]=~c[14]),o=0;o<16;o++)s[o]=t(p.b,4*o);for(o=0;o<10;o++)r(0,4,8,12,s[f[o*16+0]],s[f[o*16+1]]),r(1,5,9,13,s[f[o*16+2]],s[f[o*16+3]]),r(2,6,10,14,s[f[o*16+4]],s[f[o*16+5]]),r(3,7,11,15,s[f[o*16+6]],s[f[o*16+7]]),r(0,5,10,15,s[f[o*16+8]],s[f[o*16+9]]),r(1,6,11,12,s[f[o*16+10]],s[f[o*16+11]]),r(2,7,8,13,s[f[o*16+12]],s[f[o*16+13]]),r(3,4,9,14,s[f[o*16+14]],s[f[o*16+15]]);for(o=0;o<8;o++)p.h[o]^=c[o]^c[o+8]}function g(p,a){if(!(p>0&&p<=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 n={h:new Uint32Array(h),b:new Uint8Array(64),c:0,t:0,outlen:p};return n.h[0]^=16842752^o<<8^p,o>0&&(b(n,a),n.c=64),n}function b(p,a){for(let o=0;o>2]>>8*(o&3)&255;return a}function k(p,a,o){o=o||32,p=e.normalizeInput(p);const n=g(o,a);return b(n,p),E(n)}function A(p,a,o){const n=k(p,a,o);return e.toHex(n)}return O={blake2s:k,blake2sHex:A,blake2sInit:g,blake2sUpdate:b,blake2sFinal:E},O}var _,K;function ae(){if(K)return _;K=1;const e=le(),t=ce();return _={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},_}var $=ae();const ue=V({bits:24,rounds:23,rightRotations:8,leftRotations:3});function fe(e){const t=$.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 de(e,t){if(!e||e.length===0)return"";const r=e[0];return e.slice(1).map((h,f)=>{const c=r*16777216+(f&16777215),s=ue.encrypt(c,t),l=(h^s)>>>0;try{return String.fromCodePoint(l)}catch{return""}}).join("")}const pe=V();function he(e){const t=$.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 ge(e,t){return e.map(r=>{try{return String.fromCodePoint(pe.decrypt(r,t))}catch{return""}}).join("")}const C="‍​­",P={3:"‍​­᠎‍",6:"‍​­‌‍",7:"‍​­‌‌"},F={0:"PLAIN",1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(F).map(([e,t])=>[t,+e]));const be=Object.entries(P).flatMap(([e,t])=>Object.entries(F).map(([r,u])=>{const h=(+r).toString(e).padStart(4,"0");if(h.length!==4)throw new RangeError(`Cipher ID ${r} exceeds ZWUS-${e}'s signature capacity`);const f=t+S[e].unifier+S[e][0]+Array.from(h,c=>S[e][c]).join("");if(f.length!==11)throw new RangeError("Signatures must contain exactly 11 characters");return{base:e,cipher:u,sig:f,legacy:!1}}));function Y(e,t){let r=e.indexOf(C);for(;r!==-1;){const u=t.find(h=>e.startsWith(h.sig,r)&&(!h.legacyPlain||e[r+h.sig.length]!==S[h.base].unifier));if(u){const{base:h,cipher:f,sig:c,legacy:s}=u;return{base:h,cipher:f,payload:e.slice(r+c.length),sigIdx:r,sigLen:c.length,legacy:s}}r=e.indexOf(C,r+1)}return null}const me=e=>Y(e,be),we=[3,6,7].flatMap(e=>[...[1,2].map(t=>({base:String(e),cipher:F[t],legacy:!0,sig:P[e]+S[e].unifier+S[e][0].repeat(3)+S[e][t]})),{base:String(e),cipher:"PLAIN",sig:P[e],legacy:!0,legacyPlain:!0}]),ye=e=>Y(e,we);function Ee(e){const t=me(e),r=ye(e);return!t||r&&r.sigIdxme(h,e),Y(h)}function Y(n){const{wrap:e,node:l,start:p,endNode:b,end:d}=n;if(!l.isConnected||!b.isConnected){e.remove(),C.delete(n);return}const c=l.parentElement;if(!c||c.checkVisibility&&!c.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})){e.style.display="none";return}const i=document.createRange();try{i.setStart(l,p),i.setEnd(b,Math.min(d,b.nodeValue.length))}catch{e.remove(),C.delete(n);return}let s=i.getBoundingClientRect();if(!s.width&&!s.height&&(s=c.getBoundingClientRect()),!s.width&&!s.height){e.style.display="none";return}if(s.bottom<0||s.top>window.innerHeight||s.right<0||s.left>window.innerWidth){e.style.display="none";return}let h=c;for(;h&&h!==document.body&&h!==document.documentElement;){const k=window.getComputedStyle(h);if(k.overflow!=="visible"||k.overflowX!=="visible"||k.overflowY!=="visible"){const I=h.getBoundingClientRect();if(s.bottomI.bottom||s.rightI.right){e.style.display="none";return}}h=h.parentElement}e.style.display="flex";const g=s.left+(s.width||0)/2,y=s.top;e.style.left=`${g-e.offsetWidth/2}px`,e.style.top=`${y-e.offsetHeight-2}px`}function me(n,e){const{wrap:l,node:p,start:b,endNode:d,end:c}=n,i=document.createRange();i.setStart(p,b),i.setEnd(d,c);const s=i.toString().slice(e.sigLen);let h="";if(e.cipher==="PLAIN")try{h=A.decodeToString(s,e.base)}catch(g){console.error(g)}else{const g=prompt(`inØsight: enter password (${e.cipher}):`);if(!g)return;try{const y=A.decodeToNumberArray(s,e.base);e.cipher==="SPECK48_96CTR"?h=ue(y,ae(g)):e.cipher==="SPECK32_64ECB (insecure)"&&(h=pe(y,de(g)))}catch(y){console.error(y)}if(!h){alert("Decryption failed.");return}}if(h){i.deleteContents();const g=document.createElement("span");g.className="inzerosight-decoded",g.style.color="#00b4d8",g.style.fontWeight="600",g.textContent=` ${h} `,i.insertNode(g),l.remove(),C.delete(n)}}function we(n,e,l){let p=n,b=$(n.nodeValue,e,l);for(;b===p.nodeValue.length;){let d=p.nextSibling,c=!1;for(;(d==null?void 0:d.nodeType)===Node.ELEMENT_NODE&&d.tagName==="WBR";)c=!0,d=d.nextSibling;if(!c||(d==null?void 0:d.nodeType)!==Node.TEXT_NODE)break;const i=$(d.nodeValue,e,0);if(!i)break;p=d,b=i}return{endNode:p,end:b}}function v(n){if(!n||n.nodeType!==Node.TEXT_NODE)return;const e=n.nodeValue;if(!e||!e.includes(N))return;let l=0;for(;l{var d;return e[(d=b.parentElement)==null?void 0:d.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let p;for(;p=l.nextNode();)v(p)}J(document.body);let F;function j(){F||C.size===0||(F=requestAnimationFrame(()=>{F=null,C.forEach(Y)}))}new MutationObserver(n=>{var e;for(const l of[...C])(!l.node.isConnected||!((e=l.node.nodeValue)!=null&&e.startsWith(N,l.start)))&&(l.wrap.remove(),C.delete(l));for(const l of n)if(l.type==="characterData")v(l.target);else for(const p of l.addedNodes)p.nodeType===Node.TEXT_NODE?v(p):p.nodeType===Node.ELEMENT_NODE&&p.id!=="in0-host"&&J(p);j()}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",j,{capture:!0,passive:!0}),window.addEventListener("resize",j,{passive:!0})})(); + `,j.appendChild(e),(document.body||document.documentElement).appendChild(N)}function Se(e,t,r,u,h){for(const b of x)if(b.node===e&&b.start===r)return;ke();const f=document.createElement("div");f.className="in0-wrap";const c=document.createElement("button");c.className="in0-btn",c.textContent=t.cipher==="PLAIN"?"Decode":"Decrypt";const s=document.createElement("span");s.className="in0-badge",s.textContent="Ø",c.appendChild(s);const l=document.createElement("div");l.className="in0-arrow",f.appendChild(c),f.appendChild(l),j.appendChild(f);const g={wrap:f,node:e,start:r,endNode:u,end:h};x.add(g),c.onclick=()=>Ae(g,t),Z(g)}function Z(e){const{wrap:t,node:r,start:u,endNode:h,end:f}=e;if(!r.isConnected||!h.isConnected){t.remove(),x.delete(e);return}const c=r.parentElement;if(!c||c.checkVisibility&&!c.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})){t.style.display="none";return}const s=document.createRange();try{s.setStart(r,u),s.setEnd(h,Math.min(f,h.nodeValue.length))}catch{t.remove(),x.delete(e);return}let l=s.getBoundingClientRect();if(!l.width&&!l.height&&(l=c.getBoundingClientRect()),!l.width&&!l.height){t.style.display="none";return}if(l.bottom<0||l.top>window.innerHeight||l.right<0||l.left>window.innerWidth){t.style.display="none";return}let g=c;for(;g&&g!==document.body&&g!==document.documentElement;){const k=window.getComputedStyle(g);if(k.overflow!=="visible"||k.overflowX!=="visible"||k.overflowY!=="visible"){const A=g.getBoundingClientRect();if(l.bottomA.bottom||l.rightA.right){t.style.display="none";return}}g=g.parentElement}t.style.display="flex";const b=l.left+(l.width||0)/2,E=l.top;t.style.left=`${b-t.offsetWidth/2}px`,t.style.top=`${E-t.offsetHeight-2}px`}function Ae(e,t){const{wrap:r,node:u,start:h,endNode:f,end:c}=e,s=document.createRange();s.setStart(u,h),s.setEnd(f,c);const l=s.toString().slice(t.sigLen);let g="";if(t.cipher==="PLAIN")try{g=S.decodeToString(l,t.base)}catch(b){console.error(b)}else{const b=prompt(`inØsight: enter password (${t.cipher}):`);if(!b)return;try{const E=S.decodeToNumberArray(l,t.base);t.cipher==="SPECK48_96CTR"?g=de(E,fe(b)):t.cipher==="SPECK32_64ECB (insecure)"&&(g=ge(E,he(b)))}catch(E){console.error(E)}if(!g){alert("Decryption failed.");return}}if(g){s.deleteContents();const b=document.createElement("span");b.className="inzerosight-decoded",b.style.color="#00b4d8",b.style.fontWeight="600",b.textContent=` ${g} `,s.insertNode(b),r.remove(),x.delete(e)}}function U(e,t){let r=e[t],u=!1;for(;(r==null?void 0:r.nodeType)===Node.ELEMENT_NODE&&r.tagName==="WBR";)u=!0,r=r[t];return u&&(r==null?void 0:r.nodeType)===Node.TEXT_NODE?r:null}function R(e){if(!e||e.nodeType!==Node.TEXT_NODE)return;for(let f;f=U(e,"previousSibling");)e=f;const t=[e];let r=e.nodeValue;for(let f;f=U(t.at(-1),"nextSibling");)t.push(f),r+=f.nodeValue;if(!r||!r.includes(C))return;const u=(f,c)=>{for(const s of t){if(f{var f;return t[(f=h.parentElement)==null?void 0:f.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let u;for(;u=r.nextNode();)U(u,"previousSibling")||R(u)}Q(document.body);let H;function L(){H||x.size===0||(H=requestAnimationFrame(()=>{H=null,x.forEach(Z)}))}new MutationObserver(e=>{var t;for(const r of[...x]){let u=((t=r.node.nodeValue)==null?void 0:t.slice(r.start))||"";for(let h=r.node;u.length -

inØsight 3.2.0source

+

inØsight 3.3.0source

diff --git a/dist/chrome/index.js b/dist/chrome/index.js index d0f0c10..9b44be8 100644 --- a/dist/chrome/index.js +++ b/dist/chrome/index.js @@ -1,4 +1,4 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))g(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const s of f.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&g(s)}).observe(document,{childList:!0,subtree:!0});function c(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function g(u){if(u.ep)return;u.ep=!0;const f=c(u);fetch(u.href,f)}})();const I={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,c=>(+t==7?ge(c):c.codePointAt(0)).toString(t).split("").map(g=>I[t][g]).join("")).join(I[t].unifier),encodeNumberArray:(e,t=7)=>e.map(c=>c.toString(t).split("").map(g=>I[t][g]).join("")).join(I[t].unifier),decodeToString:(e,t=7)=>I.decodeToNumberArray(e,t).map(c=>String.fromCodePoint(+t==7?he(c):c)).join(""),decodeToNumberArray:(e,t=7)=>e.split(I[t].unifier).map(c=>Array.from(c).map(g=>Object.keys(I[t]).find(u=>I[t][u]===g)).join("")).filter(Boolean).map(c=>parseInt(c,t))},de="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",X=[...new Set([...de,...Array.from({length:95},(e,t)=>String.fromCharCode(t+32))])],pe=new Map(X.map((e,t)=>[e,t])),ge=e=>pe.get(e)??(e.codePointAt(0)<32?e.codePointAt(0)+95:e.codePointAt(0)),he=e=>e<95?X[e].codePointAt(0):e<127?e-95:e,J=65536;function Q(e,t,c){const g=[];for(let u=0;u=55296&&e.charCodeAt(f-1)<=56319&&f--,g.push(I[c](e.slice(u,f),t)),u=f}return g.join(I[t].unifier)}function ee(e,t,c){const g=[],u=I[t].unifier;for(let f=0;f=f?n+1:e.indexOf(u,s)+1||e.length}g.push(I[c](e.slice(f,s),t)),f=s}return c==="decodeToString"?g.join(""):g.flat()}const be=(e,t)=>Q(e,t,"encodeString"),M=(e,t)=>Q(e,t,"encodeNumberArray"),ye=(e,t)=>ee(e,t,"decodeToString"),v=(e,t)=>ee(e,t,"decodeToNumberArray");function me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var F,G;function Ae(){if(G)return F;G=1;function e(t={}){const c=t.bits||16,g=t.rounds||22,u=t.rightRotations||7,f=t.leftRotations||2,s=2**c,n=s-1,a=(l,o)=>l>>o|l<l<>c-o,m=(l,o,r)=>(l=a(l,u),l=l+o&n,l^=r,o=y(o,f),o^=l,[l,o]),w=(l,o,r)=>(o^=l,o=a(o,f),l^=r,l=l-o&n,l=y(l,u),[l,o]);function k(l,o){let r=l[0],d=l[1],i=o[0],h=o.slice(1);[d,r]=m(d,r,i);for(let b=0;b{const d=l([o/s|0,o&n],r);return d[0]*s+d[1]}}return{encrypt:p(k),decrypt:p(E),encryptRaw:k,decryptRaw:E}}return F=e,F}var we=Ae();const te=me(we);var P,K;function ne(){if(K)return P;K=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 c(s){return Array.prototype.map.call(s,function(n){return(n<16?"0":"")+n.toString(16)}).join("")}function g(s){return(4294967296+s).toString(16).substring(1)}function u(s,n,a){let y=` -`+s+" = ";for(let m=0;m=4294967296&&b++,r[d]=h,r[d+1]=b}function c(r,d,i,h){let b=r[d]+i;i<0&&(b+=4294967296);let A=r[d+1]+h;b>=4294967296&&A++,r[d]=b,r[d+1]=A}function g(r,d){return r[d]^r[d+1]<<8^r[d+2]<<16^r[d+3]<<24}function u(r,d,i,h,b,A){const le=y[b],ae=y[b+1],ue=y[A],fe=y[A+1];t(a,r,d),c(a,r,le,ae);let S=a[h]^a[r],C=a[h+1]^a[r+1];a[h]=C,a[h+1]=S,t(a,i,h),S=a[d]^a[i],C=a[d+1]^a[i+1],a[d]=S>>>24^C<<8,a[d+1]=C>>>24^S<<8,t(a,r,d),c(a,r,ue,fe),S=a[h]^a[r],C=a[h+1]^a[r+1],a[h]=S>>>16^C<<16,a[h+1]=C>>>16^S<<16,t(a,i,h),S=a[d]^a[i],C=a[d+1]^a[i+1],a[d]=C>>>31^S<<1,a[d+1]=S>>>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})),a=new Uint32Array(32),y=new Uint32Array(32);function m(r,d){let i=0;for(i=0;i<16;i++)a[i]=r.h[i],a[i+16]=f[i];for(a[24]=a[24]^r.t,a[25]=a[25]^r.t/4294967296,d&&(a[28]=~a[28],a[29]=~a[29]),i=0;i<32;i++)y[i]=g(r.b,4*i);for(i=0;i<12;i++)u(0,8,16,24,n[i*16+0],n[i*16+1]),u(2,10,18,26,n[i*16+2],n[i*16+3]),u(4,12,20,28,n[i*16+4],n[i*16+5]),u(6,14,22,30,n[i*16+6],n[i*16+7]),u(0,10,20,30,n[i*16+8],n[i*16+9]),u(2,12,22,24,n[i*16+10],n[i*16+11]),u(4,14,16,26,n[i*16+12],n[i*16+13]),u(6,8,18,28,n[i*16+14],n[i*16+15]);for(i=0;i<16;i++)r.h[i]=r.h[i]^a[i]^a[i+16]}const w=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 k(r,d,i,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(i&&i.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};w.fill(0),w[0]=r,d&&(w[1]=d.length),w[2]=1,w[3]=1,i&&w.set(i,32),h&&w.set(h,48);for(let A=0;A<16;A++)b.h[A]=f[A]^g(w,A*4);return d&&(E(b,d),b.c=128),b}function E(r,d){for(let i=0;i>2]>>8*(i&3);return d}function l(r,d,i,h,b){i=i||64,r=e.normalizeInput(r),h&&(h=e.normalizeInput(h)),b&&(b=e.normalizeInput(b));const A=k(i,d,h,b);return E(A,r),p(A)}function o(r,d,i,h,b){const A=l(r,d,i,h,b);return e.toHex(A)}return O={blake2b:l,blake2bHex:o,blake2bInit:k,blake2bUpdate:E,blake2bFinal:p},O}var R,z;function ke(){if(z)return R;z=1;const e=ne();function t(p,l){return p[l]^p[l+1]<<8^p[l+2]<<16^p[l+3]<<24}function c(p,l,o,r,d,i){s[p]=s[p]+s[l]+d,s[r]=g(s[r]^s[p],16),s[o]=s[o]+s[r],s[l]=g(s[l]^s[o],12),s[p]=s[p]+s[l]+i,s[r]=g(s[r]^s[p],8),s[o]=s[o]+s[r],s[l]=g(s[l]^s[o],7)}function g(p,l){return p>>>l^p<<32-l}const u=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 a(p,l){let o=0;for(o=0;o<8;o++)s[o]=p.h[o],s[o+8]=u[o];for(s[12]^=p.t,s[13]^=p.t/4294967296,l&&(s[14]=~s[14]),o=0;o<16;o++)n[o]=t(p.b,4*o);for(o=0;o<10;o++)c(0,4,8,12,n[f[o*16+0]],n[f[o*16+1]]),c(1,5,9,13,n[f[o*16+2]],n[f[o*16+3]]),c(2,6,10,14,n[f[o*16+4]],n[f[o*16+5]]),c(3,7,11,15,n[f[o*16+6]],n[f[o*16+7]]),c(0,5,10,15,n[f[o*16+8]],n[f[o*16+9]]),c(1,6,11,12,n[f[o*16+10]],n[f[o*16+11]]),c(2,7,8,13,n[f[o*16+12]],n[f[o*16+13]]),c(3,4,9,14,n[f[o*16+14]],n[f[o*16+15]]);for(o=0;o<8;o++)p.h[o]^=s[o]^s[o+8]}function y(p,l){if(!(p>0&&p<=32))throw new Error("Incorrect output length, should be in [1, 32]");const o=l?l.length:0;if(l&&!(o>0&&o<=32))throw new Error("Incorrect key length, should be in [1, 32]");const r={h:new Uint32Array(u),b:new Uint8Array(64),c:0,t:0,outlen:p};return r.h[0]^=16842752^o<<8^p,o>0&&(m(r,l),r.c=64),r}function m(p,l){for(let o=0;o>2]>>8*(o&3)&255;return l}function k(p,l,o){o=o||32,p=e.normalizeInput(p);const r=y(o,l);return m(r,p),w(r)}function E(p,l,o){const r=k(p,l,o);return e.toHex(r)}return R={blake2s:k,blake2sHex:E,blake2sInit:y,blake2sUpdate:m,blake2sFinal:w},R}var _,$;function Ee(){if($)return _;$=1;const e=Ie(),t=ke();return _={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},_}var re=Ee();const oe=te({bits:24,rounds:23,rightRotations:8,leftRotations:3});function W(e){const t=re.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 Se(e,t){const c=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]&16777215,g=Array.from(e,(u,f)=>{const s=c*16777216+(f&16777215),n=oe.encrypt(s,t);return(u.codePointAt(0)^n)>>>0});return[c,...g]}function Ce(e,t){if(!e||e.length===0)return"";const c=e[0];return e.slice(1).map((u,f)=>{const s=c*16777216+(f&16777215),n=oe.encrypt(s,t),a=(u^n)>>>0;try{return String.fromCodePoint(a)}catch{return""}}).join("")}const ie=te();function Y(e){const t=re.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 Be(e,t){return Array.from(e,c=>ie.encrypt(c.codePointAt(0),t))}function Te(e,t){return e.map(c=>{try{return String.fromCodePoint(ie.decrypt(c,t))}catch{return""}}).join("")}const j="‍​­",B={3:"‍​­᠎‍",6:"‍​­‌‍",7:"‍​­‌‌"},ce={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"},Ue=Object.fromEntries(Object.entries(ce).map(([e,t])=>[t,+e]));function De(e,t){let c=B[e];const g=Ue[t];if(g){const u=Array.from(g.toString(e).padStart(3,"0"),f=>I[e][f]).join("");c+=I[e].unifier+I[e][0]+u}return c}function Fe(e){let t=e.indexOf(j),c;for(;t!==-1&&(c=Object.keys(B).find(f=>e.startsWith(B[f],t)),!c);)t=e.indexOf(j,t+j.length);if(!c)return null;const g=e.slice(t+B[c].length),u=I[c].unifier+I[c][0];if(g.startsWith(u)){const s=Array.from(g.slice(u.length,u.length+3)).map(m=>Object.keys(I[c]).find(w=>I[c][w]===m)).join(""),n=ce[parseInt(s,c)];if(!n)return{base:c,cipher:"PLAIN",payload:g,sigIdx:t,sigLen:B[c].length};const a=g.slice(u.length+3),y=B[c].length+u.length+3;return{base:c,cipher:n,payload:a,sigIdx:t,sigLen:y}}return{base:c,cipher:"PLAIN",payload:g,sigIdx:t,sigLen:B[c].length}}const T=document.getElementById("textarea"),N=document.getElementById("encoder"),L=document.getElementById("cipher"),H=document.getElementById("sign"),D=document.getElementById("sigDetect"),U=document.getElementById("notice"),Pe=["encodeButton","decodeButton"].map(e=>document.getElementById(e)),V=[...Pe,N,L,H];document.getElementById("encodeButton").addEventListener("click",se);document.getElementById("decodeButton").addEventListener("click",se);H.addEventListener("click",e=>e.target.classList.toggle("on"));let Z,x=!1;async function se(e){if(x)return;if(clearTimeout(Z),D.className="",T.value===""){T.value="The text box is empty.";return}const t=e.target.id==="encodeButton"?"NO":"YES";let c=Re(),g=N.value.split("-")[1],u=T.value;if(t==="YES"){const n=Fe(u);if(n){if(n.base!==g||n.cipher&&n.cipher!==c){const a=n.cipher&&n.cipher!=="PLAIN"?` (${n.cipher})`:"";D.textContent=`ZWUS-${n.base}${a} signature detected`,D.className="show",Z=setTimeout(()=>D.className="",2e3)}g=n.base,N.value="ZWUS-"+g,n.cipher&&(c=n.cipher,L.value=c),u=u.slice(0,n.sigIdx)+n.payload}}const f=c!=="PLAIN",s=f&&prompt("enter password.");if(!(f&&!s)){x=!0,V.forEach(n=>n.disabled=!0),U.textContent="Processing…";try{let n=await _e[t][c](u,g,s);if(t==="NO"&&H.classList.contains("on")&&(n=De(g,c)+n),T.value=n,t==="NO"){U.textContent="Copying…";const a=await Oe(n);a&&n.length<=65536&&(T.value=`Copied to your clipboard. - A copy has been placed between these brackets [`+n+"]"),U.textContent=a?`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 Oe(e){var t;if((t=navigator.clipboard)!=null&&t.writeText){let c;try{return await Promise.race([navigator.clipboard.writeText(e),new Promise((g,u)=>c=setTimeout(()=>u(new Error("Copy timed out")),5e3))]),!0}catch(g){console.warn("Clipboard copy failed",g)}finally{clearTimeout(c)}}if(e.length>65536)return!1;T.select();try{return document.execCommand("copy")}catch(c){return console.warn("Clipboard copy failed",c),!1}}function Re(){return L.value}const _e={NO:{PLAIN:(e,t)=>be(e,t),SPECK48_96CTR:(e,t,c)=>M(Se(e,W(c)),t),"SPECK32_64ECB (insecure)":(e,t,c)=>M(Be(e,Y(c)),t)},YES:{PLAIN:(e,t)=>ye(e,t),SPECK48_96CTR:async(e,t,c)=>Ce(await v(e,t),W(c)),"SPECK32_64ECB (insecure)":async(e,t,c)=>Te(await v(e,t),Y(c))}}; +(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=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=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<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{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=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>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>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.sigIdxdocument.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))}}; diff --git a/dist/chrome/manifest.json b/dist/chrome/manifest.json index 43eaf6c..6768ba0 100644 --- a/dist/chrome/manifest.json +++ b/dist/chrome/manifest.json @@ -1 +1 @@ -{"name":"inØsight","version":"3.2.0","author":"planetrenox@pm.me","homepage_url":"https://github.com/inzerosight/inzerosight","description":"Communicate undetected in plain sight.","icons":{"48":"icon_500.png"},"permissions":["clipboardWrite"],"manifest_version":3,"action":{"default_icon":{"48":"icon_500.png"},"default_title":"inØsight","default_popup":"index.html"},"content_scripts":[{"matches":[""],"js":["content.js"],"run_at":"document_idle"}]} \ No newline at end of file +{"name":"inØsight","version":"3.3.0","author":"planetrenox@pm.me","homepage_url":"https://github.com/inzerosight/inzerosight","description":"Communicate undetected in plain sight.","icons":{"48":"icon_500.png"},"permissions":["clipboardWrite"],"manifest_version":3,"action":{"default_icon":{"48":"icon_500.png"},"default_title":"inØsight","default_popup":"index.html"},"content_scripts":[{"matches":[""],"js":["content.js"],"run_at":"document_idle"}]} \ No newline at end of file diff --git a/dist/firefox/content.js b/dist/firefox/content.js index 6f63110..c165703 100644 --- a/dist/firefox/content.js +++ b/dist/firefox/content.js @@ -1,6 +1,6 @@ -(function(){"use strict";const A={3:{unifier:"­",0:"᠎",1:"​",2:"‍"},6:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎"},7:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎",6:"\uFEFF"},encodeString:(n,e=7)=>Array.from(n,l=>(+e==7?ee(l):l.codePointAt(0)).toString(e).split("").map(p=>A[e][p]).join("")).join(A[e].unifier),encodeNumberArray:(n,e=7)=>n.map(l=>l.toString(e).split("").map(p=>A[e][p]).join("")).join(A[e].unifier),decodeToString:(n,e=7)=>A.decodeToNumberArray(n,e).map(l=>String.fromCodePoint(+e==7?te(l):l)).join(""),decodeToNumberArray:(n,e=7)=>n.split(A[e].unifier).map(l=>Array.from(l).map(p=>Object.keys(A[e]).find(b=>A[e][b]===p)).join("")).filter(Boolean).map(l=>parseInt(l,e))},Q="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",H=[...new Set([...Q,...Array.from({length:95},(n,e)=>String.fromCharCode(e+32))])],Z=new Map(H.map((n,e)=>[n,e])),ee=n=>Z.get(n)??(n.codePointAt(0)<32?n.codePointAt(0)+95:n.codePointAt(0)),te=n=>n<95?H[n].codePointAt(0):n<127?n-95:n;function ne(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var D,L;function oe(){if(L)return D;L=1;function n(e={}){const l=e.bits||16,p=e.rounds||22,b=e.rightRotations||7,d=e.leftRotations||2,c=2**l,i=c-1,s=(a,o)=>a>>o|a<a<>l-o,g=(a,o,t)=>(a=s(a,b),a=a+o&i,a^=t,o=h(o,d),o^=a,[a,o]),y=(a,o,t)=>(o^=a,o=s(o,d),a^=t,a=a-o&i,a=h(a,b),[a,o]);function k(a,o){let t=a[0],u=a[1],r=o[0],m=o.slice(1);[u,t]=g(u,t,r);for(let w=0;w{const u=a([o/c|0,o&i],t);return u[0]*c+u[1]}}return{encrypt:f(k),decrypt:f(I),encryptRaw:k,decryptRaw:I}}return D=n,D}var re=oe();const M=ne(re);var U,z;function G(){if(z)return U;z=1;const n="Input must be an string, Buffer or Uint8Array";function e(c){let i;if(c instanceof Uint8Array)i=c;else if(typeof c=="string")i=new TextEncoder().encode(c);else throw new Error(n);return i}function l(c){return Array.prototype.map.call(c,function(i){return(i<16?"0":"")+i.toString(16)}).join("")}function p(c){return(4294967296+c).toString(16).substring(1)}function b(c,i,s){let h=` -`+c+" = ";for(let g=0;g=4294967296&&w++,t[u]=m,t[u+1]=w}function l(t,u,r,m){let w=t[u]+r;r<0&&(w+=4294967296);let E=t[u+1]+m;w>=4294967296&&E++,t[u]=w,t[u+1]=E}function p(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function b(t,u,r,m,w,E){const ye=h[w],Ee=h[w+1],ke=h[E],Ae=h[E+1];e(s,t,u),l(s,t,ye,Ee);let S=s[m]^s[t],T=s[m+1]^s[t+1];s[m]=T,s[m+1]=S,e(s,r,m),S=s[u]^s[r],T=s[u+1]^s[r+1],s[u]=S>>>24^T<<8,s[u+1]=T>>>24^S<<8,e(s,t,u),l(s,t,ke,Ae),S=s[m]^s[t],T=s[m+1]^s[t+1],s[m]=S>>>16^T<<16,s[m+1]=T>>>16^S<<16,e(s,r,m),S=s[u]^s[r],T=s[u+1]^s[r+1],s[u]=T>>>31^S<<1,s[u+1]=S>>>31^T<<1}const d=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=[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],i=new Uint8Array(c.map(function(t){return t*2})),s=new Uint32Array(32),h=new Uint32Array(32);function g(t,u){let r=0;for(r=0;r<16;r++)s[r]=t.h[r],s[r+16]=d[r];for(s[24]=s[24]^t.t,s[25]=s[25]^t.t/4294967296,u&&(s[28]=~s[28],s[29]=~s[29]),r=0;r<32;r++)h[r]=p(t.b,4*r);for(r=0;r<12;r++)b(0,8,16,24,i[r*16+0],i[r*16+1]),b(2,10,18,26,i[r*16+2],i[r*16+3]),b(4,12,20,28,i[r*16+4],i[r*16+5]),b(6,14,22,30,i[r*16+6],i[r*16+7]),b(0,10,20,30,i[r*16+8],i[r*16+9]),b(2,12,22,24,i[r*16+10],i[r*16+11]),b(4,14,16,26,i[r*16+12],i[r*16+13]),b(6,8,18,28,i[r*16+14],i[r*16+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^s[r]^s[r+16]}const y=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 k(t,u,r,m){if(t===0||t>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(u&&u.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(r&&r.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(m&&m.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const w={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};y.fill(0),y[0]=t,u&&(y[1]=u.length),y[2]=1,y[3]=1,r&&y.set(r,32),m&&y.set(m,48);for(let E=0;E<16;E++)w.h[E]=d[E]^p(y,E*4);return u&&(I(w,u),w.c=128),w}function I(t,u){for(let r=0;r>2]>>8*(r&3);return u}function a(t,u,r,m,w){r=r||64,t=n.normalizeInput(t),m&&(m=n.normalizeInput(m)),w&&(w=n.normalizeInput(w));const E=k(r,u,m,w);return I(E,t),f(E)}function o(t,u,r,m,w){const E=a(t,u,r,m,w);return n.toHex(E)}return B={blake2b:a,blake2bHex:o,blake2bInit:k,blake2bUpdate:I,blake2bFinal:f},B}var O,V;function se(){if(V)return O;V=1;const n=G();function e(f,a){return f[a]^f[a+1]<<8^f[a+2]<<16^f[a+3]<<24}function l(f,a,o,t,u,r){c[f]=c[f]+c[a]+u,c[t]=p(c[t]^c[f],16),c[o]=c[o]+c[t],c[a]=p(c[a]^c[o],12),c[f]=c[f]+c[a]+r,c[t]=p(c[t]^c[f],8),c[o]=c[o]+c[t],c[a]=p(c[a]^c[o],7)}function p(f,a){return f>>>a^f<<32-a}const b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),d=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]),c=new Uint32Array(16),i=new Uint32Array(16);function s(f,a){let o=0;for(o=0;o<8;o++)c[o]=f.h[o],c[o+8]=b[o];for(c[12]^=f.t,c[13]^=f.t/4294967296,a&&(c[14]=~c[14]),o=0;o<16;o++)i[o]=e(f.b,4*o);for(o=0;o<10;o++)l(0,4,8,12,i[d[o*16+0]],i[d[o*16+1]]),l(1,5,9,13,i[d[o*16+2]],i[d[o*16+3]]),l(2,6,10,14,i[d[o*16+4]],i[d[o*16+5]]),l(3,7,11,15,i[d[o*16+6]],i[d[o*16+7]]),l(0,5,10,15,i[d[o*16+8]],i[d[o*16+9]]),l(1,6,11,12,i[d[o*16+10]],i[d[o*16+11]]),l(2,7,8,13,i[d[o*16+12]],i[d[o*16+13]]),l(3,4,9,14,i[d[o*16+14]],i[d[o*16+15]]);for(o=0;o<8;o++)f.h[o]^=c[o]^c[o+8]}function h(f,a){if(!(f>0&&f<=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 t={h:new Uint32Array(b),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^o<<8^f,o>0&&(g(t,a),t.c=64),t}function g(f,a){for(let o=0;o>2]>>8*(o&3)&255;return a}function k(f,a,o){o=o||32,f=n.normalizeInput(f);const t=h(o,a);return g(t,f),y(t)}function I(f,a,o){const t=k(f,a,o);return n.toHex(t)}return O={blake2s:k,blake2sHex:I,blake2sInit:h,blake2sUpdate:g,blake2sFinal:y},O}var _,W;function le(){if(W)return _;W=1;const n=ie(),e=se();return _={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},_}var X=le();const ce=M({bits:24,rounds:23,rightRotations:8,leftRotations:3});function ae(n){const e=X.blake2bHex(n,null,12);return[parseInt(e.slice(0,6),16),parseInt(e.slice(6,12),16),parseInt(e.slice(12,18),16),parseInt(e.slice(18,24),16)]}function ue(n,e){if(!n||n.length===0)return"";const l=n[0];return n.slice(1).map((b,d)=>{const c=l*16777216+(d&16777215),i=ce.encrypt(c,e),s=(b^i)>>>0;try{return String.fromCodePoint(s)}catch{return""}}).join("")}const fe=M();function de(n){const e=X.blake2bHex(n,null,8);return[parseInt(e.slice(0,4),16),parseInt(e.slice(4,8),16),parseInt(e.slice(8,12),16),parseInt(e.slice(12,16),16)]}function pe(n,e){return n.map(l=>{try{return String.fromCodePoint(fe.decrypt(l,e))}catch{return""}}).join("")}const N="‍​­",x={3:"‍​­᠎‍",6:"‍​­‌‍",7:"‍​­‌‌"},K={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(K).map(([n,e])=>[e,+n]));function be(n){let e=n.indexOf(N),l;for(;e!==-1&&(l=Object.keys(x).find(d=>n.startsWith(x[d],e)),!l);)e=n.indexOf(N,e+N.length);if(!l)return null;const p=n.slice(e+x[l].length),b=A[l].unifier+A[l][0];if(p.startsWith(b)){const c=Array.from(p.slice(b.length,b.length+3)).map(g=>Object.keys(A[l]).find(y=>A[l][y]===g)).join(""),i=K[parseInt(c,l)];if(!i)return{base:l,cipher:"PLAIN",payload:p,sigIdx:e,sigLen:x[l].length};const s=p.slice(b.length+3),h=x[l].length+b.length+3;return{base:l,cipher:i,payload:s,sigIdx:e,sigLen:h}}return{base:l,cipher:"PLAIN",payload:p,sigIdx:e,sigLen:x[l].length}}function $(n,e,l){const p=new Set(Object.values(A[e]));let b=l;for(;bArray.from(e,r=>(+t==7?ne(r):r.codePointAt(0)).toString(t).split("").map(u=>S[t][u]).join("")).join(S[t].unifier),encodeNumberArray:(e,t=7)=>e.map(r=>r.toString(t).split("").map(u=>S[t][u]).join("")).join(S[t].unifier),decodeToString:(e,t=7)=>S.decodeToNumberArray(e,t).map(r=>String.fromCodePoint(+t==7?re(r):r)).join(""),decodeToNumberArray:(e,t=7)=>e.split(S[t].unifier).map(r=>Array.from(r).map(u=>Object.keys(S[t]).find(h=>S[t][h]===u)).join("")).filter(Boolean).map(r=>parseInt(r,t))},ee="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",M=[...new Set([...ee,...Array.from({length:95},(e,t)=>String.fromCharCode(t+32))])],te=new Map(M.map((e,t)=>[e,t])),ne=e=>te.get(e)??(e.codePointAt(0)<32?e.codePointAt(0)+95:e.codePointAt(0)),re=e=>e<95?M[e].codePointAt(0):e<127?e-95:e;function oe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var D,G;function ie(){if(G)return D;G=1;function e(t={}){const r=t.bits||16,u=t.rounds||22,h=t.rightRotations||7,f=t.leftRotations||2,c=2**r,s=c-1,l=(a,o)=>a>>o|a<a<>r-o,b=(a,o,n)=>(a=l(a,h),a=a+o&s,a^=n,o=g(o,f),o^=a,[a,o]),E=(a,o,n)=>(o^=a,o=l(o,f),a^=n,a=a-o&s,a=g(a,h),[a,o]);function k(a,o){let n=a[0],d=a[1],i=o[0],m=o.slice(1);[d,n]=b(d,n,i);for(let w=0;w{const d=a([o/c|0,o&s],n);return d[0]*c+d[1]}}return{encrypt:p(k),decrypt:p(A),encryptRaw:k,decryptRaw:A}}return D=e,D}var se=ie();const V=oe(se);var B,z;function W(){if(z)return B;z=1;const e="Input must be an string, Buffer or Uint8Array";function t(c){let s;if(c instanceof Uint8Array)s=c;else if(typeof c=="string")s=new TextEncoder().encode(c);else throw new Error(e);return s}function r(c){return Array.prototype.map.call(c,function(s){return(s<16?"0":"")+s.toString(16)}).join("")}function u(c){return(4294967296+c).toString(16).substring(1)}function h(c,s,l){let g=` +`+c+" = ";for(let b=0;b=4294967296&&w++,n[d]=m,n[d+1]=w}function r(n,d,i,m){let w=n[d]+i;i<0&&(w+=4294967296);let y=n[d+1]+m;w>=4294967296&&y++,n[d]=w,n[d+1]=y}function u(n,d){return n[d]^n[d+1]<<8^n[d+2]<<16^n[d+3]<<24}function h(n,d,i,m,w,y){const Ie=g[w],Te=g[w+1],xe=g[y],Ce=g[y+1];t(l,n,d),r(l,n,Ie,Te);let I=l[m]^l[n],T=l[m+1]^l[n+1];l[m]=T,l[m+1]=I,t(l,i,m),I=l[d]^l[i],T=l[d+1]^l[i+1],l[d]=I>>>24^T<<8,l[d+1]=T>>>24^I<<8,t(l,n,d),r(l,n,xe,Ce),I=l[m]^l[n],T=l[m+1]^l[n+1],l[m]=I>>>16^T<<16,l[m+1]=T>>>16^I<<16,t(l,i,m),I=l[d]^l[i],T=l[d+1]^l[i+1],l[d]=T>>>31^I<<1,l[d+1]=I>>>31^T<<1}const f=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=[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],s=new Uint8Array(c.map(function(n){return n*2})),l=new Uint32Array(32),g=new Uint32Array(32);function b(n,d){let i=0;for(i=0;i<16;i++)l[i]=n.h[i],l[i+16]=f[i];for(l[24]=l[24]^n.t,l[25]=l[25]^n.t/4294967296,d&&(l[28]=~l[28],l[29]=~l[29]),i=0;i<32;i++)g[i]=u(n.b,4*i);for(i=0;i<12;i++)h(0,8,16,24,s[i*16+0],s[i*16+1]),h(2,10,18,26,s[i*16+2],s[i*16+3]),h(4,12,20,28,s[i*16+4],s[i*16+5]),h(6,14,22,30,s[i*16+6],s[i*16+7]),h(0,10,20,30,s[i*16+8],s[i*16+9]),h(2,12,22,24,s[i*16+10],s[i*16+11]),h(4,14,16,26,s[i*16+12],s[i*16+13]),h(6,8,18,28,s[i*16+14],s[i*16+15]);for(i=0;i<16;i++)n.h[i]=n.h[i]^l[i]^l[i+16]}const E=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 k(n,d,i,m){if(n===0||n>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(i&&i.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(m&&m.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const w={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:n};E.fill(0),E[0]=n,d&&(E[1]=d.length),E[2]=1,E[3]=1,i&&E.set(i,32),m&&E.set(m,48);for(let y=0;y<16;y++)w.h[y]=f[y]^u(E,y*4);return d&&(A(w,d),w.c=128),w}function A(n,d){for(let i=0;i>2]>>8*(i&3);return d}function a(n,d,i,m,w){i=i||64,n=e.normalizeInput(n),m&&(m=e.normalizeInput(m)),w&&(w=e.normalizeInput(w));const y=k(i,d,m,w);return A(y,n),p(y)}function o(n,d,i,m,w){const y=a(n,d,i,m,w);return e.toHex(y)}return v={blake2b:a,blake2bHex:o,blake2bInit:k,blake2bUpdate:A,blake2bFinal:p},v}var O,X;function ce(){if(X)return O;X=1;const e=W();function t(p,a){return p[a]^p[a+1]<<8^p[a+2]<<16^p[a+3]<<24}function r(p,a,o,n,d,i){c[p]=c[p]+c[a]+d,c[n]=u(c[n]^c[p],16),c[o]=c[o]+c[n],c[a]=u(c[a]^c[o],12),c[p]=c[p]+c[a]+i,c[n]=u(c[n]^c[p],8),c[o]=c[o]+c[n],c[a]=u(c[a]^c[o],7)}function u(p,a){return p>>>a^p<<32-a}const h=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]),c=new Uint32Array(16),s=new Uint32Array(16);function l(p,a){let o=0;for(o=0;o<8;o++)c[o]=p.h[o],c[o+8]=h[o];for(c[12]^=p.t,c[13]^=p.t/4294967296,a&&(c[14]=~c[14]),o=0;o<16;o++)s[o]=t(p.b,4*o);for(o=0;o<10;o++)r(0,4,8,12,s[f[o*16+0]],s[f[o*16+1]]),r(1,5,9,13,s[f[o*16+2]],s[f[o*16+3]]),r(2,6,10,14,s[f[o*16+4]],s[f[o*16+5]]),r(3,7,11,15,s[f[o*16+6]],s[f[o*16+7]]),r(0,5,10,15,s[f[o*16+8]],s[f[o*16+9]]),r(1,6,11,12,s[f[o*16+10]],s[f[o*16+11]]),r(2,7,8,13,s[f[o*16+12]],s[f[o*16+13]]),r(3,4,9,14,s[f[o*16+14]],s[f[o*16+15]]);for(o=0;o<8;o++)p.h[o]^=c[o]^c[o+8]}function g(p,a){if(!(p>0&&p<=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 n={h:new Uint32Array(h),b:new Uint8Array(64),c:0,t:0,outlen:p};return n.h[0]^=16842752^o<<8^p,o>0&&(b(n,a),n.c=64),n}function b(p,a){for(let o=0;o>2]>>8*(o&3)&255;return a}function k(p,a,o){o=o||32,p=e.normalizeInput(p);const n=g(o,a);return b(n,p),E(n)}function A(p,a,o){const n=k(p,a,o);return e.toHex(n)}return O={blake2s:k,blake2sHex:A,blake2sInit:g,blake2sUpdate:b,blake2sFinal:E},O}var _,K;function ae(){if(K)return _;K=1;const e=le(),t=ce();return _={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},_}var $=ae();const ue=V({bits:24,rounds:23,rightRotations:8,leftRotations:3});function fe(e){const t=$.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 de(e,t){if(!e||e.length===0)return"";const r=e[0];return e.slice(1).map((h,f)=>{const c=r*16777216+(f&16777215),s=ue.encrypt(c,t),l=(h^s)>>>0;try{return String.fromCodePoint(l)}catch{return""}}).join("")}const pe=V();function he(e){const t=$.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 ge(e,t){return e.map(r=>{try{return String.fromCodePoint(pe.decrypt(r,t))}catch{return""}}).join("")}const C="‍​­",P={3:"‍​­᠎‍",6:"‍​­‌‍",7:"‍​­‌‌"},F={0:"PLAIN",1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(F).map(([e,t])=>[t,+e]));const be=Object.entries(P).flatMap(([e,t])=>Object.entries(F).map(([r,u])=>{const h=(+r).toString(e).padStart(4,"0");if(h.length!==4)throw new RangeError(`Cipher ID ${r} exceeds ZWUS-${e}'s signature capacity`);const f=t+S[e].unifier+S[e][0]+Array.from(h,c=>S[e][c]).join("");if(f.length!==11)throw new RangeError("Signatures must contain exactly 11 characters");return{base:e,cipher:u,sig:f,legacy:!1}}));function Y(e,t){let r=e.indexOf(C);for(;r!==-1;){const u=t.find(h=>e.startsWith(h.sig,r)&&(!h.legacyPlain||e[r+h.sig.length]!==S[h.base].unifier));if(u){const{base:h,cipher:f,sig:c,legacy:s}=u;return{base:h,cipher:f,payload:e.slice(r+c.length),sigIdx:r,sigLen:c.length,legacy:s}}r=e.indexOf(C,r+1)}return null}const me=e=>Y(e,be),we=[3,6,7].flatMap(e=>[...[1,2].map(t=>({base:String(e),cipher:F[t],legacy:!0,sig:P[e]+S[e].unifier+S[e][0].repeat(3)+S[e][t]})),{base:String(e),cipher:"PLAIN",sig:P[e],legacy:!0,legacyPlain:!0}]),ye=e=>Y(e,we);function Ee(e){const t=me(e),r=ye(e);return!t||r&&r.sigIdxme(h,e),Y(h)}function Y(n){const{wrap:e,node:l,start:p,endNode:b,end:d}=n;if(!l.isConnected||!b.isConnected){e.remove(),C.delete(n);return}const c=l.parentElement;if(!c||c.checkVisibility&&!c.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})){e.style.display="none";return}const i=document.createRange();try{i.setStart(l,p),i.setEnd(b,Math.min(d,b.nodeValue.length))}catch{e.remove(),C.delete(n);return}let s=i.getBoundingClientRect();if(!s.width&&!s.height&&(s=c.getBoundingClientRect()),!s.width&&!s.height){e.style.display="none";return}if(s.bottom<0||s.top>window.innerHeight||s.right<0||s.left>window.innerWidth){e.style.display="none";return}let h=c;for(;h&&h!==document.body&&h!==document.documentElement;){const k=window.getComputedStyle(h);if(k.overflow!=="visible"||k.overflowX!=="visible"||k.overflowY!=="visible"){const I=h.getBoundingClientRect();if(s.bottomI.bottom||s.rightI.right){e.style.display="none";return}}h=h.parentElement}e.style.display="flex";const g=s.left+(s.width||0)/2,y=s.top;e.style.left=`${g-e.offsetWidth/2}px`,e.style.top=`${y-e.offsetHeight-2}px`}function me(n,e){const{wrap:l,node:p,start:b,endNode:d,end:c}=n,i=document.createRange();i.setStart(p,b),i.setEnd(d,c);const s=i.toString().slice(e.sigLen);let h="";if(e.cipher==="PLAIN")try{h=A.decodeToString(s,e.base)}catch(g){console.error(g)}else{const g=prompt(`inØsight: enter password (${e.cipher}):`);if(!g)return;try{const y=A.decodeToNumberArray(s,e.base);e.cipher==="SPECK48_96CTR"?h=ue(y,ae(g)):e.cipher==="SPECK32_64ECB (insecure)"&&(h=pe(y,de(g)))}catch(y){console.error(y)}if(!h){alert("Decryption failed.");return}}if(h){i.deleteContents();const g=document.createElement("span");g.className="inzerosight-decoded",g.style.color="#00b4d8",g.style.fontWeight="600",g.textContent=` ${h} `,i.insertNode(g),l.remove(),C.delete(n)}}function we(n,e,l){let p=n,b=$(n.nodeValue,e,l);for(;b===p.nodeValue.length;){let d=p.nextSibling,c=!1;for(;(d==null?void 0:d.nodeType)===Node.ELEMENT_NODE&&d.tagName==="WBR";)c=!0,d=d.nextSibling;if(!c||(d==null?void 0:d.nodeType)!==Node.TEXT_NODE)break;const i=$(d.nodeValue,e,0);if(!i)break;p=d,b=i}return{endNode:p,end:b}}function v(n){if(!n||n.nodeType!==Node.TEXT_NODE)return;const e=n.nodeValue;if(!e||!e.includes(N))return;let l=0;for(;l{var d;return e[(d=b.parentElement)==null?void 0:d.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let p;for(;p=l.nextNode();)v(p)}J(document.body);let F;function j(){F||C.size===0||(F=requestAnimationFrame(()=>{F=null,C.forEach(Y)}))}new MutationObserver(n=>{var e;for(const l of[...C])(!l.node.isConnected||!((e=l.node.nodeValue)!=null&&e.startsWith(N,l.start)))&&(l.wrap.remove(),C.delete(l));for(const l of n)if(l.type==="characterData")v(l.target);else for(const p of l.addedNodes)p.nodeType===Node.TEXT_NODE?v(p):p.nodeType===Node.ELEMENT_NODE&&p.id!=="in0-host"&&J(p);j()}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",j,{capture:!0,passive:!0}),window.addEventListener("resize",j,{passive:!0})})(); + `,j.appendChild(e),(document.body||document.documentElement).appendChild(N)}function Se(e,t,r,u,h){for(const b of x)if(b.node===e&&b.start===r)return;ke();const f=document.createElement("div");f.className="in0-wrap";const c=document.createElement("button");c.className="in0-btn",c.textContent=t.cipher==="PLAIN"?"Decode":"Decrypt";const s=document.createElement("span");s.className="in0-badge",s.textContent="Ø",c.appendChild(s);const l=document.createElement("div");l.className="in0-arrow",f.appendChild(c),f.appendChild(l),j.appendChild(f);const g={wrap:f,node:e,start:r,endNode:u,end:h};x.add(g),c.onclick=()=>Ae(g,t),Z(g)}function Z(e){const{wrap:t,node:r,start:u,endNode:h,end:f}=e;if(!r.isConnected||!h.isConnected){t.remove(),x.delete(e);return}const c=r.parentElement;if(!c||c.checkVisibility&&!c.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})){t.style.display="none";return}const s=document.createRange();try{s.setStart(r,u),s.setEnd(h,Math.min(f,h.nodeValue.length))}catch{t.remove(),x.delete(e);return}let l=s.getBoundingClientRect();if(!l.width&&!l.height&&(l=c.getBoundingClientRect()),!l.width&&!l.height){t.style.display="none";return}if(l.bottom<0||l.top>window.innerHeight||l.right<0||l.left>window.innerWidth){t.style.display="none";return}let g=c;for(;g&&g!==document.body&&g!==document.documentElement;){const k=window.getComputedStyle(g);if(k.overflow!=="visible"||k.overflowX!=="visible"||k.overflowY!=="visible"){const A=g.getBoundingClientRect();if(l.bottomA.bottom||l.rightA.right){t.style.display="none";return}}g=g.parentElement}t.style.display="flex";const b=l.left+(l.width||0)/2,E=l.top;t.style.left=`${b-t.offsetWidth/2}px`,t.style.top=`${E-t.offsetHeight-2}px`}function Ae(e,t){const{wrap:r,node:u,start:h,endNode:f,end:c}=e,s=document.createRange();s.setStart(u,h),s.setEnd(f,c);const l=s.toString().slice(t.sigLen);let g="";if(t.cipher==="PLAIN")try{g=S.decodeToString(l,t.base)}catch(b){console.error(b)}else{const b=prompt(`inØsight: enter password (${t.cipher}):`);if(!b)return;try{const E=S.decodeToNumberArray(l,t.base);t.cipher==="SPECK48_96CTR"?g=de(E,fe(b)):t.cipher==="SPECK32_64ECB (insecure)"&&(g=ge(E,he(b)))}catch(E){console.error(E)}if(!g){alert("Decryption failed.");return}}if(g){s.deleteContents();const b=document.createElement("span");b.className="inzerosight-decoded",b.style.color="#00b4d8",b.style.fontWeight="600",b.textContent=` ${g} `,s.insertNode(b),r.remove(),x.delete(e)}}function U(e,t){let r=e[t],u=!1;for(;(r==null?void 0:r.nodeType)===Node.ELEMENT_NODE&&r.tagName==="WBR";)u=!0,r=r[t];return u&&(r==null?void 0:r.nodeType)===Node.TEXT_NODE?r:null}function R(e){if(!e||e.nodeType!==Node.TEXT_NODE)return;for(let f;f=U(e,"previousSibling");)e=f;const t=[e];let r=e.nodeValue;for(let f;f=U(t.at(-1),"nextSibling");)t.push(f),r+=f.nodeValue;if(!r||!r.includes(C))return;const u=(f,c)=>{for(const s of t){if(f{var f;return t[(f=h.parentElement)==null?void 0:f.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let u;for(;u=r.nextNode();)U(u,"previousSibling")||R(u)}Q(document.body);let H;function L(){H||x.size===0||(H=requestAnimationFrame(()=>{H=null,x.forEach(Z)}))}new MutationObserver(e=>{var t;for(const r of[...x]){let u=((t=r.node.nodeValue)==null?void 0:t.slice(r.start))||"";for(let h=r.node;u.length -

inØsight 3.2.0source

+

inØsight 3.3.0source

diff --git a/dist/firefox/index.js b/dist/firefox/index.js index d0f0c10..9b44be8 100644 --- a/dist/firefox/index.js +++ b/dist/firefox/index.js @@ -1,4 +1,4 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))g(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const s of f.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&g(s)}).observe(document,{childList:!0,subtree:!0});function c(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function g(u){if(u.ep)return;u.ep=!0;const f=c(u);fetch(u.href,f)}})();const I={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,c=>(+t==7?ge(c):c.codePointAt(0)).toString(t).split("").map(g=>I[t][g]).join("")).join(I[t].unifier),encodeNumberArray:(e,t=7)=>e.map(c=>c.toString(t).split("").map(g=>I[t][g]).join("")).join(I[t].unifier),decodeToString:(e,t=7)=>I.decodeToNumberArray(e,t).map(c=>String.fromCodePoint(+t==7?he(c):c)).join(""),decodeToNumberArray:(e,t=7)=>e.split(I[t].unifier).map(c=>Array.from(c).map(g=>Object.keys(I[t]).find(u=>I[t][u]===g)).join("")).filter(Boolean).map(c=>parseInt(c,t))},de="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",X=[...new Set([...de,...Array.from({length:95},(e,t)=>String.fromCharCode(t+32))])],pe=new Map(X.map((e,t)=>[e,t])),ge=e=>pe.get(e)??(e.codePointAt(0)<32?e.codePointAt(0)+95:e.codePointAt(0)),he=e=>e<95?X[e].codePointAt(0):e<127?e-95:e,J=65536;function Q(e,t,c){const g=[];for(let u=0;u=55296&&e.charCodeAt(f-1)<=56319&&f--,g.push(I[c](e.slice(u,f),t)),u=f}return g.join(I[t].unifier)}function ee(e,t,c){const g=[],u=I[t].unifier;for(let f=0;f=f?n+1:e.indexOf(u,s)+1||e.length}g.push(I[c](e.slice(f,s),t)),f=s}return c==="decodeToString"?g.join(""):g.flat()}const be=(e,t)=>Q(e,t,"encodeString"),M=(e,t)=>Q(e,t,"encodeNumberArray"),ye=(e,t)=>ee(e,t,"decodeToString"),v=(e,t)=>ee(e,t,"decodeToNumberArray");function me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var F,G;function Ae(){if(G)return F;G=1;function e(t={}){const c=t.bits||16,g=t.rounds||22,u=t.rightRotations||7,f=t.leftRotations||2,s=2**c,n=s-1,a=(l,o)=>l>>o|l<l<>c-o,m=(l,o,r)=>(l=a(l,u),l=l+o&n,l^=r,o=y(o,f),o^=l,[l,o]),w=(l,o,r)=>(o^=l,o=a(o,f),l^=r,l=l-o&n,l=y(l,u),[l,o]);function k(l,o){let r=l[0],d=l[1],i=o[0],h=o.slice(1);[d,r]=m(d,r,i);for(let b=0;b{const d=l([o/s|0,o&n],r);return d[0]*s+d[1]}}return{encrypt:p(k),decrypt:p(E),encryptRaw:k,decryptRaw:E}}return F=e,F}var we=Ae();const te=me(we);var P,K;function ne(){if(K)return P;K=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 c(s){return Array.prototype.map.call(s,function(n){return(n<16?"0":"")+n.toString(16)}).join("")}function g(s){return(4294967296+s).toString(16).substring(1)}function u(s,n,a){let y=` -`+s+" = ";for(let m=0;m=4294967296&&b++,r[d]=h,r[d+1]=b}function c(r,d,i,h){let b=r[d]+i;i<0&&(b+=4294967296);let A=r[d+1]+h;b>=4294967296&&A++,r[d]=b,r[d+1]=A}function g(r,d){return r[d]^r[d+1]<<8^r[d+2]<<16^r[d+3]<<24}function u(r,d,i,h,b,A){const le=y[b],ae=y[b+1],ue=y[A],fe=y[A+1];t(a,r,d),c(a,r,le,ae);let S=a[h]^a[r],C=a[h+1]^a[r+1];a[h]=C,a[h+1]=S,t(a,i,h),S=a[d]^a[i],C=a[d+1]^a[i+1],a[d]=S>>>24^C<<8,a[d+1]=C>>>24^S<<8,t(a,r,d),c(a,r,ue,fe),S=a[h]^a[r],C=a[h+1]^a[r+1],a[h]=S>>>16^C<<16,a[h+1]=C>>>16^S<<16,t(a,i,h),S=a[d]^a[i],C=a[d+1]^a[i+1],a[d]=C>>>31^S<<1,a[d+1]=S>>>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})),a=new Uint32Array(32),y=new Uint32Array(32);function m(r,d){let i=0;for(i=0;i<16;i++)a[i]=r.h[i],a[i+16]=f[i];for(a[24]=a[24]^r.t,a[25]=a[25]^r.t/4294967296,d&&(a[28]=~a[28],a[29]=~a[29]),i=0;i<32;i++)y[i]=g(r.b,4*i);for(i=0;i<12;i++)u(0,8,16,24,n[i*16+0],n[i*16+1]),u(2,10,18,26,n[i*16+2],n[i*16+3]),u(4,12,20,28,n[i*16+4],n[i*16+5]),u(6,14,22,30,n[i*16+6],n[i*16+7]),u(0,10,20,30,n[i*16+8],n[i*16+9]),u(2,12,22,24,n[i*16+10],n[i*16+11]),u(4,14,16,26,n[i*16+12],n[i*16+13]),u(6,8,18,28,n[i*16+14],n[i*16+15]);for(i=0;i<16;i++)r.h[i]=r.h[i]^a[i]^a[i+16]}const w=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 k(r,d,i,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(i&&i.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};w.fill(0),w[0]=r,d&&(w[1]=d.length),w[2]=1,w[3]=1,i&&w.set(i,32),h&&w.set(h,48);for(let A=0;A<16;A++)b.h[A]=f[A]^g(w,A*4);return d&&(E(b,d),b.c=128),b}function E(r,d){for(let i=0;i>2]>>8*(i&3);return d}function l(r,d,i,h,b){i=i||64,r=e.normalizeInput(r),h&&(h=e.normalizeInput(h)),b&&(b=e.normalizeInput(b));const A=k(i,d,h,b);return E(A,r),p(A)}function o(r,d,i,h,b){const A=l(r,d,i,h,b);return e.toHex(A)}return O={blake2b:l,blake2bHex:o,blake2bInit:k,blake2bUpdate:E,blake2bFinal:p},O}var R,z;function ke(){if(z)return R;z=1;const e=ne();function t(p,l){return p[l]^p[l+1]<<8^p[l+2]<<16^p[l+3]<<24}function c(p,l,o,r,d,i){s[p]=s[p]+s[l]+d,s[r]=g(s[r]^s[p],16),s[o]=s[o]+s[r],s[l]=g(s[l]^s[o],12),s[p]=s[p]+s[l]+i,s[r]=g(s[r]^s[p],8),s[o]=s[o]+s[r],s[l]=g(s[l]^s[o],7)}function g(p,l){return p>>>l^p<<32-l}const u=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 a(p,l){let o=0;for(o=0;o<8;o++)s[o]=p.h[o],s[o+8]=u[o];for(s[12]^=p.t,s[13]^=p.t/4294967296,l&&(s[14]=~s[14]),o=0;o<16;o++)n[o]=t(p.b,4*o);for(o=0;o<10;o++)c(0,4,8,12,n[f[o*16+0]],n[f[o*16+1]]),c(1,5,9,13,n[f[o*16+2]],n[f[o*16+3]]),c(2,6,10,14,n[f[o*16+4]],n[f[o*16+5]]),c(3,7,11,15,n[f[o*16+6]],n[f[o*16+7]]),c(0,5,10,15,n[f[o*16+8]],n[f[o*16+9]]),c(1,6,11,12,n[f[o*16+10]],n[f[o*16+11]]),c(2,7,8,13,n[f[o*16+12]],n[f[o*16+13]]),c(3,4,9,14,n[f[o*16+14]],n[f[o*16+15]]);for(o=0;o<8;o++)p.h[o]^=s[o]^s[o+8]}function y(p,l){if(!(p>0&&p<=32))throw new Error("Incorrect output length, should be in [1, 32]");const o=l?l.length:0;if(l&&!(o>0&&o<=32))throw new Error("Incorrect key length, should be in [1, 32]");const r={h:new Uint32Array(u),b:new Uint8Array(64),c:0,t:0,outlen:p};return r.h[0]^=16842752^o<<8^p,o>0&&(m(r,l),r.c=64),r}function m(p,l){for(let o=0;o>2]>>8*(o&3)&255;return l}function k(p,l,o){o=o||32,p=e.normalizeInput(p);const r=y(o,l);return m(r,p),w(r)}function E(p,l,o){const r=k(p,l,o);return e.toHex(r)}return R={blake2s:k,blake2sHex:E,blake2sInit:y,blake2sUpdate:m,blake2sFinal:w},R}var _,$;function Ee(){if($)return _;$=1;const e=Ie(),t=ke();return _={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},_}var re=Ee();const oe=te({bits:24,rounds:23,rightRotations:8,leftRotations:3});function W(e){const t=re.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 Se(e,t){const c=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]&16777215,g=Array.from(e,(u,f)=>{const s=c*16777216+(f&16777215),n=oe.encrypt(s,t);return(u.codePointAt(0)^n)>>>0});return[c,...g]}function Ce(e,t){if(!e||e.length===0)return"";const c=e[0];return e.slice(1).map((u,f)=>{const s=c*16777216+(f&16777215),n=oe.encrypt(s,t),a=(u^n)>>>0;try{return String.fromCodePoint(a)}catch{return""}}).join("")}const ie=te();function Y(e){const t=re.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 Be(e,t){return Array.from(e,c=>ie.encrypt(c.codePointAt(0),t))}function Te(e,t){return e.map(c=>{try{return String.fromCodePoint(ie.decrypt(c,t))}catch{return""}}).join("")}const j="‍​­",B={3:"‍​­᠎‍",6:"‍​­‌‍",7:"‍​­‌‌"},ce={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"},Ue=Object.fromEntries(Object.entries(ce).map(([e,t])=>[t,+e]));function De(e,t){let c=B[e];const g=Ue[t];if(g){const u=Array.from(g.toString(e).padStart(3,"0"),f=>I[e][f]).join("");c+=I[e].unifier+I[e][0]+u}return c}function Fe(e){let t=e.indexOf(j),c;for(;t!==-1&&(c=Object.keys(B).find(f=>e.startsWith(B[f],t)),!c);)t=e.indexOf(j,t+j.length);if(!c)return null;const g=e.slice(t+B[c].length),u=I[c].unifier+I[c][0];if(g.startsWith(u)){const s=Array.from(g.slice(u.length,u.length+3)).map(m=>Object.keys(I[c]).find(w=>I[c][w]===m)).join(""),n=ce[parseInt(s,c)];if(!n)return{base:c,cipher:"PLAIN",payload:g,sigIdx:t,sigLen:B[c].length};const a=g.slice(u.length+3),y=B[c].length+u.length+3;return{base:c,cipher:n,payload:a,sigIdx:t,sigLen:y}}return{base:c,cipher:"PLAIN",payload:g,sigIdx:t,sigLen:B[c].length}}const T=document.getElementById("textarea"),N=document.getElementById("encoder"),L=document.getElementById("cipher"),H=document.getElementById("sign"),D=document.getElementById("sigDetect"),U=document.getElementById("notice"),Pe=["encodeButton","decodeButton"].map(e=>document.getElementById(e)),V=[...Pe,N,L,H];document.getElementById("encodeButton").addEventListener("click",se);document.getElementById("decodeButton").addEventListener("click",se);H.addEventListener("click",e=>e.target.classList.toggle("on"));let Z,x=!1;async function se(e){if(x)return;if(clearTimeout(Z),D.className="",T.value===""){T.value="The text box is empty.";return}const t=e.target.id==="encodeButton"?"NO":"YES";let c=Re(),g=N.value.split("-")[1],u=T.value;if(t==="YES"){const n=Fe(u);if(n){if(n.base!==g||n.cipher&&n.cipher!==c){const a=n.cipher&&n.cipher!=="PLAIN"?` (${n.cipher})`:"";D.textContent=`ZWUS-${n.base}${a} signature detected`,D.className="show",Z=setTimeout(()=>D.className="",2e3)}g=n.base,N.value="ZWUS-"+g,n.cipher&&(c=n.cipher,L.value=c),u=u.slice(0,n.sigIdx)+n.payload}}const f=c!=="PLAIN",s=f&&prompt("enter password.");if(!(f&&!s)){x=!0,V.forEach(n=>n.disabled=!0),U.textContent="Processing…";try{let n=await _e[t][c](u,g,s);if(t==="NO"&&H.classList.contains("on")&&(n=De(g,c)+n),T.value=n,t==="NO"){U.textContent="Copying…";const a=await Oe(n);a&&n.length<=65536&&(T.value=`Copied to your clipboard. - A copy has been placed between these brackets [`+n+"]"),U.textContent=a?`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 Oe(e){var t;if((t=navigator.clipboard)!=null&&t.writeText){let c;try{return await Promise.race([navigator.clipboard.writeText(e),new Promise((g,u)=>c=setTimeout(()=>u(new Error("Copy timed out")),5e3))]),!0}catch(g){console.warn("Clipboard copy failed",g)}finally{clearTimeout(c)}}if(e.length>65536)return!1;T.select();try{return document.execCommand("copy")}catch(c){return console.warn("Clipboard copy failed",c),!1}}function Re(){return L.value}const _e={NO:{PLAIN:(e,t)=>be(e,t),SPECK48_96CTR:(e,t,c)=>M(Se(e,W(c)),t),"SPECK32_64ECB (insecure)":(e,t,c)=>M(Be(e,Y(c)),t)},YES:{PLAIN:(e,t)=>ye(e,t),SPECK48_96CTR:async(e,t,c)=>Ce(await v(e,t),W(c)),"SPECK32_64ECB (insecure)":async(e,t,c)=>Te(await v(e,t),Y(c))}}; +(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=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=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<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{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=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>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>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.sigIdxdocument.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))}}; diff --git a/dist/firefox/manifest.json b/dist/firefox/manifest.json index 52e92a4..797bef1 100644 --- a/dist/firefox/manifest.json +++ b/dist/firefox/manifest.json @@ -1 +1 @@ -{"name":"inØsight","version":"3.2.0","author":"planetrenox@pm.me","homepage_url":"https://github.com/inzerosight/inzerosight","description":"Communicate undetected in plain sight.","icons":{"48":"icon_500.png"},"permissions":["clipboardWrite"],"manifest_version":2,"browser_action":{"browser_style":false,"default_icon":"icon_500.png","default_title":"inØsight","default_popup":"index.html"},"content_security_policy":"script-src 'self'; style-src 'self';","browser_specific_settings":{"gecko":{"id":"{0a73f41c-c59c-404b-9e07-f7392fa830d4}"}},"content_scripts":[{"matches":[""],"js":["content.js"],"run_at":"document_idle"}]} \ No newline at end of file +{"name":"inØsight","version":"3.3.0","author":"planetrenox@pm.me","homepage_url":"https://github.com/inzerosight/inzerosight","description":"Communicate undetected in plain sight.","icons":{"48":"icon_500.png"},"permissions":["clipboardWrite"],"manifest_version":2,"browser_action":{"browser_style":false,"default_icon":"icon_500.png","default_title":"inØsight","default_popup":"index.html"},"content_security_policy":"script-src 'self'; style-src 'self';","browser_specific_settings":{"gecko":{"id":"{0a73f41c-c59c-404b-9e07-f7392fa830d4}"}},"content_scripts":[{"matches":[""],"js":["content.js"],"run_at":"document_idle"}]} \ No newline at end of file diff --git a/dist/inzerosight-chrome.zip b/dist/inzerosight-chrome.zip index 25a043e..5dd5088 100644 Binary files a/dist/inzerosight-chrome.zip and b/dist/inzerosight-chrome.zip differ diff --git a/dist/inzerosight-firefox-source.zip b/dist/inzerosight-firefox-source.zip deleted file mode 100644 index b2481fa..0000000 Binary files a/dist/inzerosight-firefox-source.zip and /dev/null differ diff --git a/dist/inzerosight-firefox.zip b/dist/inzerosight-firefox.zip index 37d61ef..6c09cb7 100644 Binary files a/dist/inzerosight-firefox.zip and b/dist/inzerosight-firefox.zip differ diff --git a/dist/web/assets/index-DlLeEfTp.js b/dist/web/assets/index-DlLeEfTp.js new file mode 100644 index 0000000..9b44be8 --- /dev/null +++ b/dist/web/assets/index-DlLeEfTp.js @@ -0,0 +1,4 @@ +(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=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=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<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{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=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>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>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.sigIdxdocument.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))}}; diff --git a/dist/web/assets/index-G7fqkm88.js b/dist/web/assets/index-G7fqkm88.js deleted file mode 100644 index d0f0c10..0000000 --- a/dist/web/assets/index-G7fqkm88.js +++ /dev/null @@ -1,4 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))g(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const s of f.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&g(s)}).observe(document,{childList:!0,subtree:!0});function c(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function g(u){if(u.ep)return;u.ep=!0;const f=c(u);fetch(u.href,f)}})();const I={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,c=>(+t==7?ge(c):c.codePointAt(0)).toString(t).split("").map(g=>I[t][g]).join("")).join(I[t].unifier),encodeNumberArray:(e,t=7)=>e.map(c=>c.toString(t).split("").map(g=>I[t][g]).join("")).join(I[t].unifier),decodeToString:(e,t=7)=>I.decodeToNumberArray(e,t).map(c=>String.fromCodePoint(+t==7?he(c):c)).join(""),decodeToNumberArray:(e,t=7)=>e.split(I[t].unifier).map(c=>Array.from(c).map(g=>Object.keys(I[t]).find(u=>I[t][u]===g)).join("")).filter(Boolean).map(c=>parseInt(c,t))},de="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",X=[...new Set([...de,...Array.from({length:95},(e,t)=>String.fromCharCode(t+32))])],pe=new Map(X.map((e,t)=>[e,t])),ge=e=>pe.get(e)??(e.codePointAt(0)<32?e.codePointAt(0)+95:e.codePointAt(0)),he=e=>e<95?X[e].codePointAt(0):e<127?e-95:e,J=65536;function Q(e,t,c){const g=[];for(let u=0;u=55296&&e.charCodeAt(f-1)<=56319&&f--,g.push(I[c](e.slice(u,f),t)),u=f}return g.join(I[t].unifier)}function ee(e,t,c){const g=[],u=I[t].unifier;for(let f=0;f=f?n+1:e.indexOf(u,s)+1||e.length}g.push(I[c](e.slice(f,s),t)),f=s}return c==="decodeToString"?g.join(""):g.flat()}const be=(e,t)=>Q(e,t,"encodeString"),M=(e,t)=>Q(e,t,"encodeNumberArray"),ye=(e,t)=>ee(e,t,"decodeToString"),v=(e,t)=>ee(e,t,"decodeToNumberArray");function me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var F,G;function Ae(){if(G)return F;G=1;function e(t={}){const c=t.bits||16,g=t.rounds||22,u=t.rightRotations||7,f=t.leftRotations||2,s=2**c,n=s-1,a=(l,o)=>l>>o|l<l<>c-o,m=(l,o,r)=>(l=a(l,u),l=l+o&n,l^=r,o=y(o,f),o^=l,[l,o]),w=(l,o,r)=>(o^=l,o=a(o,f),l^=r,l=l-o&n,l=y(l,u),[l,o]);function k(l,o){let r=l[0],d=l[1],i=o[0],h=o.slice(1);[d,r]=m(d,r,i);for(let b=0;b{const d=l([o/s|0,o&n],r);return d[0]*s+d[1]}}return{encrypt:p(k),decrypt:p(E),encryptRaw:k,decryptRaw:E}}return F=e,F}var we=Ae();const te=me(we);var P,K;function ne(){if(K)return P;K=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 c(s){return Array.prototype.map.call(s,function(n){return(n<16?"0":"")+n.toString(16)}).join("")}function g(s){return(4294967296+s).toString(16).substring(1)}function u(s,n,a){let y=` -`+s+" = ";for(let m=0;m=4294967296&&b++,r[d]=h,r[d+1]=b}function c(r,d,i,h){let b=r[d]+i;i<0&&(b+=4294967296);let A=r[d+1]+h;b>=4294967296&&A++,r[d]=b,r[d+1]=A}function g(r,d){return r[d]^r[d+1]<<8^r[d+2]<<16^r[d+3]<<24}function u(r,d,i,h,b,A){const le=y[b],ae=y[b+1],ue=y[A],fe=y[A+1];t(a,r,d),c(a,r,le,ae);let S=a[h]^a[r],C=a[h+1]^a[r+1];a[h]=C,a[h+1]=S,t(a,i,h),S=a[d]^a[i],C=a[d+1]^a[i+1],a[d]=S>>>24^C<<8,a[d+1]=C>>>24^S<<8,t(a,r,d),c(a,r,ue,fe),S=a[h]^a[r],C=a[h+1]^a[r+1],a[h]=S>>>16^C<<16,a[h+1]=C>>>16^S<<16,t(a,i,h),S=a[d]^a[i],C=a[d+1]^a[i+1],a[d]=C>>>31^S<<1,a[d+1]=S>>>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})),a=new Uint32Array(32),y=new Uint32Array(32);function m(r,d){let i=0;for(i=0;i<16;i++)a[i]=r.h[i],a[i+16]=f[i];for(a[24]=a[24]^r.t,a[25]=a[25]^r.t/4294967296,d&&(a[28]=~a[28],a[29]=~a[29]),i=0;i<32;i++)y[i]=g(r.b,4*i);for(i=0;i<12;i++)u(0,8,16,24,n[i*16+0],n[i*16+1]),u(2,10,18,26,n[i*16+2],n[i*16+3]),u(4,12,20,28,n[i*16+4],n[i*16+5]),u(6,14,22,30,n[i*16+6],n[i*16+7]),u(0,10,20,30,n[i*16+8],n[i*16+9]),u(2,12,22,24,n[i*16+10],n[i*16+11]),u(4,14,16,26,n[i*16+12],n[i*16+13]),u(6,8,18,28,n[i*16+14],n[i*16+15]);for(i=0;i<16;i++)r.h[i]=r.h[i]^a[i]^a[i+16]}const w=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 k(r,d,i,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(i&&i.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};w.fill(0),w[0]=r,d&&(w[1]=d.length),w[2]=1,w[3]=1,i&&w.set(i,32),h&&w.set(h,48);for(let A=0;A<16;A++)b.h[A]=f[A]^g(w,A*4);return d&&(E(b,d),b.c=128),b}function E(r,d){for(let i=0;i>2]>>8*(i&3);return d}function l(r,d,i,h,b){i=i||64,r=e.normalizeInput(r),h&&(h=e.normalizeInput(h)),b&&(b=e.normalizeInput(b));const A=k(i,d,h,b);return E(A,r),p(A)}function o(r,d,i,h,b){const A=l(r,d,i,h,b);return e.toHex(A)}return O={blake2b:l,blake2bHex:o,blake2bInit:k,blake2bUpdate:E,blake2bFinal:p},O}var R,z;function ke(){if(z)return R;z=1;const e=ne();function t(p,l){return p[l]^p[l+1]<<8^p[l+2]<<16^p[l+3]<<24}function c(p,l,o,r,d,i){s[p]=s[p]+s[l]+d,s[r]=g(s[r]^s[p],16),s[o]=s[o]+s[r],s[l]=g(s[l]^s[o],12),s[p]=s[p]+s[l]+i,s[r]=g(s[r]^s[p],8),s[o]=s[o]+s[r],s[l]=g(s[l]^s[o],7)}function g(p,l){return p>>>l^p<<32-l}const u=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 a(p,l){let o=0;for(o=0;o<8;o++)s[o]=p.h[o],s[o+8]=u[o];for(s[12]^=p.t,s[13]^=p.t/4294967296,l&&(s[14]=~s[14]),o=0;o<16;o++)n[o]=t(p.b,4*o);for(o=0;o<10;o++)c(0,4,8,12,n[f[o*16+0]],n[f[o*16+1]]),c(1,5,9,13,n[f[o*16+2]],n[f[o*16+3]]),c(2,6,10,14,n[f[o*16+4]],n[f[o*16+5]]),c(3,7,11,15,n[f[o*16+6]],n[f[o*16+7]]),c(0,5,10,15,n[f[o*16+8]],n[f[o*16+9]]),c(1,6,11,12,n[f[o*16+10]],n[f[o*16+11]]),c(2,7,8,13,n[f[o*16+12]],n[f[o*16+13]]),c(3,4,9,14,n[f[o*16+14]],n[f[o*16+15]]);for(o=0;o<8;o++)p.h[o]^=s[o]^s[o+8]}function y(p,l){if(!(p>0&&p<=32))throw new Error("Incorrect output length, should be in [1, 32]");const o=l?l.length:0;if(l&&!(o>0&&o<=32))throw new Error("Incorrect key length, should be in [1, 32]");const r={h:new Uint32Array(u),b:new Uint8Array(64),c:0,t:0,outlen:p};return r.h[0]^=16842752^o<<8^p,o>0&&(m(r,l),r.c=64),r}function m(p,l){for(let o=0;o>2]>>8*(o&3)&255;return l}function k(p,l,o){o=o||32,p=e.normalizeInput(p);const r=y(o,l);return m(r,p),w(r)}function E(p,l,o){const r=k(p,l,o);return e.toHex(r)}return R={blake2s:k,blake2sHex:E,blake2sInit:y,blake2sUpdate:m,blake2sFinal:w},R}var _,$;function Ee(){if($)return _;$=1;const e=Ie(),t=ke();return _={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},_}var re=Ee();const oe=te({bits:24,rounds:23,rightRotations:8,leftRotations:3});function W(e){const t=re.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 Se(e,t){const c=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]&16777215,g=Array.from(e,(u,f)=>{const s=c*16777216+(f&16777215),n=oe.encrypt(s,t);return(u.codePointAt(0)^n)>>>0});return[c,...g]}function Ce(e,t){if(!e||e.length===0)return"";const c=e[0];return e.slice(1).map((u,f)=>{const s=c*16777216+(f&16777215),n=oe.encrypt(s,t),a=(u^n)>>>0;try{return String.fromCodePoint(a)}catch{return""}}).join("")}const ie=te();function Y(e){const t=re.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 Be(e,t){return Array.from(e,c=>ie.encrypt(c.codePointAt(0),t))}function Te(e,t){return e.map(c=>{try{return String.fromCodePoint(ie.decrypt(c,t))}catch{return""}}).join("")}const j="‍​­",B={3:"‍​­᠎‍",6:"‍​­‌‍",7:"‍​­‌‌"},ce={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"},Ue=Object.fromEntries(Object.entries(ce).map(([e,t])=>[t,+e]));function De(e,t){let c=B[e];const g=Ue[t];if(g){const u=Array.from(g.toString(e).padStart(3,"0"),f=>I[e][f]).join("");c+=I[e].unifier+I[e][0]+u}return c}function Fe(e){let t=e.indexOf(j),c;for(;t!==-1&&(c=Object.keys(B).find(f=>e.startsWith(B[f],t)),!c);)t=e.indexOf(j,t+j.length);if(!c)return null;const g=e.slice(t+B[c].length),u=I[c].unifier+I[c][0];if(g.startsWith(u)){const s=Array.from(g.slice(u.length,u.length+3)).map(m=>Object.keys(I[c]).find(w=>I[c][w]===m)).join(""),n=ce[parseInt(s,c)];if(!n)return{base:c,cipher:"PLAIN",payload:g,sigIdx:t,sigLen:B[c].length};const a=g.slice(u.length+3),y=B[c].length+u.length+3;return{base:c,cipher:n,payload:a,sigIdx:t,sigLen:y}}return{base:c,cipher:"PLAIN",payload:g,sigIdx:t,sigLen:B[c].length}}const T=document.getElementById("textarea"),N=document.getElementById("encoder"),L=document.getElementById("cipher"),H=document.getElementById("sign"),D=document.getElementById("sigDetect"),U=document.getElementById("notice"),Pe=["encodeButton","decodeButton"].map(e=>document.getElementById(e)),V=[...Pe,N,L,H];document.getElementById("encodeButton").addEventListener("click",se);document.getElementById("decodeButton").addEventListener("click",se);H.addEventListener("click",e=>e.target.classList.toggle("on"));let Z,x=!1;async function se(e){if(x)return;if(clearTimeout(Z),D.className="",T.value===""){T.value="The text box is empty.";return}const t=e.target.id==="encodeButton"?"NO":"YES";let c=Re(),g=N.value.split("-")[1],u=T.value;if(t==="YES"){const n=Fe(u);if(n){if(n.base!==g||n.cipher&&n.cipher!==c){const a=n.cipher&&n.cipher!=="PLAIN"?` (${n.cipher})`:"";D.textContent=`ZWUS-${n.base}${a} signature detected`,D.className="show",Z=setTimeout(()=>D.className="",2e3)}g=n.base,N.value="ZWUS-"+g,n.cipher&&(c=n.cipher,L.value=c),u=u.slice(0,n.sigIdx)+n.payload}}const f=c!=="PLAIN",s=f&&prompt("enter password.");if(!(f&&!s)){x=!0,V.forEach(n=>n.disabled=!0),U.textContent="Processing…";try{let n=await _e[t][c](u,g,s);if(t==="NO"&&H.classList.contains("on")&&(n=De(g,c)+n),T.value=n,t==="NO"){U.textContent="Copying…";const a=await Oe(n);a&&n.length<=65536&&(T.value=`Copied to your clipboard. - A copy has been placed between these brackets [`+n+"]"),U.textContent=a?`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 Oe(e){var t;if((t=navigator.clipboard)!=null&&t.writeText){let c;try{return await Promise.race([navigator.clipboard.writeText(e),new Promise((g,u)=>c=setTimeout(()=>u(new Error("Copy timed out")),5e3))]),!0}catch(g){console.warn("Clipboard copy failed",g)}finally{clearTimeout(c)}}if(e.length>65536)return!1;T.select();try{return document.execCommand("copy")}catch(c){return console.warn("Clipboard copy failed",c),!1}}function Re(){return L.value}const _e={NO:{PLAIN:(e,t)=>be(e,t),SPECK48_96CTR:(e,t,c)=>M(Se(e,W(c)),t),"SPECK32_64ECB (insecure)":(e,t,c)=>M(Be(e,Y(c)),t)},YES:{PLAIN:(e,t)=>ye(e,t),SPECK48_96CTR:async(e,t,c)=>Ce(await v(e,t),W(c)),"SPECK32_64ECB (insecure)":async(e,t,c)=>Te(await v(e,t),Y(c))}}; diff --git a/dist/web/index.html b/dist/web/index.html index 35b4778..d7abffb 100644 --- a/dist/web/index.html +++ b/dist/web/index.html @@ -3,11 +3,11 @@ - + -

inØsight 3.2.0source

+

inØsight 3.3.0source

diff --git a/docs/zwus.md b/docs/zwus.md index d161e4f..9a724f6 100644 --- a/docs/zwus.md +++ b/docs/zwus.md @@ -15,6 +15,30 @@ Choosing the right ZWUS base depends on platform compatibility. If you enable **Sign** when encoding, an invisible signature is attached to the secret message. When decoding—either in the extension popup or via the on-screen overlay—inØsight automatically identifies the base and cipher. +### Signature format + +New signatures contain exactly **11 zero-width characters**: + +`standard header (5) + unifier (1) + zero digit (1) + mode ID (4)` + +The five-character standard headers are unchanged. The unifier and digits use the selected standard's alphabet. Mode IDs are encoded in that standard's base and padded to exactly four digits: + +| Mode ID | Mode | +| :--- | :--- | +| `0000` | PLAIN | +| `0001` | SPECK48_96CTR | +| `0002` | SPECK32_64ECB (insecure) | + +Detection requires an exact match to one of the nine registered signatures (three standards × three modes). Unknown IDs and partial headers are not modern signatures. Characters after a matched signature belong to the payload; they never extend the signature. PLAIN uses the same header format as the ciphers but does not encrypt the payload. + +### Legacy signatures + +For compatibility, inØsight still reads the old five-character PLAIN headers and ten-character encrypted headers for ZWUS-3, ZWUS-6, and ZWUS-7. New encoding always writes the 11-character format. Complete modern signatures take priority within an uninterrupted zero-width run. Legacy messages separated from modern messages by visible text remain independently detectable. + +Legacy recognition is isolated in `LEGACY_SIGNATURES` and `parseLegacySig` in `sig.js`, with explicitly labeled legacy tests. To retire it, remove that registry, reader, legacy tests, and the `legacyPlain` condition in `findSig`, then make `parseSig` use only `parseModernSig`. Future standards must not be added to the legacy registry. + +Incomplete or unknown extended headers do not fall back to legacy PLAIN. Exact legacy encrypted headers remain recognized, with everything after their tenth character treated as payload. + --- ## Unicode Alphabet by Standard diff --git a/index.html b/index.html index ffb6273..4d7ec7a 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ -

inØsight 3.2.0source

+

inØsight 3.3.0source

diff --git a/package-lock.json b/package-lock.json index 05e871e..8296187 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "inzerosight", - "version": "3.2.0", + "version": "3.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "inzerosight", - "version": "3.2.0", + "version": "3.3.0", "dependencies": { "blakejs": "1.2.1", "generic-speck": "1.1.1", diff --git a/package.json b/package.json index e947cb4..18abafd 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "inzerosight", - "version": "3.2.0", + "version": "3.3.0", "private": true, "type": "module", "scripts": { + "test": "bun test sig.test.js content.test.js", "dev": "vite --mode chrome", "build:web": "vite build --mode web", "build:firefox": "vite build --mode firefox", diff --git a/sig.js b/sig.js index d99e890..5d25589 100644 --- a/sig.js +++ b/sig.js @@ -9,6 +9,7 @@ export const SIG = { }; export const CIPHERS = { + 0: 'PLAIN', 1: 'SPECK48_96CTR', 2: 'SPECK32_64ECB (insecure)' }; @@ -17,36 +18,59 @@ export const CIPHER_TO_ID = Object.fromEntries( Object.entries(CIPHERS).map(([k, v]) => [v, +k]) ); +const SIGNATURES = Object.entries(SIG).flatMap(([base, prefix]) => + Object.entries(CIPHERS).map(([id, cipher]) => { + const digits = (+id).toString(base).padStart(4, '0'); + if (digits.length !== 4) throw new RangeError(`Cipher ID ${id} exceeds ZWUS-${base}'s signature capacity`); + const sig = prefix + zwus[base].unifier + zwus[base][0] + + Array.from(digits, d => zwus[base][d]).join(''); + if (sig.length !== 11) throw new RangeError('Signatures must contain exactly 11 characters'); + return { base, cipher, sig, legacy: false }; + }) +); + export function makeSig(base, cipher) { - let s = SIG[base]; - const id = CIPHER_TO_ID[cipher]; - if (id) { - const zwDigits = Array.from(id.toString(base).padStart(3, '0'), d => zwus[base][d]).join(''); - s += zwus[base].unifier + zwus[base][0] + zwDigits; - } - return s; + const entry = SIGNATURES.find(s => s.base === String(base) && s.cipher === cipher); + if (!entry) throw new RangeError(`Unsupported signature: ZWUS-${base}, ${cipher}`); + return entry.sig; } -export function parseSig(text) { - let sigIdx = text.indexOf(SIG_PREFIX), base; +function findSig(text, signatures) { + let sigIdx = text.indexOf(SIG_PREFIX); while (sigIdx !== -1) { - base = Object.keys(SIG).find(b => text.startsWith(SIG[b], sigIdx)); - if (base) break; - sigIdx = text.indexOf(SIG_PREFIX, sigIdx + SIG_PREFIX.length); + const entry = signatures.find(s => text.startsWith(s.sig, sigIdx) && + (!s.legacyPlain || text[sigIdx + s.sig.length] !== zwus[s.base].unifier)); + if (entry) { + const { base, cipher, sig, legacy } = entry; + return { base, cipher, payload: text.slice(sigIdx + sig.length), sigIdx, sigLen: sig.length, legacy }; + } + sigIdx = text.indexOf(SIG_PREFIX, sigIdx + 1); } - if (!base) return null; - const after = text.slice(sigIdx + SIG[base].length); - const barrier = zwus[base].unifier + zwus[base][0]; - if (after.startsWith(barrier)) { - const zwDigits = Array.from(after.slice(barrier.length, barrier.length + 3)); - const digits = zwDigits.map(z => Object.keys(zwus[base]).find(k => zwus[base][k] === z)).join(''); - const cipher = CIPHERS[parseInt(digits, base)]; - if (!cipher) return { base, cipher: 'PLAIN', payload: after, sigIdx, sigLen: SIG[base].length }; - const payload = after.slice(barrier.length + 3); - const sigLen = SIG[base].length + barrier.length + 3; - return { base, cipher, payload, sigIdx, sigLen }; - } - return { base, cipher: 'PLAIN', payload: after, sigIdx, sigLen: SIG[base].length }; + return null; +} + +// Current format: match only complete, registered 11-character signatures. +export const parseModernSig = text => findSig(text, SIGNATURES); + +// Legacy compatibility: remove this registry, reader, and parseSig fallback together. +// Keep the supported bases and cipher IDs frozen; future standards use only the current format. +const LEGACY_SIGNATURES = [3, 6, 7].flatMap(base => [ + ...[1, 2].map(id => ({ + base: String(base), cipher: CIPHERS[id], legacy: true, + sig: SIG[base] + zwus[base].unifier + zwus[base][0].repeat(3) + zwus[base][id] + })), + { base: String(base), cipher: 'PLAIN', sig: SIG[base], legacy: true, legacyPlain: true } +]); + +// Legacy plaintext never starts with a unifier; do not downgrade incomplete/unknown extensions. +export const parseLegacySig = text => findSig(text, LEGACY_SIGNATURES); +export function parseSig(text) { + const modern = parseModernSig(text), legacy = parseLegacySig(text); + if (!modern) return legacy; + // Legacy messages separated by visible text still need their own overlay. + if (legacy && legacy.sigIdx < modern.sigIdx && + getPayloadEnd(text, legacy.base, legacy.sigIdx + legacy.sigLen) < modern.sigIdx) return legacy; + return modern; } export function getPayloadEnd(text, base, startOffset) { diff --git a/sig.test.js b/sig.test.js new file mode 100644 index 0000000..125d88d --- /dev/null +++ b/sig.test.js @@ -0,0 +1,133 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import zwus from 'zwus'; +import * as chunked from './chunked.js'; +import * as ctr from './speck48_96ctr.js'; +import * as ecb from './speck32_64ecb.js'; +import { makeSig, parseSig, parseModernSig, parseLegacySig, getPayloadEnd } from './sig.js'; + +// Frozen wire-format fixtures, independent of the signature registry. +const HEADERS = { + 3: '\u200D\u200B\u00AD\u180E\u200D', + 6: '\u200D\u200B\u00AD\u200C\u200D', + 7: '\u200D\u200B\u00AD\u200C\u200C' +}; +const MODES = ['PLAIN', 'SPECK48_96CTR', 'SPECK32_64ECB (insecure)']; +const MESSAGE = 'tt\0 Hello, 世界 🌍\n'; +const key = 'signature regression'; + +for (const base of [3, 6, 7]) { + const z = zwus[base], header = HEADERS[base]; + const extended = digits => header + z.unifier + z[0] + + Array.from(digits, d => z[d]).join(''); + + test(`ZWUS-${base}: exact 11-character headers and round trips for every mode`, () => { + for (const [id, cipher] of MODES.entries()) { + const expected = extended('000' + id); + assert.equal(makeSig(base, cipher), expected); + assert.equal(makeSig(String(base), cipher).length, 11); + const engine = [null, ctr, ecb][id]; + const payload = engine ? chunked.encodeNumberArray(engine.encrypt(MESSAGE, engine.getKey(key)), base) : + chunked.encodeString(MESSAGE, base); + const parsed = parseSig('visible ' + expected + payload + ' suffix'); + assert.deepEqual(parsed, { + base: String(base), cipher, payload: payload + ' suffix', sigIdx: 8, sigLen: 11, legacy: false + }); + const start = parsed.sigIdx + parsed.sigLen; + const source = 'visible ' + expected + payload + ' suffix'; + const end = getPayloadEnd(source, base, start); + assert.equal(source.slice(start, end), payload); + const decoded = engine ? engine.decrypt(chunked.decodeToNumberArray(parsed.payload, base), engine.getKey(key)) : + chunked.decodeToString(parsed.payload, base); + assert.equal(decoded, MESSAGE); + } + }); + + test(`ZWUS-${base}: modern reader rejects every unregistered four-digit ID`, () => { + for (let id = 3; id < base ** 4; id++) + assert.equal(parseModernSig(extended(id.toString(base).padStart(4, '0'))), null, `ID ${id}`); + }); + + test(`ZWUS-${base}: modern reader requires every character to match`, () => { + const sig = extended('0000'); + for (let end = 0; end < sig.length; end++) + assert.equal(parseModernSig(sig.slice(0, end)), null); + for (let i = 0; i < sig.length; i++) + assert.equal(parseModernSig(sig.slice(0, i) + 'x' + sig.slice(i + 1)), null); + assert.equal(parseModernSig(extended('10000')), null); + assert.equal(parseSig(extended('0000') + z[2]).sigLen, 11); + assert.equal(parseSig(extended('0000') + z[2]).payload, z[2]); + }); + + test(`ZWUS-${base}: malformed extensions do not fall back to legacy PLAIN`, () => { + for (const tail of [z.unifier, z.unifier + z[0], z.unifier + z[0].repeat(4), + z.unifier + z[0] + 'xxx', z.unifier + z[0] + z[2].repeat(4)]) + assert.equal(parseSig(header + tail), null); + }); + + test(`ZWUS-${base}: legacy five-character PLAIN stays readable`, () => { + const payload = zwus.encodeString(MESSAGE, base); + const parsed = parseSig(header + payload); + assert.deepEqual(parsed, { + base: String(base), cipher: 'PLAIN', payload, sigIdx: 0, sigLen: 5, legacy: true + }); + assert.equal(zwus.decodeToString(parsed.payload, base), MESSAGE); + assert.equal(parseModernSig(header + payload), null); + }); + + test(`ZWUS-${base}: legacy ten-character encrypted signatures stay readable`, () => { + for (const [id, engine] of [[1, ctr], [2, ecb]]) { + const sig = extended('00' + id); + const payload = zwus.encodeNumberArray(engine.encrypt(MESSAGE, engine.getKey(key)), base); + const parsed = parseSig(sig + payload); + assert.equal(parsed.cipher, MODES[id]); + assert.equal(parsed.sigLen, 10); + assert.equal(parsed.legacy, true); + assert.equal(parsed.payload, payload); + assert.equal(engine.decrypt(zwus.decodeToNumberArray(parsed.payload, base), engine.getKey(key)), MESSAGE); + // A legacy header's next digit is payload, even if all 11 characters resemble a future ID. + assert.equal(parseLegacySig(sig + z[0]).payload, z[0]); + } + }); + + test(`ZWUS-${base}: complete modern signatures take priority and preserve offsets`, () => { + const sig = extended('0000'), payload = zwus.encodeString('hello', base); + const prefix = header + z.unifier + 'broken '; + const parsed = parseSig(prefix + sig + payload); + assert.equal(parsed.sigIdx, prefix.length); + assert.equal(parsed.legacy, false); + assert.equal(parsed.payload, payload); + }); + + test(`ZWUS-${base}: legacy and modern messages separated by visible text remain discoverable`, () => { + const payload = zwus.encodeString('hello', base); + const legacy = header + payload, modern = extended('0000') + payload; + const text = legacy + ' and ' + modern; + const first = parseSig(text); + assert.equal(first.legacy, true); + assert.equal(first.sigIdx, 0); + const end = getPayloadEnd(text, base, first.sigLen); + assert.equal(end, legacy.length); + assert.equal(parseSig(text.slice(end)).legacy, false); + }); + + test(`ZWUS-${base}: empty and chunked payloads preserve their contents`, () => { + const sig = makeSig(base, 'PLAIN'); + assert.equal(parseSig(sig).payload, ''); + const text = 't'.repeat(65535) + '🌍\0'; + assert.equal(chunked.decodeToString(parseSig(sig + chunked.encodeString(text, base)).payload, base), text); + }); +} + +test('unknown standards and modes cannot generate signatures', () => { + assert.throws(() => makeSig(8, 'PLAIN'), RangeError); + assert.throws(() => makeSig(7, 'unknown'), RangeError); + assert.throws(() => makeSig(7), RangeError); +}); + +test('legacy cross-standard collision does not match a modern signature', () => { + const text = zwus.encodeString('ŵt', 7); + assert.equal(parseModernSig(text), null); + assert.equal(parseLegacySig(text).base, '6'); + assert.equal(parseSig(text + makeSig(7, 'PLAIN')).legacy, false); +}); diff --git a/vite.config.js b/vite.config.js index 51f417b..73fc40f 100644 --- a/vite.config.js +++ b/vite.config.js @@ -12,7 +12,7 @@ export default defineConfig(async ({ mode }) => { manifest: () => { const base = { name: "in\u00D8sight", - version: "3.2.0", + version: "3.3.0", author: "planetrenox@pm.me", homepage_url: "https://github.com/inzerosight/inzerosight", description: "Communicate undetected in plain sight.",