gws-client 0.6.3 → 1.0.0

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 CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  用于web前端调用GZCA数字证书客户端UKEY证书应用接口,调用前需确保已安装GZCA数字证书客户端并启动,支持TypeScript。
4
4
 
5
- ## 快速开始
5
+ ## 1 快速开始
6
6
 
7
- ### 安装
7
+ ### 1.1 安装
8
8
 
9
9
  #### 使用包管理器
10
10
 
@@ -26,7 +26,7 @@ Install with pnpm
26
26
  pnpm add gws-client
27
27
  ```
28
28
 
29
- ### 使用
29
+ ### 1.2 使用
30
30
 
31
31
  #### ES Module
32
32
 
@@ -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插入拔出时回调 | `(event: {type: 'remove' \| 'insert', data: CertType}) => void` | -- |
87
+ | onUkeyChange | 可选,Ukey插入拔出时回调 | `(event: {type: 'remove' \| 'insert', data: CertType}) => void` | -- |
88
88
  | theme | 可选,弹窗主题色 | `String` | `#409eff` |
89
89
 
90
90
  #### 示例
@@ -124,9 +124,9 @@ async function pkcs1Sign() {
124
124
  }
125
125
  ```
126
126
 
127
- ## API接口
127
+ ## 2 API接口
128
128
 
129
- ### 销毁
129
+ ### 2.1 销毁
130
130
 
131
131
  断开socket连接
132
132
 
@@ -140,7 +140,7 @@ destroy
140
140
  type Destroy = () => void;
141
141
  ```
142
142
 
143
- ### 重启
143
+ ### 2.2 重启
144
144
 
145
145
  重新连接socket,可重新传入新配置
146
146
 
@@ -154,7 +154,7 @@ restart
154
154
  type Restart = (config?: GwsServiceConfigType) => void;
155
155
  ```
156
156
 
157
- ### 获取签名证书
157
+ ### 2.3 获取签名证书
158
158
 
159
159
  获取签名证书,可获取证书CN项,证书CertB64,sn
160
160
 
@@ -168,7 +168,7 @@ getSignatureCert
168
168
  type GetSignatureCert = (cert?: CertType) => Promise<CertType>;
169
169
  ```
170
170
 
171
- ### 获取签名证书列表
171
+ ### 2.4 获取签名证书列表
172
172
 
173
173
  获取签名证书列表
174
174
 
@@ -182,7 +182,7 @@ getSignatureCertList
182
182
  type GetSignatureCertList = () => Promise<CertType[]>;
183
183
  ```
184
184
 
185
- ### 获取加密证书
185
+ ### 2.5 获取加密证书
186
186
 
187
187
  获取加密证书,可获取证书CN项,证书CertB64,sn
188
188
 
@@ -196,7 +196,7 @@ getEncryptionCert
196
196
  type GetEncryptionCert = (cert?: CertType) => Promise<CertType>;
197
197
  ```
198
198
 
199
- ### 获取加密证书列表
199
+ ### 2.6 获取加密证书列表
200
200
 
201
201
  获取加密证书列表
202
202
 
@@ -210,7 +210,7 @@ getEncryptionCertList
210
210
  type GetEncryptionCertList = () => Promise<CertType[]>;
