gws-client 1.0.2 → 1.1.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 Se=Object.defineProperty,xe=Object.defineProperties;var Be=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable;var J=(n,e,t)=>e in n?Se(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))$e.call(e,t)&&J(n,t,e[t]);if(ee)for(var t of ee(e))Ie.call(e,t)&&J(n,t,e[t]);return n},x=(n,e)=>xe(n,Be(e));var i=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);var l=(n,e,t)=>new Promise((s,r)=>{var a=d=>{try{u(t.next(d))}catch(h){r(h)}},o=d=>{try{u(t.throw(d))}catch(h){r(h)}},u=d=>d.done?s(d.value):Promise.resolve(d.value).then(a,o);u((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ae=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",te="1",ne="2";var ge=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(ge||{});const Ee="00000001";function _e(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var F={},se;function Le(){if(se)return F;se=1,F.byteLength=u,F.toByteArray=h,F.fromByteArray=p;for(var n=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,a=s.length;r<a;++r)n[r]=s[r],e[s.charCodeAt(r)]=r;e[45]=62,e[95]=63;function o(y){var c=y.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var g=y.indexOf("=");g===-1&&(g=c);var w=g===c?0:4-g%4;return[g,w]}function u(y){var c=o(y),g=c[0],w=c[1];return(g+w)*3/4-w}function d(y,c,g){return(c+g)*3/4-g}function h(y){var c,g=o(y),w=g[0],m=g[1],v=new t(d(y,w,m)),b=0,E=m>0?w-4:w,k;for(k=0;k<E;k+=4)c=e[y.charCodeAt(k)]<<18|e[y.charCodeAt(k+1)]<<12|e[y.charCodeAt(k+2)]<<6|e[y.charCodeAt(k+3)],v[b++]=c>>16&255,v[b++]=c>>8&255,v[b++]=c&255;return m===2&&(c=e[y.charCodeAt(k)]<<2|e[y.charCodeAt(k+1)]>>4,v[b++]=c&255),m===1&&(c=e[y.charCodeAt(k)]<<10|e[y.charCodeAt(k+1)]<<4|e[y.charCodeAt(k+2)]>>2,v[b++]=c>>8&255,v[b++]=c&255),v}function f(y){return n[y>>18&63]+n[y>>12&63]+n[y>>6&63]+n[y&63]}function C(y,c,g){for(var w,m=[],v=c;v<g;v+=3)w=(y[v]<<16&16711680)+(y[v+1]<<8&65280)+(y[v+2]&255),m.push(f(w));return m.join("")}function p(y){for(var c,g=y.length,w=g%3,m=[],v=16383,b=0,E=g-w;b<E;b+=v)m.push(C(y,b,b+v>E?E:b+v));return w===1?(c=y[g-1],m.push(n[c>>2]+n[c<<4&63]+"==")):w===2&&(c=(y[g-2]<<8)+y[g-1],m.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),m.join("")}return F}var Pe=Le();const re=_e(Pe);class Te{constructor(){i(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const s=this.deps.get(e);s&&s(t)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-oivou{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-oivou{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-oivou{background-color:#fff;padding:1.42857rem;border-radius:.35714rem;width:40%}.model-title.svelte-oivou{color:#303133;font-size:1.28571rem;margin-bottom:1.14286rem}.modal-visible.svelte-oivou{display:flex}.modal-footer.svelte-oivou{display:flex;align-items:center;justify-content:flex-end;margin-top:1.14286rem}.modal-btn.svelte-oivou{padding:.57143rem 1.07143rem;border-radius:.28571rem;font-size:1rem;border:.07143rem solid #dcdfe6}.success.svelte-oivou{margin-left:.85714rem;color:#fff}.slot.svelte-oivou{max-height:14.28571rem;overflow-y:scroll}.slot.svelte-oivou::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:1.14286rem;display:flex;align-items:center;cursor:pointer;border-bottom:.07143rem solid #ebeef5;font-size:1rem}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:.07143rem solid #ebeef5}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4{display:inline-block;color:#606266}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4:first-child{width:30%}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:12.85714rem;height:12.85714rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.07143rem solid #ccc;margin-top:.71429rem;margin-right:.71429rem;border-radius:.28571rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:7.14286rem;height:7.14286rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.71429rem;color:#333}")),document.head.appendChild(n)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Me=Object.defineProperty,He=(n,e,t)=>e in n?Me(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ae=(n,e,t)=>He(n,typeof e!="symbol"?e+"":e,t);function W(){}function Ge(n,e){for(const t in e)n[t]=e[t];return n}function fe(n){return n()}function oe(){return Object.create(null)}function V(n){n.forEach(fe)}function O(n){return typeof n=="function"}function pe(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Fe(n){return Object.keys(n).length===0}function je(n,e,t,s){if(n){const r=me(n,e,t,s);return n[0](r)}}function me(n,e,t,s){return n[1]&&s?Ge(t.ctx.slice(),n[1](s(e))):t.ctx}function Oe(n,e,t,s){if(n[2]&&s){const r=n[2](s(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const a=[],o=Math.max(e.dirty.length,r.length);for(let u=0;u<o;u+=1)a[u]=e.dirty[u]|r[u];return a}return e.dirty|r}return e.dirty}function Ne(n,e,t,s,r,a){if(r){const o=me(e,t,s,a);n.p(o,r)}}function Ze(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let s=0;s<t;s++)e[s]=-1;return e}return-1}function ie(n){return n==null?"":n}function S(n,e){n.appendChild(e)}function Q(n,e,t){n.insertBefore(e,t||null)}function U(n){n.parentNode&&n.parentNode.removeChild(n)}function Ve(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function I(n){return document.createElement(n)}function A(n){return document.createTextNode(n)}function N(){return A(" ")}function Re(){return A("")}function j(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function B(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ue(n){return Array.from(n.childNodes)}function M(n,e){e=""+e,n.data!==e&&(n.data=e)}function ce(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let X;function Z(n){X=n}const P=[],le=[];let H=[];const ue=[],Je=Promise.resolve();let q=!1;function ze(){q||(q=!0,Je.then(Ce))}function K(n){H.push(n)}const z=new Set;let L=0;function Ce(){if(L!==0)return;const n=X;do{try{for(;L<P.length;){const e=P[L];L++,Z(e),We(e.$$)}}catch(e){throw P.length=0,L=0,e}for(Z(null),P.length=0,L=0;le.length;)le.pop()();for(let e=0;e<H.length;e+=1){const t=H[e];z.has(t)||(z.add(t),t())}H.length=0}while(P.length);for(;ue.length;)ue.pop()();q=!1,z.clear(),Z(n)}function We(n){if(n.fragment!==null){n.update(),V(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(K)}}function qe(n){const e=[],t=[];H.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),H=e}const R=new Set;let Ke;function Y(n,e){n&&n.i&&(R.delete(n),n.i(e))}function ve(n,e,t,s){if(n&&n.o){if(R.has(n))return;R.add(n),Ke.c.push(()=>{R.delete(n)}),n.o(e)}}function de(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Qe(n){n&&n.c()}function we(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),K(()=>{const a=n.$$.on_mount.map(fe).filter(O);n.$$.on_destroy?n.$$.on_destroy.push(...a):V(a),n.$$.on_mount=[]}),r.forEach(K)}function ke(n,e){const t=n.$$;t.fragment!==null&&(qe(t.after_update),V(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Xe(n,e){n.$$.dirty[0]===-1&&(P.push(n),ze(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function be(n,e,t,s,r,a,o=null,u=[-1]){const d=X;Z(n);const h=n.$$={fragment:null,ctx:[],props:a,update:W,not_equal:r,bound:oe(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:oe(),dirty:u,skip_bound:!1,root:e.target||d.$$.root};o&&o(h.root);let f=!1;if(h.ctx=t?t(n,e.props||{},(C,p,...y)=>{const c=y.length?y[0]:p;return h.ctx&&r(h.ctx[C],h.ctx[C]=c)&&(!h.skip_bound&&h.bound[C]&&h.bound[C](c),f&&Xe(n,C)),p}):[],h.update(),f=!0,V(h.before_update),h.fragment=s?s(h.ctx):!1,e.target){if(e.hydrate){const C=Ue(e.target);h.fragment&&h.fragment.l(C),C.forEach(U)}else h.fragment&&h.fragment.c();e.intro&&Y(n.$$.fragment),we(n,e.target,e.anchor),Ce()}Z(d)}class De{constructor(){ae(this,"$$"),ae(this,"$$set")}$destroy(){ke(this,1),this.$destroy=W}$on(e,t){if(!O(t))return W;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Fe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ye="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ye);function et(n){let e,t,s,r=(n[1]||"标题")+"",a,o,u,d,h,f,C=(n[4]||"取消")+"",p,y,c,g=(n[5]||"确认")+"",w,m,v,b;const E=n[8].default,k=je(E,n,n[7],null);return{c(){e=I("div"),t=I("div"),s=I("div"),a=A(r),o=N(),u=I("div"),k&&k.c(),d=N(),h=I("div"),f=I("button"),p=A(C),y=N(),c=I("button"),w=A(g),B(s,"class","model-title svelte-oivou"),B(u,"class","slot svelte-oivou"),B(f,"class","modal-btn svelte-oivou"),B(c,"class","modal-btn success svelte-oivou"),ce(c,"background-color",n[6]),B(h,"class","modal-footer svelte-oivou"),B(t,"class","modal-content svelte-oivou"),B(e,"class","modal-background modal-visible svelte-oivou")},m($,_){Q($,e,_),S(e,t),S(t,s),S(s,a),S(t,o),S(t,u),k&&k.m(u,null),S(t,d),S(t,h),S(h,f),S(f,p),S(h,y),S(h,c),S(c,w),m=!0,v||(b=[j(f,"click",function(){O(n[0])&&n[0].apply(this,arguments)}),j(c,"click",function(){O(n[2])&&n[2].apply(this,arguments)}),j(t,"click",tt),j(e,"click",function(){O(n[3])&&n[3].apply(this,arguments)})],v=!0)},p($,[_]){n=$,(!m||_&2)&&r!==(r=(n[1]||"标题")+"")&&M(a,r),k&&k.p&&(!m||_&128)&&Ne(k,E,n,n[7],m?Oe(E,n[7],_,null):Ze(n[7]),null),(!m||_&16)&&C!==(C=(n[4]||"取消")+"")&&M(p,C),(!m||_&32)&&g!==(g=(n[5]||"确认")+"")&&M(w,g),(!m||_&64)&&ce(c,"background-color",n[6])},i($){m||(Y(k,$),m=!0)},o($){ve(k,$),m=!1},d($){$&&U(e),k&&k.d($),v=!1,V(b)}}}const tt=n=>n.stopPropagation();function nt(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:a}=e,{title:o}=e,{onOk:u}=e,{onClose:d}=e,{cancelText:h}=e,{okText:f}=e,{theme:C}=e;return n.$$set=p=>{"onCancel"in p&&t(0,a=p.onCancel),"title"in p&&t(1,o=p.title),"onOk"in p&&t(2,u=p.onOk),"onClose"in p&&t(3,d=p.onClose),"cancelText"in p&&t(4,h=p.cancelText),"okText"in p&&t(5,f=p.okText),"theme"in p&&t(6,C=p.theme),"$$scope"in p&&t(7,r=p.$$scope)},[a,o,u,d,h,f,C,r,s]}class st extends De{constructor(e){super(),be(this,e,nt,et,pe,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function he(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function ye(n){let e,t,s=n[11].CN+"",r,a,o,u=n[11].DevClass+"",d,h,f=n[11].sn+"",C,p,y,c,g,w;function m(){return n[10](n[13])}return{c(){e=I("div"),t=I("span"),r=A(s),a=N(),o=I("span"),d=A(u),h=A("("),C=A(f),p=A(")"),y=N(),B(t,"class","svelte-jtc2v4"),B(o,"class","svelte-jtc2v4"),B(e,"class",c=ie(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(v,b){Q(v,e,b),S(e,t),S(t,r),S(e,a),S(e,o),S(o,d),S(o,h),S(o,C),S(o,p),S(e,y),g||(w=j(e,"click",m),g=!0)},p(v,b){n=v,b&1&&s!==(s=n[11].CN+"")&&M(r,s),b&1&&u!==(u=n[11].DevClass+"")&&M(d,u),b&1&&f!==(f=n[11].sn+"")&&M(C,f),b&32&&c!==(c=ie(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&B(e,"class",c)},d(v){v&&U(e),g=!1,w()}}}function rt(n){let e,t=de(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=ye(he(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Re()},m(r,a){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(r,a);Q(r,e,a)},p(r,a){if(a&33){t=de(r[0]);let o;for(o=0;o<t.length;o+=1){const u=he(r,t,o);s[o]?s[o].p(u,a):(s[o]=ye(u),s[o].c(),s[o].m(e.parentNode,e))}for(;o<s.length;o+=1)s[o].d(1);s.length=t.length}},d(r){r&&U(e),Ve(s,r)}}}function at(n){let e,t;return e=new st({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[rt]},$$scope:{ctx:n}}}),{c(){Qe(e.$$.fragment)},m(s,r){we(e,s,r),t=!0},p(s,[r]){const a={};r&2&&(a.onClose=s[1]),r&4&&(a.cancelText=s[2]),r&8&&(a.okText=s[3]),r&16&&(a.theme=s[4]),r&16417&&(a.$$scope={dirty:r,ctx:s}),e.$set(a)},i(s){t||(Y(e.$$.fragment,s),t=!0)},o(s){ve(e.$$.fragment,s),t=!1},d(s){ke(e,s)}}}function ot(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:o}=e,{cancelText:u=""}=e,{okText:d=""}=e,{theme:h="#409eff"}=e,f=0;const C=()=>{r("未选择证书"),o==null||o()},p=()=>{a==null||a(s[f]),o==null||o()},y=c=>t(5,f=c);return n.$$set=c=>{"certList"in c&&t(0,s=c.certList),"onCancel"in c&&t(8,r=c.onCancel),"onOk"in c&&t(9,a=c.onOk),"onClose"in c&&t(1,o=c.onClose),"cancelText"in c&&t(2,u=c.cancelText),"okText"in c&&t(3,d=c.okText),"theme"in c&&t(4,h=c.theme)},[s,o,u,d,h,f,C,p,r,a,y]}class it extends De{constructor(e){super(),be(this,e,ot,at,pe,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class ct{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new it({target:document.body,props:x(D({},e),{onCancel:r=>{s({code:-1,msg:r})},onOk:r=>{t(r)},onClose:()=>{this.close()}})})}));i(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const lt=new ct;class ut{constructor(e){i(this,"socketInstance",null);i(this,"eventBus",new Te);i(this,"isRememberPin",!1);i(this,"pinPolicy");i(this,"socketConfig",null);i(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});i(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});i(this,"sendMessage",(e,t)=>new Promise((s,r)=>{var o,u;if(((o=this.socketInstance)==null?void 0:o.readyState)!==WebSocket.OPEN){r({errCode:-1,msg:"数字证书客户端连接失败"});return}const a={function:e,args:[t!=null?t:{}]};(u=this.socketInstance)==null||u.send(JSON.stringify(a)),this.eventBus.on(e,d=>{d.success?s(d.data):r(d)})}));i(this,"handleEventData",e=>l(this,null,function*(){var t,s,r,a,o,u,d,h,f,C;if(e.data instanceof Blob){const p=yield e.data.arrayBuffer(),c=new TextDecoder("gbk").decode(p),g=JSON.parse(c),w={success:(t=g.result)==null?void 0:t.success,msg:(s=g.result)==null?void 0:s.msg,errCode:(r=g.result)==null?void 0:r.errCode,data:g.data},m=(a=g.result)==null?void 0:a.function;m==="GZCA_OnDeviceChange"?(h=(o=this.socketConfig)==null?void 0:o.onUkeyChange)==null||h.call(o,x(D({},w),{type:(u=g.result)==null?void 0:u.event,data:(d=g.data)==null?void 0:d[0]})):this.eventBus.emit(m,w),(C=(f=this.socketConfig)==null?void 0:f.onMessage)==null||C.call(f,w)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return re.fromByteArray(t)});i(this,"base64Decode",e=>{const t=re.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>l(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>l(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:Ee})}));i(this,"certLogin",e=>l(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}))}));i(this,"getCert",(e,t)=>l(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&(yield this.certLogin(s.ContainerName)),s}));i(this,"chooseCert",e=>l(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield lt.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"getCertList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"pkcs1Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",D({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",D({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",D({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",D({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",D({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",D({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",D({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));var t,s;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(s=e.pinPolicy)!=null?s:ge.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=s=>{var r;(r=e.onError)==null||r.call(e,s)},t.onopen=s=>{var r;(r=e.onOpen)==null||r.call(e,s),e.onUkeyChange&&this.addUkeyEvents()},t.onmessage=s=>{this.handleEventData(s)},t.onclose=s=>{var r;(r=e.onClose)==null||r.call(e,s)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const T=class T{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ut(x(D({},e!=null?e:{}),{url:Ae}))});i(this,"appendCertBase64",(e,t=!0)=>l(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return x(D({},e!=null?e:{}),{CertB64:s==null?void 0:s.CertB64})}));i(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});i(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});i(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});i(this,"getSignatureCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:te},e)}));i(this,"getSignatureCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:te})}));i(this,"getEncryptionCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:ne},e)}));i(this,"getEncryptionCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:ne})}));i(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});i(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});i(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});i(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});i(this,"pkcs1Sign",(e,t)=>l(this,null,function*(){var a,o,u;const s=yield this.getSignatureCert(t),r=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(x(D({},e!=null?e:{}),{ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:""}));return(u=r==null?void 0:r[0])==null?void 0:u.SignData}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){var r;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(s)}));i(this,"pkcs1Base64Sign",(e,t)=>l(this,null,function*(){var o,u,d,h,f;const s=yield this.getSignatureCert(t),r=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),a=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign(x(D({},e!=null?e:{}),{ContainerName:(d=s==null?void 0:s.ContainerName)!=null?d:"",DataB64:r}));return(f=a==null?void 0:a[0])==null?void 0:f.SignData}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){var a,o,u;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e);return!!(yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",e=>l(this,null,function*(){var r,a;const t=yield this.getSignatureCert(e),s=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:""});return{cert:t,sealList:s}}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(a=s==null?void 0:s[0])==null?void 0:a.Z}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){var a,o;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e),r=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:t});return r==null?void 0:r[0].H}));i(this,"pkcs1HashSign",(e,t)=>l(this,null,function*(){var a,o,u,d;const s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1HashSign({ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(d=r==null?void 0:r[0])==null?void 0:d.SignData}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(x(D({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var o,u,d,h,f;const s=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield this.getSignatureCert(t),a=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign(x(D({},e!=null?e:{}),{ContainerName:(d=r==null?void 0:r.ContainerName)!=null?d:"",DataB64:s}));return(f=a==null?void 0:a[0])==null?void 0:f.SignData}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){var r,a,o;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));i(this,"sm3Hash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HexHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3FileHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){var a,o,u,d,h,f;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=(d=e.KeyB64)!=null?d:this.base64Encode({Data:(u=e.Key)!=null?u:""}),r=yield(h=this.coreInstance)==null?void 0:h.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(f=r==null?void 0:r[0])==null?void 0:f.DataB64}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){var r,a,o,u;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:(r=e.Data)!=null?r:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(u=s==null?void 0:s[0])==null?void 0:u.DataB64}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){var a,o;const t=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption(x(D({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),r=(o=s==null?void 0:s[0])==null?void 0:o.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:r}):r}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(a=s==null?void 0:s[0])==null?void 0:a.Data}));i(this,"asymmetricDecryption",(e,t)=>l(this,null,function*(){var a,o;const s=yield this.getEncryptionCert(t),r=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption(x(D({},e!=null?e:{}),{ContainerName:s==null?void 0:s.ContainerName}));return(o=r==null?void 0:r[0])==null?void 0:o.Data}));i(this,"sm4Encryption",e=>l(this,null,function*(){var s;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(e);return t==null?void 0:t[0]}));i(this,"sm4Decryption",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(e);return(r=t==null?void 0:t[0])==null?void 0:r.Data}));i(this,"getCertInfo",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e);return D({},(r=t==null?void 0:t[0])!=null?r:{})}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid(D({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return T.instance&&!(e!=null&&e.isCreateNew)?T.instance:(this.createGwsCore(e),T.instance=this,this)}};i(T,"instance",null);let G=T;function dt(n){return new Promise((e,t)=>{if(G.instance&&!(n!=null&&n.isCreateNew))e(G.instance);else{const s=new G(x(D({},n!=null?n:{}),{onOpen(r){var a;e(s),(a=n==null?void 0:n.onOpen)==null||a.call(n,r)},onClose(r){var a;t(r),(a=n==null?void 0:n.onClose)==null||a.call(n,r)}}))}})}exports.GwsService=G;exports.createService=dt;
1
+ "use strict";var Ee=Object.defineProperty,Pe=Object.defineProperties;var $e=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var _e=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var Y=(s,e,t)=>e in s?Ee(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,p=(s,e)=>{for(var t in e||(e={}))_e.call(e,t)&&Y(s,t,e[t]);if(se)for(var t of se(e))Le.call(e,t)&&Y(s,t,e[t]);return s},B=(s,e)=>Pe(s,$e(e));var o=(s,e,t)=>Y(s,typeof e!="symbol"?e+"":e,t);var l=(s,e,t)=>new Promise((n,r)=>{var a=u=>{try{c(t.next(u))}catch(d){r(d)}},i=u=>{try{c(t.throw(u))}catch(d){r(d)}},c=u=>u.done?n(u.value):Promise.resolve(u.value).then(a,i);c((t=t.apply(s,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Me=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",re="1",ae="2";var we=(s=>(s.MIN="0",s.LOW="1",s.MIDDLE="2",s.HIGH="3",s))(we||{});const Te="00000001";function Ne(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var G={},ie;function Ge(){if(ie)return G;ie=1,G.byteLength=c,G.toByteArray=d,G.fromByteArray=m;for(var s=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,a=n.length;r<a;++r)s[r]=n[r],e[n.charCodeAt(r)]=r;e[45]=62,e[95]=63;function i(h){var y=h.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var w=h.indexOf("=");w===-1&&(w=y);var g=w===y?0:4-w%4;return[w,g]}function c(h){var y=i(h),w=y[0],g=y[1];return(w+g)*3/4-g}function u(h,y,w){return(y+w)*3/4-w}function d(h){var y,w=i(h),g=w[0],S=w[1],k=new t(u(h,g,S)),I=0,A=S>0?g-4:g,v;for(v=0;v<A;v+=4)y=e[h.charCodeAt(v)]<<18|e[h.charCodeAt(v+1)]<<12|e[h.charCodeAt(v+2)]<<6|e[h.charCodeAt(v+3)],k[I++]=y>>16&255,k[I++]=y>>8&255,k[I++]=y&255;return S===2&&(y=e[h.charCodeAt(v)]<<2|e[h.charCodeAt(v+1)]>>4,k[I++]=y&255),S===1&&(y=e[h.charCodeAt(v)]<<10|e[h.charCodeAt(v+1)]<<4|e[h.charCodeAt(v+2)]>>2,k[I++]=y>>8&255,k[I++]=y&255),k}function C(h){return s[h>>18&63]+s[h>>12&63]+s[h>>6&63]+s[h&63]}function f(h,y,w){for(var g,S=[],k=y;k<w;k+=3)g=(h[k]<<16&16711680)+(h[k+1]<<8&65280)+(h[k+2]&255),S.push(C(g));return S.join("")}function m(h){for(var y,w=h.length,g=w%3,S=[],k=16383,I=0,A=w-g;I<A;I+=k)S.push(f(h,I,I+k>A?A:I+k));return g===1?(y=h[w-1],S.push(s[y>>2]+s[y<<4&63]+"==")):g===2&&(y=(h[w-2]<<8)+h[w-1],S.push(s[y>>10]+s[y>>4&63]+s[y<<2&63]+"=")),S.join("")}return G}var Fe=Ge();const oe=Ne(Fe);class He{constructor(){o(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const n=this.deps.get(e);n==null||n(t)}}(function(){try{var s=document.createElement("style");s.appendChild(document.createTextNode("button.svelte-16iv9d0{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-16iv9d0{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-16iv9d0{background-color:#fff;padding:1.25rem;border-radius:.3125rem;width:40%}.model-title.svelte-16iv9d0{color:#303133;font-size:1.125rem;margin-bottom:1.125rem}.modal-visible.svelte-16iv9d0{display:flex}.modal-footer.svelte-16iv9d0{display:flex;align-items:center;justify-content:flex-end;margin-top:1rem}.modal-btn.svelte-16iv9d0{padding:.5rem .9375rem;border-radius:.25rem;font-size:.875rem;border:.0625rem solid #dcdfe6}.success.svelte-16iv9d0{margin-left:.75rem;color:#fff}.slot.svelte-16iv9d0{max-height:12.5rem;overflow-y:scroll}.slot.svelte-16iv9d0::-webkit-scrollbar{display:none}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:11.25rem;height:11.25rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.0625rem solid #ccc;margin-top:.625rem;margin-right:.625rem;border-radius:.25rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:6.25rem;height:6.25rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.625rem;color:#333}.cert-item.svelte-1kh75ag.svelte-1kh75ag{padding:1rem;display:flex;align-items:center;cursor:pointer;border-bottom:.0625rem solid #ebeef5;font-size:1rem}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag{word-break:break-all;color:#373a40}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag:nth-child(1){padding-right:.5rem}.cert-item-selected.svelte-1kh75ag.svelte-1kh75ag{background-color:#f1f1f1}.cert-item-first.svelte-1kh75ag.svelte-1kh75ag{border-top:.0625rem solid #ebeef5}")),document.head.appendChild(s)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Ze=Object.defineProperty,Oe=(s,e,t)=>e in s?Ze(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ce=(s,e,t)=>Oe(s,typeof e!="symbol"?e+"":e,t);function Q(){}function Ve(s,e){for(const t in e)s[t]=e[t];return s}function pe(s){return s()}function le(){return Object.create(null)}function O(s){s.forEach(pe)}function H(s){return typeof s=="function"}function Se(s,e){return s!=s?e==e:s!==e||s&&typeof s=="object"||typeof s=="function"}function je(s){return Object.keys(s).length===0}function Ue(s,e,t,n){if(s){const r=ve(s,e,t,n);return s[0](r)}}function ve(s,e,t,n){return s[1]&&n?Ve(t.ctx.slice(),s[1](n(e))):t.ctx}function ze(s,e,t,n){if(s[2]&&n){const r=s[2](n(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const a=[],i=Math.max(e.dirty.length,r.length);for(let c=0;c<i;c+=1)a[c]=e.dirty[c]|r[c];return a}return e.dirty|r}return e.dirty}function Je(s,e,t,n,r,a){if(r){const i=ve(e,t,n,a);s.p(i,r)}}function qe(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 de(s){return s==null?"":s}function b(s,e){s.appendChild(e)}function K(s,e,t){s.insertBefore(e,t||null)}function V(s){s.parentNode&&s.parentNode.removeChild(s)}function ke(s,e){for(let t=0;t<s.length;t+=1)s[t]&&s[t].d(e)}function E(s){return document.createElement(s)}function M(s){return document.createTextNode(s)}function j(){return M(" ")}function We(){return M("")}function F(s,e,t,n){return s.addEventListener(e,t,n),()=>s.removeEventListener(e,t,n)}function x(s,e,t){t==null?s.removeAttribute(e):s.getAttribute(e)!==t&&s.setAttribute(e,t)}function Ke(s){return Array.from(s.childNodes)}function U(s,e){e=""+e,s.data!==e&&(s.data=e)}function q(s,e,t,n){t==null?s.style.removeProperty(e):s.style.setProperty(e,t,"")}let te;function Z(s){te=s}const _=[],ue=[];let T=[];const he=[],Ye=Promise.resolve();let X=!1;function Re(){X||(X=!0,Ye.then(Ie))}function ee(s){T.push(s)}const R=new Set;let $=0;function Ie(){if($!==0)return;const s=te;do{try{for(;$<_.length;){const e=_[$];$++,Z(e),Qe(e.$$)}}catch(e){throw _.length=0,$=0,e}for(Z(null),_.length=0,$=0;ue.length;)ue.pop()();for(let e=0;e<T.length;e+=1){const t=T[e];R.has(t)||(R.add(t),t())}T.length=0}while(_.length);for(;he.length;)he.pop()();X=!1,R.clear(),Z(s)}function Qe(s){if(s.fragment!==null){s.update(),O(s.before_update);const e=s.dirty;s.dirty=[-1],s.fragment&&s.fragment.p(s.ctx,e),s.after_update.forEach(ee)}}function Xe(s){const e=[],t=[];T.forEach(n=>s.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),T=e}const z=new Set;let et;function ne(s,e){s&&s.i&&(z.delete(s),s.i(e))}function Be(s,e,t,n){if(s&&s.o){if(z.has(s))return;z.add(s),et.c.push(()=>{z.delete(s)}),s.o(e)}}function W(s){return(s==null?void 0:s.length)!==void 0?s:Array.from(s)}function tt(s){s&&s.c()}function be(s,e,t){const{fragment:n,after_update:r}=s.$$;n&&n.m(e,t),ee(()=>{const a=s.$$.on_mount.map(pe).filter(H);s.$$.on_destroy?s.$$.on_destroy.push(...a):O(a),s.$$.on_mount=[]}),r.forEach(ee)}function De(s,e){const t=s.$$;t.fragment!==null&&(Xe(t.after_update),O(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function nt(s,e){s.$$.dirty[0]===-1&&(_.push(s),Re(),s.$$.dirty.fill(0)),s.$$.dirty[e/31|0]|=1<<e%31}function xe(s,e,t,n,r,a,i=null,c=[-1]){const u=te;Z(s);const d=s.$$={fragment:null,ctx:[],props:a,update:Q,not_equal:r,bound:le(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(u?u.$$.context:[])),callbacks:le(),dirty:c,skip_bound:!1,root:e.target||u.$$.root};i&&i(d.root);let C=!1;if(d.ctx=t?t(s,e.props||{},(f,m,...h)=>{const y=h.length?h[0]:m;return d.ctx&&r(d.ctx[f],d.ctx[f]=y)&&(!d.skip_bound&&d.bound[f]&&d.bound[f](y),C&&nt(s,f)),m}):[],d.update(),C=!0,O(d.before_update),d.fragment=n?n(d.ctx):!1,e.target){if(e.hydrate){const f=Ke(e.target);d.fragment&&d.fragment.l(f),f.forEach(V)}else d.fragment&&d.fragment.c();e.intro&&ne(s.$$.fragment),be(s,e.target,e.anchor),Ie()}Z(u)}class Ae{constructor(){ce(this,"$$"),ce(this,"$$set")}$destroy(){De(this,1),this.$destroy=Q}$on(e,t){if(!H(t))return Q;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const r=n.indexOf(t);r!==-1&&n.splice(r,1)}}$set(e){this.$$set&&!je(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const st="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(st);function rt(s){let e,t,n,r=(s[1]||"标题")+"",a,i,c,u,d,C,f=(s[4]||"取消")+"",m,h,y,w=(s[5]||"确认")+"",g,S,k,I;const A=s[8].default,v=Ue(A,s,s[7],null);return{c(){e=E("div"),t=E("div"),n=E("div"),a=M(r),i=j(),c=E("div"),v&&v.c(),u=j(),d=E("div"),C=E("button"),m=M(f),h=j(),y=E("button"),g=M(w),x(n,"class","model-title svelte-16iv9d0"),x(c,"class","slot svelte-16iv9d0"),x(C,"class","modal-btn svelte-16iv9d0"),x(y,"class","modal-btn success svelte-16iv9d0"),q(y,"background-color",s[6]),x(d,"class","modal-footer svelte-16iv9d0"),x(t,"class","modal-content svelte-16iv9d0"),x(e,"class","modal-background modal-visible svelte-16iv9d0")},m(D,P){K(D,e,P),b(e,t),b(t,n),b(n,a),b(t,i),b(t,c),v&&v.m(c,null),b(t,u),b(t,d),b(d,C),b(C,m),b(d,h),b(d,y),b(y,g),S=!0,k||(I=[F(C,"click",function(){H(s[0])&&s[0].apply(this,arguments)}),F(y,"click",function(){H(s[2])&&s[2].apply(this,arguments)}),F(t,"click",at),F(e,"click",function(){H(s[3])&&s[3].apply(this,arguments)})],k=!0)},p(D,[P]){s=D,(!S||P&2)&&r!==(r=(s[1]||"标题")+"")&&U(a,r),v&&v.p&&(!S||P&128)&&Je(v,A,s,s[7],S?ze(A,s[7],P,null):qe(s[7]),null),(!S||P&16)&&f!==(f=(s[4]||"取消")+"")&&U(m,f),(!S||P&32)&&w!==(w=(s[5]||"确认")+"")&&U(g,w),(!S||P&64)&&q(y,"background-color",s[6])},i(D){S||(ne(v,D),S=!0)},o(D){Be(v,D),S=!1},d(D){D&&V(e),v&&v.d(D),k=!1,O(I)}}}const at=s=>s.stopPropagation();function it(s,e,t){let{$$slots:n={},$$scope:r}=e,{onCancel:a}=e,{title:i}=e,{onOk:c}=e,{onClose:u}=e,{cancelText:d}=e,{okText:C}=e,{theme:f}=e;return s.$$set=m=>{"onCancel"in m&&t(0,a=m.onCancel),"title"in m&&t(1,i=m.title),"onOk"in m&&t(2,c=m.onOk),"onClose"in m&&t(3,u=m.onClose),"cancelText"in m&&t(4,d=m.cancelText),"okText"in m&&t(5,C=m.okText),"theme"in m&&t(6,f=m.theme),"$$scope"in m&&t(7,r=m.$$scope)},[a,i,c,u,d,C,f,r,n]}class ot extends Ae{constructor(e){super(),xe(this,e,it,rt,Se,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function ge(s,e,t){const n=s.slice();return n[13]=e[t],n[15]=t,n}function ye(s,e,t){const n=s.slice();return n[16]=e[t],n}function fe(s){let e,t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"",n;return{c(){e=E("div"),n=M(t),x(e,"class","svelte-1kh75ag"),q(e,"width",`${100/s[1].length}%`)},m(r,a){K(r,e,a),b(e,n)},p(r,a){a&3&&t!==(t=(r[16].format?r[16].format(r[13]):r[13][r[16].key])+"")&&U(n,t),a&2&&q(e,"width",`${100/r[1].length}%`)},d(r){r&&V(e)}}}function Ce(s){let e,t,n,r,a,i=W(s[1]),c=[];for(let d=0;d<i.length;d+=1)c[d]=fe(ye(s,i,d));function u(){return s[12](s[15])}return{c(){e=E("div");for(let d=0;d<c.length;d+=1)c[d].c();t=j(),x(e,"class",n=de(`cert-item ${s[15]===0?"cert-item-first":""} ${s[15]===s[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(d,C){K(d,e,C);for(let f=0;f<c.length;f+=1)c[f]&&c[f].m(e,null);b(e,t),r||(a=F(e,"click",u),r=!0)},p(d,C){if(s=d,C&3){i=W(s[1]);let f;for(f=0;f<i.length;f+=1){const m=ye(s,i,f);c[f]?c[f].p(m,C):(c[f]=fe(m),c[f].c(),c[f].m(e,t))}for(;f<c.length;f+=1)c[f].d(1);c.length=i.length}C&128&&n!==(n=de(`cert-item ${s[15]===0?"cert-item-first":""} ${s[15]===s[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&x(e,"class",n)},d(d){d&&V(e),ke(c,d),r=!1,a()}}}function ct(s){let e,t=W(s[0]),n=[];for(let r=0;r<t.length;r+=1)n[r]=Ce(ge(s,t,r));return{c(){for(let r=0;r<n.length;r+=1)n[r].c();e=We()},m(r,a){for(let i=0;i<n.length;i+=1)n[i]&&n[i].m(r,a);K(r,e,a)},p(r,a){if(a&131){t=W(r[0]);let i;for(i=0;i<t.length;i+=1){const c=ge(r,t,i);n[i]?n[i].p(c,a):(n[i]=Ce(c),n[i].c(),n[i].m(e.parentNode,e))}for(;i<n.length;i+=1)n[i].d(1);n.length=t.length}},d(r){r&&V(e),ke(n,r)}}}function lt(s){let e,t;return e=new ot({props:{onOk:s[9],onClose:s[2],onCancel:s[8],cancelText:s[3],okText:s[4],title:s[6],theme:s[5],$$slots:{default:[ct]},$$scope:{ctx:s}}}),{c(){tt(e.$$.fragment)},m(n,r){be(e,n,r),t=!0},p(n,[r]){const a={};r&4&&(a.onClose=n[2]),r&8&&(a.cancelText=n[3]),r&16&&(a.okText=n[4]),r&64&&(a.title=n[6]),r&32&&(a.theme=n[5]),r&524419&&(a.$$scope={dirty:r,ctx:n}),e.$set(a)},i(n){t||(ne(e.$$.fragment,n),t=!0)},o(n){Be(e.$$.fragment,n),t=!1},d(n){De(e,n)}}}function dt(s,e,t){let{data:n=[]}=e,{columns:r=[]}=e,{onCancel:a}=e,{onOk:i}=e,{onClose:c}=e,{cancelText:u=""}=e,{okText:d=""}=e,{theme:C="#409eff"}=e,{title:f=""}=e,m=0;const h=()=>{a(`${f}失败`),c==null||c()},y=()=>{i==null||i(n[m]),c==null||c()},w=g=>t(7,m=g);return s.$$set=g=>{"data"in g&&t(0,n=g.data),"columns"in g&&t(1,r=g.columns),"onCancel"in g&&t(10,a=g.onCancel),"onOk"in g&&t(11,i=g.onOk),"onClose"in g&&t(2,c=g.onClose),"cancelText"in g&&t(3,u=g.cancelText),"okText"in g&&t(4,d=g.okText),"theme"in g&&t(5,C=g.theme),"title"in g&&t(6,f=g.title)},[n,r,c,u,d,C,f,m,h,y,a,i,w]}class ut extends Ae{constructor(e){super(),xe(this,e,dt,lt,Se,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class ht{constructor(){o(this,"modalInstance",{current:null});o(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new ut({target:document.body,props:B(p({},e),{onCancel:r=>{n({code:-1,msg:r})},onOk:r=>{t(r)},onClose:()=>{this.close()}})})}));o(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const J=new ht;function gt(s=32,e=!0,t=0){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=[];if(t=t||n.length,s)for(let a=0;a<s;a++)r[a]=n[0|Math.random()*t];else{let a;r[8]=r[13]=r[18]=r[23]="-",r[14]="4";for(let i=0;i<36;i++)r[i]||(a=0|Math.random()*16,r[i]=n[i===19?a&3|8:a])}return e?(r.shift(),`u${r.join("")}`):r.join("")}const yt=[{key:"CN"},{format:s=>`${s.DevClass}(${s.sn})`}],ft=[{key:"SealId"},{key:"Vid"},{format:s=>`${s.FileName}(${s.FileSize}B)`}],me=[{key:"SealId"}];class Ct{constructor(e){o(this,"socketInstance",null);o(this,"eventBus",new He);o(this,"isRememberPin",!1);o(this,"pinPolicy");o(this,"socketConfig",null);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)=>new Promise((n,r)=>{var u,d;if(((u=this.socketInstance)==null?void 0:u.readyState)!==WebSocket.OPEN){r({errCode:-1,msg:"数字证书客户端连接失败"});return}const a=gt(),i=C=>{C.success?n(C.data):r(C)},c={function:e,args:[t!=null?t:{}],msgid:a};(d=this.socketInstance)==null||d.send(JSON.stringify(c)),this.eventBus.on(e,i),this.eventBus.on(a,i)}));o(this,"handleEventData",e=>l(this,null,function*(){var t,n,r,a,i,c,u,d;if(e.data instanceof Blob){const C=yield e.data.arrayBuffer(),m=new TextDecoder("gbk").decode(C),h=JSON.parse(m),y={success:(t=h.result)==null?void 0:t.success,msg:(n=h.result)==null?void 0:n.msg,errCode:(r=h.result)==null?void 0:r.errCode,data:h.data,type:(a=h.result)==null?void 0:a.event},w=(i=h.result)==null?void 0:i.function,g=(c=h.result)==null?void 0:c.msgid;g?this.eventBus.emit(g,y):this.eventBus.emit(w,y),(d=(u=this.socketConfig)==null?void 0:u.onMessage)==null||d.call(u,y)}}));o(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return oe.fromByteArray(t)});o(this,"base64Decode",e=>{const t=oe.toByteArray(e);return new TextDecoder().decode(t)});o(this,"changeIsRememberPin",e=>l(this,null,function*(){this.isRememberPin=e}));o(this,"changePinPolicy",e=>l(this,null,function*(){this.pinPolicy=e}));o(this,"checkCertIsLogin",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));o(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:Te}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,r;(r=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||r.call(t,B(p({},e),{data:(n=e.data)==null?void 0:n[0]}))})}));o(this,"certLogin",e=>l(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,"getCert",(e,t,n)=>l(this,null,function*(){const r=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.certLogin(r.ContainerName)),r}));o(this,"chooseCert",e=>l(this,null,function*(){var r;const t=yield this.getCertList(e);return t!=null&&t.length?(t==null?void 0:t.length)===1?t[0]:yield J.open({title:"选择证书",data:t,columns:yt,theme:(r=this.socketConfig)==null?void 0:r.theme}):Promise.reject({errCode:-1,msg:"暂无证书"})}));o(this,"getCertList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));o(this,"pkcs1Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",p({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",p({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"batchPkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",p({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));o(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));o(this,"getSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"writeSeal",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"deleteSeal",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"getSealInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"getTPSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"getTPSealPic",e=>l(this,null,function*(){var n;return yield this.sendMessage("GZCA_GetSealPicData",p({IsLogin:(n=e.IsLogin)!=null?n:this.getIsLogin()},e!=null?e:{}))}));o(this,"sm2SignPreprocess1",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));o(this,"sm2SignPreprocess2",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));o(this,"pkcs1HashSign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",p({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));o(this,"pkcs7Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",p({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs7VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));o(this,"sm3Hash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));o(this,"sm3HexHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));o(this,"sm3FileHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));o(this,"sm3HashEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));o(this,"pkcs7Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));o(this,"pkcs7Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"pkcs7FileEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeSealFileEx_qyzc",e)}));o(this,"pkcs7FileDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeOpenFileEx_qyzc",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"asymmetricEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));o(this,"asymmetricDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"sm4Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));o(this,"sm4Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));o(this,"getCertInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));o(this,"getCertInfoByOid",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));o(this,"getSealVendor",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetSealIssuer",e)}));o(this,"deleteAllSealByVendor",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));var t,n;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(n=e.pinPolicy)!=null?n:we.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=n=>{var r;(r=e.onError)==null||r.call(e,n)},t.onopen=n=>{var r;(r=e.onOpen)==null||r.call(e,n),e.onUkeyChange&&this.addUkeyEvents()},t.onmessage=n=>{this.handleEventData(n)},t.onclose=n=>{var r;(r=e.onClose)==null||r.call(e,n)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const L=class L{constructor(e){o(this,"coreInstance",null);o(this,"gwsConfig",{});o(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new Ct(B(p({},e!=null?e:{}),{url:Me}))});o(this,"appendCertBase64",(e,t=!0)=>l(this,null,function*(){if(e.CertB64)return e;const n=t?yield this.getSignatureCert():yield this.getEncryptionCert();return B(p({},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,"getSignatureCert",(e,t=!0)=>l(this,null,function*(){var r;return yield(r=this.coreInstance)==null?void 0:r.getCert({CertType:re},e,t)}));o(this,"getSignatureCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:re})}));o(this,"getEncryptionCert",(e,t=!0)=>l(this,null,function*(){var r;return yield(r=this.coreInstance)==null?void 0:r.getCert({CertType:ae},e,t)}));o(this,"getEncryptionCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:ae})}));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)=>l(this,null,function*(){var a,i,c;const n=yield this.getSignatureCert(t),r=yield(i=this.coreInstance)==null?void 0:i.pkcs1Sign(B(p({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""}));return(c=r==null?void 0:r[0])==null?void 0:c.SignData}));o(this,"pkcs1VerifySignature",e=>l(this,null,function*(){var r;const t=yield this.appendCertBase64(e),n=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(n)}));o(this,"pkcs1Base64Sign",(e,t)=>l(this,null,function*(){var i,c,u,d,C;const n=yield this.getSignatureCert(t),r=(c=e.DataB64)!=null?c:this.base64Encode({Data:(i=e.Data)!=null?i:""}),a=yield(d=this.coreInstance)==null?void 0:d.pkcs1Base64Sign(B(p({},e!=null?e:{}),{ContainerName:(u=n==null?void 0:n.ContainerName)!=null?u:"",DataB64:r}));return(C=a==null?void 0:a[0])==null?void 0:C.SignData}));o(this,"batchPkcs1Base64Sign",(e,t)=>l(this,null,function*(){var C,f,m,h,y,w;const n="|",r=(f=e.DataB64)!=null?f:(C=e.Data)==null?void 0:C.map(g=>this.base64Encode({Data:g})),a=yield this.getSignatureCert(t);let i="";i=Array.isArray(r)?r==null?void 0:r.map((g,S)=>`${S}:${g}`).join(n):"";const c=yield(h=this.coreInstance)==null?void 0:h.batchPkcs1Base64Sign({ContainerName:(m=a==null?void 0:a.ContainerName)!=null?m:"",DataB64:i}),u=(w=(y=c==null?void 0:c[0])==null?void 0:y.SignData)==null?void 0:w.split(n),d=[];return u.forEach(g=>{const S=g.split(":"),k=Number(S[0]),I=S[1];d[k]=I}),d}));o(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){var a,i,c;const t=(i=e.DataB64)!=null?i:this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=yield this.appendCertBase64(e);return!!(yield(c=this.coreInstance)==null?void 0:c.pkcs1Base64VerifySignature({CertB64:n.CertB64,DataB64:t,SignData:n.SignData}))}));o(this,"writeSeal",(e,t)=>l(this,null,function*(){var a,i;const n=yield this.getSignatureCert(t);return!!(yield(i=this.coreInstance)==null?void 0:i.writeSeal(B(p({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""})))}));o(this,"deleteSeal",e=>l(this,null,function*(){var a,i,c,u,d;const t=yield this.getSealList(e);if(!((a=t==null?void 0:t.data)!=null&&a.length))return Promise.reject({errCode:-1,msg:"暂无印章"});const n=yield J.open({title:"删除印章",data:t==null?void 0:t.data,columns:me,okText:"删除"});return!!(yield(d=this.coreInstance)==null?void 0:d.deleteSeal({ContainerName:(c=(i=t==null?void 0:t.cert)==null?void 0:i.ContainerName)!=null?c:"",SealId:(u=n==null?void 0:n.SealId)!=null?u:""}))}));o(this,"getSealList",e=>l(this,null,function*(){var r,a;const t=yield this.getSignatureCert(e),n=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:"",IsLogin:"Y"});return{cert:t,data:n}}));o(this,"getSealInfo",e=>l(this,null,function*(){var a,i,c,u,d,C,f;const t=yield this.getSealList(e);if(!((a=t==null?void 0:t.data)!=null&&a.length))return Promise.reject({errCode:-1,msg:"暂无印章"});const n=((i=t==null?void 0:t.data)==null?void 0:i.length)>1?yield J.open({title:"选择印章",data:t==null?void 0:t.data,columns:me,theme:(c=this.gwsConfig)==null?void 0:c.theme}):t==null?void 0:t.data[0],r=yield(f=this.coreInstance)==null?void 0:f.getSealInfo({ContainerName:(d=(u=t==null?void 0:t.cert)==null?void 0:u.ContainerName)!=null?d:"",SealId:(C=n==null?void 0:n.SealId)!=null?C:""});return r==null?void 0:r[0]}));o(this,"getTPSealList",(e,t)=>l(this,null,function*(){var a,i;const n=yield this.getSignatureCert(t),r=yield(i=this.coreInstance)==null?void 0:i.getTPSealList({ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:"",Vid:e==null?void 0:e.Vid});return{cert:n,data:r}}));o(this,"getTPSeal",(e,t)=>l(this,null,function*(){var a,i,c;const n=yield this.getTPSealList(e,t);if(!((a=n==null?void 0:n.data)!=null&&a.length))return Promise.reject({errCode:-1,msg:"暂无印章"});const r=((i=n==null?void 0:n.data)==null?void 0:i.length)===1?n==null?void 0:n.data[0]:yield J.open({title:"选择印章",data:n==null?void 0:n.data,columns:ft,theme:(c=this.gwsConfig)==null?void 0:c.theme});return{cert:n==null?void 0:n.cert,data:r}}));o(this,"getTPSealPic",(e,t)=>l(this,null,function*(){var a,i,c,u,d;const n=yield this.getTPSeal(e,t),r=yield(d=this.coreInstance)==null?void 0:d.getTPSealPic(B(p({ContainerName:(i=(a=n==null?void 0:n.cert)==null?void 0:a.ContainerName)!=null?i:""},(c=n==null?void 0:n.data)!=null?c:{}),{FileSize:String((u=n==null?void 0:n.data)==null?void 0:u.FileSize)}));return r==null?void 0:r[0]}));o(this,"sm2SignPreprocess1",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e),n=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(a=n==null?void 0:n[0])==null?void 0:a.Z}));o(this,"sm2SignPreprocess2",e=>l(this,null,function*(){var a,i;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=yield this.appendCertBase64(e),r=yield(i=this.coreInstance)==null?void 0:i.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return r==null?void 0:r[0].H}));o(this,"pkcs1HashSign",(e,t)=>l(this,null,function*(){var a,i,c,u;const n=yield this.getSignatureCert(t),r=yield(c=this.coreInstance)==null?void 0:c.pkcs1HashSign({ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(i=e.HashAlg)!=null?i:"sm3"});return(u=r==null?void 0:r[0])==null?void 0:u.SignData}));o(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(B(p({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));o(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var i,c,u,d,C;const n=(c=e.DataB64)!=null?c:this.base64Encode({Data:(i=e.Data)!=null?i:""}),r=yield this.getSignatureCert(t),a=yield(d=this.coreInstance)==null?void 0:d.pkcs7Sign(B(p({},e!=null?e:{}),{ContainerName:(u=r==null?void 0:r.ContainerName)!=null?u:"",DataB64:n}));return(C=a==null?void 0:a[0])==null?void 0:C.SignData}));o(this,"pkcs7VerifySignature",e=>l(this,null,function*(){var r,a,i;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(i=this.coreInstance)==null?void 0:i.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));o(this,"sm3Hash",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));o(this,"sm3HexHash",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));o(this,"sm3FileHash",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));o(this,"sm3HashEncryption",e=>l(this,null,function*(){var a,i,c,u,d,C;const t=(i=e.DataB64)!=null?i:this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=(u=e.KeyB64)!=null?u:this.base64Encode({Data:(c=e.Key)!=null?c:""}),r=yield(d=this.coreInstance)==null?void 0:d.sm3HashEncryption({dataB64:t,keyB64:n,alg:"sm3"});return(C=r==null?void 0:r[0])==null?void 0:C.DataB64}));o(this,"pkcs7Encryption",e=>l(this,null,function*(){var r,a,i,c;if(!e.CertB64List){const u=yield this.getEncryptionCert();e.CertB64List=u==null?void 0:u.CertB64}const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield(i=this.coreInstance)==null?void 0:i.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(c=n==null?void 0:n[0])==null?void 0:c.DataB64}));o(this,"pkcs7Decryption",e=>l(this,null,function*(){var a,i;const t=yield this.getEncryptionCert(),n=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption(B(p({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),r=(i=n==null?void 0:n[0])==null?void 0:i.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:r}):r}));o(this,"pkcs7FileEncryption",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7FileEncryption(t);return(a=n==null?void 0:n[0])==null?void 0:a.DataB64}));o(this,"pkcs7FileDecryption",e=>l(this,null,function*(){var r,a,i;const t=yield this.getEncryptionCert(),n=yield(a=this.coreInstance)==null?void 0:a.pkcs7FileDecryption({SrcFile:e.SrcFile,DstFile:(r=e.DstFile)!=null?r:e.SrcFile.slice(0,-4),ContainerName:t==null?void 0:t.ContainerName});return(i=n==null?void 0:n[0])==null?void 0:i.DataB64}));o(this,"asymmetricEncryption",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),n=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(a=n==null?void 0:n[0])==null?void 0:a.Data}));o(this,"asymmetricDecryption",(e,t)=>l(this,null,function*(){var a,i;const n=yield this.getEncryptionCert(t),r=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption(B(p({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(i=r==null?void 0:r[0])==null?void 0:i.Data}));o(this,"sm4Encryption",e=>l(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=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Decryption(e);return(r=t==null?void 0:t[0])==null?void 0:r.Data}));o(this,"getCertInfo",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfo(e);return p({},(r=t==null?void 0:t[0])!=null?r:{})}));o(this,"getCertInfoByOid",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(p({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));o(this,"getSealVendor",e=>l(this,null,function*(){var r;const t=yield this.getSignatureCert(e),n=yield(r=this.coreInstance)==null?void 0:r.getSealVendor({ContainerName:t==null?void 0:t.ContainerName});return n==null?void 0:n[0]}));o(this,"deleteAllSealByVendor",(e,t)=>l(this,null,function*(){var a;const n=yield this.getSignatureCert(t),r=yield(a=this.coreInstance)==null?void 0:a.deleteAllSealByVendor(B(p({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return r==null?void 0:r[0]}));return L.instance&&!(e!=null&&e.isCreateNew)?L.instance:(this.createGwsCore(e),L.instance=this,this)}};o(L,"instance",null);let N=L;function mt(s){return new Promise((e,t)=>{if(N.instance&&!(s!=null&&s.isCreateNew))e(N.instance);else{const n=new N(B(p({},s!=null?s:{}),{onOpen(r){var a;e(n),(a=s==null?void 0:s.onOpen)==null||a.call(s,r)},onClose(r){var a;t(r),(a=s==null?void 0:s.onClose)==null||a.call(s,r)}}))}})}exports.GwsService=N;exports.createService=mt;
package/dist/index.d.ts CHANGED
@@ -21,9 +21,9 @@ export declare class GwsService {
21
21
  destroy: () => void;
22
22
  restart: (config?: Record<string, any>) => void;
23
23
  getSocketReadyState: () => number | undefined;
24
- getSignatureCert: (cert?: CertType) => Promise<CertType | undefined>;
24
+ getSignatureCert: (cert?: CertType, checkLogin?: boolean) => Promise<Record<string, any> | undefined>;
25
25
  getSignatureCertList: () => Promise<CertType[] | undefined>;
26
- getEncryptionCert: (cert?: CertType) => Promise<CertType | undefined>;
26
+ getEncryptionCert: (cert?: CertType, checkLogin?: boolean) => Promise<Record<string, any> | undefined>;
27
27
  getEncryptionCertList: () => Promise<CertType[] | undefined>;
28
28
  base64Encode: (params: {
29
29
  Data: string;
@@ -32,7 +32,7 @@ export declare class GwsService {
32
32
  DataB64: string;
33
33
  }) => string;
34
34
  changeIsRememberPin: (bol: boolean) => void;
35
- changePinPolicy: (pinPolicy: number) => void;
35
+ changePinPolicy: (pinPolicy: string) => void;
36
36
  pkcs1Sign: (params: {
37
37
  Data: string;
38
38
  IsLogin?: string;
@@ -47,18 +47,54 @@ export declare class GwsService {
47
47
  DataB64?: string;
48
48
  IsLogin?: string;
49
49
  }, curCert?: CertType) => Promise<any>;
50
+ batchPkcs1Base64Sign: (params: {
51
+ Data?: string[];
52
+ DataB64?: string[];
53
+ }, curCert?: CertType) => Promise<string[]>;
50
54
  pkcs1Base64VerifySignature: (params: {
51
55
  CertB64?: string;
52
56
  Data?: string;
53
57
  DataB64?: string;
54
58
  SignData: string;
55
59
  }) => Promise<boolean>;
60
+ writeSeal: (params: {
61
+ SealId: string;
62
+ DataB64: string;
63
+ IsLogin?: string;
64
+ }, curCert?: CertType) => Promise<boolean>;
65
+ deleteSeal: (curCert?: CertType) => Promise<boolean>;
56
66
  getSealList: (curCert?: CertType) => Promise<{
57
- cert: CertType | undefined;
58
- sealList: {
67
+ cert: Record<string, any> | undefined;
68
+ data: {
69
+ SealId: string;
70
+ }[];
71
+ }>;
72
+ getSealInfo: (curCert?: CertType) => Promise<any>;
73
+ getTPSealList: (params?: {
74
+ Vid?: string;
75
+ }, curCert?: CertType) => Promise<{
76
+ cert: Record<string, any> | undefined;
77
+ data: {
78
+ FileName: string;
79
+ FileSize: number;
59
80
  SealId: string;
81
+ Vid: string;
60
82
  }[];
61
83
  }>;
84
+ getTPSeal: (params?: {
85
+ Vid: string;
86
+ }, curCert?: CertType) => Promise<{
87
+ cert: Record<string, any> | undefined;
88
+ data: Record<string, any> | {
89
+ FileName: string;
90
+ FileSize: number;
91
+ SealId: string;
92
+ Vid: string;
93
+ };
94
+ }>;
95
+ getTPSealPic: (params?: {
96
+ Vid: string;
97
+ }, curCert?: CertType) => Promise<any>;
62
98
  sm2SignPreprocess1: (params: {
63
99
  CertB64?: string;
64
100
  }) => Promise<any>;
@@ -113,6 +149,15 @@ export declare class GwsService {
113
149
  shouldDecodeBase64?: boolean;
114
150
  IsLogin?: string;
115
151
  }) => Promise<any>;
152
+ pkcs7FileEncryption: (params: {
153
+ DstFile?: string;
154
+ CertB64?: string;
155
+ SrcFile: string;
156
+ }) => Promise<any>;
157
+ pkcs7FileDecryption: (params: {
158
+ SrcFile: string;
159
+ DstFile?: string;
160
+ }) => Promise<any>;
116
161
  asymmetricEncryption: (params: {
117
162
  CertB64?: string;
118
163
  Data: string;
@@ -135,20 +180,31 @@ export declare class GwsService {
135
180
  Oid: string;
136
181
  CertB64: string;
137
182
  }) => Promise<any>;
183
+ getSealVendor: (curCert?: CertType) => Promise<any>;
184
+ deleteAllSealByVendor: (params: {
185
+ SealIssuer: string;
186
+ }, curCert?: CertType) => Promise<any>;
138
187
  }
139
188
 
140
- export declare type ModalOptions = {
189
+ export declare type SelectModalColItemType = {
190
+ key?: string;
191
+ format?: (record: Record<string, any>) => string;
192
+ };
193
+
194
+ export declare type SelectModalOptions = {
195
+ data: Record<string, any>[];
196
+ columns: SelectModalColItemType[];
141
197
  cancelText?: string;
142
198
  okText?: string;
143
- certList?: CertType[];
144
199
  onOk?: (cert: CertType) => void;
145
200
  onCancel?: (cert: CertType) => void;
146
201
  theme?: string;
202
+ title?: string;
147
203
  };
148
204
 
149
205
  export declare type ServiceConfigType = {
150
206
  url?: string;
151
- pinPolicy?: number;
207
+ pinPolicy?: string;
152
208
  isRememberPin?: boolean;
153
209
  isCreateNew?: boolean;
154
210
  onOpen?: (event: Event) => void;
@@ -164,6 +220,14 @@ export declare type SocketResponseType = {
164
220
  success?: boolean;
165
221
  msg: string;
166
222
  errCode: number;
223
+ type?: string;
224
+ };
225
+
226
+ export declare type TPSeaType = {
227
+ FileName: string;
228
+ FileSize: number;
229
+ SealId: string;
230
+ Vid: string;
167
231
  };
168
232
 
169
233
  export { }