@joclaim/browser-extension-sdk 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/JoclaimExtensionSDK-mv2.bundle.js +5 -5
- package/build/JoclaimExtensionSDK-mv2.bundle.js.map +1 -1
- package/build/JoclaimExtensionSDK.bundle.js +5 -5
- package/build/JoclaimExtensionSDK.bundle.js.map +1 -1
- package/build/background/background-mv2.bundle.js +1 -1
- package/build/background/background-mv2.bundle.js.map +1 -1
- package/build/background/background.bundle.js +1 -1
- package/build/background/background.bundle.js.map +1 -1
- package/package.json +5 -4
- package/readme.md +199 -90
- package/src/types/index.d.ts +1 -0
- package/build/174.bundle.js +0 -1
- package/build/975.bundle.js +0 -2
- package/build/975.bundle.js.map +0 -1
- package/build/content/components/joclaim-provider-verification-popup.css +0 -666
- package/build/content/components/joclaim-provider-verification-popup.html +0 -138
- package/build/content/content.bundle.js +0 -11
- package/build/content/content.bundle.js.map +0 -1
- package/build/interceptor/injection-scripts.bundle.js +0 -2
- package/build/interceptor/injection-scripts.bundle.js.map +0 -1
- package/build/interceptor/network-interceptor.bundle.js +0 -2
- package/build/interceptor/network-interceptor.bundle.js.map +0 -1
- package/build/offscreen/offscreen.bundle.js +0 -117
- package/build/offscreen/offscreen.bundle.js.map +0 -1
- package/build/offscreen/offscreen.html +0 -15
- package/build/scripts/download-circuits.js +0 -1
- package/build/scripts/install-assets.js +0 -2
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Joclaim Offscreen Document</title>
|
|
7
|
-
<script defer src="./offscreen.bundle.js"></script>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="offscreen-container">
|
|
11
|
-
<!-- This document is used for proof generation operations that require DOM access -->
|
|
12
|
-
</div>
|
|
13
|
-
<!-- Let webpack inject the script automatically -->
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const fs=require("fs"),path=require("path"),https=require("https"),REPO="xj894976677/zk-symmetric-crypto",TARGET_DIR=path.join(process.cwd(),"public","browser-rpc","resources"),TEMP_DIR=path.join(process.cwd(),"zk-resources");function getLatestCommitHash(){return new Promise((e,t)=>{const o=`https://api.github.com/repos/${REPO}/commits/test`,s=https.get(o,{headers:{"User-Agent":"Node.js"}},o=>{let s="";o.on("data",e=>s+=e),o.on("end",()=>{try{const o=JSON.parse(s);o.sha?e(o.sha):t(new Error("No SHA found in GitHub API response"))}catch(e){t(new Error(`Failed to parse GitHub API response: ${e.message}`))}})});s.on("error",t),s.setTimeout(1e4,()=>{s.destroy(),t(new Error("Timeout fetching latest commit hash"))})})}function getFileSize(e,t,o=null){return o||(o=`https://github.com/${REPO}/raw/${t}/resources/${e}`),new Promise((s,r)=>{const n=https.request(o,{method:"HEAD"},o=>{if([301,302].includes(o.statusCode)&&o.headers.location)return s(getFileSize(e,t,o.headers.location));const r=parseInt(o.headers["content-length"],10);s(isNaN(r)?0:r)});n.on("error",r),n.end()})}async function downloadFile(e,t,o,s,r=null,n=3){r||(r=`https://github.com/${REPO}/raw/${s}/resources/${e}`);const a=path.dirname(t);await fs.promises.mkdir(a,{recursive:!0});for(let a=1;a<=n;a++)try{return await new Promise((n,a)=>{const i=fs.createWriteStream(t),c=https.get(r,r=>{if([301,302].includes(r.statusCode)&&r.headers.location)return downloadFile(e,t,o,s,r.headers.location).then(n).catch(a);r.on("data",e=>{o(e.length)}),r.pipe(i),i.on("finish",()=>{i.close(n)})});c.on("error",e=>{fs.unlink(t,()=>a(e))}),c.setTimeout(3e4,()=>{c.destroy(),a(new Error(`Timeout downloading ${e}`))})})}catch(t){if(a===n)throw new Error(`Failed to download ${e} after ${n} attempts: ${t.message}`);console.log(`\nRetry ${a}/${n} for ${e}: ${t.message}`),await new Promise(e=>setTimeout(e,1e3*Math.pow(2,a)))}}function formatBytes(e){const t=["B","KB","MB","GB"];let o=0;for(;e>=1024&&o<t.length-1;)e/=1024,o++;return`${e.toFixed(1)} ${t[o]}`}function renderProgress(e,t,o,s,r,n){const a=Math.min(s>0?o/s:0,1),i=Math.round(25*a),c=Math.max(0,25-i),l="█".repeat(i)+"░".repeat(c),d=r>0?Math.max(0,s-o)/r:0,m=(100*a).toFixed(1).padStart(5),p=`${formatBytes(r)}/s`,h=isFinite(d)?`${Math.round(d)}s`.padStart(4):"--";return`[${e.toString().padStart(2)}/${t}] ${m}% [${l}] Speed: ${p} Time Left: ${h} | ${n}`}async function main(){try{console.log("🔄 Fetching latest commit hash...");const e=await getLatestCommitHash();console.log(`📝 Using commit: ${e}`),await fs.promises.mkdir(TARGET_DIR,{recursive:!0});const t=["circuit_final.zkey","circuit.wasm","circuit.r1cs"],o=[...["chacha20","aes-256-ctr","aes-128-ctr"].flatMap(e=>t.map(t=>`snarkjs/${e}/${t}`))];if(await Promise.all(o.map(async e=>{try{return await fs.promises.access(path.join(TARGET_DIR,e)),!0}catch{return!1}})).then(e=>e.every(e=>e)))return console.log("ZK files already exist in target directory, skipping download."),void process.exit(0);await fs.promises.rm(TEMP_DIR,{recursive:!0,force:!0}),await fs.promises.mkdir(TEMP_DIR,{recursive:!0}),console.log("📦 Downloading ZK files ");const s=o.length;console.log("🔍 Fetching file information... please wait");let r={},n=0;for(const t of o)try{const o=await getFileSize(t,e);r[t]=o,n+=o}catch(e){r[t]=0}let a=0,i=0;const c=Date.now();process.stdout.write("[?25l");for(const t of o){const o=path.join(TEMP_DIR,t);let r=0;await downloadFile(t,o,e=>{r+=e,i+=e;const o=(Date.now()-c)/1e3,l=renderProgress(a,s,i,n,o>0?i/o:0,path.basename(t));process.stdout.write("\r[K"+l)},e),a++;const l=(Date.now()-c)/1e3,d=renderProgress(a,s,i,n,l>0?i/l:0,path.basename(t));process.stdout.write("\r[K"+d)}process.stdout.write("[?25h\n"),console.log("\nMoving files to final location..."),await fs.promises.rm(TARGET_DIR,{recursive:!0,force:!0}),await fs.promises.rename(TEMP_DIR,TARGET_DIR),console.log("Download completed successfully!"),process.exit(0)}catch(e){process.stdout.write("[?25h\n"),console.error("\nFatal error during download:",e),await fs.promises.rm(TEMP_DIR,{recursive:!0,force:!0}),process.exit(1)}}process.on("unhandledRejection",e=>{console.error("Unhandled promise rejection:",e),process.exit(1)}),main();
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const fs=require("fs"),path=require("path"),cp=require("child_process");function parseArgs(){const o=process.argv.slice(2),e={};for(let n=0;n<o.length;n++){const[c,i]=o[n].split("=");c.startsWith("--")&&(e[c.replace(/^--/,"")]=i??!0)}return e}function ensureDir(o){fs.mkdirSync(o,{recursive:!0})}function copyFile(o,e){ensureDir(path.dirname(e)),fs.copyFileSync(o,e)}function copyDir(o,e){if(fs.existsSync(o)){ensureDir(e);for(const n of fs.readdirSync(o)){const c=path.join(o,n),i=path.join(e,n);fs.statSync(c).isDirectory()?copyDir(c,i):copyFile(c,i)}}}async function main(){const o=parseArgs(),e=process.cwd(),n=path.resolve(__dirname,".."),c=path.resolve(e,o["public-dir"]||"public");console.log("[joclaim] downloading circuits...");const i=path.join(n,"scripts","download-circuits.js");try{cp.execFileSync(process.execPath,[i],{stdio:"inherit",cwd:e})}catch(o){console.error("[joclaim] circuits download failed",o.message),process.exit(1)}console.log("[joclaim] copying assets...");const s=path.join(c,"joclaim-browser-extension-sdk");copyFile(path.join(n,"content","content.bundle.js"),path.join(s,"content","content.bundle.js")),copyDir(path.join(n,"content","components"),path.join(s,"content","components")),copyDir(path.join(n,"interceptor"),path.join(s,"interceptor")),copyDir(path.join(n,"offscreen"),path.join(s,"offscreen"));const t=path.join(n,"343.bundle.js");fs.existsSync(t)&©File(t,path.join(c,"343.bundle.js")),copyFile(path.join(n,"JoclaimExtensionSDK.bundle.js"),path.join(c,"joclaim-browser-extension-sdk","JoclaimExtensionSDK.bundle.js")),console.log("[joclaim] setup complete")}main().catch(o=>{console.error("[joclaim] setup failed",o),process.exit(1)});
|