211
211
  ```
212
212
 
213
- ### 获取证书详情
213
+ ### 2.7 获取证书详情
214
214
 
215
215
  获取证书详情,可获取证书公钥CertPublicKey,证书序列号CertSerial,证书有效期CertValidTime
216
216
 
@@ -232,7 +232,7 @@ type GetCertInfo = (params: {
232
232
  | ------- | ---------------- | -------- | ------ |
233
233
  | CertB64 | 必填,证书Base64 | `String` | -- |
234
234
 
235
- ### PKCS1签名
235
+ ### 2.8 PKCS1签名
236
236
 
237
237
  PKCS1签名,返回签名值
238
238
 
@@ -256,7 +256,7 @@ type Pkcs1Sign = (
256
256
  | Data | 必填,待签名原文 | `String` | -- |
257
257
  | IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
258
258
 
259
- ### PKCS1验签
259
+ ### 2.9 PKCS1验签
260
260
 
261
261
  PKCS1验签,传入curCert时使用该证书,返回验签结果,`true`为验签成功,验签失败时返回`Promise.reject`
262
262
 
@@ -285,7 +285,7 @@ type Pkcs1VerifySignature = (
285
285
  | SignData | 必填,Base64编码的签名值 | `String` | -- |
286
286
  | CertB64 | 可选,Base64编码的签名证书 | `String` | -- |
287
287
 
288
- ### PKCS1 B64签名
288
+ ### 2.10 PKCS1 B64签名
289
289
 
290
290
  PKCS1 base64签名,传入curCert时使用该证书,返回签名值
291
291
 
@@ -311,7 +311,7 @@ type Pkcs1Base64Sign = (params: {
311
311
  | DataB64 | 与Data二选一 , Base64编码的待签名原文,同时存在时使用DataB64 | `String` | -- |
312
312
  | IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
313
313
 
314
- ### PKCS1 B64验签
314
+ ### 2.11 PKCS1 B64验签
315
315
 
316
316
  PKCS1 base64验签,返回验签结果,`true`为验签成功,验签失败时返回`Promise.reject`
317
317
 
@@ -339,7 +339,7 @@ type Pkcs1Base64VerifySignature = (params: {
339
339
  | SignData | 必填,Base64编码的签名值 | `String` | -- |
340
340
  | CertB64 | 可选,Base64编码的签名证书 | `String` | -- |
341
341
 
342
- ### PKCS1哈希签名
342
+ ### 2.12 PKCS1哈希签名
343
343
 
344
344
  PKCS1哈希签名,返回签名值
345
345
 
@@ -366,7 +366,7 @@ type Pkcs1HashSign = (
366
366
  | HashAlg | 可选,哈希算法 | `sm3` \| `sha1`\| `sha256` | `sm3` |
367
367
  | IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
368
368
 
369
- ### PKCS1哈希验签
369
+ ### 2.13 PKCS1哈希验签
370
370
 
371
371
  PKCS1哈希验签,返回验签结果,传入curCert时使用该证书,`true`为验签成功,验签失败时返回`Promise.reject`
372
372
 
@@ -394,7 +394,7 @@ type Pkcs1Base64VerifySignature = (params: {
394
394
  | CertB64 | 可选,Base64编码的签名证书 | `String` | -- |
395
395
  | HashAlg | 可选,哈希算法 | `sm3` \| `sha1`\| `sha256` | `sm3` |
396
396
 
397
- ### PKCS7签名
397
+ ### 2.14 PKCS7签名
398
398
 
399
399
  PKCS7签名,返回签名值
400
400
 
@@ -425,7 +425,7 @@ type Pkcs7Sign = (
425
425
  | IsDetached | 必填,Y为detach,N为attach,attach模式签名值带了原文 | `Y` \| `N` | -- |
426
426
  | IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
427
427
 
428
- ### PKCS7验签
428
+ ### 2.15 PKCS7验签
429
429
 
430
430
  PKCS7验签,返回验签结果,传入curCert时使用该证书,`true`为验签成功,验签失败时返回`Promise.reject`
431
431
 
@@ -451,7 +451,7 @@ type Pkcs7VerifySignature = (params: {
451
451
  | DataB64 | 与Data二选一 , Base64编码的待签名原文,同时存在时使用DataB64 | `String` | -- |
452
452
  | SignData | 必填,签名值 | `String` | -- |
453
453
 
454
- ### base64编码
454
+ ### 2.16 base64编码
455
455
 
456
456
  base64编码,返回base64编码内容
457
457
 
@@ -471,7 +471,7 @@ type Base64Encode = (params: { Data: string }) => string;
471
471
  | ---- | ---------------------- | -------- | ------ |
472
472
  | Data | 必填,base64待编码内容 | `String` | -- |
473
473
 
474
- ### base64解码
474
+ ### 2.17 base64解码
475
475
 
476
476
  base64解码,返回base64解码内容
477
477
 
@@ -491,7 +491,7 @@ type Base64Decode = (params: { DataB64: string }) => string;
491
491
  | ------- | ---------------------- | -------- | ------ |
492
492
  | DataB64 | 必填,base64待解码内容 | `String` | -- |
493
493
 
494
- ### SM3哈希
494
+ ### 2.18 SM3哈希
495
495
 
496
496
  SM3哈希,返回SM3哈希值
497
497
 
@@ -511,7 +511,7 @@ type Sm3Hash = (params: { Data: string }) => Promise<string>;
511
511
  | ---- | ------------------------ | -------- | ------ |
512
512
  | Data | 必填,待计算杂凑值的原文 | `String` | -- |
513
513
 
514
- ### SM3 B64哈希
514
+ ### 2.19 SM3 B64哈希
515
515
 
516
516
  SM3 B64哈希
517
517
 
@@ -531,7 +531,7 @@ type Sm3HexHash = (params: { DataB64: string }) => Promise<string>;
531
531
  | ------- | ------------------------------ | -------- | ------ |
532
532
  | DataB64 | 必填,待计算杂凑值的原文base64 | `String` | -- |
533
533
 
534
- ### SM3 文件哈希
534
+ ### 2.20 SM3 文件哈希
535
535
 
536
536
  SM3 文件哈希
537
537
 
@@ -551,7 +551,7 @@ type Sm3FileHash = (params: { SrcFile: string }) => Promise<string>;
551
551
  | ------- | ------------------------------------------------------- | -------- | ------ |
552
552
  | SrcFile | 必填,待计算杂凑值的本地文件全路径。建议使用正斜杠(/) | `String` | -- |
553
553
 
554
- ### SM3哈希加密
554
+ ### 2.21 SM3哈希加密
555
555
 
556
556
  SM3哈希加密
557
557
 
@@ -579,7 +579,7 @@ type Sm3HashEncryption = (params: {
579
579
  | Key | 与KeyB64二选一,密钥 | `String` | -- |
580
580
  | KeyB64 | 与Key二选一 , base64编码的密钥,同时存在时使用KeyB64 | `String` | -- |
581
581
 
582
- ### PKCS7加密
582
+ ### 2.22 PKCS7加密
583
583
 
584
584
  PKCS7加密,返回加密字符串
585
585
 
@@ -605,7 +605,7 @@ type Pkcs7Encryption = (params: {
605
605
  | DataB64 | 与Data二选一 , Base64编码的待加密原文,同时存在时使用DataB64 | `String` | -- |
606
606
  | CertB64List | 必填,加密证书base64,多个以\|连接 | `String` | -- |
607
607
 
608
- ### PKCS7解密
608
+ ### 2.23 PKCS7解密
609
609
 
610
610
  PKCS7解密,返回解密字符串
611
611
 
@@ -631,7 +631,7 @@ type Pkcs7Decryption = (params: {
631
631
  | shouldDecodeBase64 | 可选,是否需要base64解码 | `Boolean` | -- |
632
632
  | IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
633
633
 
634
- ### 非对称加密
634
+ ### 2.24 非对称加密
635
635
 
636
636
  非对称加密,返回加密字符串
637
637
 
@@ -653,7 +653,7 @@ type AsymmetricDecryption = (params: { Data: string;IsLogin?: string }) => Pro
653
653
  | CertB64 | 可选,加密证书B64 | `String` | -- |
654
654
  | IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
655
655
 
656
- ### 非对称解密
656
+ ### 2.25 非对称解密
657
657
 
658
658
  非对称解密,返回解密字符串
659
659
 
@@ -676,7 +676,7 @@ type AsymmetricDecryption = (
676
676
  | ---- | ---------------- | -------- | ------ |
677
677
  | Data | 必填,待解密原文 | `String` | -- |
678
678
 
679
- ### SM4对称加密
679
+ ### 2.26 SM4对称加密
680
680
 
681
681
  SM4对称加密,传入curCert时使用该证书,返回加密字符串,加密密钥
682
682
 
@@ -705,7 +705,7 @@ type Sm4Encryption = (params: {
705
705
  | Data | 加密密文 | `String` |
706
706
  | KeyB64 | Base64对称密钥 | `String` |
707
707
 
708
- ### SM4对称解密
708
+ ### 2.27 SM4对称解密
709
709
 
710
710
  SM4对称解密,返回解密字符串
711
711
 
@@ -729,7 +729,7 @@ type Sm4Decryption = (params: {
729
729
  | Data | 必填,待解密原文 | `String` | -- |
730
730
  | KeyB64 | 必填,Base64对称密钥 | `String` | -- |
731
731
 
732
- ### 获取印章列表
732
+ ### 2.28 获取印章列表
733
733
 
734
734
  获取印章列表,传入curCert时使用该证书,可获取印章SealId
735
735
 
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Se=Object.defineProperty,xe=Object.defineProperties;var Be=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable;var J=(n,e,t)=>e in n?Se(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))$e.call(e,t)&&J(n,t,e[t]);if(ee)for(var t of ee(e))Ie.call(e,t)&&J(n,t,e[t]);return n},x=(n,e)=>xe(n,Be(e));var i=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);var l=(n,e,t)=>new Promise((s,r)=>{var a=d=>{try{u(t.next(d))}catch(h){r(h)}},o=d=>{try{u(t.throw(d))}catch(h){r(h)}},u=d=>d.done?s(d.value):Promise.resolve(d.value).then(a,o);u((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ee=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",te="1",ne="2";var ge=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(ge||{});const Ae="00000001";function _e(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var F={},se;function Le(){if(se)return F;se=1,F.byteLength=u,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 g=y.indexOf("=");g===-1&&(g=c);var w=g===c?0:4-g%4;return[g,w]}function u(y){var c=o(y),g=c[0],w=c[1];return(g+w)*3/4-w}function d(y,c,g){return(c+g)*3/4-g}function h(y){var c,g=o(y),w=g[0],m=g[1],C=new t(d(y,w,m)),b=0,A=m>0?w-4:w,k;for(k=0;k<A;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[b++]=c>>16&255,C[b++]=c>>8&255,C[b++]=c&255;return m===2&&(c=e[y.charCodeAt(k)]<<2|e[y.charCodeAt(k+1)]>>4,C[b++]=c&255),m===1&&(c=e[y.charCodeAt(k)]<<10|e[y.charCodeAt(k+1)]<<4|e[y.charCodeAt(k+2)]>>2,C[b++]=c>>8&255,C[b++]=c&255),C}function f(y){return n[y>>18&63]+n[y>>12&63]+n[y>>6&63]+n[y&63]}function v(y,c,g){for(var w,m=[],C=c;C<g;C+=3)w=(y[C]<<16&16711680)+(y[C+1]<<8&65280)+(y[C+2]&255),m.push(f(w));return m.join("")}function p(y){for(var c,g=y.length,w=g%3,m=[],C=16383,b=0,A=g-w;b<A;b+=C)m.push(v(y,b,b+C>A?A:b+C));return w===1?(c=y[g-1],m.push(n[c>>2]+n[c<<4&63]+"==")):w===2&&(c=(y[g-2]<<8)+y[g-1],m.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),m.join("")}return F}var Pe=Le();const re=_e(Pe);class Te{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 Me=Object.defineProperty,He=(n,e,t)=>e in n?Me(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ae=(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 fe(n){return n()}function oe(){return Object.create(null)}function V(n){n.forEach(fe)}function O(n){return typeof n=="function"}function pe(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=me(n,e,t,s);return n[0](r)}}function me(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 u=0;u<o;u+=1)a[u]=e.dirty[u]|r[u];return a}return e.dirty|r}return e.dirty}function Ne(n,e,t,s,r,a){if(r){const o=me(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 ie(n){return n!=null?n:""}function S(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 I(n){return document.createElement(n)}function E(n){return document.createTextNode(n)}function N(){return E(" ")}function Re(){return E("")}function j(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function B(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 M(n,e){e=""+e,n.data!==e&&(n.data=e)}function ce(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let X;function Z(n){X=n}const P=[],le=[];let H=[];const ue=[],Je=Promise.resolve();let q=!1;function ze(){q||(q=!0,Je.then(ve))}function K(n){H.push(n)}const z=new Set;let L=0;function ve(){if(L!==0)return;const n=X;do{try{for(;L<P.length;){const e=P[L];L++,Z(e),We(e.$$)}}catch(e){throw P.length=0,L=0,e}for(Z(null),P.length=0,L=0;le.length;)le.pop()();for(let e=0;e<H.length;e+=1){const t=H[e];z.has(t)||(z.add(t),t())}H.length=0}while(P.length);for(;ue.length;)ue.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 Ce(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 de(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Qe(n){n&&n.c()}function we(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),K(()=>{const a=n.$$.on_mount.map(fe).filter(O);n.$$.on_destroy?n.$$.on_destroy.push(...a):V(a),n.$$.on_mount=[]}),r.forEach(K)}function ke(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&&(P.push(n),ze(),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 d=X;Z(n);const h=n.$$={fragment:null,ctx:[],props:a,update:W,not_equal:r,bound:oe(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:oe(),dirty:u,skip_bound:!1,root:e.target||d.$$.root};o&&o(h.root);let f=!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),f&&Xe(n,v)),p}):[],h.update(),f=!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),we(n,e.target,e.anchor),ve()}Z(d)}class De{constructor(){ae(this,"$$"),ae(this,"$$set")}$destroy(){ke(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,u,d,h,f,v=(n[4]||"取消")+"",p,y,c,g=(n[5]||"确认")+"",w,m,C,b;const A=n[8].default,k=je(A,n,n[7],null);return{c(){e=I("div"),t=I("div"),s=I("div"),a=E(r),o=N(),u=I("div"),k&&k.c(),d=N(),h=I("div"),f=I("button"),p=E(v),y=N(),c=I("button"),w=E(g),B(s,"class","model-title svelte-oivou"),B(u,"class","slot svelte-oivou"),B(f,"class","modal-btn svelte-oivou"),B(c,"class","modal-btn success svelte-oivou"),ce(c,"background-color",n[6]),B(h,"class","modal-footer svelte-oivou"),B(t,"class","modal-content svelte-oivou"),B(e,"class","modal-background modal-visible svelte-oivou")},m($,_){Q($,e,_),S(e,t),S(t,s),S(s,a),S(t,o),S(t,u),k&&k.m(u,null),S(t,d),S(t,h),S(h,f),S(f,p),S(h,y),S(h,c),S(c,w),m=!0,C||(b=[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)})],C=!0)},p($,[_]){n=$,(!m||_&2)&&r!==(r=(n[1]||"标题")+"")&&M(a,r),k&&k.p&&(!m||_&128)&&Ne(k,A,n,n[7],m?Oe(A,n[7],_,null):Ze(n[7]),null),(!m||_&16)&&v!==(v=(n[4]||"取消")+"")&&M(p,v),(!m||_&32)&&g!==(g=(n[5]||"确认")+"")&&M(w,g),(!m||_&64)&&ce(c,"background-color",n[6])},i($){m||(Y(k,$),m=!0)},o($){Ce(k,$),m=!1},d($){$&&U(e),k&&k.d($),C=!1,V(b)}}}const tt=n=>n.stopPropagation();function nt(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:a}=e,{title:o}=e,{onOk:u}=e,{onClose:d}=e,{cancelText:h}=e,{okText:f}=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,d=p.onClose),"cancelText"in p&&t(4,h=p.cancelText),"okText"in p&&t(5,f=p.okText),"theme"in p&&t(6,v=p.theme),"$$scope"in p&&t(7,r=p.$$scope)},[a,o,u,d,h,f,v,r,s]}class st extends De{constructor(e){super(),be(this,e,nt,et,pe,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function he(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function ye(n){let e,t,s=n[11].CN+"",r,a,o,u=n[11].DevClass+"",d,h,f=n[11].sn+"",v,p,y,c,g,w;function m(){return n[10](n[13])}return{c(){e=I("div"),t=I("span"),r=E(s),a=N(),o=I("span"),d=E(u),h=E("("),v=E(f),p=E(")"),y=N(),B(t,"class","svelte-jtc2v4"),B(o,"class","svelte-jtc2v4"),B(e,"class",c=ie(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(C,b){Q(C,e,b),S(e,t),S(t,r),S(e,a),S(e,o),S(o,d),S(o,h),S(o,v),S(o,p),S(e,y),g||(w=j(e,"click",m),g=!0)},p(C,b){n=C,b&1&&s!==(s=n[11].CN+"")&&M(r,s),b&1&&u!==(u=n[11].DevClass+"")&&M(d,u),b&1&&f!==(f=n[11].sn+"")&&M(v,f),b&32&&c!==(c=ie(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&B(e,"class",c)},d(C){C&&U(e),g=!1,w()}}}function rt(n){let e,t=de(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=ye(he(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=de(r[0]);let o;for(o=0;o<t.length;o+=1){const u=he(r,t,o);s[o]?s[o].p(u,a):(s[o]=ye(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&&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){we(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){Ce(e.$$.fragment,s),t=!1},d(s){ke(e,s)}}}function ot(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:o}=e,{cancelText:u=""}=e,{okText:d=""}=e,{theme:h="#409eff"}=e,f=0;const v=()=>{r("未选择证书"),o==null||o()},p=()=>{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,u=c.cancelText),"okText"in c&&t(3,d=c.okText),"theme"in c&&t(4,h=c.theme)},[s,o,u,d,h,f,v,p,r,a,y]}class it extends De{constructor(e){super(),be(this,e,ot,at,pe,{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:x(D({},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 Te);i(this,"isRememberPin",!1);i(this,"pinPolicy");i(this,"socketConfig",null);i(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});i(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});i(this,"sendMessage",(e,t)=>new Promise((s,r)=>{var 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,d=>{d.success?s(d.data):r(d)})}));i(this,"handleEventData",e=>l(this,null,function*(){var t,s,r,a,o,u,d,h,f,v;if(e.data instanceof Blob){const p=yield e.data.arrayBuffer(),c=new TextDecoder("gbk").decode(p),g=JSON.parse(c),w={success:(t=g.result)==null?void 0:t.success,msg:(s=g.result)==null?void 0:s.msg,errCode:(r=g.result)==null?void 0:r.errCode,data:g.data},m=(a=g.result)==null?void 0:a.function;m==="GZCA_OnDeviceChange"?(h=(o=this.socketConfig)==null?void 0:o.onUkeyEvent)==null||h.call(o,x(D({},w),{type:(u=g.result)==null?void 0:u.event,data:(d=g.data)==null?void 0:d[0]})):this.eventBus.emit(m,w),(v=(f=this.socketConfig)==null?void 0:f.onMessage)==null||v.call(f,w)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return re.fromByteArray(t)});i(this,"base64Decode",e=>{const t=re.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:Ae})}));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 lt.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",D({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",D({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",D({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",D({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",D({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",D({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",D({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:ge.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 T=class T{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ut(x(D({},e!=null?e:{}),{url:Ee}))});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 x(D({},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:te},e)}));i(this,"getSignatureCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:te})}));i(this,"getEncryptionCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:ne},e)}));i(this,"getEncryptionCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:ne})}));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(x(D({},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,d,h,f;const s=yield this.getSignatureCert(t),r=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),a=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign(x(D({},e!=null?e:{}),{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=>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,d;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(d=r==null?void 0:r[0])==null?void 0:d.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(x(D({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var o,u,d,h,f;const s=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield this.getSignatureCert(t),a=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign(x(D({},e!=null?e:{}),{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=>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,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:(u=e.Key)!=null?u:""}),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=>l(this,null,function*(){var r,a,o,u;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(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(x(D({},e!=null?e:{}),{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(x(D({},e!=null?e:{}),{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 D({},(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(D({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return T.instance&&!(e!=null&&e.isCreateNew)?T.instance:(this.createGwsCore(e),T.instance=this,this)}};i(T,"instance",null);let G=T;function dt(n){return new Promise((e,t)=>{if(G.instance&&!(n!=null&&n.isCreateNew))e(G.instance);else{const s=new G(x(D({},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 Se=Object.defineProperty,xe=Object.defineProperties;var Be=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var $e=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable;var J=(n,e,t)=>e in n?Se(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))$e.call(e,t)&&J(n,t,e[t]);if(ee)for(var t of ee(e))Ie.call(e,t)&&J(n,t,e[t]);return n},x=(n,e)=>xe(n,Be(e));var i=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);var l=(n,e,t)=>new Promise((s,r)=>{var a=d=>{try{u(t.next(d))}catch(h){r(h)}},o=d=>{try{u(t.throw(d))}catch(h){r(h)}},u=d=>d.done?s(d.value):Promise.resolve(d.value).then(a,o);u((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ae=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",te="1",ne="2";var ge=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(ge||{});const Ee="00000001";function _e(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var F={},se;function Le(){if(se)return F;se=1,F.byteLength=u,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 g=y.indexOf("=");g===-1&&(g=c);var w=g===c?0:4-g%4;return[g,w]}function u(y){var c=o(y),g=c[0],w=c[1];return(g+w)*3/4-w}function d(y,c,g){return(c+g)*3/4-g}function h(y){var c,g=o(y),w=g[0],m=g[1],v=new t(d(y,w,m)),b=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)],v[b++]=c>>16&255,v[b++]=c>>8&255,v[b++]=c&255;return m===2&&(c=e[y.charCodeAt(k)]<<2|e[y.charCodeAt(k+1)]>>4,v[b++]=c&255),m===1&&(c=e[y.charCodeAt(k)]<<10|e[y.charCodeAt(k+1)]<<4|e[y.charCodeAt(k+2)]>>2,v[b++]=c>>8&255,v[b++]=c&255),v}function f(y){return n[y>>18&63]+n[y>>12&63]+n[y>>6&63]+n[y&63]}function C(y,c,g){for(var w,m=[],v=c;v<g;v+=3)w=(y[v]<<16&16711680)+(y[v+1]<<8&65280)+(y[v+2]&255),m.push(f(w));return m.join("")}function p(y){for(var c,g=y.length,w=g%3,m=[],v=16383,b=0,E=g-w;b<E;b+=v)m.push(C(y,b,b+v>E?E:b+v));return w===1?(c=y[g-1],m.push(n[c>>2]+n[c<<4&63]+"==")):w===2&&(c=(y[g-2]<<8)+y[g-1],m.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),m.join("")}return F}var Pe=Le();const re=_e(Pe);class Te{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 Me=Object.defineProperty,He=(n,e,t)=>e in n?Me(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ae=(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 fe(n){return n()}function oe(){return Object.create(null)}function V(n){n.forEach(fe)}function O(n){return typeof n=="function"}function pe(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=me(n,e,t,s);return n[0](r)}}function me(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 u=0;u<o;u+=1)a[u]=e.dirty[u]|r[u];return a}return e.dirty|r}return e.dirty}function Ne(n,e,t,s,r,a){if(r){const o=me(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 ie(n){return n!=null?n:""}function S(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 I(n){return document.createElement(n)}function A(n){return document.createTextNode(n)}function N(){return A(" ")}function Re(){return A("")}function j(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function B(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 M(n,e){e=""+e,n.data!==e&&(n.data=e)}function ce(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let X;function Z(n){X=n}const P=[],le=[];let H=[];const ue=[],Je=Promise.resolve();let q=!1;function ze(){q||(q=!0,Je.then(Ce))}function K(n){H.push(n)}const z=new Set;let L=0;function Ce(){if(L!==0)return;const n=X;do{try{for(;L<P.length;){const e=P[L];L++,Z(e),We(e.$$)}}catch(e){throw P.length=0,L=0,e}for(Z(null),P.length=0,L=0;le.length;)le.pop()();for(let e=0;e<H.length;e+=1){const t=H[e];z.has(t)||(z.add(t),t())}H.length=0}while(P.length);for(;ue.length;)ue.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 ve(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 de(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Qe(n){n&&n.c()}function we(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),K(()=>{const a=n.$$.on_mount.map(fe).filter(O);n.$$.on_destroy?n.$$.on_destroy.push(...a):V(a),n.$$.on_mount=[]}),r.forEach(K)}function ke(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&&(P.push(n),ze(),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 d=X;Z(n);const h=n.$$={fragment:null,ctx:[],props:a,update:W,not_equal:r,bound:oe(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:oe(),dirty:u,skip_bound:!1,root:e.target||d.$$.root};o&&o(h.root);let f=!1;if(h.ctx=t?t(n,e.props||{},(C,p,...y)=>{const c=y.length?y[0]:p;return h.ctx&&r(h.ctx[C],h.ctx[C]=c)&&(!h.skip_bound&&h.bound[C]&&h.bound[C](c),f&&Xe(n,C)),p}):[],h.update(),f=!0,V(h.before_update),h.fragment=s?s(h.ctx):!1,e.target){if(e.hydrate){const C=Ue(e.target);h.fragment&&h.fragment.l(C),C.forEach(U)}else h.fragment&&h.fragment.c();e.intro&&Y(n.$$.fragment),we(n,e.target,e.anchor),Ce()}Z(d)}class De{constructor(){ae(this,"$$"),ae(this,"$$set")}$destroy(){ke(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,u,d,h,f,C=(n[4]||"取消")+"",p,y,c,g=(n[5]||"确认")+"",w,m,v,b;const E=n[8].default,k=je(E,n,n[7],null);return{c(){e=I("div"),t=I("div"),s=I("div"),a=A(r),o=N(),u=I("div"),k&&k.c(),d=N(),h=I("div"),f=I("button"),p=A(C),y=N(),c=I("button"),w=A(g),B(s,"class","model-title svelte-oivou"),B(u,"class","slot svelte-oivou"),B(f,"class","modal-btn svelte-oivou"),B(c,"class","modal-btn success svelte-oivou"),ce(c,"background-color",n[6]),B(h,"class","modal-footer svelte-oivou"),B(t,"class","modal-content svelte-oivou"),B(e,"class","modal-background modal-visible svelte-oivou")},m($,_){Q($,e,_),S(e,t),S(t,s),S(s,a),S(t,o),S(t,u),k&&k.m(u,null),S(t,d),S(t,h),S(h,f),S(f,p),S(h,y),S(h,c),S(c,w),m=!0,v||(b=[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($,[_]){n=$,(!m||_&2)&&r!==(r=(n[1]||"标题")+"")&&M(a,r),k&&k.p&&(!m||_&128)&&Ne(k,E,n,n[7],m?Oe(E,n[7],_,null):Ze(n[7]),null),(!m||_&16)&&C!==(C=(n[4]||"取消")+"")&&M(p,C),(!m||_&32)&&g!==(g=(n[5]||"确认")+"")&&M(w,g),(!m||_&64)&&ce(c,"background-color",n[6])},i($){m||(Y(k,$),m=!0)},o($){ve(k,$),m=!1},d($){$&&U(e),k&&k.d($),v=!1,V(b)}}}const tt=n=>n.stopPropagation();function nt(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:a}=e,{title:o}=e,{onOk:u}=e,{onClose:d}=e,{cancelText:h}=e,{okText:f}=e,{theme:C}=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,d=p.onClose),"cancelText"in p&&t(4,h=p.cancelText),"okText"in p&&t(5,f=p.okText),"theme"in p&&t(6,C=p.theme),"$$scope"in p&&t(7,r=p.$$scope)},[a,o,u,d,h,f,C,r,s]}class st extends De{constructor(e){super(),be(this,e,nt,et,pe,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function he(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function ye(n){let e,t,s=n[11].CN+"",r,a,o,u=n[11].DevClass+"",d,h,f=n[11].sn+"",C,p,y,c,g,w;function m(){return n[10](n[13])}return{c(){e=I("div"),t=I("span"),r=A(s),a=N(),o=I("span"),d=A(u),h=A("("),C=A(f),p=A(")"),y=N(),B(t,"class","svelte-jtc2v4"),B(o,"class","svelte-jtc2v4"),B(e,"class",c=ie(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(v,b){Q(v,e,b),S(e,t),S(t,r),S(e,a),S(e,o),S(o,d),S(o,h),S(o,C),S(o,p),S(e,y),g||(w=j(e,"click",m),g=!0)},p(v,b){n=v,b&1&&s!==(s=n[11].CN+"")&&M(r,s),b&1&&u!==(u=n[11].DevClass+"")&&M(d,u),b&1&&f!==(f=n[11].sn+"")&&M(C,f),b&32&&c!==(c=ie(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&B(e,"class",c)},d(v){v&&U(e),g=!1,w()}}}function rt(n){let e,t=de(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=ye(he(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=de(r[0]);let o;for(o=0;o<t.length;o+=1){const u=he(r,t,o);s[o]?s[o].p(u,a):(s[o]=ye(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&&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){we(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){ve(e.$$.fragment,s),t=!1},d(s){ke(e,s)}}}function ot(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:o}=e,{cancelText:u=""}=e,{okText:d=""}=e,{theme:h="#409eff"}=e,f=0;const C=()=>{r("未选择证书"),o==null||o()},p=()=>{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,u=c.cancelText),"okText"in c&&t(3,d=c.okText),"theme"in c&&t(4,h=c.theme)},[s,o,u,d,h,f,C,p,r,a,y]}class it extends De{constructor(e){super(),be(this,e,ot,at,pe,{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:x(D({},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 Te);i(this,"isRememberPin",!1);i(this,"pinPolicy");i(this,"socketConfig",null);i(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});i(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});i(this,"sendMessage",(e,t)=>new Promise((s,r)=>{var 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,d=>{d.success?s(d.data):r(d)})}));i(this,"handleEventData",e=>l(this,null,function*(){var t,s,r,a,o,u,d,h,f,C;if(e.data instanceof Blob){const p=yield e.data.arrayBuffer(),c=new TextDecoder("gbk").decode(p),g=JSON.parse(c),w={success:(t=g.result)==null?void 0:t.success,msg:(s=g.result)==null?void 0:s.msg,errCode:(r=g.result)==null?void 0:r.errCode,data:g.data},m=(a=g.result)==null?void 0:a.function;m==="GZCA_OnDeviceChange"?(h=(o=this.socketConfig)==null?void 0:o.onUkeyChange)==null||h.call(o,x(D({},w),{type:(u=g.result)==null?void 0:u.event,data:(d=g.data)==null?void 0:d[0]})):this.eventBus.emit(m,w),(C=(f=this.socketConfig)==null?void 0:f.onMessage)==null||C.call(f,w)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return re.fromByteArray(t)});i(this,"base64Decode",e=>{const t=re.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:Ee})}));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 lt.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",D({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",D({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",D({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",D({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",D({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",D({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",D({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:ge.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=s=>{var r;(r=e.onError)==null||r.call(e,s)},t.onopen=s=>{var r;(r=e.onOpen)==null||r.call(e,s),e.onUkeyChange&&this.addUkeyEvents()},t.onmessage=s=>{this.handleEventData(s)},t.onclose=s=>{var r;(r=e.onClose)==null||r.call(e,s)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const T=class T{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ut(x(D({},e!=null?e:{}),{url:Ae}))});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 x(D({},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:te},e)}));i(this,"getSignatureCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:te})}));i(this,"getEncryptionCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:ne},e)}));i(this,"getEncryptionCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:ne})}));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(x(D({},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,d,h,f;const s=yield this.getSignatureCert(t),r=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),a=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign(x(D({},e!=null?e:{}),{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=>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,d;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(d=r==null?void 0:r[0])==null?void 0:d.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(x(D({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var o,u,d,h,f;const s=(u=e.DataB64)!=null?u:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield this.getSignatureCert(t),a=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign(x(D({},e!=null?e:{}),{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=>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,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:(u=e.Key)!=null?u:""}),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=>l(this,null,function*(){var r,a,o,u;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(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(x(D({},e!=null?e:{}),{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(x(D({},e!=null?e:{}),{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 D({},(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(D({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return T.instance&&!(e!=null&&e.isCreateNew)?T.instance:(this.createGwsCore(e),T.instance=this,this)}};i(T,"instance",null);let G=T;function dt(n){return new Promise((e,t)=>{if(G.instance&&!(n!=null&&n.isCreateNew))e(G.instance);else{const s=new G(x(D({},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.d.ts CHANGED
@@ -155,7 +155,7 @@ export declare type ServiceConfigType = {
155
155
  onMessage?: (data: Record<string, unknown>) => void;
156
156
  onError?: (event: Event) => void;
157
157
  onClose?: (event: Event) => void;
158
- onUkeyEvent?: (data: Record<string, unknown>) => void;
158
+ onUkeyChange?: (data: Record<string, unknown>) => void;
159
159
  theme?: string;
160
160
  };
161
161
 
package/dist/index.es.js CHANGED
@@ -27,9 +27,9 @@ var l = (n, e, t) => new Promise((s, r) => {
27
27
  }, u = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(a, o);
28
28
  u((t = t.apply(n, e)).next());
29
29
  });
30
- const Ee = window.location.href.includes("https") ? "wss://localhost:19528" : "ws://localhost:9527", te = "1", ne = "2";
31
- var fe = /* @__PURE__ */ ((n) => (n[n.MIN = 0] = "MIN", n[n.LOW = 1] = "LOW", n[n.MIDDLE = 2] = "MIDDLE", n[n.HIGH = 3] = "HIGH", n))(fe || {});
32
- const Ae = "00000001";
30
+ const Ae = window.location.href.includes("https") ? "wss://localhost:19528" : "ws://localhost:9527", te = "1", ne = "2";
31
+ var ge = /* @__PURE__ */ ((n) => (n[n.MIN = 0] = "MIN", n[n.LOW = 1] = "LOW", n[n.MIDDLE = 2] = "MIDDLE", n[n.HIGH = 3] = "HIGH", n))(ge || {});
32
+ const Ee = "00000001";
33
33
  function _e(n) {
34
34
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
35
35
  }
@@ -44,38 +44,38 @@ 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 f = y.indexOf("=");
48
- f === -1 && (f = c);
49
- var w = f === c ? 0 : 4 - f % 4;
50
- return [f, w];
47
+ var g = y.indexOf("=");
48
+ g === -1 && (g = c);
49
+ var w = g === c ? 0 : 4 - g % 4;
50
+ return [g, w];
51
51
  }
52
52
  function u(y) {
53
- var c = o(y), f = c[0], w = c[1];
54
- return (f + w) * 3 / 4 - w;
53
+ var c = o(y), g = c[0], w = c[1];
54
+ return (g + w) * 3 / 4 - w;
55
55
  }
56
- function d(y, c, f) {
57
- return (c + f) * 3 / 4 - f;
56
+ function d(y, c, g) {
57
+ return (c + g) * 3 / 4 - g;
58
58
  }
59
59
  function h(y) {
60
- var c, f = o(y), w = f[0], m = f[1], v = new t(d(y, w, m)), b = 0, A = m > 0 ? w - 4 : w, k;
61
- for (k = 0; k < A; k += 4)
60
+ var c, g = o(y), w = g[0], m = g[1], v = new t(d(y, w, m)), b = 0, E = m > 0 ? w - 4 : w, k;
61
+ for (k = 0; k < E; k += 4)
62
62
  c = e[y.charCodeAt(k)] << 18 | e[y.charCodeAt(k + 1)] << 12 | e[y.charCodeAt(k + 2)] << 6 | e[y.charCodeAt(k + 3)], v[b++] = c >> 16 & 255, v[b++] = c >> 8 & 255, v[b++] = c & 255;
63
63
  return m === 2 && (c = e[y.charCodeAt(k)] << 2 | e[y.charCodeAt(k + 1)] >> 4, v[b++] = c & 255), m === 1 && (c = e[y.charCodeAt(k)] << 10 | e[y.charCodeAt(k + 1)] << 4 | e[y.charCodeAt(k + 2)] >> 2, v[b++] = c >> 8 & 255, v[b++] = c & 255), v;
64
64
  }
65
- function g(y) {
65
+ function f(y) {
66
66
  return n[y >> 18 & 63] + n[y >> 12 & 63] + n[y >> 6 & 63] + n[y & 63];
67
67
  }
68
- function C(y, c, f) {
69
- for (var w, m = [], v = c; v < f; v += 3)
70
- w = (y[v] << 16 & 16711680) + (y[v + 1] << 8 & 65280) + (y[v + 2] & 255), m.push(g(w));
68
+ function C(y, c, g) {
69
+ for (var w, m = [], v = c; v < g; v += 3)
70
+ w = (y[v] << 16 & 16711680) + (y[v + 1] << 8 & 65280) + (y[v + 2] & 255), m.push(f(w));
71
71
  return m.join("");
72
72
  }
73
73
  function p(y) {
74
- for (var c, f = y.length, w = f % 3, m = [], v = 16383, b = 0, A = f - w; b < A; b += v)
75
- m.push(C(y, b, b + v > A ? A : b + v));
76
- return w === 1 ? (c = y[f - 1], m.push(
74
+ for (var c, g = y.length, w = g % 3, m = [], v = 16383, b = 0, E = g - w; b < E; b += v)
75
+ m.push(C(y, b, b + v > E ? E : b + v));
76
+ return w === 1 ? (c = y[g - 1], m.push(
77
77
  n[c >> 2] + n[c << 4 & 63] + "=="
78
- )) : w === 2 && (c = (y[f - 2] << 8) + y[f - 1], m.push(
78
+ )) : w === 2 && (c = (y[g - 2] << 8) + y[g - 1], m.push(
79
79
  n[c >> 10] + n[c >> 4 & 63] + n[c << 2 & 63] + "="
80
80
  )), m.join("");
81
81
  }
@@ -113,14 +113,14 @@ function Ge(n, e) {
113
113
  n
114
114
  );
115
115
  }
116
- function ge(n) {
116
+ function fe(n) {
117
117
  return n();
118
118
  }
119
119
  function oe() {
120
120
  return /* @__PURE__ */ Object.create(null);
121
121
  }
122
122
  function V(n) {
123
- n.forEach(ge);
123
+ n.forEach(fe);
124
124
  }
125
125
  function j(n) {
126
126
  return typeof n == "function";
@@ -189,14 +189,14 @@ function Ve(n, e) {
189
189
  function I(n) {
190
190
  return document.createElement(n);
191
191
  }
192
- function E(n) {
192
+ function A(n) {
193
193
  return document.createTextNode(n);
194
194
  }
195
195
  function N() {
196
- return E(" ");
196
+ return A(" ");
197
197
  }
198
198
  function Re() {
199
- return E("");
199
+ return A("");
200
200
  }
201
201
  function F(n, e, t, s) {
202
202
  return n.addEventListener(e, t, s), () => n.removeEventListener(e, t, s);
@@ -287,7 +287,7 @@ function Qe(n) {
287
287
  function we(n, e, t) {
288
288
  const { fragment: s, after_update: r } = n.$$;
289
289
  s && s.m(e, t), K(() => {
290
- const a = n.$$.on_mount.map(ge).filter(j);
290
+ const a = n.$$.on_mount.map(fe).filter(j);
291
291
  n.$$.on_destroy ? n.$$.on_destroy.push(...a) : V(a), n.$$.on_mount = [];
292
292
  }), r.forEach(K);
293
293
  }
@@ -323,11 +323,11 @@ function be(n, e, t, s, r, a, o = null, u = [-1]) {
323
323
  root: e.target || d.$$.root
324
324
  };
325
325
  o && o(h.root);
326
- let g = !1;
326
+ let f = !1;
327
327
  if (h.ctx = t ? t(n, e.props || {}, (C, p, ...y) => {
328
328
  const c = y.length ? y[0] : p;
329
- return h.ctx && r(h.ctx[C], h.ctx[C] = c) && (!h.skip_bound && h.bound[C] && h.bound[C](c), g && Xe(n, C)), p;
330
- }) : [], h.update(), g = !0, V(h.before_update), h.fragment = s ? s(h.ctx) : !1, e.target) {
329
+ return h.ctx && r(h.ctx[C], h.ctx[C] = c) && (!h.skip_bound && h.bound[C] && h.bound[C](c), f && Xe(n, C)), p;
330
+ }) : [], h.update(), f = !0, V(h.before_update), h.fragment = s ? s(h.ctx) : !1, e.target) {
331
331
  if (e.hydrate) {
332
332
  const C = Ue(e.target);
333
333
  h.fragment && h.fragment.l(C), C.forEach(U);
@@ -374,18 +374,18 @@ function et(n) {
374
374
  let e, t, s, r = (
375
375
  /*title*/
376
376
  (n[1] || "标题") + ""
377
- ), a, o, u, d, h, g, C = (
377
+ ), a, o, u, d, h, f, C = (
378
378
  /*cancelText*/
379
379
  (n[4] || "取消") + ""
380
- ), p, y, c, f = (
380
+ ), p, y, c, g = (
381
381
  /*okText*/
382
382
  (n[5] || "确认") + ""
383
383
  ), w, m, v, b;
384
- const A = (
384
+ const E = (
385
385
  /*#slots*/
386
386
  n[8].default
387
387
  ), k = je(
388
- A,
388
+ E,
389
389
  n,
390
390
  /*$$scope*/
391
391
  n[7],
@@ -393,7 +393,7 @@ function et(n) {
393
393
  );
394
394
  return {
395
395
  c() {
396
- e = I("div"), t = I("div"), s = I("div"), a = E(r), o = N(), u = I("div"), k && k.c(), d = N(), h = I("div"), g = I("button"), p = E(C), y = N(), c = I("button"), w = E(f), S(s, "class", "model-title svelte-oivou"), S(u, "class", "slot svelte-oivou"), S(g, "class", "modal-btn svelte-oivou"), S(c, "class", "modal-btn success svelte-oivou"), ce(
396
+ e = I("div"), t = I("div"), s = I("div"), a = A(r), o = N(), u = I("div"), k && k.c(), d = N(), h = I("div"), f = I("button"), p = A(C), y = N(), c = I("button"), w = A(g), S(s, "class", "model-title svelte-oivou"), S(u, "class", "slot svelte-oivou"), S(f, "class", "modal-btn svelte-oivou"), S(c, "class", "modal-btn success svelte-oivou"), ce(
397
397
  c,
398
398
  "background-color",
399
399
  /*theme*/
@@ -401,8 +401,8 @@ function et(n) {
401
401
  ), S(h, "class", "modal-footer svelte-oivou"), S(t, "class", "modal-content svelte-oivou"), S(e, "class", "modal-background modal-visible svelte-oivou");
402
402
  },
403
403
  m($, _) {
404
- Q($, e, _), x(e, t), x(t, s), x(s, a), x(t, o), x(t, u), k && k.m(u, null), x(t, d), x(t, h), x(h, g), x(g, p), x(h, y), x(h, c), x(c, w), m = !0, v || (b = [
405
- F(g, "click", function() {
404
+ Q($, e, _), x(e, t), x(t, s), x(s, a), x(t, o), x(t, u), k && k.m(u, null), x(t, d), x(t, h), x(h, f), x(f, p), x(h, y), x(h, c), x(c, w), m = !0, v || (b = [
405
+ F(f, "click", function() {
406
406
  j(
407
407
  /*onCancel*/
408
408
  n[0]
@@ -429,12 +429,12 @@ function et(n) {
429
429
  (n[1] || "标题") + "") && H(a, r), k && k.p && (!m || _ & /*$$scope*/
430
430
  128) && Oe(
431
431
  k,
432
- A,
432
+ E,
433
433
  n,
434
434
  /*$$scope*/
435
435
  n[7],
436
436
  m ? Ne(
437
- A,
437
+ E,
438
438
  /*$$scope*/
439
439
  n[7],
440
440
  _,
@@ -447,8 +447,8 @@ function et(n) {
447
447
  ), (!m || _ & /*cancelText*/
448
448
  16) && C !== (C = /*cancelText*/
449
449
  (n[4] || "取消") + "") && H(p, C), (!m || _ & /*okText*/
450
- 32) && f !== (f = /*okText*/
451
- (n[5] || "确认") + "") && H(w, f), (!m || _ & /*theme*/
450
+ 32) && g !== (g = /*okText*/
451
+ (n[5] || "确认") + "") && H(w, g), (!m || _ & /*theme*/
452
452
  64) && ce(
453
453
  c,
454
454
  "background-color",
@@ -469,10 +469,10 @@ function et(n) {
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: u } = e, { onClose: d } = e, { cancelText: h } = e, { okText: g } = e, { theme: C } = e;
472
+ let { $$slots: s = {}, $$scope: r } = e, { onCancel: a } = e, { title: o } = e, { onOk: u } = e, { onClose: d } = e, { cancelText: h } = e, { okText: f } = e, { theme: C } = e;
473
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, u = 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, C = p.theme), "$$scope" in p && t(7, r = p.$$scope);
475
- }, [a, o, u, d, h, g, C, r, s];
474
+ "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, d = p.onClose), "cancelText" in p && t(4, h = p.cancelText), "okText" in p && t(5, f = p.okText), "theme" in p && t(6, C = p.theme), "$$scope" in p && t(7, r = p.$$scope);
475
+ }, [a, o, u, d, h, f, C, r, s];
476
476
  }
477
477
  class st extends De {
478
478
  constructor(e) {
@@ -498,10 +498,10 @@ function ye(n) {
498
498
  ), r, a, o, u = (
499
499
  /*item*/
500
500
  n[11].DevClass + ""
501
- ), d, h, g = (
501
+ ), d, h, f = (
502
502
  /*item*/
503
503
  n[11].sn + ""
504
- ), C, p, y, c, f, w;
504
+ ), C, p, y, c, g, w;
505
505
  function m() {
506
506
  return (
507
507
  /*click_handler*/
@@ -513,13 +513,13 @@ function ye(n) {
513
513
  }
514
514
  return {
515
515
  c() {
516
- e = I("div"), t = I("span"), r = E(s), a = N(), o = I("span"), d = E(u), h = E("("), C = E(g), p = E(")"), y = N(), S(t, "class", "svelte-jtc2v4"), S(o, "class", "svelte-jtc2v4"), S(e, "class", c = ie(`cert-item ${/*index*/
516
+ e = I("div"), t = I("span"), r = A(s), a = N(), o = I("span"), d = A(u), h = A("("), C = A(f), p = A(")"), y = N(), S(t, "class", "svelte-jtc2v4"), S(o, "class", "svelte-jtc2v4"), S(e, "class", c = ie(`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
521
  m(v, b) {
522
- Q(v, e, b), x(e, t), x(t, r), x(e, a), x(e, o), x(o, d), x(o, h), x(o, C), x(o, p), x(e, y), f || (w = F(e, "click", m), f = !0);
522
+ Q(v, e, b), x(e, t), x(t, r), x(e, a), x(e, o), x(o, d), x(o, h), x(o, C), x(o, p), x(e, y), g || (w = F(e, "click", m), g = !0);
523
523
  },
524
524
  p(v, b) {
525
525
  n = v, b & /*certList*/
@@ -527,15 +527,15 @@ function ye(n) {
527
527
  n[11].CN + "") && H(r, s), b & /*certList*/
528
528
  1 && u !== (u = /*item*/
529
529
  n[11].DevClass + "") && H(d, u), b & /*certList*/
530
- 1 && g !== (g = /*item*/
531
- n[11].sn + "") && H(C, g), b & /*selectedIndex*/
530
+ 1 && f !== (f = /*item*/
531
+ n[11].sn + "") && H(C, f), b & /*selectedIndex*/
532
532
  32 && c !== (c = ie(`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") && S(e, "class", c);
536
536
  },
537
537
  d(v) {
538
- v && U(e), f = !1, w();
538
+ v && U(e), g = !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: u = "" } = e, { okText: d = "" } = e, { theme: h = "#409eff" } = e, g = 0;
646
+ let { certList: s = [] } = e, { onCancel: r } = e, { onOk: a } = e, { onClose: o } = e, { cancelText: u = "" } = e, { okText: d = "" } = e, { theme: h = "#409eff" } = e, f = 0;
647
647
  const C = () => {
648
648
  r("未选择证书"), o == null || o();
649
649
  }, p = () => {
650
- a == null || a(s[g]), o == null || o();
651
- }, y = (c) => t(5, g = c);
650
+ a == null || a(s[f]), o == null || o();
651
+ }, y = (c) => t(5, f = 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, u = c.cancelText), "okText" in c && t(3, d = c.okText), "theme" in c && t(4, h = c.theme);
654
654
  }, [
@@ -657,7 +657,7 @@ function ot(n, e, t) {
657
657
  u,
658
658
  d,
659
659
  h,
660
- g,
660
+ f,
661
661
  C,
662
662
  p,
663
663
  r,
@@ -742,18 +742,18 @@ class ut {
742
742
  });
743
743
  }));
