UNPKG

scandit-web-datacapture-core

Version:

Scandit Data Capture SDK for the Web

1 lines 1.55 kB
import{CHN as e,Id as a}from"./chunk-6RVAZ75N.js";function n(n,t){return async function(p,s){if(function(e,n){const t=new URL(e.url);return n.senderId===a&&"localhost"===t.hostname||""===t.hostname}(p.senderFrame,s))switch(s.type){case"get-license-key":if(null!=s.payload)try{const a=await async function(e,a){const{fs:n,crypto:t,path:p,app:s}=e,[r,c]=a.publicKey.split(":"),d=p.join(s.getAppPath(),a.licenseDataPath);return function(e,a,n){const p=t.createDecipheriv("aes-256-cbc",a,n);let s=p.update(e,"hex","utf8");return s+=p.final("utf8"),s}((await n.readFile(d)).toString("utf8"),Buffer.from(r,"base64"),Buffer.from(c,"base64"))}(n,{licenseDataPath:s.payload.licenseDataPath,publicKey:t});p.sender.send(e,{type:s.type,senderId:s.senderId,payload:{licenseKey:a??""}})}catch(a){p.sender.send(e,{type:s.type,senderId:s.senderId,payload:{error:a}})}break;case"get-app-info":try{const a=await async function(e){const{fs:a,path:n,app:t}=e;let p=process.cwd();t.isPackaged&&(p=t.getAppPath());const s=await a.readFile(n.join(p,"package.json"),"utf8"),r=JSON.parse(s);return{appId:r.build?.appId??r.appId,name:r.name,version:r.version}}(n);p.sender.send(e,{type:s.type,senderId:s.senderId,payload:{isPackaged:n.app.isPackaged,version:a.version??n.app.getVersion(),appName:a.name??n.app.getName(),appId:a.appId??""}})}catch(a){p.sender.send(e,{type:s.type,senderId:s.senderId,payload:{error:a}})}}}}var t=null,p=null;function s(a,s){p=a,t=n(a,s),p.ipcMain.on(e,t)}function r(){null!=t&&null!=p&&p.ipcMain.off(e,t)}export{s as register,r as unregister};