gws-client 1.2.7 → 1.3.1

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