gws-client 0.5.0 → 0.5.2

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 kt=Object.defineProperty,xt=Object.defineProperties;var Dt=Object.getOwnPropertyDescriptors;var tt=Object.getOwnPropertySymbols;var bt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var U=(n,t,e)=>t in n?kt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,b=(n,t)=>{for(var e in t||(t={}))bt.call(t,e)&&U(n,e,t[e]);if(tt)for(var e of tt(t))Bt.call(t,e)&&U(n,e,t[e]);return n},B=(n,t)=>xt(n,Dt(t));var c=(n,t,e)=>U(n,typeof t!="symbol"?t+"":t,e);var l=(n,t,e)=>new Promise((s,a)=>{var r=u=>{try{i(e.next(u))}catch(h){a(h)}},o=u=>{try{i(e.throw(u))}catch(h){a(h)}},i=u=>u.done?s(u.value):Promise.resolve(u.value).then(r,o);i((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",$t="1",It="2";var ut=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(ut||{});const Et="00000001";function At(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var F={},et;function _t(){if(et)return F;et=1,F.byteLength=i,F.toByteArray=h,F.fromByteArray=D;for(var n=[],t=[],e=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,r=s.length;a<r;++a)n[a]=s[a],t[s.charCodeAt(a)]=a;t[45]=62,t[95]=63;function o(d){var p=d.length;if(p%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=d.indexOf("=");f===-1&&(f=p);var v=f===p?0:4-f%4;return[f,v]}function i(d){var p=o(d),f=p[0],v=p[1];return(f+v)*3/4-v}function u(d,p,f){return(p+f)*3/4-f}function h(d){var p,f=o(d),v=f[0],w=f[1],m=new e(u(d,v,w)),k=0,A=w>0?v-4:v,C;for(C=0;C<A;C+=4)p=t[d.charCodeAt(C)]<<18|t[d.charCodeAt(C+1)]<<12|t[d.charCodeAt(C+2)]<<6|t[d.charCodeAt(C+3)],m[k++]=p>>16&255,m[k++]=p>>8&255,m[k++]=p&255;return w===2&&(p=t[d.charCodeAt(C)]<<2|t[d.charCodeAt(C+1)]>>4,m[k++]=p&255),w===1&&(p=t[d.charCodeAt(C)]<<10|t[d.charCodeAt(C+1)]<<4|t[d.charCodeAt(C+2)]>>2,m[k++]=p>>8&255,m[k++]=p&255),m}function g(d){return n[d>>18&63]+n[d>>12&63]+n[d>>6&63]+n[d&63]}function y(d,p,f){for(var v,w=[],m=p;m<f;m+=3)v=(d[m]<<16&16711680)+(d[m+1]<<8&65280)+(d[m+2]&255),w.push(g(v));return w.join("")}function D(d){for(var p,f=d.length,v=f%3,w=[],m=16383,k=0,A=f-v;k<A;k+=m)w.push(y(d,k,k+m>A?A:k+m));return v===1?(p=d[f-1],w.push(n[p>>2]+n[p<<4&63]+"==")):v===2&&(p=(d[f-2]<<8)+d[f-1],w.push(n[p>>10]+n[p>>4&63]+n[p<<2&63]+"=")),w.join("")}return F}var Lt=_t();const nt=At(Lt);class Pt{constructor(){c(this,"deps",new Map)}on(t,e){this.deps.set(t,e)}emit(t,e){const s=this.deps.get(t);s&&s(e)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-n1zwga{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-n1zwga{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-n1zwga{background-color:#fff;padding:20px;border-radius:5px;width:40%}.model-title.svelte-n1zwga{color:#303133;font-size:18px;margin-bottom:16px}.modal-visible.svelte-n1zwga{display:flex}.modal-footer.svelte-n1zwga{display:flex;align-items:center;justify-content:flex-end;margin-top:16px}.modal-btn.svelte-n1zwga{padding:8px 15px;border-radius:4px;font-size:14px;border:1px solid #dcdfe6}.success.svelte-n1zwga{background-color:#409eff;margin-left:12px;color:#fff}.slot.svelte-n1zwga{max-height:200px;overflow-y:scroll}.slot.svelte-n1zwga::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:16px;display:flex;align-items:center;cursor:pointer;border-bottom:1px solid #ebeef5;font-size:14px}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:1px 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:180px;height:180px;display:flex;flex-direction:column;align-items:center;justify-content:center;border:1px solid #ccc;margin-top:10px;margin-right:10px;border-radius:4px}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:100px;height:100px}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:10px;color:#333}")),document.head.appendChild(n)}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var Mt=Object.defineProperty,Tt=(n,t,e)=>t in n?Mt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,st=(n,t,e)=>Tt(n,typeof t!="symbol"?t+"":t,e);function q(){}function Ht(n,t){for(const e in t)n[e]=t[e];return n}function ht(n){return n()}function at(){return Object.create(null)}function z(n){n.forEach(ht)}function O(n){return typeof n=="function"}function yt(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function Gt(n){return Object.keys(n).length===0}function Ft(n,t,e,s){if(n){const a=pt(n,t,e,s);return n[0](a)}}function pt(n,t,e,s){return n[1]&&s?Ht(e.ctx.slice(),n[1](s(t))):e.ctx}function jt(n,t,e,s){if(n[2]&&s){const a=n[2](s(e));if(t.dirty===void 0)return a;if(typeof a=="object"){const r=[],o=Math.max(t.dirty.length,a.length);for(let i=0;i<o;i+=1)r[i]=t.dirty[i]|a[i];return r}return t.dirty|a}return t.dirty}function Ot(n,t,e,s,a,r){if(a){const o=pt(t,e,s,r);n.p(o,a)}}function Zt(n){if(n.ctx.length>32){const t=[],e=n.ctx.length/32;for(let s=0;s<e;s++)t[s]=-1;return t}return-1}function rt(n){return n!=null?n:""}function x(n,t){n.appendChild(t)}function Q(n,t,e){n.insertBefore(t,e||null)}function R(n){n.parentNode&&n.parentNode.removeChild(n)}function Nt(n,t){for(let e=0;e<n.length;e+=1)n[e]&&n[e].d(t)}function I(n){return document.createElement(n)}function E(n){return document.createTextNode(n)}function Z(){return E(" ")}function zt(){return E("")}function j(n,t,e,s){return n.addEventListener(t,e,s),()=>n.removeEventListener(t,e,s)}function S(n,t,e){e==null?n.removeAttribute(t):n.getAttribute(t)!==e&&n.setAttribute(t,e)}function Vt(n){return Array.from(n.childNodes)}function T(n,t){t=""+t,n.data!==t&&(n.data=t)}let X;function N(n){X=n}const P=[],ot=[];let H=[];const ct=[],Rt=Promise.resolve();let K=!1;function Ut(){K||(K=!0,Rt.then(gt))}function W(n){H.push(n)}const J=new Set;let L=0;function gt(){if(L!==0)return;const n=X;do{try{for(;L<P.length;){const t=P[L];L++,N(t),Jt(t.$$)}}catch(t){throw P.length=0,L=0,t}for(N(null),P.length=0,L=0;ot.length;)ot.pop()();for(let t=0;t<H.length;t+=1){const e=H[t];J.has(e)||(J.add(e),e())}H.length=0}while(P.length);for(;ct.length;)ct.pop()();K=!1,J.clear(),N(n)}function Jt(n){if(n.fragment!==null){n.update(),z(n.before_update);const t=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,t),n.after_update.forEach(W)}}function qt(n){const t=[],e=[];H.forEach(s=>n.indexOf(s)===-1?t.push(s):e.push(s)),e.forEach(s=>s()),H=t}const V=new Set;let Kt;function Y(n,t){n&&n.i&&(V.delete(n),n.i(t))}function ft(n,t,e,s){if(n&&n.o){if(V.has(n))return;V.add(n),Kt.c.push(()=>{V.delete(n)}),n.o(t)}}function it(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Wt(n){n&&n.c()}function mt(n,t,e){const{fragment:s,after_update:a}=n.$$;s&&s.m(t,e),W(()=>{const r=n.$$.on_mount.map(ht).filter(O);n.$$.on_destroy?n.$$.on_destroy.push(...r):z(r),n.$$.on_mount=[]}),a.forEach(W)}function wt(n,t){const e=n.$$;e.fragment!==null&&(qt(e.after_update),z(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Qt(n,t){n.$$.dirty[0]===-1&&(P.push(n),Ut(),n.$$.dirty.fill(0)),n.$$.dirty[t/31|0]|=1<<t%31}function Ct(n,t,e,s,a,r,o=null,i=[-1]){const u=X;N(n);const h=n.$$={fragment:null,ctx:[],props:r,update:q,not_equal:a,bound:at(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(u?u.$$.context:[])),callbacks:at(),dirty:i,skip_bound:!1,root:t.target||u.$$.root};o&&o(h.root);let g=!1;if(h.ctx=e?e(n,t.props||{},(y,D,...d)=>{const p=d.length?d[0]:D;return h.ctx&&a(h.ctx[y],h.ctx[y]=p)&&(!h.skip_bound&&h.bound[y]&&h.bound[y](p),g&&Qt(n,y)),D}):[],h.update(),g=!0,z(h.before_update),h.fragment=s?s(h.ctx):!1,t.target){if(t.hydrate){const y=Vt(t.target);h.fragment&&h.fragment.l(y),y.forEach(R)}else h.fragment&&h.fragment.c();t.intro&&Y(n.$$.fragment),mt(n,t.target,t.anchor),gt()}N(u)}class vt{constructor(){st(this,"$$"),st(this,"$$set")}$destroy(){wt(this,1),this.$destroy=q}$on(t,e){if(!O(e))return q;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(e),()=>{const a=s.indexOf(e);a!==-1&&s.splice(a,1)}}$set(t){this.$$set&&!Gt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Xt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Xt);function Yt(n){let t,e,s,a=(n[1]||"标题")+"",r,o,i,u,h,g,y=(n[4]||"取消")+"",D,d,p,f=(n[5]||"确认")+"",v,w,m,k;const A=n[7].default,C=Ft(A,n,n[6],null);return{c(){t=I("div"),e=I("div"),s=I("div"),r=E(a),o=Z(),i=I("div"),C&&C.c(),u=Z(),h=I("div"),g=I("button"),D=E(y),d=Z(),p=I("button"),v=E(f),S(s,"class","model-title svelte-n1zwga"),S(i,"class","slot svelte-n1zwga"),S(g,"class","modal-btn svelte-n1zwga"),S(p,"class","modal-btn success svelte-n1zwga"),S(h,"class","modal-footer svelte-n1zwga"),S(e,"class","modal-content svelte-n1zwga"),S(t,"class","modal-background modal-visible svelte-n1zwga")},m($,_){Q($,t,_),x(t,e),x(e,s),x(s,r),x(e,o),x(e,i),C&&C.m(i,null),x(e,u),x(e,h),x(h,g),x(g,D),x(h,d),x(h,p),x(p,v),w=!0,m||(k=[j(g,"click",function(){O(n[0])&&n[0].apply(this,arguments)}),j(p,"click",function(){O(n[2])&&n[2].apply(this,arguments)}),j(e,"click",te),j(t,"click",function(){O(n[3])&&n[3].apply(this,arguments)})],m=!0)},p($,[_]){n=$,(!w||_&2)&&a!==(a=(n[1]||"标题")+"")&&T(r,a),C&&C.p&&(!w||_&64)&&Ot(C,A,n,n[6],w?jt(A,n[6],_,null):Zt(n[6]),null),(!w||_&16)&&y!==(y=(n[4]||"取消")+"")&&T(D,y),(!w||_&32)&&f!==(f=(n[5]||"确认")+"")&&T(v,f)},i($){w||(Y(C,$),w=!0)},o($){ft(C,$),w=!1},d($){$&&R(t),C&&C.d($),m=!1,z(k)}}}const te=n=>n.stopPropagation();function ee(n,t,e){let{$$slots:s={},$$scope:a}=t,{onCancel:r}=t,{title:o}=t,{onOk:i}=t,{onClose:u}=t,{cancelText:h}=t,{okText:g}=t;return n.$$set=y=>{"onCancel"in y&&e(0,r=y.onCancel),"title"in y&&e(1,o=y.title),"onOk"in y&&e(2,i=y.onOk),"onClose"in y&&e(3,u=y.onClose),"cancelText"in y&&e(4,h=y.cancelText),"okText"in y&&e(5,g=y.okText),"$$scope"in y&&e(6,a=y.$$scope)},[r,o,i,u,h,g,a,s]}class ne extends vt{constructor(t){super(),Ct(this,t,ee,Yt,yt,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5})}}function lt(n,t,e){const s=n.slice();return s[10]=t[e],s[12]=e,s}function dt(n){let t,e,s=n[10].CN+"",a,r,o,i=n[10].DevClass+"",u,h,g=n[10].sn+"",y,D,d,p,f,v;function w(){return n[9](n[12])}return{c(){t=I("div"),e=I("span"),a=E(s),r=Z(),o=I("span"),u=E(i),h=E("("),y=E(g),D=E(")"),d=Z(),S(e,"class","svelte-jtc2v4"),S(o,"class","svelte-jtc2v4"),S(t,"class",p=rt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(m,k){Q(m,t,k),x(t,e),x(e,a),x(t,r),x(t,o),x(o,u),x(o,h),x(o,y),x(o,D),x(t,d),f||(v=j(t,"click",w),f=!0)},p(m,k){n=m,k&1&&s!==(s=n[10].CN+"")&&T(a,s),k&1&&i!==(i=n[10].DevClass+"")&&T(u,i),k&1&&g!==(g=n[10].sn+"")&&T(y,g),k&16&&p!==(p=rt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&S(t,"class",p)},d(m){m&&R(t),f=!1,v()}}}function se(n){let t,e=it(n[0]),s=[];for(let a=0;a<e.length;a+=1)s[a]=dt(lt(n,e,a));return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=zt()},m(a,r){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(a,r);Q(a,t,r)},p(a,r){if(r&17){e=it(a[0]);let o;for(o=0;o<e.length;o+=1){const i=lt(a,e,o);s[o]?s[o].p(i,r):(s[o]=dt(i),s[o].c(),s[o].m(t.parentNode,t))}for(;o<s.length;o+=1)s[o].d(1);s.length=e.length}},d(a){a&&R(t),Nt(s,a)}}}function ae(n){let t,e;return t=new ne({props:{onOk:n[6],onClose:n[1],onCancel:n[5],cancelText:n[2],okText:n[3],title:"选择证书",$$slots:{default:[se]},$$scope:{ctx:n}}}),{c(){Wt(t.$$.fragment)},m(s,a){mt(t,s,a),e=!0},p(s,[a]){const r={};a&2&&(r.onClose=s[1]),a&4&&(r.cancelText=s[2]),a&8&&(r.okText=s[3]),a&8209&&(r.$$scope={dirty:a,ctx:s}),t.$set(r)},i(s){e||(Y(t.$$.fragment,s),e=!0)},o(s){ft(t.$$.fragment,s),e=!1},d(s){wt(t,s)}}}function re(n,t,e){let{certList:s=[]}=t,{onCancel:a}=t,{onOk:r}=t,{onClose:o}=t,{cancelText:i=""}=t,{okText:u=""}=t,h=0;const g=()=>{o==null||o()},y=()=>{r==null||r(s[h]),o==null||o()},D=d=>e(4,h=d);return n.$$set=d=>{"certList"in d&&e(0,s=d.certList),"onCancel"in d&&e(7,a=d.onCancel),"onOk"in d&&e(8,r=d.onOk),"onClose"in d&&e(1,o=d.onClose),"cancelText"in d&&e(2,i=d.cancelText),"okText"in d&&e(3,u=d.okText)},[s,o,i,u,h,g,y,a,r,D]}class oe extends vt{constructor(t){super(),Ct(this,t,re,ae,yt,{certList:0,onCancel:7,onOk:8,onClose:1,cancelText:2,okText:3})}}class ce{constructor(){c(this,"modalInstance",{current:null});c(this,"open",t=>new Promise((e,s)=>{this.modalInstance.current=new oe({target:document.body,props:B(b({},t),{onCancel:a=>{s()},onOk:a=>{e(a)},onClose:()=>{this.close()}})})}));c(this,"close",()=>{setTimeout(()=>{var t;(t=this.modalInstance.current)==null||t.$destroy()})})}}const ie=new ce;class le{constructor(t){c(this,"socketInstance",null);c(this,"eventBus",new Pt);c(this,"isRememberPin",!1);c(this,"socketEvent");c(this,"pinPolicy");c(this,"socketConfig",null);c(this,"getSocketReadyState",()=>{var t;return(t=this.socketInstance)==null?void 0:t.readyState});c(this,"destroy",()=>{var t;(t=this.socketInstance)==null||t.close()});c(this,"sendMessage",(t,e)=>new Promise((s,a)=>{var o,i;if(((o=this.socketInstance)==null?void 0:o.readyState)!==WebSocket.OPEN){console.log(t),a({errCode:-1,msg:"socket未连接"});return}const r={function:t,args:[e!=null?e:{}]};(i=this.socketInstance)==null||i.send(JSON.stringify(r)),this.eventBus.on(t,u=>{u.success?s(u.data):a(u)})}));c(this,"handleEventData",t=>l(this,null,function*(){var e,s,a,r,o,i;if(t.data instanceof Blob){const u=yield t.data.arrayBuffer(),g=new TextDecoder("gbk").decode(u),y=JSON.parse(g),D={data:y.data,success:(e=y.result)==null?void 0:e.success,msg:(s=y.result)==null?void 0:s.msg,errCode:(a=y.result)==null?void 0:a.errCode};this.eventBus.emit((r=y.result)==null?void 0:r.function,D),(i=(o=this.socketConfig)==null?void 0:o.onMessage)==null||i.call(o,D)}}));c(this,"base64Encode",t=>{const e=new TextEncoder().encode(t);return nt.fromByteArray(e)});c(this,"base64Decode",t=>{const e=nt.toByteArray(t);return new TextDecoder().decode(e)});c(this,"changeIsRememberPin",t=>l(this,null,function*(){this.isRememberPin=t}));c(this,"changePinPolicy",t=>l(this,null,function*(){this.pinPolicy=t}));c(this,"checkCertIsLogin",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",t)}));c(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_StartListen",{Type:Et}).then(t=>{var e,s;(s=(e=this.socketConfig)==null?void 0:e.onUkeyEvent)==null||s.call(e,t)})}));c(this,"certLogin",t=>l(this,null,function*(){const e=yield this.checkCertIsLogin({ContainerName:t});e!=null&&e[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:t,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));c(this,"getCert",(t,e)=>l(this,null,function*(){const s=e!=null?e:yield this.chooseCert(t);return yield this.certLogin(s.ContainerName),s}));c(this,"getCertList",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",t)}));c(this,"chooseCert",t=>l(this,null,function*(){const e=yield this.getCertList(t);return(e==null?void 0:e.length)===1?e[0]:yield ie.open({certList:e})}));c(this,"pkcs1Sign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",B(b({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1Base64Sign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",B(b({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1VerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",t)}));c(this,"pkcs1Base64VerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",t)}));c(this,"getSealList",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",B(b({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm2SignPreprocess1",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",t)}));c(this,"sm2SignPreprocess2",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",t)}));c(this,"pkcs1HashSign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",B(b({},t!=null?t:{}),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1HashVerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",t)}));c(this,"pkcs7Sign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",B(b({},t),{IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy}))}));c(this,"pkcs7VerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",t)}));c(this,"sm3Hash",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",t)}));c(this,"sm3HexHash",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",t)}));c(this,"sm3FileHash",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",t)}));c(this,"sm3HashEncryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",t)}));c(this,"pkcs7Encryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",t)}));c(this,"pkcs7Decryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",B(b({},t),{IsLogin:this.getIsLogin()}))}));c(this,"asymmetricEncryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",t)}));c(this,"asymmetricDecryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",B(b({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm4Encryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",t)}));c(this,"sm4Decryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",t)}));c(this,"getCertInfo",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",t)}));c(this,"getCertInfoByOid",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",t)}));var e,s;this.socketConfig=t,this.socketInstance=this.createSocket(t),this.isRememberPin=(e=t.isRememberPin)!=null?e:!1,this.pinPolicy=(s=t.pinPolicy)!=null?s:ut.MIN}createSocket(t){const e=new WebSocket(t.url);return e.onerror=s=>{var a;(a=t.onError)==null||a.call(t,s)},e.onopen=s=>{var a;(a=t.onOpen)==null||a.call(t,s),this.addUkeyEvents()},e.onmessage=s=>{this.handleEventData(s)},e.onclose=s=>{var a;(a=t.onClose)==null||a.call(t,s)},e}getIsLogin(){return this.isRememberPin?"Y":"N"}}const M=class M{constructor(t){c(this,"coreInstance",null);c(this,"gwsConfig",{});c(this,"createGwsCore",t=>{this.gwsConfig=t!=null?t:{},this.coreInstance=new le(B(b({},t!=null?t:{}),{url:St}))});c(this,"appendCertBase64",(t,e=!0)=>l(this,null,function*(){if(t.CertB64)return t;const s=e?yield this.getSignatureCert():yield this.getEncryptionCert();return B(b({},t!=null?t:{}),{CertB64:s==null?void 0:s.CertB64})}));c(this,"destroy",()=>{var t;(t=this.coreInstance)==null||t.destroy(),this.coreInstance=null});c(this,"restart",t=>{this.coreInstance&&this.destroy(),this.gwsConfig=t!=null?t:this.gwsConfig,this.createGwsCore(t)});c(this,"getSocketReadyState",()=>{var t;return(t=this.coreInstance)==null?void 0:t.getSocketReadyState()});c(this,"getSignatureCert",t=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:$t},t)}));c(this,"getEncryptionCert",t=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:It},t)}));c(this,"base64Encode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Encode(t.Data)});c(this,"base64Decode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Decode(t.DataB64)});c(this,"changeIsRememberPin",t=>{var e;(e=this.coreInstance)==null||e.changeIsRememberPin(t)});c(this,"changePinPolicy",t=>{var e;(e=this.coreInstance)==null||e.changePinPolicy(t)});c(this,"pkcs1Sign",(t,e)=>l(this,null,function*(){var r,o,i;const s=yield this.getSignatureCert(e),a=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(B(b({},t!=null?t:{}),{ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:""}));return(i=a==null?void 0:a[0])==null?void 0:i.SignData}));c(this,"pkcs1VerifySignature",t=>l(this,null,function*(){var a;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.pkcs1VerifySignature(e);return Array.isArray(s)}));c(this,"pkcs1Base64Sign",(t,e)=>l(this,null,function*(){var o,i,u,h,g;const s=yield this.getSignatureCert(e),a=(i=t.DataB64)!=null?i:this.base64Encode({Data:(o=t.Data)!=null?o:""}),r=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign({ContainerName:(u=s==null?void 0:s.ContainerName)!=null?u:"",DataB64:a});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs1Base64VerifySignature",t=>l(this,null,function*(){var r,o,i;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t);return!!(yield(i=this.coreInstance)==null?void 0:i.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:e,SignData:s.SignData}))}));c(this,"getSealList",()=>l(this,null,function*(){var s,a;const t=yield this.getSignatureCert(),e=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:""});return{cert:t,sealList:e}}));c(this,"sm2SignPreprocess1",t=>l(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess1(e);return(r=s==null?void 0:s[0])==null?void 0:r.Z}));c(this,"sm2SignPreprocess2",t=>l(this,null,function*(){var r,o;const e=this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t),a=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:e});return a==null?void 0:a[0].H}));c(this,"pkcs1HashSign",(t,e)=>l(this,null,function*(){var r,o,i,u;const s=yield this.getSignatureCert(e),a=yield(i=this.coreInstance)==null?void 0:i.pkcs1HashSign({ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:"",DataB64:t.DataB64,HashAlg:(o=t.HashAlg)!=null?o:"sm3"});return(u=a==null?void 0:a[0])==null?void 0:u.SignData}));c(this,"pkcs1HashVerifySignature",t=>l(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t);return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs1HashVerifySignature(B(b({},e),{HashAlg:(a=e.HashAlg)!=null?a:"sm3"})))}));c(this,"pkcs7Sign",(t,e)=>l(this,null,function*(){var o,i,u,h,g;const s=(i=t.DataB64)!=null?i:this.base64Encode({Data:(o=t.Data)!=null?o:""}),a=yield this.getSignatureCert(e),r=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign({IsDetached:t.IsDetached,ContainerName:(u=a==null?void 0:a.ContainerName)!=null?u:"",DataB64:s});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs7VerifySignature",t=>l(this,null,function*(){var a,r,o;const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:e,SignData:t.SignData}))}));c(this,"sm3Hash",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HexHash",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3FileHash",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HashEncryption",t=>l(this,null,function*(){var r,o,i,u,h,g;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=(u=t.KeyB64)!=null?u:this.base64Encode({Data:(i=t.Key)!=null?i:""}),a=yield(h=this.coreInstance)==null?void 0:h.sm3HashEncryption({dataB64:e,keyB64:s,alg:"sm3"});return(g=a==null?void 0:a[0])==null?void 0:g.DataB64}));c(this,"pkcs7Encryption",t=>l(this,null,function*(){var a,r,o,i;if(!t.CertB64List){const u=yield this.getEncryptionCert();t.CertB64List=u==null?void 0:u.CertB64}const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:e,CertB64List:t.CertB64List});return(i=s==null?void 0:s[0])==null?void 0:i.DataB64}));c(this,"pkcs7Decryption",t=>l(this,null,function*(){var r,o;const e=yield this.getEncryptionCert(),s=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption({DataB64:t.DataB64,ContainerName:e==null?void 0:e.ContainerName}),a=(o=s==null?void 0:s[0])==null?void 0:o.DataB64;return t.shouldDecodeBase64?this.base64Decode({DataB64:a}):a}));c(this,"asymmetricEncryption",t=>l(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t,!1),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricEncryption(e);return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"asymmetricDecryption",t=>l(this,null,function*(){var a,r;const e=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption({Data:t.Data,ContainerName:e==null?void 0:e.ContainerName});return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"sm4Encryption",t=>l(this,null,function*(){var s;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(t);return e==null?void 0:e[0]}));c(this,"sm4Decryption",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(t);return(a=e==null?void 0:e[0])==null?void 0:a.Data}));c(this,"getCertInfo",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(t);return b({},(a=e==null?void 0:e[0])!=null?a:{})}));c(this,"getCertInfoByOid",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid(b({},t!=null?t:{}));return(a=e==null?void 0:e[0])==null?void 0:a.OidValue}));return M.instance&&!(t!=null&&t.isCreateNew)?M.instance:(this.createGwsCore(t),M.instance=this,this)}};c(M,"instance",null);let G=M;function de(n){return new Promise((t,e)=>{if(G.instance)t(G.instance);else{const s=new G(B(b({},n!=null?n:{}),{onOpen(a){var r;t(s),(r=n==null?void 0:n.onOpen)==null||r.call(n,a)},onClose(a){var r;e(a),(r=n==null?void 0:n.onClose)==null||r.call(n,a)}}))}})}exports.GwsService=G;exports.createService=de;
1
+ "use strict";var kt=Object.defineProperty,xt=Object.defineProperties;var Dt=Object.getOwnPropertyDescriptors;var tt=Object.getOwnPropertySymbols;var bt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var U=(n,t,e)=>t in n?kt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,b=(n,t)=>{for(var e in t||(t={}))bt.call(t,e)&&U(n,e,t[e]);if(tt)for(var e of tt(t))Bt.call(t,e)&&U(n,e,t[e]);return n},B=(n,t)=>xt(n,Dt(t));var c=(n,t,e)=>U(n,typeof t!="symbol"?t+"":t,e);var l=(n,t,e)=>new Promise((s,a)=>{var r=u=>{try{i(e.next(u))}catch(h){a(h)}},o=u=>{try{i(e.throw(u))}catch(h){a(h)}},i=u=>u.done?s(u.value):Promise.resolve(u.value).then(r,o);i((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",$t="1",It="2";var ut=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(ut||{});const Et="00000001";function At(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var F={},et;function _t(){if(et)return F;et=1,F.byteLength=i,F.toByteArray=h,F.fromByteArray=D;for(var n=[],t=[],e=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,r=s.length;a<r;++a)n[a]=s[a],t[s.charCodeAt(a)]=a;t[45]=62,t[95]=63;function o(d){var p=d.length;if(p%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=d.indexOf("=");f===-1&&(f=p);var v=f===p?0:4-f%4;return[f,v]}function i(d){var p=o(d),f=p[0],v=p[1];return(f+v)*3/4-v}function u(d,p,f){return(p+f)*3/4-f}function h(d){var p,f=o(d),v=f[0],w=f[1],m=new e(u(d,v,w)),k=0,A=w>0?v-4:v,C;for(C=0;C<A;C+=4)p=t[d.charCodeAt(C)]<<18|t[d.charCodeAt(C+1)]<<12|t[d.charCodeAt(C+2)]<<6|t[d.charCodeAt(C+3)],m[k++]=p>>16&255,m[k++]=p>>8&255,m[k++]=p&255;return w===2&&(p=t[d.charCodeAt(C)]<<2|t[d.charCodeAt(C+1)]>>4,m[k++]=p&255),w===1&&(p=t[d.charCodeAt(C)]<<10|t[d.charCodeAt(C+1)]<<4|t[d.charCodeAt(C+2)]>>2,m[k++]=p>>8&255,m[k++]=p&255),m}function g(d){return n[d>>18&63]+n[d>>12&63]+n[d>>6&63]+n[d&63]}function y(d,p,f){for(var v,w=[],m=p;m<f;m+=3)v=(d[m]<<16&16711680)+(d[m+1]<<8&65280)+(d[m+2]&255),w.push(g(v));return w.join("")}function D(d){for(var p,f=d.length,v=f%3,w=[],m=16383,k=0,A=f-v;k<A;k+=m)w.push(y(d,k,k+m>A?A:k+m));return v===1?(p=d[f-1],w.push(n[p>>2]+n[p<<4&63]+"==")):v===2&&(p=(d[f-2]<<8)+d[f-1],w.push(n[p>>10]+n[p>>4&63]+n[p<<2&63]+"=")),w.join("")}return F}var Lt=_t();const nt=At(Lt);class Pt{constructor(){c(this,"deps",new Map)}on(t,e){this.deps.set(t,e)}emit(t,e){const s=this.deps.get(t);s&&s(e)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-n1zwga{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-n1zwga{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-n1zwga{background-color:#fff;padding:20px;border-radius:5px;width:40%}.model-title.svelte-n1zwga{color:#303133;font-size:18px;margin-bottom:16px}.modal-visible.svelte-n1zwga{display:flex}.modal-footer.svelte-n1zwga{display:flex;align-items:center;justify-content:flex-end;margin-top:16px}.modal-btn.svelte-n1zwga{padding:8px 15px;border-radius:4px;font-size:14px;border:1px solid #dcdfe6}.success.svelte-n1zwga{background-color:#409eff;margin-left:12px;color:#fff}.slot.svelte-n1zwga{max-height:200px;overflow-y:scroll}.slot.svelte-n1zwga::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:16px;display:flex;align-items:center;cursor:pointer;border-bottom:1px solid #ebeef5;font-size:14px}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:1px 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:180px;height:180px;display:flex;flex-direction:column;align-items:center;justify-content:center;border:1px solid #ccc;margin-top:10px;margin-right:10px;border-radius:4px}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:100px;height:100px}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:10px;color:#333}")),document.head.appendChild(n)}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var Mt=Object.defineProperty,Tt=(n,t,e)=>t in n?Mt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,st=(n,t,e)=>Tt(n,typeof t!="symbol"?t+"":t,e);function q(){}function Ht(n,t){for(const e in t)n[e]=t[e];return n}function ht(n){return n()}function at(){return Object.create(null)}function z(n){n.forEach(ht)}function O(n){return typeof n=="function"}function yt(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function Gt(n){return Object.keys(n).length===0}function Ft(n,t,e,s){if(n){const a=pt(n,t,e,s);return n[0](a)}}function pt(n,t,e,s){return n[1]&&s?Ht(e.ctx.slice(),n[1](s(t))):e.ctx}function jt(n,t,e,s){if(n[2]&&s){const a=n[2](s(e));if(t.dirty===void 0)return a;if(typeof a=="object"){const r=[],o=Math.max(t.dirty.length,a.length);for(let i=0;i<o;i+=1)r[i]=t.dirty[i]|a[i];return r}return t.dirty|a}return t.dirty}function Ot(n,t,e,s,a,r){if(a){const o=pt(t,e,s,r);n.p(o,a)}}function Nt(n){if(n.ctx.length>32){const t=[],e=n.ctx.length/32;for(let s=0;s<e;s++)t[s]=-1;return t}return-1}function rt(n){return n!=null?n:""}function x(n,t){n.appendChild(t)}function Q(n,t,e){n.insertBefore(t,e||null)}function R(n){n.parentNode&&n.parentNode.removeChild(n)}function Zt(n,t){for(let e=0;e<n.length;e+=1)n[e]&&n[e].d(t)}function I(n){return document.createElement(n)}function E(n){return document.createTextNode(n)}function N(){return E(" ")}function zt(){return E("")}function j(n,t,e,s){return n.addEventListener(t,e,s),()=>n.removeEventListener(t,e,s)}function S(n,t,e){e==null?n.removeAttribute(t):n.getAttribute(t)!==e&&n.setAttribute(t,e)}function Vt(n){return Array.from(n.childNodes)}function T(n,t){t=""+t,n.data!==t&&(n.data=t)}let X;function Z(n){X=n}const P=[],ot=[];let H=[];const ct=[],Rt=Promise.resolve();let K=!1;function Ut(){K||(K=!0,Rt.then(gt))}function W(n){H.push(n)}const J=new Set;let L=0;function gt(){if(L!==0)return;const n=X;do{try{for(;L<P.length;){const t=P[L];L++,Z(t),Jt(t.$$)}}catch(t){throw P.length=0,L=0,t}for(Z(null),P.length=0,L=0;ot.length;)ot.pop()();for(let t=0;t<H.length;t+=1){const e=H[t];J.has(e)||(J.add(e),e())}H.length=0}while(P.length);for(;ct.length;)ct.pop()();K=!1,J.clear(),Z(n)}function Jt(n){if(n.fragment!==null){n.update(),z(n.before_update);const t=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,t),n.after_update.forEach(W)}}function qt(n){const t=[],e=[];H.forEach(s=>n.indexOf(s)===-1?t.push(s):e.push(s)),e.forEach(s=>s()),H=t}const V=new Set;let Kt;function Y(n,t){n&&n.i&&(V.delete(n),n.i(t))}function ft(n,t,e,s){if(n&&n.o){if(V.has(n))return;V.add(n),Kt.c.push(()=>{V.delete(n)}),n.o(t)}}function it(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Wt(n){n&&n.c()}function mt(n,t,e){const{fragment:s,after_update:a}=n.$$;s&&s.m(t,e),W(()=>{const r=n.$$.on_mount.map(ht).filter(O);n.$$.on_destroy?n.$$.on_destroy.push(...r):z(r),n.$$.on_mount=[]}),a.forEach(W)}function wt(n,t){const e=n.$$;e.fragment!==null&&(qt(e.after_update),z(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Qt(n,t){n.$$.dirty[0]===-1&&(P.push(n),Ut(),n.$$.dirty.fill(0)),n.$$.dirty[t/31|0]|=1<<t%31}function Ct(n,t,e,s,a,r,o=null,i=[-1]){const u=X;Z(n);const h=n.$$={fragment:null,ctx:[],props:r,update:q,not_equal:a,bound:at(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(u?u.$$.context:[])),callbacks:at(),dirty:i,skip_bound:!1,root:t.target||u.$$.root};o&&o(h.root);let g=!1;if(h.ctx=e?e(n,t.props||{},(y,D,...d)=>{const p=d.length?d[0]:D;return h.ctx&&a(h.ctx[y],h.ctx[y]=p)&&(!h.skip_bound&&h.bound[y]&&h.bound[y](p),g&&Qt(n,y)),D}):[],h.update(),g=!0,z(h.before_update),h.fragment=s?s(h.ctx):!1,t.target){if(t.hydrate){const y=Vt(t.target);h.fragment&&h.fragment.l(y),y.forEach(R)}else h.fragment&&h.fragment.c();t.intro&&Y(n.$$.fragment),mt(n,t.target,t.anchor),gt()}Z(u)}class vt{constructor(){st(this,"$$"),st(this,"$$set")}$destroy(){wt(this,1),this.$destroy=q}$on(t,e){if(!O(e))return q;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(e),()=>{const a=s.indexOf(e);a!==-1&&s.splice(a,1)}}$set(t){this.$$set&&!Gt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Xt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Xt);function Yt(n){let t,e,s,a=(n[1]||"标题")+"",r,o,i,u,h,g,y=(n[4]||"取消")+"",D,d,p,f=(n[5]||"确认")+"",v,w,m,k;const A=n[7].default,C=Ft(A,n,n[6],null);return{c(){t=I("div"),e=I("div"),s=I("div"),r=E(a),o=N(),i=I("div"),C&&C.c(),u=N(),h=I("div"),g=I("button"),D=E(y),d=N(),p=I("button"),v=E(f),S(s,"class","model-title svelte-n1zwga"),S(i,"class","slot svelte-n1zwga"),S(g,"class","modal-btn svelte-n1zwga"),S(p,"class","modal-btn success svelte-n1zwga"),S(h,"class","modal-footer svelte-n1zwga"),S(e,"class","modal-content svelte-n1zwga"),S(t,"class","modal-background modal-visible svelte-n1zwga")},m($,_){Q($,t,_),x(t,e),x(e,s),x(s,r),x(e,o),x(e,i),C&&C.m(i,null),x(e,u),x(e,h),x(h,g),x(g,D),x(h,d),x(h,p),x(p,v),w=!0,m||(k=[j(g,"click",function(){O(n[0])&&n[0].apply(this,arguments)}),j(p,"click",function(){O(n[2])&&n[2].apply(this,arguments)}),j(e,"click",te),j(t,"click",function(){O(n[3])&&n[3].apply(this,arguments)})],m=!0)},p($,[_]){n=$,(!w||_&2)&&a!==(a=(n[1]||"标题")+"")&&T(r,a),C&&C.p&&(!w||_&64)&&Ot(C,A,n,n[6],w?jt(A,n[6],_,null):Nt(n[6]),null),(!w||_&16)&&y!==(y=(n[4]||"取消")+"")&&T(D,y),(!w||_&32)&&f!==(f=(n[5]||"确认")+"")&&T(v,f)},i($){w||(Y(C,$),w=!0)},o($){ft(C,$),w=!1},d($){$&&R(t),C&&C.d($),m=!1,z(k)}}}const te=n=>n.stopPropagation();function ee(n,t,e){let{$$slots:s={},$$scope:a}=t,{onCancel:r}=t,{title:o}=t,{onOk:i}=t,{onClose:u}=t,{cancelText:h}=t,{okText:g}=t;return n.$$set=y=>{"onCancel"in y&&e(0,r=y.onCancel),"title"in y&&e(1,o=y.title),"onOk"in y&&e(2,i=y.onOk),"onClose"in y&&e(3,u=y.onClose),"cancelText"in y&&e(4,h=y.cancelText),"okText"in y&&e(5,g=y.okText),"$$scope"in y&&e(6,a=y.$$scope)},[r,o,i,u,h,g,a,s]}class ne extends vt{constructor(t){super(),Ct(this,t,ee,Yt,yt,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5})}}function lt(n,t,e){const s=n.slice();return s[10]=t[e],s[12]=e,s}function dt(n){let t,e,s=n[10].CN+"",a,r,o,i=n[10].DevClass+"",u,h,g=n[10].sn+"",y,D,d,p,f,v;function w(){return n[9](n[12])}return{c(){t=I("div"),e=I("span"),a=E(s),r=N(),o=I("span"),u=E(i),h=E("("),y=E(g),D=E(")"),d=N(),S(e,"class","svelte-jtc2v4"),S(o,"class","svelte-jtc2v4"),S(t,"class",p=rt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(m,k){Q(m,t,k),x(t,e),x(e,a),x(t,r),x(t,o),x(o,u),x(o,h),x(o,y),x(o,D),x(t,d),f||(v=j(t,"click",w),f=!0)},p(m,k){n=m,k&1&&s!==(s=n[10].CN+"")&&T(a,s),k&1&&i!==(i=n[10].DevClass+"")&&T(u,i),k&1&&g!==(g=n[10].sn+"")&&T(y,g),k&16&&p!==(p=rt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&S(t,"class",p)},d(m){m&&R(t),f=!1,v()}}}function se(n){let t,e=it(n[0]),s=[];for(let a=0;a<e.length;a+=1)s[a]=dt(lt(n,e,a));return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=zt()},m(a,r){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(a,r);Q(a,t,r)},p(a,r){if(r&17){e=it(a[0]);let o;for(o=0;o<e.length;o+=1){const i=lt(a,e,o);s[o]?s[o].p(i,r):(s[o]=dt(i),s[o].c(),s[o].m(t.parentNode,t))}for(;o<s.length;o+=1)s[o].d(1);s.length=e.length}},d(a){a&&R(t),Zt(s,a)}}}function ae(n){let t,e;return t=new ne({props:{onOk:n[6],onClose:n[1],onCancel:n[5],cancelText:n[2],okText:n[3],title:"选择证书",$$slots:{default:[se]},$$scope:{ctx:n}}}),{c(){Wt(t.$$.fragment)},m(s,a){mt(t,s,a),e=!0},p(s,[a]){const r={};a&2&&(r.onClose=s[1]),a&4&&(r.cancelText=s[2]),a&8&&(r.okText=s[3]),a&8209&&(r.$$scope={dirty:a,ctx:s}),t.$set(r)},i(s){e||(Y(t.$$.fragment,s),e=!0)},o(s){ft(t.$$.fragment,s),e=!1},d(s){wt(t,s)}}}function re(n,t,e){let{certList:s=[]}=t,{onCancel:a}=t,{onOk:r}=t,{onClose:o}=t,{cancelText:i=""}=t,{okText:u=""}=t,h=0;const g=()=>{o==null||o()},y=()=>{r==null||r(s[h]),o==null||o()},D=d=>e(4,h=d);return n.$$set=d=>{"certList"in d&&e(0,s=d.certList),"onCancel"in d&&e(7,a=d.onCancel),"onOk"in d&&e(8,r=d.onOk),"onClose"in d&&e(1,o=d.onClose),"cancelText"in d&&e(2,i=d.cancelText),"okText"in d&&e(3,u=d.okText)},[s,o,i,u,h,g,y,a,r,D]}class oe extends vt{constructor(t){super(),Ct(this,t,re,ae,yt,{certList:0,onCancel:7,onOk:8,onClose:1,cancelText:2,okText:3})}}class ce{constructor(){c(this,"modalInstance",{current:null});c(this,"open",t=>new Promise((e,s)=>{this.modalInstance.current=new oe({target:document.body,props:B(b({},t),{onCancel:a=>{s()},onOk:a=>{e(a)},onClose:()=>{this.close()}})})}));c(this,"close",()=>{setTimeout(()=>{var t;(t=this.modalInstance.current)==null||t.$destroy()})})}}const ie=new ce;class le{constructor(t){c(this,"socketInstance",null);c(this,"eventBus",new Pt);c(this,"isRememberPin",!1);c(this,"socketEvent");c(this,"pinPolicy");c(this,"socketConfig",null);c(this,"getSocketReadyState",()=>{var t;return(t=this.socketInstance)==null?void 0:t.readyState});c(this,"destroy",()=>{var t;(t=this.socketInstance)==null||t.close()});c(this,"sendMessage",(t,e)=>new Promise((s,a)=>{var o,i;if(((o=this.socketInstance)==null?void 0:o.readyState)!==WebSocket.OPEN){console.log(t),a({errCode:-1,msg:"socket未连接"});return}const r={function:t,args:[e!=null?e:{}]};(i=this.socketInstance)==null||i.send(JSON.stringify(r)),this.eventBus.on(t,u=>{u.success?s(u.data):a(u)})}));c(this,"handleEventData",t=>l(this,null,function*(){var e,s,a,r,o,i;if(t.data instanceof Blob){const u=yield t.data.arrayBuffer(),g=new TextDecoder("gbk").decode(u),y=JSON.parse(g),D={data:y.data,success:(e=y.result)==null?void 0:e.success,msg:(s=y.result)==null?void 0:s.msg,errCode:(a=y.result)==null?void 0:a.errCode};this.eventBus.emit((r=y.result)==null?void 0:r.function,D),(i=(o=this.socketConfig)==null?void 0:o.onMessage)==null||i.call(o,D)}}));c(this,"base64Encode",t=>{const e=new TextEncoder().encode(t);return nt.fromByteArray(e)});c(this,"base64Decode",t=>{const e=nt.toByteArray(t);return new TextDecoder().decode(e)});c(this,"changeIsRememberPin",t=>l(this,null,function*(){this.isRememberPin=t}));c(this,"changePinPolicy",t=>l(this,null,function*(){this.pinPolicy=t}));c(this,"checkCertIsLogin",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",t)}));c(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_StartListen",{Type:Et}).then(t=>{var e,s;(s=(e=this.socketConfig)==null?void 0:e.onUkeyEvent)==null||s.call(e,t)})}));c(this,"certLogin",t=>l(this,null,function*(){const e=yield this.checkCertIsLogin({ContainerName:t});e!=null&&e[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:t,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));c(this,"getCert",(t,e)=>l(this,null,function*(){const s=e!=null?e:yield this.chooseCert(t);return yield this.certLogin(s.ContainerName),s}));c(this,"getCertList",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",t)}));c(this,"chooseCert",t=>l(this,null,function*(){const e=yield this.getCertList(t);return(e==null?void 0:e.length)===1?e[0]:yield ie.open({certList:e})}));c(this,"pkcs1Sign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",B(b({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1Base64Sign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",B(b({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1VerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",t)}));c(this,"pkcs1Base64VerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",t)}));c(this,"getSealList",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",B(b({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm2SignPreprocess1",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",t)}));c(this,"sm2SignPreprocess2",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",t)}));c(this,"pkcs1HashSign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",B(b({},t!=null?t:{}),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1HashVerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",t)}));c(this,"pkcs7Sign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",B(b({},t),{IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy}))}));c(this,"pkcs7VerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",t)}));c(this,"sm3Hash",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",t)}));c(this,"sm3HexHash",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",t)}));c(this,"sm3FileHash",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",t)}));c(this,"sm3HashEncryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",t)}));c(this,"pkcs7Encryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",t)}));c(this,"pkcs7Decryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",B(b({},t),{IsLogin:this.getIsLogin()}))}));c(this,"asymmetricEncryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",t)}));c(this,"asymmetricDecryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",B(b({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm4Encryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",t)}));c(this,"sm4Decryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",t)}));c(this,"getCertInfo",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",t)}));c(this,"getCertInfoByOid",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",t)}));var e,s;this.socketConfig=t,this.socketInstance=this.createSocket(t),this.isRememberPin=(e=t.isRememberPin)!=null?e:!1,this.pinPolicy=(s=t.pinPolicy)!=null?s:ut.MIN}createSocket(t){const e=new WebSocket(t.url);return e.onerror=s=>{var a;(a=t.onError)==null||a.call(t,s)},e.onopen=s=>{var a;(a=t.onOpen)==null||a.call(t,s),this.addUkeyEvents()},e.onmessage=s=>{this.handleEventData(s)},e.onclose=s=>{var a;(a=t.onClose)==null||a.call(t,s)},e}getIsLogin(){return this.isRememberPin?"Y":"N"}}const M=class M{constructor(t){c(this,"coreInstance",null);c(this,"gwsConfig",{});c(this,"createGwsCore",t=>{this.gwsConfig=t!=null?t:{},this.coreInstance=new le(B(b({},t!=null?t:{}),{url:St}))});c(this,"appendCertBase64",(t,e=!0)=>l(this,null,function*(){if(t.CertB64)return t;const s=e?yield this.getSignatureCert():yield this.getEncryptionCert();return B(b({},t!=null?t:{}),{CertB64:s==null?void 0:s.CertB64})}));c(this,"destroy",()=>{var t;(t=this.coreInstance)==null||t.destroy(),this.coreInstance=null});c(this,"restart",t=>{this.coreInstance&&this.destroy(),this.gwsConfig=t!=null?t:this.gwsConfig,this.createGwsCore(t)});c(this,"getSocketReadyState",()=>{var t;return(t=this.coreInstance)==null?void 0:t.getSocketReadyState()});c(this,"getSignatureCert",t=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:$t},t)}));c(this,"getEncryptionCert",t=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:It},t)}));c(this,"base64Encode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Encode(t.Data)});c(this,"base64Decode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Decode(t.DataB64)});c(this,"changeIsRememberPin",t=>{var e;(e=this.coreInstance)==null||e.changeIsRememberPin(t)});c(this,"changePinPolicy",t=>{var e;(e=this.coreInstance)==null||e.changePinPolicy(t)});c(this,"pkcs1Sign",(t,e)=>l(this,null,function*(){var r,o,i;const s=yield this.getSignatureCert(e),a=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(B(b({},t!=null?t:{}),{ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:""}));return(i=a==null?void 0:a[0])==null?void 0:i.SignData}));c(this,"pkcs1VerifySignature",t=>l(this,null,function*(){var a;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.pkcs1VerifySignature(e);return Array.isArray(s)}));c(this,"pkcs1Base64Sign",(t,e)=>l(this,null,function*(){var o,i,u,h,g;const s=yield this.getSignatureCert(e),a=(i=t.DataB64)!=null?i:this.base64Encode({Data:(o=t.Data)!=null?o:""}),r=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign({ContainerName:(u=s==null?void 0:s.ContainerName)!=null?u:"",DataB64:a});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs1Base64VerifySignature",t=>l(this,null,function*(){var r,o,i;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t);return!!(yield(i=this.coreInstance)==null?void 0:i.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:e,SignData:s.SignData}))}));c(this,"getSealList",()=>l(this,null,function*(){var s,a;const t=yield this.getSignatureCert(),e=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:""});return{cert:t,sealList:e}}));c(this,"sm2SignPreprocess1",t=>l(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess1(e);return(r=s==null?void 0:s[0])==null?void 0:r.Z}));c(this,"sm2SignPreprocess2",t=>l(this,null,function*(){var r,o;const e=this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t),a=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:e});return a==null?void 0:a[0].H}));c(this,"pkcs1HashSign",(t,e)=>l(this,null,function*(){var r,o,i,u;const s=yield this.getSignatureCert(e),a=yield(i=this.coreInstance)==null?void 0:i.pkcs1HashSign({ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:"",DataB64:t.DataB64,HashAlg:(o=t.HashAlg)!=null?o:"sm3"});return(u=a==null?void 0:a[0])==null?void 0:u.SignData}));c(this,"pkcs1HashVerifySignature",t=>l(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t);return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs1HashVerifySignature(B(b({},e),{HashAlg:(a=e.HashAlg)!=null?a:"sm3"})))}));c(this,"pkcs7Sign",(t,e)=>l(this,null,function*(){var o,i,u,h,g;const s=(i=t.DataB64)!=null?i:this.base64Encode({Data:(o=t.Data)!=null?o:""}),a=yield this.getSignatureCert(e),r=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign({IsDetached:t.IsDetached,ContainerName:(u=a==null?void 0:a.ContainerName)!=null?u:"",DataB64:s});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs7VerifySignature",t=>l(this,null,function*(){var a,r,o;const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:e,SignData:t.SignData}))}));c(this,"sm3Hash",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HexHash",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3FileHash",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HashEncryption",t=>l(this,null,function*(){var r,o,i,u,h,g;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=(u=t.KeyB64)!=null?u:this.base64Encode({Data:(i=t.Key)!=null?i:""}),a=yield(h=this.coreInstance)==null?void 0:h.sm3HashEncryption({dataB64:e,keyB64:s,alg:"sm3"});return(g=a==null?void 0:a[0])==null?void 0:g.DataB64}));c(this,"pkcs7Encryption",t=>l(this,null,function*(){var a,r,o,i;if(!t.CertB64List){const u=yield this.getEncryptionCert();t.CertB64List=u==null?void 0:u.CertB64}const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:e,CertB64List:t.CertB64List});return(i=s==null?void 0:s[0])==null?void 0:i.DataB64}));c(this,"pkcs7Decryption",t=>l(this,null,function*(){var r,o;const e=yield this.getEncryptionCert(),s=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption({DataB64:t.DataB64,ContainerName:e==null?void 0:e.ContainerName}),a=(o=s==null?void 0:s[0])==null?void 0:o.DataB64;return t.shouldDecodeBase64?this.base64Decode({DataB64:a}):a}));c(this,"asymmetricEncryption",t=>l(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t,!1),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricEncryption(e);return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"asymmetricDecryption",t=>l(this,null,function*(){var a,r;const e=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption({Data:t.Data,ContainerName:e==null?void 0:e.ContainerName});return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"sm4Encryption",t=>l(this,null,function*(){var s;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(t);return e==null?void 0:e[0]}));c(this,"sm4Decryption",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(t);return(a=e==null?void 0:e[0])==null?void 0:a.Data}));c(this,"getCertInfo",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(t);return b({},(a=e==null?void 0:e[0])!=null?a:{})}));c(this,"getCertInfoByOid",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid(b({},t!=null?t:{}));return(a=e==null?void 0:e[0])==null?void 0:a.OidValue}));return M.instance&&!(t!=null&&t.isCreateNew)?M.instance:(this.createGwsCore(t),M.instance=this,this)}};c(M,"instance",null);let G=M;function de(n){return new Promise((t,e)=>{if(G.instance&&!(n!=null&&n.isCreateNew))t(G.instance);else{const s=new G(B(b({},n!=null?n:{}),{onOpen(a){var r;t(s),(r=n==null?void 0:n.onOpen)==null||r.call(n,a)},onClose(a){var r;e(a),(r=n==null?void 0:n.onClose)==null||r.call(n,a)}}))}})}exports.GwsService=G;exports.createService=de;
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ declare type CertType = {
9
9
  [key: string]: unknown;
10
10
  };
11
11
 
12
- export declare function createService(config?: ServiceConfigType): Promise<unknown>;
12
+ export declare function createService(config?: ServiceConfigType): Promise<GwsService>;
13
13
 
14
14
  export declare class GwsService {
15
15
  static instance: GwsService | null;
package/dist/index.es.js CHANGED
@@ -161,7 +161,7 @@ function Ot(n, t, e, s, a, r) {
161
161
  n.p(o, a);
162
162
  }
163
163
  }
164
- function Zt(n) {
164
+ function Nt(n) {
165
165
  if (n.ctx.length > 32) {
166
166
  const t = [], e = n.ctx.length / 32;
167
167
  for (let s = 0; s < e; s++)
@@ -182,7 +182,7 @@ function Q(n, t, e) {
182
182
  function R(n) {
183
183
  n.parentNode && n.parentNode.removeChild(n);
184
184
  }
185
- function Nt(n, t) {
185
+ function Zt(n, t) {
186
186
  for (let e = 0; e < n.length; e += 1)
187
187
  n[e] && n[e].d(t);
188
188
  }
@@ -212,7 +212,7 @@ function M(n, t) {
212
212
  t);
213
213
  }
214
214
  let X;
215
- function Z(n) {
215
+ function N(n) {
216
216
  X = n;
217
217
  }
218
218
  const P = [], ot = [];
@@ -235,12 +235,12 @@ function gt() {
235
235
  try {
236
236
  for (; L < P.length; ) {
237
237
  const t = P[L];
238
- L++, Z(t), Jt(t.$$);
238
+ L++, N(t), Jt(t.$$);
239
239
  }
240
240
  } catch (t) {
241
241
  throw P.length = 0, L = 0, t;
242
242
  }
243
- for (Z(null), P.length = 0, L = 0; ot.length; ) ot.pop()();
243
+ for (N(null), P.length = 0, L = 0; ot.length; ) ot.pop()();
244
244
  for (let t = 0; t < T.length; t += 1) {
245
245
  const e = T[t];
246
246
  J.has(e) || (J.add(e), e());
@@ -249,7 +249,7 @@ function gt() {
249
249
  } while (P.length);
250
250
  for (; ct.length; )
251
251
  ct.pop()();
252
- K = !1, J.clear(), Z(n);
252
+ K = !1, J.clear(), N(n);
253
253
  }
254
254
  function Jt(n) {
255
255
  if (n.fragment !== null) {
@@ -297,7 +297,7 @@ function Qt(n, t) {
297
297
  }
298
298
  function Ct(n, t, e, s, a, r, o = null, i = [-1]) {
299
299
  const u = X;
300
- Z(n);
300
+ N(n);
301
301
  const h = n.$$ = {
302
302
  fragment: null,
303
303
  ctx: [],
@@ -332,7 +332,7 @@ function Ct(n, t, e, s, a, r, o = null, i = [-1]) {
332
332
  h.fragment && h.fragment.c();
333
333
  t.intro && Y(n.$$.fragment), mt(n, t.target, t.anchor), gt();
334
334
  }
335
- Z(u);
335
+ N(u);
336
336
  }
337
337
  class vt {
338
338
  constructor() {
@@ -431,7 +431,7 @@ function Yt(n) {
431
431
  n[6],
432
432
  _,
433
433
  null
434
- ) : Zt(
434
+ ) : Nt(
435
435
  /*$$scope*/
436
436
  n[6]
437
437
  ),
@@ -560,7 +560,7 @@ function se(n) {
560
560
  }
561
561
  },
562
562
  d(a) {
563
- a && R(t), Nt(s, a);
563
+ a && R(t), Zt(s, a);
564
564
  }
565
565
  };
566
566
  }
@@ -1111,13 +1111,13 @@ const H = class H {
1111
1111
  }
1112
1112
  };
1113
1113
  c(H, "instance", null);
1114
- let N = H;
1114
+ let Z = H;
1115
1115
  function ue(n) {
1116
1116
  return new Promise((t, e) => {
1117
- if (N.instance)
1118
- t(N.instance);
1117
+ if (Z.instance && !(n != null && n.isCreateNew))
1118
+ t(Z.instance);
1119
1119
  else {
1120
- const s = new N(b(B({}, n != null ? n : {}), {
1120
+ const s = new Z(b(B({}, n != null ? n : {}), {
1121
1121
  onOpen(a) {
1122
1122
  var r;
1123
1123
  t(s), (r = n == null ? void 0 : n.onOpen) == null || r.call(n, a);
@@ -1131,6 +1131,6 @@ function ue(n) {
1131
1131
  });
1132
1132
  }
1133
1133
  export {
1134
- N as GwsService,
1134
+ Z as GwsService,
1135
1135
  ue as createService
1136
1136
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(D,w){typeof exports=="object"&&typeof module!="undefined"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(D=typeof globalThis!="undefined"?globalThis:D||self,w(D.GWS_CLIENT={}))})(this,function(D){"use strict";var ce=Object.defineProperty,ie=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var $t=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var it=(D,w,B)=>w in D?ce(D,w,{enumerable:!0,configurable:!0,writable:!0,value:B}):D[w]=B,$=(D,w)=>{for(var B in w||(w={}))de.call(w,B)&&it(D,B,w[B]);if($t)for(var B of $t(w))ue.call(w,B)&&it(D,B,w[B]);return D},I=(D,w)=>ie(D,le(w));var c=(D,w,B)=>it(D,typeof w!="symbol"?w+"":w,B);var i=(D,w,B)=>new Promise((X,z)=>{var Y=A=>{try{T(B.next(A))}catch(V){z(V)}},tt=A=>{try{T(B.throw(A))}catch(V){z(V)}},T=A=>A.done?X(A.value):Promise.resolve(A.value).then(Y,tt);T((B=B.apply(D,w)).next())});const w=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",B="1",X="2";var z=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(z||{});const Y="00000001";function tt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var T={},A;function V(){if(A)return T;A=1,T.byteLength=d,T.toByteArray=u,T.fromByteArray=S;for(var n=[],t=[],e=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,r=s.length;a<r;++a)n[a]=s[a],t[s.charCodeAt(a)]=a;t[45]=62,t[95]=63;function o(l){var y=l.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=l.indexOf("=");f===-1&&(f=y);var k=f===y?0:4-f%4;return[f,k]}function d(l){var y=o(l),f=y[0],k=y[1];return(f+k)*3/4-k}function p(l,y,f){return(y+f)*3/4-f}function u(l){var y,f=o(l),k=f[0],C=f[1],m=new e(p(l,k,C)),x=0,M=C>0?k-4:k,v;for(v=0;v<M;v+=4)y=t[l.charCodeAt(v)]<<18|t[l.charCodeAt(v+1)]<<12|t[l.charCodeAt(v+2)]<<6|t[l.charCodeAt(v+3)],m[x++]=y>>16&255,m[x++]=y>>8&255,m[x++]=y&255;return C===2&&(y=t[l.charCodeAt(v)]<<2|t[l.charCodeAt(v+1)]>>4,m[x++]=y&255),C===1&&(y=t[l.charCodeAt(v)]<<10|t[l.charCodeAt(v+1)]<<4|t[l.charCodeAt(v+2)]>>2,m[x++]=y>>8&255,m[x++]=y&255),m}function g(l){return n[l>>18&63]+n[l>>12&63]+n[l>>6&63]+n[l&63]}function h(l,y,f){for(var k,C=[],m=y;m<f;m+=3)k=(l[m]<<16&16711680)+(l[m+1]<<8&65280)+(l[m+2]&255),C.push(g(k));return C.join("")}function S(l){for(var y,f=l.length,k=f%3,C=[],m=16383,x=0,M=f-k;x<M;x+=m)C.push(h(l,x,x+m>M?M:x+m));return k===1?(y=l[f-1],C.push(n[y>>2]+n[y<<4&63]+"==")):k===2&&(y=(l[f-2]<<8)+l[f-1],C.push(n[y>>10]+n[y>>4&63]+n[y<<2&63]+"=")),C.join("")}return T}var It=V();const lt=tt(It);class Et{constructor(){c(this,"deps",new Map)}on(t,e){this.deps.set(t,e)}emit(t,e){const s=this.deps.get(t);s&&s(e)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-n1zwga{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-n1zwga{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-n1zwga{background-color:#fff;padding:20px;border-radius:5px;width:40%}.model-title.svelte-n1zwga{color:#303133;font-size:18px;margin-bottom:16px}.modal-visible.svelte-n1zwga{display:flex}.modal-footer.svelte-n1zwga{display:flex;align-items:center;justify-content:flex-end;margin-top:16px}.modal-btn.svelte-n1zwga{padding:8px 15px;border-radius:4px;font-size:14px;border:1px solid #dcdfe6}.success.svelte-n1zwga{background-color:#409eff;margin-left:12px;color:#fff}.slot.svelte-n1zwga{max-height:200px;overflow-y:scroll}.slot.svelte-n1zwga::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:16px;display:flex;align-items:center;cursor:pointer;border-bottom:1px solid #ebeef5;font-size:14px}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:1px 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:180px;height:180px;display:flex;flex-direction:column;align-items:center;justify-content:center;border:1px solid #ccc;margin-top:10px;margin-right:10px;border-radius:4px}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:100px;height:100px}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:10px;color:#333}")),document.head.appendChild(n)}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var At=Object.defineProperty,_t=(n,t,e)=>t in n?At(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,dt=(n,t,e)=>_t(n,typeof t!="symbol"?t+"":t,e);function et(){}function Lt(n,t){for(const e in t)n[e]=t[e];return n}function ut(n){return n()}function ht(){return Object.create(null)}function R(n){n.forEach(ut)}function U(n){return typeof n=="function"}function yt(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function Pt(n){return Object.keys(n).length===0}function Tt(n,t,e,s){if(n){const a=pt(n,t,e,s);return n[0](a)}}function pt(n,t,e,s){return n[1]&&s?Lt(e.ctx.slice(),n[1](s(t))):e.ctx}function Mt(n,t,e,s){if(n[2]&&s){const a=n[2](s(e));if(t.dirty===void 0)return a;if(typeof a=="object"){const r=[],o=Math.max(t.dirty.length,a.length);for(let d=0;d<o;d+=1)r[d]=t.dirty[d]|a[d];return r}return t.dirty|a}return t.dirty}function Ht(n,t,e,s,a,r){if(a){const o=pt(t,e,s,r);n.p(o,a)}}function Gt(n){if(n.ctx.length>32){const t=[],e=n.ctx.length/32;for(let s=0;s<e;s++)t[s]=-1;return t}return-1}function gt(n){return n!=null?n:""}function b(n,t){n.appendChild(t)}function nt(n,t,e){n.insertBefore(t,e||null)}function K(n){n.parentNode&&n.parentNode.removeChild(n)}function jt(n,t){for(let e=0;e<n.length;e+=1)n[e]&&n[e].d(t)}function _(n){return document.createElement(n)}function L(n){return document.createTextNode(n)}function J(){return L(" ")}function Ft(){return L("")}function W(n,t,e,s){return n.addEventListener(t,e,s),()=>n.removeEventListener(t,e,s)}function E(n,t,e){e==null?n.removeAttribute(t):n.getAttribute(t)!==e&&n.setAttribute(t,e)}function Ot(n){return Array.from(n.childNodes)}function G(n,t){t=""+t,n.data!==t&&(n.data=t)}let st;function q(n){st=n}const j=[],ft=[];let F=[];const mt=[],Nt=Promise.resolve();let at=!1;function Zt(){at||(at=!0,Nt.then(wt))}function rt(n){F.push(n)}const ot=new Set;let O=0;function wt(){if(O!==0)return;const n=st;do{try{for(;O<j.length;){const t=j[O];O++,q(t),zt(t.$$)}}catch(t){throw j.length=0,O=0,t}for(q(null),j.length=0,O=0;ft.length;)ft.pop()();for(let t=0;t<F.length;t+=1){const e=F[t];ot.has(e)||(ot.add(e),e())}F.length=0}while(j.length);for(;mt.length;)mt.pop()();at=!1,ot.clear(),q(n)}function zt(n){if(n.fragment!==null){n.update(),R(n.before_update);const t=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,t),n.after_update.forEach(rt)}}function Vt(n){const t=[],e=[];F.forEach(s=>n.indexOf(s)===-1?t.push(s):e.push(s)),e.forEach(s=>s()),F=t}const Q=new Set;let Rt;function ct(n,t){n&&n.i&&(Q.delete(n),n.i(t))}function Ct(n,t,e,s){if(n&&n.o){if(Q.has(n))return;Q.add(n),Rt.c.push(()=>{Q.delete(n)}),n.o(t)}}function vt(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Ut(n){n&&n.c()}function kt(n,t,e){const{fragment:s,after_update:a}=n.$$;s&&s.m(t,e),rt(()=>{const r=n.$$.on_mount.map(ut).filter(U);n.$$.on_destroy?n.$$.on_destroy.push(...r):R(r),n.$$.on_mount=[]}),a.forEach(rt)}function xt(n,t){const e=n.$$;e.fragment!==null&&(Vt(e.after_update),R(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Jt(n,t){n.$$.dirty[0]===-1&&(j.push(n),Zt(),n.$$.dirty.fill(0)),n.$$.dirty[t/31|0]|=1<<t%31}function Dt(n,t,e,s,a,r,o=null,d=[-1]){const p=st;q(n);const u=n.$$={fragment:null,ctx:[],props:r,update:et,not_equal:a,bound:ht(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(p?p.$$.context:[])),callbacks:ht(),dirty:d,skip_bound:!1,root:t.target||p.$$.root};o&&o(u.root);let g=!1;if(u.ctx=e?e(n,t.props||{},(h,S,...l)=>{const y=l.length?l[0]:S;return u.ctx&&a(u.ctx[h],u.ctx[h]=y)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](y),g&&Jt(n,h)),S}):[],u.update(),g=!0,R(u.before_update),u.fragment=s?s(u.ctx):!1,t.target){if(t.hydrate){const h=Ot(t.target);u.fragment&&u.fragment.l(h),h.forEach(K)}else u.fragment&&u.fragment.c();t.intro&&ct(n.$$.fragment),kt(n,t.target,t.anchor),wt()}q(p)}class bt{constructor(){dt(this,"$$"),dt(this,"$$set")}$destroy(){xt(this,1),this.$destroy=et}$on(t,e){if(!U(e))return et;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(e),()=>{const a=s.indexOf(e);a!==-1&&s.splice(a,1)}}$set(t){this.$$set&&!Pt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Wt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Wt);function qt(n){let t,e,s,a=(n[1]||"标题")+"",r,o,d,p,u,g,h=(n[4]||"取消")+"",S,l,y,f=(n[5]||"确认")+"",k,C,m,x;const M=n[7].default,v=Tt(M,n,n[6],null);return{c(){t=_("div"),e=_("div"),s=_("div"),r=L(a),o=J(),d=_("div"),v&&v.c(),p=J(),u=_("div"),g=_("button"),S=L(h),l=J(),y=_("button"),k=L(f),E(s,"class","model-title svelte-n1zwga"),E(d,"class","slot svelte-n1zwga"),E(g,"class","modal-btn svelte-n1zwga"),E(y,"class","modal-btn success svelte-n1zwga"),E(u,"class","modal-footer svelte-n1zwga"),E(e,"class","modal-content svelte-n1zwga"),E(t,"class","modal-background modal-visible svelte-n1zwga")},m(P,H){nt(P,t,H),b(t,e),b(e,s),b(s,r),b(e,o),b(e,d),v&&v.m(d,null),b(e,p),b(e,u),b(u,g),b(g,S),b(u,l),b(u,y),b(y,k),C=!0,m||(x=[W(g,"click",function(){U(n[0])&&n[0].apply(this,arguments)}),W(y,"click",function(){U(n[2])&&n[2].apply(this,arguments)}),W(e,"click",Kt),W(t,"click",function(){U(n[3])&&n[3].apply(this,arguments)})],m=!0)},p(P,[H]){n=P,(!C||H&2)&&a!==(a=(n[1]||"标题")+"")&&G(r,a),v&&v.p&&(!C||H&64)&&Ht(v,M,n,n[6],C?Mt(M,n[6],H,null):Gt(n[6]),null),(!C||H&16)&&h!==(h=(n[4]||"取消")+"")&&G(S,h),(!C||H&32)&&f!==(f=(n[5]||"确认")+"")&&G(k,f)},i(P){C||(ct(v,P),C=!0)},o(P){Ct(v,P),C=!1},d(P){P&&K(t),v&&v.d(P),m=!1,R(x)}}}const Kt=n=>n.stopPropagation();function Qt(n,t,e){let{$$slots:s={},$$scope:a}=t,{onCancel:r}=t,{title:o}=t,{onOk:d}=t,{onClose:p}=t,{cancelText:u}=t,{okText:g}=t;return n.$$set=h=>{"onCancel"in h&&e(0,r=h.onCancel),"title"in h&&e(1,o=h.title),"onOk"in h&&e(2,d=h.onOk),"onClose"in h&&e(3,p=h.onClose),"cancelText"in h&&e(4,u=h.cancelText),"okText"in h&&e(5,g=h.okText),"$$scope"in h&&e(6,a=h.$$scope)},[r,o,d,p,u,g,a,s]}class Xt extends bt{constructor(t){super(),Dt(this,t,Qt,qt,yt,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5})}}function Bt(n,t,e){const s=n.slice();return s[10]=t[e],s[12]=e,s}function St(n){let t,e,s=n[10].CN+"",a,r,o,d=n[10].DevClass+"",p,u,g=n[10].sn+"",h,S,l,y,f,k;function C(){return n[9](n[12])}return{c(){t=_("div"),e=_("span"),a=L(s),r=J(),o=_("span"),p=L(d),u=L("("),h=L(g),S=L(")"),l=J(),E(e,"class","svelte-jtc2v4"),E(o,"class","svelte-jtc2v4"),E(t,"class",y=gt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(m,x){nt(m,t,x),b(t,e),b(e,a),b(t,r),b(t,o),b(o,p),b(o,u),b(o,h),b(o,S),b(t,l),f||(k=W(t,"click",C),f=!0)},p(m,x){n=m,x&1&&s!==(s=n[10].CN+"")&&G(a,s),x&1&&d!==(d=n[10].DevClass+"")&&G(p,d),x&1&&g!==(g=n[10].sn+"")&&G(h,g),x&16&&y!==(y=gt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&E(t,"class",y)},d(m){m&&K(t),f=!1,k()}}}function Yt(n){let t,e=vt(n[0]),s=[];for(let a=0;a<e.length;a+=1)s[a]=St(Bt(n,e,a));return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=Ft()},m(a,r){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(a,r);nt(a,t,r)},p(a,r){if(r&17){e=vt(a[0]);let o;for(o=0;o<e.length;o+=1){const d=Bt(a,e,o);s[o]?s[o].p(d,r):(s[o]=St(d),s[o].c(),s[o].m(t.parentNode,t))}for(;o<s.length;o+=1)s[o].d(1);s.length=e.length}},d(a){a&&K(t),jt(s,a)}}}function te(n){let t,e;return t=new Xt({props:{onOk:n[6],onClose:n[1],onCancel:n[5],cancelText:n[2],okText:n[3],title:"选择证书",$$slots:{default:[Yt]},$$scope:{ctx:n}}}),{c(){Ut(t.$$.fragment)},m(s,a){kt(t,s,a),e=!0},p(s,[a]){const r={};a&2&&(r.onClose=s[1]),a&4&&(r.cancelText=s[2]),a&8&&(r.okText=s[3]),a&8209&&(r.$$scope={dirty:a,ctx:s}),t.$set(r)},i(s){e||(ct(t.$$.fragment,s),e=!0)},o(s){Ct(t.$$.fragment,s),e=!1},d(s){xt(t,s)}}}function ee(n,t,e){let{certList:s=[]}=t,{onCancel:a}=t,{onOk:r}=t,{onClose:o}=t,{cancelText:d=""}=t,{okText:p=""}=t,u=0;const g=()=>{o==null||o()},h=()=>{r==null||r(s[u]),o==null||o()},S=l=>e(4,u=l);return n.$$set=l=>{"certList"in l&&e(0,s=l.certList),"onCancel"in l&&e(7,a=l.onCancel),"onOk"in l&&e(8,r=l.onOk),"onClose"in l&&e(1,o=l.onClose),"cancelText"in l&&e(2,d=l.cancelText),"okText"in l&&e(3,p=l.okText)},[s,o,d,p,u,g,h,a,r,S]}class ne extends bt{constructor(t){super(),Dt(this,t,ee,te,yt,{certList:0,onCancel:7,onOk:8,onClose:1,cancelText:2,okText:3})}}class se{constructor(){c(this,"modalInstance",{current:null});c(this,"open",t=>new Promise((e,s)=>{this.modalInstance.current=new ne({target:document.body,props:I($({},t),{onCancel:a=>{s()},onOk:a=>{e(a)},onClose:()=>{this.close()}})})}));c(this,"close",()=>{setTimeout(()=>{var t;(t=this.modalInstance.current)==null||t.$destroy()})})}}const ae=new se;class re{constructor(t){c(this,"socketInstance",null);c(this,"eventBus",new Et);c(this,"isRememberPin",!1);c(this,"socketEvent");c(this,"pinPolicy");c(this,"socketConfig",null);c(this,"getSocketReadyState",()=>{var t;return(t=this.socketInstance)==null?void 0:t.readyState});c(this,"destroy",()=>{var t;(t=this.socketInstance)==null||t.close()});c(this,"sendMessage",(t,e)=>new Promise((s,a)=>{var o,d;if(((o=this.socketInstance)==null?void 0:o.readyState)!==WebSocket.OPEN){console.log(t),a({errCode:-1,msg:"socket未连接"});return}const r={function:t,args:[e!=null?e:{}]};(d=this.socketInstance)==null||d.send(JSON.stringify(r)),this.eventBus.on(t,p=>{p.success?s(p.data):a(p)})}));c(this,"handleEventData",t=>i(this,null,function*(){var e,s,a,r,o,d;if(t.data instanceof Blob){const p=yield t.data.arrayBuffer(),g=new TextDecoder("gbk").decode(p),h=JSON.parse(g),S={data:h.data,success:(e=h.result)==null?void 0:e.success,msg:(s=h.result)==null?void 0:s.msg,errCode:(a=h.result)==null?void 0:a.errCode};this.eventBus.emit((r=h.result)==null?void 0:r.function,S),(d=(o=this.socketConfig)==null?void 0:o.onMessage)==null||d.call(o,S)}}));c(this,"base64Encode",t=>{const e=new TextEncoder().encode(t);return lt.fromByteArray(e)});c(this,"base64Decode",t=>{const e=lt.toByteArray(t);return new TextDecoder().decode(e)});c(this,"changeIsRememberPin",t=>i(this,null,function*(){this.isRememberPin=t}));c(this,"changePinPolicy",t=>i(this,null,function*(){this.pinPolicy=t}));c(this,"checkCertIsLogin",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",t)}));c(this,"addUkeyEvents",()=>i(this,null,function*(){this.sendMessage("GZCA_StartListen",{Type:Y}).then(t=>{var e,s;(s=(e=this.socketConfig)==null?void 0:e.onUkeyEvent)==null||s.call(e,t)})}));c(this,"certLogin",t=>i(this,null,function*(){const e=yield this.checkCertIsLogin({ContainerName:t});e!=null&&e[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:t,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));c(this,"getCert",(t,e)=>i(this,null,function*(){const s=e!=null?e:yield this.chooseCert(t);return yield this.certLogin(s.ContainerName),s}));c(this,"getCertList",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",t)}));c(this,"chooseCert",t=>i(this,null,function*(){const e=yield this.getCertList(t);return(e==null?void 0:e.length)===1?e[0]:yield ae.open({certList:e})}));c(this,"pkcs1Sign",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",I($({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1Base64Sign",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",I($({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1VerifySignature",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",t)}));c(this,"pkcs1Base64VerifySignature",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",t)}));c(this,"getSealList",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",I($({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm2SignPreprocess1",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",t)}));c(this,"sm2SignPreprocess2",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",t)}));c(this,"pkcs1HashSign",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",I($({},t!=null?t:{}),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1HashVerifySignature",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",t)}));c(this,"pkcs7Sign",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",I($({},t),{IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy}))}));c(this,"pkcs7VerifySignature",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",t)}));c(this,"sm3Hash",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_HashData",t)}));c(this,"sm3HexHash",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",t)}));c(this,"sm3FileHash",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",t)}));c(this,"sm3HashEncryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_HMac",t)}));c(this,"pkcs7Encryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",t)}));c(this,"pkcs7Decryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",I($({},t),{IsLogin:this.getIsLogin()}))}));c(this,"asymmetricEncryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",t)}));c(this,"asymmetricDecryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",I($({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm4Encryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",t)}));c(this,"sm4Decryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",t)}));c(this,"getCertInfo",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",t)}));c(this,"getCertInfoByOid",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",t)}));var e,s;this.socketConfig=t,this.socketInstance=this.createSocket(t),this.isRememberPin=(e=t.isRememberPin)!=null?e:!1,this.pinPolicy=(s=t.pinPolicy)!=null?s:z.MIN}createSocket(t){const e=new WebSocket(t.url);return e.onerror=s=>{var a;(a=t.onError)==null||a.call(t,s)},e.onopen=s=>{var a;(a=t.onOpen)==null||a.call(t,s),this.addUkeyEvents()},e.onmessage=s=>{this.handleEventData(s)},e.onclose=s=>{var a;(a=t.onClose)==null||a.call(t,s)},e}getIsLogin(){return this.isRememberPin?"Y":"N"}}const Z=class Z{constructor(t){c(this,"coreInstance",null);c(this,"gwsConfig",{});c(this,"createGwsCore",t=>{this.gwsConfig=t!=null?t:{},this.coreInstance=new re(I($({},t!=null?t:{}),{url:w}))});c(this,"appendCertBase64",(t,e=!0)=>i(this,null,function*(){if(t.CertB64)return t;const s=e?yield this.getSignatureCert():yield this.getEncryptionCert();return I($({},t!=null?t:{}),{CertB64:s==null?void 0:s.CertB64})}));c(this,"destroy",()=>{var t;(t=this.coreInstance)==null||t.destroy(),this.coreInstance=null});c(this,"restart",t=>{this.coreInstance&&this.destroy(),this.gwsConfig=t!=null?t:this.gwsConfig,this.createGwsCore(t)});c(this,"getSocketReadyState",()=>{var t;return(t=this.coreInstance)==null?void 0:t.getSocketReadyState()});c(this,"getSignatureCert",t=>i(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:B},t)}));c(this,"getEncryptionCert",t=>i(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:X},t)}));c(this,"base64Encode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Encode(t.Data)});c(this,"base64Decode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Decode(t.DataB64)});c(this,"changeIsRememberPin",t=>{var e;(e=this.coreInstance)==null||e.changeIsRememberPin(t)});c(this,"changePinPolicy",t=>{var e;(e=this.coreInstance)==null||e.changePinPolicy(t)});c(this,"pkcs1Sign",(t,e)=>i(this,null,function*(){var r,o,d;const s=yield this.getSignatureCert(e),a=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(I($({},t!=null?t:{}),{ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:""}));return(d=a==null?void 0:a[0])==null?void 0:d.SignData}));c(this,"pkcs1VerifySignature",t=>i(this,null,function*(){var a;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.pkcs1VerifySignature(e);return Array.isArray(s)}));c(this,"pkcs1Base64Sign",(t,e)=>i(this,null,function*(){var o,d,p,u,g;const s=yield this.getSignatureCert(e),a=(d=t.DataB64)!=null?d:this.base64Encode({Data:(o=t.Data)!=null?o:""}),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign({ContainerName:(p=s==null?void 0:s.ContainerName)!=null?p:"",DataB64:a});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs1Base64VerifySignature",t=>i(this,null,function*(){var r,o,d;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t);return!!(yield(d=this.coreInstance)==null?void 0:d.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:e,SignData:s.SignData}))}));c(this,"getSealList",()=>i(this,null,function*(){var s,a;const t=yield this.getSignatureCert(),e=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:""});return{cert:t,sealList:e}}));c(this,"sm2SignPreprocess1",t=>i(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess1(e);return(r=s==null?void 0:s[0])==null?void 0:r.Z}));c(this,"sm2SignPreprocess2",t=>i(this,null,function*(){var r,o;const e=this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t),a=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:e});return a==null?void 0:a[0].H}));c(this,"pkcs1HashSign",(t,e)=>i(this,null,function*(){var r,o,d,p;const s=yield this.getSignatureCert(e),a=yield(d=this.coreInstance)==null?void 0:d.pkcs1HashSign({ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:"",DataB64:t.DataB64,HashAlg:(o=t.HashAlg)!=null?o:"sm3"});return(p=a==null?void 0:a[0])==null?void 0:p.SignData}));c(this,"pkcs1HashVerifySignature",t=>i(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t);return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs1HashVerifySignature(I($({},e),{HashAlg:(a=e.HashAlg)!=null?a:"sm3"})))}));c(this,"pkcs7Sign",(t,e)=>i(this,null,function*(){var o,d,p,u,g;const s=(d=t.DataB64)!=null?d:this.base64Encode({Data:(o=t.Data)!=null?o:""}),a=yield this.getSignatureCert(e),r=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign({IsDetached:t.IsDetached,ContainerName:(p=a==null?void 0:a.ContainerName)!=null?p:"",DataB64:s});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs7VerifySignature",t=>i(this,null,function*(){var a,r,o;const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:e,SignData:t.SignData}))}));c(this,"sm3Hash",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HexHash",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3FileHash",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HashEncryption",t=>i(this,null,function*(){var r,o,d,p,u,g;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=(p=t.KeyB64)!=null?p:this.base64Encode({Data:(d=t.Key)!=null?d:""}),a=yield(u=this.coreInstance)==null?void 0:u.sm3HashEncryption({dataB64:e,keyB64:s,alg:"sm3"});return(g=a==null?void 0:a[0])==null?void 0:g.DataB64}));c(this,"pkcs7Encryption",t=>i(this,null,function*(){var a,r,o,d;if(!t.CertB64List){const p=yield this.getEncryptionCert();t.CertB64List=p==null?void 0:p.CertB64}const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:e,CertB64List:t.CertB64List});return(d=s==null?void 0:s[0])==null?void 0:d.DataB64}));c(this,"pkcs7Decryption",t=>i(this,null,function*(){var r,o;const e=yield this.getEncryptionCert(),s=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption({DataB64:t.DataB64,ContainerName:e==null?void 0:e.ContainerName}),a=(o=s==null?void 0:s[0])==null?void 0:o.DataB64;return t.shouldDecodeBase64?this.base64Decode({DataB64:a}):a}));c(this,"asymmetricEncryption",t=>i(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t,!1),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricEncryption(e);return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"asymmetricDecryption",t=>i(this,null,function*(){var a,r;const e=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption({Data:t.Data,ContainerName:e==null?void 0:e.ContainerName});return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"sm4Encryption",t=>i(this,null,function*(){var s;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(t);return e==null?void 0:e[0]}));c(this,"sm4Decryption",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(t);return(a=e==null?void 0:e[0])==null?void 0:a.Data}));c(this,"getCertInfo",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(t);return $({},(a=e==null?void 0:e[0])!=null?a:{})}));c(this,"getCertInfoByOid",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid($({},t!=null?t:{}));return(a=e==null?void 0:e[0])==null?void 0:a.OidValue}));return Z.instance&&!(t!=null&&t.isCreateNew)?Z.instance:(this.createGwsCore(t),Z.instance=this,this)}};c(Z,"instance",null);let N=Z;function oe(n){return new Promise((t,e)=>{if(N.instance)t(N.instance);else{const s=new N(I($({},n!=null?n:{}),{onOpen(a){var r;t(s),(r=n==null?void 0:n.onOpen)==null||r.call(n,a)},onClose(a){var r;e(a),(r=n==null?void 0:n.onClose)==null||r.call(n,a)}}))}})}D.GwsService=N,D.createService=oe,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
1
+ (function(D,w){typeof exports=="object"&&typeof module!="undefined"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(D=typeof globalThis!="undefined"?globalThis:D||self,w(D.GWS_CLIENT={}))})(this,function(D){"use strict";var ce=Object.defineProperty,ie=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var $t=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var it=(D,w,B)=>w in D?ce(D,w,{enumerable:!0,configurable:!0,writable:!0,value:B}):D[w]=B,$=(D,w)=>{for(var B in w||(w={}))de.call(w,B)&&it(D,B,w[B]);if($t)for(var B of $t(w))ue.call(w,B)&&it(D,B,w[B]);return D},I=(D,w)=>ie(D,le(w));var c=(D,w,B)=>it(D,typeof w!="symbol"?w+"":w,B);var i=(D,w,B)=>new Promise((X,z)=>{var Y=A=>{try{T(B.next(A))}catch(V){z(V)}},tt=A=>{try{T(B.throw(A))}catch(V){z(V)}},T=A=>A.done?X(A.value):Promise.resolve(A.value).then(Y,tt);T((B=B.apply(D,w)).next())});const w=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",B="1",X="2";var z=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(z||{});const Y="00000001";function tt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var T={},A;function V(){if(A)return T;A=1,T.byteLength=d,T.toByteArray=u,T.fromByteArray=S;for(var n=[],t=[],e=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,r=s.length;a<r;++a)n[a]=s[a],t[s.charCodeAt(a)]=a;t[45]=62,t[95]=63;function o(l){var y=l.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=l.indexOf("=");f===-1&&(f=y);var k=f===y?0:4-f%4;return[f,k]}function d(l){var y=o(l),f=y[0],k=y[1];return(f+k)*3/4-k}function p(l,y,f){return(y+f)*3/4-f}function u(l){var y,f=o(l),k=f[0],C=f[1],m=new e(p(l,k,C)),x=0,M=C>0?k-4:k,v;for(v=0;v<M;v+=4)y=t[l.charCodeAt(v)]<<18|t[l.charCodeAt(v+1)]<<12|t[l.charCodeAt(v+2)]<<6|t[l.charCodeAt(v+3)],m[x++]=y>>16&255,m[x++]=y>>8&255,m[x++]=y&255;return C===2&&(y=t[l.charCodeAt(v)]<<2|t[l.charCodeAt(v+1)]>>4,m[x++]=y&255),C===1&&(y=t[l.charCodeAt(v)]<<10|t[l.charCodeAt(v+1)]<<4|t[l.charCodeAt(v+2)]>>2,m[x++]=y>>8&255,m[x++]=y&255),m}function g(l){return n[l>>18&63]+n[l>>12&63]+n[l>>6&63]+n[l&63]}function h(l,y,f){for(var k,C=[],m=y;m<f;m+=3)k=(l[m]<<16&16711680)+(l[m+1]<<8&65280)+(l[m+2]&255),C.push(g(k));return C.join("")}function S(l){for(var y,f=l.length,k=f%3,C=[],m=16383,x=0,M=f-k;x<M;x+=m)C.push(h(l,x,x+m>M?M:x+m));return k===1?(y=l[f-1],C.push(n[y>>2]+n[y<<4&63]+"==")):k===2&&(y=(l[f-2]<<8)+l[f-1],C.push(n[y>>10]+n[y>>4&63]+n[y<<2&63]+"=")),C.join("")}return T}var It=V();const lt=tt(It);class Et{constructor(){c(this,"deps",new Map)}on(t,e){this.deps.set(t,e)}emit(t,e){const s=this.deps.get(t);s&&s(e)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-n1zwga{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-n1zwga{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-n1zwga{background-color:#fff;padding:20px;border-radius:5px;width:40%}.model-title.svelte-n1zwga{color:#303133;font-size:18px;margin-bottom:16px}.modal-visible.svelte-n1zwga{display:flex}.modal-footer.svelte-n1zwga{display:flex;align-items:center;justify-content:flex-end;margin-top:16px}.modal-btn.svelte-n1zwga{padding:8px 15px;border-radius:4px;font-size:14px;border:1px solid #dcdfe6}.success.svelte-n1zwga{background-color:#409eff;margin-left:12px;color:#fff}.slot.svelte-n1zwga{max-height:200px;overflow-y:scroll}.slot.svelte-n1zwga::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:16px;display:flex;align-items:center;cursor:pointer;border-bottom:1px solid #ebeef5;font-size:14px}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:1px 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:180px;height:180px;display:flex;flex-direction:column;align-items:center;justify-content:center;border:1px solid #ccc;margin-top:10px;margin-right:10px;border-radius:4px}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:100px;height:100px}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:10px;color:#333}")),document.head.appendChild(n)}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var At=Object.defineProperty,_t=(n,t,e)=>t in n?At(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,dt=(n,t,e)=>_t(n,typeof t!="symbol"?t+"":t,e);function et(){}function Lt(n,t){for(const e in t)n[e]=t[e];return n}function ut(n){return n()}function ht(){return Object.create(null)}function R(n){n.forEach(ut)}function U(n){return typeof n=="function"}function yt(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function Pt(n){return Object.keys(n).length===0}function Tt(n,t,e,s){if(n){const a=pt(n,t,e,s);return n[0](a)}}function pt(n,t,e,s){return n[1]&&s?Lt(e.ctx.slice(),n[1](s(t))):e.ctx}function Mt(n,t,e,s){if(n[2]&&s){const a=n[2](s(e));if(t.dirty===void 0)return a;if(typeof a=="object"){const r=[],o=Math.max(t.dirty.length,a.length);for(let d=0;d<o;d+=1)r[d]=t.dirty[d]|a[d];return r}return t.dirty|a}return t.dirty}function Ht(n,t,e,s,a,r){if(a){const o=pt(t,e,s,r);n.p(o,a)}}function Gt(n){if(n.ctx.length>32){const t=[],e=n.ctx.length/32;for(let s=0;s<e;s++)t[s]=-1;return t}return-1}function gt(n){return n!=null?n:""}function b(n,t){n.appendChild(t)}function nt(n,t,e){n.insertBefore(t,e||null)}function K(n){n.parentNode&&n.parentNode.removeChild(n)}function jt(n,t){for(let e=0;e<n.length;e+=1)n[e]&&n[e].d(t)}function _(n){return document.createElement(n)}function L(n){return document.createTextNode(n)}function J(){return L(" ")}function Ft(){return L("")}function W(n,t,e,s){return n.addEventListener(t,e,s),()=>n.removeEventListener(t,e,s)}function E(n,t,e){e==null?n.removeAttribute(t):n.getAttribute(t)!==e&&n.setAttribute(t,e)}function Ot(n){return Array.from(n.childNodes)}function G(n,t){t=""+t,n.data!==t&&(n.data=t)}let st;function q(n){st=n}const j=[],ft=[];let F=[];const mt=[],Nt=Promise.resolve();let at=!1;function Zt(){at||(at=!0,Nt.then(wt))}function rt(n){F.push(n)}const ot=new Set;let O=0;function wt(){if(O!==0)return;const n=st;do{try{for(;O<j.length;){const t=j[O];O++,q(t),zt(t.$$)}}catch(t){throw j.length=0,O=0,t}for(q(null),j.length=0,O=0;ft.length;)ft.pop()();for(let t=0;t<F.length;t+=1){const e=F[t];ot.has(e)||(ot.add(e),e())}F.length=0}while(j.length);for(;mt.length;)mt.pop()();at=!1,ot.clear(),q(n)}function zt(n){if(n.fragment!==null){n.update(),R(n.before_update);const t=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,t),n.after_update.forEach(rt)}}function Vt(n){const t=[],e=[];F.forEach(s=>n.indexOf(s)===-1?t.push(s):e.push(s)),e.forEach(s=>s()),F=t}const Q=new Set;let Rt;function ct(n,t){n&&n.i&&(Q.delete(n),n.i(t))}function Ct(n,t,e,s){if(n&&n.o){if(Q.has(n))return;Q.add(n),Rt.c.push(()=>{Q.delete(n)}),n.o(t)}}function vt(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Ut(n){n&&n.c()}function kt(n,t,e){const{fragment:s,after_update:a}=n.$$;s&&s.m(t,e),rt(()=>{const r=n.$$.on_mount.map(ut).filter(U);n.$$.on_destroy?n.$$.on_destroy.push(...r):R(r),n.$$.on_mount=[]}),a.forEach(rt)}function xt(n,t){const e=n.$$;e.fragment!==null&&(Vt(e.after_update),R(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Jt(n,t){n.$$.dirty[0]===-1&&(j.push(n),Zt(),n.$$.dirty.fill(0)),n.$$.dirty[t/31|0]|=1<<t%31}function Dt(n,t,e,s,a,r,o=null,d=[-1]){const p=st;q(n);const u=n.$$={fragment:null,ctx:[],props:r,update:et,not_equal:a,bound:ht(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(p?p.$$.context:[])),callbacks:ht(),dirty:d,skip_bound:!1,root:t.target||p.$$.root};o&&o(u.root);let g=!1;if(u.ctx=e?e(n,t.props||{},(h,S,...l)=>{const y=l.length?l[0]:S;return u.ctx&&a(u.ctx[h],u.ctx[h]=y)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](y),g&&Jt(n,h)),S}):[],u.update(),g=!0,R(u.before_update),u.fragment=s?s(u.ctx):!1,t.target){if(t.hydrate){const h=Ot(t.target);u.fragment&&u.fragment.l(h),h.forEach(K)}else u.fragment&&u.fragment.c();t.intro&&ct(n.$$.fragment),kt(n,t.target,t.anchor),wt()}q(p)}class bt{constructor(){dt(this,"$$"),dt(this,"$$set")}$destroy(){xt(this,1),this.$destroy=et}$on(t,e){if(!U(e))return et;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(e),()=>{const a=s.indexOf(e);a!==-1&&s.splice(a,1)}}$set(t){this.$$set&&!Pt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Wt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Wt);function qt(n){let t,e,s,a=(n[1]||"标题")+"",r,o,d,p,u,g,h=(n[4]||"取消")+"",S,l,y,f=(n[5]||"确认")+"",k,C,m,x;const M=n[7].default,v=Tt(M,n,n[6],null);return{c(){t=_("div"),e=_("div"),s=_("div"),r=L(a),o=J(),d=_("div"),v&&v.c(),p=J(),u=_("div"),g=_("button"),S=L(h),l=J(),y=_("button"),k=L(f),E(s,"class","model-title svelte-n1zwga"),E(d,"class","slot svelte-n1zwga"),E(g,"class","modal-btn svelte-n1zwga"),E(y,"class","modal-btn success svelte-n1zwga"),E(u,"class","modal-footer svelte-n1zwga"),E(e,"class","modal-content svelte-n1zwga"),E(t,"class","modal-background modal-visible svelte-n1zwga")},m(P,H){nt(P,t,H),b(t,e),b(e,s),b(s,r),b(e,o),b(e,d),v&&v.m(d,null),b(e,p),b(e,u),b(u,g),b(g,S),b(u,l),b(u,y),b(y,k),C=!0,m||(x=[W(g,"click",function(){U(n[0])&&n[0].apply(this,arguments)}),W(y,"click",function(){U(n[2])&&n[2].apply(this,arguments)}),W(e,"click",Kt),W(t,"click",function(){U(n[3])&&n[3].apply(this,arguments)})],m=!0)},p(P,[H]){n=P,(!C||H&2)&&a!==(a=(n[1]||"标题")+"")&&G(r,a),v&&v.p&&(!C||H&64)&&Ht(v,M,n,n[6],C?Mt(M,n[6],H,null):Gt(n[6]),null),(!C||H&16)&&h!==(h=(n[4]||"取消")+"")&&G(S,h),(!C||H&32)&&f!==(f=(n[5]||"确认")+"")&&G(k,f)},i(P){C||(ct(v,P),C=!0)},o(P){Ct(v,P),C=!1},d(P){P&&K(t),v&&v.d(P),m=!1,R(x)}}}const Kt=n=>n.stopPropagation();function Qt(n,t,e){let{$$slots:s={},$$scope:a}=t,{onCancel:r}=t,{title:o}=t,{onOk:d}=t,{onClose:p}=t,{cancelText:u}=t,{okText:g}=t;return n.$$set=h=>{"onCancel"in h&&e(0,r=h.onCancel),"title"in h&&e(1,o=h.title),"onOk"in h&&e(2,d=h.onOk),"onClose"in h&&e(3,p=h.onClose),"cancelText"in h&&e(4,u=h.cancelText),"okText"in h&&e(5,g=h.okText),"$$scope"in h&&e(6,a=h.$$scope)},[r,o,d,p,u,g,a,s]}class Xt extends bt{constructor(t){super(),Dt(this,t,Qt,qt,yt,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5})}}function Bt(n,t,e){const s=n.slice();return s[10]=t[e],s[12]=e,s}function St(n){let t,e,s=n[10].CN+"",a,r,o,d=n[10].DevClass+"",p,u,g=n[10].sn+"",h,S,l,y,f,k;function C(){return n[9](n[12])}return{c(){t=_("div"),e=_("span"),a=L(s),r=J(),o=_("span"),p=L(d),u=L("("),h=L(g),S=L(")"),l=J(),E(e,"class","svelte-jtc2v4"),E(o,"class","svelte-jtc2v4"),E(t,"class",y=gt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(m,x){nt(m,t,x),b(t,e),b(e,a),b(t,r),b(t,o),b(o,p),b(o,u),b(o,h),b(o,S),b(t,l),f||(k=W(t,"click",C),f=!0)},p(m,x){n=m,x&1&&s!==(s=n[10].CN+"")&&G(a,s),x&1&&d!==(d=n[10].DevClass+"")&&G(p,d),x&1&&g!==(g=n[10].sn+"")&&G(h,g),x&16&&y!==(y=gt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&E(t,"class",y)},d(m){m&&K(t),f=!1,k()}}}function Yt(n){let t,e=vt(n[0]),s=[];for(let a=0;a<e.length;a+=1)s[a]=St(Bt(n,e,a));return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=Ft()},m(a,r){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(a,r);nt(a,t,r)},p(a,r){if(r&17){e=vt(a[0]);let o;for(o=0;o<e.length;o+=1){const d=Bt(a,e,o);s[o]?s[o].p(d,r):(s[o]=St(d),s[o].c(),s[o].m(t.parentNode,t))}for(;o<s.length;o+=1)s[o].d(1);s.length=e.length}},d(a){a&&K(t),jt(s,a)}}}function te(n){let t,e;return t=new Xt({props:{onOk:n[6],onClose:n[1],onCancel:n[5],cancelText:n[2],okText:n[3],title:"选择证书",$$slots:{default:[Yt]},$$scope:{ctx:n}}}),{c(){Ut(t.$$.fragment)},m(s,a){kt(t,s,a),e=!0},p(s,[a]){const r={};a&2&&(r.onClose=s[1]),a&4&&(r.cancelText=s[2]),a&8&&(r.okText=s[3]),a&8209&&(r.$$scope={dirty:a,ctx:s}),t.$set(r)},i(s){e||(ct(t.$$.fragment,s),e=!0)},o(s){Ct(t.$$.fragment,s),e=!1},d(s){xt(t,s)}}}function ee(n,t,e){let{certList:s=[]}=t,{onCancel:a}=t,{onOk:r}=t,{onClose:o}=t,{cancelText:d=""}=t,{okText:p=""}=t,u=0;const g=()=>{o==null||o()},h=()=>{r==null||r(s[u]),o==null||o()},S=l=>e(4,u=l);return n.$$set=l=>{"certList"in l&&e(0,s=l.certList),"onCancel"in l&&e(7,a=l.onCancel),"onOk"in l&&e(8,r=l.onOk),"onClose"in l&&e(1,o=l.onClose),"cancelText"in l&&e(2,d=l.cancelText),"okText"in l&&e(3,p=l.okText)},[s,o,d,p,u,g,h,a,r,S]}class ne extends bt{constructor(t){super(),Dt(this,t,ee,te,yt,{certList:0,onCancel:7,onOk:8,onClose:1,cancelText:2,okText:3})}}class se{constructor(){c(this,"modalInstance",{current:null});c(this,"open",t=>new Promise((e,s)=>{this.modalInstance.current=new ne({target:document.body,props:I($({},t),{onCancel:a=>{s()},onOk:a=>{e(a)},onClose:()=>{this.close()}})})}));c(this,"close",()=>{setTimeout(()=>{var t;(t=this.modalInstance.current)==null||t.$destroy()})})}}const ae=new se;class re{constructor(t){c(this,"socketInstance",null);c(this,"eventBus",new Et);c(this,"isRememberPin",!1);c(this,"socketEvent");c(this,"pinPolicy");c(this,"socketConfig",null);c(this,"getSocketReadyState",()=>{var t;return(t=this.socketInstance)==null?void 0:t.readyState});c(this,"destroy",()=>{var t;(t=this.socketInstance)==null||t.close()});c(this,"sendMessage",(t,e)=>new Promise((s,a)=>{var o,d;if(((o=this.socketInstance)==null?void 0:o.readyState)!==WebSocket.OPEN){console.log(t),a({errCode:-1,msg:"socket未连接"});return}const r={function:t,args:[e!=null?e:{}]};(d=this.socketInstance)==null||d.send(JSON.stringify(r)),this.eventBus.on(t,p=>{p.success?s(p.data):a(p)})}));c(this,"handleEventData",t=>i(this,null,function*(){var e,s,a,r,o,d;if(t.data instanceof Blob){const p=yield t.data.arrayBuffer(),g=new TextDecoder("gbk").decode(p),h=JSON.parse(g),S={data:h.data,success:(e=h.result)==null?void 0:e.success,msg:(s=h.result)==null?void 0:s.msg,errCode:(a=h.result)==null?void 0:a.errCode};this.eventBus.emit((r=h.result)==null?void 0:r.function,S),(d=(o=this.socketConfig)==null?void 0:o.onMessage)==null||d.call(o,S)}}));c(this,"base64Encode",t=>{const e=new TextEncoder().encode(t);return lt.fromByteArray(e)});c(this,"base64Decode",t=>{const e=lt.toByteArray(t);return new TextDecoder().decode(e)});c(this,"changeIsRememberPin",t=>i(this,null,function*(){this.isRememberPin=t}));c(this,"changePinPolicy",t=>i(this,null,function*(){this.pinPolicy=t}));c(this,"checkCertIsLogin",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",t)}));c(this,"addUkeyEvents",()=>i(this,null,function*(){this.sendMessage("GZCA_StartListen",{Type:Y}).then(t=>{var e,s;(s=(e=this.socketConfig)==null?void 0:e.onUkeyEvent)==null||s.call(e,t)})}));c(this,"certLogin",t=>i(this,null,function*(){const e=yield this.checkCertIsLogin({ContainerName:t});e!=null&&e[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:t,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));c(this,"getCert",(t,e)=>i(this,null,function*(){const s=e!=null?e:yield this.chooseCert(t);return yield this.certLogin(s.ContainerName),s}));c(this,"getCertList",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",t)}));c(this,"chooseCert",t=>i(this,null,function*(){const e=yield this.getCertList(t);return(e==null?void 0:e.length)===1?e[0]:yield ae.open({certList:e})}));c(this,"pkcs1Sign",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",I($({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1Base64Sign",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",I($({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1VerifySignature",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",t)}));c(this,"pkcs1Base64VerifySignature",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",t)}));c(this,"getSealList",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",I($({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm2SignPreprocess1",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",t)}));c(this,"sm2SignPreprocess2",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",t)}));c(this,"pkcs1HashSign",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",I($({},t!=null?t:{}),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1HashVerifySignature",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",t)}));c(this,"pkcs7Sign",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",I($({},t),{IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy}))}));c(this,"pkcs7VerifySignature",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",t)}));c(this,"sm3Hash",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_HashData",t)}));c(this,"sm3HexHash",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",t)}));c(this,"sm3FileHash",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",t)}));c(this,"sm3HashEncryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_HMac",t)}));c(this,"pkcs7Encryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",t)}));c(this,"pkcs7Decryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",I($({},t),{IsLogin:this.getIsLogin()}))}));c(this,"asymmetricEncryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",t)}));c(this,"asymmetricDecryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",I($({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm4Encryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",t)}));c(this,"sm4Decryption",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",t)}));c(this,"getCertInfo",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",t)}));c(this,"getCertInfoByOid",t=>i(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",t)}));var e,s;this.socketConfig=t,this.socketInstance=this.createSocket(t),this.isRememberPin=(e=t.isRememberPin)!=null?e:!1,this.pinPolicy=(s=t.pinPolicy)!=null?s:z.MIN}createSocket(t){const e=new WebSocket(t.url);return e.onerror=s=>{var a;(a=t.onError)==null||a.call(t,s)},e.onopen=s=>{var a;(a=t.onOpen)==null||a.call(t,s),this.addUkeyEvents()},e.onmessage=s=>{this.handleEventData(s)},e.onclose=s=>{var a;(a=t.onClose)==null||a.call(t,s)},e}getIsLogin(){return this.isRememberPin?"Y":"N"}}const Z=class Z{constructor(t){c(this,"coreInstance",null);c(this,"gwsConfig",{});c(this,"createGwsCore",t=>{this.gwsConfig=t!=null?t:{},this.coreInstance=new re(I($({},t!=null?t:{}),{url:w}))});c(this,"appendCertBase64",(t,e=!0)=>i(this,null,function*(){if(t.CertB64)return t;const s=e?yield this.getSignatureCert():yield this.getEncryptionCert();return I($({},t!=null?t:{}),{CertB64:s==null?void 0:s.CertB64})}));c(this,"destroy",()=>{var t;(t=this.coreInstance)==null||t.destroy(),this.coreInstance=null});c(this,"restart",t=>{this.coreInstance&&this.destroy(),this.gwsConfig=t!=null?t:this.gwsConfig,this.createGwsCore(t)});c(this,"getSocketReadyState",()=>{var t;return(t=this.coreInstance)==null?void 0:t.getSocketReadyState()});c(this,"getSignatureCert",t=>i(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:B},t)}));c(this,"getEncryptionCert",t=>i(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:X},t)}));c(this,"base64Encode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Encode(t.Data)});c(this,"base64Decode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Decode(t.DataB64)});c(this,"changeIsRememberPin",t=>{var e;(e=this.coreInstance)==null||e.changeIsRememberPin(t)});c(this,"changePinPolicy",t=>{var e;(e=this.coreInstance)==null||e.changePinPolicy(t)});c(this,"pkcs1Sign",(t,e)=>i(this,null,function*(){var r,o,d;const s=yield this.getSignatureCert(e),a=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(I($({},t!=null?t:{}),{ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:""}));return(d=a==null?void 0:a[0])==null?void 0:d.SignData}));c(this,"pkcs1VerifySignature",t=>i(this,null,function*(){var a;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.pkcs1VerifySignature(e);return Array.isArray(s)}));c(this,"pkcs1Base64Sign",(t,e)=>i(this,null,function*(){var o,d,p,u,g;const s=yield this.getSignatureCert(e),a=(d=t.DataB64)!=null?d:this.base64Encode({Data:(o=t.Data)!=null?o:""}),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64Sign({ContainerName:(p=s==null?void 0:s.ContainerName)!=null?p:"",DataB64:a});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs1Base64VerifySignature",t=>i(this,null,function*(){var r,o,d;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t);return!!(yield(d=this.coreInstance)==null?void 0:d.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:e,SignData:s.SignData}))}));c(this,"getSealList",()=>i(this,null,function*(){var s,a;const t=yield this.getSignatureCert(),e=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:""});return{cert:t,sealList:e}}));c(this,"sm2SignPreprocess1",t=>i(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess1(e);return(r=s==null?void 0:s[0])==null?void 0:r.Z}));c(this,"sm2SignPreprocess2",t=>i(this,null,function*(){var r,o;const e=this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t),a=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:e});return a==null?void 0:a[0].H}));c(this,"pkcs1HashSign",(t,e)=>i(this,null,function*(){var r,o,d,p;const s=yield this.getSignatureCert(e),a=yield(d=this.coreInstance)==null?void 0:d.pkcs1HashSign({ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:"",DataB64:t.DataB64,HashAlg:(o=t.HashAlg)!=null?o:"sm3"});return(p=a==null?void 0:a[0])==null?void 0:p.SignData}));c(this,"pkcs1HashVerifySignature",t=>i(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t);return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs1HashVerifySignature(I($({},e),{HashAlg:(a=e.HashAlg)!=null?a:"sm3"})))}));c(this,"pkcs7Sign",(t,e)=>i(this,null,function*(){var o,d,p,u,g;const s=(d=t.DataB64)!=null?d:this.base64Encode({Data:(o=t.Data)!=null?o:""}),a=yield this.getSignatureCert(e),r=yield(u=this.coreInstance)==null?void 0:u.pkcs7Sign({IsDetached:t.IsDetached,ContainerName:(p=a==null?void 0:a.ContainerName)!=null?p:"",DataB64:s});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs7VerifySignature",t=>i(this,null,function*(){var a,r,o;const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:e,SignData:t.SignData}))}));c(this,"sm3Hash",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HexHash",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3FileHash",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HashEncryption",t=>i(this,null,function*(){var r,o,d,p,u,g;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=(p=t.KeyB64)!=null?p:this.base64Encode({Data:(d=t.Key)!=null?d:""}),a=yield(u=this.coreInstance)==null?void 0:u.sm3HashEncryption({dataB64:e,keyB64:s,alg:"sm3"});return(g=a==null?void 0:a[0])==null?void 0:g.DataB64}));c(this,"pkcs7Encryption",t=>i(this,null,function*(){var a,r,o,d;if(!t.CertB64List){const p=yield this.getEncryptionCert();t.CertB64List=p==null?void 0:p.CertB64}const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:e,CertB64List:t.CertB64List});return(d=s==null?void 0:s[0])==null?void 0:d.DataB64}));c(this,"pkcs7Decryption",t=>i(this,null,function*(){var r,o;const e=yield this.getEncryptionCert(),s=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption({DataB64:t.DataB64,ContainerName:e==null?void 0:e.ContainerName}),a=(o=s==null?void 0:s[0])==null?void 0:o.DataB64;return t.shouldDecodeBase64?this.base64Decode({DataB64:a}):a}));c(this,"asymmetricEncryption",t=>i(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t,!1),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricEncryption(e);return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"asymmetricDecryption",t=>i(this,null,function*(){var a,r;const e=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption({Data:t.Data,ContainerName:e==null?void 0:e.ContainerName});return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"sm4Encryption",t=>i(this,null,function*(){var s;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(t);return e==null?void 0:e[0]}));c(this,"sm4Decryption",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(t);return(a=e==null?void 0:e[0])==null?void 0:a.Data}));c(this,"getCertInfo",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(t);return $({},(a=e==null?void 0:e[0])!=null?a:{})}));c(this,"getCertInfoByOid",t=>i(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid($({},t!=null?t:{}));return(a=e==null?void 0:e[0])==null?void 0:a.OidValue}));return Z.instance&&!(t!=null&&t.isCreateNew)?Z.instance:(this.createGwsCore(t),Z.instance=this,this)}};c(Z,"instance",null);let N=Z;function oe(n){return new Promise((t,e)=>{if(N.instance&&!(n!=null&&n.isCreateNew))t(N.instance);else{const s=new N(I($({},n!=null?n:{}),{onOpen(a){var r;t(s),(r=n==null?void 0:n.onOpen)==null||r.call(n,a)},onClose(a){var r;e(a),(r=n==null?void 0:n.onClose)==null||r.call(n,a)}}))}})}D.GwsService=N,D.createService=oe,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gws-client",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "module": "dist/index.es.js",
6
6
  "main": "dist/index.cjs.js",