gws-client 0.5.8 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +489 -495
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var De=Object.defineProperty,be=Object.defineProperties;var Be=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable;var J=(n,e,t)=>e in n?De(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,B=(n,e)=>{for(var t in e||(e={}))Se.call(e,t)&&J(n,t,e[t]);if(ee)for(var t of ee(e))xe.call(e,t)&&J(n,t,e[t]);return n},L=(n,e)=>be(n,Be(e));var i=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);var u=(n,e,t)=>new Promise((s,r)=>{var a=d=>{try{l(t.next(d))}catch(h){r(h)}},o=d=>{try{l(t.throw(d))}catch(h){r(h)}},l=d=>d.done?s(d.value):Promise.resolve(d.value).then(a,o);l((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ie=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",$e="1",Ae="2";var he=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(he||{});const Ee="00000001";function Le(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var N={},te;function _e(){if(te)return N;te=1,N.byteLength=l,N.toByteArray=h,N.fromByteArray=f;for(var n=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,a=s.length;r<a;++r)n[r]=s[r],e[s.charCodeAt(r)]=r;e[45]=62,e[95]=63;function o(y){var c=y.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=y.indexOf("=");m===-1&&(m=c);var k=m===c?0:4-m%4;return[m,k]}function l(y){var c=o(y),m=c[0],k=c[1];return(m+k)*3/4-k}function d(y,c,m){return(c+m)*3/4-m}function h(y){var c,m=o(y),k=m[0],C=m[1],v=new t(d(y,k,C)),D=0,A=C>0?k-4:k,w;for(w=0;w<A;w+=4)c=e[y.charCodeAt(w)]<<18|e[y.charCodeAt(w+1)]<<12|e[y.charCodeAt(w+2)]<<6|e[y.charCodeAt(w+3)],v[D++]=c>>16&255,v[D++]=c>>8&255,v[D++]=c&255;return C===2&&(c=e[y.charCodeAt(w)]<<2|e[y.charCodeAt(w+1)]>>4,v[D++]=c&255),C===1&&(c=e[y.charCodeAt(w)]<<10|e[y.charCodeAt(w+1)]<<4|e[y.charCodeAt(w+2)]>>2,v[D++]=c>>8&255,v[D++]=c&255),v}function g(y){return n[y>>18&63]+n[y>>12&63]+n[y>>6&63]+n[y&63]}function p(y,c,m){for(var k,C=[],v=c;v<m;v+=3)k=(y[v]<<16&16711680)+(y[v+1]<<8&65280)+(y[v+2]&255),C.push(g(k));return C.join("")}function f(y){for(var c,m=y.length,k=m%3,C=[],v=16383,D=0,A=m-k;D<A;D+=v)C.push(p(y,D,D+v>A?A:D+v));return k===1?(c=y[m-1],C.push(n[c>>2]+n[c<<4&63]+"==")):k===2&&(c=(y[m-2]<<8)+y[m-1],C.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),C.join("")}return N}var Pe=_e();const ne=Le(Pe);class Me{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 Te=Object.defineProperty,He=(n,e,t)=>e in n?Te(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,se=(n,e,t)=>He(n,typeof e!="symbol"?e+"":e,t);function Y(){}function Ge(n,e){for(const t in e)n[t]=e[t];return n}function ye(n){return n()}function re(){return Object.create(null)}function V(n){n.forEach(ye)}function j(n){return typeof n=="function"}function ge(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Ne(n){return Object.keys(n).length===0}function Fe(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?Ge(t.ctx.slice(),n[1](s(e))):t.ctx}function je(n,e,t,s){if(n[2]&&s){const r=n[2](s(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const a=[],o=Math.max(e.dirty.length,r.length);for(let l=0;l<o;l+=1)a[l]=e.dirty[l]|r[l];return a}return e.dirty|r}return e.dirty}function Oe(n,e,t,s,r,a){if(r){const o=fe(e,t,s,a);n.p(o,r)}}function Ze(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let s=0;s<t;s++)e[s]=-1;return e}return-1}function ae(n){return n!=null?n:""}function b(n,e){n.appendChild(e)}function W(n,e,t){n.insertBefore(e,t||null)}function U(n){n.parentNode&&n.parentNode.removeChild(n)}function Ve(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function I(n){return document.createElement(n)}function $(n){return document.createTextNode(n)}function O(){return $(" ")}function Re(){return $("")}function F(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function S(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ue(n){return Array.from(n.childNodes)}function T(n,e){e=""+e,n.data!==e&&(n.data=e)}function oe(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let Q;function Z(n){Q=n}const P=[],ie=[];let H=[];const ce=[],Je=Promise.resolve();let q=!1;function ze(){q||(q=!0,Je.then(pe))}function K(n){H.push(n)}const z=new Set;let _=0;function pe(){if(_!==0)return;const n=Q;do{try{for(;_<P.length;){const e=P[_];_++,Z(e),Ye(e.$$)}}catch(e){throw P.length=0,_=0,e}for(Z(null),P.length=0,_=0;ie.length;)ie.pop()();for(let e=0;e<H.length;e+=1){const t=H[e];z.has(t)||(z.add(t),t())}H.length=0}while(P.length);for(;ce.length;)ce.pop()();q=!1,z.clear(),Z(n)}function Ye(n){if(n.fragment!==null){n.update(),V(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(K)}}function qe(n){const e=[],t=[];H.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),H=e}const R=new Set;let Ke;function X(n,e){n&&n.i&&(R.delete(n),n.i(e))}function me(n,e,t,s){if(n&&n.o){if(R.has(n))return;R.add(n),Ke.c.push(()=>{R.delete(n)}),n.o(e)}}function le(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function We(n){n&&n.c()}function ve(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),K(()=>{const a=n.$$.on_mount.map(ye).filter(j);n.$$.on_destroy?n.$$.on_destroy.push(...a):V(a),n.$$.on_mount=[]}),r.forEach(K)}function Ce(n,e){const t=n.$$;t.fragment!==null&&(qe(t.after_update),V(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Qe(n,e){n.$$.dirty[0]===-1&&(P.push(n),ze(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function we(n,e,t,s,r,a,o=null,l=[-1]){const d=Q;Z(n);const h=n.$$={fragment:null,ctx:[],props:a,update:Y,not_equal:r,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:re(),dirty:l,skip_bound:!1,root:e.target||d.$$.root};o&&o(h.root);let g=!1;if(h.ctx=t?t(n,e.props||{},(p,f,...y)=>{const c=y.length?y[0]:f;return h.ctx&&r(h.ctx[p],h.ctx[p]=c)&&(!h.skip_bound&&h.bound[p]&&h.bound[p](c),g&&Qe(n,p)),f}):[],h.update(),g=!0,V(h.before_update),h.fragment=s?s(h.ctx):!1,e.target){if(e.hydrate){const p=Ue(e.target);h.fragment&&h.fragment.l(p),p.forEach(U)}else h.fragment&&h.fragment.c();e.intro&&X(n.$$.fragment),ve(n,e.target,e.anchor),pe()}Z(d)}class ke{constructor(){se(this,"$$"),se(this,"$$set")}$destroy(){Ce(this,1),this.$destroy=Y}$on(e,t){if(!j(t))return Y;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&&!Ne(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Xe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Xe);function et(n){let e,t,s,r=(n[1]||"标题")+"",a,o,l,d,h,g,p=(n[4]||"取消")+"",f,y,c,m=(n[5]||"确认")+"",k,C,v,D;const A=n[8].default,w=Fe(A,n,n[7],null);return{c(){e=I("div"),t=I("div"),s=I("div"),a=$(r),o=O(),l=I("div"),w&&w.c(),d=O(),h=I("div"),g=I("button"),f=$(p),y=O(),c=I("button"),k=$(m),S(s,"class","model-title svelte-oivou"),S(l,"class","slot svelte-oivou"),S(g,"class","modal-btn svelte-oivou"),S(c,"class","modal-btn success svelte-oivou"),oe(c,"background-color",n[6]),S(h,"class","modal-footer svelte-oivou"),S(t,"class","modal-content svelte-oivou"),S(e,"class","modal-background modal-visible svelte-oivou")},m(x,E){W(x,e,E),b(e,t),b(t,s),b(s,a),b(t,o),b(t,l),w&&w.m(l,null),b(t,d),b(t,h),b(h,g),b(g,f),b(h,y),b(h,c),b(c,k),C=!0,v||(D=[F(g,"click",function(){j(n[0])&&n[0].apply(this,arguments)}),F(c,"click",function(){j(n[2])&&n[2].apply(this,arguments)}),F(t,"click",tt),F(e,"click",function(){j(n[3])&&n[3].apply(this,arguments)})],v=!0)},p(x,[E]){n=x,(!C||E&2)&&r!==(r=(n[1]||"标题")+"")&&T(a,r),w&&w.p&&(!C||E&128)&&Oe(w,A,n,n[7],C?je(A,n[7],E,null):Ze(n[7]),null),(!C||E&16)&&p!==(p=(n[4]||"取消")+"")&&T(f,p),(!C||E&32)&&m!==(m=(n[5]||"确认")+"")&&T(k,m),(!C||E&64)&&oe(c,"background-color",n[6])},i(x){C||(X(w,x),C=!0)},o(x){me(w,x),C=!1},d(x){x&&U(e),w&&w.d(x),v=!1,V(D)}}}const tt=n=>n.stopPropagation();function nt(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:a}=e,{title:o}=e,{onOk:l}=e,{onClose:d}=e,{cancelText:h}=e,{okText:g}=e,{theme:p}=e;return n.$$set=f=>{"onCancel"in f&&t(0,a=f.onCancel),"title"in f&&t(1,o=f.title),"onOk"in f&&t(2,l=f.onOk),"onClose"in f&&t(3,d=f.onClose),"cancelText"in f&&t(4,h=f.cancelText),"okText"in f&&t(5,g=f.okText),"theme"in f&&t(6,p=f.theme),"$$scope"in f&&t(7,r=f.$$scope)},[a,o,l,d,h,g,p,r,s]}class st extends ke{constructor(e){super(),we(this,e,nt,et,ge,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function ue(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function de(n){let e,t,s=n[11].CN+"",r,a,o,l=n[11].DevClass+"",d,h,g=n[11].sn+"",p,f,y,c,m,k;function C(){return n[10](n[13])}return{c(){e=I("div"),t=I("span"),r=$(s),a=O(),o=I("span"),d=$(l),h=$("("),p=$(g),f=$(")"),y=O(),S(t,"class","svelte-jtc2v4"),S(o,"class","svelte-jtc2v4"),S(e,"class",c=ae(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(v,D){W(v,e,D),b(e,t),b(t,r),b(e,a),b(e,o),b(o,d),b(o,h),b(o,p),b(o,f),b(e,y),m||(k=F(e,"click",C),m=!0)},p(v,D){n=v,D&1&&s!==(s=n[11].CN+"")&&T(r,s),D&1&&l!==(l=n[11].DevClass+"")&&T(d,l),D&1&&g!==(g=n[11].sn+"")&&T(p,g),D&32&&c!==(c=ae(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&S(e,"class",c)},d(v){v&&U(e),m=!1,k()}}}function rt(n){let e,t=le(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=de(ue(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Re()},m(r,a){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(r,a);W(r,e,a)},p(r,a){if(a&33){t=le(r[0]);let o;for(o=0;o<t.length;o+=1){const l=ue(r,t,o);s[o]?s[o].p(l,a):(s[o]=de(l),s[o].c(),s[o].m(e.parentNode,e))}for(;o<s.length;o+=1)s[o].d(1);s.length=t.length}},d(r){r&&U(e),Ve(s,r)}}}function at(n){let e,t;return e=new st({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[rt]},$$scope:{ctx:n}}}),{c(){We(e.$$.fragment)},m(s,r){ve(e,s,r),t=!0},p(s,[r]){const a={};r&2&&(a.onClose=s[1]),r&4&&(a.cancelText=s[2]),r&8&&(a.okText=s[3]),r&16&&(a.theme=s[4]),r&16417&&(a.$$scope={dirty:r,ctx:s}),e.$set(a)},i(s){t||(X(e.$$.fragment,s),t=!0)},o(s){me(e.$$.fragment,s),t=!1},d(s){Ce(e,s)}}}function ot(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:o}=e,{cancelText:l=""}=e,{okText:d=""}=e,{theme:h="#409eff"}=e,g=0;const p=()=>{r("未选择证书"),o==null||o()},f=()=>{a==null||a(s[g]),o==null||o()},y=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,a=c.onOk),"onClose"in c&&t(1,o=c.onClose),"cancelText"in c&&t(2,l=c.cancelText),"okText"in c&&t(3,d=c.okText),"theme"in c&&t(4,h=c.theme)},[s,o,l,d,h,g,p,f,r,a,y]}class it extends ke{constructor(e){super(),we(this,e,ot,at,ge,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class ct{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new it({target:document.body,props:L(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 lt=new ct;class ut{constructor(e){i(this,"socketInstance",null);i(this,"eventBus",new Me);i(this,"isRememberPin",!1);i(this,"socketEvent");i(this,"pinPolicy");i(this,"socketConfig",null);i(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});i(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});i(this,"sendMessage",(e,t)=>new Promise((s,r)=>{var o,l;if(((o=this.socketInstance)==null?void 0:o.readyState)!==WebSocket.OPEN){r({errCode:-1,msg:"socket未连接"});return}const a={function:e,args:[t!=null?t:{}]};(l=this.socketInstance)==null||l.send(JSON.stringify(a)),this.eventBus.on(e,d=>{d.success?s(d.data):r(d)})}));i(this,"handleEventData",e=>u(this,null,function*(){var t,s,r,a,o,l;if(e.data instanceof Blob){const d=yield e.data.arrayBuffer(),g=new TextDecoder("gbk").decode(d),p=JSON.parse(g),f={data:p.data,success:(t=p.result)==null?void 0:t.success,msg:(s=p.result)==null?void 0:s.msg,errCode:(r=p.result)==null?void 0:r.errCode};this.eventBus.emit((a=p.result)==null?void 0:a.function,f),(l=(o=this.socketConfig)==null?void 0:o.onMessage)==null||l.call(o,f)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return ne.fromByteArray(t)});i(this,"base64Decode",e=>{const t=ne.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>u(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>u(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>u(this,null,function*(){this.sendMessage("GZCA_StartListen",{Type:Ee}).then(e=>{var t,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyEvent)==null||s.call(t,e)})}));i(this,"certLogin",e=>u(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)=>u(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return yield this.certLogin(s.ContainerName),s}));i(this,"getCertList",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"chooseCert",e=>u(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield lt.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"pkcs1Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>u(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=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>u(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:he.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),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 M=class M{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ut(L(B({},e!=null?e:{}),{url:Ie}))});i(this,"appendCertBase64",(e,t=!0)=>u(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return L(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=>u(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:$e},e)}));i(this,"getEncryptionCert",e=>u(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:Ae},e)}));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)=>u(this,null,function*(){var a,o,l;const s=yield this.getSignatureCert(t),r=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(L(B({},e!=null?e:{}),{ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:"",IsLogin:t?"Y":"N"}));return(l=r==null?void 0:r[0])==null?void 0:l.SignData}));i(this,"pkcs1VerifySignature",e=>u(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)=>u(this,null,function*(){var o,l,d,h,g;const s=yield this.getSignatureCert(t),r=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),a=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign({ContainerName:(d=s==null?void 0:s.ContainerName)!=null?d:"",DataB64:r,IsLogin:t?"Y":"N"});return(g=a==null?void 0:a[0])==null?void 0:g.SignData}));i(this,"pkcs1Base64VerifySignature",e=>u(this,null,function*(){var a,o,l;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",e=>u(this,null,function*(){var r,a;const t=yield this.getSignatureCert(e),s=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:"",IsLogin:e?"Y":"N"});return{cert:t,sealList:s}}));i(this,"sm2SignPreprocess1",e=>u(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(a=s==null?void 0:s[0])==null?void 0:a.Z}));i(this,"sm2SignPreprocess2",e=>u(this,null,function*(){var a,o;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e),r=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:t});return r==null?void 0:r[0].H}));i(this,"pkcs1HashSign",(e,t)=>u(this,null,function*(){var a,o,l,d;const s=yield this.getSignatureCert(t),r=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3",IsLogin:t?"Y":"N"});return(d=r==null?void 0:r[0])==null?void 0:d.SignData}));i(this,"pkcs1HashVerifySignature",e=>u(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(L(B({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>u(this,null,function*(){var o,l,d,h,g;const s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield this.getSignatureCert(t),a=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign({IsDetached:e.IsDetached,ContainerName:(d=r==null?void 0:r.ContainerName)!=null?d:"",DataB64:s,IsLogin:t?"Y":"N"});return(g=a==null?void 0:a[0])==null?void 0:g.SignData}));i(this,"pkcs7VerifySignature",e=>u(this,null,function*(){var r,a,o;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));i(this,"sm3Hash",e=>u(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=>u(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=>u(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=>u(this,null,function*(){var a,o,l,d,h,g;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=(d=e.KeyB64)!=null?d:this.base64Encode({Data:(l=e.Key)!=null?l:""}),r=yield(h=this.coreInstance)==null?void 0:h.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(g=r==null?void 0:r[0])==null?void 0:g.DataB64}));i(this,"pkcs7Encryption",e=>u(this,null,function*(){var r,a,o,l;if(!e.CertB64List){const d=yield this.getEncryptionCert();e.CertB64List=d==null?void 0:d.CertB64}const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(l=s==null?void 0:s[0])==null?void 0:l.DataB64}));i(this,"pkcs7Decryption",e=>u(this,null,function*(){var a,o;const t=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption({DataB64:e.DataB64,ContainerName:t==null?void 0:t.ContainerName}),r=(o=s==null?void 0:s[0])==null?void 0:o.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:r}):r}));i(this,"asymmetricEncryption",e=>u(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(a=s==null?void 0:s[0])==null?void 0:a.Data}));i(this,"asymmetricDecryption",(e,t)=>u(this,null,function*(){var a,o;const s=yield this.getEncryptionCert(t),r=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption({Data:e.Data,ContainerName:s==null?void 0:s.ContainerName,IsLogin:t?"Y":"N"});return(o=r==null?void 0:r[0])==null?void 0:o.Data}));i(this,"sm4Encryption",e=>u(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=>u(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=>u(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=>u(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 M.instance&&!(e!=null&&e.isCreateNew)?M.instance:(this.createGwsCore(e),M.instance=this,this)}};i(M,"instance",null);let G=M;function dt(n){return new Promise((e,t)=>{if(G.instance&&!(n!=null&&n.isCreateNew))e(G.instance);else{const s=new G(L(B({},n!=null?n:{}),{onOpen(r){var a;e(s),(a=n==null?void 0:n.onOpen)==null||a.call(n,r)},onClose(r){var a;t(r),(a=n==null?void 0:n.onClose)==null||a.call(n,r)}}))}})}exports.GwsService=G;exports.createService=dt;
|
|
1
|
+
"use strict";var De=Object.defineProperty,be=Object.defineProperties;var Be=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable;var J=(n,e,t)=>e in n?De(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,B=(n,e)=>{for(var t in e||(e={}))Se.call(e,t)&&J(n,t,e[t]);if(ee)for(var t of ee(e))xe.call(e,t)&&J(n,t,e[t]);return n},_=(n,e)=>be(n,Be(e));var i=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);var u=(n,e,t)=>new Promise((s,r)=>{var a=d=>{try{l(t.next(d))}catch(h){r(h)}},o=d=>{try{l(t.throw(d))}catch(h){r(h)}},l=d=>d.done?s(d.value):Promise.resolve(d.value).then(a,o);l((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",Ie="1",Ae="2";var he=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(he||{});const Ee="00000001";function _e(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var F={},te;function Pe(){if(te)return F;te=1,F.byteLength=l,F.toByteArray=h,F.fromByteArray=g;for(var n=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,a=s.length;r<a;++r)n[r]=s[r],e[s.charCodeAt(r)]=r;e[45]=62,e[95]=63;function o(y){var c=y.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=y.indexOf("=");m===-1&&(m=c);var k=m===c?0:4-m%4;return[m,k]}function l(y){var c=o(y),m=c[0],k=c[1];return(m+k)*3/4-k}function d(y,c,m){return(c+m)*3/4-m}function h(y){var c,m=o(y),k=m[0],C=m[1],v=new t(d(y,k,C)),D=0,A=C>0?k-4:k,w;for(w=0;w<A;w+=4)c=e[y.charCodeAt(w)]<<18|e[y.charCodeAt(w+1)]<<12|e[y.charCodeAt(w+2)]<<6|e[y.charCodeAt(w+3)],v[D++]=c>>16&255,v[D++]=c>>8&255,v[D++]=c&255;return C===2&&(c=e[y.charCodeAt(w)]<<2|e[y.charCodeAt(w+1)]>>4,v[D++]=c&255),C===1&&(c=e[y.charCodeAt(w)]<<10|e[y.charCodeAt(w+1)]<<4|e[y.charCodeAt(w+2)]>>2,v[D++]=c>>8&255,v[D++]=c&255),v}function f(y){return n[y>>18&63]+n[y>>12&63]+n[y>>6&63]+n[y&63]}function p(y,c,m){for(var k,C=[],v=c;v<m;v+=3)k=(y[v]<<16&16711680)+(y[v+1]<<8&65280)+(y[v+2]&255),C.push(f(k));return C.join("")}function g(y){for(var c,m=y.length,k=m%3,C=[],v=16383,D=0,A=m-k;D<A;D+=v)C.push(p(y,D,D+v>A?A:D+v));return k===1?(c=y[m-1],C.push(n[c>>2]+n[c<<4&63]+"==")):k===2&&(c=(y[m-2]<<8)+y[m-1],C.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),C.join("")}return F}var Le=Pe();const ne=_e(Le);class Me{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 Te=Object.defineProperty,He=(n,e,t)=>e in n?Te(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,se=(n,e,t)=>He(n,typeof e!="symbol"?e+"":e,t);function q(){}function Ge(n,e){for(const t in e)n[t]=e[t];return n}function ye(n){return n()}function re(){return Object.create(null)}function V(n){n.forEach(ye)}function O(n){return typeof n=="function"}function fe(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Fe(n){return Object.keys(n).length===0}function je(n,e,t,s){if(n){const r=ge(n,e,t,s);return n[0](r)}}function ge(n,e,t,s){return n[1]&&s?Ge(t.ctx.slice(),n[1](s(e))):t.ctx}function Oe(n,e,t,s){if(n[2]&&s){const r=n[2](s(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const a=[],o=Math.max(e.dirty.length,r.length);for(let l=0;l<o;l+=1)a[l]=e.dirty[l]|r[l];return a}return e.dirty|r}return e.dirty}function Ne(n,e,t,s,r,a){if(r){const o=ge(e,t,s,a);n.p(o,r)}}function Ze(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let s=0;s<t;s++)e[s]=-1;return e}return-1}function ae(n){return n!=null?n:""}function b(n,e){n.appendChild(e)}function Q(n,e,t){n.insertBefore(e,t||null)}function U(n){n.parentNode&&n.parentNode.removeChild(n)}function Ve(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function $(n){return document.createElement(n)}function I(n){return document.createTextNode(n)}function N(){return I(" ")}function Re(){return I("")}function j(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function S(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ue(n){return Array.from(n.childNodes)}function T(n,e){e=""+e,n.data!==e&&(n.data=e)}function oe(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let X;function Z(n){X=n}const L=[],ie=[];let H=[];const ce=[],Je=Promise.resolve();let K=!1;function ze(){K||(K=!0,Je.then(pe))}function W(n){H.push(n)}const z=new Set;let P=0;function pe(){if(P!==0)return;const n=X;do{try{for(;P<L.length;){const e=L[P];P++,Z(e),qe(e.$$)}}catch(e){throw L.length=0,P=0,e}for(Z(null),L.length=0,P=0;ie.length;)ie.pop()();for(let e=0;e<H.length;e+=1){const t=H[e];z.has(t)||(z.add(t),t())}H.length=0}while(L.length);for(;ce.length;)ce.pop()();K=!1,z.clear(),Z(n)}function qe(n){if(n.fragment!==null){n.update(),V(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(W)}}function Ke(n){const e=[],t=[];H.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),H=e}const R=new Set;let We;function Y(n,e){n&&n.i&&(R.delete(n),n.i(e))}function me(n,e,t,s){if(n&&n.o){if(R.has(n))return;R.add(n),We.c.push(()=>{R.delete(n)}),n.o(e)}}function le(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Qe(n){n&&n.c()}function ve(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),W(()=>{const a=n.$$.on_mount.map(ye).filter(O);n.$$.on_destroy?n.$$.on_destroy.push(...a):V(a),n.$$.on_mount=[]}),r.forEach(W)}function Ce(n,e){const t=n.$$;t.fragment!==null&&(Ke(t.after_update),V(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Xe(n,e){n.$$.dirty[0]===-1&&(L.push(n),ze(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function we(n,e,t,s,r,a,o=null,l=[-1]){const d=X;Z(n);const h=n.$$={fragment:null,ctx:[],props:a,update:q,not_equal:r,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:re(),dirty:l,skip_bound:!1,root:e.target||d.$$.root};o&&o(h.root);let f=!1;if(h.ctx=t?t(n,e.props||{},(p,g,...y)=>{const c=y.length?y[0]:g;return h.ctx&&r(h.ctx[p],h.ctx[p]=c)&&(!h.skip_bound&&h.bound[p]&&h.bound[p](c),f&&Xe(n,p)),g}):[],h.update(),f=!0,V(h.before_update),h.fragment=s?s(h.ctx):!1,e.target){if(e.hydrate){const p=Ue(e.target);h.fragment&&h.fragment.l(p),p.forEach(U)}else h.fragment&&h.fragment.c();e.intro&&Y(n.$$.fragment),ve(n,e.target,e.anchor),pe()}Z(d)}class ke{constructor(){se(this,"$$"),se(this,"$$set")}$destroy(){Ce(this,1),this.$destroy=q}$on(e,t){if(!O(t))return q;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Fe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ye="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ye);function et(n){let e,t,s,r=(n[1]||"标题")+"",a,o,l,d,h,f,p=(n[4]||"取消")+"",g,y,c,m=(n[5]||"确认")+"",k,C,v,D;const A=n[8].default,w=je(A,n,n[7],null);return{c(){e=$("div"),t=$("div"),s=$("div"),a=I(r),o=N(),l=$("div"),w&&w.c(),d=N(),h=$("div"),f=$("button"),g=I(p),y=N(),c=$("button"),k=I(m),S(s,"class","model-title svelte-oivou"),S(l,"class","slot svelte-oivou"),S(f,"class","modal-btn svelte-oivou"),S(c,"class","modal-btn success svelte-oivou"),oe(c,"background-color",n[6]),S(h,"class","modal-footer svelte-oivou"),S(t,"class","modal-content svelte-oivou"),S(e,"class","modal-background modal-visible svelte-oivou")},m(x,E){Q(x,e,E),b(e,t),b(t,s),b(s,a),b(t,o),b(t,l),w&&w.m(l,null),b(t,d),b(t,h),b(h,f),b(f,g),b(h,y),b(h,c),b(c,k),C=!0,v||(D=[j(f,"click",function(){O(n[0])&&n[0].apply(this,arguments)}),j(c,"click",function(){O(n[2])&&n[2].apply(this,arguments)}),j(t,"click",tt),j(e,"click",function(){O(n[3])&&n[3].apply(this,arguments)})],v=!0)},p(x,[E]){n=x,(!C||E&2)&&r!==(r=(n[1]||"标题")+"")&&T(a,r),w&&w.p&&(!C||E&128)&&Ne(w,A,n,n[7],C?Oe(A,n[7],E,null):Ze(n[7]),null),(!C||E&16)&&p!==(p=(n[4]||"取消")+"")&&T(g,p),(!C||E&32)&&m!==(m=(n[5]||"确认")+"")&&T(k,m),(!C||E&64)&&oe(c,"background-color",n[6])},i(x){C||(Y(w,x),C=!0)},o(x){me(w,x),C=!1},d(x){x&&U(e),w&&w.d(x),v=!1,V(D)}}}const tt=n=>n.stopPropagation();function nt(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:a}=e,{title:o}=e,{onOk:l}=e,{onClose:d}=e,{cancelText:h}=e,{okText:f}=e,{theme:p}=e;return n.$$set=g=>{"onCancel"in g&&t(0,a=g.onCancel),"title"in g&&t(1,o=g.title),"onOk"in g&&t(2,l=g.onOk),"onClose"in g&&t(3,d=g.onClose),"cancelText"in g&&t(4,h=g.cancelText),"okText"in g&&t(5,f=g.okText),"theme"in g&&t(6,p=g.theme),"$$scope"in g&&t(7,r=g.$$scope)},[a,o,l,d,h,f,p,r,s]}class st extends ke{constructor(e){super(),we(this,e,nt,et,fe,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function ue(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function de(n){let e,t,s=n[11].CN+"",r,a,o,l=n[11].DevClass+"",d,h,f=n[11].sn+"",p,g,y,c,m,k;function C(){return n[10](n[13])}return{c(){e=$("div"),t=$("span"),r=I(s),a=N(),o=$("span"),d=I(l),h=I("("),p=I(f),g=I(")"),y=N(),S(t,"class","svelte-jtc2v4"),S(o,"class","svelte-jtc2v4"),S(e,"class",c=ae(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(v,D){Q(v,e,D),b(e,t),b(t,r),b(e,a),b(e,o),b(o,d),b(o,h),b(o,p),b(o,g),b(e,y),m||(k=j(e,"click",C),m=!0)},p(v,D){n=v,D&1&&s!==(s=n[11].CN+"")&&T(r,s),D&1&&l!==(l=n[11].DevClass+"")&&T(d,l),D&1&&f!==(f=n[11].sn+"")&&T(p,f),D&32&&c!==(c=ae(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&S(e,"class",c)},d(v){v&&U(e),m=!1,k()}}}function rt(n){let e,t=le(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=de(ue(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Re()},m(r,a){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(r,a);Q(r,e,a)},p(r,a){if(a&33){t=le(r[0]);let o;for(o=0;o<t.length;o+=1){const l=ue(r,t,o);s[o]?s[o].p(l,a):(s[o]=de(l),s[o].c(),s[o].m(e.parentNode,e))}for(;o<s.length;o+=1)s[o].d(1);s.length=t.length}},d(r){r&&U(e),Ve(s,r)}}}function at(n){let e,t;return e=new st({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[rt]},$$scope:{ctx:n}}}),{c(){Qe(e.$$.fragment)},m(s,r){ve(e,s,r),t=!0},p(s,[r]){const a={};r&2&&(a.onClose=s[1]),r&4&&(a.cancelText=s[2]),r&8&&(a.okText=s[3]),r&16&&(a.theme=s[4]),r&16417&&(a.$$scope={dirty:r,ctx:s}),e.$set(a)},i(s){t||(Y(e.$$.fragment,s),t=!0)},o(s){me(e.$$.fragment,s),t=!1},d(s){Ce(e,s)}}}function ot(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:o}=e,{cancelText:l=""}=e,{okText:d=""}=e,{theme:h="#409eff"}=e,f=0;const p=()=>{r("未选择证书"),o==null||o()},g=()=>{a==null||a(s[f]),o==null||o()},y=c=>t(5,f=c);return n.$$set=c=>{"certList"in c&&t(0,s=c.certList),"onCancel"in c&&t(8,r=c.onCancel),"onOk"in c&&t(9,a=c.onOk),"onClose"in c&&t(1,o=c.onClose),"cancelText"in c&&t(2,l=c.cancelText),"okText"in c&&t(3,d=c.okText),"theme"in c&&t(4,h=c.theme)},[s,o,l,d,h,f,p,g,r,a,y]}class it extends ke{constructor(e){super(),we(this,e,ot,at,fe,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class ct{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new it({target:document.body,props:_(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 lt=new ct;class ut{constructor(e){i(this,"socketInstance",null);i(this,"eventBus",new Me);i(this,"isRememberPin",!1);i(this,"socketEvent");i(this,"pinPolicy");i(this,"socketConfig",null);i(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});i(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});i(this,"sendMessage",(e,t)=>new Promise((s,r)=>{var o,l;if(((o=this.socketInstance)==null?void 0:o.readyState)!==WebSocket.OPEN){r({errCode:-1,msg:"socket未连接"});return}const a={function:e,args:[t!=null?t:{}]};(l=this.socketInstance)==null||l.send(JSON.stringify(a)),this.eventBus.on(e,d=>{d.success?s(d.data):r(d)})}));i(this,"handleEventData",e=>u(this,null,function*(){var t,s,r,a,o,l;if(e.data instanceof Blob){const d=yield e.data.arrayBuffer(),f=new TextDecoder("gbk").decode(d),p=JSON.parse(f),g={data:p.data,success:(t=p.result)==null?void 0:t.success,msg:(s=p.result)==null?void 0:s.msg,errCode:(r=p.result)==null?void 0:r.errCode};this.eventBus.emit((a=p.result)==null?void 0:a.function,g),(l=(o=this.socketConfig)==null?void 0:o.onMessage)==null||l.call(o,g)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return ne.fromByteArray(t)});i(this,"base64Decode",e=>{const t=ne.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>u(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>u(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>u(this,null,function*(){this.sendMessage("GZCA_StartListen",{Type:Ee}).then(e=>{var t,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyEvent)==null||s.call(t,e)})}));i(this,"certLogin",e=>u(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)=>u(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=>u(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield lt.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"getCertList",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"pkcs1Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>u(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=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>u(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:he.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),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 M=class M{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ut(_(B({},e!=null?e:{}),{url:$e}))});i(this,"appendCertBase64",(e,t=!0)=>u(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return _(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=>u(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:Ie},e)}));i(this,"getEncryptionCert",e=>u(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:Ae},e)}));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)=>u(this,null,function*(){var a,o,l;const s=yield this.getSignatureCert(t),r=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(_(B({},e!=null?e:{}),{ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:""}));return(l=r==null?void 0:r[0])==null?void 0:l.SignData}));i(this,"pkcs1VerifySignature",e=>u(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)=>u(this,null,function*(){var o,l,d,h,f;const s=yield this.getSignatureCert(t),r=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),a=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign({ContainerName:(d=s==null?void 0:s.ContainerName)!=null?d:"",DataB64:r});return(f=a==null?void 0:a[0])==null?void 0:f.SignData}));i(this,"pkcs1Base64VerifySignature",e=>u(this,null,function*(){var a,o,l;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",e=>u(this,null,function*(){var r,a;const t=yield this.getSignatureCert(e),s=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:""});return{cert:t,sealList:s}}));i(this,"sm2SignPreprocess1",e=>u(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(a=s==null?void 0:s[0])==null?void 0:a.Z}));i(this,"sm2SignPreprocess2",e=>u(this,null,function*(){var a,o;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e),r=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:t});return r==null?void 0:r[0].H}));i(this,"pkcs1HashSign",(e,t)=>u(this,null,function*(){var a,o,l,d;const s=yield this.getSignatureCert(t),r=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(d=r==null?void 0:r[0])==null?void 0:d.SignData}));i(this,"pkcs1HashVerifySignature",e=>u(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(_(B({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>u(this,null,function*(){var o,l,d,h,f;const s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield this.getSignatureCert(t),a=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign({IsDetached:e.IsDetached,ContainerName:(d=r==null?void 0:r.ContainerName)!=null?d:"",DataB64:s});return(f=a==null?void 0:a[0])==null?void 0:f.SignData}));i(this,"pkcs7VerifySignature",e=>u(this,null,function*(){var r,a,o;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));i(this,"sm3Hash",e=>u(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=>u(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=>u(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=>u(this,null,function*(){var a,o,l,d,h,f;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=(d=e.KeyB64)!=null?d:this.base64Encode({Data:(l=e.Key)!=null?l:""}),r=yield(h=this.coreInstance)==null?void 0:h.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(f=r==null?void 0:r[0])==null?void 0:f.DataB64}));i(this,"pkcs7Encryption",e=>u(this,null,function*(){var r,a,o,l;if(!e.CertB64List){const d=yield this.getEncryptionCert();e.CertB64List=d==null?void 0:d.CertB64}const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(l=s==null?void 0:s[0])==null?void 0:l.DataB64}));i(this,"pkcs7Decryption",e=>u(this,null,function*(){var a,o;const t=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption({DataB64:e.DataB64,ContainerName:t==null?void 0:t.ContainerName}),r=(o=s==null?void 0:s[0])==null?void 0:o.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:r}):r}));i(this,"asymmetricEncryption",e=>u(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(a=s==null?void 0:s[0])==null?void 0:a.Data}));i(this,"asymmetricDecryption",(e,t)=>u(this,null,function*(){var a,o;const s=yield this.getEncryptionCert(t),r=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption({Data:e.Data,ContainerName:s==null?void 0:s.ContainerName});return(o=r==null?void 0:r[0])==null?void 0:o.Data}));i(this,"sm4Encryption",e=>u(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=>u(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=>u(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=>u(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 M.instance&&!(e!=null&&e.isCreateNew)?M.instance:(this.createGwsCore(e),M.instance=this,this)}};i(M,"instance",null);let G=M;function dt(n){return new Promise((e,t)=>{if(G.instance&&!(n!=null&&n.isCreateNew))e(G.instance);else{const s=new G(_(B({},n!=null?n:{}),{onOpen(r){var a;e(s),(a=n==null?void 0:n.onOpen)==null||a.call(n,r)},onClose(r){var a;t(r),(a=n==null?void 0:n.onClose)==null||a.call(n,r)}}))}})}exports.GwsService=G;exports.createService=dt;
|