744
744
  i(this, "handleEventData", (e) => l(this, null, function* () {
745
- var t, s, r, a, o, u, d, h, g, C;
745
+ var t, s, r, a, o, u, d, h, f, C;
746
746
  if (e.data instanceof Blob) {
747
- const p = yield e.data.arrayBuffer(), c = new TextDecoder("gbk").decode(p), f = JSON.parse(c), w = {
748
- success: (t = f.result) == null ? void 0 : t.success,
749
- msg: (s = f.result) == null ? void 0 : s.msg,
750
- errCode: (r = f.result) == null ? void 0 : r.errCode,
751
- data: f.data
752
- }, m = (a = f.result) == null ? void 0 : a.function;
753
- m === "GZCA_OnDeviceChange" ? (h = (o = this.socketConfig) == null ? void 0 : o.onUkeyEvent) == null || h.call(o, B(D({}, w), {
754
- type: (u = f.result) == null ? void 0 : u.event,
755
- data: (d = f.data) == null ? void 0 : d[0]
756
- })) : this.eventBus.emit(m, w), (C = (g = this.socketConfig) == null ? void 0 : g.onMessage) == null || C.call(g, w);
747
+ const p = yield e.data.arrayBuffer(), c = new TextDecoder("gbk").decode(p), g = JSON.parse(c), w = {
748
+ success: (t = g.result) == null ? void 0 : t.success,
749
+ msg: (s = g.result) == null ? void 0 : s.msg,
750
+ errCode: (r = g.result) == null ? void 0 : r.errCode,
751
+ data: g.data
752
+ }, m = (a = g.result) == null ? void 0 : a.function;
753
+ m === "GZCA_OnDeviceChange" ? (h = (o = this.socketConfig) == null ? void 0 : o.onUkeyChange) == null || h.call(o, B(D({}, w), {
754
+ type: (u = g.result) == null ? void 0 : u.event,
755
+ data: (d = g.data) == null ? void 0 : d[0]
756
+ })) : this.eventBus.emit(m, w), (C = (f = this.socketConfig) == null ? void 0 : f.onMessage) == null || C.call(f, w);
757
757
  }
758
758
  }));
