gws-client 1.2.5 → 1.2.7
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/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +6 -12
- package/dist/index.es.js +324 -317
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Ne=Object.defineProperty,xe=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Te=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var J=(s,e,t)=>e in s?Ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,S=(s,e)=>{for(var t in e||(e={}))Te.call(e,t)&&J(s,t,e[t]);if(ae)for(var t of ae(e))Me.call(e,t)&&J(s,t,e[t]);return s},v=(s,e)=>xe(s,$e(e));var o=(s,e,t)=>J(s,typeof e!="symbol"?e+"":e,t);var c=(s,e,t)=>new Promise((n,i)=>{var a=d=>{try{l(t.next(d))}catch(u){i(u)}},r=d=>{try{l(t.throw(d))}catch(u){i(u)}},l=d=>d.done?n(d.value):Promise.resolve(d.value).then(a,r);l((t=t.apply(s,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Oe=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",re="1",oe="2",Fe="1",Ge="2",Ve="3";var Ie=(s=>(s.MIN="0",s.LOW="1",s.MIDDLE="2",s.HIGH="3",s))(Ie||{});const p={LEVEL_1:1,LEVEL_2:2,LEVEL_3:4},Ze={OPEN:p.LEVEL_1,INTERNAL:p.LEVEL_2|p.LEVEL_1,OMP:p.LEVEL_3|p.LEVEL_2|p.LEVEL_1},He="00000001",q="NO_SEAL_AVAILABLE",Ue="CERTIFICATE_NOT_FOUND",je="CLIENT_CONNECTION_FAILED",Ke="ACCESS_DENIED",ce=[{oid:"1.2.86.21.1.3",key:"trustServiceNo"},{oid:"1.2.156.10260.4.1.1",key:"idCardNo"},{oid:"1.2.156.10260.4.1.4",key:"orgCode"}];function ze(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var F={},le;function Re(){if(le)return F;le=1,F.byteLength=l,F.toByteArray=u,F.fromByteArray=w;for(var s=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,a=n.length;i<a;++i)s[i]=n[i],e[n.charCodeAt(i)]=i;e[45]=62,e[95]=63;function r(y){var g=y.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=y.indexOf("=");m===-1&&(m=g);var f=m===g?0:4-m%4;return[m,f]}function l(y){var g=r(y),m=g[0],f=g[1];return(m+f)*3/4-f}function d(y,g,m){return(g+m)*3/4-m}function u(y){var g,m=r(y),f=m[0],E=m[1],k=new t(d(y,f,E)),_=0,P=E>0?f-4:f,I;for(I=0;I<P;I+=4)g=e[y.charCodeAt(I)]<<18|e[y.charCodeAt(I+1)]<<12|e[y.charCodeAt(I+2)]<<6|e[y.charCodeAt(I+3)],k[_++]=g>>16&255,k[_++]=g>>8&255,k[_++]=g&255;return E===2&&(g=e[y.charCodeAt(I)]<<2|e[y.charCodeAt(I+1)]>>4,k[_++]=g&255),E===1&&(g=e[y.charCodeAt(I)]<<10|e[y.charCodeAt(I+1)]<<4|e[y.charCodeAt(I+2)]>>2,k[_++]=g>>8&255,k[_++]=g&255),k}function C(y){return s[y>>18&63]+s[y>>12&63]+s[y>>6&63]+s[y&63]}function h(y,g,m){for(var f,E=[],k=g;k<m;k+=3)f=(y[k]<<16&16711680)+(y[k+1]<<8&65280)+(y[k+2]&255),E.push(C(f));return E.join("")}function w(y){for(var g,m=y.length,f=m%3,E=[],k=16383,_=0,P=m-f;_<P;_+=k)E.push(h(y,_,_+k>P?P:_+k));return f===1?(g=y[m-1],E.push(s[g>>2]+s[g<<4&63]+"==")):f===2&&(g=(y[m-2]<<8)+y[m-1],E.push(s[g>>10]+s[g>>4&63]+s[g<<2&63]+"=")),E.join("")}return F}var Ye=Re();const ue=ze(Ye);class Qe{constructor(){o(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const n=this.deps.get(e);n==null||n(t)}}(function(){try{var s=document.createElement("style");s.appendChild(document.createTextNode("button.svelte-16iv9d0{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-16iv9d0{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-16iv9d0{background-color:#fff;padding:1.25rem;border-radius:.3125rem;width:40%}.model-title.svelte-16iv9d0{color:#303133;font-size:1.125rem;margin-bottom:1.125rem}.modal-visible.svelte-16iv9d0{display:flex}.modal-footer.svelte-16iv9d0{display:flex;align-items:center;justify-content:flex-end;margin-top:1rem}.modal-btn.svelte-16iv9d0{padding:.5rem .9375rem;border-radius:.25rem;font-size:.875rem;border:.0625rem solid #dcdfe6}.success.svelte-16iv9d0{margin-left:.75rem;color:#fff}.slot.svelte-16iv9d0{max-height:12.5rem;overflow-y:scroll}.slot.svelte-16iv9d0::-webkit-scrollbar{display:none}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:11.25rem;height:11.25rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.0625rem solid #ccc;margin-top:.625rem;margin-right:.625rem;border-radius:.25rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:6.25rem;height:6.25rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.625rem;color:#333}.cert-item.svelte-1kh75ag.svelte-1kh75ag{padding:1rem;display:flex;align-items:center;cursor:pointer;border-bottom:.0625rem solid #ebeef5;font-size:1rem}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag{word-break:break-all;color:#373a40}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag:nth-child(1){padding-right:.5rem}.cert-item-selected.svelte-1kh75ag.svelte-1kh75ag{background-color:#f1f1f1}.cert-item-first.svelte-1kh75ag.svelte-1kh75ag{border-top:.0625rem solid #ebeef5}")),document.head.appendChild(s)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var We=Object.defineProperty,Je=(s,e,t)=>e in s?We(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,de=(s,e,t)=>Je(s,typeof e!="symbol"?e+"":e,t);function ee(){}function qe(s,e){for(const t in e)s[t]=e[t];return s}function ke(s){return s()}function he(){return Object.create(null)}function U(s){s.forEach(ke)}function Z(s){return typeof s=="function"}function ve(s,e){return s!=s?e==e:s!==e||s&&typeof s=="object"||typeof s=="function"}function Xe(s){return Object.keys(s).length===0}function et(s,e,t,n){if(s){const i=pe(s,e,t,n);return s[0](i)}}function pe(s,e,t,n){return s[1]&&n?qe(t.ctx.slice(),s[1](n(e))):t.ctx}function tt(s,e,t,n){if(s[2]&&n){const i=s[2](n(t));if(e.dirty===void 0)return i;if(typeof i=="object"){const a=[],r=Math.max(e.dirty.length,i.length);for(let l=0;l<r;l+=1)a[l]=e.dirty[l]|i[l];return a}return e.dirty|i}return e.dirty}function nt(s,e,t,n,i,a){if(i){const r=pe(e,t,n,a);s.p(r,i)}}function st(s){if(s.ctx.length>32){const e=[],t=s.ctx.length/32;for(let n=0;n<t;n++)e[n]=-1;return e}return-1}function ge(s){return s==null?"":s}function L(s,e){s.appendChild(e)}function W(s,e,t){s.insertBefore(e,t||null)}function j(s){s.parentNode&&s.parentNode.removeChild(s)}function _e(s,e){for(let t=0;t<s.length;t+=1)s[t]&&s[t].d(e)}function A(s){return document.createElement(s)}function T(s){return document.createTextNode(s)}function K(){return T(" ")}function it(){return T("")}function G(s,e,t,n){return s.addEventListener(e,t,n),()=>s.removeEventListener(e,t,n)}function B(s,e,t){t==null?s.removeAttribute(e):s.getAttribute(e)!==t&&s.setAttribute(e,t)}function at(s){return Array.from(s.childNodes)}function z(s,e){e=""+e,s.data!==e&&(s.data=e)}function Y(s,e,t,n){t==null?s.style.removeProperty(e):s.style.setProperty(e,t,"")}let se;function H(s){se=s}const x=[],ye=[];let M=[];const Ce=[],rt=Promise.resolve();let te=!1;function ot(){te||(te=!0,rt.then(Le))}function ne(s){M.push(s)}const X=new Set;let N=0;function Le(){if(N!==0)return;const s=se;do{try{for(;N<x.length;){const e=x[N];N++,H(e),ct(e.$$)}}catch(e){throw x.length=0,N=0,e}for(H(null),x.length=0,N=0;ye.length;)ye.pop()();for(let e=0;e<M.length;e+=1){const t=M[e];X.has(t)||(X.add(t),t())}M.length=0}while(x.length);for(;Ce.length;)Ce.pop()();te=!1,X.clear(),H(s)}function ct(s){if(s.fragment!==null){s.update(),U(s.before_update);const e=s.dirty;s.dirty=[-1],s.fragment&&s.fragment.p(s.ctx,e),s.after_update.forEach(ne)}}function lt(s){const e=[],t=[];M.forEach(n=>s.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),M=e}const R=new Set;let ut;function ie(s,e){s&&s.i&&(R.delete(s),s.i(e))}function De(s,e,t,n){if(s&&s.o){if(R.has(s))return;R.add(s),ut.c.push(()=>{R.delete(s)}),s.o(e)}}function Q(s){return(s==null?void 0:s.length)!==void 0?s:Array.from(s)}function dt(s){s&&s.c()}function Be(s,e,t){const{fragment:n,after_update:i}=s.$$;n&&n.m(e,t),ne(()=>{const a=s.$$.on_mount.map(ke).filter(Z);s.$$.on_destroy?s.$$.on_destroy.push(...a):U(a),s.$$.on_mount=[]}),i.forEach(ne)}function Pe(s,e){const t=s.$$;t.fragment!==null&&(lt(t.after_update),U(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ht(s,e){s.$$.dirty[0]===-1&&(x.push(s),ot(),s.$$.dirty.fill(0)),s.$$.dirty[e/31|0]|=1<<e%31}function Ae(s,e,t,n,i,a,r=null,l=[-1]){const d=se;H(s);const u=s.$$={fragment:null,ctx:[],props:a,update:ee,not_equal:i,bound:he(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:he(),dirty:l,skip_bound:!1,root:e.target||d.$$.root};r&&r(u.root);let C=!1;if(u.ctx=t?t(s,e.props||{},(h,w,...y)=>{const g=y.length?y[0]:w;return u.ctx&&i(u.ctx[h],u.ctx[h]=g)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](g),C&&ht(s,h)),w}):[],u.update(),C=!0,U(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const h=at(e.target);u.fragment&&u.fragment.l(h),h.forEach(j)}else u.fragment&&u.fragment.c();e.intro&&ie(s.$$.fragment),Be(s,e.target,e.anchor),Le()}H(d)}class be{constructor(){de(this,"$$"),de(this,"$$set")}$destroy(){Pe(this,1),this.$destroy=ee}$on(e,t){if(!Z(t))return ee;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Xe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const gt="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(gt);function yt(s){let e,t,n,i=(s[1]||"标题")+"",a,r,l,d,u,C,h=(s[4]||"取消")+"",w,y,g,m=(s[5]||"确认")+"",f,E,k,_;const P=s[8].default,I=et(P,s,s[7],null);return{c(){e=A("div"),t=A("div"),n=A("div"),a=T(i),r=K(),l=A("div"),I&&I.c(),d=K(),u=A("div"),C=A("button"),w=T(h),y=K(),g=A("button"),f=T(m),B(n,"class","model-title svelte-16iv9d0"),B(l,"class","slot svelte-16iv9d0"),B(C,"class","modal-btn svelte-16iv9d0"),B(g,"class","modal-btn success svelte-16iv9d0"),Y(g,"background-color",s[6]),B(u,"class","modal-footer svelte-16iv9d0"),B(t,"class","modal-content svelte-16iv9d0"),B(e,"class","modal-background modal-visible svelte-16iv9d0")},m(D,b){W(D,e,b),L(e,t),L(t,n),L(n,a),L(t,r),L(t,l),I&&I.m(l,null),L(t,d),L(t,u),L(u,C),L(C,w),L(u,y),L(u,g),L(g,f),E=!0,k||(_=[G(C,"click",function(){Z(s[0])&&s[0].apply(this,arguments)}),G(g,"click",function(){Z(s[2])&&s[2].apply(this,arguments)}),G(t,"click",Ct),G(e,"click",function(){Z(s[3])&&s[3].apply(this,arguments)})],k=!0)},p(D,[b]){s=D,(!E||b&2)&&i!==(i=(s[1]||"标题")+"")&&z(a,i),I&&I.p&&(!E||b&128)&&nt(I,P,s,s[7],E?tt(P,s[7],b,null):st(s[7]),null),(!E||b&16)&&h!==(h=(s[4]||"取消")+"")&&z(w,h),(!E||b&32)&&m!==(m=(s[5]||"确认")+"")&&z(f,m),(!E||b&64)&&Y(g,"background-color",s[6])},i(D){E||(ie(I,D),E=!0)},o(D){De(I,D),E=!1},d(D){D&&j(e),I&&I.d(D),k=!1,U(_)}}}const Ct=s=>s.stopPropagation();function ft(s,e,t){let{$$slots:n={},$$scope:i}=e,{onCancel:a}=e,{title:r}=e,{onOk:l}=e,{onClose:d}=e,{cancelText:u}=e,{okText:C}=e,{theme:h}=e;return s.$$set=w=>{"onCancel"in w&&t(0,a=w.onCancel),"title"in w&&t(1,r=w.title),"onOk"in w&&t(2,l=w.onOk),"onClose"in w&&t(3,d=w.onClose),"cancelText"in w&&t(4,u=w.cancelText),"okText"in w&&t(5,C=w.okText),"theme"in w&&t(6,h=w.theme),"$$scope"in w&&t(7,i=w.$$scope)},[a,r,l,d,u,C,h,i,n]}class wt extends be{constructor(e){super(),Ae(this,e,ft,yt,ve,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function fe(s,e,t){const n=s.slice();return n[13]=e[t],n[15]=t,n}function we(s,e,t){const n=s.slice();return n[16]=e[t],n}function me(s){let e,t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"",n;return{c(){e=A("div"),n=T(t),B(e,"class","svelte-1kh75ag"),Y(e,"width",`${100/s[1].length}%`)},m(i,a){W(i,e,a),L(e,n)},p(i,a){a&3&&t!==(t=(i[16].format?i[16].format(i[13]):i[13][i[16].key])+"")&&z(n,t),a&2&&Y(e,"width",`${100/i[1].length}%`)},d(i){i&&j(e)}}}function Se(s){let e,t,n,i,a,r=Q(s[1]),l=[];for(let u=0;u<r.length;u+=1)l[u]=me(we(s,r,u));function d(){return s[12](s[15])}return{c(){e=A("div");for(let u=0;u<l.length;u+=1)l[u].c();t=K(),B(e,"class",n=ge(`cert-item ${s[15]===0?"cert-item-first":""} ${s[15]===s[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(u,C){W(u,e,C);for(let h=0;h<l.length;h+=1)l[h]&&l[h].m(e,null);L(e,t),i||(a=G(e,"click",d),i=!0)},p(u,C){if(s=u,C&3){r=Q(s[1]);let h;for(h=0;h<r.length;h+=1){const w=we(s,r,h);l[h]?l[h].p(w,C):(l[h]=me(w),l[h].c(),l[h].m(e,t))}for(;h<l.length;h+=1)l[h].d(1);l.length=r.length}C&128&&n!==(n=ge(`cert-item ${s[15]===0?"cert-item-first":""} ${s[15]===s[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&B(e,"class",n)},d(u){u&&j(e),_e(l,u),i=!1,a()}}}function mt(s){let e,t=Q(s[0]),n=[];for(let i=0;i<t.length;i+=1)n[i]=Se(fe(s,t,i));return{c(){for(let i=0;i<n.length;i+=1)n[i].c();e=it()},m(i,a){for(let r=0;r<n.length;r+=1)n[r]&&n[r].m(i,a);W(i,e,a)},p(i,a){if(a&131){t=Q(i[0]);let r;for(r=0;r<t.length;r+=1){const l=fe(i,t,r);n[r]?n[r].p(l,a):(n[r]=Se(l),n[r].c(),n[r].m(e.parentNode,e))}for(;r<n.length;r+=1)n[r].d(1);n.length=t.length}},d(i){i&&j(e),_e(n,i)}}}function St(s){let e,t;return e=new wt({props:{onOk:s[9],onClose:s[2],onCancel:s[8],cancelText:s[3],okText:s[4],title:s[6],theme:s[5],$$slots:{default:[mt]},$$scope:{ctx:s}}}),{c(){dt(e.$$.fragment)},m(n,i){Be(e,n,i),t=!0},p(n,[i]){const a={};i&4&&(a.onClose=n[2]),i&8&&(a.cancelText=n[3]),i&16&&(a.okText=n[4]),i&64&&(a.title=n[6]),i&32&&(a.theme=n[5]),i&524419&&(a.$$scope={dirty:i,ctx:n}),e.$set(a)},i(n){t||(ie(e.$$.fragment,n),t=!0)},o(n){De(e.$$.fragment,n),t=!1},d(n){Pe(e,n)}}}function Et(s,e,t){let{data:n=[]}=e,{columns:i=[]}=e,{onCancel:a}=e,{onOk:r}=e,{onClose:l}=e,{cancelText:d=""}=e,{okText:u=""}=e,{theme:C="#409eff"}=e,{title:h=""}=e,w=0;const y=()=>{a(`${h}失败`),l==null||l()},g=()=>{r==null||r(n[w]),l==null||l()},m=f=>t(7,w=f);return s.$$set=f=>{"data"in f&&t(0,n=f.data),"columns"in f&&t(1,i=f.columns),"onCancel"in f&&t(10,a=f.onCancel),"onOk"in f&&t(11,r=f.onOk),"onClose"in f&&t(2,l=f.onClose),"cancelText"in f&&t(3,d=f.cancelText),"okText"in f&&t(4,u=f.okText),"theme"in f&&t(5,C=f.theme),"title"in f&&t(6,h=f.title)},[n,i,l,d,u,C,h,w,y,g,a,r,m]}class It extends be{constructor(e){super(),Ae(this,e,Et,St,ve,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class kt{constructor(){o(this,"modalInstance",{current:null});o(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new It({target:document.body,props:v(S({},e),{onCancel:i=>{n({code:-1,msg:i})},onOk:i=>{t(i)},onClose:()=>{this.close()}})})}));o(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const V=new kt;function vt(s=32,e=!0,t=0){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[];if(t=t||n.length,s)for(let a=0;a<s;a++)i[a]=n[0|Math.random()*t];else{let a;i[8]=i[13]=i[18]=i[23]="-",i[14]="4";for(let r=0;r<36;r++)i[r]||(a=0|Math.random()*16,i[r]=n[r===19?a&3|8:a])}return e?(i.shift(),`u${i.join("")}`):i.join("")}const pt=[{key:"CN"},{format:s=>`${s.DevClass}(${s.sn})`}],_t=[{key:"SealId"},{key:"Vid"},{format:s=>`${s.FileName}(${s.FileSize}B)`}],Ee=[{key:"SealId"}],Lt=[{key:"manu"},{key:"sn"}];class Dt{constructor(e){o(this,"socketInstance",null);o(this,"eventBus",new Qe);o(this,"scene");o(this,"isRememberPin",!1);o(this,"pinPolicy");o(this,"socketConfig",null);o(this,"isConnecting",!1);o(this,"messageQueue",[]);o(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});o(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});o(this,"sendMessage",(e,t,n)=>new Promise((i,a)=>{var l;const r=()=>{var h,w;if(((h=this.socketInstance)==null?void 0:h.readyState)!==WebSocket.OPEN){a({errCode:je,msg:"数字证书客户端连接失败"});return}const d=vt(),u=y=>{y.success?i(y.data):a(y)},C={function:e,args:t?[t]:[],msgid:d};(w=this.socketInstance)==null||w.send(JSON.stringify(C)),this.eventBus.on(e,u),this.eventBus.on(d,u)};if(n&&(this.scene&n)!==n){a({errCode:Ke,msg:"无权限执行此操作"});return}if(((l=this.socketInstance)==null?void 0:l.readyState)===WebSocket.OPEN){r();return}this.messageQueue.push(r),this.isConnecting||this.initSocket(this.socketConfig)}));o(this,"flushMsgQueue",()=>{var e;(e=this.messageQueue)==null||e.forEach(t=>t()),this.messageQueue=[]});o(this,"handleEventData",e=>c(this,null,function*(){var t,n,i,a,r,l,d,u;if(e.data instanceof Blob){const C=yield e.data.arrayBuffer(),y=new TextDecoder(navigator.userAgent.includes("Windows")?"gbk":"utf-8").decode(C).replace(/\\(?!(["\\\/bfnrtu]))/g,""),g=JSON.parse(y),m={success:(t=g.result)==null?void 0:t.success,msg:(n=g.result)==null?void 0:n.msg,errCode:(i=g.result)==null?void 0:i.errCode,data:g.data,type:(a=g.result)==null?void 0:a.event},f=(r=g.result)==null?void 0:r.function,E=(l=g.result)==null?void 0:l.msgid;E?this.eventBus.emit(E,m):this.eventBus.emit(f,m),(u=(d=this.socketConfig)==null?void 0:d.onMessage)==null||u.call(d,m)}}));o(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return ue.fromByteArray(t)});o(this,"base64Decode",e=>{const t=ue.toByteArray(e);return new TextDecoder().decode(t)});o(this,"changeIsRememberPin",e=>c(this,null,function*(){this.isRememberPin=e}));o(this,"changePinPolicy",e=>c(this,null,function*(){this.pinPolicy=e}));o(this,"checkCertIsLogin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));o(this,"addUkeyEvents",()=>c(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:He}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,i;(i=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||i.call(t,v(S({},e),{data:(n=e.data)==null?void 0:n[0]}))})}));o(this,"certLogin",e=>c(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));o(this,"verifyPin",e=>c(this,null,function*(){var t;yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:e.UserPin?"Y":"N",UserPin:(t=e.UserPin)!=null?t:"123456",PinPolicy:this.pinPolicy})}));o(this,"getCert",(e,t,n)=>c(this,null,function*(){const i=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.certLogin(i.ContainerName)),i}));o(this,"chooseCert",e=>c(this,null,function*(){var i;const t=yield this.getCertList(e);return t!=null&&t.length?(t==null?void 0:t.length)===1?t[0]:yield V.open({title:"选择证书",data:t,columns:pt,theme:(i=this.socketConfig)==null?void 0:i.theme}):Promise.reject({errCode:Ue,msg:"暂无证书"})}));o(this,"getCertList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));o(this,"pkcs1Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"batchPkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));o(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));o(this,"getSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",S({IsLogin:this.getIsLogin()},e!=null?e:{}),p.LEVEL_2)}));o(this,"writeSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),p.LEVEL_2)}));o(this,"deleteSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),p.LEVEL_2)}));o(this,"getSealInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),p.LEVEL_2)}));o(this,"getTPSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",S({IsLogin:this.getIsLogin()},e!=null?e:{}),p.LEVEL_2)}));o(this,"getTPSealPic",e=>c(this,null,function*(){var n;return yield this.sendMessage("GZCA_GetSealPicData",S({IsLogin:(n=e.IsLogin)!=null?n:this.getIsLogin()},e!=null?e:{}),p.LEVEL_2)}));o(this,"sm2SignPreprocess1",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));o(this,"sm2SignPreprocess2",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));o(this,"pkcs1HashSign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",S({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));o(this,"pkcs7Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",S({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs7VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));o(this,"sm3Hash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));o(this,"sm3HexHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));o(this,"sm3FileHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));o(this,"sm3HashEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));o(this,"pkcs7Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));o(this,"pkcs7Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"pkcs7FileEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeSealFileEx_qyzc",e)}));o(this,"pkcs7FileDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeOpenFileEx_qyzc",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"asymmetricEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));o(this,"asymmetricDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",S({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"sm4Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));o(this,"sm4Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));o(this,"getCertInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));o(this,"getCertInfoByOid",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));o(this,"getSealVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealIssuer",e,p.LEVEL_2)}));o(this,"deleteAllSealByVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",S({IsLogin:this.getIsLogin()},e!=null?e:{}),p.LEVEL_2)}));o(this,"applyCert",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ApplyCert",{manu:e.manu,sn:e.sn,keyid:e.ContainerName,type:e.type,url:e.url},p.LEVEL_3)}));o(this,"resetPin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_UnblockUserPin",S({},e!=null?e:{}),p.LEVEL_3)}));o(this,"getUKeyList",()=>c(this,null,function*(){return yield this.sendMessage("GetUKeyList",void 0,p.LEVEL_3)}));o(this,"getUKeyInfo",e=>c(this,null,function*(){return yield this.sendMessage("GetUKeyID",e!=null?e:{},p.LEVEL_3)}));var t,n,i;this.socketConfig=e,this.initSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.scene=(n=e.scene)!=null?n:Ze.OPEN,this.pinPolicy=(i=e.pinPolicy)!=null?i:Ie.MIN}initSocket(e){this.isConnecting=!0;const t=new WebSocket(e.url);t.onerror=n=>{var i;this.isConnecting=!1,(i=e.onError)==null||i.call(e,n),this.flushMsgQueue()},t.onopen=n=>{var i;this.isConnecting=!1,(i=e.onOpen)==null||i.call(e,n),e.onUkeyChange&&this.addUkeyEvents(),this.flushMsgQueue()},t.onmessage=n=>{this.handleEventData(n)},t.onclose=n=>{var i;this.isConnecting=!1,(i=e.onClose)==null||i.call(e,n)},this.socketInstance=t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const $=class ${constructor(e){o(this,"coreInstance",null);o(this,"gwsConfig",{});o(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new Dt(v(S({},e!=null?e:{}),{url:Oe}))});o(this,"appendCertBase64",(e,t=!0)=>c(this,null,function*(){if(e.CertB64)return e;const n=t?yield this.getSignatureCert():yield this.getEncryptionCert();return v(S({},e!=null?e:{}),{CertB64:n==null?void 0:n.CertB64})}));o(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});o(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});o(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});o(this,"verifyPin",(e,t)=>c(this,null,function*(){var i,a;const n=yield this.getSignatureCert(t);return(a=this.coreInstance)==null?void 0:a.verifyPin({ContainerName:(i=n==null?void 0:n.ContainerName)!=null?i:"",UserPin:e==null?void 0:e.UserPin})}));o(this,"getSignatureCert",(e,t=!0)=>c(this,null,function*(){var i;return yield(i=this.coreInstance)==null?void 0:i.getCert({CertType:re},e,t)}));o(this,"getSignatureCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:re})}));o(this,"getEncryptionCert",(e,t=!0)=>c(this,null,function*(){var i;return yield(i=this.coreInstance)==null?void 0:i.getCert({CertType:oe},e,t)}));o(this,"getEncryptionCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:oe})}));o(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});o(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});o(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});o(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});o(this,"pkcs1Sign",(e,t)=>c(this,null,function*(){var a,r,l;const n=yield this.getSignatureCert(t),i=yield(r=this.coreInstance)==null?void 0:r.pkcs1Sign(v(S({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""}));return(l=i==null?void 0:i[0])==null?void 0:l.SignData}));o(this,"pkcs1VerifySignature",e=>c(this,null,function*(){var i;const t=yield this.appendCertBase64(e),n=yield(i=this.coreInstance)==null?void 0:i.pkcs1VerifySignature(t);return Array.isArray(n)}));o(this,"pkcs1Base64Sign",(e,t)=>c(this,null,function*(){var r,l,d,u,C;const n=yield this.getSignatureCert(t),i=(l=e.DataB64)!=null?l:this.base64Encode({Data:(r=e.Data)!=null?r:""}),a=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign(v(S({},e!=null?e:{}),{ContainerName:(d=n==null?void 0:n.ContainerName)!=null?d:"",DataB64:i}));return(C=a==null?void 0:a[0])==null?void 0:C.SignData}));o(this,"batchPkcs1Base64Sign",(e,t)=>c(this,null,function*(){var C,h,w,y,g,m;const n="|",i=(h=e.DataB64)!=null?h:(C=e.Data)==null?void 0:C.map(f=>this.base64Encode({Data:f})),a=yield this.getSignatureCert(t);let r="";r=Array.isArray(i)?i==null?void 0:i.map((f,E)=>`${E}:${f}`).join(n):"";const l=yield(y=this.coreInstance)==null?void 0:y.batchPkcs1Base64Sign({ContainerName:(w=a==null?void 0:a.ContainerName)!=null?w:"",DataB64:r}),d=(m=(g=l==null?void 0:l[0])==null?void 0:g.SignData)==null?void 0:m.split(n),u=[];return d.forEach(f=>{const E=f.split(":"),k=Number(E[0]),_=E[1];u[k]=_}),u}));o(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){var a,r,l;const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:n.CertB64,DataB64:t,SignData:n.SignData}))}));o(this,"writeSeal",(e,t)=>c(this,null,function*(){var a,r;const n=yield this.getSignatureCert(t);return!!(yield(r=this.coreInstance)==null?void 0:r.writeSeal(v(S({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""})))}));o(this,"deleteSeal",e=>c(this,null,function*(){var r,l,d,u,C;const t=yield this.getSealList(e);if(!((r=t==null?void 0:t.data)!=null&&r.length))return Promise.reject({errCode:q,msg:"暂无印章"});const n=yield V.open({title:"删除印章",data:t==null?void 0:t.data,columns:Ee,okText:"删除"}),i=(l=n==null?void 0:n.SealId)!=null?l:"";return!!(yield(C=this.coreInstance)==null?void 0:C.deleteSeal({ContainerName:(u=(d=t==null?void 0:t.cert)==null?void 0:d.ContainerName)!=null?u:"",SealId:i}))}));o(this,"deleteSealById",(e,t)=>c(this,null,function*(){var a,r;const n=yield this.getSignatureCert(t);return!!(yield(r=this.coreInstance)==null?void 0:r.deleteSeal(v(S({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""})))}));o(this,"getSealList",e=>c(this,null,function*(){var i,a;const t=yield this.getSignatureCert(e),n=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(i=t==null?void 0:t.ContainerName)!=null?i:"",IsLogin:"Y"});return{cert:t,data:n}}));o(this,"getSealInfo",e=>c(this,null,function*(){var a,r,l,d,u,C,h;const t=yield this.getSealList(e);if(!((a=t==null?void 0:t.data)!=null&&a.length))return Promise.reject({errCode:q,msg:"暂无印章"});const n=((r=t==null?void 0:t.data)==null?void 0:r.length)>1?yield V.open({title:"选择印章",data:t==null?void 0:t.data,columns:Ee,theme:(l=this.gwsConfig)==null?void 0:l.theme}):t==null?void 0:t.data[0],i=yield(h=this.coreInstance)==null?void 0:h.getSealInfo({ContainerName:(u=(d=t==null?void 0:t.cert)==null?void 0:d.ContainerName)!=null?u:"",SealId:(C=n==null?void 0:n.SealId)!=null?C:""});return i==null?void 0:i[0]}));o(this,"getTPSealList",(e,t)=>c(this,null,function*(){var a,r;const n=yield this.getSignatureCert(t);return yield(r=this.coreInstance)==null?void 0:r.getTPSealList({ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:"",Vid:e==null?void 0:e.Vid})}));o(this,"getTPSeal",(e,t)=>c(this,null,function*(){var a;const n=yield this.getTPSealList(e,t);return n!=null&&n.length?(n==null?void 0:n.length)===1?n==null?void 0:n[0]:yield V.open({title:"选择印章",data:n,columns:_t,theme:(a=this.gwsConfig)==null?void 0:a.theme}):Promise.reject({errCode:q,msg:"暂无印章"})}));o(this,"getTPSealPic",(e,t,n)=>c(this,null,function*(){var l,d;const i=yield this.getSignatureCert(t),a=n||(yield this.getTPSeal(e,t)),r=yield(d=this.coreInstance)==null?void 0:d.getTPSealPic(v(S({ContainerName:(l=i==null?void 0:i.ContainerName)!=null?l:""},a!=null?a:{}),{FileSize:String(a==null?void 0:a.FileSize)}));return r==null?void 0:r[0]}));o(this,"sm2SignPreprocess1",e=>c(this,null,function*(){var i,a;const t=yield this.appendCertBase64(e),n=yield(i=this.coreInstance)==null?void 0:i.sm2SignPreprocess1(t);return(a=n==null?void 0:n[0])==null?void 0:a.Z}));o(this,"sm2SignPreprocess2",e=>c(this,null,function*(){var a,r;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=yield this.appendCertBase64(e),i=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return i==null?void 0:i[0].H}));o(this,"pkcs1HashSign",(e,t)=>c(this,null,function*(){var a,r,l,d;const n=yield this.getSignatureCert(t),i=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(r=e.HashAlg)!=null?r:"sm3"});return(d=i==null?void 0:i[0])==null?void 0:d.SignData}));o(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){var i,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(v(S({},t),{HashAlg:(i=t.HashAlg)!=null?i:"sm3"})))}));o(this,"pkcs7Sign",(e,t)=>c(this,null,function*(){var r,l,d,u,C;const n=(l=e.DataB64)!=null?l:this.base64Encode({Data:(r=e.Data)!=null?r:""}),i=yield this.getSignatureCert(t),a=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign(v(S({},e!=null?e:{}),{ContainerName:(d=i==null?void 0:i.ContainerName)!=null?d:"",DataB64:n}));return(C=a==null?void 0:a[0])==null?void 0:C.SignData}));o(this,"pkcs7VerifySignature",e=>c(this,null,function*(){var i,a,r;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(i=e.Data)!=null?i:""});return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));o(this,"sm3Hash",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.sm3Hash(e);return(i=t==null?void 0:t[0])==null?void 0:i.HashB64}));o(this,"sm3HexHash",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.sm3HexHash(e);return(i=t==null?void 0:t[0])==null?void 0:i.HashB64}));o(this,"sm3FileHash",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.sm3FileHash(e);return(i=t==null?void 0:t[0])==null?void 0:i.HashB64}));o(this,"sm3HashEncryption",e=>c(this,null,function*(){var a,r,l,d,u,C;const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=(d=e.KeyB64)!=null?d:this.base64Encode({Data:(l=e.Key)!=null?l:""}),i=yield(u=this.coreInstance)==null?void 0:u.sm3HashEncryption({dataB64:t,keyB64:n,alg:"sm3"});return(C=i==null?void 0:i[0])==null?void 0:C.DataB64}));o(this,"pkcs7Encryption",e=>c(this,null,function*(){var i,a,r,l;if(!e.CertB64List){const d=yield this.getEncryptionCert();e.CertB64List=d==null?void 0:d.CertB64}const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(i=e.Data)!=null?i:""}),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(l=n==null?void 0:n[0])==null?void 0:l.DataB64}));o(this,"pkcs7Decryption",e=>c(this,null,function*(){var a,r;const t=yield this.getEncryptionCert(),n=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption(v(S({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),i=(r=n==null?void 0:n[0])==null?void 0:r.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:i}):i}));o(this,"pkcs7FileEncryption",e=>c(this,null,function*(){var i,a;const t=yield this.appendCertBase64(e,!1),n=yield(i=this.coreInstance)==null?void 0:i.pkcs7FileEncryption(t);return(a=n==null?void 0:n[0])==null?void 0:a.DataB64}));o(this,"pkcs7FileDecryption",e=>c(this,null,function*(){var i,a,r;const t=yield this.getEncryptionCert(),n=yield(a=this.coreInstance)==null?void 0:a.pkcs7FileDecryption({SrcFile:e.SrcFile,DstFile:(i=e.DstFile)!=null?i:e.SrcFile.slice(0,-4),ContainerName:t==null?void 0:t.ContainerName});return(r=n==null?void 0:n[0])==null?void 0:r.DataB64}));o(this,"asymmetricEncryption",e=>c(this,null,function*(){var i,a;const t=yield this.appendCertBase64(e,!1),n=yield(i=this.coreInstance)==null?void 0:i.asymmetricEncryption(t);return(a=n==null?void 0:n[0])==null?void 0:a.Data}));o(this,"asymmetricDecryption",(e,t)=>c(this,null,function*(){var a,r;const n=yield this.getEncryptionCert(t),i=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption(v(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(r=i==null?void 0:i[0])==null?void 0:r.Data}));o(this,"sm4Encryption",e=>c(this,null,function*(){var n;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Encryption(e);return t==null?void 0:t[0]}));o(this,"sm4Decryption",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Decryption(e);return(i=t==null?void 0:t[0])==null?void 0:i.Data}));o(this,"getCertInfo",e=>c(this,null,function*(){var i,a,r,l,d;const t=yield(i=this.coreInstance)==null?void 0:i.getCertInfo(e),n=(a=t==null?void 0:t[0])!=null?a:{};for(let u=0;u<ce.length;u++){const C=ce[u];try{const h=yield(r=this.coreInstance)==null?void 0:r.getCertInfoByOid({Oid:C.oid,CertB64:e.CertB64});n[C.key]=(d=(l=h==null?void 0:h[0])==null?void 0:l.OidValue)==null?void 0:d.replace(".","")}catch(h){n[C.key]=null}}return n!=null&&n.idCardNo?n!=null&&n.CertSubject.includes("O=")||n.orgCode?n.certCate=Ge:n.certCate=Fe:n.certCate=Ve,n}));o(this,"getCertInfoByOid",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(S({},e!=null?e:{}));return(i=t==null?void 0:t[0])==null?void 0:i.OidValue}));o(this,"getSealVendor",e=>c(this,null,function*(){var i;const t=yield this.getSignatureCert(e),n=yield(i=this.coreInstance)==null?void 0:i.getSealVendor({ContainerName:t==null?void 0:t.ContainerName});return n==null?void 0:n[0]}));o(this,"deleteAllSealByVendor",(e,t)=>c(this,null,function*(){var a;const n=yield this.getSignatureCert(t),i=yield(a=this.coreInstance)==null?void 0:a.deleteAllSealByVendor(v(S({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return i==null?void 0:i[0]}));o(this,"getUKey",e=>c(this,null,function*(){var i,a;if(e)return e;const t=yield(i=this.coreInstance)==null?void 0:i.getUKeyList();return yield V.open({title:"选择介质",data:t,columns:Lt,theme:(a=this.gwsConfig)==null?void 0:a.theme})}));o(this,"getUKeyList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getUKeyList()}));o(this,"getUKeyInfo",e=>c(this,null,function*(){var i;const t=yield this.getUKey(e),n=yield(i=this.coreInstance)==null?void 0:i.getUKeyInfo({manu:t==null?void 0:t.manu,sn:t==null?void 0:t.sn});return n==null?void 0:n[0]}));o(this,"applyCert",(e,t)=>c(this,null,function*(){var r;const n=yield this.getUKey(t),i=yield this.getUKeyInfo(n);return yield(r=this.coreInstance)==null?void 0:r.applyCert(v(S({},e!=null?e:{}),{manu:i==null?void 0:i.manu,sn:i==null?void 0:i.sn,ContainerName:i==null?void 0:i.keyid}))}));o(this,"resetPin",(e,t)=>c(this,null,function*(){var a;const n=yield this.getSignatureCert(t);return yield(a=this.coreInstance)==null?void 0:a.resetPin(v(S({},e!=null?e:{}),{manu:n==null?void 0:n.manu,sn:n==null?void 0:n.sn,ContainerName:n==null?void 0:n.ContainerName}))}));return $.instance&&!(e!=null&&e.isCreateNew)?$.instance:(this.createGwsCore(e),$.instance=this,this)}};o($,"instance",null);let O=$;function Bt(s){return new Promise((e,t)=>{if(O.instance&&!(s!=null&&s.isCreateNew))e(O.instance);else{const n=new O(v(S({},s!=null?s:{}),{onOpen(i){var a;e(n),(a=s==null?void 0:s.onOpen)==null||a.call(s,i)},onClose(i){var a;t(i),(a=s==null?void 0:s.onClose)==null||a.call(s,i)}}))}})}exports.GwsService=O;exports.createService=Bt;
|
|
1
|
+
"use strict";var be=Object.defineProperty,xe=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Te=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var J=(s,e,t)=>e in s?be(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,m=(s,e)=>{for(var t in e||(e={}))Te.call(e,t)&&J(s,t,e[t]);if(ae)for(var t of ae(e))Me.call(e,t)&&J(s,t,e[t]);return s},v=(s,e)=>xe(s,$e(e));var r=(s,e,t)=>J(s,typeof e!="symbol"?e+"":e,t);var c=(s,e,t)=>new Promise((n,i)=>{var a=d=>{try{l(t.next(d))}catch(u){i(u)}},o=d=>{try{l(t.throw(d))}catch(u){i(u)}},l=d=>d.done?n(d.value):Promise.resolve(d.value).then(a,o);l((t=t.apply(s,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Oe=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",re="1",oe="2",Fe="1",Ge="2",Ve="3";var Ie=(s=>(s.MIN="0",s.LOW="1",s.MIDDLE="2",s.HIGH="3",s))(Ie||{});const _={LEVEL_1:1,LEVEL_2:2,LEVEL_3:4},Ze={OPEN:_.LEVEL_1,INTERNAL:_.LEVEL_2|_.LEVEL_1,OMP:_.LEVEL_3|_.LEVEL_2|_.LEVEL_1},He="00000001",q="NO_SEAL_AVAILABLE",Ue="CERTIFICATE_NOT_FOUND",je="CLIENT_CONNECTION_FAILED",Ke="ACCESS_DENIED",ce=[{oid:"1.2.86.21.1.3",key:"trustServiceNo"},{oid:"1.2.156.10260.4.1.1",key:"idCardNo"},{oid:"1.2.156.10260.4.1.4",key:"orgCode"}];function ze(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var F={},le;function Re(){if(le)return F;le=1,F.byteLength=l,F.toByteArray=u,F.fromByteArray=w;for(var s=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,a=n.length;i<a;++i)s[i]=n[i],e[n.charCodeAt(i)]=i;e[45]=62,e[95]=63;function o(y){var g=y.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var S=y.indexOf("=");S===-1&&(S=g);var f=S===g?0:4-S%4;return[S,f]}function l(y){var g=o(y),S=g[0],f=g[1];return(S+f)*3/4-f}function d(y,g,S){return(g+S)*3/4-S}function u(y){var g,S=o(y),f=S[0],E=S[1],k=new t(d(y,f,E)),p=0,P=E>0?f-4:f,I;for(I=0;I<P;I+=4)g=e[y.charCodeAt(I)]<<18|e[y.charCodeAt(I+1)]<<12|e[y.charCodeAt(I+2)]<<6|e[y.charCodeAt(I+3)],k[p++]=g>>16&255,k[p++]=g>>8&255,k[p++]=g&255;return E===2&&(g=e[y.charCodeAt(I)]<<2|e[y.charCodeAt(I+1)]>>4,k[p++]=g&255),E===1&&(g=e[y.charCodeAt(I)]<<10|e[y.charCodeAt(I+1)]<<4|e[y.charCodeAt(I+2)]>>2,k[p++]=g>>8&255,k[p++]=g&255),k}function C(y){return s[y>>18&63]+s[y>>12&63]+s[y>>6&63]+s[y&63]}function h(y,g,S){for(var f,E=[],k=g;k<S;k+=3)f=(y[k]<<16&16711680)+(y[k+1]<<8&65280)+(y[k+2]&255),E.push(C(f));return E.join("")}function w(y){for(var g,S=y.length,f=S%3,E=[],k=16383,p=0,P=S-f;p<P;p+=k)E.push(h(y,p,p+k>P?P:p+k));return f===1?(g=y[S-1],E.push(s[g>>2]+s[g<<4&63]+"==")):f===2&&(g=(y[S-2]<<8)+y[S-1],E.push(s[g>>10]+s[g>>4&63]+s[g<<2&63]+"=")),E.join("")}return F}var Ye=Re();const ue=ze(Ye);class Qe{constructor(){r(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const n=this.deps.get(e);n==null||n(t)}}(function(){try{var s=document.createElement("style");s.appendChild(document.createTextNode("button.svelte-16iv9d0{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-16iv9d0{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-16iv9d0{background-color:#fff;padding:1.25rem;border-radius:.3125rem;width:40%}.model-title.svelte-16iv9d0{color:#303133;font-size:1.125rem;margin-bottom:1.125rem}.modal-visible.svelte-16iv9d0{display:flex}.modal-footer.svelte-16iv9d0{display:flex;align-items:center;justify-content:flex-end;margin-top:1rem}.modal-btn.svelte-16iv9d0{padding:.5rem .9375rem;border-radius:.25rem;font-size:.875rem;border:.0625rem solid #dcdfe6}.success.svelte-16iv9d0{margin-left:.75rem;color:#fff}.slot.svelte-16iv9d0{max-height:12.5rem;overflow-y:scroll}.slot.svelte-16iv9d0::-webkit-scrollbar{display:none}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:11.25rem;height:11.25rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.0625rem solid #ccc;margin-top:.625rem;margin-right:.625rem;border-radius:.25rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:6.25rem;height:6.25rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.625rem;color:#333}.cert-item.svelte-1kh75ag.svelte-1kh75ag{padding:1rem;display:flex;align-items:center;cursor:pointer;border-bottom:.0625rem solid #ebeef5;font-size:1rem}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag{word-break:break-all;color:#373a40}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag:nth-child(1){padding-right:.5rem}.cert-item-selected.svelte-1kh75ag.svelte-1kh75ag{background-color:#f1f1f1}.cert-item-first.svelte-1kh75ag.svelte-1kh75ag{border-top:.0625rem solid #ebeef5}")),document.head.appendChild(s)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var We=Object.defineProperty,Je=(s,e,t)=>e in s?We(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,de=(s,e,t)=>Je(s,typeof e!="symbol"?e+"":e,t);function ee(){}function qe(s,e){for(const t in e)s[t]=e[t];return s}function ke(s){return s()}function he(){return Object.create(null)}function U(s){s.forEach(ke)}function Z(s){return typeof s=="function"}function ve(s,e){return s!=s?e==e:s!==e||s&&typeof s=="object"||typeof s=="function"}function Xe(s){return Object.keys(s).length===0}function et(s,e,t,n){if(s){const i=_e(s,e,t,n);return s[0](i)}}function _e(s,e,t,n){return s[1]&&n?qe(t.ctx.slice(),s[1](n(e))):t.ctx}function tt(s,e,t,n){if(s[2]&&n){const i=s[2](n(t));if(e.dirty===void 0)return i;if(typeof i=="object"){const a=[],o=Math.max(e.dirty.length,i.length);for(let l=0;l<o;l+=1)a[l]=e.dirty[l]|i[l];return a}return e.dirty|i}return e.dirty}function nt(s,e,t,n,i,a){if(i){const o=_e(e,t,n,a);s.p(o,i)}}function st(s){if(s.ctx.length>32){const e=[],t=s.ctx.length/32;for(let n=0;n<t;n++)e[n]=-1;return e}return-1}function ge(s){return s==null?"":s}function L(s,e){s.appendChild(e)}function W(s,e,t){s.insertBefore(e,t||null)}function j(s){s.parentNode&&s.parentNode.removeChild(s)}function pe(s,e){for(let t=0;t<s.length;t+=1)s[t]&&s[t].d(e)}function A(s){return document.createElement(s)}function T(s){return document.createTextNode(s)}function K(){return T(" ")}function it(){return T("")}function G(s,e,t,n){return s.addEventListener(e,t,n),()=>s.removeEventListener(e,t,n)}function B(s,e,t){t==null?s.removeAttribute(e):s.getAttribute(e)!==t&&s.setAttribute(e,t)}function at(s){return Array.from(s.childNodes)}function z(s,e){e=""+e,s.data!==e&&(s.data=e)}function Y(s,e,t,n){t==null?s.style.removeProperty(e):s.style.setProperty(e,t,"")}let se;function H(s){se=s}const x=[],ye=[];let M=[];const Ce=[],rt=Promise.resolve();let te=!1;function ot(){te||(te=!0,rt.then(Le))}function ne(s){M.push(s)}const X=new Set;let b=0;function Le(){if(b!==0)return;const s=se;do{try{for(;b<x.length;){const e=x[b];b++,H(e),ct(e.$$)}}catch(e){throw x.length=0,b=0,e}for(H(null),x.length=0,b=0;ye.length;)ye.pop()();for(let e=0;e<M.length;e+=1){const t=M[e];X.has(t)||(X.add(t),t())}M.length=0}while(x.length);for(;Ce.length;)Ce.pop()();te=!1,X.clear(),H(s)}function ct(s){if(s.fragment!==null){s.update(),U(s.before_update);const e=s.dirty;s.dirty=[-1],s.fragment&&s.fragment.p(s.ctx,e),s.after_update.forEach(ne)}}function lt(s){const e=[],t=[];M.forEach(n=>s.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),M=e}const R=new Set;let ut;function ie(s,e){s&&s.i&&(R.delete(s),s.i(e))}function De(s,e,t,n){if(s&&s.o){if(R.has(s))return;R.add(s),ut.c.push(()=>{R.delete(s)}),s.o(e)}}function Q(s){return(s==null?void 0:s.length)!==void 0?s:Array.from(s)}function dt(s){s&&s.c()}function Be(s,e,t){const{fragment:n,after_update:i}=s.$$;n&&n.m(e,t),ne(()=>{const a=s.$$.on_mount.map(ke).filter(Z);s.$$.on_destroy?s.$$.on_destroy.push(...a):U(a),s.$$.on_mount=[]}),i.forEach(ne)}function Pe(s,e){const t=s.$$;t.fragment!==null&&(lt(t.after_update),U(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ht(s,e){s.$$.dirty[0]===-1&&(x.push(s),ot(),s.$$.dirty.fill(0)),s.$$.dirty[e/31|0]|=1<<e%31}function Ae(s,e,t,n,i,a,o=null,l=[-1]){const d=se;H(s);const u=s.$$={fragment:null,ctx:[],props:a,update:ee,not_equal:i,bound:he(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:he(),dirty:l,skip_bound:!1,root:e.target||d.$$.root};o&&o(u.root);let C=!1;if(u.ctx=t?t(s,e.props||{},(h,w,...y)=>{const g=y.length?y[0]:w;return u.ctx&&i(u.ctx[h],u.ctx[h]=g)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](g),C&&ht(s,h)),w}):[],u.update(),C=!0,U(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const h=at(e.target);u.fragment&&u.fragment.l(h),h.forEach(j)}else u.fragment&&u.fragment.c();e.intro&&ie(s.$$.fragment),Be(s,e.target,e.anchor),Le()}H(d)}class Ne{constructor(){de(this,"$$"),de(this,"$$set")}$destroy(){Pe(this,1),this.$destroy=ee}$on(e,t){if(!Z(t))return ee;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Xe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const gt="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(gt);function yt(s){let e,t,n,i=(s[1]||"标题")+"",a,o,l,d,u,C,h=(s[4]||"取消")+"",w,y,g,S=(s[5]||"确认")+"",f,E,k,p;const P=s[8].default,I=et(P,s,s[7],null);return{c(){e=A("div"),t=A("div"),n=A("div"),a=T(i),o=K(),l=A("div"),I&&I.c(),d=K(),u=A("div"),C=A("button"),w=T(h),y=K(),g=A("button"),f=T(S),B(n,"class","model-title svelte-16iv9d0"),B(l,"class","slot svelte-16iv9d0"),B(C,"class","modal-btn svelte-16iv9d0"),B(g,"class","modal-btn success svelte-16iv9d0"),Y(g,"background-color",s[6]),B(u,"class","modal-footer svelte-16iv9d0"),B(t,"class","modal-content svelte-16iv9d0"),B(e,"class","modal-background modal-visible svelte-16iv9d0")},m(D,N){W(D,e,N),L(e,t),L(t,n),L(n,a),L(t,o),L(t,l),I&&I.m(l,null),L(t,d),L(t,u),L(u,C),L(C,w),L(u,y),L(u,g),L(g,f),E=!0,k||(p=[G(C,"click",function(){Z(s[0])&&s[0].apply(this,arguments)}),G(g,"click",function(){Z(s[2])&&s[2].apply(this,arguments)}),G(t,"click",Ct),G(e,"click",function(){Z(s[3])&&s[3].apply(this,arguments)})],k=!0)},p(D,[N]){s=D,(!E||N&2)&&i!==(i=(s[1]||"标题")+"")&&z(a,i),I&&I.p&&(!E||N&128)&&nt(I,P,s,s[7],E?tt(P,s[7],N,null):st(s[7]),null),(!E||N&16)&&h!==(h=(s[4]||"取消")+"")&&z(w,h),(!E||N&32)&&S!==(S=(s[5]||"确认")+"")&&z(f,S),(!E||N&64)&&Y(g,"background-color",s[6])},i(D){E||(ie(I,D),E=!0)},o(D){De(I,D),E=!1},d(D){D&&j(e),I&&I.d(D),k=!1,U(p)}}}const Ct=s=>s.stopPropagation();function ft(s,e,t){let{$$slots:n={},$$scope:i}=e,{onCancel:a}=e,{title:o}=e,{onOk:l}=e,{onClose:d}=e,{cancelText:u}=e,{okText:C}=e,{theme:h}=e;return s.$$set=w=>{"onCancel"in w&&t(0,a=w.onCancel),"title"in w&&t(1,o=w.title),"onOk"in w&&t(2,l=w.onOk),"onClose"in w&&t(3,d=w.onClose),"cancelText"in w&&t(4,u=w.cancelText),"okText"in w&&t(5,C=w.okText),"theme"in w&&t(6,h=w.theme),"$$scope"in w&&t(7,i=w.$$scope)},[a,o,l,d,u,C,h,i,n]}class wt extends Ne{constructor(e){super(),Ae(this,e,ft,yt,ve,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function fe(s,e,t){const n=s.slice();return n[13]=e[t],n[15]=t,n}function we(s,e,t){const n=s.slice();return n[16]=e[t],n}function me(s){let e,t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"",n;return{c(){e=A("div"),n=T(t),B(e,"class","svelte-1kh75ag"),Y(e,"width",`${100/s[1].length}%`)},m(i,a){W(i,e,a),L(e,n)},p(i,a){a&3&&t!==(t=(i[16].format?i[16].format(i[13]):i[13][i[16].key])+"")&&z(n,t),a&2&&Y(e,"width",`${100/i[1].length}%`)},d(i){i&&j(e)}}}function Se(s){let e,t,n,i,a,o=Q(s[1]),l=[];for(let u=0;u<o.length;u+=1)l[u]=me(we(s,o,u));function d(){return s[12](s[15])}return{c(){e=A("div");for(let u=0;u<l.length;u+=1)l[u].c();t=K(),B(e,"class",n=ge(`cert-item ${s[15]===0?"cert-item-first":""} ${s[15]===s[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(u,C){W(u,e,C);for(let h=0;h<l.length;h+=1)l[h]&&l[h].m(e,null);L(e,t),i||(a=G(e,"click",d),i=!0)},p(u,C){if(s=u,C&3){o=Q(s[1]);let h;for(h=0;h<o.length;h+=1){const w=we(s,o,h);l[h]?l[h].p(w,C):(l[h]=me(w),l[h].c(),l[h].m(e,t))}for(;h<l.length;h+=1)l[h].d(1);l.length=o.length}C&128&&n!==(n=ge(`cert-item ${s[15]===0?"cert-item-first":""} ${s[15]===s[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&B(e,"class",n)},d(u){u&&j(e),pe(l,u),i=!1,a()}}}function mt(s){let e,t=Q(s[0]),n=[];for(let i=0;i<t.length;i+=1)n[i]=Se(fe(s,t,i));return{c(){for(let i=0;i<n.length;i+=1)n[i].c();e=it()},m(i,a){for(let o=0;o<n.length;o+=1)n[o]&&n[o].m(i,a);W(i,e,a)},p(i,a){if(a&131){t=Q(i[0]);let o;for(o=0;o<t.length;o+=1){const l=fe(i,t,o);n[o]?n[o].p(l,a):(n[o]=Se(l),n[o].c(),n[o].m(e.parentNode,e))}for(;o<n.length;o+=1)n[o].d(1);n.length=t.length}},d(i){i&&j(e),pe(n,i)}}}function St(s){let e,t;return e=new wt({props:{onOk:s[9],onClose:s[2],onCancel:s[8],cancelText:s[3],okText:s[4],title:s[6],theme:s[5],$$slots:{default:[mt]},$$scope:{ctx:s}}}),{c(){dt(e.$$.fragment)},m(n,i){Be(e,n,i),t=!0},p(n,[i]){const a={};i&4&&(a.onClose=n[2]),i&8&&(a.cancelText=n[3]),i&16&&(a.okText=n[4]),i&64&&(a.title=n[6]),i&32&&(a.theme=n[5]),i&524419&&(a.$$scope={dirty:i,ctx:n}),e.$set(a)},i(n){t||(ie(e.$$.fragment,n),t=!0)},o(n){De(e.$$.fragment,n),t=!1},d(n){Pe(e,n)}}}function Et(s,e,t){let{data:n=[]}=e,{columns:i=[]}=e,{onCancel:a}=e,{onOk:o}=e,{onClose:l}=e,{cancelText:d=""}=e,{okText:u=""}=e,{theme:C="#409eff"}=e,{title:h=""}=e,w=0;const y=()=>{a(`${h}失败`),l==null||l()},g=()=>{o==null||o(n[w]),l==null||l()},S=f=>t(7,w=f);return s.$$set=f=>{"data"in f&&t(0,n=f.data),"columns"in f&&t(1,i=f.columns),"onCancel"in f&&t(10,a=f.onCancel),"onOk"in f&&t(11,o=f.onOk),"onClose"in f&&t(2,l=f.onClose),"cancelText"in f&&t(3,d=f.cancelText),"okText"in f&&t(4,u=f.okText),"theme"in f&&t(5,C=f.theme),"title"in f&&t(6,h=f.title)},[n,i,l,d,u,C,h,w,y,g,a,o,S]}class It extends Ne{constructor(e){super(),Ae(this,e,Et,St,ve,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class kt{constructor(){r(this,"modalInstance",{current:null});r(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new It({target:document.body,props:v(m({},e),{onCancel:i=>{n({code:-1,msg:i})},onOk:i=>{t(i)},onClose:()=>{this.close()}})})}));r(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const V=new kt;function vt(s=32,e=!0,t=0){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[];if(t=t||n.length,s)for(let a=0;a<s;a++)i[a]=n[0|Math.random()*t];else{let a;i[8]=i[13]=i[18]=i[23]="-",i[14]="4";for(let o=0;o<36;o++)i[o]||(a=0|Math.random()*16,i[o]=n[o===19?a&3|8:a])}return e?(i.shift(),`u${i.join("")}`):i.join("")}const _t=[{key:"CN"},{format:s=>`${s.DevClass}(${s.sn})`}],pt=[{key:"SealId"},{key:"Vid"},{format:s=>`${s.FileName}(${s.FileSize}B)`}],Ee=[{key:"SealId"}],Lt=[{key:"manu"},{key:"sn"}];class Dt{constructor(e){r(this,"socketInstance",null);r(this,"eventBus",new Qe);r(this,"scene");r(this,"isRememberPin",!1);r(this,"pinPolicy");r(this,"socketConfig",null);r(this,"isConnecting",!1);r(this,"messageQueue",[]);r(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});r(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});r(this,"sendMessage",(e,t,n)=>new Promise((i,a)=>{var l;const o=()=>{var h,w;if(((h=this.socketInstance)==null?void 0:h.readyState)!==WebSocket.OPEN){a({errCode:je,msg:"数字证书客户端连接失败"});return}const d=vt(),u=y=>{y.success?i(y.data):a(y)},C={function:e,args:t?[t]:[],msgid:d};(w=this.socketInstance)==null||w.send(JSON.stringify(C)),this.eventBus.on(e,u),this.eventBus.on(d,u)};if(n&&(this.scene&n)!==n){a({errCode:Ke,msg:"无权限执行此操作"});return}if(((l=this.socketInstance)==null?void 0:l.readyState)===WebSocket.OPEN){o();return}this.messageQueue.push(o),this.isConnecting||this.initSocket(this.socketConfig)}));r(this,"flushMsgQueue",()=>{var e;(e=this.messageQueue)==null||e.forEach(t=>t()),this.messageQueue=[]});r(this,"handleEventData",e=>c(this,null,function*(){var t,n,i,a,o,l,d,u;if(e.data instanceof Blob){const C=yield e.data.arrayBuffer(),y=new TextDecoder(navigator.userAgent.includes("Windows")?"gbk":"utf-8").decode(C).replace(/\\(?!(["\\\/bfnrtu]))/g,""),g=JSON.parse(y),S={success:(t=g.result)==null?void 0:t.success,msg:(n=g.result)==null?void 0:n.msg,errCode:(i=g.result)==null?void 0:i.errCode,data:g.data,type:(a=g.result)==null?void 0:a.event},f=(o=g.result)==null?void 0:o.function,E=(l=g.result)==null?void 0:l.msgid;E?this.eventBus.emit(E,S):this.eventBus.emit(f,S),(u=(d=this.socketConfig)==null?void 0:d.onMessage)==null||u.call(d,S)}}));r(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return ue.fromByteArray(t)});r(this,"base64Decode",e=>{const t=ue.toByteArray(e);return new TextDecoder().decode(t)});r(this,"changeIsRememberPin",e=>c(this,null,function*(){this.isRememberPin=e}));r(this,"changePinPolicy",e=>c(this,null,function*(){this.pinPolicy=e}));r(this,"checkCertIsLogin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));r(this,"addUkeyEvents",()=>c(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:He}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,i;(i=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||i.call(t,v(m({},e),{data:(n=e.data)==null?void 0:n[0]}))})}));r(this,"ensureCertLogin",e=>c(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e.ContainerName});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));r(this,"verifyPin",e=>c(this,null,function*(){var t;yield this.sendMessage("GZCA_Login",{ContainerName:e.ContainerName,IsLogin:e.UserPin?"Y":"N",UserPin:(t=e.UserPin)!=null?t:"123456",PinPolicy:this.pinPolicy})}));r(this,"getCert",(e,t,n)=>c(this,null,function*(){const i=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.ensureCertLogin({ContainerName:i.ContainerName})),i}));r(this,"chooseCert",e=>c(this,null,function*(){var i;const t=yield this.getCertList(e);return t!=null&&t.length?(t==null?void 0:t.length)===1?t[0]:yield V.open({title:"选择证书",data:t,columns:_t,theme:(i=this.socketConfig)==null?void 0:i.theme}):Promise.reject({errCode:Ue,msg:"暂无证书"})}));r(this,"getCertList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));r(this,"pkcs1Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",m({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));r(this,"pkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",m({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));r(this,"batchPkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",m({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));r(this,"pkcs1VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));r(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));r(this,"getSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",m({IsLogin:this.getIsLogin()},e!=null?e:{}),_.LEVEL_2)}));r(this,"writeSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",m({IsLogin:this.getIsLogin()},e!=null?e:{}),_.LEVEL_2)}));r(this,"deleteSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",m({IsLogin:this.getIsLogin()},e!=null?e:{}),_.LEVEL_2)}));r(this,"getSealInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",m({IsLogin:this.getIsLogin()},e!=null?e:{}),_.LEVEL_2)}));r(this,"getTPSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",m({IsLogin:this.getIsLogin()},e!=null?e:{}),_.LEVEL_2)}));r(this,"getTPSealPic",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicData",m({IsLogin:this.getIsLogin()},e!=null?e:{}),_.LEVEL_2)}));r(this,"sm2SignPreprocess1",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));r(this,"sm2SignPreprocess2",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));r(this,"pkcs1HashSign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",m({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));r(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));r(this,"pkcs7Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",m({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));r(this,"pkcs7VerifySignature",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));r(this,"sm3Hash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));r(this,"sm3HexHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));r(this,"sm3FileHash",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));r(this,"sm3HashEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));r(this,"pkcs7Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));r(this,"pkcs7Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",m({IsLogin:this.getIsLogin()},e!=null?e:{}))}));r(this,"pkcs7FileEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeSealFileEx_qyzc",e)}));r(this,"pkcs7FileDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeOpenFileEx_qyzc",m({IsLogin:this.getIsLogin()},e!=null?e:{}))}));r(this,"asymmetricEncryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));r(this,"asymmetricDecryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",m({IsLogin:this.getIsLogin()},e!=null?e:{}))}));r(this,"sm4Encryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));r(this,"sm4Decryption",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));r(this,"getCertInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));r(this,"getCertInfoByOid",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));r(this,"getSealVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealIssuer",e,_.LEVEL_2)}));r(this,"deleteAllSealByVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",m({IsLogin:this.getIsLogin()},e!=null?e:{}),_.LEVEL_2)}));r(this,"applyCert",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ApplyCert",{manu:e.manu,sn:e.sn,keyid:e.ContainerName,type:e.type,url:e.url},_.LEVEL_3)}));r(this,"resetPin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_UnblockUserPin",m({},e!=null?e:{}),_.LEVEL_3)}));r(this,"getUKeyList",()=>c(this,null,function*(){return yield this.sendMessage("GetUKeyList",void 0,_.LEVEL_3)}));r(this,"getUKeyInfo",e=>c(this,null,function*(){return yield this.sendMessage("GetUKeyID",e!=null?e:{},_.LEVEL_3)}));var t,n,i;this.socketConfig=e,this.initSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.scene=(n=e.scene)!=null?n:Ze.OPEN,this.pinPolicy=(i=e.pinPolicy)!=null?i:Ie.MIN}initSocket(e){this.isConnecting=!0;const t=new WebSocket(e.url);t.onerror=n=>{var i;this.isConnecting=!1,(i=e.onError)==null||i.call(e,n),this.flushMsgQueue()},t.onopen=n=>{var i;this.isConnecting=!1,(i=e.onOpen)==null||i.call(e,n),e.onUkeyChange&&this.addUkeyEvents(),this.flushMsgQueue()},t.onmessage=n=>{this.handleEventData(n)},t.onclose=n=>{var i;this.isConnecting=!1,(i=e.onClose)==null||i.call(e,n)},this.socketInstance=t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const $=class ${constructor(e){r(this,"coreInstance",null);r(this,"gwsConfig",{});r(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new Dt(v(m({},e!=null?e:{}),{url:Oe}))});r(this,"appendCertBase64",(e,t=!0)=>c(this,null,function*(){if(e.CertB64)return e;const n=t?yield this.getSignatureCert():yield this.getEncryptionCert();return v(m({},e!=null?e:{}),{CertB64:n==null?void 0:n.CertB64})}));r(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});r(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});r(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});r(this,"verifyPin",(e,t)=>c(this,null,function*(){var i,a;const n=yield this.getSignatureCert(t);return(a=this.coreInstance)==null?void 0:a.verifyPin({ContainerName:(i=n==null?void 0:n.ContainerName)!=null?i:"",UserPin:e==null?void 0:e.UserPin})}));r(this,"ensureCertLogin",e=>c(this,null,function*(){var i,a;const t=yield this.getSignatureCert(e);return yield(a=this.coreInstance)==null?void 0:a.ensureCertLogin({ContainerName:(i=t==null?void 0:t.ContainerName)!=null?i:""})}));r(this,"getSignatureCert",(e,t=!0)=>c(this,null,function*(){var i;return yield(i=this.coreInstance)==null?void 0:i.getCert({CertType:re},e,t)}));r(this,"getSignatureCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:re})}));r(this,"getEncryptionCert",(e,t=!0)=>c(this,null,function*(){var i;return yield(i=this.coreInstance)==null?void 0:i.getCert({CertType:oe},e,t)}));r(this,"getEncryptionCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:oe})}));r(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});r(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});r(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});r(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});r(this,"pkcs1Sign",(e,t)=>c(this,null,function*(){var a,o,l;const n=yield this.getSignatureCert(t),i=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(v(m({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""}));return(l=i==null?void 0:i[0])==null?void 0:l.SignData}));r(this,"pkcs1VerifySignature",e=>c(this,null,function*(){var i;const t=yield this.appendCertBase64(e),n=yield(i=this.coreInstance)==null?void 0:i.pkcs1VerifySignature(t);return Array.isArray(n)}));r(this,"pkcs1Base64Sign",(e,t)=>c(this,null,function*(){var o,l,d,u,C;const n=yield this.getSignatureCert(t),i=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),a=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign(v(m({},e!=null?e:{}),{ContainerName:(d=n==null?void 0:n.ContainerName)!=null?d:"",DataB64:i}));return(C=a==null?void 0:a[0])==null?void 0:C.SignData}));r(this,"batchPkcs1Base64Sign",(e,t)=>c(this,null,function*(){var C,h,w,y,g,S;const n="|",i=(h=e.DataB64)!=null?h:(C=e.Data)==null?void 0:C.map(f=>this.base64Encode({Data:f})),a=yield this.getSignatureCert(t);let o="";o=Array.isArray(i)?i==null?void 0:i.map((f,E)=>`${E}:${f}`).join(n):"";const l=yield(y=this.coreInstance)==null?void 0:y.batchPkcs1Base64Sign({ContainerName:(w=a==null?void 0:a.ContainerName)!=null?w:"",DataB64:o}),d=(S=(g=l==null?void 0:l[0])==null?void 0:g.SignData)==null?void 0:S.split(n),u=[];return d.forEach(f=>{const E=f.split(":"),k=Number(E[0]),p=E[1];u[k]=p}),u}));r(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){var a,o,l;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:n.CertB64,DataB64:t,SignData:n.SignData}))}));r(this,"writeSeal",(e,t)=>c(this,null,function*(){var a,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.writeSeal(v(m({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""})))}));r(this,"deleteSeal",e=>c(this,null,function*(){var o,l,d,u,C;const t=yield this.getSealList(e);if(!((o=t==null?void 0:t.data)!=null&&o.length))return Promise.reject({errCode:q,msg:"暂无印章"});const n=yield V.open({title:"删除印章",data:t==null?void 0:t.data,columns:Ee,okText:"删除"}),i=(l=n==null?void 0:n.SealId)!=null?l:"";return!!(yield(C=this.coreInstance)==null?void 0:C.deleteSeal({ContainerName:(u=(d=t==null?void 0:t.cert)==null?void 0:d.ContainerName)!=null?u:"",SealId:i}))}));r(this,"deleteSealById",(e,t)=>c(this,null,function*(){var a,o;const n=yield this.getSignatureCert(t);return!!(yield(o=this.coreInstance)==null?void 0:o.deleteSeal(v(m({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""})))}));r(this,"getSealList",e=>c(this,null,function*(){var i,a;const t=yield this.getSignatureCert(e),n=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(i=t==null?void 0:t.ContainerName)!=null?i:"",IsLogin:"Y"});return{cert:t,data:n}}));r(this,"getSealInfo",e=>c(this,null,function*(){var a,o,l,d,u,C,h;const t=yield this.getSealList(e);if(!((a=t==null?void 0:t.data)!=null&&a.length))return Promise.reject({errCode:q,msg:"暂无印章"});const n=((o=t==null?void 0:t.data)==null?void 0:o.length)>1?yield V.open({title:"选择印章",data:t==null?void 0:t.data,columns:Ee,theme:(l=this.gwsConfig)==null?void 0:l.theme}):t==null?void 0:t.data[0],i=yield(h=this.coreInstance)==null?void 0:h.getSealInfo({ContainerName:(u=(d=t==null?void 0:t.cert)==null?void 0:d.ContainerName)!=null?u:"",SealId:(C=n==null?void 0:n.SealId)!=null?C:""});return i==null?void 0:i[0]}));r(this,"getTPSealList",(e,t)=>c(this,null,function*(){var a,o;const n=yield this.getSignatureCert(t);return yield(o=this.coreInstance)==null?void 0:o.getTPSealList(m({ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""},e!=null?e:{}))}));r(this,"getTPSeal",(e,t)=>c(this,null,function*(){var a;const n=yield this.getTPSealList(e,t);return n!=null&&n.length?(n==null?void 0:n.length)===1?n==null?void 0:n[0]:yield V.open({title:"选择印章",data:n,columns:pt,theme:(a=this.gwsConfig)==null?void 0:a.theme}):Promise.reject({errCode:q,msg:"暂无印章"})}));r(this,"getTPSealPic",(e,t,n)=>c(this,null,function*(){var l,d;const i=yield this.getSignatureCert(t),a=n||(yield this.getTPSeal(e,t)),o=yield(d=this.coreInstance)==null?void 0:d.getTPSealPic(v(m(m({ContainerName:(l=i==null?void 0:i.ContainerName)!=null?l:""},a!=null?a:{}),e!=null?e:{}),{FileSize:String(a==null?void 0:a.FileSize)}));return o==null?void 0:o[0]}));r(this,"sm2SignPreprocess1",e=>c(this,null,function*(){var i,a;const t=yield this.appendCertBase64(e),n=yield(i=this.coreInstance)==null?void 0:i.sm2SignPreprocess1(t);return(a=n==null?void 0:n[0])==null?void 0:a.Z}));r(this,"sm2SignPreprocess2",e=>c(this,null,function*(){var a,o;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=yield this.appendCertBase64(e),i=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return i==null?void 0:i[0].H}));r(this,"pkcs1HashSign",(e,t)=>c(this,null,function*(){var a,o,l,d;const n=yield this.getSignatureCert(t),i=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(d=i==null?void 0:i[0])==null?void 0:d.SignData}));r(this,"pkcs1HashVerifySignature",e=>c(this,null,function*(){var i,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(v(m({},t),{HashAlg:(i=t.HashAlg)!=null?i:"sm3"})))}));r(this,"pkcs7Sign",(e,t)=>c(this,null,function*(){var o,l,d,u,C;const n=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),i=yield this.getSignatureCert(t),a=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign(v(m({},e!=null?e:{}),{ContainerName:(d=i==null?void 0:i.ContainerName)!=null?d:"",DataB64:n}));return(C=a==null?void 0:a[0])==null?void 0:C.SignData}));r(this,"pkcs7VerifySignature",e=>c(this,null,function*(){var i,a,o;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(i=e.Data)!=null?i:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));r(this,"sm3Hash",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.sm3Hash(e);return(i=t==null?void 0:t[0])==null?void 0:i.HashB64}));r(this,"sm3HexHash",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.sm3HexHash(e);return(i=t==null?void 0:t[0])==null?void 0:i.HashB64}));r(this,"sm3FileHash",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.sm3FileHash(e);return(i=t==null?void 0:t[0])==null?void 0:i.HashB64}));r(this,"sm3HashEncryption",e=>c(this,null,function*(){var a,o,l,d,u,C;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=(d=e.KeyB64)!=null?d:this.base64Encode({Data:(l=e.Key)!=null?l:""}),i=yield(u=this.coreInstance)==null?void 0:u.sm3HashEncryption({dataB64:t,keyB64:n,alg:"sm3"});return(C=i==null?void 0:i[0])==null?void 0:C.DataB64}));r(this,"pkcs7Encryption",e=>c(this,null,function*(){var i,a,o,l;if(!e.CertB64List){const d=yield this.getEncryptionCert();e.CertB64List=d==null?void 0:d.CertB64}const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(i=e.Data)!=null?i:""}),n=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(l=n==null?void 0:n[0])==null?void 0:l.DataB64}));r(this,"pkcs7Decryption",e=>c(this,null,function*(){var a,o;const t=yield this.getEncryptionCert(),n=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption(v(m({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),i=(o=n==null?void 0:n[0])==null?void 0:o.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:i}):i}));r(this,"pkcs7FileEncryption",e=>c(this,null,function*(){var i,a;const t=yield this.appendCertBase64(e,!1),n=yield(i=this.coreInstance)==null?void 0:i.pkcs7FileEncryption(t);return(a=n==null?void 0:n[0])==null?void 0:a.DataB64}));r(this,"pkcs7FileDecryption",e=>c(this,null,function*(){var i,a,o;const t=yield this.getEncryptionCert(),n=yield(a=this.coreInstance)==null?void 0:a.pkcs7FileDecryption({SrcFile:e.SrcFile,DstFile:(i=e.DstFile)!=null?i:e.SrcFile.slice(0,-4),ContainerName:t==null?void 0:t.ContainerName});return(o=n==null?void 0:n[0])==null?void 0:o.DataB64}));r(this,"asymmetricEncryption",e=>c(this,null,function*(){var i,a;const t=yield this.appendCertBase64(e,!1),n=yield(i=this.coreInstance)==null?void 0:i.asymmetricEncryption(t);return(a=n==null?void 0:n[0])==null?void 0:a.Data}));r(this,"asymmetricDecryption",(e,t)=>c(this,null,function*(){var a,o;const n=yield this.getEncryptionCert(t),i=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption(v(m({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(o=i==null?void 0:i[0])==null?void 0:o.Data}));r(this,"sm4Encryption",e=>c(this,null,function*(){var n;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Encryption(e);return t==null?void 0:t[0]}));r(this,"sm4Decryption",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Decryption(e);return(i=t==null?void 0:t[0])==null?void 0:i.Data}));r(this,"getCertInfo",e=>c(this,null,function*(){var i,a,o,l,d;const t=yield(i=this.coreInstance)==null?void 0:i.getCertInfo(e),n=(a=t==null?void 0:t[0])!=null?a:{};for(let u=0;u<ce.length;u++){const C=ce[u];try{const h=yield(o=this.coreInstance)==null?void 0:o.getCertInfoByOid({Oid:C.oid,CertB64:e.CertB64});n[C.key]=(d=(l=h==null?void 0:h[0])==null?void 0:l.OidValue)==null?void 0:d.replace(".","")}catch(h){n[C.key]=null}}return n!=null&&n.idCardNo?n!=null&&n.CertSubject.includes("O=")||n.orgCode?n.certCate=Ge:n.certCate=Fe:n.certCate=Ve,n}));r(this,"getCertInfoByOid",e=>c(this,null,function*(){var n,i;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(m({},e!=null?e:{}));return(i=t==null?void 0:t[0])==null?void 0:i.OidValue}));r(this,"getSealVendor",e=>c(this,null,function*(){var i;const t=yield this.getSignatureCert(e),n=yield(i=this.coreInstance)==null?void 0:i.getSealVendor({ContainerName:t==null?void 0:t.ContainerName});return n==null?void 0:n[0]}));r(this,"deleteAllSealByVendor",(e,t)=>c(this,null,function*(){var a;const n=yield this.getSignatureCert(t),i=yield(a=this.coreInstance)==null?void 0:a.deleteAllSealByVendor(v(m({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return i==null?void 0:i[0]}));r(this,"getUKey",e=>c(this,null,function*(){var i,a;if(e)return e;const t=yield(i=this.coreInstance)==null?void 0:i.getUKeyList();return yield V.open({title:"选择介质",data:t,columns:Lt,theme:(a=this.gwsConfig)==null?void 0:a.theme})}));r(this,"getUKeyList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getUKeyList()}));r(this,"getUKeyInfo",e=>c(this,null,function*(){var i;const t=yield this.getUKey(e),n=yield(i=this.coreInstance)==null?void 0:i.getUKeyInfo({manu:t==null?void 0:t.manu,sn:t==null?void 0:t.sn});return n==null?void 0:n[0]}));r(this,"applyCert",(e,t)=>c(this,null,function*(){var o;const n=yield this.getUKey(t),i=yield this.getUKeyInfo(n);return yield(o=this.coreInstance)==null?void 0:o.applyCert(v(m({},e!=null?e:{}),{manu:i==null?void 0:i.manu,sn:i==null?void 0:i.sn,ContainerName:i==null?void 0:i.keyid}))}));r(this,"resetPin",(e,t)=>c(this,null,function*(){var a;const n=yield this.getSignatureCert(t);return yield(a=this.coreInstance)==null?void 0:a.resetPin(v(m({},e!=null?e:{}),{manu:n==null?void 0:n.manu,sn:n==null?void 0:n.sn,ContainerName:n==null?void 0:n.ContainerName}))}));return $.instance&&!(e!=null&&e.isCreateNew)?$.instance:(this.createGwsCore(e),$.instance=this,this)}};r($,"instance",null);let O=$;function Bt(s){return new Promise((e,t)=>{if(O.instance&&!(s!=null&&s.isCreateNew))e(O.instance);else{const n=new O(v(m({},s!=null?s:{}),{onOpen(i){var a;e(n),(a=s==null?void 0:s.onOpen)==null||a.call(s,i)},onClose(i){var a;t(i),(a=s==null?void 0:s.onClose)==null||a.call(s,i)}}))}})}exports.GwsService=O;exports.createService=Bt;
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare class GwsService {
|
|
|
24
24
|
verifyPin: (params: {
|
|
25
25
|
UserPin?: string;
|
|
26
26
|
}, curCert?: CertType) => Promise<void | undefined>;
|
|
27
|
+
ensureCertLogin: (curCert?: CertType) => Promise<void | undefined>;
|
|
27
28
|
getSignatureCert: (cert?: CertType, checkLogin?: boolean) => Promise<Record<string, any> | undefined>;
|
|
28
29
|
getSignatureCertList: () => Promise<CertType[] | undefined>;
|
|
29
30
|
getEncryptionCert: (cert?: CertType, checkLogin?: boolean) => Promise<Record<string, any> | undefined>;
|
|
@@ -78,22 +79,15 @@ export declare class GwsService {
|
|
|
78
79
|
getSealInfo: (curCert?: CertType) => Promise<any>;
|
|
79
80
|
getTPSealList: (params?: {
|
|
80
81
|
Vid?: string;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
FileSize: number;
|
|
84
|
-
SealId: string;
|
|
85
|
-
Vid: string;
|
|
86
|
-
}[]>;
|
|
82
|
+
IsLogin?: string;
|
|
83
|
+
}, curCert?: CertType) => Promise<TPSeaType[]>;
|
|
87
84
|
getTPSeal: (params?: {
|
|
88
85
|
Vid: string;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
FileSize: number;
|
|
92
|
-
SealId: string;
|
|
93
|
-
Vid: string;
|
|
94
|
-
}>;
|
|
86
|
+
IsLogin?: string;
|
|
87
|
+
}, curCert?: CertType) => Promise<Record<string, any> | TPSeaType>;
|
|
95
88
|
getTPSealPic: (params?: {
|
|
96
89
|
Vid: string;
|
|
90
|
+
IsLogin?: string;
|
|
97
91
|
}, curCert?: CertType, curSeal?: TPSeaType) => Promise<any>;
|
|
98
92
|
sm2SignPreprocess1: (params: {
|
|
99
93
|
CertB64?: string;
|