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