gws-client 1.2.3 → 1.2.4
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 +1 -0
- package/dist/index.es.js +161 -157
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_,k){typeof exports=="object"&&typeof module!="undefined"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(_=typeof globalThis!="undefined"?globalThis:_||self,k(_.GWS_CLIENT={}))})(this,function(_){"use strict";var _t=Object.defineProperty,Lt=Object.defineProperties;var Bt=Object.getOwnPropertyDescriptors;var Oe=Object.getOwnPropertySymbols;var Pt=Object.prototype.hasOwnProperty,At=Object.prototype.propertyIsEnumerable;var ge=(_,k,L)=>k in _?_t(_,k,{enumerable:!0,configurable:!0,writable:!0,value:L}):_[k]=L,E=(_,k)=>{for(var L in k||(k={}))Pt.call(k,L)&&ge(_,L,k[L]);if(Oe)for(var L of Oe(k))At.call(k,L)&&ge(_,L,k[L]);return _},B=(_,k)=>Lt(_,Bt(k));var o=(_,k,L)=>ge(_,typeof k!="symbol"?k+"":k,L);var c=(_,k,L)=>new Promise((Q,J)=>{var ie=I=>{try{T(L.next(I))}catch(H){J(H)}},re=I=>{try{T(L.throw(I))}catch(H){J(H)}},T=I=>I.done?Q(I.value):Promise.resolve(I.value).then(ie,re);T((L=L.apply(_,k)).next())});const k=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",L="1",Q="2",J="1",ie="2",re="3";var T=(i=>(i.MIN="0",i.LOW="1",i.MIDDLE="2",i.HIGH="3",i))(T||{});const I={LEVEL_1:1,LEVEL_2:2,LEVEL_3:4},H={OPEN:I.LEVEL_1,INTERNAL:I.LEVEL_2|I.LEVEL_1,OMP:I.LEVEL_3|I.LEVEL_2|I.LEVEL_1},Ge="00000001",ae="NO_SEAL_AVAILABLE",Fe="CERTIFICATE_NOT_FOUND",Ve="CLIENT_CONNECTION_FAILED",Ze="ACCESS_DENIED",ye=[{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 He(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var U={},fe;function Ue(){if(fe)return U;fe=1,U.byteLength=l,U.toByteArray=u,U.fromByteArray=w;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 a(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 C=m===g?0:4-m%4;return[m,C]}function l(y){var g=a(y),m=g[0],C=g[1];return(m+C)*3/4-C}function d(y,g,m){return(g+m)*3/4-m}function u(y){var g,m=a(y),C=m[0],S=m[1],p=new t(d(y,C,S)),P=0,x=S>0?C-4:C,v;for(v=0;v<x;v+=4)g=e[y.charCodeAt(v)]<<18|e[y.charCodeAt(v+1)]<<12|e[y.charCodeAt(v+2)]<<6|e[y.charCodeAt(v+3)],p[P++]=g>>16&255,p[P++]=g>>8&255,p[P++]=g&255;return S===2&&(g=e[y.charCodeAt(v)]<<2|e[y.charCodeAt(v+1)]>>4,p[P++]=g&255),S===1&&(g=e[y.charCodeAt(v)]<<10|e[y.charCodeAt(v+1)]<<4|e[y.charCodeAt(v+2)]>>2,p[P++]=g>>8&255,p[P++]=g&255),p}function f(y){return i[y>>18&63]+i[y>>12&63]+i[y>>6&63]+i[y&63]}function h(y,g,m){for(var C,S=[],p=g;p<m;p+=3)C=(y[p]<<16&16711680)+(y[p+1]<<8&65280)+(y[p+2]&255),S.push(f(C));return S.join("")}function w(y){for(var g,m=y.length,C=m%3,S=[],p=16383,P=0,x=m-C;P<x;P+=p)S.push(h(y,P,P+p>x?x:P+p));return C===1?(g=y[m-1],S.push(i[g>>2]+i[g<<4&63]+"==")):C===2&&(g=(y[m-2]<<8)+y[m-1],S.push(i[g>>10]+i[g>>4&63]+i[g<<2&63]+"=")),S.join("")}return U}var je=Ue();const Ce=He(je);class Ke{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 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 ze=Object.defineProperty,Re=(i,e,t)=>e in i?ze(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,we=(i,e,t)=>Re(i,typeof e!="symbol"?e+"":e,t);function oe(){}function We(i,e){for(const t in e)i[t]=e[t];return i}function me(i){return i()}function Ee(){return Object.create(null)}function j(i){i.forEach(me)}function K(i){return typeof i=="function"}function Se(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Ye(i){return Object.keys(i).length===0}function Qe(i,e,t,n){if(i){const s=Ie(i,e,t,n);return i[0](s)}}function Ie(i,e,t,n){return i[1]&&n?We(t.ctx.slice(),i[1](n(e))):t.ctx}function Je(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=[],a=Math.max(e.dirty.length,s.length);for(let l=0;l<a;l+=1)r[l]=e.dirty[l]|s[l];return r}return e.dirty|s}return e.dirty}function qe(i,e,t,n,s,r){if(s){const a=Ie(e,t,n,r);i.p(a,s)}}function Xe(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 ke(i){return i==null?"":i}function A(i,e){i.appendChild(e)}function q(i,e,t){i.insertBefore(e,t||null)}function z(i){i.parentNode&&i.parentNode.removeChild(i)}function ve(i,e){for(let t=0;t<i.length;t+=1)i[t]&&i[t].d(e)}function N(i){return document.createElement(i)}function M(i){return document.createTextNode(i)}function X(){return M(" ")}function et(){return M("")}function R(i,e,t,n){return i.addEventListener(e,t,n),()=>i.removeEventListener(e,t,n)}function D(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function tt(i){return Array.from(i.childNodes)}function ee(i,e){e=""+e,i.data!==e&&(i.data=e)}function te(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}let ce;function W(i){ce=i}const O=[],pe=[];let G=[];const _e=[],nt=Promise.resolve();let le=!1;function st(){le||(le=!0,nt.then(Le))}function ue(i){G.push(i)}const de=new Set;let F=0;function Le(){if(F!==0)return;const i=ce;do{try{for(;F<O.length;){const e=O[F];F++,W(e),it(e.$$)}}catch(e){throw O.length=0,F=0,e}for(W(null),O.length=0,F=0;pe.length;)pe.pop()();for(let e=0;e<G.length;e+=1){const t=G[e];de.has(t)||(de.add(t),t())}G.length=0}while(O.length);for(;_e.length;)_e.pop()();le=!1,de.clear(),W(i)}function it(i){if(i.fragment!==null){i.update(),j(i.before_update);const e=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,e),i.after_update.forEach(ue)}}function rt(i){const e=[],t=[];G.forEach(n=>i.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),G=e}const ne=new Set;let at;function he(i,e){i&&i.i&&(ne.delete(i),i.i(e))}function Be(i,e,t,n){if(i&&i.o){if(ne.has(i))return;ne.add(i),at.c.push(()=>{ne.delete(i)}),i.o(e)}}function se(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function ot(i){i&&i.c()}function Pe(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ue(()=>{const r=i.$$.on_mount.map(me).filter(K);i.$$.on_destroy?i.$$.on_destroy.push(...r):j(r),i.$$.on_mount=[]}),s.forEach(ue)}function Ae(i,e){const t=i.$$;t.fragment!==null&&(rt(t.after_update),j(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ct(i,e){i.$$.dirty[0]===-1&&(O.push(i),st(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<<e%31}function De(i,e,t,n,s,r,a=null,l=[-1]){const d=ce;W(i);const u=i.$$={fragment:null,ctx:[],props:r,update:oe,not_equal:s,bound:Ee(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:Ee(),dirty:l,skip_bound:!1,root:e.target||d.$$.root};a&&a(u.root);let f=!1;if(u.ctx=t?t(i,e.props||{},(h,w,...y)=>{const g=y.length?y[0]:w;return u.ctx&&s(u.ctx[h],u.ctx[h]=g)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](g),f&&ct(i,h)),w}):[],u.update(),f=!0,j(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const h=tt(e.target);u.fragment&&u.fragment.l(h),h.forEach(z)}else u.fragment&&u.fragment.c();e.intro&&he(i.$$.fragment),Pe(i,e.target,e.anchor),Le()}W(d)}class be{constructor(){we(this,"$$"),we(this,"$$set")}$destroy(){Ae(this,1),this.$destroy=oe}$on(e,t){if(!K(t))return oe;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&&!Ye(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const lt="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(lt);function ut(i){let e,t,n,s=(i[1]||"标题")+"",r,a,l,d,u,f,h=(i[4]||"取消")+"",w,y,g,m=(i[5]||"确认")+"",C,S,p,P;const x=i[8].default,v=Qe(x,i,i[7],null);return{c(){e=N("div"),t=N("div"),n=N("div"),r=M(s),a=X(),l=N("div"),v&&v.c(),d=X(),u=N("div"),f=N("button"),w=M(h),y=X(),g=N("button"),C=M(m),D(n,"class","model-title svelte-16iv9d0"),D(l,"class","slot svelte-16iv9d0"),D(f,"class","modal-btn svelte-16iv9d0"),D(g,"class","modal-btn success svelte-16iv9d0"),te(g,"background-color",i[6]),D(u,"class","modal-footer svelte-16iv9d0"),D(t,"class","modal-content svelte-16iv9d0"),D(e,"class","modal-background modal-visible svelte-16iv9d0")},m(b,$){q(b,e,$),A(e,t),A(t,n),A(n,r),A(t,a),A(t,l),v&&v.m(l,null),A(t,d),A(t,u),A(u,f),A(f,w),A(u,y),A(u,g),A(g,C),S=!0,p||(P=[R(f,"click",function(){K(i[0])&&i[0].apply(this,arguments)}),R(g,"click",function(){K(i[2])&&i[2].apply(this,arguments)}),R(t,"click",dt),R(e,"click",function(){K(i[3])&&i[3].apply(this,arguments)})],p=!0)},p(b,[$]){i=b,(!S||$&2)&&s!==(s=(i[1]||"标题")+"")&&ee(r,s),v&&v.p&&(!S||$&128)&&qe(v,x,i,i[7],S?Je(x,i[7],$,null):Xe(i[7]),null),(!S||$&16)&&h!==(h=(i[4]||"取消")+"")&&ee(w,h),(!S||$&32)&&m!==(m=(i[5]||"确认")+"")&&ee(C,m),(!S||$&64)&&te(g,"background-color",i[6])},i(b){S||(he(v,b),S=!0)},o(b){Be(v,b),S=!1},d(b){b&&z(e),v&&v.d(b),p=!1,j(P)}}}const dt=i=>i.stopPropagation();function ht(i,e,t){let{$$slots:n={},$$scope:s}=e,{onCancel:r}=e,{title:a}=e,{onOk:l}=e,{onClose:d}=e,{cancelText:u}=e,{okText:f}=e,{theme:h}=e;return i.$$set=w=>{"onCancel"in w&&t(0,r=w.onCancel),"title"in w&&t(1,a=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,f=w.okText),"theme"in w&&t(6,h=w.theme),"$$scope"in w&&t(7,s=w.$$scope)},[r,a,l,d,u,f,h,s,n]}class gt extends be{constructor(e){super(),De(this,e,ht,ut,Se,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function Ne(i,e,t){const n=i.slice();return n[13]=e[t],n[15]=t,n}function xe(i,e,t){const n=i.slice();return n[16]=e[t],n}function $e(i){let e,t=(i[16].format?i[16].format(i[13]):i[13][i[16].key])+"",n;return{c(){e=N("div"),n=M(t),D(e,"class","svelte-1kh75ag"),te(e,"width",`${100/i[1].length}%`)},m(s,r){q(s,e,r),A(e,n)},p(s,r){r&3&&t!==(t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"")&&ee(n,t),r&2&&te(e,"width",`${100/s[1].length}%`)},d(s){s&&z(e)}}}function Te(i){let e,t,n,s,r,a=se(i[1]),l=[];for(let u=0;u<a.length;u+=1)l[u]=$e(xe(i,a,u));function d(){return i[12](i[15])}return{c(){e=N("div");for(let u=0;u<l.length;u+=1)l[u].c();t=X(),D(e,"class",n=ke(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(u,f){q(u,e,f);for(let h=0;h<l.length;h+=1)l[h]&&l[h].m(e,null);A(e,t),s||(r=R(e,"click",d),s=!0)},p(u,f){if(i=u,f&3){a=se(i[1]);let h;for(h=0;h<a.length;h+=1){const w=xe(i,a,h);l[h]?l[h].p(w,f):(l[h]=$e(w),l[h].c(),l[h].m(e,t))}for(;h<l.length;h+=1)l[h].d(1);l.length=a.length}f&128&&n!==(n=ke(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&D(e,"class",n)},d(u){u&&z(e),ve(l,u),s=!1,r()}}}function yt(i){let e,t=se(i[0]),n=[];for(let s=0;s<t.length;s+=1)n[s]=Te(Ne(i,t,s));return{c(){for(let s=0;s<n.length;s+=1)n[s].c();e=et()},m(s,r){for(let a=0;a<n.length;a+=1)n[a]&&n[a].m(s,r);q(s,e,r)},p(s,r){if(r&131){t=se(s[0]);let a;for(a=0;a<t.length;a+=1){const l=Ne(s,t,a);n[a]?n[a].p(l,r):(n[a]=Te(l),n[a].c(),n[a].m(e.parentNode,e))}for(;a<n.length;a+=1)n[a].d(1);n.length=t.length}},d(s){s&&z(e),ve(n,s)}}}function ft(i){let e,t;return e=new gt({props:{onOk:i[9],onClose:i[2],onCancel:i[8],cancelText:i[3],okText:i[4],title:i[6],theme:i[5],$$slots:{default:[yt]},$$scope:{ctx:i}}}),{c(){ot(e.$$.fragment)},m(n,s){Pe(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||(he(e.$$.fragment,n),t=!0)},o(n){Be(e.$$.fragment,n),t=!1},d(n){Ae(e,n)}}}function Ct(i,e,t){let{data:n=[]}=e,{columns:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:l}=e,{cancelText:d=""}=e,{okText:u=""}=e,{theme:f="#409eff"}=e,{title:h=""}=e,w=0;const y=()=>{r(`${h}失败`),l==null||l()},g=()=>{a==null||a(n[w]),l==null||l()},m=C=>t(7,w=C);return i.$$set=C=>{"data"in C&&t(0,n=C.data),"columns"in C&&t(1,s=C.columns),"onCancel"in C&&t(10,r=C.onCancel),"onOk"in C&&t(11,a=C.onOk),"onClose"in C&&t(2,l=C.onClose),"cancelText"in C&&t(3,d=C.cancelText),"okText"in C&&t(4,u=C.okText),"theme"in C&&t(5,f=C.theme),"title"in C&&t(6,h=C.title)},[n,s,l,d,u,f,h,w,y,g,r,a,m]}class wt extends be{constructor(e){super(),De(this,e,Ct,ft,Se,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class mt{constructor(){o(this,"modalInstance",{current:null});o(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new wt({target:document.body,props:B(E({},e),{onCancel:s=>{n({code:-1,msg:s})},onOk:s=>{t(s)},onClose:()=>{this.close()}})})}));o(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const Y=new mt;function Et(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 a=0;a<36;a++)s[a]||(r=0|Math.random()*16,s[a]=n[a===19?r&3|8:r])}return e?(s.shift(),`u${s.join("")}`):s.join("")}const St=[{key:"CN"},{format:i=>`${i.DevClass}(${i.sn})`}],It=[{key:"SealId"},{key:"Vid"},{format:i=>`${i.FileName}(${i.FileSize}B)`}],Me=[{key:"SealId"}],kt=[{key:"manu"},{key:"sn"}];class vt{constructor(e){o(this,"socketInstance",null);o(this,"eventBus",new Ke);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((s,r)=>{var l;const a=()=>{var h,w;if(((h=this.socketInstance)==null?void 0:h.readyState)!==WebSocket.OPEN){r({errCode:Ve,msg:"数字证书客户端连接失败"});return}const d=Et(),u=y=>{y.success?s(y.data):r(y)},f={function:e,args:t?[t]:[],msgid:d};(w=this.socketInstance)==null||w.send(JSON.stringify(f)),this.eventBus.on(e,u),this.eventBus.on(d,u)};if(n&&(this.scene&n)!==n){r({errCode:Ze,msg:"无权限执行此操作"});return}if(((l=this.socketInstance)==null?void 0:l.readyState)===WebSocket.OPEN){a();return}this.messageQueue.push(a),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,s,r,a,l,d,u;if(e.data instanceof Blob){const f=yield e.data.arrayBuffer(),y=new TextDecoder(navigator.userAgent.includes("Windows")?"gbk":"utf-8").decode(f).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:(s=g.result)==null?void 0:s.errCode,data:g.data,type:(r=g.result)==null?void 0:r.event},C=(a=g.result)==null?void 0:a.function,S=(l=g.result)==null?void 0:l.msgid;S?this.eventBus.emit(S,m):this.eventBus.emit(C,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 Ce.fromByteArray(t)});o(this,"base64Decode",e=>{const t=Ce.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:Ge}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||s.call(t,B(E({},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 s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.certLogin(s.ContainerName)),s}));o(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 Y.open({title:"选择证书",data:t,columns:St,theme:(s=this.socketConfig)==null?void 0:s.theme}):Promise.reject({errCode:Fe,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",E({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",E({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"batchPkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",E({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",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"writeSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"deleteSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"getSealInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"getTPSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"getTPSealPic",e=>c(this,null,function*(){var n;return yield this.sendMessage("GZCA_GetSealPicData",E({IsLogin:(n=e.IsLogin)!=null?n:this.getIsLogin()},e!=null?e:{}),I.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",E({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",E({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",E({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",E({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",E({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,I.LEVEL_2)}));o(this,"deleteAllSealByVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.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},I.LEVEL_3)}));o(this,"resetPin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_UnblockUserPin",E({},e!=null?e:{}),I.LEVEL_3)}));o(this,"getUKeyList",()=>c(this,null,function*(){return yield this.sendMessage("GetUKeyList",void 0,I.LEVEL_3)}));o(this,"getUKeyInfo",e=>c(this,null,function*(){return yield this.sendMessage("GetUKeyID",e!=null?e:{},I.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:H.OPEN,this.pinPolicy=(s=e.pinPolicy)!=null?s:T.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 Z=class Z{constructor(e){o(this,"coreInstance",null);o(this,"gwsConfig",{});o(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new vt(B(E({},e!=null?e:{}),{url:k}))});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 B(E({},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 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})}));o(this,"getSignatureCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:L},e,t)}));o(this,"getSignatureCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:L})}));o(this,"getEncryptionCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:Q},e,t)}));o(this,"getEncryptionCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:Q})}));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 r,a,l;const n=yield this.getSignatureCert(t),s=yield(a=this.coreInstance)==null?void 0:a.pkcs1Sign(B(E({},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}));o(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)}));o(this,"pkcs1Base64Sign",(e,t)=>c(this,null,function*(){var a,l,d,u,f;const n=yield this.getSignatureCert(t),s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(a=e.Data)!=null?a:""}),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign(B(E({},e!=null?e:{}),{ContainerName:(d=n==null?void 0:n.ContainerName)!=null?d:"",DataB64:s}));return(f=r==null?void 0:r[0])==null?void 0:f.SignData}));o(this,"batchPkcs1Base64Sign",(e,t)=>c(this,null,function*(){var f,h,w,y,g,m;const n="|",s=(h=e.DataB64)!=null?h:(f=e.Data)==null?void 0:f.map(C=>this.base64Encode({Data:C})),r=yield this.getSignatureCert(t);let a="";a=Array.isArray(s)?s==null?void 0:s.map((C,S)=>`${S}:${C}`).join(n):"";const l=yield(y=this.coreInstance)==null?void 0:y.batchPkcs1Base64Sign({ContainerName:(w=r==null?void 0:r.ContainerName)!=null?w:"",DataB64:a}),d=(m=(g=l==null?void 0:l[0])==null?void 0:g.SignData)==null?void 0:m.split(n),u=[];return d.forEach(C=>{const S=C.split(":"),p=Number(S[0]),P=S[1];u[p]=P}),u}));o(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){var r,a,l;const t=(a=e.DataB64)!=null?a: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}))}));o(this,"writeSeal",(e,t)=>c(this,null,function*(){var r,a;const n=yield this.getSignatureCert(t);return!!(yield(a=this.coreInstance)==null?void 0:a.writeSeal(B(E({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));o(this,"deleteSeal",e=>c(this,null,function*(){var a,l,d,u,f;const t=yield this.getSealList(e);if(!((a=t==null?void 0:t.data)!=null&&a.length))return Promise.reject({errCode:ae,msg:"暂无印章"});const n=yield Y.open({title:"删除印章",data:t==null?void 0:t.data,columns:Me,okText:"删除"}),s=(l=n==null?void 0:n.SealId)!=null?l:"";return!!(yield(f=this.coreInstance)==null?void 0:f.deleteSeal({ContainerName:(u=(d=t==null?void 0:t.cert)==null?void 0:d.ContainerName)!=null?u:"",SealId:s}))}));o(this,"deleteSealById",(e,t)=>c(this,null,function*(){var r,a;const n=yield this.getSignatureCert(t);return!!(yield(a=this.coreInstance)==null?void 0:a.deleteSeal(B(E({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));o(this,"getSealList",e=>c(this,null,function*(){var s,r;const t=yield this.getSignatureCert(e),n=yield(r=this.coreInstance)==null?void 0:r.getSealList({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:"",IsLogin:"Y"});return{cert:t,data:n}}));o(this,"getSealInfo",e=>c(this,null,function*(){var r,a,l,d,u,f,h;const t=yield this.getSealList(e);if(!((r=t==null?void 0:t.data)!=null&&r.length))return Promise.reject({errCode:ae,msg:"暂无印章"});const n=((a=t==null?void 0:t.data)==null?void 0:a.length)>1?yield Y.open({title:"选择印章",data:t==null?void 0:t.data,columns:Me,theme:(l=this.gwsConfig)==null?void 0:l.theme}):t==null?void 0:t.data[0],s=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:(f=n==null?void 0:n.SealId)!=null?f:""});return s==null?void 0:s[0]}));o(this,"getTPSealList",(e,t)=>c(this,null,function*(){var r,a;const n=yield this.getSignatureCert(t),s=yield(a=this.coreInstance)==null?void 0:a.getTPSealList({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:"",Vid:e==null?void 0:e.Vid});return{cert:n,data:s}}));o(this,"getTPSeal",(e,t)=>c(this,null,function*(){var r,a,l;const n=yield this.getTPSealList(e,t);if(!((r=n==null?void 0:n.data)!=null&&r.length))return Promise.reject({errCode:ae,msg:"暂无印章"});const s=((a=n==null?void 0:n.data)==null?void 0:a.length)===1?n==null?void 0:n.data[0]:yield Y.open({title:"选择印章",data:n==null?void 0:n.data,columns:It,theme:(l=this.gwsConfig)==null?void 0:l.theme});return{cert:n==null?void 0:n.cert,data:s}}));o(this,"getTPSealPic",(e,t)=>c(this,null,function*(){var r,a,l,d,u;const n=yield this.getTPSeal(e,t),s=yield(u=this.coreInstance)==null?void 0:u.getTPSealPic(B(E({ContainerName:(a=(r=n==null?void 0:n.cert)==null?void 0:r.ContainerName)!=null?a:""},(l=n==null?void 0:n.data)!=null?l:{}),{FileSize:String((d=n==null?void 0:n.data)==null?void 0:d.FileSize)}));return s==null?void 0:s[0]}));o(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}));o(this,"sm2SignPreprocess2",e=>c(this,null,function*(){var r,a;const t=this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e),s=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return s==null?void 0:s[0].H}));o(this,"pkcs1HashSign",(e,t)=>c(this,null,function*(){var r,a,l,d;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:(a=e.HashAlg)!=null?a:"sm3"});return(d=s==null?void 0:s[0])==null?void 0:d.SignData}));o(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(B(E({},t),{HashAlg:(s=t.HashAlg)!=null?s:"sm3"})))}));o(this,"pkcs7Sign",(e,t)=>c(this,null,function*(){var a,l,d,u,f;const n=(l=e.DataB64)!=null?l:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign(B(E({},e!=null?e:{}),{ContainerName:(d=s==null?void 0:s.ContainerName)!=null?d:"",DataB64:n}));return(f=r==null?void 0:r[0])==null?void 0:f.SignData}));o(this,"pkcs7VerifySignature",e=>c(this,null,function*(){var s,r,a;const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""});return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));o(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}));o(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}));o(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}));o(this,"sm3HashEncryption",e=>c(this,null,function*(){var r,a,l,d,u,f;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=(d=e.KeyB64)!=null?d: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(f=s==null?void 0:s[0])==null?void 0:f.DataB64}));o(this,"pkcs7Encryption",e=>c(this,null,function*(){var s,r,a,l;if(!e.CertB64List){const d=yield this.getEncryptionCert();e.CertB64List=d==null?void 0:d.CertB64}const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""}),n=yield(a=this.coreInstance)==null?void 0:a.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 r,a;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption(B(E({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),s=(a=n==null?void 0:n[0])==null?void 0:a.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:s}):s}));o(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}));o(this,"pkcs7FileDecryption",e=>c(this,null,function*(){var s,r,a;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(a=n==null?void 0:n[0])==null?void 0:a.DataB64}));o(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}));o(this,"asymmetricDecryption",(e,t)=>c(this,null,function*(){var r,a;const n=yield this.getEncryptionCert(t),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricDecryption(B(E({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(a=s==null?void 0:s[0])==null?void 0:a.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,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}));o(this,"getCertInfo",e=>c(this,null,function*(){var s,r,a,l,d;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<ye.length;u++){const f=ye[u];try{const h=yield(a=this.coreInstance)==null?void 0:a.getCertInfoByOid({Oid:f.oid,CertB64:e.CertB64});n[f.key]=(d=(l=h==null?void 0:h[0])==null?void 0:l.OidValue)==null?void 0:d.replace(".","")}catch(h){n[f.key]=null}}return n!=null&&n.idCardNo?n!=null&&n.CertSubject.includes("O=")||n.orgCode?n.certCate=ie:n.certCate=J:n.certCate=re,n}));o(this,"getCertInfoByOid",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(E({},e!=null?e:{}));return(s=t==null?void 0:t[0])==null?void 0:s.OidValue}));o(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]}));o(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(B(E({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return s==null?void 0:s[0]}));o(this,"getUKey",e=>c(this,null,function*(){var s;if(e)return e;const t=yield(s=this.coreInstance)==null?void 0:s.getUKeyList();return yield Y.open({title:"选择介质",data:t,columns:kt})}));o(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]}));o(this,"applyCert",(e,t)=>c(this,null,function*(){var a;const n=yield this.getUKey(t),s=yield this.getUKeyInfo(n);return yield(a=this.coreInstance)==null?void 0:a.applyCert(B(E({},e!=null?e:{}),{manu:s==null?void 0:s.manu,sn:s==null?void 0:s.sn,ContainerName:s==null?void 0:s.keyid}))}));o(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(B(E({},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 Z.instance&&!(e!=null&&e.isCreateNew)?Z.instance:(this.createGwsCore(e),Z.instance=this,this)}};o(Z,"instance",null);let V=Z;function pt(i){return new Promise((e,t)=>{if(V.instance&&!(i!=null&&i.isCreateNew))e(V.instance);else{const n=new V(B(E({},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)}}))}})}_.GwsService=V,_.createService=pt,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(_,k){typeof exports=="object"&&typeof module!="undefined"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(_=typeof globalThis!="undefined"?globalThis:_||self,k(_.GWS_CLIENT={}))})(this,function(_){"use strict";var _t=Object.defineProperty,Lt=Object.defineProperties;var Bt=Object.getOwnPropertyDescriptors;var Oe=Object.getOwnPropertySymbols;var Pt=Object.prototype.hasOwnProperty,At=Object.prototype.propertyIsEnumerable;var ge=(_,k,L)=>k in _?_t(_,k,{enumerable:!0,configurable:!0,writable:!0,value:L}):_[k]=L,E=(_,k)=>{for(var L in k||(k={}))Pt.call(k,L)&&ge(_,L,k[L]);if(Oe)for(var L of Oe(k))At.call(k,L)&&ge(_,L,k[L]);return _},B=(_,k)=>Lt(_,Bt(k));var o=(_,k,L)=>ge(_,typeof k!="symbol"?k+"":k,L);var c=(_,k,L)=>new Promise((Q,J)=>{var ie=I=>{try{T(L.next(I))}catch(H){J(H)}},re=I=>{try{T(L.throw(I))}catch(H){J(H)}},T=I=>I.done?Q(I.value):Promise.resolve(I.value).then(ie,re);T((L=L.apply(_,k)).next())});const k=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",L="1",Q="2",J="1",ie="2",re="3";var T=(i=>(i.MIN="0",i.LOW="1",i.MIDDLE="2",i.HIGH="3",i))(T||{});const I={LEVEL_1:1,LEVEL_2:2,LEVEL_3:4},H={OPEN:I.LEVEL_1,INTERNAL:I.LEVEL_2|I.LEVEL_1,OMP:I.LEVEL_3|I.LEVEL_2|I.LEVEL_1},Ge="00000001",ae="NO_SEAL_AVAILABLE",Fe="CERTIFICATE_NOT_FOUND",Ve="CLIENT_CONNECTION_FAILED",Ze="ACCESS_DENIED",ye=[{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 He(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var U={},fe;function Ue(){if(fe)return U;fe=1,U.byteLength=l,U.toByteArray=u,U.fromByteArray=w;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 a(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 C=m===g?0:4-m%4;return[m,C]}function l(y){var g=a(y),m=g[0],C=g[1];return(m+C)*3/4-C}function d(y,g,m){return(g+m)*3/4-m}function u(y){var g,m=a(y),C=m[0],S=m[1],p=new t(d(y,C,S)),P=0,x=S>0?C-4:C,v;for(v=0;v<x;v+=4)g=e[y.charCodeAt(v)]<<18|e[y.charCodeAt(v+1)]<<12|e[y.charCodeAt(v+2)]<<6|e[y.charCodeAt(v+3)],p[P++]=g>>16&255,p[P++]=g>>8&255,p[P++]=g&255;return S===2&&(g=e[y.charCodeAt(v)]<<2|e[y.charCodeAt(v+1)]>>4,p[P++]=g&255),S===1&&(g=e[y.charCodeAt(v)]<<10|e[y.charCodeAt(v+1)]<<4|e[y.charCodeAt(v+2)]>>2,p[P++]=g>>8&255,p[P++]=g&255),p}function f(y){return i[y>>18&63]+i[y>>12&63]+i[y>>6&63]+i[y&63]}function h(y,g,m){for(var C,S=[],p=g;p<m;p+=3)C=(y[p]<<16&16711680)+(y[p+1]<<8&65280)+(y[p+2]&255),S.push(f(C));return S.join("")}function w(y){for(var g,m=y.length,C=m%3,S=[],p=16383,P=0,x=m-C;P<x;P+=p)S.push(h(y,P,P+p>x?x:P+p));return C===1?(g=y[m-1],S.push(i[g>>2]+i[g<<4&63]+"==")):C===2&&(g=(y[m-2]<<8)+y[m-1],S.push(i[g>>10]+i[g>>4&63]+i[g<<2&63]+"=")),S.join("")}return U}var je=Ue();const Ce=He(je);class Ke{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 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 ze=Object.defineProperty,Re=(i,e,t)=>e in i?ze(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,we=(i,e,t)=>Re(i,typeof e!="symbol"?e+"":e,t);function oe(){}function We(i,e){for(const t in e)i[t]=e[t];return i}function me(i){return i()}function Ee(){return Object.create(null)}function j(i){i.forEach(me)}function K(i){return typeof i=="function"}function Se(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function Ye(i){return Object.keys(i).length===0}function Qe(i,e,t,n){if(i){const s=Ie(i,e,t,n);return i[0](s)}}function Ie(i,e,t,n){return i[1]&&n?We(t.ctx.slice(),i[1](n(e))):t.ctx}function Je(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=[],a=Math.max(e.dirty.length,s.length);for(let l=0;l<a;l+=1)r[l]=e.dirty[l]|s[l];return r}return e.dirty|s}return e.dirty}function qe(i,e,t,n,s,r){if(s){const a=Ie(e,t,n,r);i.p(a,s)}}function Xe(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 ke(i){return i==null?"":i}function A(i,e){i.appendChild(e)}function q(i,e,t){i.insertBefore(e,t||null)}function z(i){i.parentNode&&i.parentNode.removeChild(i)}function ve(i,e){for(let t=0;t<i.length;t+=1)i[t]&&i[t].d(e)}function N(i){return document.createElement(i)}function M(i){return document.createTextNode(i)}function X(){return M(" ")}function et(){return M("")}function R(i,e,t,n){return i.addEventListener(e,t,n),()=>i.removeEventListener(e,t,n)}function D(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function tt(i){return Array.from(i.childNodes)}function ee(i,e){e=""+e,i.data!==e&&(i.data=e)}function te(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,"")}let ce;function W(i){ce=i}const O=[],pe=[];let G=[];const _e=[],nt=Promise.resolve();let le=!1;function st(){le||(le=!0,nt.then(Le))}function ue(i){G.push(i)}const de=new Set;let F=0;function Le(){if(F!==0)return;const i=ce;do{try{for(;F<O.length;){const e=O[F];F++,W(e),it(e.$$)}}catch(e){throw O.length=0,F=0,e}for(W(null),O.length=0,F=0;pe.length;)pe.pop()();for(let e=0;e<G.length;e+=1){const t=G[e];de.has(t)||(de.add(t),t())}G.length=0}while(O.length);for(;_e.length;)_e.pop()();le=!1,de.clear(),W(i)}function it(i){if(i.fragment!==null){i.update(),j(i.before_update);const e=i.dirty;i.dirty=[-1],i.fragment&&i.fragment.p(i.ctx,e),i.after_update.forEach(ue)}}function rt(i){const e=[],t=[];G.forEach(n=>i.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),G=e}const ne=new Set;let at;function he(i,e){i&&i.i&&(ne.delete(i),i.i(e))}function Be(i,e,t,n){if(i&&i.o){if(ne.has(i))return;ne.add(i),at.c.push(()=>{ne.delete(i)}),i.o(e)}}function se(i){return(i==null?void 0:i.length)!==void 0?i:Array.from(i)}function ot(i){i&&i.c()}function Pe(i,e,t){const{fragment:n,after_update:s}=i.$$;n&&n.m(e,t),ue(()=>{const r=i.$$.on_mount.map(me).filter(K);i.$$.on_destroy?i.$$.on_destroy.push(...r):j(r),i.$$.on_mount=[]}),s.forEach(ue)}function Ae(i,e){const t=i.$$;t.fragment!==null&&(rt(t.after_update),j(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ct(i,e){i.$$.dirty[0]===-1&&(O.push(i),st(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<<e%31}function De(i,e,t,n,s,r,a=null,l=[-1]){const d=ce;W(i);const u=i.$$={fragment:null,ctx:[],props:r,update:oe,not_equal:s,bound:Ee(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:Ee(),dirty:l,skip_bound:!1,root:e.target||d.$$.root};a&&a(u.root);let f=!1;if(u.ctx=t?t(i,e.props||{},(h,w,...y)=>{const g=y.length?y[0]:w;return u.ctx&&s(u.ctx[h],u.ctx[h]=g)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](g),f&&ct(i,h)),w}):[],u.update(),f=!0,j(u.before_update),u.fragment=n?n(u.ctx):!1,e.target){if(e.hydrate){const h=tt(e.target);u.fragment&&u.fragment.l(h),h.forEach(z)}else u.fragment&&u.fragment.c();e.intro&&he(i.$$.fragment),Pe(i,e.target,e.anchor),Le()}W(d)}class be{constructor(){we(this,"$$"),we(this,"$$set")}$destroy(){Ae(this,1),this.$destroy=oe}$on(e,t){if(!K(t))return oe;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&&!Ye(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const lt="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(lt);function ut(i){let e,t,n,s=(i[1]||"标题")+"",r,a,l,d,u,f,h=(i[4]||"取消")+"",w,y,g,m=(i[5]||"确认")+"",C,S,p,P;const x=i[8].default,v=Qe(x,i,i[7],null);return{c(){e=N("div"),t=N("div"),n=N("div"),r=M(s),a=X(),l=N("div"),v&&v.c(),d=X(),u=N("div"),f=N("button"),w=M(h),y=X(),g=N("button"),C=M(m),D(n,"class","model-title svelte-16iv9d0"),D(l,"class","slot svelte-16iv9d0"),D(f,"class","modal-btn svelte-16iv9d0"),D(g,"class","modal-btn success svelte-16iv9d0"),te(g,"background-color",i[6]),D(u,"class","modal-footer svelte-16iv9d0"),D(t,"class","modal-content svelte-16iv9d0"),D(e,"class","modal-background modal-visible svelte-16iv9d0")},m(b,$){q(b,e,$),A(e,t),A(t,n),A(n,r),A(t,a),A(t,l),v&&v.m(l,null),A(t,d),A(t,u),A(u,f),A(f,w),A(u,y),A(u,g),A(g,C),S=!0,p||(P=[R(f,"click",function(){K(i[0])&&i[0].apply(this,arguments)}),R(g,"click",function(){K(i[2])&&i[2].apply(this,arguments)}),R(t,"click",dt),R(e,"click",function(){K(i[3])&&i[3].apply(this,arguments)})],p=!0)},p(b,[$]){i=b,(!S||$&2)&&s!==(s=(i[1]||"标题")+"")&&ee(r,s),v&&v.p&&(!S||$&128)&&qe(v,x,i,i[7],S?Je(x,i[7],$,null):Xe(i[7]),null),(!S||$&16)&&h!==(h=(i[4]||"取消")+"")&&ee(w,h),(!S||$&32)&&m!==(m=(i[5]||"确认")+"")&&ee(C,m),(!S||$&64)&&te(g,"background-color",i[6])},i(b){S||(he(v,b),S=!0)},o(b){Be(v,b),S=!1},d(b){b&&z(e),v&&v.d(b),p=!1,j(P)}}}const dt=i=>i.stopPropagation();function ht(i,e,t){let{$$slots:n={},$$scope:s}=e,{onCancel:r}=e,{title:a}=e,{onOk:l}=e,{onClose:d}=e,{cancelText:u}=e,{okText:f}=e,{theme:h}=e;return i.$$set=w=>{"onCancel"in w&&t(0,r=w.onCancel),"title"in w&&t(1,a=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,f=w.okText),"theme"in w&&t(6,h=w.theme),"$$scope"in w&&t(7,s=w.$$scope)},[r,a,l,d,u,f,h,s,n]}class gt extends be{constructor(e){super(),De(this,e,ht,ut,Se,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function Ne(i,e,t){const n=i.slice();return n[13]=e[t],n[15]=t,n}function xe(i,e,t){const n=i.slice();return n[16]=e[t],n}function $e(i){let e,t=(i[16].format?i[16].format(i[13]):i[13][i[16].key])+"",n;return{c(){e=N("div"),n=M(t),D(e,"class","svelte-1kh75ag"),te(e,"width",`${100/i[1].length}%`)},m(s,r){q(s,e,r),A(e,n)},p(s,r){r&3&&t!==(t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"")&&ee(n,t),r&2&&te(e,"width",`${100/s[1].length}%`)},d(s){s&&z(e)}}}function Te(i){let e,t,n,s,r,a=se(i[1]),l=[];for(let u=0;u<a.length;u+=1)l[u]=$e(xe(i,a,u));function d(){return i[12](i[15])}return{c(){e=N("div");for(let u=0;u<l.length;u+=1)l[u].c();t=X(),D(e,"class",n=ke(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(u,f){q(u,e,f);for(let h=0;h<l.length;h+=1)l[h]&&l[h].m(e,null);A(e,t),s||(r=R(e,"click",d),s=!0)},p(u,f){if(i=u,f&3){a=se(i[1]);let h;for(h=0;h<a.length;h+=1){const w=xe(i,a,h);l[h]?l[h].p(w,f):(l[h]=$e(w),l[h].c(),l[h].m(e,t))}for(;h<l.length;h+=1)l[h].d(1);l.length=a.length}f&128&&n!==(n=ke(`cert-item ${i[15]===0?"cert-item-first":""} ${i[15]===i[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&D(e,"class",n)},d(u){u&&z(e),ve(l,u),s=!1,r()}}}function yt(i){let e,t=se(i[0]),n=[];for(let s=0;s<t.length;s+=1)n[s]=Te(Ne(i,t,s));return{c(){for(let s=0;s<n.length;s+=1)n[s].c();e=et()},m(s,r){for(let a=0;a<n.length;a+=1)n[a]&&n[a].m(s,r);q(s,e,r)},p(s,r){if(r&131){t=se(s[0]);let a;for(a=0;a<t.length;a+=1){const l=Ne(s,t,a);n[a]?n[a].p(l,r):(n[a]=Te(l),n[a].c(),n[a].m(e.parentNode,e))}for(;a<n.length;a+=1)n[a].d(1);n.length=t.length}},d(s){s&&z(e),ve(n,s)}}}function ft(i){let e,t;return e=new gt({props:{onOk:i[9],onClose:i[2],onCancel:i[8],cancelText:i[3],okText:i[4],title:i[6],theme:i[5],$$slots:{default:[yt]},$$scope:{ctx:i}}}),{c(){ot(e.$$.fragment)},m(n,s){Pe(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||(he(e.$$.fragment,n),t=!0)},o(n){Be(e.$$.fragment,n),t=!1},d(n){Ae(e,n)}}}function Ct(i,e,t){let{data:n=[]}=e,{columns:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:l}=e,{cancelText:d=""}=e,{okText:u=""}=e,{theme:f="#409eff"}=e,{title:h=""}=e,w=0;const y=()=>{r(`${h}失败`),l==null||l()},g=()=>{a==null||a(n[w]),l==null||l()},m=C=>t(7,w=C);return i.$$set=C=>{"data"in C&&t(0,n=C.data),"columns"in C&&t(1,s=C.columns),"onCancel"in C&&t(10,r=C.onCancel),"onOk"in C&&t(11,a=C.onOk),"onClose"in C&&t(2,l=C.onClose),"cancelText"in C&&t(3,d=C.cancelText),"okText"in C&&t(4,u=C.okText),"theme"in C&&t(5,f=C.theme),"title"in C&&t(6,h=C.title)},[n,s,l,d,u,f,h,w,y,g,r,a,m]}class wt extends be{constructor(e){super(),De(this,e,Ct,ft,Se,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class mt{constructor(){o(this,"modalInstance",{current:null});o(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new wt({target:document.body,props:B(E({},e),{onCancel:s=>{n({code:-1,msg:s})},onOk:s=>{t(s)},onClose:()=>{this.close()}})})}));o(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const Y=new mt;function Et(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 a=0;a<36;a++)s[a]||(r=0|Math.random()*16,s[a]=n[a===19?r&3|8:r])}return e?(s.shift(),`u${s.join("")}`):s.join("")}const St=[{key:"CN"},{format:i=>`${i.DevClass}(${i.sn})`}],It=[{key:"SealId"},{key:"Vid"},{format:i=>`${i.FileName}(${i.FileSize}B)`}],Me=[{key:"SealId"}],kt=[{key:"manu"},{key:"sn"}];class vt{constructor(e){o(this,"socketInstance",null);o(this,"eventBus",new Ke);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((s,r)=>{var l;const a=()=>{var h,w;if(((h=this.socketInstance)==null?void 0:h.readyState)!==WebSocket.OPEN){r({errCode:Ve,msg:"数字证书客户端连接失败"});return}const d=Et(),u=y=>{y.success?s(y.data):r(y)},f={function:e,args:t?[t]:[],msgid:d};(w=this.socketInstance)==null||w.send(JSON.stringify(f)),this.eventBus.on(e,u),this.eventBus.on(d,u)};if(n&&(this.scene&n)!==n){r({errCode:Ze,msg:"无权限执行此操作"});return}if(((l=this.socketInstance)==null?void 0:l.readyState)===WebSocket.OPEN){a();return}this.messageQueue.push(a),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,s,r,a,l,d,u;if(e.data instanceof Blob){const f=yield e.data.arrayBuffer(),y=new TextDecoder(navigator.userAgent.includes("Windows")?"gbk":"utf-8").decode(f).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:(s=g.result)==null?void 0:s.errCode,data:g.data,type:(r=g.result)==null?void 0:r.event},C=(a=g.result)==null?void 0:a.function,S=(l=g.result)==null?void 0:l.msgid;S?this.eventBus.emit(S,m):this.eventBus.emit(C,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 Ce.fromByteArray(t)});o(this,"base64Decode",e=>{const t=Ce.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:Ge}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||s.call(t,B(E({},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 s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.certLogin(s.ContainerName)),s}));o(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 Y.open({title:"选择证书",data:t,columns:St,theme:(s=this.socketConfig)==null?void 0:s.theme}):Promise.reject({errCode:Fe,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",E({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",E({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"batchPkcs1Base64Sign",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",E({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",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"writeSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"deleteSeal",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"getSealInfo",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"getTPSealList",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.LEVEL_2)}));o(this,"getTPSealPic",e=>c(this,null,function*(){var n;return yield this.sendMessage("GZCA_GetSealPicData",E({IsLogin:(n=e.IsLogin)!=null?n:this.getIsLogin()},e!=null?e:{}),I.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",E({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",E({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",E({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",E({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",E({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,I.LEVEL_2)}));o(this,"deleteAllSealByVendor",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",E({IsLogin:this.getIsLogin()},e!=null?e:{}),I.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},I.LEVEL_3)}));o(this,"resetPin",e=>c(this,null,function*(){return yield this.sendMessage("GZCA_UnblockUserPin",E({},e!=null?e:{}),I.LEVEL_3)}));o(this,"getUKeyList",()=>c(this,null,function*(){return yield this.sendMessage("GetUKeyList",void 0,I.LEVEL_3)}));o(this,"getUKeyInfo",e=>c(this,null,function*(){return yield this.sendMessage("GetUKeyID",e!=null?e:{},I.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:H.OPEN,this.pinPolicy=(s=e.pinPolicy)!=null?s:T.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 Z=class Z{constructor(e){o(this,"coreInstance",null);o(this,"gwsConfig",{});o(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new vt(B(E({},e!=null?e:{}),{url:k}))});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 B(E({},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 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})}));o(this,"getSignatureCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:L},e,t)}));o(this,"getSignatureCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:L})}));o(this,"getEncryptionCert",(e,t=!0)=>c(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:Q},e,t)}));o(this,"getEncryptionCertList",()=>c(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:Q})}));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 r,a,l;const n=yield this.getSignatureCert(t),s=yield(a=this.coreInstance)==null?void 0:a.pkcs1Sign(B(E({},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}));o(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)}));o(this,"pkcs1Base64Sign",(e,t)=>c(this,null,function*(){var a,l,d,u,f;const n=yield this.getSignatureCert(t),s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(a=e.Data)!=null?a:""}),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign(B(E({},e!=null?e:{}),{ContainerName:(d=n==null?void 0:n.ContainerName)!=null?d:"",DataB64:s}));return(f=r==null?void 0:r[0])==null?void 0:f.SignData}));o(this,"batchPkcs1Base64Sign",(e,t)=>c(this,null,function*(){var f,h,w,y,g,m;const n="|",s=(h=e.DataB64)!=null?h:(f=e.Data)==null?void 0:f.map(C=>this.base64Encode({Data:C})),r=yield this.getSignatureCert(t);let a="";a=Array.isArray(s)?s==null?void 0:s.map((C,S)=>`${S}:${C}`).join(n):"";const l=yield(y=this.coreInstance)==null?void 0:y.batchPkcs1Base64Sign({ContainerName:(w=r==null?void 0:r.ContainerName)!=null?w:"",DataB64:a}),d=(m=(g=l==null?void 0:l[0])==null?void 0:g.SignData)==null?void 0:m.split(n),u=[];return d.forEach(C=>{const S=C.split(":"),p=Number(S[0]),P=S[1];u[p]=P}),u}));o(this,"pkcs1Base64VerifySignature",e=>c(this,null,function*(){var r,a,l;const t=(a=e.DataB64)!=null?a: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}))}));o(this,"writeSeal",(e,t)=>c(this,null,function*(){var r,a;const n=yield this.getSignatureCert(t);return!!(yield(a=this.coreInstance)==null?void 0:a.writeSeal(B(E({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));o(this,"deleteSeal",e=>c(this,null,function*(){var a,l,d,u,f;const t=yield this.getSealList(e);if(!((a=t==null?void 0:t.data)!=null&&a.length))return Promise.reject({errCode:ae,msg:"暂无印章"});const n=yield Y.open({title:"删除印章",data:t==null?void 0:t.data,columns:Me,okText:"删除"}),s=(l=n==null?void 0:n.SealId)!=null?l:"";return!!(yield(f=this.coreInstance)==null?void 0:f.deleteSeal({ContainerName:(u=(d=t==null?void 0:t.cert)==null?void 0:d.ContainerName)!=null?u:"",SealId:s}))}));o(this,"deleteSealById",(e,t)=>c(this,null,function*(){var r,a;const n=yield this.getSignatureCert(t);return!!(yield(a=this.coreInstance)==null?void 0:a.deleteSeal(B(E({},e!=null?e:{}),{ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:""})))}));o(this,"getSealList",e=>c(this,null,function*(){var s,r;const t=yield this.getSignatureCert(e),n=yield(r=this.coreInstance)==null?void 0:r.getSealList({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:"",IsLogin:"Y"});return{cert:t,data:n}}));o(this,"getSealInfo",e=>c(this,null,function*(){var r,a,l,d,u,f,h;const t=yield this.getSealList(e);if(!((r=t==null?void 0:t.data)!=null&&r.length))return Promise.reject({errCode:ae,msg:"暂无印章"});const n=((a=t==null?void 0:t.data)==null?void 0:a.length)>1?yield Y.open({title:"选择印章",data:t==null?void 0:t.data,columns:Me,theme:(l=this.gwsConfig)==null?void 0:l.theme}):t==null?void 0:t.data[0],s=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:(f=n==null?void 0:n.SealId)!=null?f:""});return s==null?void 0:s[0]}));o(this,"getTPSealList",(e,t)=>c(this,null,function*(){var r,a;const n=yield this.getSignatureCert(t),s=yield(a=this.coreInstance)==null?void 0:a.getTPSealList({ContainerName:(r=n==null?void 0:n.ContainerName)!=null?r:"",Vid:e==null?void 0:e.Vid});return{cert:n,data:s}}));o(this,"getTPSeal",(e,t)=>c(this,null,function*(){var r,a,l;const n=yield this.getTPSealList(e,t);if(!((r=n==null?void 0:n.data)!=null&&r.length))return Promise.reject({errCode:ae,msg:"暂无印章"});const s=((a=n==null?void 0:n.data)==null?void 0:a.length)===1?n==null?void 0:n.data[0]:yield Y.open({title:"选择印章",data:n==null?void 0:n.data,columns:It,theme:(l=this.gwsConfig)==null?void 0:l.theme});return{cert:n==null?void 0:n.cert,data:s}}));o(this,"getTPSealPic",(e,t)=>c(this,null,function*(){var r,a,l,d,u;const n=yield this.getTPSeal(e,t),s=yield(u=this.coreInstance)==null?void 0:u.getTPSealPic(B(E({ContainerName:(a=(r=n==null?void 0:n.cert)==null?void 0:r.ContainerName)!=null?a:""},(l=n==null?void 0:n.data)!=null?l:{}),{FileSize:String((d=n==null?void 0:n.data)==null?void 0:d.FileSize)}));return s==null?void 0:s[0]}));o(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}));o(this,"sm2SignPreprocess2",e=>c(this,null,function*(){var r,a;const t=this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield this.appendCertBase64(e),s=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return s==null?void 0:s[0].H}));o(this,"pkcs1HashSign",(e,t)=>c(this,null,function*(){var r,a,l,d;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:(a=e.HashAlg)!=null?a:"sm3"});return(d=s==null?void 0:s[0])==null?void 0:d.SignData}));o(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(B(E({},t),{HashAlg:(s=t.HashAlg)!=null?s:"sm3"})))}));o(this,"pkcs7Sign",(e,t)=>c(this,null,function*(){var a,l,d,u,f;const n=(l=e.DataB64)!=null?l:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign(B(E({},e!=null?e:{}),{ContainerName:(d=s==null?void 0:s.ContainerName)!=null?d:"",DataB64:n}));return(f=r==null?void 0:r[0])==null?void 0:f.SignData}));o(this,"pkcs7VerifySignature",e=>c(this,null,function*(){var s,r,a;const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""});return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));o(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}));o(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}));o(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}));o(this,"sm3HashEncryption",e=>c(this,null,function*(){var r,a,l,d,u,f;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=(d=e.KeyB64)!=null?d: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(f=s==null?void 0:s[0])==null?void 0:f.DataB64}));o(this,"pkcs7Encryption",e=>c(this,null,function*(){var s,r,a,l;if(!e.CertB64List){const d=yield this.getEncryptionCert();e.CertB64List=d==null?void 0:d.CertB64}const t=(r=e.DataB64)!=null?r:this.base64Encode({Data:(s=e.Data)!=null?s:""}),n=yield(a=this.coreInstance)==null?void 0:a.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 r,a;const t=yield this.getEncryptionCert(),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption(B(E({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),s=(a=n==null?void 0:n[0])==null?void 0:a.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:s}):s}));o(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}));o(this,"pkcs7FileDecryption",e=>c(this,null,function*(){var s,r,a;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(a=n==null?void 0:n[0])==null?void 0:a.DataB64}));o(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}));o(this,"asymmetricDecryption",(e,t)=>c(this,null,function*(){var r,a;const n=yield this.getEncryptionCert(t),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricDecryption(B(E({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(a=s==null?void 0:s[0])==null?void 0:a.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,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}));o(this,"getCertInfo",e=>c(this,null,function*(){var s,r,a,l,d;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<ye.length;u++){const f=ye[u];try{const h=yield(a=this.coreInstance)==null?void 0:a.getCertInfoByOid({Oid:f.oid,CertB64:e.CertB64});n[f.key]=(d=(l=h==null?void 0:h[0])==null?void 0:l.OidValue)==null?void 0:d.replace(".","")}catch(h){n[f.key]=null}}return n!=null&&n.idCardNo?n!=null&&n.CertSubject.includes("O=")||n.orgCode?n.certCate=ie:n.certCate=J:n.certCate=re,n}));o(this,"getCertInfoByOid",e=>c(this,null,function*(){var n,s;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(E({},e!=null?e:{}));return(s=t==null?void 0:t[0])==null?void 0:s.OidValue}));o(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]}));o(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(B(E({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return s==null?void 0:s[0]}));o(this,"getUKey",e=>c(this,null,function*(){var s;if(e)return e;const t=yield(s=this.coreInstance)==null?void 0:s.getUKeyList();return yield Y.open({title:"选择介质",data:t,columns:kt})}));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 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]}));o(this,"applyCert",(e,t)=>c(this,null,function*(){var a;const n=yield this.getUKey(t),s=yield this.getUKeyInfo(n);return yield(a=this.coreInstance)==null?void 0:a.applyCert(B(E({},e!=null?e:{}),{manu:s==null?void 0:s.manu,sn:s==null?void 0:s.sn,ContainerName:s==null?void 0:s.keyid}))}));o(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(B(E({},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 Z.instance&&!(e!=null&&e.isCreateNew)?Z.instance:(this.createGwsCore(e),Z.instance=this,this)}};o(Z,"instance",null);let V=Z;function pt(i){return new Promise((e,t)=>{if(V.instance&&!(i!=null&&i.isCreateNew))e(V.instance);else{const n=new V(B(E({},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)}}))}})}_.GwsService=V,_.createService=pt,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|