gws-client 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -671,7 +671,7 @@ class ie {
671
671
  if (((o = this.socketInstance) == null ? void 0 : o.readyState) !== WebSocket.OPEN) {
672
672
  a({
673
673
  errCode: -1,
674
- message: "socket连接未建立"
674
+ msg: "socket未连接"
675
675
  });
676
676
  return;
677
677
  }
@@ -871,8 +871,8 @@ const P = class P {
871
871
  });
872
872
  c(this, "pkcs1VerifySignature", async (t) => {
873
873
  var a;
874
- const e = await this.appendCertBase64(t);
875
- return !!await ((a = this.coreInstance) == null ? void 0 : a.pkcs1VerifySignature(e));
874
+ const e = await this.appendCertBase64(t), s = await ((a = this.coreInstance) == null ? void 0 : a.pkcs1VerifySignature(e));
875
+ return Array.isArray(s);
876
876
  });
877
877
  c(this, "pkcs1Base64Sign", async (t, e) => {
878
878
  var o, i;
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();(function(m,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(m=typeof globalThis<"u"?globalThis:m||self,p(m.GZCA={}))})(this,function(m){"use strict";var ie=Object.defineProperty;var le=(m,p,_)=>p in m?ie(m,p,{enumerable:!0,configurable:!0,writable:!0,value:_}):m[p]=_;var c=(m,p,_)=>le(m,typeof p!="symbol"?p+"":p,_);const p=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",_="1",kt="2";var st=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(st||{}),j={};j.byteLength=St,j.toByteArray=$t,j.fromByteArray=Et;for(var B=[],w=[],Bt=typeof Uint8Array<"u"?Uint8Array:Array,W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=0,bt=W.length;L<bt;++L)B[L]=W[L],w[W.charCodeAt(L)]=L;w[45]=62,w[95]=63;function at(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var s=e===t?0:4-e%4;return[e,s]}function St(n){var t=at(n),e=t[0],s=t[1];return(e+s)*3/4-s}function Dt(n,t,e){return(t+e)*3/4-e}function $t(n){var t,e=at(n),s=e[0],a=e[1],r=new Bt(Dt(n,s,a)),o=0,i=a>0?s-4:s,d;for(d=0;d<i;d+=4)t=w[n.charCodeAt(d)]<<18|w[n.charCodeAt(d+1)]<<12|w[n.charCodeAt(d+2)]<<6|w[n.charCodeAt(d+3)],r[o++]=t>>16&255,r[o++]=t>>8&255,r[o++]=t&255;return a===2&&(t=w[n.charCodeAt(d)]<<2|w[n.charCodeAt(d+1)]>>4,r[o++]=t&255),a===1&&(t=w[n.charCodeAt(d)]<<10|w[n.charCodeAt(d+1)]<<4|w[n.charCodeAt(d+2)]>>2,r[o++]=t>>8&255,r[o++]=t&255),r}function It(n){return B[n>>18&63]+B[n>>12&63]+B[n>>6&63]+B[n&63]}function At(n,t,e){for(var s,a=[],r=t;r<e;r+=3)s=(n[r]<<16&16711680)+(n[r+1]<<8&65280)+(n[r+2]&255),a.push(It(s));return a.join("")}function Et(n){for(var t,e=n.length,s=e%3,a=[],r=16383,o=0,i=e-s;o<i;o+=r)a.push(At(n,o,o+r>i?i:o+r));return s===1?(t=n[e-1],a.push(B[t>>2]+B[t<<4&63]+"==")):s===2&&(t=(n[e-2]<<8)+n[e-1],a.push(B[t>>10]+B[t>>4&63]+B[t<<2&63]+"=")),a.join("")}class _t{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 Lt=Object.defineProperty,Pt=(n,t,e)=>t in n?Lt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,rt=(n,t,e)=>Pt(n,typeof t!="symbol"?t+"":t,e);function J(){}function Tt(n,t){for(const e in t)n[e]=t[e];return n}function ot(n){return n()}function ct(){return Object.create(null)}function Z(n){n.forEach(ot)}function N(n){return typeof n=="function"}function it(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function Ht(n){return Object.keys(n).length===0}function Mt(n,t,e,s){if(n){const a=lt(n,t,e,s);return n[0](a)}}function lt(n,t,e,s){return n[1]&&s?Tt(e.ctx.slice(),n[1](s(t))):e.ctx}function Gt(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 Ft(n,t,e,s,a,r){if(a){const o=lt(t,e,s,r);n.p(o,a)}}function jt(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 dt(n){return n??""}function g(n,t){n.appendChild(t)}function K(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 b(n){return document.createElement(n)}function S(n){return document.createTextNode(n)}function O(){return S(" ")}function Nt(){return S("")}function z(n,t,e,s){return n.addEventListener(t,e,s),()=>n.removeEventListener(t,e,s)}function C(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 P(n,t){t=""+t,n.data!==t&&(n.data=t)}let q;function V(n){q=n}const T=[],ut=[];let H=[];const ht=[],zt=Promise.resolve();let Q=!1;function Vt(){Q||(Q=!0,zt.then(gt))}function X(n){H.push(n)}const Y=new Set;let M=0;function gt(){if(M!==0)return;const n=q;do{try{for(;M<T.length;){const t=T[M];M++,V(t),Rt(t.$$)}}catch(t){throw T.length=0,M=0,t}for(V(null),T.length=0,M=0;ut.length;)ut.pop()();for(let t=0;t<H.length;t+=1){const e=H[t];Y.has(e)||(Y.add(e),e())}H.length=0}while(T.length);for(;ht.length;)ht.pop()();Q=!1,Y.clear(),V(n)}function Rt(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(X)}}function Ut(n){const t=[],e=[];H.forEach(s=>n.indexOf(s)===-1?t.push(s):e.push(s)),e.forEach(s=>s()),H=t}const U=new Set;let Wt;function tt(n,t){n&&n.i&&(U.delete(n),n.i(t))}function ft(n,t,e,s){if(n&&n.o){if(U.has(n))return;U.add(n),Wt.c.push(()=>{U.delete(n)}),n.o(t)}}function pt(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Jt(n){n&&n.c()}function yt(n,t,e){const{fragment:s,after_update:a}=n.$$;s&&s.m(t,e),X(()=>{const r=n.$$.on_mount.map(ot).filter(N);n.$$.on_destroy?n.$$.on_destroy.push(...r):Z(r),n.$$.on_mount=[]}),a.forEach(X)}function mt(n,t){const e=n.$$;e.fragment!==null&&(Ut(e.after_update),Z(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Kt(n,t){n.$$.dirty[0]===-1&&(T.push(n),Vt(),n.$$.dirty.fill(0)),n.$$.dirty[t/31|0]|=1<<t%31}function wt(n,t,e,s,a,r,o=null,i=[-1]){const d=q;V(n);const l=n.$$={fragment:null,ctx:[],props:r,update:J,not_equal:a,bound:ct(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(d?d.$$.context:[])),callbacks:ct(),dirty:i,skip_bound:!1,root:t.target||d.$$.root};o&&o(l.root);let f=!1;if(l.ctx=e?e(n,t.props||{},(u,v,...h)=>{const y=h.length?h[0]:v;return l.ctx&&a(l.ctx[u],l.ctx[u]=y)&&(!l.skip_bound&&l.bound[u]&&l.bound[u](y),f&&Kt(n,u)),v}):[],l.update(),f=!0,Z(l.before_update),l.fragment=s?s(l.ctx):!1,t.target){if(t.hydrate){const u=Ot(t.target);l.fragment&&l.fragment.l(u),u.forEach(R)}else l.fragment&&l.fragment.c();t.intro&&tt(n.$$.fragment),yt(n,t.target,t.anchor),gt()}V(d)}class Ct{constructor(){rt(this,"$$"),rt(this,"$$set")}$destroy(){mt(this,1),this.$destroy=J}$on(t,e){if(!N(e))return J;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&&!Ht(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const qt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(qt);function Qt(n){let t,e,s,a=(n[1]||"标题")+"",r,o,i,d,l,f,u=(n[4]||"取消")+"",v,h,y,A=(n[5]||"确认")+"",F,x,$,I;const nt=n[7].default,k=Mt(nt,n,n[6],null);return{c(){t=b("div"),e=b("div"),s=b("div"),r=S(a),o=O(),i=b("div"),k&&k.c(),d=O(),l=b("div"),f=b("button"),v=S(u),h=O(),y=b("button"),F=S(A),C(s,"class","model-title svelte-n1zwga"),C(i,"class","slot svelte-n1zwga"),C(f,"class","modal-btn svelte-n1zwga"),C(y,"class","modal-btn success svelte-n1zwga"),C(l,"class","modal-footer svelte-n1zwga"),C(e,"class","modal-content svelte-n1zwga"),C(t,"class","modal-background modal-visible svelte-n1zwga")},m(D,E){K(D,t,E),g(t,e),g(e,s),g(s,r),g(e,o),g(e,i),k&&k.m(i,null),g(e,d),g(e,l),g(l,f),g(f,v),g(l,h),g(l,y),g(y,F),x=!0,$||(I=[z(f,"click",function(){N(n[0])&&n[0].apply(this,arguments)}),z(y,"click",function(){N(n[2])&&n[2].apply(this,arguments)}),z(e,"click",Xt),z(t,"click",function(){N(n[3])&&n[3].apply(this,arguments)})],$=!0)},p(D,[E]){n=D,(!x||E&2)&&a!==(a=(n[1]||"标题")+"")&&P(r,a),k&&k.p&&(!x||E&64)&&Ft(k,nt,n,n[6],x?Gt(nt,n[6],E,null):jt(n[6]),null),(!x||E&16)&&u!==(u=(n[4]||"取消")+"")&&P(v,u),(!x||E&32)&&A!==(A=(n[5]||"确认")+"")&&P(F,A)},i(D){x||(tt(k,D),x=!0)},o(D){ft(k,D),x=!1},d(D){D&&R(t),k&&k.d(D),$=!1,Z(I)}}}const Xt=n=>n.stopPropagation();function Yt(n,t,e){let{$$slots:s={},$$scope:a}=t,{onCancel:r}=t,{title:o}=t,{onOk:i}=t,{onClose:d}=t,{cancelText:l}=t,{okText:f}=t;return n.$$set=u=>{"onCancel"in u&&e(0,r=u.onCancel),"title"in u&&e(1,o=u.title),"onOk"in u&&e(2,i=u.onOk),"onClose"in u&&e(3,d=u.onClose),"cancelText"in u&&e(4,l=u.cancelText),"okText"in u&&e(5,f=u.okText),"$$scope"in u&&e(6,a=u.$$scope)},[r,o,i,d,l,f,a,s]}class te extends Ct{constructor(t){super(),wt(this,t,Yt,Qt,it,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5})}}function vt(n,t,e){const s=n.slice();return s[10]=t[e],s[12]=e,s}function xt(n){let t,e,s=n[10].CN+"",a,r,o,i=n[10].DevClass+"",d,l,f=n[10].sn+"",u,v,h,y,A,F;function x(){return n[9](n[12])}return{c(){t=b("div"),e=b("span"),a=S(s),r=O(),o=b("span"),d=S(i),l=S("("),u=S(f),v=S(")"),h=O(),C(e,"class","svelte-jtc2v4"),C(o,"class","svelte-jtc2v4"),C(t,"class",y=dt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m($,I){K($,t,I),g(t,e),g(e,a),g(t,r),g(t,o),g(o,d),g(o,l),g(o,u),g(o,v),g(t,h),A||(F=z(t,"click",x),A=!0)},p($,I){n=$,I&1&&s!==(s=n[10].CN+"")&&P(a,s),I&1&&i!==(i=n[10].DevClass+"")&&P(d,i),I&1&&f!==(f=n[10].sn+"")&&P(u,f),I&16&&y!==(y=dt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&C(t,"class",y)},d($){$&&R(t),A=!1,F()}}}function ee(n){let t,e=pt(n[0]),s=[];for(let a=0;a<e.length;a+=1)s[a]=xt(vt(n,e,a));return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=Nt()},m(a,r){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(a,r);K(a,t,r)},p(a,r){if(r&17){e=pt(a[0]);let o;for(o=0;o<e.length;o+=1){const i=vt(a,e,o);s[o]?s[o].p(i,r):(s[o]=xt(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 ne(n){let t,e;return t=new te({props:{onOk:n[6],onClose:n[1],onCancel:n[5],cancelText:n[2],okText:n[3],title:"选择证书",$$slots:{default:[ee]},$$scope:{ctx:n}}}),{c(){Jt(t.$$.fragment)},m(s,a){yt(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||(tt(t.$$.fragment,s),e=!0)},o(s){ft(t.$$.fragment,s),e=!1},d(s){mt(t,s)}}}function se(n,t,e){let{certList:s=[]}=t,{onCancel:a}=t,{onOk:r}=t,{onClose:o}=t,{cancelText:i=""}=t,{okText:d=""}=t,l=0;const f=()=>{o==null||o()},u=()=>{r==null||r(s[l]),o==null||o()},v=h=>e(4,l=h);return n.$$set=h=>{"certList"in h&&e(0,s=h.certList),"onCancel"in h&&e(7,a=h.onCancel),"onOk"in h&&e(8,r=h.onOk),"onClose"in h&&e(1,o=h.onClose),"cancelText"in h&&e(2,i=h.cancelText),"okText"in h&&e(3,d=h.okText)},[s,o,i,d,l,f,u,a,r,v]}class ae extends Ct{constructor(t){super(),wt(this,t,se,ne,it,{certList:0,onCancel:7,onOk:8,onClose:1,cancelText:2,okText:3})}}class re{constructor(){c(this,"modalInstance",{current:null});c(this,"open",t=>new Promise((e,s)=>{this.modalInstance.current=new ae({target:document.body,props:{...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 oe=new re;class ce{constructor(t){c(this,"socketInstance",null);c(this,"eventBus",new _t);c(this,"isRememberPin",!1);c(this,"socketEvent");c(this,"pinPolicy");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){a({errCode:-1,message:"socket连接未建立"});return}const r={function:t,args:[e??{}]};(i=this.socketInstance)==null||i.send(JSON.stringify(r)),this.eventBus.on(t,d=>{d.success?s(d.data):a(d)})}));c(this,"handleEventData",async t=>{var e,s,a,r;if(t.data instanceof Blob){const o=await t.data.arrayBuffer(),d=new TextDecoder("gbk").decode(o),l=JSON.parse(d);this.eventBus.emit((e=l.result)==null?void 0:e.function,{data:l.data,success:(s=l.result)==null?void 0:s.success,msg:(a=l.result)==null?void 0:a.msg,errCode:(r=l.result)==null?void 0:r.errCode})}});c(this,"base64Encode",t=>{const e=new TextEncoder().encode(t);return j.fromByteArray(e)});c(this,"base64Decode",t=>{const e=j.toByteArray(t);return new TextDecoder().decode(e)});c(this,"changeIsRememberPin",async t=>{this.isRememberPin=t});c(this,"changePinPolicy",async t=>{this.pinPolicy=t});c(this,"checkCertIsLogin",async t=>await this.sendMessage("GZCA_IsLogin",t));c(this,"certLogin",async t=>{const e=await this.checkCertIsLogin({ContainerName:t});e!=null&&e[0].isLogin||await this.sendMessage("GZCA_Login",{ContainerName:t,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy})});c(this,"getCert",async(t,e)=>{const s=e??await this.chooseCert(t);return await this.certLogin(s.ContainerName),s});c(this,"getCertList",async t=>await this.sendMessage("GZCA_GetCertList",t));c(this,"chooseCert",async t=>{const e=await this.getCertList(t);return(e==null?void 0:e.length)===1?e[0]:await oe.open({certList:e})});c(this,"pkcs1Sign",async t=>await this.sendMessage("GZCA_Pkcs1SignData",{...t,IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1Base64Sign",async t=>await this.sendMessage("GZCA_Pkcs1SignDataEx",{...t,IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySign",t));c(this,"pkcs1Base64VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySignEx",t));c(this,"getSealList",async t=>await this.sendMessage("GZCA_EnumSeals",{...t,IsLogin:this.getIsLogin()}));c(this,"sm2SignPreprocess1",async t=>await this.sendMessage("GZCA_PrepareSm2SignStep1",t));c(this,"sm2SignPreprocess2",async t=>await this.sendMessage("GZCA_PrepareSm2SignStep2",t));c(this,"pkcs1HashSign",async t=>await this.sendMessage("GZCA_Pkcs1SignDataForHash",{...t??{},IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1HashVerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySignForHash",t));c(this,"pkcs7Sign",async t=>await this.sendMessage("GZCA_Pkcs7SignData",{...t,IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy}));c(this,"pkcs7VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs7VerifySign",t));c(this,"sm3Hash",async t=>await this.sendMessage("GZCA_HashData",t));c(this,"sm3HexHash",async t=>await this.sendMessage("GZCA_HashDataEx",t));c(this,"sm3FileHash",async t=>await this.sendMessage("GZCA_HashFile",t));c(this,"sm3HashEncryption",async t=>await this.sendMessage("GZCA_HMac",t));c(this,"pkcs7Encryption",async t=>await this.sendMessage("GZCA_Pkcs7EncryptData",t));c(this,"pkcs7Decryption",async t=>await this.sendMessage("GZCA_Pkcs7DecryptData",{...t,IsLogin:this.getIsLogin()}));c(this,"asymmetricEncryption",async t=>await this.sendMessage("GZCA_AsymEncryptData",t));c(this,"asymmetricDecryption",async t=>await this.sendMessage("GZCA_AsymDecryptData",{...t,IsLogin:this.getIsLogin()}));c(this,"sm4Encryption",async t=>await this.sendMessage("GZCA_EncryptDataEx",t));c(this,"sm4Decryption",async t=>await this.sendMessage("GZCA_DecryptDataEx",t));c(this,"getCertInfo",async t=>await this.sendMessage("GZCA_GetCertInfo",t));c(this,"getCertInfoByOid",async t=>await this.sendMessage("GZCA_GetCertInfoByOid",t));this.socketInstance=this.createSocket(t),this.isRememberPin=t.isRememberPin??!1,this.pinPolicy=t.pinPolicy??st.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)},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 G=class G{constructor(t){c(this,"coreInstance",null);c(this,"gwsConfig",{});c(this,"createGwsCore",t=>{this.gwsConfig=t??{},this.coreInstance=new ce({...t??{},url:p})});c(this,"appendCertBase64",async(t,e=!0)=>{if(t.CertB64)return t;const s=e?await this.getSignatureCert():await this.getEncryptionCert();return{...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??this.gwsConfig,this.createGwsCore(t)});c(this,"getSocketReadyState",()=>{var t;return(t=this.coreInstance)==null?void 0:t.getSocketReadyState()});c(this,"getSignatureCert",async t=>{var s;return await((s=this.coreInstance)==null?void 0:s.getCert({CertType:_},t))});c(this,"getEncryptionCert",async t=>{var s;return await((s=this.coreInstance)==null?void 0:s.getCert({CertType:kt},t))});c(this,"base64Encode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Encode(t)});c(this,"base64Decode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Decode(t)});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",async(t,e)=>{var r,o;const s=await this.getSignatureCert(e),a=await((r=this.coreInstance)==null?void 0:r.pkcs1Sign({...t??{},ContainerName:(s==null?void 0:s.ContainerName)??""}));return(o=a==null?void 0:a[0])==null?void 0:o.SignData});c(this,"pkcs1VerifySignature",async t=>{var a;const e=await this.appendCertBase64(t);return!!await((a=this.coreInstance)==null?void 0:a.pkcs1VerifySignature(e))});c(this,"pkcs1Base64Sign",async(t,e)=>{var o,i;const s=await this.getSignatureCert(e),a=t.DataB64??this.base64Encode(t.Data??""),r=await((o=this.coreInstance)==null?void 0:o.pkcs1Base64Sign({ContainerName:(s==null?void 0:s.ContainerName)??"",DataB64:a}));return(i=r==null?void 0:r[0])==null?void 0:i.SignData});c(this,"pkcs1Base64VerifySignature",async t=>{var r;const e=t.DataB64??this.base64Encode(t.Data??""),s=await this.appendCertBase64(t);return!!await((r=this.coreInstance)==null?void 0:r.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:e,SignData:s.SignData}))});c(this,"getSealList",async()=>{var s;const t=await this.getSignatureCert(),e=await((s=this.coreInstance)==null?void 0:s.getSealList({ContainerName:(t==null?void 0:t.ContainerName)??""}));return{cert:t,sealList:e}});c(this,"sm2SignPreprocess1",async t=>{var a,r;const e=await this.appendCertBase64(t),s=await((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",async t=>{var r;const e=this.base64Encode(t.Data),s=await this.appendCertBase64(t),a=await((r=this.coreInstance)==null?void 0:r.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:e}));return a==null?void 0:a[0].H});c(this,"pkcs1HashSign",async(t,e)=>{var r,o;const s=await this.getSignatureCert(e),a=await((r=this.coreInstance)==null?void 0:r.pkcs1HashSign({ContainerName:(s==null?void 0:s.ContainerName)??"",DataB64:t.DataB64,HashAlg:t.HashAlg??"sm3"}));return(o=a==null?void 0:a[0])==null?void 0:o.SignData});c(this,"pkcs1HashVerifySignature",async t=>{var a;const e=await this.appendCertBase64(t);return!!await((a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature({...e,HashAlg:e.HashAlg??"sm3"}))});c(this,"pkcs7Sign",async(t,e)=>{var o,i;const s=t.DataB64??this.base64Encode(t.Data??""),a=await this.getSignatureCert(e),r=await((o=this.coreInstance)==null?void 0:o.pkcs7Sign({IsDetached:t.IsDetached,ContainerName:(a==null?void 0:a.ContainerName)??"",DataB64:s}));return(i=r==null?void 0:r[0])==null?void 0:i.SignData});c(this,"pkcs7VerifySignature",async t=>{var a;const e=t.DataB64??this.base64Encode(t.Data??"");return!!await((a=this.coreInstance)==null?void 0:a.pkcs7VerifySignature({DataB64:e,SignData:t.SignData}))});c(this,"sm3Hash",async t=>{var s,a;const e=await((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",async t=>{var s,a;const e=await((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",async t=>{var s,a;const e=await((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",async t=>{var r,o;const e=t.DataB64??this.base64Encode(t.Data??""),s=t.KeyB64??this.base64Encode(t.Key??""),a=await((r=this.coreInstance)==null?void 0:r.sm3HashEncryption({dataB64:e,keyB64:s,alg:"sm3"}));return(o=a==null?void 0:a[0])==null?void 0:o.DataB64});c(this,"pkcs7Encryption",async t=>{var a,r;if(!t.CertB64List){const o=await this.getEncryptionCert();t.CertB64List=o==null?void 0:o.CertB64}const e=t.DataB64??this.base64Encode(t.Data??""),s=await((a=this.coreInstance)==null?void 0:a.pkcs7Encryption({DataB64:e,CertB64List:t.CertB64List}));return(r=s==null?void 0:s[0])==null?void 0:r.DataB64});c(this,"pkcs7Decryption",async t=>{var r,o;const e=await this.getEncryptionCert(),s=await((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(a):a});c(this,"asymmetricEncryption",async t=>{var a,r;const e=await this.appendCertBase64(t,!1),s=await((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",async t=>{var a,r;const e=await this.getEncryptionCert(),s=await((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",async t=>{var s;const e=await((s=this.coreInstance)==null?void 0:s.sm4Encryption(t));return e==null?void 0:e[0]});c(this,"sm4Decryption",async t=>{var s,a;const e=await((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",async()=>{var s;const t=await this.getSignatureCert(),e=await((s=this.coreInstance)==null?void 0:s.getCertInfo({CertB64:t==null?void 0:t.CertB64}));return{...(e==null?void 0:e[0])??{},...t??{}}});c(this,"getCertInfoByOid",async t=>{var a,r;const e=await this.getSignatureCert(),s=await((a=this.coreInstance)==null?void 0:a.getCertInfoByOid({...t??{},CertB64:e==null?void 0:e.CertB64}));return(r=s==null?void 0:s[0])==null?void 0:r.OidValue});return G.instance?G.instance:(this.createGwsCore(t),G.instance=this,this)}};c(G,"instance",null);let et=G;m.GwsService=et,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
1
+ (function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();(function(m,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(m=typeof globalThis<"u"?globalThis:m||self,p(m.GZCA={}))})(this,function(m){"use strict";var ie=Object.defineProperty;var le=(m,p,_)=>p in m?ie(m,p,{enumerable:!0,configurable:!0,writable:!0,value:_}):m[p]=_;var c=(m,p,_)=>le(m,typeof p!="symbol"?p+"":p,_);const p=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",_="1",kt="2";var st=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(st||{}),j={};j.byteLength=St,j.toByteArray=$t,j.fromByteArray=Et;for(var B=[],w=[],Bt=typeof Uint8Array<"u"?Uint8Array:Array,W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=0,bt=W.length;L<bt;++L)B[L]=W[L],w[W.charCodeAt(L)]=L;w[45]=62,w[95]=63;function at(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var s=e===t?0:4-e%4;return[e,s]}function St(n){var t=at(n),e=t[0],s=t[1];return(e+s)*3/4-s}function Dt(n,t,e){return(t+e)*3/4-e}function $t(n){var t,e=at(n),s=e[0],a=e[1],r=new Bt(Dt(n,s,a)),o=0,i=a>0?s-4:s,d;for(d=0;d<i;d+=4)t=w[n.charCodeAt(d)]<<18|w[n.charCodeAt(d+1)]<<12|w[n.charCodeAt(d+2)]<<6|w[n.charCodeAt(d+3)],r[o++]=t>>16&255,r[o++]=t>>8&255,r[o++]=t&255;return a===2&&(t=w[n.charCodeAt(d)]<<2|w[n.charCodeAt(d+1)]>>4,r[o++]=t&255),a===1&&(t=w[n.charCodeAt(d)]<<10|w[n.charCodeAt(d+1)]<<4|w[n.charCodeAt(d+2)]>>2,r[o++]=t>>8&255,r[o++]=t&255),r}function It(n){return B[n>>18&63]+B[n>>12&63]+B[n>>6&63]+B[n&63]}function At(n,t,e){for(var s,a=[],r=t;r<e;r+=3)s=(n[r]<<16&16711680)+(n[r+1]<<8&65280)+(n[r+2]&255),a.push(It(s));return a.join("")}function Et(n){for(var t,e=n.length,s=e%3,a=[],r=16383,o=0,i=e-s;o<i;o+=r)a.push(At(n,o,o+r>i?i:o+r));return s===1?(t=n[e-1],a.push(B[t>>2]+B[t<<4&63]+"==")):s===2&&(t=(n[e-2]<<8)+n[e-1],a.push(B[t>>10]+B[t>>4&63]+B[t<<2&63]+"=")),a.join("")}class _t{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 Lt=Object.defineProperty,Pt=(n,t,e)=>t in n?Lt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,rt=(n,t,e)=>Pt(n,typeof t!="symbol"?t+"":t,e);function J(){}function Tt(n,t){for(const e in t)n[e]=t[e];return n}function ot(n){return n()}function ct(){return Object.create(null)}function Z(n){n.forEach(ot)}function N(n){return typeof n=="function"}function it(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function Ht(n){return Object.keys(n).length===0}function Mt(n,t,e,s){if(n){const a=lt(n,t,e,s);return n[0](a)}}function lt(n,t,e,s){return n[1]&&s?Tt(e.ctx.slice(),n[1](s(t))):e.ctx}function Gt(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 Ft(n,t,e,s,a,r){if(a){const o=lt(t,e,s,r);n.p(o,a)}}function jt(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 dt(n){return n??""}function g(n,t){n.appendChild(t)}function K(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 b(n){return document.createElement(n)}function S(n){return document.createTextNode(n)}function O(){return S(" ")}function Nt(){return S("")}function z(n,t,e,s){return n.addEventListener(t,e,s),()=>n.removeEventListener(t,e,s)}function C(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 P(n,t){t=""+t,n.data!==t&&(n.data=t)}let q;function V(n){q=n}const T=[],ut=[];let H=[];const ht=[],zt=Promise.resolve();let Q=!1;function Vt(){Q||(Q=!0,zt.then(gt))}function X(n){H.push(n)}const Y=new Set;let M=0;function gt(){if(M!==0)return;const n=q;do{try{for(;M<T.length;){const t=T[M];M++,V(t),Rt(t.$$)}}catch(t){throw T.length=0,M=0,t}for(V(null),T.length=0,M=0;ut.length;)ut.pop()();for(let t=0;t<H.length;t+=1){const e=H[t];Y.has(e)||(Y.add(e),e())}H.length=0}while(T.length);for(;ht.length;)ht.pop()();Q=!1,Y.clear(),V(n)}function Rt(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(X)}}function Ut(n){const t=[],e=[];H.forEach(s=>n.indexOf(s)===-1?t.push(s):e.push(s)),e.forEach(s=>s()),H=t}const U=new Set;let Wt;function tt(n,t){n&&n.i&&(U.delete(n),n.i(t))}function ft(n,t,e,s){if(n&&n.o){if(U.has(n))return;U.add(n),Wt.c.push(()=>{U.delete(n)}),n.o(t)}}function pt(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Jt(n){n&&n.c()}function yt(n,t,e){const{fragment:s,after_update:a}=n.$$;s&&s.m(t,e),X(()=>{const r=n.$$.on_mount.map(ot).filter(N);n.$$.on_destroy?n.$$.on_destroy.push(...r):Z(r),n.$$.on_mount=[]}),a.forEach(X)}function mt(n,t){const e=n.$$;e.fragment!==null&&(Ut(e.after_update),Z(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Kt(n,t){n.$$.dirty[0]===-1&&(T.push(n),Vt(),n.$$.dirty.fill(0)),n.$$.dirty[t/31|0]|=1<<t%31}function wt(n,t,e,s,a,r,o=null,i=[-1]){const d=q;V(n);const l=n.$$={fragment:null,ctx:[],props:r,update:J,not_equal:a,bound:ct(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(d?d.$$.context:[])),callbacks:ct(),dirty:i,skip_bound:!1,root:t.target||d.$$.root};o&&o(l.root);let f=!1;if(l.ctx=e?e(n,t.props||{},(u,v,...h)=>{const y=h.length?h[0]:v;return l.ctx&&a(l.ctx[u],l.ctx[u]=y)&&(!l.skip_bound&&l.bound[u]&&l.bound[u](y),f&&Kt(n,u)),v}):[],l.update(),f=!0,Z(l.before_update),l.fragment=s?s(l.ctx):!1,t.target){if(t.hydrate){const u=Ot(t.target);l.fragment&&l.fragment.l(u),u.forEach(R)}else l.fragment&&l.fragment.c();t.intro&&tt(n.$$.fragment),yt(n,t.target,t.anchor),gt()}V(d)}class Ct{constructor(){rt(this,"$$"),rt(this,"$$set")}$destroy(){mt(this,1),this.$destroy=J}$on(t,e){if(!N(e))return J;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&&!Ht(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const qt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(qt);function Qt(n){let t,e,s,a=(n[1]||"标题")+"",r,o,i,d,l,f,u=(n[4]||"取消")+"",v,h,y,A=(n[5]||"确认")+"",F,x,$,I;const nt=n[7].default,k=Mt(nt,n,n[6],null);return{c(){t=b("div"),e=b("div"),s=b("div"),r=S(a),o=O(),i=b("div"),k&&k.c(),d=O(),l=b("div"),f=b("button"),v=S(u),h=O(),y=b("button"),F=S(A),C(s,"class","model-title svelte-n1zwga"),C(i,"class","slot svelte-n1zwga"),C(f,"class","modal-btn svelte-n1zwga"),C(y,"class","modal-btn success svelte-n1zwga"),C(l,"class","modal-footer svelte-n1zwga"),C(e,"class","modal-content svelte-n1zwga"),C(t,"class","modal-background modal-visible svelte-n1zwga")},m(D,E){K(D,t,E),g(t,e),g(e,s),g(s,r),g(e,o),g(e,i),k&&k.m(i,null),g(e,d),g(e,l),g(l,f),g(f,v),g(l,h),g(l,y),g(y,F),x=!0,$||(I=[z(f,"click",function(){N(n[0])&&n[0].apply(this,arguments)}),z(y,"click",function(){N(n[2])&&n[2].apply(this,arguments)}),z(e,"click",Xt),z(t,"click",function(){N(n[3])&&n[3].apply(this,arguments)})],$=!0)},p(D,[E]){n=D,(!x||E&2)&&a!==(a=(n[1]||"标题")+"")&&P(r,a),k&&k.p&&(!x||E&64)&&Ft(k,nt,n,n[6],x?Gt(nt,n[6],E,null):jt(n[6]),null),(!x||E&16)&&u!==(u=(n[4]||"取消")+"")&&P(v,u),(!x||E&32)&&A!==(A=(n[5]||"确认")+"")&&P(F,A)},i(D){x||(tt(k,D),x=!0)},o(D){ft(k,D),x=!1},d(D){D&&R(t),k&&k.d(D),$=!1,Z(I)}}}const Xt=n=>n.stopPropagation();function Yt(n,t,e){let{$$slots:s={},$$scope:a}=t,{onCancel:r}=t,{title:o}=t,{onOk:i}=t,{onClose:d}=t,{cancelText:l}=t,{okText:f}=t;return n.$$set=u=>{"onCancel"in u&&e(0,r=u.onCancel),"title"in u&&e(1,o=u.title),"onOk"in u&&e(2,i=u.onOk),"onClose"in u&&e(3,d=u.onClose),"cancelText"in u&&e(4,l=u.cancelText),"okText"in u&&e(5,f=u.okText),"$$scope"in u&&e(6,a=u.$$scope)},[r,o,i,d,l,f,a,s]}class te extends Ct{constructor(t){super(),wt(this,t,Yt,Qt,it,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5})}}function vt(n,t,e){const s=n.slice();return s[10]=t[e],s[12]=e,s}function xt(n){let t,e,s=n[10].CN+"",a,r,o,i=n[10].DevClass+"",d,l,f=n[10].sn+"",u,v,h,y,A,F;function x(){return n[9](n[12])}return{c(){t=b("div"),e=b("span"),a=S(s),r=O(),o=b("span"),d=S(i),l=S("("),u=S(f),v=S(")"),h=O(),C(e,"class","svelte-jtc2v4"),C(o,"class","svelte-jtc2v4"),C(t,"class",y=dt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m($,I){K($,t,I),g(t,e),g(e,a),g(t,r),g(t,o),g(o,d),g(o,l),g(o,u),g(o,v),g(t,h),A||(F=z(t,"click",x),A=!0)},p($,I){n=$,I&1&&s!==(s=n[10].CN+"")&&P(a,s),I&1&&i!==(i=n[10].DevClass+"")&&P(d,i),I&1&&f!==(f=n[10].sn+"")&&P(u,f),I&16&&y!==(y=dt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&C(t,"class",y)},d($){$&&R(t),A=!1,F()}}}function ee(n){let t,e=pt(n[0]),s=[];for(let a=0;a<e.length;a+=1)s[a]=xt(vt(n,e,a));return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=Nt()},m(a,r){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(a,r);K(a,t,r)},p(a,r){if(r&17){e=pt(a[0]);let o;for(o=0;o<e.length;o+=1){const i=vt(a,e,o);s[o]?s[o].p(i,r):(s[o]=xt(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 ne(n){let t,e;return t=new te({props:{onOk:n[6],onClose:n[1],onCancel:n[5],cancelText:n[2],okText:n[3],title:"选择证书",$$slots:{default:[ee]},$$scope:{ctx:n}}}),{c(){Jt(t.$$.fragment)},m(s,a){yt(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||(tt(t.$$.fragment,s),e=!0)},o(s){ft(t.$$.fragment,s),e=!1},d(s){mt(t,s)}}}function se(n,t,e){let{certList:s=[]}=t,{onCancel:a}=t,{onOk:r}=t,{onClose:o}=t,{cancelText:i=""}=t,{okText:d=""}=t,l=0;const f=()=>{o==null||o()},u=()=>{r==null||r(s[l]),o==null||o()},v=h=>e(4,l=h);return n.$$set=h=>{"certList"in h&&e(0,s=h.certList),"onCancel"in h&&e(7,a=h.onCancel),"onOk"in h&&e(8,r=h.onOk),"onClose"in h&&e(1,o=h.onClose),"cancelText"in h&&e(2,i=h.cancelText),"okText"in h&&e(3,d=h.okText)},[s,o,i,d,l,f,u,a,r,v]}class ae extends Ct{constructor(t){super(),wt(this,t,se,ne,it,{certList:0,onCancel:7,onOk:8,onClose:1,cancelText:2,okText:3})}}class re{constructor(){c(this,"modalInstance",{current:null});c(this,"open",t=>new Promise((e,s)=>{this.modalInstance.current=new ae({target:document.body,props:{...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 oe=new re;class ce{constructor(t){c(this,"socketInstance",null);c(this,"eventBus",new _t);c(this,"isRememberPin",!1);c(this,"socketEvent");c(this,"pinPolicy");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){a({errCode:-1,msg:"socket未连接"});return}const r={function:t,args:[e??{}]};(i=this.socketInstance)==null||i.send(JSON.stringify(r)),this.eventBus.on(t,d=>{d.success?s(d.data):a(d)})}));c(this,"handleEventData",async t=>{var e,s,a,r;if(t.data instanceof Blob){const o=await t.data.arrayBuffer(),d=new TextDecoder("gbk").decode(o),l=JSON.parse(d);this.eventBus.emit((e=l.result)==null?void 0:e.function,{data:l.data,success:(s=l.result)==null?void 0:s.success,msg:(a=l.result)==null?void 0:a.msg,errCode:(r=l.result)==null?void 0:r.errCode})}});c(this,"base64Encode",t=>{const e=new TextEncoder().encode(t);return j.fromByteArray(e)});c(this,"base64Decode",t=>{const e=j.toByteArray(t);return new TextDecoder().decode(e)});c(this,"changeIsRememberPin",async t=>{this.isRememberPin=t});c(this,"changePinPolicy",async t=>{this.pinPolicy=t});c(this,"checkCertIsLogin",async t=>await this.sendMessage("GZCA_IsLogin",t));c(this,"certLogin",async t=>{const e=await this.checkCertIsLogin({ContainerName:t});e!=null&&e[0].isLogin||await this.sendMessage("GZCA_Login",{ContainerName:t,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy})});c(this,"getCert",async(t,e)=>{const s=e??await this.chooseCert(t);return await this.certLogin(s.ContainerName),s});c(this,"getCertList",async t=>await this.sendMessage("GZCA_GetCertList",t));c(this,"chooseCert",async t=>{const e=await this.getCertList(t);return(e==null?void 0:e.length)===1?e[0]:await oe.open({certList:e})});c(this,"pkcs1Sign",async t=>await this.sendMessage("GZCA_Pkcs1SignData",{...t,IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1Base64Sign",async t=>await this.sendMessage("GZCA_Pkcs1SignDataEx",{...t,IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySign",t));c(this,"pkcs1Base64VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySignEx",t));c(this,"getSealList",async t=>await this.sendMessage("GZCA_EnumSeals",{...t,IsLogin:this.getIsLogin()}));c(this,"sm2SignPreprocess1",async t=>await this.sendMessage("GZCA_PrepareSm2SignStep1",t));c(this,"sm2SignPreprocess2",async t=>await this.sendMessage("GZCA_PrepareSm2SignStep2",t));c(this,"pkcs1HashSign",async t=>await this.sendMessage("GZCA_Pkcs1SignDataForHash",{...t??{},IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1HashVerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySignForHash",t));c(this,"pkcs7Sign",async t=>await this.sendMessage("GZCA_Pkcs7SignData",{...t,IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy}));c(this,"pkcs7VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs7VerifySign",t));c(this,"sm3Hash",async t=>await this.sendMessage("GZCA_HashData",t));c(this,"sm3HexHash",async t=>await this.sendMessage("GZCA_HashDataEx",t));c(this,"sm3FileHash",async t=>await this.sendMessage("GZCA_HashFile",t));c(this,"sm3HashEncryption",async t=>await this.sendMessage("GZCA_HMac",t));c(this,"pkcs7Encryption",async t=>await this.sendMessage("GZCA_Pkcs7EncryptData",t));c(this,"pkcs7Decryption",async t=>await this.sendMessage("GZCA_Pkcs7DecryptData",{...t,IsLogin:this.getIsLogin()}));c(this,"asymmetricEncryption",async t=>await this.sendMessage("GZCA_AsymEncryptData",t));c(this,"asymmetricDecryption",async t=>await this.sendMessage("GZCA_AsymDecryptData",{...t,IsLogin:this.getIsLogin()}));c(this,"sm4Encryption",async t=>await this.sendMessage("GZCA_EncryptDataEx",t));c(this,"sm4Decryption",async t=>await this.sendMessage("GZCA_DecryptDataEx",t));c(this,"getCertInfo",async t=>await this.sendMessage("GZCA_GetCertInfo",t));c(this,"getCertInfoByOid",async t=>await this.sendMessage("GZCA_GetCertInfoByOid",t));this.socketInstance=this.createSocket(t),this.isRememberPin=t.isRememberPin??!1,this.pinPolicy=t.pinPolicy??st.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)},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 G=class G{constructor(t){c(this,"coreInstance",null);c(this,"gwsConfig",{});c(this,"createGwsCore",t=>{this.gwsConfig=t??{},this.coreInstance=new ce({...t??{},url:p})});c(this,"appendCertBase64",async(t,e=!0)=>{if(t.CertB64)return t;const s=e?await this.getSignatureCert():await this.getEncryptionCert();return{...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??this.gwsConfig,this.createGwsCore(t)});c(this,"getSocketReadyState",()=>{var t;return(t=this.coreInstance)==null?void 0:t.getSocketReadyState()});c(this,"getSignatureCert",async t=>{var s;return await((s=this.coreInstance)==null?void 0:s.getCert({CertType:_},t))});c(this,"getEncryptionCert",async t=>{var s;return await((s=this.coreInstance)==null?void 0:s.getCert({CertType:kt},t))});c(this,"base64Encode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Encode(t)});c(this,"base64Decode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Decode(t)});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",async(t,e)=>{var r,o;const s=await this.getSignatureCert(e),a=await((r=this.coreInstance)==null?void 0:r.pkcs1Sign({...t??{},ContainerName:(s==null?void 0:s.ContainerName)??""}));return(o=a==null?void 0:a[0])==null?void 0:o.SignData});c(this,"pkcs1VerifySignature",async t=>{var a;const e=await this.appendCertBase64(t),s=await((a=this.coreInstance)==null?void 0:a.pkcs1VerifySignature(e));return Array.isArray(s)});c(this,"pkcs1Base64Sign",async(t,e)=>{var o,i;const s=await this.getSignatureCert(e),a=t.DataB64??this.base64Encode(t.Data??""),r=await((o=this.coreInstance)==null?void 0:o.pkcs1Base64Sign({ContainerName:(s==null?void 0:s.ContainerName)??"",DataB64:a}));return(i=r==null?void 0:r[0])==null?void 0:i.SignData});c(this,"pkcs1Base64VerifySignature",async t=>{var r;const e=t.DataB64??this.base64Encode(t.Data??""),s=await this.appendCertBase64(t);return!!await((r=this.coreInstance)==null?void 0:r.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:e,SignData:s.SignData}))});c(this,"getSealList",async()=>{var s;const t=await this.getSignatureCert(),e=await((s=this.coreInstance)==null?void 0:s.getSealList({ContainerName:(t==null?void 0:t.ContainerName)??""}));return{cert:t,sealList:e}});c(this,"sm2SignPreprocess1",async t=>{var a,r;const e=await this.appendCertBase64(t),s=await((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",async t=>{var r;const e=this.base64Encode(t.Data),s=await this.appendCertBase64(t),a=await((r=this.coreInstance)==null?void 0:r.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:e}));return a==null?void 0:a[0].H});c(this,"pkcs1HashSign",async(t,e)=>{var r,o;const s=await this.getSignatureCert(e),a=await((r=this.coreInstance)==null?void 0:r.pkcs1HashSign({ContainerName:(s==null?void 0:s.ContainerName)??"",DataB64:t.DataB64,HashAlg:t.HashAlg??"sm3"}));return(o=a==null?void 0:a[0])==null?void 0:o.SignData});c(this,"pkcs1HashVerifySignature",async t=>{var a;const e=await this.appendCertBase64(t);return!!await((a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature({...e,HashAlg:e.HashAlg??"sm3"}))});c(this,"pkcs7Sign",async(t,e)=>{var o,i;const s=t.DataB64??this.base64Encode(t.Data??""),a=await this.getSignatureCert(e),r=await((o=this.coreInstance)==null?void 0:o.pkcs7Sign({IsDetached:t.IsDetached,ContainerName:(a==null?void 0:a.ContainerName)??"",DataB64:s}));return(i=r==null?void 0:r[0])==null?void 0:i.SignData});c(this,"pkcs7VerifySignature",async t=>{var a;const e=t.DataB64??this.base64Encode(t.Data??"");return!!await((a=this.coreInstance)==null?void 0:a.pkcs7VerifySignature({DataB64:e,SignData:t.SignData}))});c(this,"sm3Hash",async t=>{var s,a;const e=await((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",async t=>{var s,a;const e=await((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",async t=>{var s,a;const e=await((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",async t=>{var r,o;const e=t.DataB64??this.base64Encode(t.Data??""),s=t.KeyB64??this.base64Encode(t.Key??""),a=await((r=this.coreInstance)==null?void 0:r.sm3HashEncryption({dataB64:e,keyB64:s,alg:"sm3"}));return(o=a==null?void 0:a[0])==null?void 0:o.DataB64});c(this,"pkcs7Encryption",async t=>{var a,r;if(!t.CertB64List){const o=await this.getEncryptionCert();t.CertB64List=o==null?void 0:o.CertB64}const e=t.DataB64??this.base64Encode(t.Data??""),s=await((a=this.coreInstance)==null?void 0:a.pkcs7Encryption({DataB64:e,CertB64List:t.CertB64List}));return(r=s==null?void 0:s[0])==null?void 0:r.DataB64});c(this,"pkcs7Decryption",async t=>{var r,o;const e=await this.getEncryptionCert(),s=await((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(a):a});c(this,"asymmetricEncryption",async t=>{var a,r;const e=await this.appendCertBase64(t,!1),s=await((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",async t=>{var a,r;const e=await this.getEncryptionCert(),s=await((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",async t=>{var s;const e=await((s=this.coreInstance)==null?void 0:s.sm4Encryption(t));return e==null?void 0:e[0]});c(this,"sm4Decryption",async t=>{var s,a;const e=await((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",async()=>{var s;const t=await this.getSignatureCert(),e=await((s=this.coreInstance)==null?void 0:s.getCertInfo({CertB64:t==null?void 0:t.CertB64}));return{...(e==null?void 0:e[0])??{},...t??{}}});c(this,"getCertInfoByOid",async t=>{var a,r;const e=await this.getSignatureCert(),s=await((a=this.coreInstance)==null?void 0:a.getCertInfoByOid({...t??{},CertB64:e==null?void 0:e.CertB64}));return(r=s==null?void 0:s[0])==null?void 0:r.OidValue});return G.instance?G.instance:(this.createGwsCore(t),G.instance=this,this)}};c(G,"instance",null);let et=G;m.GwsService=et,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,26 +1,29 @@
1
- {
2
- "name": "gws-client",
3
- "version": "0.1.2",
4
- "type": "module",
5
- "main": "dist/index.umd.js",
6
- "module": "dist/index.es.js",
7
- "types": "dist/index.d.ts",
8
- "description": "gws client",
9
- "keywords": [
10
- "gzca",
11
- "signature",
12
- "encryption"
13
- ],
14
- "scripts": {
15
- "dev": "vite",
16
- "build": "vite build",
17
- "preview": "vite preview"
18
- },
19
- "dependencies": {
20
- "base64-js": "^1.5.1"
21
- },
22
- "author": "gzca",
23
- "files": [
24
- "dist"
25
- ]
26
- }
1
+ {
2
+ "name": "gws-client",
3
+ "version": "0.1.4",
4
+ "type": "module",
5
+ "main": "dist/index.umd.js",
6
+ "module": "src/index.es.js",
7
+ "types": "dist/index.d.ts",
8
+ "description": "gws client",
9
+ "keywords": [
10
+ "gzca",
11
+ "signature",
12
+ "encryption"
13
+ ],
14
+ "dependencies": {
15
+ "base64-js": "^1.5.1"
16
+ },
17
+ "author": "gzca",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "publishConfig": {
22
+ "registry": "https://registry.npmjs.org/"
23
+ },
24
+ "scripts": {
25
+ "dev": "vite",
26
+ "build": "vite build",
27
+ "preview": "vite preview"
28
+ }
29
+ }