gws-client 1.0.2 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(S,k){typeof exports=="object"&&typeof module!="undefined"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(S=typeof globalThis!="undefined"?globalThis:S||self,k(S.GWS_CLIENT={}))})(this,function(S){"use strict";var ct=Object.defineProperty,lt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Ie=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ce=(S,k,$)=>k in S?ct(S,k,{enumerable:!0,configurable:!0,writable:!0,value:$}):S[k]=$,B=(S,k)=>{for(var $ in k||(k={}))dt.call(k,$)&&ce(S,$,k[$]);if(Ie)for(var $ of Ie(k))ht.call(k,$)&&ce(S,$,k[$]);return S},I=(S,k)=>lt(S,ut(k));var i=(S,k,$)=>ce(S,typeof k!="symbol"?k+"":k,$);var l=(S,k,$)=>new Promise((K,V)=>{var Y=E=>{try{T($.next(E))}catch(R){V(R)}},ee=E=>{try{T($.throw(E))}catch(R){V(R)}},T=E=>E.done?K(E.value):Promise.resolve(E.value).then(Y,ee);T(($=$.apply(S,k)).next())});const k=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",$="1",K="2";var V=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(V||{});const Y="00000001";function ee(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var T={},E;function R(){if(E)return T;E=1,T.byteLength=u,T.toByteArray=d,T.fromByteArray=p;for(var n=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,o=s.length;r<o;++r)n[r]=s[r],e[s.charCodeAt(r)]=r;e[45]=62,e[95]=63;function a(h){var c=h.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=h.indexOf("=");f===-1&&(f=c);var w=f===c?0:4-f%4;return[f,w]}function u(h){var c=a(h),f=c[0],w=c[1];return(f+w)*3/4-w}function y(h,c,f){return(c+f)*3/4-f}function d(h){var c,f=a(h),w=f[0],m=f[1],v=new t(y(h,w,m)),D=0,M=m>0?w-4:w,b;for(b=0;b<M;b+=4)c=e[h.charCodeAt(b)]<<18|e[h.charCodeAt(b+1)]<<12|e[h.charCodeAt(b+2)]<<6|e[h.charCodeAt(b+3)],v[D++]=c>>16&255,v[D++]=c>>8&255,v[D++]=c&255;return m===2&&(c=e[h.charCodeAt(b)]<<2|e[h.charCodeAt(b+1)]>>4,v[D++]=c&255),m===1&&(c=e[h.charCodeAt(b)]<<10|e[h.charCodeAt(b+1)]<<4|e[h.charCodeAt(b+2)]>>2,v[D++]=c>>8&255,v[D++]=c&255),v}function g(h){return n[h>>18&63]+n[h>>12&63]+n[h>>6&63]+n[h&63]}function C(h,c,f){for(var w,m=[],v=c;v<f;v+=3)w=(h[v]<<16&16711680)+(h[v+1]<<8&65280)+(h[v+2]&255),m.push(g(w));return m.join("")}function p(h){for(var c,f=h.length,w=f%3,m=[],v=16383,D=0,M=f-w;D<M;D+=v)m.push(C(h,D,D+v>M?M:D+v));return w===1?(c=h[f-1],m.push(n[c>>2]+n[c<<4&63]+"==")):w===2&&(c=(h[f-2]<<8)+h[f-1],m.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),m.join("")}return T}var Ae=R();const le=ee(Ae);class Ee{constructor(){i(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const s=this.deps.get(e);s&&s(t)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-oivou{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-oivou{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-oivou{background-color:#fff;padding:1.42857rem;border-radius:.35714rem;width:40%}.model-title.svelte-oivou{color:#303133;font-size:1.28571rem;margin-bottom:1.14286rem}.modal-visible.svelte-oivou{display:flex}.modal-footer.svelte-oivou{display:flex;align-items:center;justify-content:flex-end;margin-top:1.14286rem}.modal-btn.svelte-oivou{padding:.57143rem 1.07143rem;border-radius:.28571rem;font-size:1rem;border:.07143rem solid #dcdfe6}.success.svelte-oivou{margin-left:.85714rem;color:#fff}.slot.svelte-oivou{max-height:14.28571rem;overflow-y:scroll}.slot.svelte-oivou::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:1.14286rem;display:flex;align-items:center;cursor:pointer;border-bottom:.07143rem solid #ebeef5;font-size:1rem}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:.07143rem solid #ebeef5}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4{display:inline-block;color:#606266}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4:first-child{width:30%}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:12.85714rem;height:12.85714rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.07143rem solid #ccc;margin-top:.71429rem;margin-right:.71429rem;border-radius:.28571rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:7.14286rem;height:7.14286rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.71429rem;color:#333}")),document.head.appendChild(n)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var _e=Object.defineProperty,Le=(n,e,t)=>e in n?_e(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ue=(n,e,t)=>Le(n,typeof e!="symbol"?e+"":e,t);function te(){}function Pe(n,e){for(const t in e)n[t]=e[t];return n}function de(n){return n()}function he(){return Object.create(null)}function U(n){n.forEach(de)}function J(n){return typeof n=="function"}function ye(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Te(n){return Object.keys(n).length===0}function Me(n,e,t,s){if(n){const r=fe(n,e,t,s);return n[0](r)}}function fe(n,e,t,s){return n[1]&&s?Pe(t.ctx.slice(),n[1](s(e))):t.ctx}function He(n,e,t,s){if(n[2]&&s){const r=n[2](s(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const o=[],a=Math.max(e.dirty.length,r.length);for(let u=0;u<a;u+=1)o[u]=e.dirty[u]|r[u];return o}return e.dirty|r}return e.dirty}function Ge(n,e,t,s,r,o){if(r){const a=fe(e,t,s,o);n.p(a,r)}}function Fe(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let s=0;s<t;s++)e[s]=-1;return e}return-1}function ge(n){return n==null?"":n}function x(n,e){n.appendChild(e)}function ne(n,e,t){n.insertBefore(e,t||null)}function Q(n){n.parentNode&&n.parentNode.removeChild(n)}function je(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function _(n){return document.createElement(n)}function L(n){return document.createTextNode(n)}function W(){return L(" ")}function Ne(){return L("")}function z(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function A(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Oe(n){return Array.from(n.childNodes)}function G(n,e){e=""+e,n.data!==e&&(n.data=e)}function pe(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let se;function q(n){se=n}const F=[],me=[];let j=[];const Ce=[],Ze=Promise.resolve();let re=!1;function Ve(){re||(re=!0,Ze.then(ve))}function oe(n){j.push(n)}const ae=new Set;let N=0;function ve(){if(N!==0)return;const n=se;do{try{for(;N<F.length;){const e=F[N];N++,q(e),Re(e.$$)}}catch(e){throw F.length=0,N=0,e}for(q(null),F.length=0,N=0;me.length;)me.pop()();for(let e=0;e<j.length;e+=1){const t=j[e];ae.has(t)||(ae.add(t),t())}j.length=0}while(F.length);for(;Ce.length;)Ce.pop()();re=!1,ae.clear(),q(n)}function Re(n){if(n.fragment!==null){n.update(),U(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(oe)}}function Ue(n){const e=[],t=[];j.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),j=e}const X=new Set;let Je;function ie(n,e){n&&n.i&&(X.delete(n),n.i(e))}function we(n,e,t,s){if(n&&n.o){if(X.has(n))return;X.add(n),Je.c.push(()=>{X.delete(n)}),n.o(e)}}function ke(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function We(n){n&&n.c()}function be(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),oe(()=>{const o=n.$$.on_mount.map(de).filter(J);n.$$.on_destroy?n.$$.on_destroy.push(...o):U(o),n.$$.on_mount=[]}),r.forEach(oe)}function De(n,e){const t=n.$$;t.fragment!==null&&(Ue(t.after_update),U(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ze(n,e){n.$$.dirty[0]===-1&&(F.push(n),Ve(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Se(n,e,t,s,r,o,a=null,u=[-1]){const y=se;q(n);const d=n.$$={fragment:null,ctx:[],props:o,update:te,not_equal:r,bound:he(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(y?y.$$.context:[])),callbacks:he(),dirty:u,skip_bound:!1,root:e.target||y.$$.root};a&&a(d.root);let g=!1;if(d.ctx=t?t(n,e.props||{},(C,p,...h)=>{const c=h.length?h[0]:p;return d.ctx&&r(d.ctx[C],d.ctx[C]=c)&&(!d.skip_bound&&d.bound[C]&&d.bound[C](c),g&&ze(n,C)),p}):[],d.update(),g=!0,U(d.before_update),d.fragment=s?s(d.ctx):!1,e.target){if(e.hydrate){const C=Oe(e.target);d.fragment&&d.fragment.l(C),C.forEach(Q)}else d.fragment&&d.fragment.c();e.intro&&ie(n.$$.fragment),be(n,e.target,e.anchor),ve()}q(y)}class xe{constructor(){ue(this,"$$"),ue(this,"$$set")}$destroy(){De(this,1),this.$destroy=te}$on(e,t){if(!J(t))return te;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Te(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const qe="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(qe);function Ke(n){let e,t,s,r=(n[1]||"标题")+"",o,a,u,y,d,g,C=(n[4]||"取消")+"",p,h,c,f=(n[5]||"确认")+"",w,m,v,D;const M=n[8].default,b=Me(M,n,n[7],null);return{c(){e=_("div"),t=_("div"),s=_("div"),o=L(r),a=W(),u=_("div"),b&&b.c(),y=W(),d=_("div"),g=_("button"),p=L(C),h=W(),c=_("button"),w=L(f),A(s,"class","model-title svelte-oivou"),A(u,"class","slot svelte-oivou"),A(g,"class","modal-btn svelte-oivou"),A(c,"class","modal-btn success svelte-oivou"),pe(c,"background-color",n[6]),A(d,"class","modal-footer svelte-oivou"),A(t,"class","modal-content svelte-oivou"),A(e,"class","modal-background modal-visible svelte-oivou")},m(P,H){ne(P,e,H),x(e,t),x(t,s),x(s,o),x(t,a),x(t,u),b&&b.m(u,null),x(t,y),x(t,d),x(d,g),x(g,p),x(d,h),x(d,c),x(c,w),m=!0,v||(D=[z(g,"click",function(){J(n[0])&&n[0].apply(this,arguments)}),z(c,"click",function(){J(n[2])&&n[2].apply(this,arguments)}),z(t,"click",Qe),z(e,"click",function(){J(n[3])&&n[3].apply(this,arguments)})],v=!0)},p(P,[H]){n=P,(!m||H&2)&&r!==(r=(n[1]||"标题")+"")&&G(o,r),b&&b.p&&(!m||H&128)&&Ge(b,M,n,n[7],m?He(M,n[7],H,null):Fe(n[7]),null),(!m||H&16)&&C!==(C=(n[4]||"取消")+"")&&G(p,C),(!m||H&32)&&f!==(f=(n[5]||"确认")+"")&&G(w,f),(!m||H&64)&&pe(c,"background-color",n[6])},i(P){m||(ie(b,P),m=!0)},o(P){we(b,P),m=!1},d(P){P&&Q(e),b&&b.d(P),v=!1,U(D)}}}const Qe=n=>n.stopPropagation();function Xe(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:o}=e,{title:a}=e,{onOk:u}=e,{onClose:y}=e,{cancelText:d}=e,{okText:g}=e,{theme:C}=e;return n.$$set=p=>{"onCancel"in p&&t(0,o=p.onCancel),"title"in p&&t(1,a=p.title),"onOk"in p&&t(2,u=p.onOk),"onClose"in p&&t(3,y=p.onClose),"cancelText"in p&&t(4,d=p.cancelText),"okText"in p&&t(5,g=p.okText),"theme"in p&&t(6,C=p.theme),"$$scope"in p&&t(7,r=p.$$scope)},[o,a,u,y,d,g,C,r,s]}class Ye extends xe{constructor(e){super(),Se(this,e,Xe,Ke,ye,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function Be(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function $e(n){let e,t,s=n[11].CN+"",r,o,a,u=n[11].DevClass+"",y,d,g=n[11].sn+"",C,p,h,c,f,w;function m(){return n[10](n[13])}return{c(){e=_("div"),t=_("span"),r=L(s),o=W(),a=_("span"),y=L(u),d=L("("),C=L(g),p=L(")"),h=W(),A(t,"class","svelte-jtc2v4"),A(a,"class","svelte-jtc2v4"),A(e,"class",c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(v,D){ne(v,e,D),x(e,t),x(t,r),x(e,o),x(e,a),x(a,y),x(a,d),x(a,C),x(a,p),x(e,h),f||(w=z(e,"click",m),f=!0)},p(v,D){n=v,D&1&&s!==(s=n[11].CN+"")&&G(r,s),D&1&&u!==(u=n[11].DevClass+"")&&G(y,u),D&1&&g!==(g=n[11].sn+"")&&G(C,g),D&32&&c!==(c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&A(e,"class",c)},d(v){v&&Q(e),f=!1,w()}}}function et(n){let e,t=ke(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=$e(Be(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Ne()},m(r,o){for(let a=0;a<s.length;a+=1)s[a]&&s[a].m(r,o);ne(r,e,o)},p(r,o){if(o&33){t=ke(r[0]);let a;for(a=0;a<t.length;a+=1){const u=Be(r,t,a);s[a]?s[a].p(u,o):(s[a]=$e(u),s[a].c(),s[a].m(e.parentNode,e))}for(;a<s.length;a+=1)s[a].d(1);s.length=t.length}},d(r){r&&Q(e),je(s,r)}}}function tt(n){let e,t;return e=new Ye({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[et]},$$scope:{ctx:n}}}),{c(){We(e.$$.fragment)},m(s,r){be(e,s,r),t=!0},p(s,[r]){const o={};r&2&&(o.onClose=s[1]),r&4&&(o.cancelText=s[2]),r&8&&(o.okText=s[3]),r&16&&(o.theme=s[4]),r&16417&&(o.$$scope={dirty:r,ctx:s}),e.$set(o)},i(s){t||(ie(e.$$.fragment,s),t=!0)},o(s){we(e.$$.fragment,s),t=!1},d(s){De(e,s)}}}function nt(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:o}=e,{onClose:a}=e,{cancelText:u=""}=e,{okText:y=""}=e,{theme:d="#409eff"}=e,g=0;const C=()=>{r("未选择证书"),a==null||a()},p=()=>{o==null||o(s[g]),a==null||a()},h=c=>t(5,g=c);return n.$$set=c=>{"certList"in c&&t(0,s=c.certList),"onCancel"in c&&t(8,r=c.onCancel),"onOk"in c&&t(9,o=c.onOk),"onClose"in c&&t(1,a=c.onClose),"cancelText"in c&&t(2,u=c.cancelText),"okText"in c&&t(3,y=c.okText),"theme"in c&&t(4,d=c.theme)},[s,a,u,y,d,g,C,p,r,o,h]}class st extends xe{constructor(e){super(),Se(this,e,nt,tt,ye,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class rt{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new st({target:document.body,props:I(B({},e),{onCancel:r=>{s({code:-1,msg:r})},onOk:r=>{t(r)},onClose:()=>{this.close()}})})}));i(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const ot=new rt;class at{constructor(e){i(this,"socketInstance",null);i(this,"eventBus",new Ee);i(this,"isRememberPin",!1);i(this,"pinPolicy");i(this,"socketConfig",null);i(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});i(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});i(this,"sendMessage",(e,t)=>new Promise((s,r)=>{var a,u;if(((a=this.socketInstance)==null?void 0:a.readyState)!==WebSocket.OPEN){r({errCode:-1,msg:"数字证书客户端连接失败"});return}const o={function:e,args:[t!=null?t:{}]};(u=this.socketInstance)==null||u.send(JSON.stringify(o)),this.eventBus.on(e,y=>{y.success?s(y.data):r(y)})}));i(this,"handleEventData",e=>l(this,null,function*(){var t,s,r,o,a,u,y,d,g,C;if(e.data instanceof Blob){const p=yield e.data.arrayBuffer(),c=new TextDecoder("gbk").decode(p),f=JSON.parse(c),w={success:(t=f.result)==null?void 0:t.success,msg:(s=f.result)==null?void 0:s.msg,errCode:(r=f.result)==null?void 0:r.errCode,data:f.data},m=(o=f.result)==null?void 0:o.function;m==="GZCA_OnDeviceChange"?(d=(a=this.socketConfig)==null?void 0:a.onUkeyChange)==null||d.call(a,I(B({},w),{type:(u=f.result)==null?void 0:u.event,data:(y=f.data)==null?void 0:y[0]})):this.eventBus.emit(m,w),(C=(g=this.socketConfig)==null?void 0:g.onMessage)==null||C.call(g,w)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return le.fromByteArray(t)});i(this,"base64Decode",e=>{const t=le.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>l(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>l(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:Y})}));i(this,"certLogin",e=>l(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));i(this,"getCert",(e,t)=>l(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&(yield this.certLogin(s.ContainerName)),s}));i(this,"chooseCert",e=>l(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield ot.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"getCertList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"pkcs1Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",B({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));var t,s;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(s=e.pinPolicy)!=null?s:V.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=s=>{var r;(r=e.onError)==null||r.call(e,s)},t.onopen=s=>{var r;(r=e.onOpen)==null||r.call(e,s),e.onUkeyChange&&this.addUkeyEvents()},t.onmessage=s=>{this.handleEventData(s)},t.onclose=s=>{var r;(r=e.onClose)==null||r.call(e,s)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const Z=class Z{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new at(I(B({},e!=null?e:{}),{url:k}))});i(this,"appendCertBase64",(e,t=!0)=>l(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return I(B({},e!=null?e:{}),{CertB64:s==null?void 0:s.CertB64})}));i(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});i(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});i(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});i(this,"getSignatureCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:$},e)}));i(this,"getSignatureCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:$})}));i(this,"getEncryptionCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:K},e)}));i(this,"getEncryptionCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:K})}));i(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});i(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});i(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});i(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});i(this,"pkcs1Sign",(e,t)=>l(this,null,function*(){var o,a,u;const s=yield this.getSignatureCert(t),r=yield(a=this.coreInstance)==null?void 0:a.pkcs1Sign(I(B({},e!=null?e:{}),{ContainerName:(o=s==null?void 0:s.ContainerName)!=null?o:""}));return(u=r==null?void 0:r[0])==null?void 0:u.SignData}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){var r;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(s)}));i(this,"pkcs1Base64Sign",(e,t)=>l(this,null,function*(){var a,u,y,d,g;const s=yield this.getSignatureCert(t),r=(u=e.DataB64)!=null?u:this.base64Encode({Data:(a=e.Data)!=null?a:""}),o=yield(d=this.coreInstance)==null?void 0:d.pkcs1Base64Sign(I(B({},e!=null?e:{}),{ContainerName:(y=s==null?void 0:s.ContainerName)!=null?y:"",DataB64:r}));return(g=o==null?void 0:o[0])==null?void 0:g.SignData}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){var o,a,u;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.appendCertBase64(e);return!!(yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",e=>l(this,null,function*(){var r,o;const t=yield this.getSignatureCert(e),s=yield(o=this.coreInstance)==null?void 0:o.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:""});return{cert:t,sealList:s}}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(o=s==null?void 0:s[0])==null?void 0:o.Z}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){var o,a;const t=this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.appendCertBase64(e),r=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:t});return r==null?void 0:r[0].H}));i(this,"pkcs1HashSign",(e,t)=>l(this,null,function*(){var o,a,u,y;const s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1HashSign({ContainerName:(o=s==null?void 0:s.ContainerName)!=null?o:"",DataB64:e.DataB64,HashAlg:(a=e.HashAlg)!=null?a:"sm3"});return(y=r==null?void 0:r[0])==null?void 0:y.SignData}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e);return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs1HashVerifySignature(I(B({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var a,u,y,d,g;const s=(u=e.DataB64)!=null?u:this.base64Encode({Data:(a=e.Data)!=null?a:""}),r=yield this.getSignatureCert(t),o=yield(d=this.coreInstance)==null?void 0:d.pkcs7Sign(I(B({},e!=null?e:{}),{ContainerName:(y=r==null?void 0:r.ContainerName)!=null?y:"",DataB64:s}));return(g=o==null?void 0:o[0])==null?void 0:g.SignData}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){var r,o,a;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));i(this,"sm3Hash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HexHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3FileHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){var o,a,u,y,d,g;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=(y=e.KeyB64)!=null?y:this.base64Encode({Data:(u=e.Key)!=null?u:""}),r=yield(d=this.coreInstance)==null?void 0:d.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(g=r==null?void 0:r[0])==null?void 0:g.DataB64}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){var r,o,a,u;if(!e.CertB64List){const y=yield this.getEncryptionCert();e.CertB64List=y==null?void 0:y.CertB64}const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),s=yield(a=this.coreInstance)==null?void 0:a.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(u=s==null?void 0:s[0])==null?void 0:u.DataB64}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){var o,a;const t=yield this.getEncryptionCert(),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Decryption(I(B({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),r=(a=s==null?void 0:s[0])==null?void 0:a.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:r}):r}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e,!1),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(o=s==null?void 0:s[0])==null?void 0:o.Data}));i(this,"asymmetricDecryption",(e,t)=>l(this,null,function*(){var o,a;const s=yield this.getEncryptionCert(t),r=yield(o=this.coreInstance)==null?void 0:o.asymmetricDecryption(I(B({},e!=null?e:{}),{ContainerName:s==null?void 0:s.ContainerName}));return(a=r==null?void 0:r[0])==null?void 0:a.Data}));i(this,"sm4Encryption",e=>l(this,null,function*(){var s;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(e);return t==null?void 0:t[0]}));i(this,"sm4Decryption",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(e);return(r=t==null?void 0:t[0])==null?void 0:r.Data}));i(this,"getCertInfo",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e);return B({},(r=t==null?void 0:t[0])!=null?r:{})}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid(B({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return Z.instance&&!(e!=null&&e.isCreateNew)?Z.instance:(this.createGwsCore(e),Z.instance=this,this)}};i(Z,"instance",null);let O=Z;function it(n){return new Promise((e,t)=>{if(O.instance&&!(n!=null&&n.isCreateNew))e(O.instance);else{const s=new O(I(B({},n!=null?n:{}),{onOpen(r){var o;e(s),(o=n==null?void 0:n.onOpen)==null||o.call(n,r)},onClose(r){var o;t(r),(o=n==null?void 0:n.onClose)==null||o.call(n,r)}}))}})}S.GwsService=O,S.createService=it,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
1
+ (function(B,v){typeof exports=="object"&&typeof module!="undefined"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(B=typeof globalThis!="undefined"?globalThis:B||self,v(B.GWS_CLIENT={}))})(this,function(B){"use strict";var yt=Object.defineProperty,ft=Object.defineProperties;var Ct=Object.getOwnPropertyDescriptors;var Le=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable;var ue=(B,v,b)=>v in B?yt(B,v,{enumerable:!0,configurable:!0,writable:!0,value:b}):B[v]=b,p=(B,v)=>{for(var b in v||(v={}))mt.call(v,b)&&ue(B,b,v[b]);if(Le)for(var b of Le(v))wt.call(v,b)&&ue(B,b,v[b]);return B},x=(B,v)=>ft(B,Ct(v));var o=(B,v,b)=>ue(B,typeof v!="symbol"?v+"":v,b);var l=(B,v,b)=>new Promise((K,V)=>{var se=A=>{try{_(b.next(A))}catch(j){V(j)}},re=A=>{try{_(b.throw(A))}catch(j){V(j)}},_=A=>A.done?K(A.value):Promise.resolve(A.value).then(se,re);_((b=b.apply(B,v)).next())});const v=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",b="1",K="2";var V=(s=>(s.MIN="0",s.LOW="1",s.MIDDLE="2",s.HIGH="3",s))(V||{});const se="00000001";function re(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var _={},A;function j(){if(A)return _;A=1,_.byteLength=c,_.toByteArray=d,_.fromByteArray=m;for(var s=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,a=n.length;r<a;++r)s[r]=n[r],e[n.charCodeAt(r)]=r;e[45]=62,e[95]=63;function i(h){var y=h.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var w=h.indexOf("=");w===-1&&(w=y);var g=w===y?0:4-w%4;return[w,g]}function c(h){var y=i(h),w=y[0],g=y[1];return(w+g)*3/4-g}function u(h,y,w){return(y+w)*3/4-w}function d(h){var y,w=i(h),g=w[0],S=w[1],I=new t(u(h,g,S)),D=0,T=S>0?g-4:g,k;for(k=0;k<T;k+=4)y=e[h.charCodeAt(k)]<<18|e[h.charCodeAt(k+1)]<<12|e[h.charCodeAt(k+2)]<<6|e[h.charCodeAt(k+3)],I[D++]=y>>16&255,I[D++]=y>>8&255,I[D++]=y&255;return S===2&&(y=e[h.charCodeAt(k)]<<2|e[h.charCodeAt(k+1)]>>4,I[D++]=y&255),S===1&&(y=e[h.charCodeAt(k)]<<10|e[h.charCodeAt(k+1)]<<4|e[h.charCodeAt(k+2)]>>2,I[D++]=y>>8&255,I[D++]=y&255),I}function C(h){return s[h>>18&63]+s[h>>12&63]+s[h>>6&63]+s[h&63]}function f(h,y,w){for(var g,S=[],I=y;I<w;I+=3)g=(h[I]<<16&16711680)+(h[I+1]<<8&65280)+(h[I+2]&255),S.push(C(g));return S.join("")}function m(h){for(var y,w=h.length,g=w%3,S=[],I=16383,D=0,T=w-g;D<T;D+=I)S.push(f(h,D,D+I>T?T:D+I));return g===1?(y=h[w-1],S.push(s[y>>2]+s[y<<4&63]+"==")):g===2&&(y=(h[w-2]<<8)+h[w-1],S.push(s[y>>10]+s[y>>4&63]+s[y<<2&63]+"=")),S.join("")}return _}var Te=j();const he=re(Te);class Me{constructor(){o(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const n=this.deps.get(e);n==null||n(t)}}(function(){try{var s=document.createElement("style");s.appendChild(document.createTextNode("button.svelte-16iv9d0{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-16iv9d0{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-16iv9d0{background-color:#fff;padding:1.25rem;border-radius:.3125rem;width:40%}.model-title.svelte-16iv9d0{color:#303133;font-size:1.125rem;margin-bottom:1.125rem}.modal-visible.svelte-16iv9d0{display:flex}.modal-footer.svelte-16iv9d0{display:flex;align-items:center;justify-content:flex-end;margin-top:1rem}.modal-btn.svelte-16iv9d0{padding:.5rem .9375rem;border-radius:.25rem;font-size:.875rem;border:.0625rem solid #dcdfe6}.success.svelte-16iv9d0{margin-left:.75rem;color:#fff}.slot.svelte-16iv9d0{max-height:12.5rem;overflow-y:scroll}.slot.svelte-16iv9d0::-webkit-scrollbar{display:none}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:11.25rem;height:11.25rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.0625rem solid #ccc;margin-top:.625rem;margin-right:.625rem;border-radius:.25rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:6.25rem;height:6.25rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.625rem;color:#333}.cert-item.svelte-1kh75ag.svelte-1kh75ag{padding:1rem;display:flex;align-items:center;cursor:pointer;border-bottom:.0625rem solid #ebeef5;font-size:1rem}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag{word-break:break-all;color:#373a40}.cert-item.svelte-1kh75ag>div.svelte-1kh75ag:nth-child(1){padding-right:.5rem}.cert-item-selected.svelte-1kh75ag.svelte-1kh75ag{background-color:#f1f1f1}.cert-item-first.svelte-1kh75ag.svelte-1kh75ag{border-top:.0625rem solid #ebeef5}")),document.head.appendChild(s)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Ne=Object.defineProperty,Ge=(s,e,t)=>e in s?Ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ge=(s,e,t)=>Ge(s,typeof e!="symbol"?e+"":e,t);function ae(){}function Fe(s,e){for(const t in e)s[t]=e[t];return s}function ye(s){return s()}function fe(){return Object.create(null)}function U(s){s.forEach(ye)}function z(s){return typeof s=="function"}function Ce(s,e){return s!=s?e==e:s!==e||s&&typeof s=="object"||typeof s=="function"}function He(s){return Object.keys(s).length===0}function Ze(s,e,t,n){if(s){const r=me(s,e,t,n);return s[0](r)}}function me(s,e,t,n){return s[1]&&n?Fe(t.ctx.slice(),s[1](n(e))):t.ctx}function Oe(s,e,t,n){if(s[2]&&n){const r=s[2](n(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const a=[],i=Math.max(e.dirty.length,r.length);for(let c=0;c<i;c+=1)a[c]=e.dirty[c]|r[c];return a}return e.dirty|r}return e.dirty}function Ve(s,e,t,n,r,a){if(r){const i=me(e,t,n,a);s.p(i,r)}}function je(s){if(s.ctx.length>32){const e=[],t=s.ctx.length/32;for(let n=0;n<t;n++)e[n]=-1;return e}return-1}function we(s){return s==null?"":s}function E(s,e){s.appendChild(e)}function Y(s,e,t){s.insertBefore(e,t||null)}function J(s){s.parentNode&&s.parentNode.removeChild(s)}function pe(s,e){for(let t=0;t<s.length;t+=1)s[t]&&s[t].d(e)}function L(s){return document.createElement(s)}function N(s){return document.createTextNode(s)}function R(){return N(" ")}function Ue(){return N("")}function W(s,e,t,n){return s.addEventListener(e,t,n),()=>s.removeEventListener(e,t,n)}function P(s,e,t){t==null?s.removeAttribute(e):s.getAttribute(e)!==t&&s.setAttribute(e,t)}function ze(s){return Array.from(s.childNodes)}function Q(s,e){e=""+e,s.data!==e&&(s.data=e)}function X(s,e,t,n){t==null?s.style.removeProperty(e):s.style.setProperty(e,t,"")}let ie;function q(s){ie=s}const G=[],Se=[];let F=[];const ve=[],Je=Promise.resolve();let oe=!1;function We(){oe||(oe=!0,Je.then(ke))}function ce(s){F.push(s)}const le=new Set;let H=0;function ke(){if(H!==0)return;const s=ie;do{try{for(;H<G.length;){const e=G[H];H++,q(e),qe(e.$$)}}catch(e){throw G.length=0,H=0,e}for(q(null),G.length=0,H=0;Se.length;)Se.pop()();for(let e=0;e<F.length;e+=1){const t=F[e];le.has(t)||(le.add(t),t())}F.length=0}while(G.length);for(;ve.length;)ve.pop()();oe=!1,le.clear(),q(s)}function qe(s){if(s.fragment!==null){s.update(),U(s.before_update);const e=s.dirty;s.dirty=[-1],s.fragment&&s.fragment.p(s.ctx,e),s.after_update.forEach(ce)}}function Ke(s){const e=[],t=[];F.forEach(n=>s.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),F=e}const ee=new Set;let Ye;function de(s,e){s&&s.i&&(ee.delete(s),s.i(e))}function Ie(s,e,t,n){if(s&&s.o){if(ee.has(s))return;ee.add(s),Ye.c.push(()=>{ee.delete(s)}),s.o(e)}}function te(s){return(s==null?void 0:s.length)!==void 0?s:Array.from(s)}function Re(s){s&&s.c()}function Be(s,e,t){const{fragment:n,after_update:r}=s.$$;n&&n.m(e,t),ce(()=>{const a=s.$$.on_mount.map(ye).filter(z);s.$$.on_destroy?s.$$.on_destroy.push(...a):U(a),s.$$.on_mount=[]}),r.forEach(ce)}function be(s,e){const t=s.$$;t.fragment!==null&&(Ke(t.after_update),U(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Qe(s,e){s.$$.dirty[0]===-1&&(G.push(s),We(),s.$$.dirty.fill(0)),s.$$.dirty[e/31|0]|=1<<e%31}function De(s,e,t,n,r,a,i=null,c=[-1]){const u=ie;q(s);const d=s.$$={fragment:null,ctx:[],props:a,update:ae,not_equal:r,bound:fe(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(u?u.$$.context:[])),callbacks:fe(),dirty:c,skip_bound:!1,root:e.target||u.$$.root};i&&i(d.root);let C=!1;if(d.ctx=t?t(s,e.props||{},(f,m,...h)=>{const y=h.length?h[0]:m;return d.ctx&&r(d.ctx[f],d.ctx[f]=y)&&(!d.skip_bound&&d.bound[f]&&d.bound[f](y),C&&Qe(s,f)),m}):[],d.update(),C=!0,U(d.before_update),d.fragment=n?n(d.ctx):!1,e.target){if(e.hydrate){const f=ze(e.target);d.fragment&&d.fragment.l(f),f.forEach(J)}else d.fragment&&d.fragment.c();e.intro&&de(s.$$.fragment),Be(s,e.target,e.anchor),ke()}q(u)}class xe{constructor(){ge(this,"$$"),ge(this,"$$set")}$destroy(){be(this,1),this.$destroy=ae}$on(e,t){if(!z(t))return ae;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const r=n.indexOf(t);r!==-1&&n.splice(r,1)}}$set(e){this.$$set&&!He(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Xe="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Xe);function et(s){let e,t,n,r=(s[1]||"标题")+"",a,i,c,u,d,C,f=(s[4]||"取消")+"",m,h,y,w=(s[5]||"确认")+"",g,S,I,D;const T=s[8].default,k=Ze(T,s,s[7],null);return{c(){e=L("div"),t=L("div"),n=L("div"),a=N(r),i=R(),c=L("div"),k&&k.c(),u=R(),d=L("div"),C=L("button"),m=N(f),h=R(),y=L("button"),g=N(w),P(n,"class","model-title svelte-16iv9d0"),P(c,"class","slot svelte-16iv9d0"),P(C,"class","modal-btn svelte-16iv9d0"),P(y,"class","modal-btn success svelte-16iv9d0"),X(y,"background-color",s[6]),P(d,"class","modal-footer svelte-16iv9d0"),P(t,"class","modal-content svelte-16iv9d0"),P(e,"class","modal-background modal-visible svelte-16iv9d0")},m($,M){Y($,e,M),E(e,t),E(t,n),E(n,a),E(t,i),E(t,c),k&&k.m(c,null),E(t,u),E(t,d),E(d,C),E(C,m),E(d,h),E(d,y),E(y,g),S=!0,I||(D=[W(C,"click",function(){z(s[0])&&s[0].apply(this,arguments)}),W(y,"click",function(){z(s[2])&&s[2].apply(this,arguments)}),W(t,"click",tt),W(e,"click",function(){z(s[3])&&s[3].apply(this,arguments)})],I=!0)},p($,[M]){s=$,(!S||M&2)&&r!==(r=(s[1]||"标题")+"")&&Q(a,r),k&&k.p&&(!S||M&128)&&Ve(k,T,s,s[7],S?Oe(T,s[7],M,null):je(s[7]),null),(!S||M&16)&&f!==(f=(s[4]||"取消")+"")&&Q(m,f),(!S||M&32)&&w!==(w=(s[5]||"确认")+"")&&Q(g,w),(!S||M&64)&&X(y,"background-color",s[6])},i($){S||(de(k,$),S=!0)},o($){Ie(k,$),S=!1},d($){$&&J(e),k&&k.d($),I=!1,U(D)}}}const tt=s=>s.stopPropagation();function nt(s,e,t){let{$$slots:n={},$$scope:r}=e,{onCancel:a}=e,{title:i}=e,{onOk:c}=e,{onClose:u}=e,{cancelText:d}=e,{okText:C}=e,{theme:f}=e;return s.$$set=m=>{"onCancel"in m&&t(0,a=m.onCancel),"title"in m&&t(1,i=m.title),"onOk"in m&&t(2,c=m.onOk),"onClose"in m&&t(3,u=m.onClose),"cancelText"in m&&t(4,d=m.cancelText),"okText"in m&&t(5,C=m.okText),"theme"in m&&t(6,f=m.theme),"$$scope"in m&&t(7,r=m.$$scope)},[a,i,c,u,d,C,f,r,n]}class st extends xe{constructor(e){super(),De(this,e,nt,et,Ce,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function Ee(s,e,t){const n=s.slice();return n[13]=e[t],n[15]=t,n}function Ae(s,e,t){const n=s.slice();return n[16]=e[t],n}function Pe(s){let e,t=(s[16].format?s[16].format(s[13]):s[13][s[16].key])+"",n;return{c(){e=L("div"),n=N(t),P(e,"class","svelte-1kh75ag"),X(e,"width",`${100/s[1].length}%`)},m(r,a){Y(r,e,a),E(e,n)},p(r,a){a&3&&t!==(t=(r[16].format?r[16].format(r[13]):r[13][r[16].key])+"")&&Q(n,t),a&2&&X(e,"width",`${100/r[1].length}%`)},d(r){r&&J(e)}}}function $e(s){let e,t,n,r,a,i=te(s[1]),c=[];for(let d=0;d<i.length;d+=1)c[d]=Pe(Ae(s,i,d));function u(){return s[12](s[15])}return{c(){e=L("div");for(let d=0;d<c.length;d+=1)c[d].c();t=R(),P(e,"class",n=we(`cert-item ${s[15]===0?"cert-item-first":""} ${s[15]===s[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")},m(d,C){Y(d,e,C);for(let f=0;f<c.length;f+=1)c[f]&&c[f].m(e,null);E(e,t),r||(a=W(e,"click",u),r=!0)},p(d,C){if(s=d,C&3){i=te(s[1]);let f;for(f=0;f<i.length;f+=1){const m=Ae(s,i,f);c[f]?c[f].p(m,C):(c[f]=Pe(m),c[f].c(),c[f].m(e,t))}for(;f<c.length;f+=1)c[f].d(1);c.length=i.length}C&128&&n!==(n=we(`cert-item ${s[15]===0?"cert-item-first":""} ${s[15]===s[7]?"cert-item-selected":""}`)+" svelte-1kh75ag")&&P(e,"class",n)},d(d){d&&J(e),pe(c,d),r=!1,a()}}}function rt(s){let e,t=te(s[0]),n=[];for(let r=0;r<t.length;r+=1)n[r]=$e(Ee(s,t,r));return{c(){for(let r=0;r<n.length;r+=1)n[r].c();e=Ue()},m(r,a){for(let i=0;i<n.length;i+=1)n[i]&&n[i].m(r,a);Y(r,e,a)},p(r,a){if(a&131){t=te(r[0]);let i;for(i=0;i<t.length;i+=1){const c=Ee(r,t,i);n[i]?n[i].p(c,a):(n[i]=$e(c),n[i].c(),n[i].m(e.parentNode,e))}for(;i<n.length;i+=1)n[i].d(1);n.length=t.length}},d(r){r&&J(e),pe(n,r)}}}function at(s){let e,t;return e=new st({props:{onOk:s[9],onClose:s[2],onCancel:s[8],cancelText:s[3],okText:s[4],title:s[6],theme:s[5],$$slots:{default:[rt]},$$scope:{ctx:s}}}),{c(){Re(e.$$.fragment)},m(n,r){Be(e,n,r),t=!0},p(n,[r]){const a={};r&4&&(a.onClose=n[2]),r&8&&(a.cancelText=n[3]),r&16&&(a.okText=n[4]),r&64&&(a.title=n[6]),r&32&&(a.theme=n[5]),r&524419&&(a.$$scope={dirty:r,ctx:n}),e.$set(a)},i(n){t||(de(e.$$.fragment,n),t=!0)},o(n){Ie(e.$$.fragment,n),t=!1},d(n){be(e,n)}}}function it(s,e,t){let{data:n=[]}=e,{columns:r=[]}=e,{onCancel:a}=e,{onOk:i}=e,{onClose:c}=e,{cancelText:u=""}=e,{okText:d=""}=e,{theme:C="#409eff"}=e,{title:f=""}=e,m=0;const h=()=>{a(`${f}失败`),c==null||c()},y=()=>{i==null||i(n[m]),c==null||c()},w=g=>t(7,m=g);return s.$$set=g=>{"data"in g&&t(0,n=g.data),"columns"in g&&t(1,r=g.columns),"onCancel"in g&&t(10,a=g.onCancel),"onOk"in g&&t(11,i=g.onOk),"onClose"in g&&t(2,c=g.onClose),"cancelText"in g&&t(3,u=g.cancelText),"okText"in g&&t(4,d=g.okText),"theme"in g&&t(5,C=g.theme),"title"in g&&t(6,f=g.title)},[n,r,c,u,d,C,f,m,h,y,a,i,w]}class ot extends xe{constructor(e){super(),De(this,e,it,at,Ce,{data:0,columns:1,onCancel:10,onOk:11,onClose:2,cancelText:3,okText:4,theme:5,title:6})}}class ct{constructor(){o(this,"modalInstance",{current:null});o(this,"open",e=>new Promise((t,n)=>{this.modalInstance.current=new ot({target:document.body,props:x(p({},e),{onCancel:r=>{n({code:-1,msg:r})},onOk:r=>{t(r)},onClose:()=>{this.close()}})})}));o(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const ne=new ct;function lt(s=32,e=!0,t=0){const n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=[];if(t=t||n.length,s)for(let a=0;a<s;a++)r[a]=n[0|Math.random()*t];else{let a;r[8]=r[13]=r[18]=r[23]="-",r[14]="4";for(let i=0;i<36;i++)r[i]||(a=0|Math.random()*16,r[i]=n[i===19?a&3|8:a])}return e?(r.shift(),`u${r.join("")}`):r.join("")}const dt=[{key:"CN"},{format:s=>`${s.DevClass}(${s.sn})`}],ut=[{key:"SealId"},{key:"Vid"},{format:s=>`${s.FileName}(${s.FileSize}B)`}],_e=[{key:"SealId"}];class ht{constructor(e){o(this,"socketInstance",null);o(this,"eventBus",new Me);o(this,"isRememberPin",!1);o(this,"pinPolicy");o(this,"socketConfig",null);o(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});o(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});o(this,"sendMessage",(e,t)=>new Promise((n,r)=>{var u,d;if(((u=this.socketInstance)==null?void 0:u.readyState)!==WebSocket.OPEN){r({errCode:-1,msg:"数字证书客户端连接失败"});return}const a=lt(),i=C=>{C.success?n(C.data):r(C)},c={function:e,args:[t!=null?t:{}],msgid:a};(d=this.socketInstance)==null||d.send(JSON.stringify(c)),this.eventBus.on(e,i),this.eventBus.on(a,i)}));o(this,"handleEventData",e=>l(this,null,function*(){var t,n,r,a,i,c,u,d;if(e.data instanceof Blob){const C=yield e.data.arrayBuffer(),m=new TextDecoder("gbk").decode(C),h=JSON.parse(m),y={success:(t=h.result)==null?void 0:t.success,msg:(n=h.result)==null?void 0:n.msg,errCode:(r=h.result)==null?void 0:r.errCode,data:h.data,type:(a=h.result)==null?void 0:a.event},w=(i=h.result)==null?void 0:i.function,g=(c=h.result)==null?void 0:c.msgid;g?this.eventBus.emit(g,y):this.eventBus.emit(w,y),(d=(u=this.socketConfig)==null?void 0:u.onMessage)==null||d.call(u,y)}}));o(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return he.fromByteArray(t)});o(this,"base64Decode",e=>{const t=he.toByteArray(e);return new TextDecoder().decode(t)});o(this,"changeIsRememberPin",e=>l(this,null,function*(){this.isRememberPin=e}));o(this,"changePinPolicy",e=>l(this,null,function*(){this.pinPolicy=e}));o(this,"checkCertIsLogin",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));o(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:se}),this.eventBus.on("GZCA_OnDeviceChange",e=>{var t,n,r;(r=(t=this.socketConfig)==null?void 0:t.onUkeyChange)==null||r.call(t,x(p({},e),{data:(n=e.data)==null?void 0:n[0]}))})}));o(this,"certLogin",e=>l(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));o(this,"getCert",(e,t,n)=>l(this,null,function*(){const r=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&n&&(yield this.certLogin(r.ContainerName)),r}));o(this,"chooseCert",e=>l(this,null,function*(){var r;const t=yield this.getCertList(e);return t!=null&&t.length?(t==null?void 0:t.length)===1?t[0]:yield ne.open({title:"选择证书",data:t,columns:dt,theme:(r=this.socketConfig)==null?void 0:r.theme}):Promise.reject({errCode:-1,msg:"暂无证书"})}));o(this,"getCertList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));o(this,"pkcs1Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",p({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",p({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"batchPkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_BatchPkcs1SignDataEx",p({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));o(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));o(this,"getSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"writeSeal",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_WriteSeal",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"deleteSeal",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DeleteSeal",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"getSealInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_ReadSeal",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"getTPSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetSealPicList",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"getTPSealPic",e=>l(this,null,function*(){var n;return yield this.sendMessage("GZCA_GetSealPicData",p({IsLogin:(n=e.IsLogin)!=null?n:this.getIsLogin()},e!=null?e:{}))}));o(this,"sm2SignPreprocess1",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));o(this,"sm2SignPreprocess2",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));o(this,"pkcs1HashSign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",p({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));o(this,"pkcs7Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",p({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));o(this,"pkcs7VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));o(this,"sm3Hash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));o(this,"sm3HexHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));o(this,"sm3FileHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));o(this,"sm3HashEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));o(this,"pkcs7Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));o(this,"pkcs7Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"pkcs7FileEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeSealFileEx_qyzc",e)}));o(this,"pkcs7FileDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnvelopeOpenFileEx_qyzc",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"asymmetricEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));o(this,"asymmetricDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));o(this,"sm4Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));o(this,"sm4Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));o(this,"getCertInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));o(this,"getCertInfoByOid",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));o(this,"getSealVendor",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetSealIssuer",e)}));o(this,"deleteAllSealByVendor",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_ClearSeal",p({IsLogin:this.getIsLogin()},e!=null?e:{}))}));var t,n;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(n=e.pinPolicy)!=null?n:V.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=n=>{var r;(r=e.onError)==null||r.call(e,n)},t.onopen=n=>{var r;(r=e.onOpen)==null||r.call(e,n),e.onUkeyChange&&this.addUkeyEvents()},t.onmessage=n=>{this.handleEventData(n)},t.onclose=n=>{var r;(r=e.onClose)==null||r.call(e,n)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const O=class O{constructor(e){o(this,"coreInstance",null);o(this,"gwsConfig",{});o(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ht(x(p({},e!=null?e:{}),{url:v}))});o(this,"appendCertBase64",(e,t=!0)=>l(this,null,function*(){if(e.CertB64)return e;const n=t?yield this.getSignatureCert():yield this.getEncryptionCert();return x(p({},e!=null?e:{}),{CertB64:n==null?void 0:n.CertB64})}));o(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});o(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});o(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});o(this,"getSignatureCert",(e,t=!0)=>l(this,null,function*(){var r;return yield(r=this.coreInstance)==null?void 0:r.getCert({CertType:b},e,t)}));o(this,"getSignatureCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:b})}));o(this,"getEncryptionCert",(e,t=!0)=>l(this,null,function*(){var r;return yield(r=this.coreInstance)==null?void 0:r.getCert({CertType:K},e,t)}));o(this,"getEncryptionCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:K})}));o(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});o(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});o(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});o(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});o(this,"pkcs1Sign",(e,t)=>l(this,null,function*(){var a,i,c;const n=yield this.getSignatureCert(t),r=yield(i=this.coreInstance)==null?void 0:i.pkcs1Sign(x(p({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""}));return(c=r==null?void 0:r[0])==null?void 0:c.SignData}));o(this,"pkcs1VerifySignature",e=>l(this,null,function*(){var r;const t=yield this.appendCertBase64(e),n=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(n)}));o(this,"pkcs1Base64Sign",(e,t)=>l(this,null,function*(){var i,c,u,d,C;const n=yield this.getSignatureCert(t),r=(c=e.DataB64)!=null?c:this.base64Encode({Data:(i=e.Data)!=null?i:""}),a=yield(d=this.coreInstance)==null?void 0:d.pkcs1Base64Sign(x(p({},e!=null?e:{}),{ContainerName:(u=n==null?void 0:n.ContainerName)!=null?u:"",DataB64:r}));return(C=a==null?void 0:a[0])==null?void 0:C.SignData}));o(this,"batchPkcs1Base64Sign",(e,t)=>l(this,null,function*(){var C,f,m,h,y,w;const n="|",r=(f=e.DataB64)!=null?f:(C=e.Data)==null?void 0:C.map(g=>this.base64Encode({Data:g})),a=yield this.getSignatureCert(t);let i="";i=Array.isArray(r)?r==null?void 0:r.map((g,S)=>`${S}:${g}`).join(n):"";const c=yield(h=this.coreInstance)==null?void 0:h.batchPkcs1Base64Sign({ContainerName:(m=a==null?void 0:a.ContainerName)!=null?m:"",DataB64:i}),u=(w=(y=c==null?void 0:c[0])==null?void 0:y.SignData)==null?void 0:w.split(n),d=[];return u.forEach(g=>{const S=g.split(":"),I=Number(S[0]),D=S[1];d[I]=D}),d}));o(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){var a,i,c;const t=(i=e.DataB64)!=null?i:this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=yield this.appendCertBase64(e);return!!(yield(c=this.coreInstance)==null?void 0:c.pkcs1Base64VerifySignature({CertB64:n.CertB64,DataB64:t,SignData:n.SignData}))}));o(this,"writeSeal",(e,t)=>l(this,null,function*(){var a,i;const n=yield this.getSignatureCert(t);return!!(yield(i=this.coreInstance)==null?void 0:i.writeSeal(x(p({},e!=null?e:{}),{ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:""})))}));o(this,"deleteSeal",e=>l(this,null,function*(){var a,i,c,u,d;const t=yield this.getSealList(e);if(!((a=t==null?void 0:t.data)!=null&&a.length))return Promise.reject({errCode:-1,msg:"暂无印章"});const n=yield ne.open({title:"删除印章",data:t==null?void 0:t.data,columns:_e,okText:"删除"});return!!(yield(d=this.coreInstance)==null?void 0:d.deleteSeal({ContainerName:(c=(i=t==null?void 0:t.cert)==null?void 0:i.ContainerName)!=null?c:"",SealId:(u=n==null?void 0:n.SealId)!=null?u:""}))}));o(this,"getSealList",e=>l(this,null,function*(){var r,a;const t=yield this.getSignatureCert(e),n=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:"",IsLogin:"Y"});return{cert:t,data:n}}));o(this,"getSealInfo",e=>l(this,null,function*(){var a,i,c,u,d,C,f;const t=yield this.getSealList(e);if(!((a=t==null?void 0:t.data)!=null&&a.length))return Promise.reject({errCode:-1,msg:"暂无印章"});const n=((i=t==null?void 0:t.data)==null?void 0:i.length)>1?yield ne.open({title:"选择印章",data:t==null?void 0:t.data,columns:_e,theme:(c=this.gwsConfig)==null?void 0:c.theme}):t==null?void 0:t.data[0],r=yield(f=this.coreInstance)==null?void 0:f.getSealInfo({ContainerName:(d=(u=t==null?void 0:t.cert)==null?void 0:u.ContainerName)!=null?d:"",SealId:(C=n==null?void 0:n.SealId)!=null?C:""});return r==null?void 0:r[0]}));o(this,"getTPSealList",(e,t)=>l(this,null,function*(){var a,i;const n=yield this.getSignatureCert(t),r=yield(i=this.coreInstance)==null?void 0:i.getTPSealList({ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:"",Vid:e==null?void 0:e.Vid});return{cert:n,data:r}}));o(this,"getTPSeal",(e,t)=>l(this,null,function*(){var a,i,c;const n=yield this.getTPSealList(e,t);if(!((a=n==null?void 0:n.data)!=null&&a.length))return Promise.reject({errCode:-1,msg:"暂无印章"});const r=((i=n==null?void 0:n.data)==null?void 0:i.length)===1?n==null?void 0:n.data[0]:yield ne.open({title:"选择印章",data:n==null?void 0:n.data,columns:ut,theme:(c=this.gwsConfig)==null?void 0:c.theme});return{cert:n==null?void 0:n.cert,data:r}}));o(this,"getTPSealPic",(e,t)=>l(this,null,function*(){var a,i,c,u,d;const n=yield this.getTPSeal(e,t),r=yield(d=this.coreInstance)==null?void 0:d.getTPSealPic(x(p({ContainerName:(i=(a=n==null?void 0:n.cert)==null?void 0:a.ContainerName)!=null?i:""},(c=n==null?void 0:n.data)!=null?c:{}),{FileSize:String((u=n==null?void 0:n.data)==null?void 0:u.FileSize)}));return r==null?void 0:r[0]}));o(this,"sm2SignPreprocess1",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e),n=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(a=n==null?void 0:n[0])==null?void 0:a.Z}));o(this,"sm2SignPreprocess2",e=>l(this,null,function*(){var a,i;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=yield this.appendCertBase64(e),r=yield(i=this.coreInstance)==null?void 0:i.sm2SignPreprocess2({CertB64:n.CertB64,DataB64:t});return r==null?void 0:r[0].H}));o(this,"pkcs1HashSign",(e,t)=>l(this,null,function*(){var a,i,c,u;const n=yield this.getSignatureCert(t),r=yield(c=this.coreInstance)==null?void 0:c.pkcs1HashSign({ContainerName:(a=n==null?void 0:n.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(i=e.HashAlg)!=null?i:"sm3"});return(u=r==null?void 0:r[0])==null?void 0:u.SignData}));o(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(x(p({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));o(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var i,c,u,d,C;const n=(c=e.DataB64)!=null?c:this.base64Encode({Data:(i=e.Data)!=null?i:""}),r=yield this.getSignatureCert(t),a=yield(d=this.coreInstance)==null?void 0:d.pkcs7Sign(x(p({},e!=null?e:{}),{ContainerName:(u=r==null?void 0:r.ContainerName)!=null?u:"",DataB64:n}));return(C=a==null?void 0:a[0])==null?void 0:C.SignData}));o(this,"pkcs7VerifySignature",e=>l(this,null,function*(){var r,a,i;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(i=this.coreInstance)==null?void 0:i.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));o(this,"sm3Hash",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));o(this,"sm3HexHash",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));o(this,"sm3FileHash",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));o(this,"sm3HashEncryption",e=>l(this,null,function*(){var a,i,c,u,d,C;const t=(i=e.DataB64)!=null?i:this.base64Encode({Data:(a=e.Data)!=null?a:""}),n=(u=e.KeyB64)!=null?u:this.base64Encode({Data:(c=e.Key)!=null?c:""}),r=yield(d=this.coreInstance)==null?void 0:d.sm3HashEncryption({dataB64:t,keyB64:n,alg:"sm3"});return(C=r==null?void 0:r[0])==null?void 0:C.DataB64}));o(this,"pkcs7Encryption",e=>l(this,null,function*(){var r,a,i,c;if(!e.CertB64List){const u=yield this.getEncryptionCert();e.CertB64List=u==null?void 0:u.CertB64}const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""}),n=yield(i=this.coreInstance)==null?void 0:i.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(c=n==null?void 0:n[0])==null?void 0:c.DataB64}));o(this,"pkcs7Decryption",e=>l(this,null,function*(){var a,i;const t=yield this.getEncryptionCert(),n=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption(x(p({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),r=(i=n==null?void 0:n[0])==null?void 0:i.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:r}):r}));o(this,"pkcs7FileEncryption",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),n=yield(r=this.coreInstance)==null?void 0:r.pkcs7FileEncryption(t);return(a=n==null?void 0:n[0])==null?void 0:a.DataB64}));o(this,"pkcs7FileDecryption",e=>l(this,null,function*(){var r,a,i;const t=yield this.getEncryptionCert(),n=yield(a=this.coreInstance)==null?void 0:a.pkcs7FileDecryption({SrcFile:e.SrcFile,DstFile:(r=e.DstFile)!=null?r:e.SrcFile.slice(0,-4),ContainerName:t==null?void 0:t.ContainerName});return(i=n==null?void 0:n[0])==null?void 0:i.DataB64}));o(this,"asymmetricEncryption",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),n=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(a=n==null?void 0:n[0])==null?void 0:a.Data}));o(this,"asymmetricDecryption",(e,t)=>l(this,null,function*(){var a,i;const n=yield this.getEncryptionCert(t),r=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption(x(p({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return(i=r==null?void 0:r[0])==null?void 0:i.Data}));o(this,"sm4Encryption",e=>l(this,null,function*(){var n;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Encryption(e);return t==null?void 0:t[0]}));o(this,"sm4Decryption",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.sm4Decryption(e);return(r=t==null?void 0:t[0])==null?void 0:r.Data}));o(this,"getCertInfo",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfo(e);return p({},(r=t==null?void 0:t[0])!=null?r:{})}));o(this,"getCertInfoByOid",e=>l(this,null,function*(){var n,r;const t=yield(n=this.coreInstance)==null?void 0:n.getCertInfoByOid(p({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));o(this,"getSealVendor",e=>l(this,null,function*(){var r;const t=yield this.getSignatureCert(e),n=yield(r=this.coreInstance)==null?void 0:r.getSealVendor({ContainerName:t==null?void 0:t.ContainerName});return n==null?void 0:n[0]}));o(this,"deleteAllSealByVendor",(e,t)=>l(this,null,function*(){var a;const n=yield this.getSignatureCert(t),r=yield(a=this.coreInstance)==null?void 0:a.deleteAllSealByVendor(x(p({},e!=null?e:{}),{ContainerName:n==null?void 0:n.ContainerName}));return r==null?void 0:r[0]}));return O.instance&&!(e!=null&&e.isCreateNew)?O.instance:(this.createGwsCore(e),O.instance=this,this)}};o(O,"instance",null);let Z=O;function gt(s){return new Promise((e,t)=>{if(Z.instance&&!(s!=null&&s.isCreateNew))e(Z.instance);else{const n=new Z(x(p({},s!=null?s:{}),{onOpen(r){var a;e(n),(a=s==null?void 0:s.onOpen)==null||a.call(s,r)},onClose(r){var a;t(r),(a=s==null?void 0:s.onClose)==null||a.call(s,r)}}))}})}B.GwsService=Z,B.createService=gt,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gws-client",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "module": "dist/index.es.js",
6
6
  "main": "dist/index.cjs.js",
@@ -13,8 +13,7 @@
13
13
  ],
14
14
  "author": "gzca",
15
15
  "files": [
16
- "dist",
17
- "README.md"
16
+ "dist"
18
17
  ],
19
18
  "publishConfig": {
20
19
  "registry": "https://registry.npmjs.org/"