gws-client 0.5.3 → 0.5.6
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 +102 -29
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +521 -493
- package/dist/index.umd.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -76,15 +76,16 @@ async function foo() {
|
|
|
76
76
|
|
|
77
77
|
#### 实例化参数说明
|
|
78
78
|
|
|
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
|
-
| onUkeyEvent | 可选,Ukey插入拔出时回调 | `(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
|
+
| onUkeyEvent | 可选,Ukey插入拔出时回调 | `(data: Record<string, any>) => void` | -- |
|
|
88
|
+
| theme | 可选,弹窗主题色 | `String` | `#409eff` |
|
|
88
89
|
|
|
89
90
|
#### 示例
|
|
90
91
|
|
|
@@ -114,7 +115,7 @@ function pkcs1Sign() {
|
|
|
114
115
|
import { createService } from "gws-client";
|
|
115
116
|
async function pkcs1Sign() {
|
|
116
117
|
try {
|
|
117
|
-
const gwsService = await createService();
|
|
118
|
+
const gwsService = await createService();
|
|
118
119
|
const res = await gwsService.pkcs1Sign({ Data: "hello world" });
|
|
119
120
|
console.log("签名值", res);
|
|
120
121
|
} catch (error) {
|
|
@@ -153,6 +154,66 @@ restart
|
|
|
153
154
|
type Restart = (config?: GwsServiceConfigType) => void;
|
|
154
155
|
```
|
|
155
156
|
|
|
157
|
+
### 获取签名证书
|
|
158
|
+
|
|
159
|
+
获取签名证书,可获取证书CN项,证书CertB64,sn
|
|
160
|
+
|
|
161
|
+
#### 接口名称
|
|
162
|
+
|
|
163
|
+
getSignatureCert
|
|
164
|
+
|
|
165
|
+
#### 函数签名
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
type GetSignatureCert = (cert?: CertType) => Promise<CertType>;
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### 参数说明
|
|
172
|
+
|
|
173
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
174
|
+
| ---- | ---- | ---- | ------ |
|
|
175
|
+
|
|
176
|
+
### 获取加密证书
|
|
177
|
+
|
|
178
|
+
获取加密证书,可获取证书CN项,证书CertB64,sn
|
|
179
|
+
|
|
180
|
+
#### 接口名称
|
|
181
|
+
|
|
182
|
+
getEncryptionCert
|
|
183
|
+
|
|
184
|
+
#### 函数签名
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
type GetEncryptionCert = (cert?: CertType) => Promise<CertType>;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### 参数说明
|
|
191
|
+
|
|
192
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
193
|
+
| ---- | ---- | ---- | ------ |
|
|
194
|
+
|
|
195
|
+
### 获取证书详情
|
|
196
|
+
|
|
197
|
+
获取证书详情,可获取证书公钥CertPublicKey,证书序列号CertSerial,证书有效期CertValidTime
|
|
198
|
+
|
|
199
|
+
#### 接口名称
|
|
200
|
+
|
|
201
|
+
getCertInfo
|
|
202
|
+
|
|
203
|
+
#### 函数签名
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
type GetCertInfo = (params: {
|
|
207
|
+
CertB64: string;
|
|
208
|
+
}) => Promise<Record<string, unknow>>;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### 参数说明
|
|
212
|
+
|
|
213
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
214
|
+
| ------- | ---------------- | -------- | ------ |
|
|
215
|
+
| CertB64 | 必填,证书Base64 | `String` | -- |
|
|
216
|
+
|
|
156
217
|
### PKCS1签名
|
|
157
218
|
|
|
158
219
|
PKCS1签名,返回签名值
|
|
@@ -164,7 +225,10 @@ pkcs1Sign
|
|
|
164
225
|
#### 函数签名
|
|
165
226
|
|
|
166
227
|
```ts
|
|
167
|
-
type Pkcs1Sign = (
|
|
228
|
+
type Pkcs1Sign = (
|
|
229
|
+
params: { Data: string },
|
|
230
|
+
curCert?: CertType
|
|
231
|
+
) => Promise<string>;
|
|
168
232
|
```
|
|
169
233
|
|
|
170
234
|
#### 参数说明
|
|
@@ -175,7 +239,7 @@ type Pkcs1Sign = (params: { Data: string }) => Promise<string>;
|
|
|
175
239
|
|
|
176
240
|
### PKCS1验签
|
|
177
241
|
|
|
178
|
-
PKCS1
|
|
242
|
+
PKCS1验签,传入curCert时使用该证书,返回验签结果,`true`为验签成功,验签失败时返回`Promise.reject`
|
|
179
243
|
|
|
180
244
|
#### 接口名称
|
|
181
245
|
|
|
@@ -184,11 +248,14 @@ pkcs1VerifySignature
|
|
|
184
248
|
#### 函数签名
|
|
185
249
|
|
|
186
250
|
```ts
|
|
187
|
-
type Pkcs1VerifySignature = (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
251
|
+
type Pkcs1VerifySignature = (
|
|
252
|
+
params: {
|
|
253
|
+
CertB64?: string;
|
|
254
|
+
Data: string;
|
|
255
|
+
SignData: string;
|
|
256
|
+
},
|
|
257
|
+
curCert?: CertType
|
|
258
|
+
) => Promise<boolean>;
|
|
192
259
|
```
|
|
193
260
|
|
|
194
261
|
#### 参数说明
|
|
@@ -201,7 +268,7 @@ type Pkcs1VerifySignature = (params: {
|
|
|
201
268
|
|
|
202
269
|
### PKCS1 B64签名
|
|
203
270
|
|
|
204
|
-
PKCS1 base64
|
|
271
|
+
PKCS1 base64签名,传入curCert时使用该证书,返回签名值
|
|
205
272
|
|
|
206
273
|
#### 接口名称
|
|
207
274
|
|
|
@@ -260,10 +327,13 @@ PKCS1哈希签名,返回签名值
|
|
|
260
327
|
pkcs1HashSign
|
|
261
328
|
|
|
262
329
|
```ts
|
|
263
|
-
type Pkcs1HashSign = (
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
330
|
+
type Pkcs1HashSign = (
|
|
331
|
+
params: {
|
|
332
|
+
DataB64: string;
|
|
333
|
+
HashAlg?: string;
|
|
334
|
+
},
|
|
335
|
+
curCert?: CertType
|
|
336
|
+
) => Promise<string>;
|
|
267
337
|
```
|
|
268
338
|
|
|
269
339
|
#### 参数说明
|
|
@@ -275,7 +345,7 @@ type Pkcs1HashSign = (params: {
|
|
|
275
345
|
|
|
276
346
|
### PKCS1哈希验签
|
|
277
347
|
|
|
278
|
-
PKCS1
|
|
348
|
+
PKCS1哈希验签,返回验签结果,传入curCert时使用该证书,`true`为验签成功,验签失败时返回`Promise.reject`
|
|
279
349
|
|
|
280
350
|
#### 接口名称
|
|
281
351
|
|
|
@@ -312,11 +382,14 @@ pkcs7Sign
|
|
|
312
382
|
#### 函数签名
|
|
313
383
|
|
|
314
384
|
```ts
|
|
315
|
-
type Pkcs7Sign = (
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
385
|
+
type Pkcs7Sign = (
|
|
386
|
+
params: {
|
|
387
|
+
Data?: string;
|
|
388
|
+
DataB64?: string;
|
|
389
|
+
IsDetached: string;
|
|
390
|
+
},
|
|
391
|
+
curCert?: CertType
|
|
392
|
+
) => Promise<string>;
|
|
320
393
|
```
|
|
321
394
|
|
|
322
395
|
#### 参数说明
|
|
@@ -329,7 +402,7 @@ type Pkcs7Sign = (params: {
|
|
|
329
402
|
|
|
330
403
|
### PKCS7验签
|
|
331
404
|
|
|
332
|
-
PKCS7
|
|
405
|
+
PKCS7验签,返回验签结果,传入curCert时使用该证书,`true`为验签成功,验签失败时返回`Promise.reject`
|
|
333
406
|
|
|
334
407
|
#### 接口名称
|
|
335
408
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var kt=Object.defineProperty,xt=Object.defineProperties;var Dt=Object.getOwnPropertyDescriptors;var tt=Object.getOwnPropertySymbols;var bt=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var U=(n,t,e)=>t in n?kt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,b=(n,t)=>{for(var e in t||(t={}))bt.call(t,e)&&U(n,e,t[e]);if(tt)for(var e of tt(t))Bt.call(t,e)&&U(n,e,t[e]);return n},B=(n,t)=>xt(n,Dt(t));var c=(n,t,e)=>U(n,typeof t!="symbol"?t+"":t,e);var l=(n,t,e)=>new Promise((s,a)=>{var r=u=>{try{i(e.next(u))}catch(h){a(h)}},o=u=>{try{i(e.throw(u))}catch(h){a(h)}},i=u=>u.done?s(u.value):Promise.resolve(u.value).then(r,o);i((e=e.apply(n,t)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",$t="1",It="2";var ut=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(ut||{});const Et="00000001";function At(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var F={},et;function _t(){if(et)return F;et=1,F.byteLength=i,F.toByteArray=h,F.fromByteArray=D;for(var n=[],t=[],e=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,r=s.length;a<r;++a)n[a]=s[a],t[s.charCodeAt(a)]=a;t[45]=62,t[95]=63;function o(d){var p=d.length;if(p%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=d.indexOf("=");f===-1&&(f=p);var v=f===p?0:4-f%4;return[f,v]}function i(d){var p=o(d),f=p[0],v=p[1];return(f+v)*3/4-v}function u(d,p,f){return(p+f)*3/4-f}function h(d){var p,f=o(d),v=f[0],w=f[1],m=new e(u(d,v,w)),k=0,A=w>0?v-4:v,C;for(C=0;C<A;C+=4)p=t[d.charCodeAt(C)]<<18|t[d.charCodeAt(C+1)]<<12|t[d.charCodeAt(C+2)]<<6|t[d.charCodeAt(C+3)],m[k++]=p>>16&255,m[k++]=p>>8&255,m[k++]=p&255;return w===2&&(p=t[d.charCodeAt(C)]<<2|t[d.charCodeAt(C+1)]>>4,m[k++]=p&255),w===1&&(p=t[d.charCodeAt(C)]<<10|t[d.charCodeAt(C+1)]<<4|t[d.charCodeAt(C+2)]>>2,m[k++]=p>>8&255,m[k++]=p&255),m}function g(d){return n[d>>18&63]+n[d>>12&63]+n[d>>6&63]+n[d&63]}function y(d,p,f){for(var v,w=[],m=p;m<f;m+=3)v=(d[m]<<16&16711680)+(d[m+1]<<8&65280)+(d[m+2]&255),w.push(g(v));return w.join("")}function D(d){for(var p,f=d.length,v=f%3,w=[],m=16383,k=0,A=f-v;k<A;k+=m)w.push(y(d,k,k+m>A?A:k+m));return v===1?(p=d[f-1],w.push(n[p>>2]+n[p<<4&63]+"==")):v===2&&(p=(d[f-2]<<8)+d[f-1],w.push(n[p>>10]+n[p>>4&63]+n[p<<2&63]+"=")),w.join("")}return F}var Lt=_t();const nt=At(Lt);class Pt{constructor(){c(this,"deps",new Map)}on(t,e){this.deps.set(t,e)}emit(t,e){const s=this.deps.get(t);s&&s(e)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-n1zwga{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-n1zwga{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-n1zwga{background-color:#fff;padding:20px;border-radius:5px;width:40%}.model-title.svelte-n1zwga{color:#303133;font-size:18px;margin-bottom:16px}.modal-visible.svelte-n1zwga{display:flex}.modal-footer.svelte-n1zwga{display:flex;align-items:center;justify-content:flex-end;margin-top:16px}.modal-btn.svelte-n1zwga{padding:8px 15px;border-radius:4px;font-size:14px;border:1px solid #dcdfe6}.success.svelte-n1zwga{background-color:#409eff;margin-left:12px;color:#fff}.slot.svelte-n1zwga{max-height:200px;overflow-y:scroll}.slot.svelte-n1zwga::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:16px;display:flex;align-items:center;cursor:pointer;border-bottom:1px solid #ebeef5;font-size:14px}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:1px 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:180px;height:180px;display:flex;flex-direction:column;align-items:center;justify-content:center;border:1px solid #ccc;margin-top:10px;margin-right:10px;border-radius:4px}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:100px;height:100px}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:10px;color:#333}")),document.head.appendChild(n)}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var Mt=Object.defineProperty,Tt=(n,t,e)=>t in n?Mt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,st=(n,t,e)=>Tt(n,typeof t!="symbol"?t+"":t,e);function q(){}function Ht(n,t){for(const e in t)n[e]=t[e];return n}function ht(n){return n()}function at(){return Object.create(null)}function z(n){n.forEach(ht)}function O(n){return typeof n=="function"}function yt(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function Gt(n){return Object.keys(n).length===0}function Ft(n,t,e,s){if(n){const a=pt(n,t,e,s);return n[0](a)}}function pt(n,t,e,s){return n[1]&&s?Ht(e.ctx.slice(),n[1](s(t))):e.ctx}function jt(n,t,e,s){if(n[2]&&s){const a=n[2](s(e));if(t.dirty===void 0)return a;if(typeof a=="object"){const r=[],o=Math.max(t.dirty.length,a.length);for(let i=0;i<o;i+=1)r[i]=t.dirty[i]|a[i];return r}return t.dirty|a}return t.dirty}function Ot(n,t,e,s,a,r){if(a){const o=pt(t,e,s,r);n.p(o,a)}}function Nt(n){if(n.ctx.length>32){const t=[],e=n.ctx.length/32;for(let s=0;s<e;s++)t[s]=-1;return t}return-1}function rt(n){return n!=null?n:""}function x(n,t){n.appendChild(t)}function Q(n,t,e){n.insertBefore(t,e||null)}function R(n){n.parentNode&&n.parentNode.removeChild(n)}function Zt(n,t){for(let e=0;e<n.length;e+=1)n[e]&&n[e].d(t)}function I(n){return document.createElement(n)}function E(n){return document.createTextNode(n)}function N(){return E(" ")}function zt(){return E("")}function j(n,t,e,s){return n.addEventListener(t,e,s),()=>n.removeEventListener(t,e,s)}function S(n,t,e){e==null?n.removeAttribute(t):n.getAttribute(t)!==e&&n.setAttribute(t,e)}function Vt(n){return Array.from(n.childNodes)}function T(n,t){t=""+t,n.data!==t&&(n.data=t)}let X;function Z(n){X=n}const P=[],ot=[];let H=[];const ct=[],Rt=Promise.resolve();let K=!1;function Ut(){K||(K=!0,Rt.then(gt))}function W(n){H.push(n)}const J=new Set;let L=0;function gt(){if(L!==0)return;const n=X;do{try{for(;L<P.length;){const t=P[L];L++,Z(t),Jt(t.$$)}}catch(t){throw P.length=0,L=0,t}for(Z(null),P.length=0,L=0;ot.length;)ot.pop()();for(let t=0;t<H.length;t+=1){const e=H[t];J.has(e)||(J.add(e),e())}H.length=0}while(P.length);for(;ct.length;)ct.pop()();K=!1,J.clear(),Z(n)}function Jt(n){if(n.fragment!==null){n.update(),z(n.before_update);const t=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,t),n.after_update.forEach(W)}}function qt(n){const t=[],e=[];H.forEach(s=>n.indexOf(s)===-1?t.push(s):e.push(s)),e.forEach(s=>s()),H=t}const V=new Set;let Kt;function Y(n,t){n&&n.i&&(V.delete(n),n.i(t))}function ft(n,t,e,s){if(n&&n.o){if(V.has(n))return;V.add(n),Kt.c.push(()=>{V.delete(n)}),n.o(t)}}function it(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Wt(n){n&&n.c()}function mt(n,t,e){const{fragment:s,after_update:a}=n.$$;s&&s.m(t,e),W(()=>{const r=n.$$.on_mount.map(ht).filter(O);n.$$.on_destroy?n.$$.on_destroy.push(...r):z(r),n.$$.on_mount=[]}),a.forEach(W)}function wt(n,t){const e=n.$$;e.fragment!==null&&(qt(e.after_update),z(e.on_destroy),e.fragment&&e.fragment.d(t),e.on_destroy=e.fragment=null,e.ctx=[])}function Qt(n,t){n.$$.dirty[0]===-1&&(P.push(n),Ut(),n.$$.dirty.fill(0)),n.$$.dirty[t/31|0]|=1<<t%31}function Ct(n,t,e,s,a,r,o=null,i=[-1]){const u=X;Z(n);const h=n.$$={fragment:null,ctx:[],props:r,update:q,not_equal:a,bound:at(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(u?u.$$.context:[])),callbacks:at(),dirty:i,skip_bound:!1,root:t.target||u.$$.root};o&&o(h.root);let g=!1;if(h.ctx=e?e(n,t.props||{},(y,D,...d)=>{const p=d.length?d[0]:D;return h.ctx&&a(h.ctx[y],h.ctx[y]=p)&&(!h.skip_bound&&h.bound[y]&&h.bound[y](p),g&&Qt(n,y)),D}):[],h.update(),g=!0,z(h.before_update),h.fragment=s?s(h.ctx):!1,t.target){if(t.hydrate){const y=Vt(t.target);h.fragment&&h.fragment.l(y),y.forEach(R)}else h.fragment&&h.fragment.c();t.intro&&Y(n.$$.fragment),mt(n,t.target,t.anchor),gt()}Z(u)}class vt{constructor(){st(this,"$$"),st(this,"$$set")}$destroy(){wt(this,1),this.$destroy=q}$on(t,e){if(!O(e))return q;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(e),()=>{const a=s.indexOf(e);a!==-1&&s.splice(a,1)}}$set(t){this.$$set&&!Gt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Xt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Xt);function Yt(n){let t,e,s,a=(n[1]||"标题")+"",r,o,i,u,h,g,y=(n[4]||"取消")+"",D,d,p,f=(n[5]||"确认")+"",v,w,m,k;const A=n[7].default,C=Ft(A,n,n[6],null);return{c(){t=I("div"),e=I("div"),s=I("div"),r=E(a),o=N(),i=I("div"),C&&C.c(),u=N(),h=I("div"),g=I("button"),D=E(y),d=N(),p=I("button"),v=E(f),S(s,"class","model-title svelte-n1zwga"),S(i,"class","slot svelte-n1zwga"),S(g,"class","modal-btn svelte-n1zwga"),S(p,"class","modal-btn success svelte-n1zwga"),S(h,"class","modal-footer svelte-n1zwga"),S(e,"class","modal-content svelte-n1zwga"),S(t,"class","modal-background modal-visible svelte-n1zwga")},m($,_){Q($,t,_),x(t,e),x(e,s),x(s,r),x(e,o),x(e,i),C&&C.m(i,null),x(e,u),x(e,h),x(h,g),x(g,D),x(h,d),x(h,p),x(p,v),w=!0,m||(k=[j(g,"click",function(){O(n[0])&&n[0].apply(this,arguments)}),j(p,"click",function(){O(n[2])&&n[2].apply(this,arguments)}),j(e,"click",te),j(t,"click",function(){O(n[3])&&n[3].apply(this,arguments)})],m=!0)},p($,[_]){n=$,(!w||_&2)&&a!==(a=(n[1]||"标题")+"")&&T(r,a),C&&C.p&&(!w||_&64)&&Ot(C,A,n,n[6],w?jt(A,n[6],_,null):Nt(n[6]),null),(!w||_&16)&&y!==(y=(n[4]||"取消")+"")&&T(D,y),(!w||_&32)&&f!==(f=(n[5]||"确认")+"")&&T(v,f)},i($){w||(Y(C,$),w=!0)},o($){ft(C,$),w=!1},d($){$&&R(t),C&&C.d($),m=!1,z(k)}}}const te=n=>n.stopPropagation();function ee(n,t,e){let{$$slots:s={},$$scope:a}=t,{onCancel:r}=t,{title:o}=t,{onOk:i}=t,{onClose:u}=t,{cancelText:h}=t,{okText:g}=t;return n.$$set=y=>{"onCancel"in y&&e(0,r=y.onCancel),"title"in y&&e(1,o=y.title),"onOk"in y&&e(2,i=y.onOk),"onClose"in y&&e(3,u=y.onClose),"cancelText"in y&&e(4,h=y.cancelText),"okText"in y&&e(5,g=y.okText),"$$scope"in y&&e(6,a=y.$$scope)},[r,o,i,u,h,g,a,s]}class ne extends vt{constructor(t){super(),Ct(this,t,ee,Yt,yt,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5})}}function lt(n,t,e){const s=n.slice();return s[10]=t[e],s[12]=e,s}function dt(n){let t,e,s=n[10].CN+"",a,r,o,i=n[10].DevClass+"",u,h,g=n[10].sn+"",y,D,d,p,f,v;function w(){return n[9](n[12])}return{c(){t=I("div"),e=I("span"),a=E(s),r=N(),o=I("span"),u=E(i),h=E("("),y=E(g),D=E(")"),d=N(),S(e,"class","svelte-jtc2v4"),S(o,"class","svelte-jtc2v4"),S(t,"class",p=rt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(m,k){Q(m,t,k),x(t,e),x(e,a),x(t,r),x(t,o),x(o,u),x(o,h),x(o,y),x(o,D),x(t,d),f||(v=j(t,"click",w),f=!0)},p(m,k){n=m,k&1&&s!==(s=n[10].CN+"")&&T(a,s),k&1&&i!==(i=n[10].DevClass+"")&&T(u,i),k&1&&g!==(g=n[10].sn+"")&&T(y,g),k&16&&p!==(p=rt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&S(t,"class",p)},d(m){m&&R(t),f=!1,v()}}}function se(n){let t,e=it(n[0]),s=[];for(let a=0;a<e.length;a+=1)s[a]=dt(lt(n,e,a));return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=zt()},m(a,r){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(a,r);Q(a,t,r)},p(a,r){if(r&17){e=it(a[0]);let o;for(o=0;o<e.length;o+=1){const i=lt(a,e,o);s[o]?s[o].p(i,r):(s[o]=dt(i),s[o].c(),s[o].m(t.parentNode,t))}for(;o<s.length;o+=1)s[o].d(1);s.length=e.length}},d(a){a&&R(t),Zt(s,a)}}}function ae(n){let t,e;return t=new ne({props:{onOk:n[6],onClose:n[1],onCancel:n[5],cancelText:n[2],okText:n[3],title:"选择证书",$$slots:{default:[se]},$$scope:{ctx:n}}}),{c(){Wt(t.$$.fragment)},m(s,a){mt(t,s,a),e=!0},p(s,[a]){const r={};a&2&&(r.onClose=s[1]),a&4&&(r.cancelText=s[2]),a&8&&(r.okText=s[3]),a&8209&&(r.$$scope={dirty:a,ctx:s}),t.$set(r)},i(s){e||(Y(t.$$.fragment,s),e=!0)},o(s){ft(t.$$.fragment,s),e=!1},d(s){wt(t,s)}}}function re(n,t,e){let{certList:s=[]}=t,{onCancel:a}=t,{onOk:r}=t,{onClose:o}=t,{cancelText:i=""}=t,{okText:u=""}=t,h=0;const g=()=>{o==null||o()},y=()=>{r==null||r(s[h]),o==null||o()},D=d=>e(4,h=d);return n.$$set=d=>{"certList"in d&&e(0,s=d.certList),"onCancel"in d&&e(7,a=d.onCancel),"onOk"in d&&e(8,r=d.onOk),"onClose"in d&&e(1,o=d.onClose),"cancelText"in d&&e(2,i=d.cancelText),"okText"in d&&e(3,u=d.okText)},[s,o,i,u,h,g,y,a,r,D]}class oe extends vt{constructor(t){super(),Ct(this,t,re,ae,yt,{certList:0,onCancel:7,onOk:8,onClose:1,cancelText:2,okText:3})}}class ce{constructor(){c(this,"modalInstance",{current:null});c(this,"open",t=>new Promise((e,s)=>{this.modalInstance.current=new oe({target:document.body,props:B(b({},t),{onCancel:a=>{s()},onOk:a=>{e(a)},onClose:()=>{this.close()}})})}));c(this,"close",()=>{setTimeout(()=>{var t;(t=this.modalInstance.current)==null||t.$destroy()})})}}const ie=new ce;class le{constructor(t){c(this,"socketInstance",null);c(this,"eventBus",new Pt);c(this,"isRememberPin",!1);c(this,"socketEvent");c(this,"pinPolicy");c(this,"socketConfig",null);c(this,"getSocketReadyState",()=>{var t;return(t=this.socketInstance)==null?void 0:t.readyState});c(this,"destroy",()=>{var t;(t=this.socketInstance)==null||t.close()});c(this,"sendMessage",(t,e)=>new Promise((s,a)=>{var o,i;if(((o=this.socketInstance)==null?void 0:o.readyState)!==WebSocket.OPEN){console.log(t),a({errCode:-1,msg:"socket未连接"});return}const r={function:t,args:[e!=null?e:{}]};(i=this.socketInstance)==null||i.send(JSON.stringify(r)),this.eventBus.on(t,u=>{u.success?s(u.data):a(u)})}));c(this,"handleEventData",t=>l(this,null,function*(){var e,s,a,r,o,i;if(t.data instanceof Blob){const u=yield t.data.arrayBuffer(),g=new TextDecoder("gbk").decode(u),y=JSON.parse(g),D={data:y.data,success:(e=y.result)==null?void 0:e.success,msg:(s=y.result)==null?void 0:s.msg,errCode:(a=y.result)==null?void 0:a.errCode};this.eventBus.emit((r=y.result)==null?void 0:r.function,D),(i=(o=this.socketConfig)==null?void 0:o.onMessage)==null||i.call(o,D)}}));c(this,"base64Encode",t=>{const e=new TextEncoder().encode(t);return nt.fromByteArray(e)});c(this,"base64Decode",t=>{const e=nt.toByteArray(t);return new TextDecoder().decode(e)});c(this,"changeIsRememberPin",t=>l(this,null,function*(){this.isRememberPin=t}));c(this,"changePinPolicy",t=>l(this,null,function*(){this.pinPolicy=t}));c(this,"checkCertIsLogin",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",t)}));c(this,"addUkeyEvents",()=>l(this,null,function*(){this.sendMessage("GZCA_StartListen",{Type:Et}).then(t=>{var e,s;(s=(e=this.socketConfig)==null?void 0:e.onUkeyEvent)==null||s.call(e,t)})}));c(this,"certLogin",t=>l(this,null,function*(){const e=yield this.checkCertIsLogin({ContainerName:t});e!=null&&e[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:t,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));c(this,"getCert",(t,e)=>l(this,null,function*(){const s=e!=null?e:yield this.chooseCert(t);return yield this.certLogin(s.ContainerName),s}));c(this,"getCertList",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",t)}));c(this,"chooseCert",t=>l(this,null,function*(){const e=yield this.getCertList(t);return(e==null?void 0:e.length)===1?e[0]:yield ie.open({certList:e})}));c(this,"pkcs1Sign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",B(b({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1Base64Sign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",B(b({},t),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1VerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",t)}));c(this,"pkcs1Base64VerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",t)}));c(this,"getSealList",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",B(b({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm2SignPreprocess1",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",t)}));c(this,"sm2SignPreprocess2",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",t)}));c(this,"pkcs1HashSign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",B(b({},t!=null?t:{}),{IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}))}));c(this,"pkcs1HashVerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",t)}));c(this,"pkcs7Sign",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",B(b({},t),{IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy}))}));c(this,"pkcs7VerifySignature",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",t)}));c(this,"sm3Hash",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashData",t)}));c(this,"sm3HexHash",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",t)}));c(this,"sm3FileHash",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",t)}));c(this,"sm3HashEncryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_HMac",t)}));c(this,"pkcs7Encryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",t)}));c(this,"pkcs7Decryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",B(b({},t),{IsLogin:this.getIsLogin()}))}));c(this,"asymmetricEncryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",t)}));c(this,"asymmetricDecryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",B(b({},t),{IsLogin:this.getIsLogin()}))}));c(this,"sm4Encryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",t)}));c(this,"sm4Decryption",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",t)}));c(this,"getCertInfo",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",t)}));c(this,"getCertInfoByOid",t=>l(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",t)}));var e,s;this.socketConfig=t,this.socketInstance=this.createSocket(t),this.isRememberPin=(e=t.isRememberPin)!=null?e:!1,this.pinPolicy=(s=t.pinPolicy)!=null?s:ut.MIN}createSocket(t){const e=new WebSocket(t.url);return e.onerror=s=>{var a;(a=t.onError)==null||a.call(t,s)},e.onopen=s=>{var a;(a=t.onOpen)==null||a.call(t,s),this.addUkeyEvents()},e.onmessage=s=>{this.handleEventData(s)},e.onclose=s=>{var a;(a=t.onClose)==null||a.call(t,s)},e}getIsLogin(){return this.isRememberPin?"Y":"N"}}const M=class M{constructor(t){c(this,"coreInstance",null);c(this,"gwsConfig",{});c(this,"createGwsCore",t=>{this.gwsConfig=t!=null?t:{},this.coreInstance=new le(B(b({},t!=null?t:{}),{url:St}))});c(this,"appendCertBase64",(t,e=!0)=>l(this,null,function*(){if(t.CertB64)return t;const s=e?yield this.getSignatureCert():yield this.getEncryptionCert();return B(b({},t!=null?t:{}),{CertB64:s==null?void 0:s.CertB64})}));c(this,"destroy",()=>{var t;(t=this.coreInstance)==null||t.destroy(),this.coreInstance=null});c(this,"restart",t=>{this.coreInstance&&this.destroy(),this.gwsConfig=t!=null?t:this.gwsConfig,this.createGwsCore(t)});c(this,"getSocketReadyState",()=>{var t;return(t=this.coreInstance)==null?void 0:t.getSocketReadyState()});c(this,"getSignatureCert",t=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:$t},t)}));c(this,"getEncryptionCert",t=>l(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:It},t)}));c(this,"base64Encode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Encode(t.Data)});c(this,"base64Decode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Decode(t.DataB64)});c(this,"changeIsRememberPin",t=>{var e;(e=this.coreInstance)==null||e.changeIsRememberPin(t)});c(this,"changePinPolicy",t=>{var e;(e=this.coreInstance)==null||e.changePinPolicy(t)});c(this,"pkcs1Sign",(t,e)=>l(this,null,function*(){var r,o,i;const s=yield this.getSignatureCert(e),a=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(B(b({},t!=null?t:{}),{ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:""}));return(i=a==null?void 0:a[0])==null?void 0:i.SignData}));c(this,"pkcs1VerifySignature",t=>l(this,null,function*(){var a;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.pkcs1VerifySignature(e);return Array.isArray(s)}));c(this,"pkcs1Base64Sign",(t,e)=>l(this,null,function*(){var o,i,u,h,g;const s=yield this.getSignatureCert(e),a=(i=t.DataB64)!=null?i:this.base64Encode({Data:(o=t.Data)!=null?o:""}),r=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign({ContainerName:(u=s==null?void 0:s.ContainerName)!=null?u:"",DataB64:a});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs1Base64VerifySignature",t=>l(this,null,function*(){var r,o,i;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t);return!!(yield(i=this.coreInstance)==null?void 0:i.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:e,SignData:s.SignData}))}));c(this,"getSealList",()=>l(this,null,function*(){var s,a;const t=yield this.getSignatureCert(),e=yield(a=this.coreInstance)==null?void 0:a.getSealList({ContainerName:(s=t==null?void 0:t.ContainerName)!=null?s:""});return{cert:t,sealList:e}}));c(this,"sm2SignPreprocess1",t=>l(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t),s=yield(a=this.coreInstance)==null?void 0:a.sm2SignPreprocess1(e);return(r=s==null?void 0:s[0])==null?void 0:r.Z}));c(this,"sm2SignPreprocess2",t=>l(this,null,function*(){var r,o;const e=this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=yield this.appendCertBase64(t),a=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:e});return a==null?void 0:a[0].H}));c(this,"pkcs1HashSign",(t,e)=>l(this,null,function*(){var r,o,i,u;const s=yield this.getSignatureCert(e),a=yield(i=this.coreInstance)==null?void 0:i.pkcs1HashSign({ContainerName:(r=s==null?void 0:s.ContainerName)!=null?r:"",DataB64:t.DataB64,HashAlg:(o=t.HashAlg)!=null?o:"sm3"});return(u=a==null?void 0:a[0])==null?void 0:u.SignData}));c(this,"pkcs1HashVerifySignature",t=>l(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t);return!!(yield(r=this.coreInstance)==null?void 0:r.pkcs1HashVerifySignature(B(b({},e),{HashAlg:(a=e.HashAlg)!=null?a:"sm3"})))}));c(this,"pkcs7Sign",(t,e)=>l(this,null,function*(){var o,i,u,h,g;const s=(i=t.DataB64)!=null?i:this.base64Encode({Data:(o=t.Data)!=null?o:""}),a=yield this.getSignatureCert(e),r=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign({IsDetached:t.IsDetached,ContainerName:(u=a==null?void 0:a.ContainerName)!=null?u:"",DataB64:s});return(g=r==null?void 0:r[0])==null?void 0:g.SignData}));c(this,"pkcs7VerifySignature",t=>l(this,null,function*(){var a,r,o;const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:e,SignData:t.SignData}))}));c(this,"sm3Hash",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HexHash",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3FileHash",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(t);return(a=e==null?void 0:e[0])==null?void 0:a.HashB64}));c(this,"sm3HashEncryption",t=>l(this,null,function*(){var r,o,i,u,h,g;const e=(o=t.DataB64)!=null?o:this.base64Encode({Data:(r=t.Data)!=null?r:""}),s=(u=t.KeyB64)!=null?u:this.base64Encode({Data:(i=t.Key)!=null?i:""}),a=yield(h=this.coreInstance)==null?void 0:h.sm3HashEncryption({dataB64:e,keyB64:s,alg:"sm3"});return(g=a==null?void 0:a[0])==null?void 0:g.DataB64}));c(this,"pkcs7Encryption",t=>l(this,null,function*(){var a,r,o,i;if(!t.CertB64List){const u=yield this.getEncryptionCert();t.CertB64List=u==null?void 0:u.CertB64}const e=(r=t.DataB64)!=null?r:this.base64Encode({Data:(a=t.Data)!=null?a:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:e,CertB64List:t.CertB64List});return(i=s==null?void 0:s[0])==null?void 0:i.DataB64}));c(this,"pkcs7Decryption",t=>l(this,null,function*(){var r,o;const e=yield this.getEncryptionCert(),s=yield(r=this.coreInstance)==null?void 0:r.pkcs7Decryption({DataB64:t.DataB64,ContainerName:e==null?void 0:e.ContainerName}),a=(o=s==null?void 0:s[0])==null?void 0:o.DataB64;return t.shouldDecodeBase64?this.base64Decode({DataB64:a}):a}));c(this,"asymmetricEncryption",t=>l(this,null,function*(){var a,r;const e=yield this.appendCertBase64(t,!1),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricEncryption(e);return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"asymmetricDecryption",t=>l(this,null,function*(){var a,r;const e=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.asymmetricDecryption({Data:t.Data,ContainerName:e==null?void 0:e.ContainerName});return(r=s==null?void 0:s[0])==null?void 0:r.Data}));c(this,"sm4Encryption",t=>l(this,null,function*(){var s;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Encryption(t);return e==null?void 0:e[0]}));c(this,"sm4Decryption",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.sm4Decryption(t);return(a=e==null?void 0:e[0])==null?void 0:a.Data}));c(this,"getCertInfo",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfo(t);return b({},(a=e==null?void 0:e[0])!=null?a:{})}));c(this,"getCertInfoByOid",t=>l(this,null,function*(){var s,a;const e=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid(b({},t!=null?t:{}));return(a=e==null?void 0:e[0])==null?void 0:a.OidValue}));return M.instance&&!(t!=null&&t.isCreateNew)?M.instance:(this.createGwsCore(t),M.instance=this,this)}};c(M,"instance",null);let G=M;function de(n){return new Promise((t,e)=>{if(G.instance&&!(n!=null&&n.isCreateNew))t(G.instance);else{const s=new G(B(b({},n!=null?n:{}),{onOpen(a){var r;t(s),(r=n==null?void 0:n.onOpen)==null||r.call(n,a)},onClose(a){var r;e(a),(r=n==null?void 0:n.onClose)==null||r.call(n,a)}}))}})}exports.GwsService=G;exports.createService=de;
|
|
1
|
+
"use strict";var De=Object.defineProperty,be=Object.defineProperties;var Be=Object.getOwnPropertyDescriptors;var ee=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable;var J=(n,e,t)=>e in n?De(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,B=(n,e)=>{for(var t in e||(e={}))Se.call(e,t)&&J(n,t,e[t]);if(ee)for(var t of ee(e))xe.call(e,t)&&J(n,t,e[t]);return n},_=(n,e)=>be(n,Be(e));var i=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);var u=(n,e,t)=>new Promise((s,r)=>{var a=d=>{try{l(t.next(d))}catch(h){r(h)}},o=d=>{try{l(t.throw(d))}catch(h){r(h)}},l=d=>d.done?s(d.value):Promise.resolve(d.value).then(a,o);l((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",Ie="1",Ae="2";var he=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(he||{});const Ee="00000001";function _e(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var F={},te;function Le(){if(te)return F;te=1,F.byteLength=l,F.toByteArray=h,F.fromByteArray=g;for(var n=[],e=[],t=typeof Uint8Array!="undefined"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,a=s.length;r<a;++r)n[r]=s[r],e[s.charCodeAt(r)]=r;e[45]=62,e[95]=63;function o(y){var c=y.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var m=y.indexOf("=");m===-1&&(m=c);var k=m===c?0:4-m%4;return[m,k]}function l(y){var c=o(y),m=c[0],k=c[1];return(m+k)*3/4-k}function d(y,c,m){return(c+m)*3/4-m}function h(y){var c,m=o(y),k=m[0],C=m[1],v=new t(d(y,k,C)),D=0,A=C>0?k-4:k,w;for(w=0;w<A;w+=4)c=e[y.charCodeAt(w)]<<18|e[y.charCodeAt(w+1)]<<12|e[y.charCodeAt(w+2)]<<6|e[y.charCodeAt(w+3)],v[D++]=c>>16&255,v[D++]=c>>8&255,v[D++]=c&255;return C===2&&(c=e[y.charCodeAt(w)]<<2|e[y.charCodeAt(w+1)]>>4,v[D++]=c&255),C===1&&(c=e[y.charCodeAt(w)]<<10|e[y.charCodeAt(w+1)]<<4|e[y.charCodeAt(w+2)]>>2,v[D++]=c>>8&255,v[D++]=c&255),v}function f(y){return n[y>>18&63]+n[y>>12&63]+n[y>>6&63]+n[y&63]}function p(y,c,m){for(var k,C=[],v=c;v<m;v+=3)k=(y[v]<<16&16711680)+(y[v+1]<<8&65280)+(y[v+2]&255),C.push(f(k));return C.join("")}function g(y){for(var c,m=y.length,k=m%3,C=[],v=16383,D=0,A=m-k;D<A;D+=v)C.push(p(y,D,D+v>A?A:D+v));return k===1?(c=y[m-1],C.push(n[c>>2]+n[c<<4&63]+"==")):k===2&&(c=(y[m-2]<<8)+y[m-1],C.push(n[c>>10]+n[c>>4&63]+n[c<<2&63]+"=")),C.join("")}return F}var Pe=Le();const ne=_e(Pe);class Me{constructor(){i(this,"deps",new Map)}on(e,t){this.deps.set(e,t)}emit(e,t){const s=this.deps.get(e);s&&s(t)}}(function(){try{var n=document.createElement("style");n.appendChild(document.createTextNode("button.svelte-oivou{background-color:transparent;border:none;padding:0;margin:0;font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;outline:none}.modal-background.svelte-oivou{display:none;position:fixed;z-index:10000;left:0;top:0;width:100%;height:100%;background-color:#00000080;align-items:center;justify-content:center}.modal-content.svelte-oivou{background-color:#fff;padding:1.42857rem;border-radius:.35714rem;width:40%}.model-title.svelte-oivou{color:#303133;font-size:1.28571rem;margin-bottom:1.14286rem}.modal-visible.svelte-oivou{display:flex}.modal-footer.svelte-oivou{display:flex;align-items:center;justify-content:flex-end;margin-top:1.14286rem}.modal-btn.svelte-oivou{padding:.57143rem 1.07143rem;border-radius:.28571rem;font-size:1rem;border:.07143rem solid #dcdfe6}.success.svelte-oivou{margin-left:.85714rem;color:#fff}.slot.svelte-oivou{max-height:14.28571rem;overflow-y:scroll}.slot.svelte-oivou::-webkit-scrollbar{display:none}.cert-item.svelte-jtc2v4.svelte-jtc2v4{padding:1.14286rem;display:flex;align-items:center;cursor:pointer;border-bottom:.07143rem solid #ebeef5;font-size:1rem}.cert-item-selected.svelte-jtc2v4.svelte-jtc2v4{background-color:#f1f1f1}.cert-item-first.svelte-jtc2v4.svelte-jtc2v4{border-top:.07143rem solid #ebeef5}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4{display:inline-block;color:#606266}.cert-item.svelte-jtc2v4 span.svelte-jtc2v4:first-child{width:30%}.seal-wrapper.svelte-1w19fs3.svelte-1w19fs3{display:flex;flex-direction:row;align-items:center;flex-wrap:wrap}.seal-item.svelte-1w19fs3.svelte-1w19fs3{width:12.85714rem;height:12.85714rem;display:flex;flex-direction:column;align-items:center;justify-content:center;border:.07143rem solid #ccc;margin-top:.71429rem;margin-right:.71429rem;border-radius:.28571rem}.seal-item.svelte-1w19fs3 img.svelte-1w19fs3{width:7.14286rem;height:7.14286rem}.seal-item-selected.svelte-1w19fs3.svelte-1w19fs3{background-color:#f1f1f1}.seal-name.svelte-1w19fs3.svelte-1w19fs3{margin-top:.71429rem;color:#333}")),document.head.appendChild(n)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Te=Object.defineProperty,He=(n,e,t)=>e in n?Te(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,se=(n,e,t)=>He(n,typeof e!="symbol"?e+"":e,t);function q(){}function Ge(n,e){for(const t in e)n[t]=e[t];return n}function ye(n){return n()}function re(){return Object.create(null)}function V(n){n.forEach(ye)}function O(n){return typeof n=="function"}function fe(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}function Fe(n){return Object.keys(n).length===0}function je(n,e,t,s){if(n){const r=ge(n,e,t,s);return n[0](r)}}function ge(n,e,t,s){return n[1]&&s?Ge(t.ctx.slice(),n[1](s(e))):t.ctx}function Oe(n,e,t,s){if(n[2]&&s){const r=n[2](s(t));if(e.dirty===void 0)return r;if(typeof r=="object"){const a=[],o=Math.max(e.dirty.length,r.length);for(let l=0;l<o;l+=1)a[l]=e.dirty[l]|r[l];return a}return e.dirty|r}return e.dirty}function Ne(n,e,t,s,r,a){if(r){const o=ge(e,t,s,a);n.p(o,r)}}function Ze(n){if(n.ctx.length>32){const e=[],t=n.ctx.length/32;for(let s=0;s<t;s++)e[s]=-1;return e}return-1}function ae(n){return n!=null?n:""}function b(n,e){n.appendChild(e)}function Q(n,e,t){n.insertBefore(e,t||null)}function U(n){n.parentNode&&n.parentNode.removeChild(n)}function Ve(n,e){for(let t=0;t<n.length;t+=1)n[t]&&n[t].d(e)}function $(n){return document.createElement(n)}function I(n){return document.createTextNode(n)}function N(){return I(" ")}function Re(){return I("")}function j(n,e,t,s){return n.addEventListener(e,t,s),()=>n.removeEventListener(e,t,s)}function S(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function Ue(n){return Array.from(n.childNodes)}function T(n,e){e=""+e,n.data!==e&&(n.data=e)}function oe(n,e,t,s){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,"")}let X;function Z(n){X=n}const P=[],ie=[];let H=[];const ce=[],Je=Promise.resolve();let K=!1;function ze(){K||(K=!0,Je.then(pe))}function W(n){H.push(n)}const z=new Set;let L=0;function pe(){if(L!==0)return;const n=X;do{try{for(;L<P.length;){const e=P[L];L++,Z(e),qe(e.$$)}}catch(e){throw P.length=0,L=0,e}for(Z(null),P.length=0,L=0;ie.length;)ie.pop()();for(let e=0;e<H.length;e+=1){const t=H[e];z.has(t)||(z.add(t),t())}H.length=0}while(P.length);for(;ce.length;)ce.pop()();K=!1,z.clear(),Z(n)}function qe(n){if(n.fragment!==null){n.update(),V(n.before_update);const e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(W)}}function Ke(n){const e=[],t=[];H.forEach(s=>n.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),H=e}const R=new Set;let We;function Y(n,e){n&&n.i&&(R.delete(n),n.i(e))}function me(n,e,t,s){if(n&&n.o){if(R.has(n))return;R.add(n),We.c.push(()=>{R.delete(n)}),n.o(e)}}function le(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Qe(n){n&&n.c()}function ve(n,e,t){const{fragment:s,after_update:r}=n.$$;s&&s.m(e,t),W(()=>{const a=n.$$.on_mount.map(ye).filter(O);n.$$.on_destroy?n.$$.on_destroy.push(...a):V(a),n.$$.on_mount=[]}),r.forEach(W)}function Ce(n,e){const t=n.$$;t.fragment!==null&&(Ke(t.after_update),V(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Xe(n,e){n.$$.dirty[0]===-1&&(P.push(n),ze(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<<e%31}function we(n,e,t,s,r,a,o=null,l=[-1]){const d=X;Z(n);const h=n.$$={fragment:null,ctx:[],props:a,update:q,not_equal:r,bound:re(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(d?d.$$.context:[])),callbacks:re(),dirty:l,skip_bound:!1,root:e.target||d.$$.root};o&&o(h.root);let f=!1;if(h.ctx=t?t(n,e.props||{},(p,g,...y)=>{const c=y.length?y[0]:g;return h.ctx&&r(h.ctx[p],h.ctx[p]=c)&&(!h.skip_bound&&h.bound[p]&&h.bound[p](c),f&&Xe(n,p)),g}):[],h.update(),f=!0,V(h.before_update),h.fragment=s?s(h.ctx):!1,e.target){if(e.hydrate){const p=Ue(e.target);h.fragment&&h.fragment.l(p),p.forEach(U)}else h.fragment&&h.fragment.c();e.intro&&Y(n.$$.fragment),ve(n,e.target,e.anchor),pe()}Z(d)}class ke{constructor(){se(this,"$$"),se(this,"$$set")}$destroy(){Ce(this,1),this.$destroy=q}$on(e,t){if(!O(t))return q;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}$set(e){this.$$set&&!Fe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ye="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Ye);function et(n){let e,t,s,r=(n[1]||"标题")+"",a,o,l,d,h,f,p=(n[4]||"取消")+"",g,y,c,m=(n[5]||"确认")+"",k,C,v,D;const A=n[8].default,w=je(A,n,n[7],null);return{c(){e=$("div"),t=$("div"),s=$("div"),a=I(r),o=N(),l=$("div"),w&&w.c(),d=N(),h=$("div"),f=$("button"),g=I(p),y=N(),c=$("button"),k=I(m),S(s,"class","model-title svelte-oivou"),S(l,"class","slot svelte-oivou"),S(f,"class","modal-btn svelte-oivou"),S(c,"class","modal-btn success svelte-oivou"),oe(c,"background-color",n[6]),S(h,"class","modal-footer svelte-oivou"),S(t,"class","modal-content svelte-oivou"),S(e,"class","modal-background modal-visible svelte-oivou")},m(x,E){Q(x,e,E),b(e,t),b(t,s),b(s,a),b(t,o),b(t,l),w&&w.m(l,null),b(t,d),b(t,h),b(h,f),b(f,g),b(h,y),b(h,c),b(c,k),C=!0,v||(D=[j(f,"click",function(){O(n[0])&&n[0].apply(this,arguments)}),j(c,"click",function(){O(n[2])&&n[2].apply(this,arguments)}),j(t,"click",tt),j(e,"click",function(){O(n[3])&&n[3].apply(this,arguments)})],v=!0)},p(x,[E]){n=x,(!C||E&2)&&r!==(r=(n[1]||"标题")+"")&&T(a,r),w&&w.p&&(!C||E&128)&&Ne(w,A,n,n[7],C?Oe(A,n[7],E,null):Ze(n[7]),null),(!C||E&16)&&p!==(p=(n[4]||"取消")+"")&&T(g,p),(!C||E&32)&&m!==(m=(n[5]||"确认")+"")&&T(k,m),(!C||E&64)&&oe(c,"background-color",n[6])},i(x){C||(Y(w,x),C=!0)},o(x){me(w,x),C=!1},d(x){x&&U(e),w&&w.d(x),v=!1,V(D)}}}const tt=n=>n.stopPropagation();function nt(n,e,t){let{$$slots:s={},$$scope:r}=e,{onCancel:a}=e,{title:o}=e,{onOk:l}=e,{onClose:d}=e,{cancelText:h}=e,{okText:f}=e,{theme:p}=e;return n.$$set=g=>{"onCancel"in g&&t(0,a=g.onCancel),"title"in g&&t(1,o=g.title),"onOk"in g&&t(2,l=g.onOk),"onClose"in g&&t(3,d=g.onClose),"cancelText"in g&&t(4,h=g.cancelText),"okText"in g&&t(5,f=g.okText),"theme"in g&&t(6,p=g.theme),"$$scope"in g&&t(7,r=g.$$scope)},[a,o,l,d,h,f,p,r,s]}class st extends ke{constructor(e){super(),we(this,e,nt,et,fe,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5,theme:6})}}function ue(n,e,t){const s=n.slice();return s[11]=e[t],s[13]=t,s}function de(n){let e,t,s=n[11].CN+"",r,a,o,l=n[11].DevClass+"",d,h,f=n[11].sn+"",p,g,y,c,m,k;function C(){return n[10](n[13])}return{c(){e=$("div"),t=$("span"),r=I(s),a=N(),o=$("span"),d=I(l),h=I("("),p=I(f),g=I(")"),y=N(),S(t,"class","svelte-jtc2v4"),S(o,"class","svelte-jtc2v4"),S(e,"class",c=ae(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m(v,D){Q(v,e,D),b(e,t),b(t,r),b(e,a),b(e,o),b(o,d),b(o,h),b(o,p),b(o,g),b(e,y),m||(k=j(e,"click",C),m=!0)},p(v,D){n=v,D&1&&s!==(s=n[11].CN+"")&&T(r,s),D&1&&l!==(l=n[11].DevClass+"")&&T(d,l),D&1&&f!==(f=n[11].sn+"")&&T(p,f),D&32&&c!==(c=ae(`cert-item ${n[13]===0?"cert-item-first":""} ${n[13]===n[5]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&S(e,"class",c)},d(v){v&&U(e),m=!1,k()}}}function rt(n){let e,t=le(n[0]),s=[];for(let r=0;r<t.length;r+=1)s[r]=de(ue(n,t,r));return{c(){for(let r=0;r<s.length;r+=1)s[r].c();e=Re()},m(r,a){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(r,a);Q(r,e,a)},p(r,a){if(a&33){t=le(r[0]);let o;for(o=0;o<t.length;o+=1){const l=ue(r,t,o);s[o]?s[o].p(l,a):(s[o]=de(l),s[o].c(),s[o].m(e.parentNode,e))}for(;o<s.length;o+=1)s[o].d(1);s.length=t.length}},d(r){r&&U(e),Ve(s,r)}}}function at(n){let e,t;return e=new st({props:{onOk:n[7],onClose:n[1],onCancel:n[6],cancelText:n[2],okText:n[3],title:"选择证书",theme:n[4],$$slots:{default:[rt]},$$scope:{ctx:n}}}),{c(){Qe(e.$$.fragment)},m(s,r){ve(e,s,r),t=!0},p(s,[r]){const a={};r&2&&(a.onClose=s[1]),r&4&&(a.cancelText=s[2]),r&8&&(a.okText=s[3]),r&16&&(a.theme=s[4]),r&16417&&(a.$$scope={dirty:r,ctx:s}),e.$set(a)},i(s){t||(Y(e.$$.fragment,s),t=!0)},o(s){me(e.$$.fragment,s),t=!1},d(s){Ce(e,s)}}}function ot(n,e,t){let{certList:s=[]}=e,{onCancel:r}=e,{onOk:a}=e,{onClose:o}=e,{cancelText:l=""}=e,{okText:d=""}=e,{theme:h="#409eff"}=e,f=0;const p=()=>{r("未选择证书"),o==null||o()},g=()=>{a==null||a(s[f]),o==null||o()},y=c=>t(5,f=c);return n.$$set=c=>{"certList"in c&&t(0,s=c.certList),"onCancel"in c&&t(8,r=c.onCancel),"onOk"in c&&t(9,a=c.onOk),"onClose"in c&&t(1,o=c.onClose),"cancelText"in c&&t(2,l=c.cancelText),"okText"in c&&t(3,d=c.okText),"theme"in c&&t(4,h=c.theme)},[s,o,l,d,h,f,p,g,r,a,y]}class it extends ke{constructor(e){super(),we(this,e,ot,at,fe,{certList:0,onCancel:8,onOk:9,onClose:1,cancelText:2,okText:3,theme:4})}}class ct{constructor(){i(this,"modalInstance",{current:null});i(this,"open",e=>new Promise((t,s)=>{this.modalInstance.current=new it({target:document.body,props:_(B({},e),{onCancel:r=>{s({code:-1,msg:r})},onOk:r=>{t(r)},onClose:()=>{this.close()}})})}));i(this,"close",()=>{setTimeout(()=>{var e;(e=this.modalInstance.current)==null||e.$destroy()})})}}const lt=new ct;class ut{constructor(e){i(this,"socketInstance",null);i(this,"eventBus",new Me);i(this,"isRememberPin",!1);i(this,"socketEvent");i(this,"pinPolicy");i(this,"socketConfig",null);i(this,"getSocketReadyState",()=>{var e;return(e=this.socketInstance)==null?void 0:e.readyState});i(this,"destroy",()=>{var e;(e=this.socketInstance)==null||e.close()});i(this,"sendMessage",(e,t)=>new Promise((s,r)=>{var o,l;if(((o=this.socketInstance)==null?void 0:o.readyState)!==WebSocket.OPEN){console.log(e),r({errCode:-1,msg:"socket未连接"});return}const a={function:e,args:[t!=null?t:{}]};(l=this.socketInstance)==null||l.send(JSON.stringify(a)),this.eventBus.on(e,d=>{d.success?s(d.data):r(d)})}));i(this,"handleEventData",e=>u(this,null,function*(){var t,s,r,a,o,l;if(e.data instanceof Blob){const d=yield e.data.arrayBuffer(),f=new TextDecoder("gbk").decode(d),p=JSON.parse(f),g={data:p.data,success:(t=p.result)==null?void 0:t.success,msg:(s=p.result)==null?void 0:s.msg,errCode:(r=p.result)==null?void 0:r.errCode};this.eventBus.emit((a=p.result)==null?void 0:a.function,g),(l=(o=this.socketConfig)==null?void 0:o.onMessage)==null||l.call(o,g)}}));i(this,"base64Encode",e=>{const t=new TextEncoder().encode(e);return ne.fromByteArray(t)});i(this,"base64Decode",e=>{const t=ne.toByteArray(e);return new TextDecoder().decode(t)});i(this,"changeIsRememberPin",e=>u(this,null,function*(){this.isRememberPin=e}));i(this,"changePinPolicy",e=>u(this,null,function*(){this.pinPolicy=e}));i(this,"checkCertIsLogin",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_IsLogin",e)}));i(this,"addUkeyEvents",()=>u(this,null,function*(){this.sendMessage("GZCA_StartListen",{Type:Ee}).then(e=>{var t,s;(s=(t=this.socketConfig)==null?void 0:t.onUkeyEvent)==null||s.call(t,e)})}));i(this,"certLogin",e=>u(this,null,function*(){const t=yield this.checkCertIsLogin({ContainerName:e});t!=null&&t[0].isLogin||(yield this.sendMessage("GZCA_Login",{ContainerName:e,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy}))}));i(this,"getCert",(e,t)=>u(this,null,function*(){const s=t!=null?t:yield this.chooseCert(e);return yield this.certLogin(s.ContainerName),s}));i(this,"getCertList",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertList",e)}));i(this,"chooseCert",e=>u(this,null,function*(){var r;const t=yield this.getCertList(e);return(t==null?void 0:t.length)===1?t[0]:yield lt.open({certList:t,theme:(r=this.socketConfig)==null?void 0:r.theme})}));i(this,"pkcs1Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignData",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1Base64Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataEx",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySign",e)}));i(this,"pkcs1Base64VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignEx",e)}));i(this,"getSealList",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_EnumSeals",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm2SignPreprocess1",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep1",e)}));i(this,"sm2SignPreprocess2",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_PrepareSm2SignStep2",e)}));i(this,"pkcs1HashSign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1SignDataForHash",B({IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs1HashVerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs1VerifySignForHash",e)}));i(this,"pkcs7Sign",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7SignData",B({IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy},e!=null?e:{}))}));i(this,"pkcs7VerifySignature",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7VerifySign",e)}));i(this,"sm3Hash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashData",e)}));i(this,"sm3HexHash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashDataEx",e)}));i(this,"sm3FileHash",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HashFile",e)}));i(this,"sm3HashEncryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_HMac",e)}));i(this,"pkcs7Encryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7EncryptData",e)}));i(this,"pkcs7Decryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_Pkcs7DecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"asymmetricEncryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_AsymEncryptData",e)}));i(this,"asymmetricDecryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_AsymDecryptData",B({IsLogin:this.getIsLogin()},e!=null?e:{}))}));i(this,"sm4Encryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_EncryptDataEx",e)}));i(this,"sm4Decryption",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_DecryptDataEx",e)}));i(this,"getCertInfo",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfo",e)}));i(this,"getCertInfoByOid",e=>u(this,null,function*(){return yield this.sendMessage("GZCA_GetCertInfoByOid",e)}));var t,s;this.socketConfig=e,this.socketInstance=this.createSocket(e),this.isRememberPin=(t=e.isRememberPin)!=null?t:!1,this.pinPolicy=(s=e.pinPolicy)!=null?s:he.MIN}createSocket(e){const t=new WebSocket(e.url);return t.onerror=s=>{var r;(r=e.onError)==null||r.call(e,s)},t.onopen=s=>{var r;(r=e.onOpen)==null||r.call(e,s),this.addUkeyEvents()},t.onmessage=s=>{this.handleEventData(s)},t.onclose=s=>{var r;(r=e.onClose)==null||r.call(e,s)},t}getIsLogin(){return this.isRememberPin?"Y":"N"}}const M=class M{constructor(e){i(this,"coreInstance",null);i(this,"gwsConfig",{});i(this,"createGwsCore",e=>{this.gwsConfig=e!=null?e:{},this.coreInstance=new ut(_(B({},e!=null?e:{}),{url:$e}))});i(this,"appendCertBase64",(e,t=!0)=>u(this,null,function*(){if(e.CertB64)return e;const s=t?yield this.getSignatureCert():yield this.getEncryptionCert();return _(B({},e!=null?e:{}),{CertB64:s==null?void 0:s.CertB64})}));i(this,"destroy",()=>{var e;(e=this.coreInstance)==null||e.destroy(),this.coreInstance=null});i(this,"restart",e=>{this.coreInstance&&this.destroy(),this.gwsConfig=e!=null?e:this.gwsConfig,this.createGwsCore(e)});i(this,"getSocketReadyState",()=>{var e;return(e=this.coreInstance)==null?void 0:e.getSocketReadyState()});i(this,"getSignatureCert",e=>u(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:Ie},e)}));i(this,"getEncryptionCert",e=>u(this,null,function*(){var s;return yield(s=this.coreInstance)==null?void 0:s.getCert({CertType:Ae},e)}));i(this,"base64Encode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Encode(e.Data)});i(this,"base64Decode",e=>{var t;return(t=this.coreInstance)==null?void 0:t.base64Decode(e.DataB64)});i(this,"changeIsRememberPin",e=>{var t;(t=this.coreInstance)==null||t.changeIsRememberPin(e)});i(this,"changePinPolicy",e=>{var t;(t=this.coreInstance)==null||t.changePinPolicy(e)});i(this,"pkcs1Sign",(e,t)=>u(this,null,function*(){var a,o,l;const s=yield this.getSignatureCert(t),r=yield(o=this.coreInstance)==null?void 0:o.pkcs1Sign(_(B({},e!=null?e:{}),{ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:""}));return(l=r==null?void 0:r[0])==null?void 0:l.SignData}));i(this,"pkcs1VerifySignature",e=>u(this,null,function*(){var r;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.pkcs1VerifySignature(t);return Array.isArray(s)}));i(this,"pkcs1Base64Sign",(e,t)=>u(this,null,function*(){var o,l,d,h,f;const s=yield this.getSignatureCert(t),r=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),a=yield(h=this.coreInstance)==null?void 0:h.pkcs1Base64Sign({ContainerName:(d=s==null?void 0:s.ContainerName)!=null?d:"",DataB64:r});return(f=a==null?void 0:a[0])==null?void 0:f.SignData}));i(this,"pkcs1Base64VerifySignature",e=>u(this,null,function*(){var a,o,l;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e);return!!(yield(l=this.coreInstance)==null?void 0:l.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:t,SignData:s.SignData}))}));i(this,"getSealList",()=>u(this,null,function*(){var s,r;const e=yield this.getSignatureCert(),t=yield(r=this.coreInstance)==null?void 0:r.getSealList({ContainerName:(s=e==null?void 0:e.ContainerName)!=null?s:""});return{cert:e,sealList:t}}));i(this,"sm2SignPreprocess1",e=>u(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e),s=yield(r=this.coreInstance)==null?void 0:r.sm2SignPreprocess1(t);return(a=s==null?void 0:s[0])==null?void 0:a.Z}));i(this,"sm2SignPreprocess2",e=>u(this,null,function*(){var a,o;const t=this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=yield this.appendCertBase64(e),r=yield(o=this.coreInstance)==null?void 0:o.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:t});return r==null?void 0:r[0].H}));i(this,"pkcs1HashSign",(e,t)=>u(this,null,function*(){var a,o,l,d;const s=yield this.getSignatureCert(t),r=yield(l=this.coreInstance)==null?void 0:l.pkcs1HashSign({ContainerName:(a=s==null?void 0:s.ContainerName)!=null?a:"",DataB64:e.DataB64,HashAlg:(o=e.HashAlg)!=null?o:"sm3"});return(d=r==null?void 0:r[0])==null?void 0:d.SignData}));i(this,"pkcs1HashVerifySignature",e=>u(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e);return!!(yield(a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature(_(B({},t),{HashAlg:(r=t.HashAlg)!=null?r:"sm3"})))}));i(this,"pkcs7Sign",(e,t)=>u(this,null,function*(){var o,l,d,h,f;const s=(l=e.DataB64)!=null?l:this.base64Encode({Data:(o=e.Data)!=null?o:""}),r=yield this.getSignatureCert(t),a=yield(h=this.coreInstance)==null?void 0:h.pkcs7Sign({IsDetached:e.IsDetached,ContainerName:(d=r==null?void 0:r.ContainerName)!=null?d:"",DataB64:s});return(f=a==null?void 0:a[0])==null?void 0:f.SignData}));i(this,"pkcs7VerifySignature",e=>u(this,null,function*(){var r,a,o;const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""});return!!(yield(o=this.coreInstance)==null?void 0:o.pkcs7VerifySignature({DataB64:t,SignData:e.SignData}))}));i(this,"sm3Hash",e=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3Hash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HexHash",e=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3HexHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3FileHash",e=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.sm3FileHash(e);return(r=t==null?void 0:t[0])==null?void 0:r.HashB64}));i(this,"sm3HashEncryption",e=>u(this,null,function*(){var a,o,l,d,h,f;const t=(o=e.DataB64)!=null?o:this.base64Encode({Data:(a=e.Data)!=null?a:""}),s=(d=e.KeyB64)!=null?d:this.base64Encode({Data:(l=e.Key)!=null?l:""}),r=yield(h=this.coreInstance)==null?void 0:h.sm3HashEncryption({dataB64:t,keyB64:s,alg:"sm3"});return(f=r==null?void 0:r[0])==null?void 0:f.DataB64}));i(this,"pkcs7Encryption",e=>u(this,null,function*(){var r,a,o,l;if(!e.CertB64List){const d=yield this.getEncryptionCert();e.CertB64List=d==null?void 0:d.CertB64}const t=(a=e.DataB64)!=null?a:this.base64Encode({Data:(r=e.Data)!=null?r:""}),s=yield(o=this.coreInstance)==null?void 0:o.pkcs7Encryption({DataB64:t,CertB64List:e.CertB64List});return(l=s==null?void 0:s[0])==null?void 0:l.DataB64}));i(this,"pkcs7Decryption",e=>u(this,null,function*(){var a,o;const t=yield this.getEncryptionCert(),s=yield(a=this.coreInstance)==null?void 0:a.pkcs7Decryption({DataB64:e.DataB64,ContainerName:t==null?void 0:t.ContainerName}),r=(o=s==null?void 0:s[0])==null?void 0:o.DataB64;return e.shouldDecodeBase64?this.base64Decode({DataB64:r}):r}));i(this,"asymmetricEncryption",e=>u(this,null,function*(){var r,a;const t=yield this.appendCertBase64(e,!1),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricEncryption(t);return(a=s==null?void 0:s[0])==null?void 0:a.Data}));i(this,"asymmetricDecryption",e=>u(this,null,function*(){var r,a;const t=yield this.getEncryptionCert(),s=yield(r=this.coreInstance)==null?void 0:r.asymmetricDecryption({Data:e.Data,ContainerName:t==null?void 0:t.ContainerName});return(a=s==null?void 0:s[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 B({},(r=t==null?void 0:t[0])!=null?r:{})}));i(this,"getCertInfoByOid",e=>u(this,null,function*(){var s,r;const t=yield(s=this.coreInstance)==null?void 0:s.getCertInfoByOid(B({},e!=null?e:{}));return(r=t==null?void 0:t[0])==null?void 0:r.OidValue}));return M.instance&&!(e!=null&&e.isCreateNew)?M.instance:(this.createGwsCore(e),M.instance=this,this)}};i(M,"instance",null);let G=M;function dt(n){return new Promise((e,t)=>{if(G.instance&&!(n!=null&&n.isCreateNew))e(G.instance);else{const s=new G(_(B({},n!=null?n:{}),{onOpen(r){var a;e(s),(a=n==null?void 0:n.onOpen)==null||a.call(n,r)},onClose(r){var a;t(r),(a=n==null?void 0:n.onClose)==null||a.call(n,r)}}))}})}exports.GwsService=G;exports.createService=dt;
|