gws-client 0.5.9 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +133 -133
- package/dist/index.umd.js +1 -1
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ async function foo() {
|
|
|
84
84
|
| onError | 可选,socket错误时回调 | `(event: Event) => void` | -- |
|
|
85
85
|
| onClose | 可选,socket关闭时回调 | `(event: Event) => void` | -- |
|
|
86
86
|
| onMessage | 可选,socket收到消息时回调 | `(data: Record<string, any>) => void` | -- |
|
|
87
|
-
| onUkeyEvent | 可选,Ukey插入拔出时回调 | `(
|
|
87
|
+
| onUkeyEvent | 可选,Ukey插入拔出时回调 | `(event: {type: 'remove' \| 'insert', data: CertType}) => void` | -- |
|
|
88
88
|
| theme | 可选,弹窗主题色 | `String` | `#409eff` |
|
|
89
89
|
|
|
90
90
|
#### 示例
|
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},_=(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;
|
|
1
|
+
"use strict";var De=Object.defineProperty,be=Object.defineProperties;var Be=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,Se=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={}))xe.call(e,t)&&J(n,t,e[t]);if(ee)for(var t of ee(e))Se.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",Ee="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 Ae="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=p;for(var n=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,a=s.length;r<a;++r)n[r]=s[r],e[s.charCodeAt(r)]=r;e[45]=62,e[95]=63;function o(y){var c=y.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=y.indexOf("=");f===-1&&(f=c);var w=f===c?0:4-f%4;return[f,w]}function l(y){var c=o(y),f=c[0],w=c[1];return(f+w)*3/4-w}function d(y,c,f){return(c+f)*3/4-f}function h(y){var c,f=o(y),w=f[0],m=f[1],C=new t(d(y,w,m)),D=0,E=m>0?w-4:w,k;for(k=0;k<E;k+=4)c=e[y.charCodeAt(k)]<<18|e[y.charCodeAt(k+1)]<<12|e[y.charCodeAt(k+2)]<<6|e[y.charCodeAt(k+3)],C[D++]=c>>16&255,C[D++]=c>>8&255,C[D++]=c&255;return m===2&&(c=e[y.charCodeAt(k)]<<2|e[y.charCodeAt(k+1)]>>4,C[D++]=c&255),m===1&&(c=e[y.charCodeAt(k)]<<10|e[y.charCodeAt(k+1)]<<4|e[y.charCodeAt(k+2)]>>2,C[D++]=c>>8&255,C[D++]=c&255),C}function g(y){return n[y>>18&63]+n[y>>12&63]+n[y>>6&63]+n[y&63]}function v(y,c,f){for(var w,m=[],C=c;C<f;C+=3)w=(y[C]<<16&16711680)+(y[C+1]<<8&65280)+(y[C+2]&255),m.push(g(w));return m.join("")}function p(y){for(var c,f=y.length,w=f%3,m=[],C=16383,D=0,E=f-w;D<E;D+=C)m.push(v(y,D,D+C>E?E:D+C));return w===1?(c=y[f-1],m.push(n[c>>2]+n[c<<4&63]+"==")):w===2&&(c=(y[f-2]<<8)+y[f-1],m.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),m.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 W(){}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 x(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 q=!1;function ze(){q||(q=!0,Je.then(pe))}function K(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),We(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()();q=!1,z.clear(),Z(n)}function We(n){if(n.fragment!==null){n.update(),V(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(K)}}function qe(n){const e=[],t=[];H.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),H=e}const R=new Set;let Ke;function Y(n,e){n&&n.i&&(R.delete(n),n.i(e))}function 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 Qe(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(O);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 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:W,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||{},(v,p,...y)=>{const c=y.length?y[0]:p;return h.ctx&&r(h.ctx[v],h.ctx[v]=c)&&(!h.skip_bound&&h.bound[v]&&h.bound[v](c),g&&Xe(n,v)),p}):[],h.update(),g=!0,V(h.before_update),h.fragment=s?s(h.ctx):!1,e.target){if(e.hydrate){const v=Ue(e.target);h.fragment&&h.fragment.l(v),v.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=W}$on(e,t){if(!O(t))return W;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Fe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ye="4";typeof window<"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,g,v=(n[4]||"取消")+"",p,y,c,f=(n[5]||"确认")+"",w,m,C,D;const E=n[8].default,k=je(E,n,n[7],null);return{c(){e=$("div"),t=$("div"),s=$("div"),a=I(r),o=N(),l=$("div"),k&&k.c(),d=N(),h=$("div"),g=$("button"),p=I(v),y=N(),c=$("button"),w=I(f),x(s,"class","model-title svelte-oivou"),x(l,"class","slot svelte-oivou"),x(g,"class","modal-btn svelte-oivou"),x(c,"class","modal-btn success svelte-oivou"),oe(c,"background-color",n[6]),x(h,"class","modal-footer svelte-oivou"),x(t,"class","modal-content svelte-oivou"),x(e,"class","modal-background modal-visible svelte-oivou")},m(S,A){Q(S,e,A),b(e,t),b(t,s),b(s,a),b(t,o),b(t,l),k&&k.m(l,null),b(t,d),b(t,h),b(h,g),b(g,p),b(h,y),b(h,c),b(c,w),m=!0,C||(D=[j(g,"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)})],C=!0)},p(S,[A]){n=S,(!m||A&2)&&r!==(r=(n[1]||"标题")+"")&&T(a,r),k&&k.p&&(!m||A&128)&&Ne(k,E,n,n[7],m?Oe(E,n[7],A,null):Ze(n[7]),null),(!m||A&16)&&v!==(v=(n[4]||"取消")+"")&&T(p,v),(!m||A&32)&&f!==(f=(n[5]||"确认")+"")&&T(w,f),(!m||A&64)&&oe(c,"background-color",n[6])},i(S){m||(Y(k,S),m=!0)},o(S){me(k,S),m=!1},d(S){S&&U(e),k&&k.d(S),C=!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:v}=e;return n.$$set=p=>{"onCancel"in p&&t(0,a=p.onCancel),"title"in p&&t(1,o=p.title),"onOk"in p&&t(2,l=p.onOk),"onClose"in p&&t(3,d=p.onClose),"cancelText"in p&&t(4,h=p.cancelText),"okText"in p&&t(5,g=p.okText),"theme"in p&&t(6,v=p.theme),"$$scope"in p&&t(7,r=p.$$scope)},[a,o,l,d,h,g,v,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,g=n[11].sn+"",v,p,y,c,f,w;function m(){return n[10](n[13])}return{c(){e=$("div"),t=$("span"),r=I(s),a=N(),o=$("span"),d=I(l),h=I("("),v=I(g),p=I(")"),y=N(),x(t,"class","svelte-jtc2v4"),x(o,"class","svelte-jtc2v4"),x(e,"class",c=ae(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(C,D){Q(C,e,D),b(e,t),b(t,r),b(e,a),b(e,o),b(o,d),b(o,h),b(o,v),b(o,p),b(e,y),f||(w=j(e,"click",m),f=!0)},p(C,D){n=C,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(v,g),D&32&&c!==(c=ae(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&x(e,"class",c)},d(C){C&&U(e),f=!1,w()}}}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,g=0;const v=()=>{r("未选择证书"),o==null||o()},p=()=>{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,v,p,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,d,h,g,v;if(e.data instanceof Blob){const p=yield e.data.arrayBuffer(),c=new TextDecoder("gbk").decode(p),f=JSON.parse(c),w={data:f.data,success:(t=f.result)==null?void 0:t.success,msg:(s=f.result)==null?void 0:s.msg,errCode:(r=f.result)==null?void 0:r.errCode},m=(a=f.result)==null?void 0:a.function;m==="GZCA_OnDeviceChange"?(h=(o=this.socketConfig)==null?void 0:o.onUkeyEvent)==null||h.call(o,{type:(l=f.result)==null?void 0:l.event,data:(d=f.data)==null?void 0:d[0]}):this.eventBus.emit(m,w),(v=(g=this.socketConfig)==null?void 0:g.onMessage)==null||v.call(g,w)}}));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_WaitForDevEvent",{Type:Ae})}));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),e.onUkeyEvent&&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:Ee},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,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});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:""});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,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});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});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;
|
package/dist/index.es.js
CHANGED
|
@@ -27,16 +27,16 @@ var u = (n, e, t) => new Promise((s, r) => {
|
|
|
27
27
|
}, l = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(a, o);
|
|
28
28
|
l((t = t.apply(n, e)).next());
|
|
29
29
|
});
|
|
30
|
-
const $e = window.location.href.includes("https") ? "wss://localhost:19528" : "ws://localhost:9527", Ie = "1",
|
|
30
|
+
const $e = window.location.href.includes("https") ? "wss://localhost:19528" : "ws://localhost:9527", Ie = "1", Ee = "2";
|
|
31
31
|
var he = /* @__PURE__ */ ((n) => (n[n.MIN = 0] = "MIN", n[n.LOW = 1] = "LOW", n[n.MIDDLE = 2] = "MIDDLE", n[n.HIGH = 3] = "HIGH", n))(he || {});
|
|
32
|
-
const
|
|
32
|
+
const Ae = "00000001";
|
|
33
33
|
function _e(n) {
|
|
34
34
|
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
35
35
|
}
|
|
36
36
|
var G = {}, te;
|
|
37
|
-
function
|
|
37
|
+
function Pe() {
|
|
38
38
|
if (te) return G;
|
|
39
|
-
te = 1, G.byteLength = l, G.toByteArray = h, G.fromByteArray =
|
|
39
|
+
te = 1, G.byteLength = l, G.toByteArray = h, G.fromByteArray = p;
|
|
40
40
|
for (var n = [], e = [], t = typeof Uint8Array != "undefined" ? Uint8Array : Array, s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", r = 0, a = s.length; r < a; ++r)
|
|
41
41
|
n[r] = s[r], e[s.charCodeAt(r)] = r;
|
|
42
42
|
e[45] = 62, e[95] = 63;
|
|
@@ -44,45 +44,45 @@ function Le() {
|
|
|
44
44
|
var c = y.length;
|
|
45
45
|
if (c % 4 > 0)
|
|
46
46
|
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
var
|
|
50
|
-
return [
|
|
47
|
+
var f = y.indexOf("=");
|
|
48
|
+
f === -1 && (f = c);
|
|
49
|
+
var w = f === c ? 0 : 4 - f % 4;
|
|
50
|
+
return [f, w];
|
|
51
51
|
}
|
|
52
52
|
function l(y) {
|
|
53
|
-
var c = o(y),
|
|
54
|
-
return (
|
|
53
|
+
var c = o(y), f = c[0], w = c[1];
|
|
54
|
+
return (f + w) * 3 / 4 - w;
|
|
55
55
|
}
|
|
56
|
-
function d(y, c,
|
|
57
|
-
return (c +
|
|
56
|
+
function d(y, c, f) {
|
|
57
|
+
return (c + f) * 3 / 4 - f;
|
|
58
58
|
}
|
|
59
59
|
function h(y) {
|
|
60
|
-
var c,
|
|
61
|
-
for (
|
|
62
|
-
c = e[y.charCodeAt(
|
|
63
|
-
return
|
|
60
|
+
var c, f = o(y), w = f[0], m = f[1], C = new t(d(y, w, m)), D = 0, E = m > 0 ? w - 4 : w, k;
|
|
61
|
+
for (k = 0; k < E; k += 4)
|
|
62
|
+
c = e[y.charCodeAt(k)] << 18 | e[y.charCodeAt(k + 1)] << 12 | e[y.charCodeAt(k + 2)] << 6 | e[y.charCodeAt(k + 3)], C[D++] = c >> 16 & 255, C[D++] = c >> 8 & 255, C[D++] = c & 255;
|
|
63
|
+
return m === 2 && (c = e[y.charCodeAt(k)] << 2 | e[y.charCodeAt(k + 1)] >> 4, C[D++] = c & 255), m === 1 && (c = e[y.charCodeAt(k)] << 10 | e[y.charCodeAt(k + 1)] << 4 | e[y.charCodeAt(k + 2)] >> 2, C[D++] = c >> 8 & 255, C[D++] = c & 255), C;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function g(y) {
|
|
66
66
|
return n[y >> 18 & 63] + n[y >> 12 & 63] + n[y >> 6 & 63] + n[y & 63];
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
for (var
|
|
70
|
-
|
|
71
|
-
return
|
|
68
|
+
function v(y, c, f) {
|
|
69
|
+
for (var w, m = [], C = c; C < f; C += 3)
|
|
70
|
+
w = (y[C] << 16 & 16711680) + (y[C + 1] << 8 & 65280) + (y[C + 2] & 255), m.push(g(w));
|
|
71
|
+
return m.join("");
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
for (var c,
|
|
75
|
-
|
|
76
|
-
return
|
|
73
|
+
function p(y) {
|
|
74
|
+
for (var c, f = y.length, w = f % 3, m = [], C = 16383, D = 0, E = f - w; D < E; D += C)
|
|
75
|
+
m.push(v(y, D, D + C > E ? E : D + C));
|
|
76
|
+
return w === 1 ? (c = y[f - 1], m.push(
|
|
77
77
|
n[c >> 2] + n[c << 4 & 63] + "=="
|
|
78
|
-
)) :
|
|
78
|
+
)) : w === 2 && (c = (y[f - 2] << 8) + y[f - 1], m.push(
|
|
79
79
|
n[c >> 10] + n[c >> 4 & 63] + n[c << 2 & 63] + "="
|
|
80
|
-
)),
|
|
80
|
+
)), m.join("");
|
|
81
81
|
}
|
|
82
82
|
return G;
|
|
83
83
|
}
|
|
84
|
-
var
|
|
85
|
-
const ne = /* @__PURE__ */ _e(
|
|
84
|
+
var Le = Pe();
|
|
85
|
+
const ne = /* @__PURE__ */ _e(Le);
|
|
86
86
|
class He {
|
|
87
87
|
constructor() {
|
|
88
88
|
i(this, "deps", /* @__PURE__ */ new Map());
|
|
@@ -104,7 +104,7 @@ class He {
|
|
|
104
104
|
}
|
|
105
105
|
})();
|
|
106
106
|
var Me = Object.defineProperty, Te = (n, e, t) => e in n ? Me(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, se = (n, e, t) => Te(n, typeof e != "symbol" ? e + "" : e, t);
|
|
107
|
-
function
|
|
107
|
+
function W() {
|
|
108
108
|
}
|
|
109
109
|
function Ge(n, e) {
|
|
110
110
|
for (const t in e) n[t] = e[t];
|
|
@@ -218,62 +218,62 @@ let X;
|
|
|
218
218
|
function O(n) {
|
|
219
219
|
X = n;
|
|
220
220
|
}
|
|
221
|
-
const
|
|
221
|
+
const L = [], ie = [];
|
|
222
222
|
let T = [];
|
|
223
223
|
const ce = [], Je = /* @__PURE__ */ Promise.resolve();
|
|
224
|
-
let
|
|
224
|
+
let q = !1;
|
|
225
225
|
function ze() {
|
|
226
|
-
|
|
226
|
+
q || (q = !0, Je.then(pe));
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function K(n) {
|
|
229
229
|
T.push(n);
|
|
230
230
|
}
|
|
231
231
|
const z = /* @__PURE__ */ new Set();
|
|
232
|
-
let
|
|
232
|
+
let P = 0;
|
|
233
233
|
function pe() {
|
|
234
|
-
if (
|
|
234
|
+
if (P !== 0)
|
|
235
235
|
return;
|
|
236
236
|
const n = X;
|
|
237
237
|
do {
|
|
238
238
|
try {
|
|
239
|
-
for (;
|
|
240
|
-
const e = P
|
|
241
|
-
|
|
239
|
+
for (; P < L.length; ) {
|
|
240
|
+
const e = L[P];
|
|
241
|
+
P++, O(e), We(e.$$);
|
|
242
242
|
}
|
|
243
243
|
} catch (e) {
|
|
244
|
-
throw
|
|
244
|
+
throw L.length = 0, P = 0, e;
|
|
245
245
|
}
|
|
246
|
-
for (O(null),
|
|
246
|
+
for (O(null), L.length = 0, P = 0; ie.length; ) ie.pop()();
|
|
247
247
|
for (let e = 0; e < T.length; e += 1) {
|
|
248
248
|
const t = T[e];
|
|
249
249
|
z.has(t) || (z.add(t), t());
|
|
250
250
|
}
|
|
251
251
|
T.length = 0;
|
|
252
|
-
} while (
|
|
252
|
+
} while (L.length);
|
|
253
253
|
for (; ce.length; )
|
|
254
254
|
ce.pop()();
|
|
255
|
-
|
|
255
|
+
q = !1, z.clear(), O(n);
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function We(n) {
|
|
258
258
|
if (n.fragment !== null) {
|
|
259
259
|
n.update(), V(n.before_update);
|
|
260
260
|
const e = n.dirty;
|
|
261
|
-
n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(
|
|
261
|
+
n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(K);
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
function
|
|
264
|
+
function qe(n) {
|
|
265
265
|
const e = [], t = [];
|
|
266
266
|
T.forEach((s) => n.indexOf(s) === -1 ? e.push(s) : t.push(s)), t.forEach((s) => s()), T = e;
|
|
267
267
|
}
|
|
268
268
|
const R = /* @__PURE__ */ new Set();
|
|
269
|
-
let
|
|
269
|
+
let Ke;
|
|
270
270
|
function Y(n, e) {
|
|
271
271
|
n && n.i && (R.delete(n), n.i(e));
|
|
272
272
|
}
|
|
273
273
|
function me(n, e, t, s) {
|
|
274
274
|
if (n && n.o) {
|
|
275
275
|
if (R.has(n)) return;
|
|
276
|
-
R.add(n),
|
|
276
|
+
R.add(n), Ke.c.push(() => {
|
|
277
277
|
R.delete(n);
|
|
278
278
|
}), n.o(e);
|
|
279
279
|
}
|
|
@@ -286,17 +286,17 @@ function Qe(n) {
|
|
|
286
286
|
}
|
|
287
287
|
function ve(n, e, t) {
|
|
288
288
|
const { fragment: s, after_update: r } = n.$$;
|
|
289
|
-
s && s.m(e, t),
|
|
289
|
+
s && s.m(e, t), K(() => {
|
|
290
290
|
const a = n.$$.on_mount.map(ye).filter(j);
|
|
291
291
|
n.$$.on_destroy ? n.$$.on_destroy.push(...a) : V(a), n.$$.on_mount = [];
|
|
292
|
-
}), r.forEach(
|
|
292
|
+
}), r.forEach(K);
|
|
293
293
|
}
|
|
294
294
|
function Ce(n, e) {
|
|
295
295
|
const t = n.$$;
|
|
296
|
-
t.fragment !== null && (
|
|
296
|
+
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 = []);
|
|
297
297
|
}
|
|
298
298
|
function Xe(n, e) {
|
|
299
|
-
n.$$.dirty[0] === -1 && (
|
|
299
|
+
n.$$.dirty[0] === -1 && (L.push(n), ze(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31;
|
|
300
300
|
}
|
|
301
301
|
function we(n, e, t, s, r, a, o = null, l = [-1]) {
|
|
302
302
|
const d = X;
|
|
@@ -306,7 +306,7 @@ function we(n, e, t, s, r, a, o = null, l = [-1]) {
|
|
|
306
306
|
ctx: [],
|
|
307
307
|
// state
|
|
308
308
|
props: a,
|
|
309
|
-
update:
|
|
309
|
+
update: W,
|
|
310
310
|
not_equal: r,
|
|
311
311
|
bound: re(),
|
|
312
312
|
// lifecycle
|
|
@@ -323,14 +323,14 @@ function we(n, e, t, s, r, a, o = null, l = [-1]) {
|
|
|
323
323
|
root: e.target || d.$$.root
|
|
324
324
|
};
|
|
325
325
|
o && o(h.root);
|
|
326
|
-
let
|
|
327
|
-
if (h.ctx = t ? t(n, e.props || {}, (
|
|
328
|
-
const c = y.length ? y[0] :
|
|
329
|
-
return h.ctx && r(h.ctx[
|
|
330
|
-
}) : [], h.update(),
|
|
326
|
+
let g = !1;
|
|
327
|
+
if (h.ctx = t ? t(n, e.props || {}, (v, p, ...y) => {
|
|
328
|
+
const c = y.length ? y[0] : p;
|
|
329
|
+
return h.ctx && r(h.ctx[v], h.ctx[v] = c) && (!h.skip_bound && h.bound[v] && h.bound[v](c), g && Xe(n, v)), p;
|
|
330
|
+
}) : [], h.update(), g = !0, V(h.before_update), h.fragment = s ? s(h.ctx) : !1, e.target) {
|
|
331
331
|
if (e.hydrate) {
|
|
332
|
-
const
|
|
333
|
-
h.fragment && h.fragment.l(
|
|
332
|
+
const v = Ue(e.target);
|
|
333
|
+
h.fragment && h.fragment.l(v), v.forEach(U);
|
|
334
334
|
} else
|
|
335
335
|
h.fragment && h.fragment.c();
|
|
336
336
|
e.intro && Y(n.$$.fragment), ve(n, e.target, e.anchor), pe();
|
|
@@ -343,7 +343,7 @@ class ke {
|
|
|
343
343
|
}
|
|
344
344
|
/** @returns {void} */
|
|
345
345
|
$destroy() {
|
|
346
|
-
Ce(this, 1), this.$destroy =
|
|
346
|
+
Ce(this, 1), this.$destroy = W;
|
|
347
347
|
}
|
|
348
348
|
/**
|
|
349
349
|
* @template {Extract<keyof Events, string>} K
|
|
@@ -353,7 +353,7 @@ class ke {
|
|
|
353
353
|
*/
|
|
354
354
|
$on(e, t) {
|
|
355
355
|
if (!j(t))
|
|
356
|
-
return
|
|
356
|
+
return W;
|
|
357
357
|
const s = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
|
|
358
358
|
return s.push(t), () => {
|
|
359
359
|
const r = s.indexOf(t);
|
|
@@ -374,18 +374,18 @@ function et(n) {
|
|
|
374
374
|
let e, t, s, r = (
|
|
375
375
|
/*title*/
|
|
376
376
|
(n[1] || "标题") + ""
|
|
377
|
-
), a, o, l, d, h,
|
|
377
|
+
), a, o, l, d, h, g, v = (
|
|
378
378
|
/*cancelText*/
|
|
379
379
|
(n[4] || "取消") + ""
|
|
380
|
-
),
|
|
380
|
+
), p, y, c, f = (
|
|
381
381
|
/*okText*/
|
|
382
382
|
(n[5] || "确认") + ""
|
|
383
|
-
),
|
|
384
|
-
const
|
|
383
|
+
), w, m, C, D;
|
|
384
|
+
const E = (
|
|
385
385
|
/*#slots*/
|
|
386
386
|
n[8].default
|
|
387
|
-
),
|
|
388
|
-
|
|
387
|
+
), k = je(
|
|
388
|
+
E,
|
|
389
389
|
n,
|
|
390
390
|
/*$$scope*/
|
|
391
391
|
n[7],
|
|
@@ -393,16 +393,16 @@ function et(n) {
|
|
|
393
393
|
);
|
|
394
394
|
return {
|
|
395
395
|
c() {
|
|
396
|
-
e = $("div"), t = $("div"), s = $("div"), a = I(r), o = N(), l = $("div"),
|
|
396
|
+
e = $("div"), t = $("div"), s = $("div"), a = I(r), o = N(), l = $("div"), k && k.c(), d = N(), h = $("div"), g = $("button"), p = I(v), y = N(), c = $("button"), w = I(f), x(s, "class", "model-title svelte-oivou"), x(l, "class", "slot svelte-oivou"), x(g, "class", "modal-btn svelte-oivou"), x(c, "class", "modal-btn success svelte-oivou"), oe(
|
|
397
397
|
c,
|
|
398
398
|
"background-color",
|
|
399
399
|
/*theme*/
|
|
400
400
|
n[6]
|
|
401
401
|
), x(h, "class", "modal-footer svelte-oivou"), x(t, "class", "modal-content svelte-oivou"), x(e, "class", "modal-background modal-visible svelte-oivou");
|
|
402
402
|
},
|
|
403
|
-
m(S,
|
|
404
|
-
Q(S, e,
|
|
405
|
-
F(
|
|
403
|
+
m(S, A) {
|
|
404
|
+
Q(S, e, A), b(e, t), b(t, s), b(s, a), b(t, o), b(t, l), k && k.m(l, null), b(t, d), b(t, h), b(h, g), b(g, p), b(h, y), b(h, c), b(c, w), m = !0, C || (D = [
|
|
405
|
+
F(g, "click", function() {
|
|
406
406
|
j(
|
|
407
407
|
/*onCancel*/
|
|
408
408
|
n[0]
|
|
@@ -421,34 +421,34 @@ function et(n) {
|
|
|
421
421
|
n[3]
|
|
422
422
|
) && n[3].apply(this, arguments);
|
|
423
423
|
})
|
|
424
|
-
],
|
|
424
|
+
], C = !0);
|
|
425
425
|
},
|
|
426
|
-
p(S, [
|
|
427
|
-
n = S, (!
|
|
426
|
+
p(S, [A]) {
|
|
427
|
+
n = S, (!m || A & /*title*/
|
|
428
428
|
2) && r !== (r = /*title*/
|
|
429
|
-
(n[1] || "标题") + "") && M(a, r),
|
|
429
|
+
(n[1] || "标题") + "") && M(a, r), k && k.p && (!m || A & /*$$scope*/
|
|
430
430
|
128) && Oe(
|
|
431
|
-
|
|
432
|
-
|
|
431
|
+
k,
|
|
432
|
+
E,
|
|
433
433
|
n,
|
|
434
434
|
/*$$scope*/
|
|
435
435
|
n[7],
|
|
436
|
-
|
|
437
|
-
|
|
436
|
+
m ? Ne(
|
|
437
|
+
E,
|
|
438
438
|
/*$$scope*/
|
|
439
439
|
n[7],
|
|
440
|
-
|
|
440
|
+
A,
|
|
441
441
|
null
|
|
442
442
|
) : Ze(
|
|
443
443
|
/*$$scope*/
|
|
444
444
|
n[7]
|
|
445
445
|
),
|
|
446
446
|
null
|
|
447
|
-
), (!
|
|
448
|
-
16) &&
|
|
449
|
-
(n[4] || "取消") + "") && M(
|
|
450
|
-
32) &&
|
|
451
|
-
(n[5] || "确认") + "") && M(
|
|
447
|
+
), (!m || A & /*cancelText*/
|
|
448
|
+
16) && v !== (v = /*cancelText*/
|
|
449
|
+
(n[4] || "取消") + "") && M(p, v), (!m || A & /*okText*/
|
|
450
|
+
32) && f !== (f = /*okText*/
|
|
451
|
+
(n[5] || "确认") + "") && M(w, f), (!m || A & /*theme*/
|
|
452
452
|
64) && oe(
|
|
453
453
|
c,
|
|
454
454
|
"background-color",
|
|
@@ -457,22 +457,22 @@ function et(n) {
|
|
|
457
457
|
);
|
|
458
458
|
},
|
|
459
459
|
i(S) {
|
|
460
|
-
|
|
460
|
+
m || (Y(k, S), m = !0);
|
|
461
461
|
},
|
|
462
462
|
o(S) {
|
|
463
|
-
me(
|
|
463
|
+
me(k, S), m = !1;
|
|
464
464
|
},
|
|
465
465
|
d(S) {
|
|
466
|
-
S && U(e),
|
|
466
|
+
S && U(e), k && k.d(S), C = !1, V(D);
|
|
467
467
|
}
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
470
|
const tt = (n) => n.stopPropagation();
|
|
471
471
|
function nt(n, e, t) {
|
|
472
|
-
let { $$slots: s = {}, $$scope: r } = e, { onCancel: a } = e, { title: o } = e, { onOk: l } = e, { onClose: d } = e, { cancelText: h } = e, { okText:
|
|
473
|
-
return n.$$set = (
|
|
474
|
-
"onCancel" in
|
|
475
|
-
}, [a, o, l, d, h,
|
|
472
|
+
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: v } = e;
|
|
473
|
+
return n.$$set = (p) => {
|
|
474
|
+
"onCancel" in p && t(0, a = p.onCancel), "title" in p && t(1, o = p.title), "onOk" in p && t(2, l = p.onOk), "onClose" in p && t(3, d = p.onClose), "cancelText" in p && t(4, h = p.cancelText), "okText" in p && t(5, g = p.okText), "theme" in p && t(6, v = p.theme), "$$scope" in p && t(7, r = p.$$scope);
|
|
475
|
+
}, [a, o, l, d, h, g, v, r, s];
|
|
476
476
|
}
|
|
477
477
|
class st extends ke {
|
|
478
478
|
constructor(e) {
|
|
@@ -498,11 +498,11 @@ function de(n) {
|
|
|
498
498
|
), r, a, o, l = (
|
|
499
499
|
/*item*/
|
|
500
500
|
n[11].DevClass + ""
|
|
501
|
-
), d, h,
|
|
501
|
+
), d, h, g = (
|
|
502
502
|
/*item*/
|
|
503
503
|
n[11].sn + ""
|
|
504
|
-
),
|
|
505
|
-
function
|
|
504
|
+
), v, p, y, c, f, w;
|
|
505
|
+
function m() {
|
|
506
506
|
return (
|
|
507
507
|
/*click_handler*/
|
|
508
508
|
n[10](
|
|
@@ -513,29 +513,29 @@ function de(n) {
|
|
|
513
513
|
}
|
|
514
514
|
return {
|
|
515
515
|
c() {
|
|
516
|
-
e = $("div"), t = $("span"), r = I(s), a = N(), o = $("span"), d = I(l), h = I("("),
|
|
516
|
+
e = $("div"), t = $("span"), r = I(s), a = N(), o = $("span"), d = I(l), h = I("("), v = I(g), p = I(")"), y = N(), x(t, "class", "svelte-jtc2v4"), x(o, "class", "svelte-jtc2v4"), x(e, "class", c = ae(`cert-item ${/*index*/
|
|
517
517
|
n[13] === 0 ? "cert-item-first" : ""} ${/*index*/
|
|
518
518
|
n[13] === /*selectedIndex*/
|
|
519
519
|
n[5] ? "cert-item-selected" : ""}`) + " svelte-jtc2v4");
|
|
520
520
|
},
|
|
521
|
-
m(
|
|
522
|
-
Q(
|
|
521
|
+
m(C, D) {
|
|
522
|
+
Q(C, e, D), b(e, t), b(t, r), b(e, a), b(e, o), b(o, d), b(o, h), b(o, v), b(o, p), b(e, y), f || (w = F(e, "click", m), f = !0);
|
|
523
523
|
},
|
|
524
|
-
p(
|
|
525
|
-
n =
|
|
524
|
+
p(C, D) {
|
|
525
|
+
n = C, D & /*certList*/
|
|
526
526
|
1 && s !== (s = /*item*/
|
|
527
527
|
n[11].CN + "") && M(r, s), D & /*certList*/
|
|
528
528
|
1 && l !== (l = /*item*/
|
|
529
529
|
n[11].DevClass + "") && M(d, l), D & /*certList*/
|
|
530
|
-
1 &&
|
|
531
|
-
n[11].sn + "") && M(
|
|
530
|
+
1 && g !== (g = /*item*/
|
|
531
|
+
n[11].sn + "") && M(v, g), D & /*selectedIndex*/
|
|
532
532
|
32 && c !== (c = ae(`cert-item ${/*index*/
|
|
533
533
|
n[13] === 0 ? "cert-item-first" : ""} ${/*index*/
|
|
534
534
|
n[13] === /*selectedIndex*/
|
|
535
535
|
n[5] ? "cert-item-selected" : ""}`) + " svelte-jtc2v4") && x(e, "class", c);
|
|
536
536
|
},
|
|
537
|
-
d(
|
|
538
|
-
|
|
537
|
+
d(C) {
|
|
538
|
+
C && U(e), f = !1, w();
|
|
539
539
|
}
|
|
540
540
|
};
|
|
541
541
|
}
|
|
@@ -643,12 +643,12 @@ function at(n) {
|
|
|
643
643
|
};
|
|
644
644
|
}
|
|
645
645
|
function ot(n, e, t) {
|
|
646
|
-
let { certList: s = [] } = e, { onCancel: r } = e, { onOk: a } = e, { onClose: o } = e, { cancelText: l = "" } = e, { okText: d = "" } = e, { theme: h = "#409eff" } = e,
|
|
647
|
-
const
|
|
646
|
+
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;
|
|
647
|
+
const v = () => {
|
|
648
648
|
r("未选择证书"), o == null || o();
|
|
649
|
-
},
|
|
650
|
-
a == null || a(s[
|
|
651
|
-
}, y = (c) => t(5,
|
|
649
|
+
}, p = () => {
|
|
650
|
+
a == null || a(s[g]), o == null || o();
|
|
651
|
+
}, y = (c) => t(5, g = c);
|
|
652
652
|
return n.$$set = (c) => {
|
|
653
653
|
"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);
|
|
654
654
|
}, [
|
|
@@ -657,9 +657,9 @@ function ot(n, e, t) {
|
|
|
657
657
|
l,
|
|
658
658
|
d,
|
|
659
659
|
h,
|
|
660
|
-
f,
|
|
661
|
-
p,
|
|
662
660
|
g,
|
|
661
|
+
v,
|
|
662
|
+
p,
|
|
663
663
|
r,
|
|
664
664
|
a,
|
|
665
665
|
y
|
|
@@ -743,15 +743,18 @@ class ut {
|
|
|
743
743
|
});
|
|
744
744
|
}));
|
|
745
745
|
i(this, "handleEventData", (e) => u(this, null, function* () {
|
|
746
|
-
var t, s, r, a, o, l;
|
|
746
|
+
var t, s, r, a, o, l, d, h, g, v;
|
|
747
747
|
if (e.data instanceof Blob) {
|
|
748
|
-
const
|
|
749
|
-
data:
|
|
750
|
-
success: (t =
|
|
751
|
-
msg: (s =
|
|
752
|
-
errCode: (r =
|
|
753
|
-
};
|
|
754
|
-
|
|
748
|
+
const p = yield e.data.arrayBuffer(), c = new TextDecoder("gbk").decode(p), f = JSON.parse(c), w = {
|
|
749
|
+
data: f.data,
|
|
750
|
+
success: (t = f.result) == null ? void 0 : t.success,
|
|
751
|
+
msg: (s = f.result) == null ? void 0 : s.msg,
|
|
752
|
+
errCode: (r = f.result) == null ? void 0 : r.errCode
|
|
753
|
+
}, m = (a = f.result) == null ? void 0 : a.function;
|
|
754
|
+
m === "GZCA_OnDeviceChange" ? (h = (o = this.socketConfig) == null ? void 0 : o.onUkeyEvent) == null || h.call(o, {
|
|
755
|
+
type: (l = f.result) == null ? void 0 : l.event,
|
|
756
|
+
data: (d = f.data) == null ? void 0 : d[0]
|
|
757
|
+
}) : this.eventBus.emit(m, w), (v = (g = this.socketConfig) == null ? void 0 : g.onMessage) == null || v.call(g, w);
|
|
755
758
|
}
|
|
756
759
|
}));
|
|
757
760
|
i(this, "base64Encode", (e) => {
|
|
@@ -772,11 +775,8 @@ class ut {
|
|
|
772
775
|
return yield this.sendMessage("GZCA_IsLogin", e);
|
|
773
776
|
}));
|
|
774
777
|
i(this, "addUkeyEvents", () => u(this, null, function* () {
|
|
775
|
-
this.sendMessage("
|
|
776
|
-
Type:
|
|
777
|
-
}).then((e) => {
|
|
778
|
-
var t, s;
|
|
779
|
-
(s = (t = this.socketConfig) == null ? void 0 : t.onUkeyEvent) == null || s.call(t, e);
|
|
778
|
+
this.sendMessage("GZCA_WaitForDevEvent", {
|
|
779
|
+
Type: Ae
|
|
780
780
|
});
|
|
781
781
|
}));
|
|
782
782
|
i(this, "certLogin", (e) => u(this, null, function* () {
|
|
@@ -906,7 +906,7 @@ class ut {
|
|
|
906
906
|
(r = e.onError) == null || r.call(e, s);
|
|
907
907
|
}, t.onopen = (s) => {
|
|
908
908
|
var r;
|
|
909
|
-
(r = e.onOpen) == null || r.call(e, s), this.addUkeyEvents();
|
|
909
|
+
(r = e.onOpen) == null || r.call(e, s), e.onUkeyEvent && this.addUkeyEvents();
|
|
910
910
|
}, t.onmessage = (s) => {
|
|
911
911
|
this.handleEventData(s);
|
|
912
912
|
}, t.onclose = (s) => {
|
|
@@ -953,7 +953,7 @@ const H = class H {
|
|
|
953
953
|
i(this, "getEncryptionCert", (e) => u(this, null, function* () {
|
|
954
954
|
var s;
|
|
955
955
|
return yield (s = this.coreInstance) == null ? void 0 : s.getCert(
|
|
956
|
-
{ CertType:
|
|
956
|
+
{ CertType: Ee },
|
|
957
957
|
e
|
|
958
958
|
);
|
|
959
959
|
}));
|
|
@@ -986,12 +986,12 @@ const H = class H {
|
|
|
986
986
|
return Array.isArray(s);
|
|
987
987
|
}));
|
|
988
988
|
i(this, "pkcs1Base64Sign", (e, t) => u(this, null, function* () {
|
|
989
|
-
var o, l, d, h,
|
|
989
|
+
var o, l, d, h, g;
|
|
990
990
|
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({
|
|
991
991
|
ContainerName: (d = s == null ? void 0 : s.ContainerName) != null ? d : "",
|
|
992
992
|
DataB64: r
|
|
993
993
|
});
|
|
994
|
-
return (
|
|
994
|
+
return (g = a == null ? void 0 : a[0]) == null ? void 0 : g.SignData;
|
|
995
995
|
}));
|
|
996
996
|
i(this, "pkcs1Base64VerifySignature", (e) => u(this, null, function* () {
|
|
997
997
|
var a, o, l;
|
|
@@ -1042,13 +1042,13 @@ const H = class H {
|
|
|
1042
1042
|
})));
|
|
1043
1043
|
}));
|
|
1044
1044
|
i(this, "pkcs7Sign", (e, t) => u(this, null, function* () {
|
|
1045
|
-
var o, l, d, h,
|
|
1045
|
+
var o, l, d, h, g;
|
|
1046
1046
|
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({
|
|
1047
1047
|
IsDetached: e.IsDetached,
|
|
1048
1048
|
ContainerName: (d = r == null ? void 0 : r.ContainerName) != null ? d : "",
|
|
1049
1049
|
DataB64: s
|
|
1050
1050
|
});
|
|
1051
|
-
return (
|
|
1051
|
+
return (g = a == null ? void 0 : a[0]) == null ? void 0 : g.SignData;
|
|
1052
1052
|
}));
|
|
1053
1053
|
i(this, "pkcs7VerifySignature", (e) => u(this, null, function* () {
|
|
1054
1054
|
var r, a, o;
|
|
@@ -1074,13 +1074,13 @@ const H = class H {
|
|
|
1074
1074
|
return (r = t == null ? void 0 : t[0]) == null ? void 0 : r.HashB64;
|
|
1075
1075
|
}));
|
|
1076
1076
|
i(this, "sm3HashEncryption", (e) => u(this, null, function* () {
|
|
1077
|
-
var a, o, l, d, h,
|
|
1077
|
+
var a, o, l, d, h, g;
|
|
1078
1078
|
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({
|
|
1079
1079
|
dataB64: t,
|
|
1080
1080
|
keyB64: s,
|
|
1081
1081
|
alg: "sm3"
|
|
1082
1082
|
});
|
|
1083
|
-
return (
|
|
1083
|
+
return (g = r == null ? void 0 : r[0]) == null ? void 0 : g.DataB64;
|
|
1084
1084
|
}));
|
|
1085
1085
|
i(this, "pkcs7Encryption", (e) => u(this, null, function* () {
|
|
1086
1086
|
var r, a, o, l;
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(B,w){typeof exports=="object"&&typeof module!="undefined"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(B=typeof globalThis!="undefined"?globalThis:B||self,w(B.GWS_CLIENT={}))})(this,function(B){"use strict";var ct=Object.defineProperty,lt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Ie=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ce=(B,w,x)=>w in B?ct(B,w,{enumerable:!0,configurable:!0,writable:!0,value:x}):B[w]=x,$=(B,w)=>{for(var x in w||(w={}))dt.call(w,x)&&ce(B,x,w[x]);if(Ie)for(var x of Ie(w))ht.call(w,x)&&ce(B,x,w[x]);return B},H=(B,w)=>lt(B,ut(w));var i=(B,w,x)=>ce(B,typeof w!="symbol"?w+"":w,x);var l=(B,w,x)=>new Promise((X,V)=>{var Y=E=>{try{P(x.next(E))}catch(R){V(R)}},ee=E=>{try{P(x.throw(E))}catch(R){V(R)}},P=E=>E.done?X(E.value):Promise.resolve(E.value).then(Y,ee);P((x=x.apply(B,w)).next())});const w=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",x="1",X="2";var V=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(V||{});const Y="00000001";function ee(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var P={},E;function R(){if(E)return P;E=1,P.byteLength=u,P.toByteArray=d,P.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(h){var c=h.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=h.indexOf("=");m===-1&&(m=c);var b=m===c?0:4-m%4;return[m,b]}function u(h){var c=o(h),m=c[0],b=c[1];return(m+b)*3/4-b}function y(h,c,m){return(c+m)*3/4-m}function d(h){var c,m=o(h),b=m[0],C=m[1],v=new t(y(h,b,C)),D=0,T=C>0?b-4:b,k;for(k=0;k<T;k+=4)c=e[h.charCodeAt(k)]<<18|e[h.charCodeAt(k+1)]<<12|e[h.charCodeAt(k+2)]<<6|e[h.charCodeAt(k+3)],v[D++]=c>>16&255,v[D++]=c>>8&255,v[D++]=c&255;return C===2&&(c=e[h.charCodeAt(k)]<<2|e[h.charCodeAt(k+1)]>>4,v[D++]=c&255),C===1&&(c=e[h.charCodeAt(k)]<<10|e[h.charCodeAt(k+1)]<<4|e[h.charCodeAt(k+2)]>>2,v[D++]=c>>8&255,v[D++]=c&255),v}function f(h){return n[h>>18&63]+n[h>>12&63]+n[h>>6&63]+n[h&63]}function p(h,c,m){for(var b,C=[],v=c;v<m;v+=3)b=(h[v]<<16&16711680)+(h[v+1]<<8&65280)+(h[v+2]&255),C.push(f(b));return C.join("")}function g(h){for(var c,m=h.length,b=m%3,C=[],v=16383,D=0,T=m-b;D<T;D+=v)C.push(p(h,D,D+v>T?T:D+v));return b===1?(c=h[m-1],C.push(n[c>>2]+n[c<<4&63]+"==")):b===2&&(c=(h[m-2]<<8)+h[m-1],C.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),C.join("")}return P}var Ee=R();const le=ee(Ee);class Ae{constructor(){i(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const s=this.deps.get(e);s&&s(t)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-oivou{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-oivou{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-oivou{background-color:#fff;padding:1.42857rem;border-radius:.35714rem;width:40%}.model-title.svelte-oivou{color:#303133;font-size:1.28571rem;margin-bottom:1.14286rem}.modal-visible.svelte-oivou{display:flex}.modal-footer.svelte-oivou{display:flex;align-items:center;justify-content:flex-end;margin-top:1.14286rem}.modal-btn.svelte-oivou{padding:.57143rem 1.07143rem;border-radius:.28571rem;font-size:1rem;border:.07143rem solid #dcdfe6}.success.svelte-oivou{margin-left:.85714rem;color:#fff}.slot.svelte-oivou{max-height:14.28571rem;overflow-y:scroll}.slot.svelte-oivou::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:1.14286rem;display:flex;align-items:center;cursor:pointer;border-bottom:.07143rem solid #ebeef5;font-size:1rem}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:.07143rem solid #ebeef5}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4{display:inline-block;color:#606266}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4:first-child{width:30%}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:12.85714rem;height:12.85714rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.07143rem solid #ccc;margin-top:.71429rem;margin-right:.71429rem;border-radius:.28571rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:7.14286rem;height:7.14286rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.71429rem;color:#333}")),document.head.appendChild(n)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var _e=Object.defineProperty,Le=(n,e,t)=>e in n?_e(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ue=(n,e,t)=>Le(n,typeof e!="symbol"?e+"":e,t);function te(){}function Pe(n,e){for(const t in e)n[t]=e[t];return n}function de(n){return n()}function he(){return Object.create(null)}function U(n){n.forEach(de)}function J(n){return typeof n=="function"}function ye(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Te(n){return Object.keys(n).length===0}function Me(n,e,t,s){if(n){const r=fe(n,e,t,s);return n[0](r)}}function fe(n,e,t,s){return n[1]&&s?Pe(t.ctx.slice(),n[1](s(e))):t.ctx}function He(n,e,t,s){if(n[2]&&s){const r=n[2](s(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const a=[],o=Math.max(e.dirty.length,r.length);for(let u=0;u<o;u+=1)a[u]=e.dirty[u]|r[u];return a}return e.dirty|r}return e.dirty}function Ge(n,e,t,s,r,a){if(r){const o=fe(e,t,s,a);n.p(o,r)}}function je(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let s=0;s<t;s++)e[s]=-1;return e}return-1}function ge(n){return n!=null?n:""}function S(n,e){n.appendChild(e)}function ne(n,e,t){n.insertBefore(e,t||null)}function K(n){n.parentNode&&n.parentNode.removeChild(n)}function Fe(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function A(n){return document.createElement(n)}function _(n){return document.createTextNode(n)}function z(){return _(" ")}function Ne(){return _("")}function W(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function I(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Oe(n){return Array.from(n.childNodes)}function G(n,e){e=""+e,n.data!==e&&(n.data=e)}function pe(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let se;function q(n){se=n}const j=[],me=[];let F=[];const ve=[],Ze=Promise.resolve();let re=!1;function Ve(){re||(re=!0,Ze.then(Ce))}function ae(n){F.push(n)}const oe=new Set;let N=0;function Ce(){if(N!==0)return;const n=se;do{try{for(;N<j.length;){const e=j[N];N++,q(e),Re(e.$$)}}catch(e){throw j.length=0,N=0,e}for(q(null),j.length=0,N=0;me.length;)me.pop()();for(let e=0;e<F.length;e+=1){const t=F[e];oe.has(t)||(oe.add(t),t())}F.length=0}while(j.length);for(;ve.length;)ve.pop()();re=!1,oe.clear(),q(n)}function Re(n){if(n.fragment!==null){n.update(),U(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(ae)}}function Ue(n){const e=[],t=[];F.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),F=e}const Q=new Set;let Je;function ie(n,e){n&&n.i&&(Q.delete(n),n.i(e))}function we(n,e,t,s){if(n&&n.o){if(Q.has(n))return;Q.add(n),Je.c.push(()=>{Q.delete(n)}),n.o(e)}}function ke(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function ze(n){n&&n.c()}function be(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),ae(()=>{const a=n.$$.on_mount.map(de).filter(J);n.$$.on_destroy?n.$$.on_destroy.push(...a):U(a),n.$$.on_mount=[]}),r.forEach(ae)}function De(n,e){const t=n.$$;t.fragment!==null&&(Ue(t.after_update),U(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function We(n,e){n.$$.dirty[0]===-1&&(j.push(n),Ve(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Be(n,e,t,s,r,a,o=null,u=[-1]){const y=se;q(n);const d=n.$$={fragment:null,ctx:[],props:a,update:te,not_equal:r,bound:he(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(y?y.$$.context:[])),callbacks:he(),dirty:u,skip_bound:!1,root:e.target||y.$$.root};o&&o(d.root);let f=!1;if(d.ctx=t?t(n,e.props||{},(p,g,...h)=>{const c=h.length?h[0]:g;return d.ctx&&r(d.ctx[p],d.ctx[p]=c)&&(!d.skip_bound&&d.bound[p]&&d.bound[p](c),f&&We(n,p)),g}):[],d.update(),f=!0,U(d.before_update),d.fragment=s?s(d.ctx):!1,e.target){if(e.hydrate){const p=Oe(e.target);d.fragment&&d.fragment.l(p),p.forEach(K)}else d.fragment&&d.fragment.c();e.intro&&ie(n.$$.fragment),be(n,e.target,e.anchor),Ce()}q(y)}class Se{constructor(){ue(this,"$$"),ue(this,"$$set")}$destroy(){De(this,1),this.$destroy=te}$on(e,t){if(!J(t))return te;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Te(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const qe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(qe);function Ke(n){let e,t,s,r=(n[1]||"标题")+"",a,o,u,y,d,f,p=(n[4]||"取消")+"",g,h,c,m=(n[5]||"确认")+"",b,C,v,D;const T=n[8].default,k=Me(T,n,n[7],null);return{c(){e=A("div"),t=A("div"),s=A("div"),a=_(r),o=z(),u=A("div"),k&&k.c(),y=z(),d=A("div"),f=A("button"),g=_(p),h=z(),c=A("button"),b=_(m),I(s,"class","model-title svelte-oivou"),I(u,"class","slot svelte-oivou"),I(f,"class","modal-btn svelte-oivou"),I(c,"class","modal-btn success svelte-oivou"),pe(c,"background-color",n[6]),I(d,"class","modal-footer svelte-oivou"),I(t,"class","modal-content svelte-oivou"),I(e,"class","modal-background modal-visible svelte-oivou")},m(L,M){ne(L,e,M),S(e,t),S(t,s),S(s,a),S(t,o),S(t,u),k&&k.m(u,null),S(t,y),S(t,d),S(d,f),S(f,g),S(d,h),S(d,c),S(c,b),C=!0,v||(D=[W(f,"click",function(){J(n[0])&&n[0].apply(this,arguments)}),W(c,"click",function(){J(n[2])&&n[2].apply(this,arguments)}),W(t,"click",Qe),W(e,"click",function(){J(n[3])&&n[3].apply(this,arguments)})],v=!0)},p(L,[M]){n=L,(!C||M&2)&&r!==(r=(n[1]||"标题")+"")&&G(a,r),k&&k.p&&(!C||M&128)&&Ge(k,T,n,n[7],C?He(T,n[7],M,null):je(n[7]),null),(!C||M&16)&&p!==(p=(n[4]||"取消")+"")&&G(g,p),(!C||M&32)&&m!==(m=(n[5]||"确认")+"")&&G(b,m),(!C||M&64)&&pe(c,"background-color",n[6])},i(L){C||(ie(k,L),C=!0)},o(L){we(k,L),C=!1},d(L){L&&K(e),k&&k.d(L),v=!1,U(D)}}}const Qe=n=>n.stopPropagation();function Xe(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:a}=e,{title:o}=e,{onOk:u}=e,{onClose:y}=e,{cancelText:d}=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,u=g.onOk),"onClose"in g&&t(3,y=g.onClose),"cancelText"in g&&t(4,d=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,u,y,d,f,p,r,s]}class Ye extends Se{constructor(e){super(),Be(this,e,Xe,Ke,ye,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function xe(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function $e(n){let e,t,s=n[11].CN+"",r,a,o,u=n[11].DevClass+"",y,d,f=n[11].sn+"",p,g,h,c,m,b;function C(){return n[10](n[13])}return{c(){e=A("div"),t=A("span"),r=_(s),a=z(),o=A("span"),y=_(u),d=_("("),p=_(f),g=_(")"),h=z(),I(t,"class","svelte-jtc2v4"),I(o,"class","svelte-jtc2v4"),I(e,"class",c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(v,D){ne(v,e,D),S(e,t),S(t,r),S(e,a),S(e,o),S(o,y),S(o,d),S(o,p),S(o,g),S(e,h),m||(b=W(e,"click",C),m=!0)},p(v,D){n=v,D&1&&s!==(s=n[11].CN+"")&&G(r,s),D&1&&u!==(u=n[11].DevClass+"")&&G(y,u),D&1&&f!==(f=n[11].sn+"")&&G(p,f),D&32&&c!==(c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&I(e,"class",c)},d(v){v&&K(e),m=!1,b()}}}function et(n){let e,t=ke(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=$e(xe(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Ne()},m(r,a){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(r,a);ne(r,e,a)},p(r,a){if(a&33){t=ke(r[0]);let o;for(o=0;o<t.length;o+=1){const u=xe(r,t,o);s[o]?s[o].p(u,a):(s[o]=$e(u),s[o].c(),s[o].m(e.parentNode,e))}for(;o<s.length;o+=1)s[o].d(1);s.length=t.length}},d(r){r&&K(e),Fe(s,r)}}}function tt(n){let e,t;return e=new Ye({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[et]},$$scope:{ctx:n}}}),{c(){ze(e.$$.fragment)},m(s,r){be(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||(ie(e.$$.fragment,s),t=!0)},o(s){we(e.$$.fragment,s),t=!1},d(s){De(e,s)}}}function nt(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:o}=e,{cancelText:u=""}=e,{okText:y=""}=e,{theme:d="#409eff"}=e,f=0;const p=()=>{r("未选择证书"),o==null||o()},g=()=>{a==null||a(s[f]),o==null||o()},h=c=>t(5,f=c);return n.$$set=c=>{"certList"in c&&t(0,s=c.certList),"onCancel"in c&&t(8,r=c.onCancel),"onOk"in c&&t(9,a=c.onOk),"onClose"in c&&t(1,o=c.onClose),"cancelText"in c&&t(2,u=c.cancelText),"okText"in c&&t(3,y=c.okText),"theme"in c&&t(4,d=c.theme)},[s,o,u,y,d,f,p,g,r,a,h]}class st extends Se{constructor(e){super(),Be(this,e,nt,tt,ye,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class rt{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new st({target:document.body,props:H($({},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 at=new rt;class ot{constructor(e){i(this,"socketInstance",null);i(this,"eventBus",new Ae);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,u;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:{}]};(u=this.socketInstance)==null||u.send(JSON.stringify(a)),this.eventBus.on(e,y=>{y.success?s(y.data):r(y)})}));i(this,"handleEventData",e=>l(this,null,function*(){var t,s,r,a,o,u;if(e.data instanceof Blob){const y=yield e.data.arrayBuffer(),f=new TextDecoder("gbk").decode(y),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),(u=(o=this.socketConfig)==null?void 0:o.onMessage)==null||u.call(o,g)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return le.fromByteArray(t)});i(this,"base64Decode",e=>{const t=le.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>l(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>l(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_StartListen",{Type:Y}).then(e=>{var t,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyEvent)==null||s.call(t,e)})}));i(this,"certLogin",e=>l(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));i(this,"getCert",(e,t)=>l(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&(yield this.certLogin(s.ContainerName)),s}));i(this,"chooseCert",e=>l(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield at.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"getCertList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"pkcs1Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",$({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",$({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",$({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",$({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",$({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",$({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",$({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));var t,s;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(s=e.pinPolicy)!=null?s:V.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=s=>{var r;(r=e.onError)==null||r.call(e,s)},t.onopen=s=>{var r;(r=e.onOpen)==null||r.call(e,s),this.addUkeyEvents()},t.onmessage=s=>{this.handleEventData(s)},t.onclose=s=>{var r;(r=e.onClose)==null||r.call(e,s)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const Z=class Z{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ot(H($({},e!=null?e:{}),{url:w}))});i(this,"appendCertBase64",(e,t=!0)=>l(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return H($({},e!=null?e:{}),{CertB64:s==null?void 0:s.CertB64})}));i(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});i(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});i(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});i(this,"getSignatureCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:x},e)}));i(this,"getEncryptionCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:X},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)=>l(this,null,function*(){var a,o,u;const s=yield this.getSignatureCert(t),r=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(H($({},e!=null?e:{}),{ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:""}));return(u=r==null?void 0:r[0])==null?void 0:u.SignData}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){var r;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(s)}));i(this,"pkcs1Base64Sign",(e,t)=>l(this,null,function*(){var o,u,y,d,f;const s=yield this.getSignatureCert(t),r=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),a=yield(d=this.coreInstance)==null?void 0:d.pkcs1Base64Sign({ContainerName:(y=s==null?void 0:s.ContainerName)!=null?y:"",DataB64:r});return(f=a==null?void 0:a[0])==null?void 0:f.SignData}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){var a,o,u;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e);return!!(yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",e=>l(this,null,function*(){var r,a;const t=yield this.getSignatureCert(e),s=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:""});return{cert:t,sealList:s}}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(a=s==null?void 0:s[0])==null?void 0:a.Z}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){var a,o;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e),r=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:t});return r==null?void 0:r[0].H}));i(this,"pkcs1HashSign",(e,t)=>l(this,null,function*(){var a,o,u,y;const s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1HashSign({ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(y=r==null?void 0:r[0])==null?void 0:y.SignData}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(H($({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var o,u,y,d,f;const s=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield this.getSignatureCert(t),a=yield(d=this.coreInstance)==null?void 0:d.pkcs7Sign({IsDetached:e.IsDetached,ContainerName:(y=r==null?void 0:r.ContainerName)!=null?y:"",DataB64:s});return(f=a==null?void 0:a[0])==null?void 0:f.SignData}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){var r,a,o;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));i(this,"sm3Hash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HexHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3FileHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){var a,o,u,y,d,f;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=(y=e.KeyB64)!=null?y:this.base64Encode({Data:(u=e.Key)!=null?u:""}),r=yield(d=this.coreInstance)==null?void 0:d.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(f=r==null?void 0:r[0])==null?void 0:f.DataB64}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){var r,a,o,u;if(!e.CertB64List){const y=yield this.getEncryptionCert();e.CertB64List=y==null?void 0:y.CertB64}const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(u=s==null?void 0:s[0])==null?void 0:u.DataB64}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){var a,o;const t=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption({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=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(a=s==null?void 0:s[0])==null?void 0:a.Data}));i(this,"asymmetricDecryption",(e,t)=>l(this,null,function*(){var a,o;const s=yield this.getEncryptionCert(t),r=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption({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=>l(this,null,function*(){var s;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(e);return t==null?void 0:t[0]}));i(this,"sm4Decryption",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(e);return(r=t==null?void 0:t[0])==null?void 0:r.Data}));i(this,"getCertInfo",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e);return $({},(r=t==null?void 0:t[0])!=null?r:{})}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid($({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return Z.instance&&!(e!=null&&e.isCreateNew)?Z.instance:(this.createGwsCore(e),Z.instance=this,this)}};i(Z,"instance",null);let O=Z;function it(n){return new Promise((e,t)=>{if(O.instance&&!(n!=null&&n.isCreateNew))e(O.instance);else{const s=new O(H($({},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)}}))}})}B.GwsService=O,B.createService=it,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(B,k){typeof exports=="object"&&typeof module!="undefined"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(B=typeof globalThis!="undefined"?globalThis:B||self,k(B.GWS_CLIENT={}))})(this,function(B){"use strict";var ct=Object.defineProperty,lt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Ie=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ce=(B,k,S)=>k in B?ct(B,k,{enumerable:!0,configurable:!0,writable:!0,value:S}):B[k]=S,$=(B,k)=>{for(var S in k||(k={}))dt.call(k,S)&&ce(B,S,k[S]);if(Ie)for(var S of Ie(k))ht.call(k,S)&&ce(B,S,k[S]);return B},H=(B,k)=>lt(B,ut(k));var i=(B,k,S)=>ce(B,typeof k!="symbol"?k+"":k,S);var l=(B,k,S)=>new Promise((X,V)=>{var Y=E=>{try{L(S.next(E))}catch(R){V(R)}},ee=E=>{try{L(S.throw(E))}catch(R){V(R)}},L=E=>E.done?X(E.value):Promise.resolve(E.value).then(Y,ee);L((S=S.apply(B,k)).next())});const k=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",S="1",X="2";var V=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(V||{});const Y="00000001";function ee(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var L={},E;function R(){if(E)return L;E=1,L.byteLength=u,L.toByteArray=d,L.fromByteArray=p;for(var n=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,a=s.length;r<a;++r)n[r]=s[r],e[s.charCodeAt(r)]=r;e[45]=62,e[95]=63;function o(h){var c=h.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=h.indexOf("=");f===-1&&(f=c);var w=f===c?0:4-f%4;return[f,w]}function u(h){var c=o(h),f=c[0],w=c[1];return(f+w)*3/4-w}function y(h,c,f){return(c+f)*3/4-f}function d(h){var c,f=o(h),w=f[0],m=f[1],C=new t(y(h,w,m)),b=0,T=m>0?w-4:w,D;for(D=0;D<T;D+=4)c=e[h.charCodeAt(D)]<<18|e[h.charCodeAt(D+1)]<<12|e[h.charCodeAt(D+2)]<<6|e[h.charCodeAt(D+3)],C[b++]=c>>16&255,C[b++]=c>>8&255,C[b++]=c&255;return m===2&&(c=e[h.charCodeAt(D)]<<2|e[h.charCodeAt(D+1)]>>4,C[b++]=c&255),m===1&&(c=e[h.charCodeAt(D)]<<10|e[h.charCodeAt(D+1)]<<4|e[h.charCodeAt(D+2)]>>2,C[b++]=c>>8&255,C[b++]=c&255),C}function g(h){return n[h>>18&63]+n[h>>12&63]+n[h>>6&63]+n[h&63]}function v(h,c,f){for(var w,m=[],C=c;C<f;C+=3)w=(h[C]<<16&16711680)+(h[C+1]<<8&65280)+(h[C+2]&255),m.push(g(w));return m.join("")}function p(h){for(var c,f=h.length,w=f%3,m=[],C=16383,b=0,T=f-w;b<T;b+=C)m.push(v(h,b,b+C>T?T:b+C));return w===1?(c=h[f-1],m.push(n[c>>2]+n[c<<4&63]+"==")):w===2&&(c=(h[f-2]<<8)+h[f-1],m.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),m.join("")}return L}var Ee=R();const le=ee(Ee);class Ae{constructor(){i(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const s=this.deps.get(e);s&&s(t)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-oivou{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-oivou{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-oivou{background-color:#fff;padding:1.42857rem;border-radius:.35714rem;width:40%}.model-title.svelte-oivou{color:#303133;font-size:1.28571rem;margin-bottom:1.14286rem}.modal-visible.svelte-oivou{display:flex}.modal-footer.svelte-oivou{display:flex;align-items:center;justify-content:flex-end;margin-top:1.14286rem}.modal-btn.svelte-oivou{padding:.57143rem 1.07143rem;border-radius:.28571rem;font-size:1rem;border:.07143rem solid #dcdfe6}.success.svelte-oivou{margin-left:.85714rem;color:#fff}.slot.svelte-oivou{max-height:14.28571rem;overflow-y:scroll}.slot.svelte-oivou::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:1.14286rem;display:flex;align-items:center;cursor:pointer;border-bottom:.07143rem solid #ebeef5;font-size:1rem}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:.07143rem solid #ebeef5}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4{display:inline-block;color:#606266}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4:first-child{width:30%}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:12.85714rem;height:12.85714rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.07143rem solid #ccc;margin-top:.71429rem;margin-right:.71429rem;border-radius:.28571rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:7.14286rem;height:7.14286rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.71429rem;color:#333}")),document.head.appendChild(n)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var _e=Object.defineProperty,Pe=(n,e,t)=>e in n?_e(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ue=(n,e,t)=>Pe(n,typeof e!="symbol"?e+"":e,t);function te(){}function Le(n,e){for(const t in e)n[t]=e[t];return n}function de(n){return n()}function he(){return Object.create(null)}function U(n){n.forEach(de)}function J(n){return typeof n=="function"}function ye(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Te(n){return Object.keys(n).length===0}function Me(n,e,t,s){if(n){const r=fe(n,e,t,s);return n[0](r)}}function fe(n,e,t,s){return n[1]&&s?Le(t.ctx.slice(),n[1](s(e))):t.ctx}function He(n,e,t,s){if(n[2]&&s){const r=n[2](s(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const a=[],o=Math.max(e.dirty.length,r.length);for(let u=0;u<o;u+=1)a[u]=e.dirty[u]|r[u];return a}return e.dirty|r}return e.dirty}function Ge(n,e,t,s,r,a){if(r){const o=fe(e,t,s,a);n.p(o,r)}}function Fe(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let s=0;s<t;s++)e[s]=-1;return e}return-1}function ge(n){return n!=null?n:""}function x(n,e){n.appendChild(e)}function ne(n,e,t){n.insertBefore(e,t||null)}function K(n){n.parentNode&&n.parentNode.removeChild(n)}function je(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function A(n){return document.createElement(n)}function _(n){return document.createTextNode(n)}function W(){return _(" ")}function Ne(){return _("")}function z(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function I(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Oe(n){return Array.from(n.childNodes)}function G(n,e){e=""+e,n.data!==e&&(n.data=e)}function pe(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let se;function q(n){se=n}const F=[],me=[];let j=[];const ve=[],Ze=Promise.resolve();let re=!1;function Ve(){re||(re=!0,Ze.then(Ce))}function ae(n){j.push(n)}const oe=new Set;let N=0;function Ce(){if(N!==0)return;const n=se;do{try{for(;N<F.length;){const e=F[N];N++,q(e),Re(e.$$)}}catch(e){throw F.length=0,N=0,e}for(q(null),F.length=0,N=0;me.length;)me.pop()();for(let e=0;e<j.length;e+=1){const t=j[e];oe.has(t)||(oe.add(t),t())}j.length=0}while(F.length);for(;ve.length;)ve.pop()();re=!1,oe.clear(),q(n)}function Re(n){if(n.fragment!==null){n.update(),U(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(ae)}}function Ue(n){const e=[],t=[];j.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),j=e}const Q=new Set;let Je;function ie(n,e){n&&n.i&&(Q.delete(n),n.i(e))}function we(n,e,t,s){if(n&&n.o){if(Q.has(n))return;Q.add(n),Je.c.push(()=>{Q.delete(n)}),n.o(e)}}function ke(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function We(n){n&&n.c()}function De(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),ae(()=>{const a=n.$$.on_mount.map(de).filter(J);n.$$.on_destroy?n.$$.on_destroy.push(...a):U(a),n.$$.on_mount=[]}),r.forEach(ae)}function be(n,e){const t=n.$$;t.fragment!==null&&(Ue(t.after_update),U(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ze(n,e){n.$$.dirty[0]===-1&&(F.push(n),Ve(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Be(n,e,t,s,r,a,o=null,u=[-1]){const y=se;q(n);const d=n.$$={fragment:null,ctx:[],props:a,update:te,not_equal:r,bound:he(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(y?y.$$.context:[])),callbacks:he(),dirty:u,skip_bound:!1,root:e.target||y.$$.root};o&&o(d.root);let g=!1;if(d.ctx=t?t(n,e.props||{},(v,p,...h)=>{const c=h.length?h[0]:p;return d.ctx&&r(d.ctx[v],d.ctx[v]=c)&&(!d.skip_bound&&d.bound[v]&&d.bound[v](c),g&&ze(n,v)),p}):[],d.update(),g=!0,U(d.before_update),d.fragment=s?s(d.ctx):!1,e.target){if(e.hydrate){const v=Oe(e.target);d.fragment&&d.fragment.l(v),v.forEach(K)}else d.fragment&&d.fragment.c();e.intro&&ie(n.$$.fragment),De(n,e.target,e.anchor),Ce()}q(y)}class xe{constructor(){ue(this,"$$"),ue(this,"$$set")}$destroy(){be(this,1),this.$destroy=te}$on(e,t){if(!J(t))return te;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Te(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const qe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(qe);function Ke(n){let e,t,s,r=(n[1]||"标题")+"",a,o,u,y,d,g,v=(n[4]||"取消")+"",p,h,c,f=(n[5]||"确认")+"",w,m,C,b;const T=n[8].default,D=Me(T,n,n[7],null);return{c(){e=A("div"),t=A("div"),s=A("div"),a=_(r),o=W(),u=A("div"),D&&D.c(),y=W(),d=A("div"),g=A("button"),p=_(v),h=W(),c=A("button"),w=_(f),I(s,"class","model-title svelte-oivou"),I(u,"class","slot svelte-oivou"),I(g,"class","modal-btn svelte-oivou"),I(c,"class","modal-btn success svelte-oivou"),pe(c,"background-color",n[6]),I(d,"class","modal-footer svelte-oivou"),I(t,"class","modal-content svelte-oivou"),I(e,"class","modal-background modal-visible svelte-oivou")},m(P,M){ne(P,e,M),x(e,t),x(t,s),x(s,a),x(t,o),x(t,u),D&&D.m(u,null),x(t,y),x(t,d),x(d,g),x(g,p),x(d,h),x(d,c),x(c,w),m=!0,C||(b=[z(g,"click",function(){J(n[0])&&n[0].apply(this,arguments)}),z(c,"click",function(){J(n[2])&&n[2].apply(this,arguments)}),z(t,"click",Qe),z(e,"click",function(){J(n[3])&&n[3].apply(this,arguments)})],C=!0)},p(P,[M]){n=P,(!m||M&2)&&r!==(r=(n[1]||"标题")+"")&&G(a,r),D&&D.p&&(!m||M&128)&&Ge(D,T,n,n[7],m?He(T,n[7],M,null):Fe(n[7]),null),(!m||M&16)&&v!==(v=(n[4]||"取消")+"")&&G(p,v),(!m||M&32)&&f!==(f=(n[5]||"确认")+"")&&G(w,f),(!m||M&64)&&pe(c,"background-color",n[6])},i(P){m||(ie(D,P),m=!0)},o(P){we(D,P),m=!1},d(P){P&&K(e),D&&D.d(P),C=!1,U(b)}}}const Qe=n=>n.stopPropagation();function Xe(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:a}=e,{title:o}=e,{onOk:u}=e,{onClose:y}=e,{cancelText:d}=e,{okText:g}=e,{theme:v}=e;return n.$$set=p=>{"onCancel"in p&&t(0,a=p.onCancel),"title"in p&&t(1,o=p.title),"onOk"in p&&t(2,u=p.onOk),"onClose"in p&&t(3,y=p.onClose),"cancelText"in p&&t(4,d=p.cancelText),"okText"in p&&t(5,g=p.okText),"theme"in p&&t(6,v=p.theme),"$$scope"in p&&t(7,r=p.$$scope)},[a,o,u,y,d,g,v,r,s]}class Ye extends xe{constructor(e){super(),Be(this,e,Xe,Ke,ye,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function Se(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function $e(n){let e,t,s=n[11].CN+"",r,a,o,u=n[11].DevClass+"",y,d,g=n[11].sn+"",v,p,h,c,f,w;function m(){return n[10](n[13])}return{c(){e=A("div"),t=A("span"),r=_(s),a=W(),o=A("span"),y=_(u),d=_("("),v=_(g),p=_(")"),h=W(),I(t,"class","svelte-jtc2v4"),I(o,"class","svelte-jtc2v4"),I(e,"class",c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(C,b){ne(C,e,b),x(e,t),x(t,r),x(e,a),x(e,o),x(o,y),x(o,d),x(o,v),x(o,p),x(e,h),f||(w=z(e,"click",m),f=!0)},p(C,b){n=C,b&1&&s!==(s=n[11].CN+"")&&G(r,s),b&1&&u!==(u=n[11].DevClass+"")&&G(y,u),b&1&&g!==(g=n[11].sn+"")&&G(v,g),b&32&&c!==(c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&I(e,"class",c)},d(C){C&&K(e),f=!1,w()}}}function et(n){let e,t=ke(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=$e(Se(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Ne()},m(r,a){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(r,a);ne(r,e,a)},p(r,a){if(a&33){t=ke(r[0]);let o;for(o=0;o<t.length;o+=1){const u=Se(r,t,o);s[o]?s[o].p(u,a):(s[o]=$e(u),s[o].c(),s[o].m(e.parentNode,e))}for(;o<s.length;o+=1)s[o].d(1);s.length=t.length}},d(r){r&&K(e),je(s,r)}}}function tt(n){let e,t;return e=new Ye({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[et]},$$scope:{ctx:n}}}),{c(){We(e.$$.fragment)},m(s,r){De(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||(ie(e.$$.fragment,s),t=!0)},o(s){we(e.$$.fragment,s),t=!1},d(s){be(e,s)}}}function nt(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:o}=e,{cancelText:u=""}=e,{okText:y=""}=e,{theme:d="#409eff"}=e,g=0;const v=()=>{r("未选择证书"),o==null||o()},p=()=>{a==null||a(s[g]),o==null||o()},h=c=>t(5,g=c);return n.$$set=c=>{"certList"in c&&t(0,s=c.certList),"onCancel"in c&&t(8,r=c.onCancel),"onOk"in c&&t(9,a=c.onOk),"onClose"in c&&t(1,o=c.onClose),"cancelText"in c&&t(2,u=c.cancelText),"okText"in c&&t(3,y=c.okText),"theme"in c&&t(4,d=c.theme)},[s,o,u,y,d,g,v,p,r,a,h]}class st extends xe{constructor(e){super(),Be(this,e,nt,tt,ye,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class rt{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new st({target:document.body,props:H($({},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 at=new rt;class ot{constructor(e){i(this,"socketInstance",null);i(this,"eventBus",new Ae);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,u;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:{}]};(u=this.socketInstance)==null||u.send(JSON.stringify(a)),this.eventBus.on(e,y=>{y.success?s(y.data):r(y)})}));i(this,"handleEventData",e=>l(this,null,function*(){var t,s,r,a,o,u,y,d,g,v;if(e.data instanceof Blob){const p=yield e.data.arrayBuffer(),c=new TextDecoder("gbk").decode(p),f=JSON.parse(c),w={data:f.data,success:(t=f.result)==null?void 0:t.success,msg:(s=f.result)==null?void 0:s.msg,errCode:(r=f.result)==null?void 0:r.errCode},m=(a=f.result)==null?void 0:a.function;m==="GZCA_OnDeviceChange"?(d=(o=this.socketConfig)==null?void 0:o.onUkeyEvent)==null||d.call(o,{type:(u=f.result)==null?void 0:u.event,data:(y=f.data)==null?void 0:y[0]}):this.eventBus.emit(m,w),(v=(g=this.socketConfig)==null?void 0:g.onMessage)==null||v.call(g,w)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return le.fromByteArray(t)});i(this,"base64Decode",e=>{const t=le.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>l(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>l(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:Y})}));i(this,"certLogin",e=>l(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));i(this,"getCert",(e,t)=>l(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&(yield this.certLogin(s.ContainerName)),s}));i(this,"chooseCert",e=>l(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield at.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"getCertList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"pkcs1Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",$({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",$({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",$({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",$({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",$({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",$({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",$({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));var t,s;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(s=e.pinPolicy)!=null?s:V.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=s=>{var r;(r=e.onError)==null||r.call(e,s)},t.onopen=s=>{var r;(r=e.onOpen)==null||r.call(e,s),e.onUkeyEvent&&this.addUkeyEvents()},t.onmessage=s=>{this.handleEventData(s)},t.onclose=s=>{var r;(r=e.onClose)==null||r.call(e,s)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const Z=class Z{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ot(H($({},e!=null?e:{}),{url:k}))});i(this,"appendCertBase64",(e,t=!0)=>l(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return H($({},e!=null?e:{}),{CertB64:s==null?void 0:s.CertB64})}));i(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});i(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});i(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});i(this,"getSignatureCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:S},e)}));i(this,"getEncryptionCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:X},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)=>l(this,null,function*(){var a,o,u;const s=yield this.getSignatureCert(t),r=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(H($({},e!=null?e:{}),{ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:""}));return(u=r==null?void 0:r[0])==null?void 0:u.SignData}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){var r;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(s)}));i(this,"pkcs1Base64Sign",(e,t)=>l(this,null,function*(){var o,u,y,d,g;const s=yield this.getSignatureCert(t),r=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),a=yield(d=this.coreInstance)==null?void 0:d.pkcs1Base64Sign({ContainerName:(y=s==null?void 0:s.ContainerName)!=null?y:"",DataB64:r});return(g=a==null?void 0:a[0])==null?void 0:g.SignData}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){var a,o,u;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e);return!!(yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",e=>l(this,null,function*(){var r,a;const t=yield this.getSignatureCert(e),s=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:""});return{cert:t,sealList:s}}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(a=s==null?void 0:s[0])==null?void 0:a.Z}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){var a,o;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e),r=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:t});return r==null?void 0:r[0].H}));i(this,"pkcs1HashSign",(e,t)=>l(this,null,function*(){var a,o,u,y;const s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1HashSign({ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(y=r==null?void 0:r[0])==null?void 0:y.SignData}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(H($({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var o,u,y,d,g;const s=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield this.getSignatureCert(t),a=yield(d=this.coreInstance)==null?void 0:d.pkcs7Sign({IsDetached:e.IsDetached,ContainerName:(y=r==null?void 0:r.ContainerName)!=null?y:"",DataB64:s});return(g=a==null?void 0:a[0])==null?void 0:g.SignData}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){var r,a,o;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));i(this,"sm3Hash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HexHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3FileHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){var a,o,u,y,d,g;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=(y=e.KeyB64)!=null?y:this.base64Encode({Data:(u=e.Key)!=null?u:""}),r=yield(d=this.coreInstance)==null?void 0:d.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(g=r==null?void 0:r[0])==null?void 0:g.DataB64}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){var r,a,o,u;if(!e.CertB64List){const y=yield this.getEncryptionCert();e.CertB64List=y==null?void 0:y.CertB64}const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(u=s==null?void 0:s[0])==null?void 0:u.DataB64}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){var a,o;const t=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption({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=>l(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(a=s==null?void 0:s[0])==null?void 0:a.Data}));i(this,"asymmetricDecryption",(e,t)=>l(this,null,function*(){var a,o;const s=yield this.getEncryptionCert(t),r=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption({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=>l(this,null,function*(){var s;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(e);return t==null?void 0:t[0]}));i(this,"sm4Decryption",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(e);return(r=t==null?void 0:t[0])==null?void 0:r.Data}));i(this,"getCertInfo",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e);return $({},(r=t==null?void 0:t[0])!=null?r:{})}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid($({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return Z.instance&&!(e!=null&&e.isCreateNew)?Z.instance:(this.createGwsCore(e),Z.instance=this,this)}};i(Z,"instance",null);let O=Z;function it(n){return new Promise((e,t)=>{if(O.instance&&!(n!=null&&n.isCreateNew))e(O.instance);else{const s=new O(H($({},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)}}))}})}B.GwsService=O,B.createService=it,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gws-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "dist/index.es.js",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
"signature",
|
|
12
12
|
"encryption"
|
|
13
13
|
],
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"base64-js": "^1.5.1"
|
|
16
|
-
},
|
|
17
14
|
"author": "gzca",
|
|
18
15
|
"files": [
|
|
19
16
|
"dist",
|