gws-client 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -32
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +239 -227
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,16 +76,16 @@ async function foo() {
|
|
|
76
76
|
|
|
77
77
|
#### 实例化参数说明
|
|
78
78
|
|
|
79
|
-
| 属性 | 说明 | 类型
|
|
80
|
-
| ------------- | -------------------------- |
|
|
81
|
-
| isRememberPin | 可选,是否记住pin码 | `Boolean`
|
|
82
|
-
| pinPolicy | 可选,口令安全策略 | `0` \| `1`\| `2`\| `3`
|
|
83
|
-
| onOpen | 可选,socket连接成功回调 | `(event: Event) => void`
|
|
84
|
-
| onError | 可选,socket错误时回调 | `(event: Event) => void`
|
|
85
|
-
| onClose | 可选,socket关闭时回调 | `(event: Event) => void`
|
|
86
|
-
| onMessage | 可选,socket收到消息时回调 | `(data: Record<string, any>) => void`
|
|
79
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
80
|
+
| ------------- | -------------------------- | --------------------------------------------------------------- | --------- |
|
|
81
|
+
| isRememberPin | 可选,是否记住pin码 | `Boolean` | `false` |
|
|
82
|
+
| pinPolicy | 可选,口令安全策略 | `0` \| `1`\| `2`\| `3` | `0` |
|
|
83
|
+
| onOpen | 可选,socket连接成功回调 | `(event: Event) => void` | -- |
|
|
84
|
+
| onError | 可选,socket错误时回调 | `(event: Event) => void` | -- |
|
|
85
|
+
| onClose | 可选,socket关闭时回调 | `(event: Event) => void` | -- |
|
|
86
|
+
| onMessage | 可选,socket收到消息时回调 | `(data: Record<string, any>) => void` | -- |
|
|
87
87
|
| onUkeyEvent | 可选,Ukey插入拔出时回调 | `(event: {type: 'remove' \| 'insert', data: CertType}) => void` | -- |
|
|
88
|
-
| theme | 可选,弹窗主题色 | `String`
|
|
88
|
+
| theme | 可选,弹窗主题色 | `String` | `#409eff` |
|
|
89
89
|
|
|
90
90
|
#### 示例
|
|
91
91
|
|
|
@@ -168,10 +168,19 @@ getSignatureCert
|
|
|
168
168
|
type GetSignatureCert = (cert?: CertType) => Promise<CertType>;
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
### 获取签名证书列表
|
|
172
|
+
|
|
173
|
+
获取签名证书列表
|
|
174
|
+
|
|
175
|
+
#### 接口名称
|
|
176
|
+
|
|
177
|
+
getSignatureCertList
|
|
178
|
+
|
|
179
|
+
#### 函数签名
|
|
172
180
|
|
|
173
|
-
|
|
174
|
-
|
|
181
|
+
```ts
|
|
182
|
+
type GetSignatureCertList = () => Promise<CertType[]>;
|
|
183
|
+
```
|
|
175
184
|
|
|
176
185
|
### 获取加密证书
|
|
177
186
|
|
|
@@ -187,10 +196,19 @@ getEncryptionCert
|
|
|
187
196
|
type GetEncryptionCert = (cert?: CertType) => Promise<CertType>;
|
|
188
197
|
```
|
|
189
198
|
|
|
190
|
-
|
|
199
|
+
### 获取加密证书列表
|
|
200
|
+
|
|
201
|
+
获取加密证书列表
|
|
191
202
|
|
|
192
|
-
|
|
193
|
-
|
|
203
|
+
#### 接口名称
|
|
204
|
+
|
|
205
|
+
getEncryptionCertList
|
|
206
|
+
|
|
207
|
+
#### 函数签名
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
type GetEncryptionCertList = () => Promise<CertType[]>;
|
|
211
|
+
```
|
|
194
212
|
|
|
195
213
|
### 获取证书详情
|
|
196
214
|
|
|
@@ -226,16 +244,17 @@ pkcs1Sign
|
|
|
226
244
|
|
|
227
245
|
```ts
|
|
228
246
|
type Pkcs1Sign = (
|
|
229
|
-
params: { Data: string },
|
|
247
|
+
params: { Data: string; IsLogin?: string },
|
|
230
248
|
curCert?: CertType
|
|
231
249
|
) => Promise<string>;
|
|
232
250
|
```
|
|
233
251
|
|
|
234
252
|
#### 参数说明
|
|
235
253
|
|
|
236
|
-
| 属性
|
|
237
|
-
|
|
|
238
|
-
| Data
|
|
254
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
255
|
+
| ------- | ------------------ | ---------- | ------ |
|
|
256
|
+
| Data | 必填,待签名原文 | `String` | -- |
|
|
257
|
+
| IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
|
|
239
258
|
|
|
240
259
|
### PKCS1验签
|
|
241
260
|
|
|
@@ -280,15 +299,17 @@ pkcs1Base64Sign
|
|
|
280
299
|
type Pkcs1Base64Sign = (params: {
|
|
281
300
|
Data?: string;
|
|
282
301
|
DataB64?: string;
|
|
302
|
+
IsLogin?: string;
|
|
283
303
|
}) => Promise<string>;
|
|
284
304
|
```
|
|
285
305
|
|
|
286
306
|
#### 参数说明
|
|
287
307
|
|
|
288
|
-
| 属性 | 说明 | 类型
|
|
289
|
-
| ------- | ------------------------------------------------------------- |
|
|
290
|
-
| Data | 与DataB64二选一,待签名原文 | `String`
|
|
291
|
-
| DataB64 | 与Data二选一 , Base64编码的待签名原文,同时存在时使用DataB64 | `String`
|
|
308
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
309
|
+
| ------- | ------------------------------------------------------------- | ---------- | ------ |
|
|
310
|
+
| Data | 与DataB64二选一,待签名原文 | `String` | -- |
|
|
311
|
+
| DataB64 | 与Data二选一 , Base64编码的待签名原文,同时存在时使用DataB64 | `String` | -- |
|
|
312
|
+
| IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
|
|
292
313
|
|
|
293
314
|
### PKCS1 B64验签
|
|
294
315
|
|
|
@@ -331,6 +352,7 @@ type Pkcs1HashSign = (
|
|
|
331
352
|
params: {
|
|
332
353
|
DataB64: string;
|
|
333
354
|
HashAlg?: string;
|
|
355
|
+
IsLogin?: string;
|
|
334
356
|
},
|
|
335
357
|
curCert?: CertType
|
|
336
358
|
) => Promise<string>;
|
|
@@ -342,6 +364,7 @@ type Pkcs1HashSign = (
|
|
|
342
364
|
| ------- | -------------------------------------- | -------------------------- | ------ |
|
|
343
365
|
| DataB64 | 必填,Base64编码带签名原文的预处理哈希 | `String` | -- |
|
|
344
366
|
| HashAlg | 可选,哈希算法 | `sm3` \| `sha1`\| `sha256` | `sm3` |
|
|
367
|
+
| IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
|
|
345
368
|
|
|
346
369
|
### PKCS1哈希验签
|
|
347
370
|
|
|
@@ -387,6 +410,7 @@ type Pkcs7Sign = (
|
|
|
387
410
|
Data?: string;
|
|
388
411
|
DataB64?: string;
|
|
389
412
|
IsDetached: string;
|
|
413
|
+
IsLogin?: string;
|
|
390
414
|
},
|
|
391
415
|
curCert?: CertType
|
|
392
416
|
) => Promise<string>;
|
|
@@ -399,6 +423,7 @@ type Pkcs7Sign = (
|
|
|
399
423
|
| Data | 与DataB64二选一,待签名原文 | `String` | -- |
|
|
400
424
|
| DataB64 | 与Data二选一 , Base64编码的待签名原文,同时存在时使用DataB64 | `String` | -- |
|
|
401
425
|
| IsDetached | 必填,Y为detach,N为attach,attach模式签名值带了原文 | `Y` \| `N` | -- |
|
|
426
|
+
| IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
|
|
402
427
|
|
|
403
428
|
### PKCS7验签
|
|
404
429
|
|
|
@@ -594,15 +619,17 @@ pkcs7Decryption
|
|
|
594
619
|
type Pkcs7Decryption = (params: {
|
|
595
620
|
DataB64: string;
|
|
596
621
|
shouldDecodeBase64?: boolean;
|
|
622
|
+
IsLogin?: string;
|
|
597
623
|
}) => Promise<string>;
|
|
598
624
|
```
|
|
599
625
|
|
|
600
626
|
#### 参数说明
|
|
601
627
|
|
|
602
|
-
| 属性 | 说明 | 类型
|
|
603
|
-
| ------------------ | ------------------------ |
|
|
604
|
-
| DataB64 | 必填,待解密原文 | `String`
|
|
605
|
-
| shouldDecodeBase64 | 可选,是否需要base64解码 | `Boolean`
|
|
628
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
629
|
+
| ------------------ | ------------------------ | ---------- | ------ |
|
|
630
|
+
| DataB64 | 必填,待解密原文 | `String` | -- |
|
|
631
|
+
| shouldDecodeBase64 | 可选,是否需要base64解码 | `Boolean` | -- |
|
|
632
|
+
| IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
|
|
606
633
|
|
|
607
634
|
### 非对称加密
|
|
608
635
|
|
|
@@ -615,15 +642,16 @@ asymmetricDecryption
|
|
|
615
642
|
#### 函数签名
|
|
616
643
|
|
|
617
644
|
```ts
|
|
618
|
-
type AsymmetricDecryption = (params: { Data: string }) => Promise<string>;
|
|
645
|
+
type AsymmetricDecryption = (params: { Data: string;IsLogin?: string }) => Promise<string>;
|
|
619
646
|
```
|
|
620
647
|
|
|
621
648
|
#### 参数说明
|
|
622
649
|
|
|
623
|
-
| 属性 | 说明
|
|
624
|
-
| ------- |
|
|
625
|
-
| Data | 必填,待解密原文
|
|
626
|
-
| CertB64 | 可选,加密证书B64
|
|
650
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
651
|
+
| ------- | ------------------ | ---------- | ------ |
|
|
652
|
+
| Data | 必填,待解密原文 | `String` | -- |
|
|
653
|
+
| CertB64 | 可选,加密证书B64 | `String` | -- |
|
|
654
|
+
| IsLogin | 可选,证书登录状态 | `Y` \| `N` | -- |
|
|
627
655
|
|
|
628
656
|
### 非对称解密
|
|
629
657
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var be=Object.defineProperty,De=Object.defineProperties;var xe=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var J=(n,e,t)=>e in n?be(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,D=(n,e)=>{for(var t in e||(e={}))Be.call(e,t)&&J(n,t,e[t]);if(ee)for(var t of ee(e))Se.call(e,t)&&J(n,t,e[t]);return n},B=(n,e)=>De(n,xe(e));var i=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);var u=(n,e,t)=>new Promise((s,r)=>{var o=d=>{try{l(t.next(d))}catch(h){r(h)}},a=d=>{try{l(t.throw(d))}catch(h){r(h)}},l=d=>d.done?s(d.value):Promise.resolve(d.value).then(o,a);l((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",Ie="1",Ae="2";var he=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(he||{});const Ee="00000001";function _e(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var F={},te;function Pe(){if(te)return F;te=1,F.byteLength=l,F.toByteArray=h,F.fromByteArray=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(y){var c=y.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=y.indexOf("=");f===-1&&(f=c);var w=f===c?0:4-f%4;return[f,w]}function l(y){var c=a(y),f=c[0],w=c[1];return(f+w)*3/4-w}function d(y,c,f){return(c+f)*3/4-f}function h(y){var c,f=a(y),w=f[0],m=f[1],C=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)],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 g(y){return n[y>>18&63]+n[y>>12&63]+n[y>>6&63]+n[y&63]}function v(y,c,f){for(var w,m=[],C=c;C<f;C+=3)w=(y[C]<<16&16711680)+(y[C+1]<<8&65280)+(y[C+2]&255),m.push(g(w));return m.join("")}function p(y){for(var c,f=y.length,w=f%3,m=[],C=16383,b=0,E=f-w;b<E;b+=C)m.push(v(y,b,b+C>E?E:b+C));return w===1?(c=y[f-1],m.push(n[c>>2]+n[c<<4&63]+"==")):w===2&&(c=(y[f-2]<<8)+y[f-1],m.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),m.join("")}return F}var Le=Pe();const ne=_e(Le);class Me{constructor(){i(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const s=this.deps.get(e);s&&s(t)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-oivou{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-oivou{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-oivou{background-color:#fff;padding:1.42857rem;border-radius:.35714rem;width:40%}.model-title.svelte-oivou{color:#303133;font-size:1.28571rem;margin-bottom:1.14286rem}.modal-visible.svelte-oivou{display:flex}.modal-footer.svelte-oivou{display:flex;align-items:center;justify-content:flex-end;margin-top:1.14286rem}.modal-btn.svelte-oivou{padding:.57143rem 1.07143rem;border-radius:.28571rem;font-size:1rem;border:.07143rem solid #dcdfe6}.success.svelte-oivou{margin-left:.85714rem;color:#fff}.slot.svelte-oivou{max-height:14.28571rem;overflow-y:scroll}.slot.svelte-oivou::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:1.14286rem;display:flex;align-items:center;cursor:pointer;border-bottom:.07143rem solid #ebeef5;font-size:1rem}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:.07143rem solid #ebeef5}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4{display:inline-block;color:#606266}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4:first-child{width:30%}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:12.85714rem;height:12.85714rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.07143rem solid #ccc;margin-top:.71429rem;margin-right:.71429rem;border-radius:.28571rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:7.14286rem;height:7.14286rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.71429rem;color:#333}")),document.head.appendChild(n)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Te=Object.defineProperty,He=(n,e,t)=>e in n?Te(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,se=(n,e,t)=>He(n,typeof e!="symbol"?e+"":e,t);function W(){}function Ge(n,e){for(const t in e)n[t]=e[t];return n}function ye(n){return n()}function re(){return Object.create(null)}function V(n){n.forEach(ye)}function O(n){return typeof n=="function"}function fe(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Fe(n){return Object.keys(n).length===0}function je(n,e,t,s){if(n){const r=ge(n,e,t,s);return n[0](r)}}function ge(n,e,t,s){return n[1]&&s?Ge(t.ctx.slice(),n[1](s(e))):t.ctx}function Oe(n,e,t,s){if(n[2]&&s){const r=n[2](s(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const o=[],a=Math.max(e.dirty.length,r.length);for(let l=0;l<a;l+=1)o[l]=e.dirty[l]|r[l];return o}return e.dirty|r}return e.dirty}function Ne(n,e,t,s,r,o){if(r){const a=ge(e,t,s,o);n.p(a,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 oe(n){return n!=null?n:""}function x(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 S(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ue(n){return Array.from(n.childNodes)}function T(n,e){e=""+e,n.data!==e&&(n.data=e)}function ae(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let X;function Z(n){X=n}const L=[],ie=[];let H=[];const ce=[],Je=Promise.resolve();let q=!1;function ze(){q||(q=!0,Je.then(pe))}function K(n){H.push(n)}const z=new Set;let P=0;function pe(){if(P!==0)return;const n=X;do{try{for(;P<L.length;){const e=L[P];P++,Z(e),We(e.$$)}}catch(e){throw L.length=0,P=0,e}for(Z(null),L.length=0,P=0;ie.length;)ie.pop()();for(let e=0;e<H.length;e+=1){const t=H[e];z.has(t)||(z.add(t),t())}H.length=0}while(L.length);for(;ce.length;)ce.pop()();q=!1,z.clear(),Z(n)}function We(n){if(n.fragment!==null){n.update(),V(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(K)}}function qe(n){const e=[],t=[];H.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),H=e}const R=new Set;let Ke;function Y(n,e){n&&n.i&&(R.delete(n),n.i(e))}function me(n,e,t,s){if(n&&n.o){if(R.has(n))return;R.add(n),Ke.c.push(()=>{R.delete(n)}),n.o(e)}}function le(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Qe(n){n&&n.c()}function ve(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),K(()=>{const o=n.$$.on_mount.map(ye).filter(O);n.$$.on_destroy?n.$$.on_destroy.push(...o):V(o),n.$$.on_mount=[]}),r.forEach(K)}function Ce(n,e){const t=n.$$;t.fragment!==null&&(qe(t.after_update),V(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Xe(n,e){n.$$.dirty[0]===-1&&(L.push(n),ze(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function we(n,e,t,s,r,o,a=null,l=[-1]){const d=X;Z(n);const h=n.$$={fragment:null,ctx:[],props:o,update:W,not_equal:r,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:re(),dirty:l,skip_bound:!1,root:e.target||d.$$.root};a&&a(h.root);let g=!1;if(h.ctx=t?t(n,e.props||{},(v,p,...y)=>{const c=y.length?y[0]:p;return h.ctx&&r(h.ctx[v],h.ctx[v]=c)&&(!h.skip_bound&&h.bound[v]&&h.bound[v](c),g&&Xe(n,v)),p}):[],h.update(),g=!0,V(h.before_update),h.fragment=s?s(h.ctx):!1,e.target){if(e.hydrate){const v=Ue(e.target);h.fragment&&h.fragment.l(v),v.forEach(U)}else h.fragment&&h.fragment.c();e.intro&&Y(n.$$.fragment),ve(n,e.target,e.anchor),pe()}Z(d)}class ke{constructor(){se(this,"$$"),se(this,"$$set")}$destroy(){Ce(this,1),this.$destroy=W}$on(e,t){if(!O(t))return W;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Fe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ye="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ye);function et(n){let e,t,s,r=(n[1]||"标题")+"",o,a,l,d,h,g,v=(n[4]||"取消")+"",p,y,c,f=(n[5]||"确认")+"",w,m,C,b;const E=n[8].default,k=je(E,n,n[7],null);return{c(){e=I("div"),t=I("div"),s=I("div"),o=A(r),a=N(),l=I("div"),k&&k.c(),d=N(),h=I("div"),g=I("button"),p=A(v),y=N(),c=I("button"),w=A(f),S(s,"class","model-title svelte-oivou"),S(l,"class","slot svelte-oivou"),S(g,"class","modal-btn svelte-oivou"),S(c,"class","modal-btn success svelte-oivou"),ae(c,"background-color",n[6]),S(h,"class","modal-footer svelte-oivou"),S(t,"class","modal-content svelte-oivou"),S(e,"class","modal-background modal-visible svelte-oivou")},m($,_){Q($,e,_),x(e,t),x(t,s),x(s,o),x(t,a),x(t,l),k&&k.m(l,null),x(t,d),x(t,h),x(h,g),x(g,p),x(h,y),x(h,c),x(c,w),m=!0,C||(b=[j(g,"click",function(){O(n[0])&&n[0].apply(this,arguments)}),j(c,"click",function(){O(n[2])&&n[2].apply(this,arguments)}),j(t,"click",tt),j(e,"click",function(){O(n[3])&&n[3].apply(this,arguments)})],C=!0)},p($,[_]){n=$,(!m||_&2)&&r!==(r=(n[1]||"标题")+"")&&T(o,r),k&&k.p&&(!m||_&128)&&Ne(k,E,n,n[7],m?Oe(E,n[7],_,null):Ze(n[7]),null),(!m||_&16)&&v!==(v=(n[4]||"取消")+"")&&T(p,v),(!m||_&32)&&f!==(f=(n[5]||"确认")+"")&&T(w,f),(!m||_&64)&&ae(c,"background-color",n[6])},i($){m||(Y(k,$),m=!0)},o($){me(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:o}=e,{title:a}=e,{onOk:l}=e,{onClose:d}=e,{cancelText:h}=e,{okText:g}=e,{theme:v}=e;return n.$$set=p=>{"onCancel"in p&&t(0,o=p.onCancel),"title"in p&&t(1,a=p.title),"onOk"in p&&t(2,l=p.onOk),"onClose"in p&&t(3,d=p.onClose),"cancelText"in p&&t(4,h=p.cancelText),"okText"in p&&t(5,g=p.okText),"theme"in p&&t(6,v=p.theme),"$$scope"in p&&t(7,r=p.$$scope)},[o,a,l,d,h,g,v,r,s]}class st extends ke{constructor(e){super(),we(this,e,nt,et,fe,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function ue(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function de(n){let e,t,s=n[11].CN+"",r,o,a,l=n[11].DevClass+"",d,h,g=n[11].sn+"",v,p,y,c,f,w;function m(){return n[10](n[13])}return{c(){e=I("div"),t=I("span"),r=A(s),o=N(),a=I("span"),d=A(l),h=A("("),v=A(g),p=A(")"),y=N(),S(t,"class","svelte-jtc2v4"),S(a,"class","svelte-jtc2v4"),S(e,"class",c=oe(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(C,b){Q(C,e,b),x(e,t),x(t,r),x(e,o),x(e,a),x(a,d),x(a,h),x(a,v),x(a,p),x(e,y),f||(w=j(e,"click",m),f=!0)},p(C,b){n=C,b&1&&s!==(s=n[11].CN+"")&&T(r,s),b&1&&l!==(l=n[11].DevClass+"")&&T(d,l),b&1&&g!==(g=n[11].sn+"")&&T(v,g),b&32&&c!==(c=oe(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&S(e,"class",c)},d(C){C&&U(e),f=!1,w()}}}function rt(n){let e,t=le(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=de(ue(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Re()},m(r,o){for(let a=0;a<s.length;a+=1)s[a]&&s[a].m(r,o);Q(r,e,o)},p(r,o){if(o&33){t=le(r[0]);let a;for(a=0;a<t.length;a+=1){const l=ue(r,t,a);s[a]?s[a].p(l,o):(s[a]=de(l),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&&U(e),Ve(s,r)}}}function ot(n){let e,t;return e=new st({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[rt]},$$scope:{ctx:n}}}),{c(){Qe(e.$$.fragment)},m(s,r){ve(e,s,r),t=!0},p(s,[r]){const 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||(Y(e.$$.fragment,s),t=!0)},o(s){me(e.$$.fragment,s),t=!1},d(s){Ce(e,s)}}}function at(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:o}=e,{onClose:a}=e,{cancelText:l=""}=e,{okText:d=""}=e,{theme:h="#409eff"}=e,g=0;const v=()=>{r("未选择证书"),a==null||a()},p=()=>{o==null||o(s[g]),a==null||a()},y=c=>t(5,g=c);return n.$$set=c=>{"certList"in c&&t(0,s=c.certList),"onCancel"in c&&t(8,r=c.onCancel),"onOk"in c&&t(9,o=c.onOk),"onClose"in c&&t(1,a=c.onClose),"cancelText"in c&&t(2,l=c.cancelText),"okText"in c&&t(3,d=c.okText),"theme"in c&&t(4,h=c.theme)},[s,a,l,d,h,g,v,p,r,o,y]}class it extends ke{constructor(e){super(),we(this,e,at,ot,fe,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class ct{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new it({target:document.body,props:B(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 Me);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,l;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:{}]};(l=this.socketInstance)==null||l.send(JSON.stringify(o)),this.eventBus.on(e,d=>{d.success?s(d.data):r(d)})}));i(this,"handleEventData",e=>u(this,null,function*(){var t,s,r,o,a,l,d,h,g,v;if(e.data instanceof Blob){const p=yield e.data.arrayBuffer(),c=new TextDecoder("gbk").decode(p),f=JSON.parse(c),w={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"?(h=(a=this.socketConfig)==null?void 0:a.onUkeyEvent)==null||h.call(a,B(D({},w),{type:(l=f.result)==null?void 0:l.event,data:(d=f.data)==null?void 0:d[0]})):this.eventBus.emit(m,w),(v=(g=this.socketConfig)==null?void 0:g.onMessage)==null||v.call(g,w)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return ne.fromByteArray(t)});i(this,"base64Decode",e=>{const t=ne.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>u(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>u(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>u(this,null,function*(){this.sendMessage("GZCA_WaitForDevEvent",{Type:Ee})}));i(this,"certLogin",e=>u(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));i(this,"getCert",(e,t)=>u(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return this.isRememberPin&&(yield this.certLogin(s.ContainerName)),s}));i(this,"chooseCert",e=>u(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield lt.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"getCertList",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"pkcs1Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",D({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",D({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",D({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",D({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",D({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs7VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",D({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",D({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));var t,s;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(s=e.pinPolicy)!=null?s:he.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=s=>{var r;(r=e.onError)==null||r.call(e,s)},t.onopen=s=>{var r;(r=e.onOpen)==null||r.call(e,s),e.onUkeyEvent&&this.addUkeyEvents()},t.onmessage=s=>{this.handleEventData(s)},t.onclose=s=>{var r;(r=e.onClose)==null||r.call(e,s)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const M=class M{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ut(B(D({},e!=null?e:{}),{url:$e}))});i(this,"appendCertBase64",(e,t=!0)=>u(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return B(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=>u(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:Ie},e)}));i(this,"getEncryptionCert",e=>u(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:Ae},e)}));i(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});i(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});i(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});i(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});i(this,"pkcs1Sign",(e,t)=>u(this,null,function*(){var o,a,l;const s=yield this.getSignatureCert(t),r=yield(a=this.coreInstance)==null?void 0:a.pkcs1Sign(B(D({},e!=null?e:{}),{ContainerName:(o=s==null?void 0:s.ContainerName)!=null?o:""}));return(l=r==null?void 0:r[0])==null?void 0:l.SignData}));i(this,"pkcs1VerifySignature",e=>u(this,null,function*(){var r;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(s)}));i(this,"pkcs1Base64Sign",(e,t)=>u(this,null,function*(){var a,l,d,h,g;const s=yield this.getSignatureCert(t),r=(l=e.DataB64)!=null?l:this.base64Encode({Data:(a=e.Data)!=null?a:""}),o=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign(B(D({},e!=null?e:{}),{ContainerName:(d=s==null?void 0:s.ContainerName)!=null?d:"",DataB64:r}));return(g=o==null?void 0:o[0])==null?void 0:g.SignData}));i(this,"pkcs1Base64VerifySignature",e=>u(this,null,function*(){var o,a,l;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",e=>u(this,null,function*(){var r,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=>u(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=>u(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)=>u(this,null,function*(){var o,a,l,d;const s=yield this.getSignatureCert(t),r=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(o=s==null?void 0:s.ContainerName)!=null?o:"",DataB64:e.DataB64,HashAlg:(a=e.HashAlg)!=null?a:"sm3"});return(d=r==null?void 0:r[0])==null?void 0:d.SignData}));i(this,"pkcs1HashVerifySignature",e=>u(this,null,function*(){var r,o;const t=yield this.appendCertBase64(e);return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs1HashVerifySignature(B(D({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>u(this,null,function*(){var a,l,d,h,g;const s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(a=e.Data)!=null?a:""}),r=yield this.getSignatureCert(t),o=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign(B(D({},e!=null?e:{}),{ContainerName:(d=r==null?void 0:r.ContainerName)!=null?d:"",DataB64:s}));return(g=o==null?void 0:o[0])==null?void 0:g.SignData}));i(this,"pkcs7VerifySignature",e=>u(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=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HexHash",e=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3FileHash",e=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HashEncryption",e=>u(this,null,function*(){var o,a,l,d,h,g;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(o=e.Data)!=null?o:""}),s=(d=e.KeyB64)!=null?d:this.base64Encode({Data:(l=e.Key)!=null?l:""}),r=yield(h=this.coreInstance)==null?void 0:h.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(g=r==null?void 0:r[0])==null?void 0:g.DataB64}));i(this,"pkcs7Encryption",e=>u(this,null,function*(){var r,o,a,l;if(!e.CertB64List){const d=yield this.getEncryptionCert();e.CertB64List=d==null?void 0:d.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(l=s==null?void 0:s[0])==null?void 0:l.DataB64}));i(this,"pkcs7Decryption",e=>u(this,null,function*(){var o,a;const t=yield this.getEncryptionCert(),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Decryption(B(D({},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=>u(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)=>u(this,null,function*(){var o,a;const s=yield this.getEncryptionCert(t),r=yield(o=this.coreInstance)==null?void 0:o.asymmetricDecryption(B(D({},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=>u(this,null,function*(){var s;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(e);return t==null?void 0:t[0]}));i(this,"sm4Decryption",e=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(e);return(r=t==null?void 0:t[0])==null?void 0:r.Data}));i(this,"getCertInfo",e=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(e);return D({},(r=t==null?void 0:t[0])!=null?r:{})}));i(this,"getCertInfoByOid",e=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid(D({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return M.instance&&!(e!=null&&e.isCreateNew)?M.instance:(this.createGwsCore(e),M.instance=this,this)}};i(M,"instance",null);let G=M;function dt(n){return new Promise((e,t)=>{if(G.instance&&!(n!=null&&n.isCreateNew))e(G.instance);else{const s=new G(B(D({},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)}}))}})}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 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;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ export declare class GwsService {
|
|
|
22
22
|
restart: (config?: Record<string, any>) => void;
|
|
23
23
|
getSocketReadyState: () => number | undefined;
|
|
24
24
|
getSignatureCert: (cert?: CertType) => Promise<CertType | undefined>;
|
|
25
|
+
getSignatureCertList: () => Promise<CertType[] | undefined>;
|
|
25
26
|
getEncryptionCert: (cert?: CertType) => Promise<CertType | undefined>;
|
|
27
|
+
getEncryptionCertList: () => Promise<CertType[] | undefined>;
|
|
26
28
|
base64Encode: (params: {
|
|
27
29
|
Data: string;
|
|
28
30
|
}) => string;
|