759
759
  i(this, "base64Encode", (e) => {
@@ -775,7 +775,7 @@ class ut {
775
775
  }));
776
776
  i(this, "addUkeyEvents", () => l(this, null, function* () {
777
777
  this.sendMessage("GZCA_WaitForDevEvent", {
778
- Type: Ae
778
+ Type: Ee
779
779
  });
780
780
  }));
781
781
  i(this, "certLogin", (e) => l(this, null, function* () {
@@ -896,7 +896,7 @@ class ut {
896
896
  return yield this.sendMessage("GZCA_GetCertInfoByOid", e);
897
897
  }));
898
898
  var t, s;
899
- this.socketConfig = e, this.socketInstance = this.createSocket(e), this.isRememberPin = (t = e.isRememberPin) != null ? t : !1, this.pinPolicy = (s = e.pinPolicy) != null ? s : fe.MIN;
899
+ this.socketConfig = e, this.socketInstance = this.createSocket(e), this.isRememberPin = (t = e.isRememberPin) != null ? t : !1, this.pinPolicy = (s = e.pinPolicy) != null ? s : ge.MIN;
900
900
  }
901
901
  createSocket(e) {
902
902
  const t = new WebSocket(e.url);
@@ -905,7 +905,7 @@ class ut {
905
905
  (r = e.onError) == null || r.call(e, s);
906
906
  }, t.onopen = (s) => {
907
907
  var r;
908
- (r = e.onOpen) == null || r.call(e, s), e.onUkeyEvent && this.addUkeyEvents();
908
+ (r = e.onOpen) == null || r.call(e, s), e.onUkeyChange && this.addUkeyEvents();
909
909
  }, t.onmessage = (s) => {
910
910
  this.handleEventData(s);
911
911
  }, t.onclose = (s) => {
@@ -923,7 +923,7 @@ const T = class T {
923
923
  i(this, "gwsConfig", {});
924
924
  i(this, "createGwsCore", (e) => {
925
925
  this.gwsConfig = e != null ? e : {}, this.coreInstance = new ut(B(D({}, e != null ? e : {}), {
926
- url: Ee
926
+ url: Ae
927
927
  }));
928
928
  });
929
929
  i(this, "appendCertBase64", (e, t = !0) => l(this, null, function* () {
@@ -997,12 +997,12 @@ const T = class T {
997
997
  return Array.isArray(s);
998
998
  }));
999
999
  i(this, "pkcs1Base64Sign", (e, t) => l(this, null, function* () {
1000
- var o, u, d, h, g;
1000
+ var o, u, d, h, f;
1001
1001
  const s = yield this.getSignatureCert(t), r = (u = e.DataB64) != null ? u : this.base64Encode({ Data: (o = e.Data) != null ? o : "" }), a = yield (h = this.coreInstance) == null ? void 0 : h.pkcs1Base64Sign(B(D({}, e != null ? e : {}), {
1002
1002
  ContainerName: (d = s == null ? void 0 : s.ContainerName) != null ? d : "",
1003
1003
  DataB64: r
1004
1004
  }));
1005
- return (g = a == null ? void 0 : a[0]) == null ? void 0 : g.SignData;
1005
+ return (f = a == null ? void 0 : a[0]) == null ? void 0 : f.SignData;
1006
1006
  }));
1007
1007
  i(this, "pkcs1Base64VerifySignature", (e) => l(this, null, function* () {
1008
1008
  var a, o, u;
@@ -1053,12 +1053,12 @@ const T = class T {
1053
1053
  })));
1054
1054
  }));
1055
1055
  i(this, "pkcs7Sign", (e, t) => l(this, null, function* () {
1056
- var o, u, d, h, g;
1056
+ var o, u, d, h, f;
1057
1057
  const s = (u = e.DataB64) != null ? u : this.base64Encode({ Data: (o = e.Data) != null ? o : "" }), r = yield this.getSignatureCert(t), a = yield (h = this.coreInstance) == null ? void 0 : h.pkcs7Sign(B(D({}, e != null ? e : {}), {
1058
1058
  ContainerName: (d = r == null ? void 0 : r.ContainerName) != null ? d : "",
1059
1059
  DataB64: s
1060
1060
  }));
1061
- return (g = a == null ? void 0 : a[0]) == null ? void 0 : g.SignData;
1061
+ return (f = a == null ? void 0 : a[0]) == null ? void 0 : f.SignData;
1062
1062
  }));
1063
1063
  i(this, "pkcs7VerifySignature", (e) => l(this, null, function* () {
1064
1064
  var r, a, o;
@@ -1084,13 +1084,13 @@ const T = class T {
1084
1084
  return (r = t == null ? void 0 : t[0]) == null ? void 0 : r.HashB64;
1085
1085
  }));
1086
1086
  i(this, "sm3HashEncryption", (e) => l(this, null, function* () {
1087
- var a, o, u, d, h, g;
1087
+ var a, o, u, d, h, f;
1088
1088
  const t = (o = e.DataB64) != null ? o : this.base64Encode({ Data: (a = e.Data) != null ? a : "" }), s = (d = e.KeyB64) != null ? d : this.base64Encode({ Data: (u = e.Key) != null ? u : "" }), r = yield (h = this.coreInstance) == null ? void 0 : h.sm3HashEncryption({
1089
1089
  dataB64: t,
1090
1090
  keyB64: s,
1091
1091
  alg: "sm3"
1092
1092
  });
1093
- return (g = r == null ? void 0 : r[0]) == null ? void 0 : g.DataB64;
1093
+ return (f = r == null ? void 0 : r[0]) == null ? void 0 : f.DataB64;
1094
1094
  }));
1095
1095
  i(this, "pkcs7Encryption", (e) => l(this, null, function* () {
1096
1096
  var r, a, o, u;
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(S,k){typeof exports=="object"&&typeof module!="undefined"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(S=typeof globalThis!="undefined"?globalThis:S||self,k(S.GWS_CLIENT={}))})(this,function(S){"use strict";var ct=Object.defineProperty,lt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Ie=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ce=(S,k,$)=>k in S?ct(S,k,{enumerable:!0,configurable:!0,writable:!0,value:$}):S[k]=$,B=(S,k)=>{for(var $ in k||(k={}))dt.call(k,$)&&ce(S,$,k[$]);if(Ie)for(var $ of Ie(k))ht.call(k,$)&&ce(S,$,k[$]);return S},I=(S,k)=>lt(S,ut(k));var i=(S,k,$)=>ce(S,typeof k!="symbol"?k+"":k,$);var l=(S,k,$)=>new Promise((K,V)=>{var Y=A=>{try{T($.next(A))}catch(R){V(R)}},ee=A=>{try{T($.throw(A))}catch(R){V(R)}},T=A=>A.done?K(A.value):Promise.resolve(A.value).then(Y,ee);T(($=$.apply(S,k)).next())});const k=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",$="1",K="2";var V=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(V||{});const Y="00000001";function ee(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var T={},A;function R(){if(A)return T;A=1,T.byteLength=u,T.toByteArray=d,T.fromByteArray=p;for(var n=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,o=s.length;r<o;++r)n[r]=s[r],e[s.charCodeAt(r)]=r;e[45]=62,e[95]=63;function a(h){var c=h.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=h.indexOf("=");f===-1&&(f=c);var w=f===c?0:4-f%4;return[f,w]}function u(h){var c=a(h),f=c[0],w=c[1];return(f+w)*3/4-w}function y(h,c,f){return(c+f)*3/4-f}function d(h){var c,f=a(h),w=f[0],m=f[1],v=new t(y(h,w,m)),D=0,M=m>0?w-4:w,b;for(b=0;b<M;b+=4)c=e[h.charCodeAt(b)]<<18|e[h.charCodeAt(b+1)]<<12|e[h.charCodeAt(b+2)]<<6|e[h.charCodeAt(b+3)],v[D++]=c>>16&255,v[D++]=c>>8&255,v[D++]=c&255;return m===2&&(c=e[h.charCodeAt(b)]<<2|e[h.charCodeAt(b+1)]>>4,v[D++]=c&255),m===1&&(c=e[h.charCodeAt(b)]<<10|e[h.charCodeAt(b+1)]<<4|e[h.charCodeAt(b+2)]>>2,v[D++]=c>>8&255,v[D++]=c&255),v}function g(h){return n[h>>18&63]+n[h>>12&63]+n[h>>6&63]+n[h&63]}function C(h,c,f){for(var w,m=[],v=c;v<f;v+=3)w=(h[v]<<16&16711680)+(h[v+1]<<8&65280)+(h[v+2]&255),m.push(g(w));return m.join("")}function p(h){for(var c,f=h.length,w=f%3,m=[],v=16383,D=0,M=f-w;D<M;D+=v)m.push(C(h,D,D+v>M?M:D+v));return w===1?(c=h[f-1],m.push(n[c>>2]+n[c<<4&63]+"==")):w===2&&(c=(h[f-2]<<8)+h[f-1],m.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),m.join("")}return T}var 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 o=[],a=Math.max(e.dirty.length,r.length);for(let u=0;u<a;u+=1)o[u]=e.dirty[u]|r[u];return o}return e.dirty|r}return e.dirty}function Ge(n,e,t,s,r,o){if(r){const a=fe(e,t,s,o);n.p(a,r)}}function Fe(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let s=0;s<t;s++)e[s]=-1;return e}return-1}function ge(n){return n!=null?n:""}function x(n,e){n.appendChild(e)}function ne(n,e,t){n.insertBefore(e,t||null)}function Q(n){n.parentNode&&n.parentNode.removeChild(n)}function je(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function _(n){return document.createElement(n)}function L(n){return document.createTextNode(n)}function W(){return L(" ")}function Ne(){return L("")}function z(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function E(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Oe(n){return Array.from(n.childNodes)}function G(n,e){e=""+e,n.data!==e&&(n.data=e)}function pe(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let se;function q(n){se=n}const F=[],me=[];let j=[];const Ce=[],Ze=Promise.resolve();let re=!1;function Ve(){re||(re=!0,Ze.then(ve))}function oe(n){j.push(n)}const ae=new Set;let N=0;function ve(){if(N!==0)return;const n=se;do{try{for(;N<F.length;){const e=F[N];N++,q(e),Re(e.$$)}}catch(e){throw F.length=0,N=0,e}for(q(null),F.length=0,N=0;me.length;)me.pop()();for(let e=0;e<j.length;e+=1){const t=j[e];ae.has(t)||(ae.add(t),t())}j.length=0}while(F.length);for(;Ce.length;)Ce.pop()();re=!1,ae.clear(),q(n)}function Re(n){if(n.fragment!==null){n.update(),U(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(oe)}}function Ue(n){const e=[],t=[];j.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),j=e}const X=new Set;let Je;function ie(n,e){n&&n.i&&(X.delete(n),n.i(e))}function we(n,e,t,s){if(n&&n.o){if(X.has(n))return;X.add(n),Je.c.push(()=>{X.delete(n)}),n.o(e)}}function ke(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function We(n){n&&n.c()}function be(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),oe(()=>{const o=n.$$.on_mount.map(de).filter(J);n.$$.on_destroy?n.$$.on_destroy.push(...o):U(o),n.$$.on_mount=[]}),r.forEach(oe)}function De(n,e){const t=n.$$;t.fragment!==null&&(Ue(t.after_update),U(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ze(n,e){n.$$.dirty[0]===-1&&(F.push(n),Ve(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Se(n,e,t,s,r,o,a=null,u=[-1]){const y=se;q(n);const d=n.$$={fragment:null,ctx:[],props:o,update:te,not_equal:r,bound:he(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(y?y.$$.context:[])),callbacks:he(),dirty:u,skip_bound:!1,root:e.target||y.$$.root};a&&a(d.root);let g=!1;if(d.ctx=t?t(n,e.props||{},(C,p,...h)=>{const c=h.length?h[0]:p;return d.ctx&&r(d.ctx[C],d.ctx[C]=c)&&(!d.skip_bound&&d.bound[C]&&d.bound[C](c),g&&ze(n,C)),p}):[],d.update(),g=!0,U(d.before_update),d.fragment=s?s(d.ctx):!1,e.target){if(e.hydrate){const C=Oe(e.target);d.fragment&&d.fragment.l(C),C.forEach(Q)}else d.fragment&&d.fragment.c();e.intro&&ie(n.$$.fragment),be(n,e.target,e.anchor),ve()}q(y)}class xe{constructor(){ue(this,"$$"),ue(this,"$$set")}$destroy(){De(this,1),this.$destroy=te}$on(e,t){if(!J(t))return te;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Te(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const qe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(qe);function Ke(n){let e,t,s,r=(n[1]||"标题")+"",o,a,u,y,d,g,C=(n[4]||"取消")+"",p,h,c,f=(n[5]||"确认")+"",w,m,v,D;const M=n[8].default,b=Me(M,n,n[7],null);return{c(){e=_("div"),t=_("div"),s=_("div"),o=L(r),a=W(),u=_("div"),b&&b.c(),y=W(),d=_("div"),g=_("button"),p=L(C),h=W(),c=_("button"),w=L(f),E(s,"class","model-title svelte-oivou"),E(u,"class","slot svelte-oivou"),E(g,"class","modal-btn svelte-oivou"),E(c,"class","modal-btn success svelte-oivou"),pe(c,"background-color",n[6]),E(d,"class","modal-footer svelte-oivou"),E(t,"class","modal-content svelte-oivou"),E(e,"class","modal-background modal-visible svelte-oivou")},m(P,H){ne(P,e,H),x(e,t),x(t,s),x(s,o),x(t,a),x(t,u),b&&b.m(u,null),x(t,y),x(t,d),x(d,g),x(g,p),x(d,h),x(d,c),x(c,w),m=!0,v||(D=[z(g,"click",function(){J(n[0])&&n[0].apply(this,arguments)}),z(c,"click",function(){J(n[2])&&n[2].apply(this,arguments)}),z(t,"click",Qe),z(e,"click",function(){J(n[3])&&n[3].apply(this,arguments)})],v=!0)},p(P,[H]){n=P,(!m||H&2)&&r!==(r=(n[1]||"标题")+"")&&G(o,r),b&&b.p&&(!m||H&128)&&Ge(b,M,n,n[7],m?He(M,n[7],H,null):Fe(n[7]),null),(!m||H&16)&&C!==(C=(n[4]||"取消")+"")&&G(p,C),(!m||H&32)&&f!==(f=(n[5]||"确认")+"")&&G(w,f),(!m||H&64)&&pe(c,"background-color",n[6])},i(P){m||(ie(b,P),m=!0)},o(P){we(b,P),m=!1},d(P){P&&Q(e),b&&b.d(P),v=!1,U(D)}}}const Qe=n=>n.stopPropagation();function Xe(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:o}=e,{title:a}=e,{onOk:u}=e,{onClose:y}=e,{cancelText:d}=e,{okText:g}=e,{theme:C}=e;return n.$$set=p=>{"onCancel"in p&&t(0,o=p.onCancel),"title"in p&&t(1,a=p.title),"onOk"in p&&t(2,u=p.onOk),"onClose"in p&&t(3,y=p.onClose),"cancelText"in p&&t(4,d=p.cancelText),"okText"in p&&t(5,g=p.okText),"theme"in p&&t(6,C=p.theme),"$$scope"in p&&t(7,r=p.$$scope)},[o,a,u,y,d,g,C,r,s]}class Ye extends xe{constructor(e){super(),Se(this,e,Xe,Ke,ye,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function Be(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function $e(n){let e,t,s=n[11].CN+"",r,o,a,u=n[11].DevClass+"",y,d,g=n[11].sn+"",C,p,h,c,f,w;function m(){return n[10](n[13])}return{c(){e=_("div"),t=_("span"),r=L(s),o=W(),a=_("span"),y=L(u),d=L("("),C=L(g),p=L(")"),h=W(),E(t,"class","svelte-jtc2v4"),E(a,"class","svelte-jtc2v4"),E(e,"class",c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(v,D){ne(v,e,D),x(e,t),x(t,r),x(e,o),x(e,a),x(a,y),x(a,d),x(a,C),x(a,p),x(e,h),f||(w=z(e,"click",m),f=!0)},p(v,D){n=v,D&1&&s!==(s=n[11].CN+"")&&G(r,s),D&1&&u!==(u=n[11].DevClass+"")&&G(y,u),D&1&&g!==(g=n[11].sn+"")&&G(C,g),D&32&&c!==(c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&E(e,"class",c)},d(v){v&&Q(e),f=!1,w()}}}function et(n){let e,t=ke(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=$e(Be(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Ne()},m(r,o){for(let a=0;a<s.length;a+=1)s[a]&&s[a].m(r,o);ne(r,e,o)},p(r,o){if(o&33){t=ke(r[0]);let a;for(a=0;a<t.length;a+=1){const u=Be(r,t,a);s[a]?s[a].p(u,o):(s[a]=$e(u),s[a].c(),s[a].m(e.parentNode,e))}for(;a<s.length;a+=1)s[a].d(1);s.length=t.length}},d(r){r&&Q(e),je(s,r)}}}function tt(n){let e,t;return e=new Ye({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[et]},$$scope:{ctx:n}}}),{c(){We(e.$$.fragment)},m(s,r){be(e,s,r),t=!0},p(s,[r]){const o={};r&2&&(o.onClose=s[1]),r&4&&(o.cancelText=s[2]),r&8&&(o.okText=s[3]),r&16&&(o.theme=s[4]),r&16417&&(o.$$scope={dirty:r,ctx:s}),e.$set(o)},i(s){t||(ie(e.$$.fragment,s),t=!0)},o(s){we(e.$$.fragment,s),t=!1},d(s){De(e,s)}}}function nt(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:o}=e,{onClose:a}=e,{cancelText:u=""}=e,{okText:y=""}=e,{theme:d="#409eff"}=e,g=0;const C=()=>{r("未选择证书"),a==null||a()},p=()=>{o==null||o(s[g]),a==null||a()},h=c=>t(5,g=c);return n.$$set=c=>{"certList"in c&&t(0,s=c.certList),"onCancel"in c&&t(8,r=c.onCancel),"onOk"in c&&t(9,o=c.onOk),"onClose"in c&&t(1,a=c.onClose),"cancelText"in c&&t(2,u=c.cancelText),"okText"in c&&t(3,y=c.okText),"theme"in c&&t(4,d=c.theme)},[s,a,u,y,d,g,C,p,r,o,h]}class st extends xe{constructor(e){super(),Se(this,e,nt,tt,ye,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class rt{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new st({target:document.body,props:I(B({},e),{onCancel:r=>{s({code:-1,msg:r})},onOk:r=>{t(r)},onClose:()=>{this.close()}})})}));i(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const ot=new rt;class at{constructor(e){i(this,"socketInstance",null);i(this,"eventBus",new Ae);i(this,"isRememberPin",!1);i(this,"pinPolicy");i(this,"socketConfig",null);i(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});i(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});i(this,"sendMessage",(e,t)=>new Promise((s,r)=>{var a,u;if(((a=this.socketInstance)==null?void 0:a.readyState)!==WebSocket.OPEN){r({errCode:-1,msg:"socket未连接"});return}const o={function:e,args:[t!=null?t:{}]};(u=this.socketInstance)==null||u.send(JSON.stringify(o)),this.eventBus.on(e,y=>{y.success?s(y.data):r(y)})}));i(this,"handleEventData",e=>l(this,null,function*(){var t,s,r,o,a,u,y,d,g,C;if(e.data instanceof Blob){const p=yield e.data.arrayBuffer(),c=new TextDecoder("gbk").decode(p),f=JSON.parse(c),w={success:(t=f.result)==null?void 0:t.success,msg:(s=f.result)==null?void 0:s.msg,errCode:(r=f.result)==null?void 0:r.errCode,data:f.data},m=(o=f.result)==null?void 0:o.function;m==="GZCA_OnDeviceChange"?(d=(a=this.socketConfig)==null?void 0:a.onUkeyEvent)==null||d.call(a,I(B({},w),{type:(u=f.result)==null?void 0:u.event,data:(y=f.data)==null?void 0:y[0]})):this.eventBus.emit(m,w),(C=(g=this.socketConfig)==null?void 0:g.onMessage)==null||C.call(g,w)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return le.fromByteArray(t)});i(this,"base64Decode",e=>{const t=le.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>l(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>l(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:Y})}));i(this,"certLogin",e=>l(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));i(this,"getCert",(e,t)=>l(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&(yield this.certLogin(s.ContainerName)),s}));i(this,"chooseCert",e=>l(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield ot.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"getCertList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"pkcs1Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",B({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));var t,s;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(s=e.pinPolicy)!=null?s:V.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=s=>{var r;(r=e.onError)==null||r.call(e,s)},t.onopen=s=>{var r;(r=e.onOpen)==null||r.call(e,s),e.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 at(I(B({},e!=null?e:{}),{url:k}))});i(this,"appendCertBase64",(e,t=!0)=>l(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return I(B({},e!=null?e:{}),{CertB64:s==null?void 0:s.CertB64})}));i(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});i(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});i(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});i(this,"getSignatureCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:$},e)}));i(this,"getSignatureCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:$})}));i(this,"getEncryptionCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:K},e)}));i(this,"getEncryptionCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:K})}));i(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});i(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});i(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});i(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});i(this,"pkcs1Sign",(e,t)=>l(this,null,function*(){var o,a,u;const s=yield this.getSignatureCert(t),r=yield(a=this.coreInstance)==null?void 0:a.pkcs1Sign(I(B({},e!=null?e:{}),{ContainerName:(o=s==null?void 0:s.ContainerName)!=null?o:""}));return(u=r==null?void 0:r[0])==null?void 0:u.SignData}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){var r;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(s)}));i(this,"pkcs1Base64Sign",(e,t)=>l(this,null,function*(){var a,u,y,d,g;const s=yield this.getSignatureCert(t),r=(u=e.DataB64)!=null?u:this.base64Encode({Data:(a=e.Data)!=null?a:""}),o=yield(d=this.coreInstance)==null?void 0:d.pkcs1Base64Sign(I(B({},e!=null?e:{}),{ContainerName:(y=s==null?void 0:s.ContainerName)!=null?y:"",DataB64:r}));return(g=o==null?void 0:o[0])==null?void 0:g.SignData}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){var o,a,u;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.appendCertBase64(e);return!!(yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",e=>l(this,null,function*(){var r,o;const t=yield this.getSignatureCert(e),s=yield(o=this.coreInstance)==null?void 0:o.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:""});return{cert:t,sealList:s}}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(o=s==null?void 0:s[0])==null?void 0:o.Z}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){var o,a;const t=this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.appendCertBase64(e),r=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:t});return r==null?void 0:r[0].H}));i(this,"pkcs1HashSign",(e,t)=>l(this,null,function*(){var o,a,u,y;const s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1HashSign({ContainerName:(o=s==null?void 0:s.ContainerName)!=null?o:"",DataB64:e.DataB64,HashAlg:(a=e.HashAlg)!=null?a:"sm3"});return(y=r==null?void 0:r[0])==null?void 0:y.SignData}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e);return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs1HashVerifySignature(I(B({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var a,u,y,d,g;const s=(u=e.DataB64)!=null?u:this.base64Encode({Data:(a=e.Data)!=null?a:""}),r=yield this.getSignatureCert(t),o=yield(d=this.coreInstance)==null?void 0:d.pkcs7Sign(I(B({},e!=null?e:{}),{ContainerName:(y=r==null?void 0:r.ContainerName)!=null?y:"",DataB64:s}));return(g=o==null?void 0:o[0])==null?void 0:g.SignData}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){var r,o,a;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));i(this,"sm3Hash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HexHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3FileHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){var o,a,u,y,d,g;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=(y=e.KeyB64)!=null?y:this.base64Encode({Data:(u=e.Key)!=null?u:""}),r=yield(d=this.coreInstance)==null?void 0:d.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(g=r==null?void 0:r[0])==null?void 0:g.DataB64}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){var r,o,a,u;if(!e.CertB64List){const y=yield this.getEncryptionCert();e.CertB64List=y==null?void 0:y.CertB64}const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),s=yield(a=this.coreInstance)==null?void 0:a.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(u=s==null?void 0:s[0])==null?void 0:u.DataB64}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){var o,a;const t=yield this.getEncryptionCert(),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Decryption(I(B({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),r=(a=s==null?void 0:s[0])==null?void 0:a.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:r}):r}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e,!1),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(o=s==null?void 0:s[0])==null?void 0:o.Data}));i(this,"asymmetricDecryption",(e,t)=>l(this,null,function*(){var o,a;const s=yield this.getEncryptionCert(t),r=yield(o=this.coreInstance)==null?void 0:o.asymmetricDecryption(I(B({},e!=null?e:{}),{ContainerName:s==null?void 0:s.ContainerName}));return(a=r==null?void 0:r[0])==null?void 0:a.Data}));i(this,"sm4Encryption",e=>l(this,null,function*(){var s;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(e);return t==null?void 0:t[0]}));i(this,"sm4Decryption",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(e);return(r=t==null?void 0:t[0])==null?void 0:r.Data}));i(this,"getCertInfo",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e);return B({},(r=t==null?void 0:t[0])!=null?r:{})}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid(B({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return Z.instance&&!(e!=null&&e.isCreateNew)?Z.instance:(this.createGwsCore(e),Z.instance=this,this)}};i(Z,"instance",null);let O=Z;function it(n){return new Promise((e,t)=>{if(O.instance&&!(n!=null&&n.isCreateNew))e(O.instance);else{const s=new O(I(B({},n!=null?n:{}),{onOpen(r){var o;e(s),(o=n==null?void 0:n.onOpen)==null||o.call(n,r)},onClose(r){var o;t(r),(o=n==null?void 0:n.onClose)==null||o.call(n,r)}}))}})}S.GwsService=O,S.createService=it,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
1
+ (function(S,k){typeof exports=="object"&&typeof module!="undefined"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(S=typeof globalThis!="undefined"?globalThis:S||self,k(S.GWS_CLIENT={}))})(this,function(S){"use strict";var ct=Object.defineProperty,lt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var Ie=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ce=(S,k,$)=>k in S?ct(S,k,{enumerable:!0,configurable:!0,writable:!0,value:$}):S[k]=$,B=(S,k)=>{for(var $ in k||(k={}))dt.call(k,$)&&ce(S,$,k[$]);if(Ie)for(var $ of Ie(k))ht.call(k,$)&&ce(S,$,k[$]);return S},I=(S,k)=>lt(S,ut(k));var i=(S,k,$)=>ce(S,typeof k!="symbol"?k+"":k,$);var l=(S,k,$)=>new Promise((K,V)=>{var Y=E=>{try{T($.next(E))}catch(R){V(R)}},ee=E=>{try{T($.throw(E))}catch(R){V(R)}},T=E=>E.done?K(E.value):Promise.resolve(E.value).then(Y,ee);T(($=$.apply(S,k)).next())});const k=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",$="1",K="2";var V=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(V||{});const Y="00000001";function ee(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var T={},E;function R(){if(E)return T;E=1,T.byteLength=u,T.toByteArray=d,T.fromByteArray=p;for(var n=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,o=s.length;r<o;++r)n[r]=s[r],e[s.charCodeAt(r)]=r;e[45]=62,e[95]=63;function a(h){var c=h.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=h.indexOf("=");f===-1&&(f=c);var w=f===c?0:4-f%4;return[f,w]}function u(h){var c=a(h),f=c[0],w=c[1];return(f+w)*3/4-w}function y(h,c,f){return(c+f)*3/4-f}function d(h){var c,f=a(h),w=f[0],m=f[1],v=new t(y(h,w,m)),D=0,M=m>0?w-4:w,b;for(b=0;b<M;b+=4)c=e[h.charCodeAt(b)]<<18|e[h.charCodeAt(b+1)]<<12|e[h.charCodeAt(b+2)]<<6|e[h.charCodeAt(b+3)],v[D++]=c>>16&255,v[D++]=c>>8&255,v[D++]=c&255;return m===2&&(c=e[h.charCodeAt(b)]<<2|e[h.charCodeAt(b+1)]>>4,v[D++]=c&255),m===1&&(c=e[h.charCodeAt(b)]<<10|e[h.charCodeAt(b+1)]<<4|e[h.charCodeAt(b+2)]>>2,v[D++]=c>>8&255,v[D++]=c&255),v}function g(h){return n[h>>18&63]+n[h>>12&63]+n[h>>6&63]+n[h&63]}function C(h,c,f){for(var w,m=[],v=c;v<f;v+=3)w=(h[v]<<16&16711680)+(h[v+1]<<8&65280)+(h[v+2]&255),m.push(g(w));return m.join("")}function p(h){for(var c,f=h.length,w=f%3,m=[],v=16383,D=0,M=f-w;D<M;D+=v)m.push(C(h,D,D+v>M?M:D+v));return w===1?(c=h[f-1],m.push(n[c>>2]+n[c<<4&63]+"==")):w===2&&(c=(h[f-2]<<8)+h[f-1],m.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),m.join("")}return T}var Ae=R();const le=ee(Ae);class Ee{constructor(){i(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const s=this.deps.get(e);s&&s(t)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-oivou{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-oivou{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-oivou{background-color:#fff;padding:1.42857rem;border-radius:.35714rem;width:40%}.model-title.svelte-oivou{color:#303133;font-size:1.28571rem;margin-bottom:1.14286rem}.modal-visible.svelte-oivou{display:flex}.modal-footer.svelte-oivou{display:flex;align-items:center;justify-content:flex-end;margin-top:1.14286rem}.modal-btn.svelte-oivou{padding:.57143rem 1.07143rem;border-radius:.28571rem;font-size:1rem;border:.07143rem solid #dcdfe6}.success.svelte-oivou{margin-left:.85714rem;color:#fff}.slot.svelte-oivou{max-height:14.28571rem;overflow-y:scroll}.slot.svelte-oivou::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:1.14286rem;display:flex;align-items:center;cursor:pointer;border-bottom:.07143rem solid #ebeef5;font-size:1rem}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:.07143rem solid #ebeef5}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4{display:inline-block;color:#606266}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4:first-child{width:30%}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:12.85714rem;height:12.85714rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.07143rem solid #ccc;margin-top:.71429rem;margin-right:.71429rem;border-radius:.28571rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:7.14286rem;height:7.14286rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.71429rem;color:#333}")),document.head.appendChild(n)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var _e=Object.defineProperty,Le=(n,e,t)=>e in n?_e(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ue=(n,e,t)=>Le(n,typeof e!="symbol"?e+"":e,t);function te(){}function Pe(n,e){for(const t in e)n[t]=e[t];return n}function de(n){return n()}function he(){return Object.create(null)}function U(n){n.forEach(de)}function J(n){return typeof n=="function"}function ye(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Te(n){return Object.keys(n).length===0}function Me(n,e,t,s){if(n){const r=fe(n,e,t,s);return n[0](r)}}function fe(n,e,t,s){return n[1]&&s?Pe(t.ctx.slice(),n[1](s(e))):t.ctx}function He(n,e,t,s){if(n[2]&&s){const r=n[2](s(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const o=[],a=Math.max(e.dirty.length,r.length);for(let u=0;u<a;u+=1)o[u]=e.dirty[u]|r[u];return o}return e.dirty|r}return e.dirty}function Ge(n,e,t,s,r,o){if(r){const a=fe(e,t,s,o);n.p(a,r)}}function Fe(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let s=0;s<t;s++)e[s]=-1;return e}return-1}function ge(n){return n!=null?n:""}function x(n,e){n.appendChild(e)}function ne(n,e,t){n.insertBefore(e,t||null)}function Q(n){n.parentNode&&n.parentNode.removeChild(n)}function je(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function _(n){return document.createElement(n)}function L(n){return document.createTextNode(n)}function W(){return L(" ")}function Ne(){return L("")}function z(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function A(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Oe(n){return Array.from(n.childNodes)}function G(n,e){e=""+e,n.data!==e&&(n.data=e)}function pe(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let se;function q(n){se=n}const F=[],me=[];let j=[];const Ce=[],Ze=Promise.resolve();let re=!1;function Ve(){re||(re=!0,Ze.then(ve))}function oe(n){j.push(n)}const ae=new Set;let N=0;function ve(){if(N!==0)return;const n=se;do{try{for(;N<F.length;){const e=F[N];N++,q(e),Re(e.$$)}}catch(e){throw F.length=0,N=0,e}for(q(null),F.length=0,N=0;me.length;)me.pop()();for(let e=0;e<j.length;e+=1){const t=j[e];ae.has(t)||(ae.add(t),t())}j.length=0}while(F.length);for(;Ce.length;)Ce.pop()();re=!1,ae.clear(),q(n)}function Re(n){if(n.fragment!==null){n.update(),U(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(oe)}}function Ue(n){const e=[],t=[];j.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),j=e}const X=new Set;let Je;function ie(n,e){n&&n.i&&(X.delete(n),n.i(e))}function we(n,e,t,s){if(n&&n.o){if(X.has(n))return;X.add(n),Je.c.push(()=>{X.delete(n)}),n.o(e)}}function ke(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function We(n){n&&n.c()}function be(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),oe(()=>{const o=n.$$.on_mount.map(de).filter(J);n.$$.on_destroy?n.$$.on_destroy.push(...o):U(o),n.$$.on_mount=[]}),r.forEach(oe)}function De(n,e){const t=n.$$;t.fragment!==null&&(Ue(t.after_update),U(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function ze(n,e){n.$$.dirty[0]===-1&&(F.push(n),Ve(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function Se(n,e,t,s,r,o,a=null,u=[-1]){const y=se;q(n);const d=n.$$={fragment:null,ctx:[],props:o,update:te,not_equal:r,bound:he(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(y?y.$$.context:[])),callbacks:he(),dirty:u,skip_bound:!1,root:e.target||y.$$.root};a&&a(d.root);let g=!1;if(d.ctx=t?t(n,e.props||{},(C,p,...h)=>{const c=h.length?h[0]:p;return d.ctx&&r(d.ctx[C],d.ctx[C]=c)&&(!d.skip_bound&&d.bound[C]&&d.bound[C](c),g&&ze(n,C)),p}):[],d.update(),g=!0,U(d.before_update),d.fragment=s?s(d.ctx):!1,e.target){if(e.hydrate){const C=Oe(e.target);d.fragment&&d.fragment.l(C),C.forEach(Q)}else d.fragment&&d.fragment.c();e.intro&&ie(n.$$.fragment),be(n,e.target,e.anchor),ve()}q(y)}class xe{constructor(){ue(this,"$$"),ue(this,"$$set")}$destroy(){De(this,1),this.$destroy=te}$on(e,t){if(!J(t))return te;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Te(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const qe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(qe);function Ke(n){let e,t,s,r=(n[1]||"标题")+"",o,a,u,y,d,g,C=(n[4]||"取消")+"",p,h,c,f=(n[5]||"确认")+"",w,m,v,D;const M=n[8].default,b=Me(M,n,n[7],null);return{c(){e=_("div"),t=_("div"),s=_("div"),o=L(r),a=W(),u=_("div"),b&&b.c(),y=W(),d=_("div"),g=_("button"),p=L(C),h=W(),c=_("button"),w=L(f),A(s,"class","model-title svelte-oivou"),A(u,"class","slot svelte-oivou"),A(g,"class","modal-btn svelte-oivou"),A(c,"class","modal-btn success svelte-oivou"),pe(c,"background-color",n[6]),A(d,"class","modal-footer svelte-oivou"),A(t,"class","modal-content svelte-oivou"),A(e,"class","modal-background modal-visible svelte-oivou")},m(P,H){ne(P,e,H),x(e,t),x(t,s),x(s,o),x(t,a),x(t,u),b&&b.m(u,null),x(t,y),x(t,d),x(d,g),x(g,p),x(d,h),x(d,c),x(c,w),m=!0,v||(D=[z(g,"click",function(){J(n[0])&&n[0].apply(this,arguments)}),z(c,"click",function(){J(n[2])&&n[2].apply(this,arguments)}),z(t,"click",Qe),z(e,"click",function(){J(n[3])&&n[3].apply(this,arguments)})],v=!0)},p(P,[H]){n=P,(!m||H&2)&&r!==(r=(n[1]||"标题")+"")&&G(o,r),b&&b.p&&(!m||H&128)&&Ge(b,M,n,n[7],m?He(M,n[7],H,null):Fe(n[7]),null),(!m||H&16)&&C!==(C=(n[4]||"取消")+"")&&G(p,C),(!m||H&32)&&f!==(f=(n[5]||"确认")+"")&&G(w,f),(!m||H&64)&&pe(c,"background-color",n[6])},i(P){m||(ie(b,P),m=!0)},o(P){we(b,P),m=!1},d(P){P&&Q(e),b&&b.d(P),v=!1,U(D)}}}const Qe=n=>n.stopPropagation();function Xe(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:o}=e,{title:a}=e,{onOk:u}=e,{onClose:y}=e,{cancelText:d}=e,{okText:g}=e,{theme:C}=e;return n.$$set=p=>{"onCancel"in p&&t(0,o=p.onCancel),"title"in p&&t(1,a=p.title),"onOk"in p&&t(2,u=p.onOk),"onClose"in p&&t(3,y=p.onClose),"cancelText"in p&&t(4,d=p.cancelText),"okText"in p&&t(5,g=p.okText),"theme"in p&&t(6,C=p.theme),"$$scope"in p&&t(7,r=p.$$scope)},[o,a,u,y,d,g,C,r,s]}class Ye extends xe{constructor(e){super(),Se(this,e,Xe,Ke,ye,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function Be(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function $e(n){let e,t,s=n[11].CN+"",r,o,a,u=n[11].DevClass+"",y,d,g=n[11].sn+"",C,p,h,c,f,w;function m(){return n[10](n[13])}return{c(){e=_("div"),t=_("span"),r=L(s),o=W(),a=_("span"),y=L(u),d=L("("),C=L(g),p=L(")"),h=W(),A(t,"class","svelte-jtc2v4"),A(a,"class","svelte-jtc2v4"),A(e,"class",c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(v,D){ne(v,e,D),x(e,t),x(t,r),x(e,o),x(e,a),x(a,y),x(a,d),x(a,C),x(a,p),x(e,h),f||(w=z(e,"click",m),f=!0)},p(v,D){n=v,D&1&&s!==(s=n[11].CN+"")&&G(r,s),D&1&&u!==(u=n[11].DevClass+"")&&G(y,u),D&1&&g!==(g=n[11].sn+"")&&G(C,g),D&32&&c!==(c=ge(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&A(e,"class",c)},d(v){v&&Q(e),f=!1,w()}}}function et(n){let e,t=ke(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=$e(Be(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Ne()},m(r,o){for(let a=0;a<s.length;a+=1)s[a]&&s[a].m(r,o);ne(r,e,o)},p(r,o){if(o&33){t=ke(r[0]);let a;for(a=0;a<t.length;a+=1){const u=Be(r,t,a);s[a]?s[a].p(u,o):(s[a]=$e(u),s[a].c(),s[a].m(e.parentNode,e))}for(;a<s.length;a+=1)s[a].d(1);s.length=t.length}},d(r){r&&Q(e),je(s,r)}}}function tt(n){let e,t;return e=new Ye({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[et]},$$scope:{ctx:n}}}),{c(){We(e.$$.fragment)},m(s,r){be(e,s,r),t=!0},p(s,[r]){const o={};r&2&&(o.onClose=s[1]),r&4&&(o.cancelText=s[2]),r&8&&(o.okText=s[3]),r&16&&(o.theme=s[4]),r&16417&&(o.$$scope={dirty:r,ctx:s}),e.$set(o)},i(s){t||(ie(e.$$.fragment,s),t=!0)},o(s){we(e.$$.fragment,s),t=!1},d(s){De(e,s)}}}function nt(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:o}=e,{onClose:a}=e,{cancelText:u=""}=e,{okText:y=""}=e,{theme:d="#409eff"}=e,g=0;const C=()=>{r("未选择证书"),a==null||a()},p=()=>{o==null||o(s[g]),a==null||a()},h=c=>t(5,g=c);return n.$$set=c=>{"certList"in c&&t(0,s=c.certList),"onCancel"in c&&t(8,r=c.onCancel),"onOk"in c&&t(9,o=c.onOk),"onClose"in c&&t(1,a=c.onClose),"cancelText"in c&&t(2,u=c.cancelText),"okText"in c&&t(3,y=c.okText),"theme"in c&&t(4,d=c.theme)},[s,a,u,y,d,g,C,p,r,o,h]}class st extends xe{constructor(e){super(),Se(this,e,nt,tt,ye,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class rt{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new st({target:document.body,props:I(B({},e),{onCancel:r=>{s({code:-1,msg:r})},onOk:r=>{t(r)},onClose:()=>{this.close()}})})}));i(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const ot=new rt;class at{constructor(e){i(this,"socketInstance",null);i(this,"eventBus",new Ee);i(this,"isRememberPin",!1);i(this,"pinPolicy");i(this,"socketConfig",null);i(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});i(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});i(this,"sendMessage",(e,t)=>new Promise((s,r)=>{var a,u;if(((a=this.socketInstance)==null?void 0:a.readyState)!==WebSocket.OPEN){r({errCode:-1,msg:"socket未连接"});return}const o={function:e,args:[t!=null?t:{}]};(u=this.socketInstance)==null||u.send(JSON.stringify(o)),this.eventBus.on(e,y=>{y.success?s(y.data):r(y)})}));i(this,"handleEventData",e=>l(this,null,function*(){var t,s,r,o,a,u,y,d,g,C;if(e.data instanceof Blob){const p=yield e.data.arrayBuffer(),c=new TextDecoder("gbk").decode(p),f=JSON.parse(c),w={success:(t=f.result)==null?void 0:t.success,msg:(s=f.result)==null?void 0:s.msg,errCode:(r=f.result)==null?void 0:r.errCode,data:f.data},m=(o=f.result)==null?void 0:o.function;m==="GZCA_OnDeviceChange"?(d=(a=this.socketConfig)==null?void 0:a.onUkeyChange)==null||d.call(a,I(B({},w),{type:(u=f.result)==null?void 0:u.event,data:(y=f.data)==null?void 0:y[0]})):this.eventBus.emit(m,w),(C=(g=this.socketConfig)==null?void 0:g.onMessage)==null||C.call(g,w)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return le.fromByteArray(t)});i(this,"base64Decode",e=>{const t=le.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>l(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>l(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:Y})}));i(this,"certLogin",e=>l(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));i(this,"getCert",(e,t)=>l(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&(yield this.certLogin(s.ContainerName)),s}));i(this,"chooseCert",e=>l(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield ot.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"getCertList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"pkcs1Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",B({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));var t,s;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(s=e.pinPolicy)!=null?s:V.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=s=>{var r;(r=e.onError)==null||r.call(e,s)},t.onopen=s=>{var r;(r=e.onOpen)==null||r.call(e,s),e.onUkeyChange&&this.addUkeyEvents()},t.onmessage=s=>{this.handleEventData(s)},t.onclose=s=>{var r;(r=e.onClose)==null||r.call(e,s)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const Z=class Z{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new at(I(B({},e!=null?e:{}),{url:k}))});i(this,"appendCertBase64",(e,t=!0)=>l(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return I(B({},e!=null?e:{}),{CertB64:s==null?void 0:s.CertB64})}));i(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});i(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});i(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});i(this,"getSignatureCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:$},e)}));i(this,"getSignatureCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:$})}));i(this,"getEncryptionCert",e=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:K},e)}));i(this,"getEncryptionCertList",()=>l(this,null,function*(){var t;return yield(t=this.coreInstance)==null?void 0:t.getCertList({CertType:K})}));i(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});i(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});i(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});i(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});i(this,"pkcs1Sign",(e,t)=>l(this,null,function*(){var o,a,u;const s=yield this.getSignatureCert(t),r=yield(a=this.coreInstance)==null?void 0:a.pkcs1Sign(I(B({},e!=null?e:{}),{ContainerName:(o=s==null?void 0:s.ContainerName)!=null?o:""}));return(u=r==null?void 0:r[0])==null?void 0:u.SignData}));i(this,"pkcs1VerifySignature",e=>l(this,null,function*(){var r;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(s)}));i(this,"pkcs1Base64Sign",(e,t)=>l(this,null,function*(){var a,u,y,d,g;const s=yield this.getSignatureCert(t),r=(u=e.DataB64)!=null?u:this.base64Encode({Data:(a=e.Data)!=null?a:""}),o=yield(d=this.coreInstance)==null?void 0:d.pkcs1Base64Sign(I(B({},e!=null?e:{}),{ContainerName:(y=s==null?void 0:s.ContainerName)!=null?y:"",DataB64:r}));return(g=o==null?void 0:o[0])==null?void 0:g.SignData}));i(this,"pkcs1Base64VerifySignature",e=>l(this,null,function*(){var o,a,u;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.appendCertBase64(e);return!!(yield(u=this.coreInstance)==null?void 0:u.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",e=>l(this,null,function*(){var r,o;const t=yield this.getSignatureCert(e),s=yield(o=this.coreInstance)==null?void 0:o.getSealList({ContainerName:(r=t==null?void 0:t.ContainerName)!=null?r:""});return{cert:t,sealList:s}}));i(this,"sm2SignPreprocess1",e=>l(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(o=s==null?void 0:s[0])==null?void 0:o.Z}));i(this,"sm2SignPreprocess2",e=>l(this,null,function*(){var o,a;const t=this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.appendCertBase64(e),r=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:t});return r==null?void 0:r[0].H}));i(this,"pkcs1HashSign",(e,t)=>l(this,null,function*(){var o,a,u,y;const s=yield this.getSignatureCert(t),r=yield(u=this.coreInstance)==null?void 0:u.pkcs1HashSign({ContainerName:(o=s==null?void 0:s.ContainerName)!=null?o:"",DataB64:e.DataB64,HashAlg:(a=e.HashAlg)!=null?a:"sm3"});return(y=r==null?void 0:r[0])==null?void 0:y.SignData}));i(this,"pkcs1HashVerifySignature",e=>l(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e);return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs1HashVerifySignature(I(B({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>l(this,null,function*(){var a,u,y,d,g;const s=(u=e.DataB64)!=null?u:this.base64Encode({Data:(a=e.Data)!=null?a:""}),r=yield this.getSignatureCert(t),o=yield(d=this.coreInstance)==null?void 0:d.pkcs7Sign(I(B({},e!=null?e:{}),{ContainerName:(y=r==null?void 0:r.ContainerName)!=null?y:"",DataB64:s}));return(g=o==null?void 0:o[0])==null?void 0:g.SignData}));i(this,"pkcs7VerifySignature",e=>l(this,null,function*(){var r,o,a;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));i(this,"sm3Hash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HexHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3FileHash",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HashEncryption",e=>l(this,null,function*(){var o,a,u,y,d,g;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=(y=e.KeyB64)!=null?y:this.base64Encode({Data:(u=e.Key)!=null?u:""}),r=yield(d=this.coreInstance)==null?void 0:d.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(g=r==null?void 0:r[0])==null?void 0:g.DataB64}));i(this,"pkcs7Encryption",e=>l(this,null,function*(){var r,o,a,u;if(!e.CertB64List){const y=yield this.getEncryptionCert();e.CertB64List=y==null?void 0:y.CertB64}const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(r=e.Data)!=null?r:""}),s=yield(a=this.coreInstance)==null?void 0:a.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(u=s==null?void 0:s[0])==null?void 0:u.DataB64}));i(this,"pkcs7Decryption",e=>l(this,null,function*(){var o,a;const t=yield this.getEncryptionCert(),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Decryption(I(B({},e!=null?e:{}),{ContainerName:t==null?void 0:t.ContainerName})),r=(a=s==null?void 0:s[0])==null?void 0:a.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:r}):r}));i(this,"asymmetricEncryption",e=>l(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e,!1),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(o=s==null?void 0:s[0])==null?void 0:o.Data}));i(this,"asymmetricDecryption",(e,t)=>l(this,null,function*(){var o,a;const s=yield this.getEncryptionCert(t),r=yield(o=this.coreInstance)==null?void 0:o.asymmetricDecryption(I(B({},e!=null?e:{}),{ContainerName:s==null?void 0:s.ContainerName}));return(a=r==null?void 0:r[0])==null?void 0:a.Data}));i(this,"sm4Encryption",e=>l(this,null,function*(){var s;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(e);return t==null?void 0:t[0]}));i(this,"sm4Decryption",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(e);return(r=t==null?void 0:t[0])==null?void 0:r.Data}));i(this,"getCertInfo",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e);return B({},(r=t==null?void 0:t[0])!=null?r:{})}));i(this,"getCertInfoByOid",e=>l(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid(B({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return Z.instance&&!(e!=null&&e.isCreateNew)?Z.instance:(this.createGwsCore(e),Z.instance=this,this)}};i(Z,"instance",null);let O=Z;function it(n){return new Promise((e,t)=>{if(O.instance&&!(n!=null&&n.isCreateNew))e(O.instance);else{const s=new O(I(B({},n!=null?n:{}),{onOpen(r){var o;e(s),(o=n==null?void 0:n.onOpen)==null||o.call(n,r)},onClose(r){var o;t(r),(o=n==null?void 0:n.onClose)==null||o.call(n,r)}}))}})}S.GwsService=O,S.createService=it,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gws-client",
3
- "version": "0.6.3",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "module": "dist/index.es.js",
6
6
  "main": "dist/index.cjs.js",