gws-client 0.1.11 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare class GwsService {
13
13
  static instance: GwsService | null;
14
14
  private coreInstance;
15
15
  private gwsConfig;
16
- constructor(config?: Record<string, any>);
16
+ constructor(config?: ServiceConfigType);
17
17
  private createGwsCore;
18
18
  private appendCertBase64;
19
19
  destroy: () => void;
@@ -21,8 +21,12 @@ export declare class GwsService {
21
21
  getSocketReadyState: () => number | undefined;
22
22
  getSignatureCert: (cert?: CertType) => Promise<CertType | undefined>;
23
23
  getEncryptionCert: (cert?: CertType) => Promise<CertType | undefined>;
24
- base64Encode: (text: string) => string;
25
- base64Decode: (text: string) => string | undefined;
24
+ base64Encode: (params: {
25
+ Data: string;
26
+ }) => string;
27
+ base64Decode: (params: {
28
+ DataB64: string;
29
+ }) => string;
26
30
  changeIsRememberPin: (bol: boolean) => void;
27
31
  changePinPolicy: (pinPolicy: number) => void;
28
32
  pkcs1Sign: (params: {
@@ -120,4 +124,16 @@ export declare class GwsService {
120
124
  }) => Promise<any>;
121
125
  }
122
126
 
127
+ declare type ServiceConfigType = {
128
+ url?: string;
129
+ pinPolicy?: number;
130
+ isRememberPin?: boolean;
131
+ isCreateNew?: boolean;
132
+ onOpen?: (event: Event) => void;
133
+ onMessage?: (data: Record<string, unknown>) => void;
134
+ onError?: (event: Event) => void;
135
+ onClose?: (event: Event) => void;
136
+ onUkeyEvent?: (data: Record<string, unknown>) => void;
137
+ };
138
+
123
139
  export { }
package/dist/index.es.js CHANGED
@@ -1,16 +1,16 @@
1
1
  var wt = Object.defineProperty;
2
2
  var vt = (n, t, e) => t in n ? wt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
3
  var c = (n, t, e) => vt(n, typeof t != "symbol" ? t + "" : t, e);
4
- const kt = window.location.href.includes("https") ? "wss://localhost:19528" : "ws://localhost:9527", xt = "1", Bt = "2";
4
+ const kt = window.location.href.includes("https") ? "wss://localhost:19528" : "ws://localhost:9527", xt = "1", Dt = "2";
5
5
  var it = /* @__PURE__ */ ((n) => (n[n.MIN = 0] = "MIN", n[n.LOW = 1] = "LOW", n[n.MIDDLE = 2] = "MIDDLE", n[n.HIGH = 3] = "HIGH", n))(it || {});
6
- const St = "00000001";
6
+ const Bt = "00000001";
7
7
  var j = {};
8
8
  j.byteLength = $t;
9
9
  j.toByteArray = At;
10
10
  j.fromByteArray = Lt;
11
- var B = [], m = [], bt = typeof Uint8Array < "u" ? Uint8Array : Array, R = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
12
- for (var E = 0, Dt = R.length; E < Dt; ++E)
13
- B[E] = R[E], m[R.charCodeAt(E)] = E;
11
+ var D = [], m = [], St = typeof Uint8Array < "u" ? Uint8Array : Array, R = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
12
+ for (var E = 0, bt = R.length; E < bt; ++E)
13
+ D[E] = R[E], m[R.charCodeAt(E)] = E;
14
14
  m[45] = 62;
15
15
  m[95] = 63;
16
16
  function lt(n) {
@@ -30,13 +30,13 @@ function It(n, t, e) {
30
30
  return (t + e) * 3 / 4 - e;
31
31
  }
32
32
  function At(n) {
33
- var t, e = lt(n), s = e[0], a = e[1], r = new bt(It(n, s, a)), o = 0, i = a > 0 ? s - 4 : s, d;
33
+ var t, e = lt(n), s = e[0], a = e[1], r = new St(It(n, s, a)), o = 0, i = a > 0 ? s - 4 : s, d;
34
34
  for (d = 0; d < i; d += 4)
35
35
  t = m[n.charCodeAt(d)] << 18 | m[n.charCodeAt(d + 1)] << 12 | m[n.charCodeAt(d + 2)] << 6 | m[n.charCodeAt(d + 3)], r[o++] = t >> 16 & 255, r[o++] = t >> 8 & 255, r[o++] = t & 255;
36
36
  return a === 2 && (t = m[n.charCodeAt(d)] << 2 | m[n.charCodeAt(d + 1)] >> 4, r[o++] = t & 255), a === 1 && (t = m[n.charCodeAt(d)] << 10 | m[n.charCodeAt(d + 1)] << 4 | m[n.charCodeAt(d + 2)] >> 2, r[o++] = t >> 8 & 255, r[o++] = t & 255), r;
37
37
  }
38
38
  function Et(n) {
39
- return B[n >> 18 & 63] + B[n >> 12 & 63] + B[n >> 6 & 63] + B[n & 63];
39
+ return D[n >> 18 & 63] + D[n >> 12 & 63] + D[n >> 6 & 63] + D[n & 63];
40
40
  }
41
41
  function _t(n, t, e) {
42
42
  for (var s, a = [], r = t; r < e; r += 3)
@@ -47,9 +47,9 @@ function Lt(n) {
47
47
  for (var t, e = n.length, s = e % 3, a = [], r = 16383, o = 0, i = e - s; o < i; o += r)
48
48
  a.push(_t(n, o, o + r > i ? i : o + r));
49
49
  return s === 1 ? (t = n[e - 1], a.push(
50
- B[t >> 2] + B[t << 4 & 63] + "=="
50
+ D[t >> 2] + D[t << 4 & 63] + "=="
51
51
  )) : s === 2 && (t = (n[e - 2] << 8) + n[e - 1], a.push(
52
- B[t >> 10] + B[t >> 4 & 63] + B[t << 2 & 63] + "="
52
+ D[t >> 10] + D[t >> 4 & 63] + D[t << 2 & 63] + "="
53
53
  )), a.join("");
54
54
  }
55
55
  class Pt {
@@ -158,14 +158,14 @@ function Ot(n, t) {
158
158
  function x(n) {
159
159
  return document.createElement(n);
160
160
  }
161
- function S(n) {
161
+ function B(n) {
162
162
  return document.createTextNode(n);
163
163
  }
164
164
  function F() {
165
- return S(" ");
165
+ return B(" ");
166
166
  }
167
167
  function zt() {
168
- return S("");
168
+ return B("");
169
169
  }
170
170
  function M(n, t, e, s) {
171
171
  return n.addEventListener(t, e, s), () => n.removeEventListener(t, e, s);
@@ -346,7 +346,7 @@ function Yt(n) {
346
346
  ), f, h, y, $ = (
347
347
  /*okText*/
348
348
  (n[5] || "确认") + ""
349
- ), A, C, b, D;
349
+ ), A, C, S, b;
350
350
  const V = (
351
351
  /*#slots*/
352
352
  n[7].default
@@ -359,10 +359,10 @@ function Yt(n) {
359
359
  );
360
360
  return {
361
361
  c() {
362
- t = x("div"), e = x("div"), s = x("div"), r = S(a), o = F(), i = x("div"), w && w.c(), d = F(), u = x("div"), p = x("button"), f = S(l), h = F(), y = x("button"), A = S($), v(s, "class", "model-title svelte-n1zwga"), v(i, "class", "slot svelte-n1zwga"), v(p, "class", "modal-btn svelte-n1zwga"), v(y, "class", "modal-btn success svelte-n1zwga"), v(u, "class", "modal-footer svelte-n1zwga"), v(e, "class", "modal-content svelte-n1zwga"), v(t, "class", "modal-background modal-visible svelte-n1zwga");
362
+ t = x("div"), e = x("div"), s = x("div"), r = B(a), o = F(), i = x("div"), w && w.c(), d = F(), u = x("div"), p = x("button"), f = B(l), h = F(), y = x("button"), A = B($), v(s, "class", "model-title svelte-n1zwga"), v(i, "class", "slot svelte-n1zwga"), v(p, "class", "modal-btn svelte-n1zwga"), v(y, "class", "modal-btn success svelte-n1zwga"), v(u, "class", "modal-footer svelte-n1zwga"), v(e, "class", "modal-content svelte-n1zwga"), v(t, "class", "modal-background modal-visible svelte-n1zwga");
363
363
  },
364
364
  m(k, I) {
365
- q(k, t, I), g(t, e), g(e, s), g(s, r), g(e, o), g(e, i), w && w.m(i, null), g(e, d), g(e, u), g(u, p), g(p, f), g(u, h), g(u, y), g(y, A), C = !0, b || (D = [
365
+ q(k, t, I), g(t, e), g(e, s), g(s, r), g(e, o), g(e, i), w && w.m(i, null), g(e, d), g(e, u), g(u, p), g(p, f), g(u, h), g(u, y), g(y, A), C = !0, S || (b = [
366
366
  M(p, "click", function() {
367
367
  G(
368
368
  /*onCancel*/
@@ -382,7 +382,7 @@ function Yt(n) {
382
382
  n[3]
383
383
  ) && n[3].apply(this, arguments);
384
384
  })
385
- ], b = !0);
385
+ ], S = !0);
386
386
  },
387
387
  p(k, [I]) {
388
388
  n = k, (!C || I & /*title*/
@@ -418,7 +418,7 @@ function Yt(n) {
418
418
  pt(w, k), C = !1;
419
419
  },
420
420
  d(k) {
421
- k && z(t), w && w.d(k), b = !1, N(D);
421
+ k && z(t), w && w.d(k), S = !1, N(b);
422
422
  }
423
423
  };
424
424
  }
@@ -467,29 +467,29 @@ function ot(n) {
467
467
  }
468
468
  return {
469
469
  c() {
470
- t = x("div"), e = x("span"), a = S(s), r = F(), o = x("span"), d = S(i), u = S("("), l = S(p), f = S(")"), h = F(), v(e, "class", "svelte-jtc2v4"), v(o, "class", "svelte-jtc2v4"), v(t, "class", y = et(`cert-item ${/*index*/
470
+ t = x("div"), e = x("span"), a = B(s), r = F(), o = x("span"), d = B(i), u = B("("), l = B(p), f = B(")"), h = F(), v(e, "class", "svelte-jtc2v4"), v(o, "class", "svelte-jtc2v4"), v(t, "class", y = et(`cert-item ${/*index*/
471
471
  n[12] === 0 ? "cert-item-first" : ""} ${/*index*/
472
472
  n[12] === /*selectedIndex*/
473
473
  n[4] ? "cert-item-selected" : ""}`) + " svelte-jtc2v4");
474
474
  },
475
- m(b, D) {
476
- q(b, t, D), g(t, e), g(e, a), g(t, r), g(t, o), g(o, d), g(o, u), g(o, l), g(o, f), g(t, h), $ || (A = M(t, "click", C), $ = !0);
475
+ m(S, b) {
476
+ q(S, t, b), g(t, e), g(e, a), g(t, r), g(t, o), g(o, d), g(o, u), g(o, l), g(o, f), g(t, h), $ || (A = M(t, "click", C), $ = !0);
477
477
  },
478
- p(b, D) {
479
- n = b, D & /*certList*/
478
+ p(S, b) {
479
+ n = S, b & /*certList*/
480
480
  1 && s !== (s = /*item*/
481
- n[10].CN + "") && H(a, s), D & /*certList*/
481
+ n[10].CN + "") && H(a, s), b & /*certList*/
482
482
  1 && i !== (i = /*item*/
483
- n[10].DevClass + "") && H(d, i), D & /*certList*/
483
+ n[10].DevClass + "") && H(d, i), b & /*certList*/
484
484
  1 && p !== (p = /*item*/
485
- n[10].sn + "") && H(l, p), D & /*selectedIndex*/
485
+ n[10].sn + "") && H(l, p), b & /*selectedIndex*/
486
486
  16 && y !== (y = et(`cert-item ${/*index*/
487
487
  n[12] === 0 ? "cert-item-first" : ""} ${/*index*/
488
488
  n[12] === /*selectedIndex*/
489
489
  n[4] ? "cert-item-selected" : ""}`) + " svelte-jtc2v4") && v(t, "class", y);
490
490
  },
491
- d(b) {
492
- b && z(t), $ = !1, A();
491
+ d(S) {
492
+ S && z(t), $ = !1, A();
493
493
  }
494
494
  };
495
495
  }
@@ -715,7 +715,7 @@ class le {
715
715
  c(this, "checkCertIsLogin", async (t) => await this.sendMessage("GZCA_IsLogin", t));
716
716
  c(this, "addUkeyEvents", async () => {
717
717
  this.sendMessage("GZCA_StartListen", {
718
- Type: St
718
+ Type: Bt
719
719
  }).then((t) => {
720
720
  var e, s;
721
721
  (s = (e = this.socketConfig) == null ? void 0 : e.onUkeyEvent) == null || s.call(e, t);
@@ -852,17 +852,17 @@ const P = class P {
852
852
  c(this, "getEncryptionCert", async (t) => {
853
853
  var s;
854
854
  return await ((s = this.coreInstance) == null ? void 0 : s.getCert(
855
- { CertType: Bt },
855
+ { CertType: Dt },
856
856
  t
857
857
  ));
858
858
  });
859
859
  c(this, "base64Encode", (t) => {
860
860
  var e;
861
- return (e = this.coreInstance) == null ? void 0 : e.base64Encode(t);
861
+ return (e = this.coreInstance) == null ? void 0 : e.base64Encode(t.Data);
862
862
  });
863
863
  c(this, "base64Decode", (t) => {
864
864
  var e;
865
- return (e = this.coreInstance) == null ? void 0 : e.base64Decode(t);
865
+ return (e = this.coreInstance) == null ? void 0 : e.base64Decode(t.DataB64);
866
866
  });
867
867
  c(this, "changeIsRememberPin", (t) => {
868
868
  var e;
@@ -887,7 +887,7 @@ const P = class P {
887
887
  });
888
888
  c(this, "pkcs1Base64Sign", async (t, e) => {
889
889
  var o, i;
890
- const s = await this.getSignatureCert(e), a = t.DataB64 ?? this.base64Encode(t.Data ?? ""), r = await ((o = this.coreInstance) == null ? void 0 : o.pkcs1Base64Sign({
890
+ const s = await this.getSignatureCert(e), a = t.DataB64 ?? this.base64Encode({ Data: t.Data ?? "" }), r = await ((o = this.coreInstance) == null ? void 0 : o.pkcs1Base64Sign({
891
891
  ContainerName: (s == null ? void 0 : s.ContainerName) ?? "",
892
892
  DataB64: a
893
893
  }));
@@ -895,7 +895,7 @@ const P = class P {
895
895
  });
896
896
  c(this, "pkcs1Base64VerifySignature", async (t) => {
897
897
  var r;
898
- const e = t.DataB64 ?? this.base64Encode(t.Data ?? ""), s = await this.appendCertBase64(t);
898
+ const e = t.DataB64 ?? this.base64Encode({ Data: t.Data ?? "" }), s = await this.appendCertBase64(t);
899
899
  return !!await ((r = this.coreInstance) == null ? void 0 : r.pkcs1Base64VerifySignature({
900
900
  CertB64: s.CertB64,
901
901
  DataB64: e,
@@ -919,7 +919,7 @@ const P = class P {
919
919
  });
920
920
  c(this, "sm2SignPreprocess2", async (t) => {
921
921
  var r;
922
- const e = this.base64Encode(t.Data), s = await this.appendCertBase64(t), a = await ((r = this.coreInstance) == null ? void 0 : r.sm2SignPreprocess2({
922
+ const e = this.base64Encode({ Data: t.Data ?? "" }), s = await this.appendCertBase64(t), a = await ((r = this.coreInstance) == null ? void 0 : r.sm2SignPreprocess2({
923
923
  CertB64: s.CertB64,
924
924
  DataB64: e
925
925
  }));
@@ -944,7 +944,7 @@ const P = class P {
944
944
  });
945
945
  c(this, "pkcs7Sign", async (t, e) => {
946
946
  var o, i;
947
- const s = t.DataB64 ?? this.base64Encode(t.Data ?? ""), a = await this.getSignatureCert(e), r = await ((o = this.coreInstance) == null ? void 0 : o.pkcs7Sign({
947
+ const s = t.DataB64 ?? this.base64Encode({ Data: t.Data ?? "" }), a = await this.getSignatureCert(e), r = await ((o = this.coreInstance) == null ? void 0 : o.pkcs7Sign({
948
948
  IsDetached: t.IsDetached,
949
949
  ContainerName: (a == null ? void 0 : a.ContainerName) ?? "",
950
950
  DataB64: s
@@ -953,7 +953,7 @@ const P = class P {
953
953
  });
954
954
  c(this, "pkcs7VerifySignature", async (t) => {
955
955
  var a;
956
- const e = t.DataB64 ?? this.base64Encode(t.Data ?? "");
956
+ const e = t.DataB64 ?? this.base64Encode({ Data: t.Data ?? "" });
957
957
  return !!await ((a = this.coreInstance) == null ? void 0 : a.pkcs7VerifySignature({
958
958
  DataB64: e,
959
959
  SignData: t.SignData
@@ -976,7 +976,7 @@ const P = class P {
976
976
  });
977
977
  c(this, "sm3HashEncryption", async (t) => {
978
978
  var r, o;
979
- const e = t.DataB64 ?? this.base64Encode(t.Data ?? ""), s = t.KeyB64 ?? this.base64Encode(t.Key ?? ""), a = await ((r = this.coreInstance) == null ? void 0 : r.sm3HashEncryption({
979
+ const e = t.DataB64 ?? this.base64Encode({ Data: t.Data ?? "" }), s = t.KeyB64 ?? this.base64Encode({ Data: t.Key ?? "" }), a = await ((r = this.coreInstance) == null ? void 0 : r.sm3HashEncryption({
980
980
  dataB64: e,
981
981
  keyB64: s,
982
982
  alg: "sm3"
@@ -989,7 +989,7 @@ const P = class P {
989
989
  const o = await this.getEncryptionCert();
990
990
  t.CertB64List = o == null ? void 0 : o.CertB64;
991
991
  }
992
- const e = t.DataB64 ?? this.base64Encode(t.Data ?? ""), s = await ((a = this.coreInstance) == null ? void 0 : a.pkcs7Encryption({
992
+ const e = t.DataB64 ?? this.base64Encode({ Data: t.Data ?? "" }), s = await ((a = this.coreInstance) == null ? void 0 : a.pkcs7Encryption({
993
993
  DataB64: e,
994
994
  CertB64List: t.CertB64List
995
995
  }));
@@ -1001,7 +1001,7 @@ const P = class P {
1001
1001
  DataB64: t.DataB64,
1002
1002
  ContainerName: e == null ? void 0 : e.ContainerName
1003
1003
  })), a = (o = s == null ? void 0 : s[0]) == null ? void 0 : o.DataB64;
1004
- return t.shouldDecodeBase64 ? this.base64Decode(a) : a;
1004
+ return t.shouldDecodeBase64 ? this.base64Decode({ DataB64: a }) : a;
1005
1005
  });
1006
1006
  c(this, "asymmetricEncryption", async (t) => {
1007
1007
  var a, r;
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(C,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(C=typeof globalThis<"u"?globalThis:C||self,y(C.GZCA={}))})(this,function(C){"use strict";var le=Object.defineProperty;var de=(C,y,_)=>y in C?le(C,y,{enumerable:!0,configurable:!0,writable:!0,value:_}):C[y]=_;var c=(C,y,_)=>de(C,typeof y!="symbol"?y+"":y,_);const y=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",_="1",kt="2";var st=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(st||{});const Bt="00000001";var j={};j.byteLength=Dt,j.toByteArray=It,j.fromByteArray=_t;for(var B=[],w=[],St=typeof Uint8Array<"u"?Uint8Array:Array,K="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=0,bt=K.length;L<bt;++L)B[L]=K[L],w[K.charCodeAt(L)]=L;w[45]=62,w[95]=63;function at(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var s=e===t?0:4-e%4;return[e,s]}function Dt(n){var t=at(n),e=t[0],s=t[1];return(e+s)*3/4-s}function $t(n,t,e){return(t+e)*3/4-e}function It(n){var t,e=at(n),s=e[0],a=e[1],r=new St($t(n,s,a)),o=0,i=a>0?s-4:s,d;for(d=0;d<i;d+=4)t=w[n.charCodeAt(d)]<<18|w[n.charCodeAt(d+1)]<<12|w[n.charCodeAt(d+2)]<<6|w[n.charCodeAt(d+3)],r[o++]=t>>16&255,r[o++]=t>>8&255,r[o++]=t&255;return a===2&&(t=w[n.charCodeAt(d)]<<2|w[n.charCodeAt(d+1)]>>4,r[o++]=t&255),a===1&&(t=w[n.charCodeAt(d)]<<10|w[n.charCodeAt(d+1)]<<4|w[n.charCodeAt(d+2)]>>2,r[o++]=t>>8&255,r[o++]=t&255),r}function At(n){return B[n>>18&63]+B[n>>12&63]+B[n>>6&63]+B[n&63]}function Et(n,t,e){for(var s,a=[],r=t;r<e;r+=3)s=(n[r]<<16&16711680)+(n[r+1]<<8&65280)+(n[r+2]&255),a.push(At(s));return a.join("")}function _t(n){for(var t,e=n.length,s=e%3,a=[],r=16383,o=0,i=e-s;o<i;o+=r)a.push(Et(n,o,o+r>i?i:o+r));return s===1?(t=n[e-1],a.push(B[t>>2]+B[t<<4&63]+"==")):s===2&&(t=(n[e-2]<<8)+n[e-1],a.push(B[t>>10]+B[t>>4&63]+B[t<<2&63]+"=")),a.join("")}class Lt{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 Pt=Object.defineProperty,Tt=(n,t,e)=>t in n?Pt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,rt=(n,t,e)=>Tt(n,typeof t!="symbol"?t+"":t,e);function W(){}function Ht(n,t){for(const e in t)n[e]=t[e];return n}function ot(n){return n()}function ct(){return Object.create(null)}function Z(n){n.forEach(ot)}function N(n){return typeof n=="function"}function it(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function Mt(n){return Object.keys(n).length===0}function Gt(n,t,e,s){if(n){const a=lt(n,t,e,s);return n[0](a)}}function lt(n,t,e,s){return n[1]&&s?Ht(e.ctx.slice(),n[1](s(t))):e.ctx}function Ft(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 jt(n,t,e,s,a,r){if(a){const o=lt(t,e,s,r);n.p(o,a)}}function Zt(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 dt(n){return n??""}function g(n,t){n.appendChild(t)}function J(n,t,e){n.insertBefore(t,e||null)}function R(n){n.parentNode&&n.parentNode.removeChild(n)}function Nt(n,t){for(let e=0;e<n.length;e+=1)n[e]&&n[e].d(t)}function S(n){return document.createElement(n)}function b(n){return document.createTextNode(n)}function O(){return b(" ")}function Ot(){return b("")}function z(n,t,e,s){return n.addEventListener(t,e,s),()=>n.removeEventListener(t,e,s)}function v(n,t,e){e==null?n.removeAttribute(t):n.getAttribute(t)!==e&&n.setAttribute(t,e)}function zt(n){return Array.from(n.childNodes)}function P(n,t){t=""+t,n.data!==t&&(n.data=t)}let q;function V(n){q=n}const T=[],ut=[];let H=[];const ht=[],Vt=Promise.resolve();let Q=!1;function Rt(){Q||(Q=!0,Vt.then(gt))}function X(n){H.push(n)}const Y=new Set;let M=0;function gt(){if(M!==0)return;const n=q;do{try{for(;M<T.length;){const t=T[M];M++,V(t),Ut(t.$$)}}catch(t){throw T.length=0,M=0,t}for(V(null),T.length=0,M=0;ut.length;)ut.pop()();for(let t=0;t<H.length;t+=1){const e=H[t];Y.has(e)||(Y.add(e),e())}H.length=0}while(T.length);for(;ht.length;)ht.pop()();Q=!1,Y.clear(),V(n)}function Ut(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(X)}}function Kt(n){const t=[],e=[];H.forEach(s=>n.indexOf(s)===-1?t.push(s):e.push(s)),e.forEach(s=>s()),H=t}const U=new Set;let Wt;function tt(n,t){n&&n.i&&(U.delete(n),n.i(t))}function ft(n,t,e,s){if(n&&n.o){if(U.has(n))return;U.add(n),Wt.c.push(()=>{U.delete(n)}),n.o(t)}}function pt(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Jt(n){n&&n.c()}function yt(n,t,e){const{fragment:s,after_update:a}=n.$$;s&&s.m(t,e),X(()=>{const r=n.$$.on_mount.map(ot).filter(N);n.$$.on_destroy?n.$$.on_destroy.push(...r):Z(r),n.$$.on_mount=[]}),a.forEach(X)}function mt(n,t){const e=n.$$;e.fragment!==null&&(Kt(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&&(T.push(n),Rt(),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 d=q;V(n);const u=n.$$={fragment:null,ctx:[],props:r,update:W,not_equal:a,bound:ct(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(d?d.$$.context:[])),callbacks:ct(),dirty:i,skip_bound:!1,root:t.target||d.$$.root};o&&o(u.root);let f=!1;if(u.ctx=e?e(n,t.props||{},(l,p,...h)=>{const m=h.length?h[0]:p;return u.ctx&&a(u.ctx[l],u.ctx[l]=m)&&(!u.skip_bound&&u.bound[l]&&u.bound[l](m),f&&qt(n,l)),p}):[],u.update(),f=!0,Z(u.before_update),u.fragment=s?s(u.ctx):!1,t.target){if(t.hydrate){const l=zt(t.target);u.fragment&&u.fragment.l(l),l.forEach(R)}else u.fragment&&u.fragment.c();t.intro&&tt(n.$$.fragment),yt(n,t.target,t.anchor),gt()}V(d)}class wt{constructor(){rt(this,"$$"),rt(this,"$$set")}$destroy(){mt(this,1),this.$destroy=W}$on(t,e){if(!N(e))return W;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&&!Mt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Qt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Qt);function Xt(n){let t,e,s,a=(n[1]||"标题")+"",r,o,i,d,u,f,l=(n[4]||"取消")+"",p,h,m,A=(n[5]||"确认")+"",F,x,$,I;const nt=n[7].default,k=Gt(nt,n,n[6],null);return{c(){t=S("div"),e=S("div"),s=S("div"),r=b(a),o=O(),i=S("div"),k&&k.c(),d=O(),u=S("div"),f=S("button"),p=b(l),h=O(),m=S("button"),F=b(A),v(s,"class","model-title svelte-n1zwga"),v(i,"class","slot svelte-n1zwga"),v(f,"class","modal-btn svelte-n1zwga"),v(m,"class","modal-btn success svelte-n1zwga"),v(u,"class","modal-footer svelte-n1zwga"),v(e,"class","modal-content svelte-n1zwga"),v(t,"class","modal-background modal-visible svelte-n1zwga")},m(D,E){J(D,t,E),g(t,e),g(e,s),g(s,r),g(e,o),g(e,i),k&&k.m(i,null),g(e,d),g(e,u),g(u,f),g(f,p),g(u,h),g(u,m),g(m,F),x=!0,$||(I=[z(f,"click",function(){N(n[0])&&n[0].apply(this,arguments)}),z(m,"click",function(){N(n[2])&&n[2].apply(this,arguments)}),z(e,"click",Yt),z(t,"click",function(){N(n[3])&&n[3].apply(this,arguments)})],$=!0)},p(D,[E]){n=D,(!x||E&2)&&a!==(a=(n[1]||"标题")+"")&&P(r,a),k&&k.p&&(!x||E&64)&&jt(k,nt,n,n[6],x?Ft(nt,n[6],E,null):Zt(n[6]),null),(!x||E&16)&&l!==(l=(n[4]||"取消")+"")&&P(p,l),(!x||E&32)&&A!==(A=(n[5]||"确认")+"")&&P(F,A)},i(D){x||(tt(k,D),x=!0)},o(D){ft(k,D),x=!1},d(D){D&&R(t),k&&k.d(D),$=!1,Z(I)}}}const Yt=n=>n.stopPropagation();function te(n,t,e){let{$$slots:s={},$$scope:a}=t,{onCancel:r}=t,{title:o}=t,{onOk:i}=t,{onClose:d}=t,{cancelText:u}=t,{okText:f}=t;return n.$$set=l=>{"onCancel"in l&&e(0,r=l.onCancel),"title"in l&&e(1,o=l.title),"onOk"in l&&e(2,i=l.onOk),"onClose"in l&&e(3,d=l.onClose),"cancelText"in l&&e(4,u=l.cancelText),"okText"in l&&e(5,f=l.okText),"$$scope"in l&&e(6,a=l.$$scope)},[r,o,i,d,u,f,a,s]}class ee extends wt{constructor(t){super(),Ct(this,t,te,Xt,it,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5})}}function vt(n,t,e){const s=n.slice();return s[10]=t[e],s[12]=e,s}function xt(n){let t,e,s=n[10].CN+"",a,r,o,i=n[10].DevClass+"",d,u,f=n[10].sn+"",l,p,h,m,A,F;function x(){return n[9](n[12])}return{c(){t=S("div"),e=S("span"),a=b(s),r=O(),o=S("span"),d=b(i),u=b("("),l=b(f),p=b(")"),h=O(),v(e,"class","svelte-jtc2v4"),v(o,"class","svelte-jtc2v4"),v(t,"class",m=dt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m($,I){J($,t,I),g(t,e),g(e,a),g(t,r),g(t,o),g(o,d),g(o,u),g(o,l),g(o,p),g(t,h),A||(F=z(t,"click",x),A=!0)},p($,I){n=$,I&1&&s!==(s=n[10].CN+"")&&P(a,s),I&1&&i!==(i=n[10].DevClass+"")&&P(d,i),I&1&&f!==(f=n[10].sn+"")&&P(l,f),I&16&&m!==(m=dt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&v(t,"class",m)},d($){$&&R(t),A=!1,F()}}}function ne(n){let t,e=pt(n[0]),s=[];for(let a=0;a<e.length;a+=1)s[a]=xt(vt(n,e,a));return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=Ot()},m(a,r){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(a,r);J(a,t,r)},p(a,r){if(r&17){e=pt(a[0]);let o;for(o=0;o<e.length;o+=1){const i=vt(a,e,o);s[o]?s[o].p(i,r):(s[o]=xt(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),Nt(s,a)}}}function se(n){let t,e;return t=new ee({props:{onOk:n[6],onClose:n[1],onCancel:n[5],cancelText:n[2],okText:n[3],title:"选择证书",$$slots:{default:[ne]},$$scope:{ctx:n}}}),{c(){Jt(t.$$.fragment)},m(s,a){yt(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||(tt(t.$$.fragment,s),e=!0)},o(s){ft(t.$$.fragment,s),e=!1},d(s){mt(t,s)}}}function ae(n,t,e){let{certList:s=[]}=t,{onCancel:a}=t,{onOk:r}=t,{onClose:o}=t,{cancelText:i=""}=t,{okText:d=""}=t,u=0;const f=()=>{o==null||o()},l=()=>{r==null||r(s[u]),o==null||o()},p=h=>e(4,u=h);return n.$$set=h=>{"certList"in h&&e(0,s=h.certList),"onCancel"in h&&e(7,a=h.onCancel),"onOk"in h&&e(8,r=h.onOk),"onClose"in h&&e(1,o=h.onClose),"cancelText"in h&&e(2,i=h.cancelText),"okText"in h&&e(3,d=h.okText)},[s,o,i,d,u,f,l,a,r,p]}class re extends wt{constructor(t){super(),Ct(this,t,ae,se,it,{certList:0,onCancel:7,onOk:8,onClose:1,cancelText:2,okText:3})}}class oe{constructor(){c(this,"modalInstance",{current:null});c(this,"open",t=>new Promise((e,s)=>{this.modalInstance.current=new re({target:document.body,props:{...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 ce=new oe;class ie{constructor(t){c(this,"socketInstance",null);c(this,"eventBus",new Lt);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??{}]};(i=this.socketInstance)==null||i.send(JSON.stringify(r)),this.eventBus.on(t,d=>{d.success?s(d.data):a(d)})}));c(this,"handleEventData",async t=>{var e,s,a,r,o,i;if(t.data instanceof Blob){const d=await t.data.arrayBuffer(),f=new TextDecoder("gbk").decode(d),l=JSON.parse(f),p={data:l.data,success:(e=l.result)==null?void 0:e.success,msg:(s=l.result)==null?void 0:s.msg,errCode:(a=l.result)==null?void 0:a.errCode};this.eventBus.emit((r=l.result)==null?void 0:r.function,p),(i=(o=this.socketConfig)==null?void 0:o.onMessage)==null||i.call(o,p)}});c(this,"base64Encode",t=>{const e=new TextEncoder().encode(t);return j.fromByteArray(e)});c(this,"base64Decode",t=>{const e=j.toByteArray(t);return new TextDecoder().decode(e)});c(this,"changeIsRememberPin",async t=>{this.isRememberPin=t});c(this,"changePinPolicy",async t=>{this.pinPolicy=t});c(this,"checkCertIsLogin",async t=>await this.sendMessage("GZCA_IsLogin",t));c(this,"addUkeyEvents",async()=>{this.sendMessage("GZCA_StartListen",{Type:Bt}).then(t=>{var e,s;(s=(e=this.socketConfig)==null?void 0:e.onUkeyEvent)==null||s.call(e,t)})});c(this,"certLogin",async t=>{const e=await this.checkCertIsLogin({ContainerName:t});e!=null&&e[0].isLogin||await this.sendMessage("GZCA_Login",{ContainerName:t,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy})});c(this,"getCert",async(t,e)=>{const s=e??await this.chooseCert(t);return await this.certLogin(s.ContainerName),s});c(this,"getCertList",async t=>await this.sendMessage("GZCA_GetCertList",t));c(this,"chooseCert",async t=>{const e=await this.getCertList(t);return(e==null?void 0:e.length)===1?e[0]:await ce.open({certList:e})});c(this,"pkcs1Sign",async t=>await this.sendMessage("GZCA_Pkcs1SignData",{...t,IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1Base64Sign",async t=>await this.sendMessage("GZCA_Pkcs1SignDataEx",{...t,IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySign",t));c(this,"pkcs1Base64VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySignEx",t));c(this,"getSealList",async t=>await this.sendMessage("GZCA_EnumSeals",{...t,IsLogin:this.getIsLogin()}));c(this,"sm2SignPreprocess1",async t=>await this.sendMessage("GZCA_PrepareSm2SignStep1",t));c(this,"sm2SignPreprocess2",async t=>await this.sendMessage("GZCA_PrepareSm2SignStep2",t));c(this,"pkcs1HashSign",async t=>await this.sendMessage("GZCA_Pkcs1SignDataForHash",{...t??{},IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1HashVerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySignForHash",t));c(this,"pkcs7Sign",async t=>await this.sendMessage("GZCA_Pkcs7SignData",{...t,IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy}));c(this,"pkcs7VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs7VerifySign",t));c(this,"sm3Hash",async t=>await this.sendMessage("GZCA_HashData",t));c(this,"sm3HexHash",async t=>await this.sendMessage("GZCA_HashDataEx",t));c(this,"sm3FileHash",async t=>await this.sendMessage("GZCA_HashFile",t));c(this,"sm3HashEncryption",async t=>await this.sendMessage("GZCA_HMac",t));c(this,"pkcs7Encryption",async t=>await this.sendMessage("GZCA_Pkcs7EncryptData",t));c(this,"pkcs7Decryption",async t=>await this.sendMessage("GZCA_Pkcs7DecryptData",{...t,IsLogin:this.getIsLogin()}));c(this,"asymmetricEncryption",async t=>await this.sendMessage("GZCA_AsymEncryptData",t));c(this,"asymmetricDecryption",async t=>await this.sendMessage("GZCA_AsymDecryptData",{...t,IsLogin:this.getIsLogin()}));c(this,"sm4Encryption",async t=>await this.sendMessage("GZCA_EncryptDataEx",t));c(this,"sm4Decryption",async t=>await this.sendMessage("GZCA_DecryptDataEx",t));c(this,"getCertInfo",async t=>await this.sendMessage("GZCA_GetCertInfo",t));c(this,"getCertInfoByOid",async t=>await this.sendMessage("GZCA_GetCertInfoByOid",t));this.socketConfig=t,this.socketInstance=this.createSocket(t),this.isRememberPin=t.isRememberPin??!1,this.pinPolicy=t.pinPolicy??st.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 G=class G{constructor(t){c(this,"coreInstance",null);c(this,"gwsConfig",{});c(this,"createGwsCore",t=>{this.gwsConfig=t??{},this.coreInstance=new ie({...t??{},url:y})});c(this,"appendCertBase64",async(t,e=!0)=>{if(t.CertB64)return t;const s=e?await this.getSignatureCert():await this.getEncryptionCert();return{...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??this.gwsConfig,this.createGwsCore(t)});c(this,"getSocketReadyState",()=>{var t;return(t=this.coreInstance)==null?void 0:t.getSocketReadyState()});c(this,"getSignatureCert",async t=>{var s;return await((s=this.coreInstance)==null?void 0:s.getCert({CertType:_},t))});c(this,"getEncryptionCert",async t=>{var s;return await((s=this.coreInstance)==null?void 0:s.getCert({CertType:kt},t))});c(this,"base64Encode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Encode(t)});c(this,"base64Decode",t=>{var e;return(e=this.coreInstance)==null?void 0:e.base64Decode(t)});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",async(t,e)=>{var r,o;const s=await this.getSignatureCert(e),a=await((r=this.coreInstance)==null?void 0:r.pkcs1Sign({...t??{},ContainerName:(s==null?void 0:s.ContainerName)??""}));return(o=a==null?void 0:a[0])==null?void 0:o.SignData});c(this,"pkcs1VerifySignature",async t=>{var a;const e=await this.appendCertBase64(t),s=await((a=this.coreInstance)==null?void 0:a.pkcs1VerifySignature(e));return Array.isArray(s)});c(this,"pkcs1Base64Sign",async(t,e)=>{var o,i;const s=await this.getSignatureCert(e),a=t.DataB64??this.base64Encode(t.Data??""),r=await((o=this.coreInstance)==null?void 0:o.pkcs1Base64Sign({ContainerName:(s==null?void 0:s.ContainerName)??"",DataB64:a}));return(i=r==null?void 0:r[0])==null?void 0:i.SignData});c(this,"pkcs1Base64VerifySignature",async t=>{var r;const e=t.DataB64??this.base64Encode(t.Data??""),s=await this.appendCertBase64(t);return!!await((r=this.coreInstance)==null?void 0:r.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:e,SignData:s.SignData}))});c(this,"getSealList",async()=>{var s;const t=await this.getSignatureCert(),e=await((s=this.coreInstance)==null?void 0:s.getSealList({ContainerName:(t==null?void 0:t.ContainerName)??""}));return{cert:t,sealList:e}});c(this,"sm2SignPreprocess1",async t=>{var a,r;const e=await this.appendCertBase64(t),s=await((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",async t=>{var r;const e=this.base64Encode(t.Data),s=await this.appendCertBase64(t),a=await((r=this.coreInstance)==null?void 0:r.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:e}));return a==null?void 0:a[0].H});c(this,"pkcs1HashSign",async(t,e)=>{var r,o;const s=await this.getSignatureCert(e),a=await((r=this.coreInstance)==null?void 0:r.pkcs1HashSign({ContainerName:(s==null?void 0:s.ContainerName)??"",DataB64:t.DataB64,HashAlg:t.HashAlg??"sm3"}));return(o=a==null?void 0:a[0])==null?void 0:o.SignData});c(this,"pkcs1HashVerifySignature",async t=>{var a;const e=await this.appendCertBase64(t);return!!await((a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature({...e,HashAlg:e.HashAlg??"sm3"}))});c(this,"pkcs7Sign",async(t,e)=>{var o,i;const s=t.DataB64??this.base64Encode(t.Data??""),a=await this.getSignatureCert(e),r=await((o=this.coreInstance)==null?void 0:o.pkcs7Sign({IsDetached:t.IsDetached,ContainerName:(a==null?void 0:a.ContainerName)??"",DataB64:s}));return(i=r==null?void 0:r[0])==null?void 0:i.SignData});c(this,"pkcs7VerifySignature",async t=>{var a;const e=t.DataB64??this.base64Encode(t.Data??"");return!!await((a=this.coreInstance)==null?void 0:a.pkcs7VerifySignature({DataB64:e,SignData:t.SignData}))});c(this,"sm3Hash",async t=>{var s,a;const e=await((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",async t=>{var s,a;const e=await((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",async t=>{var s,a;const e=await((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",async t=>{var r,o;const e=t.DataB64??this.base64Encode(t.Data??""),s=t.KeyB64??this.base64Encode(t.Key??""),a=await((r=this.coreInstance)==null?void 0:r.sm3HashEncryption({dataB64:e,keyB64:s,alg:"sm3"}));return(o=a==null?void 0:a[0])==null?void 0:o.DataB64});c(this,"pkcs7Encryption",async t=>{var a,r;if(!t.CertB64List){const o=await this.getEncryptionCert();t.CertB64List=o==null?void 0:o.CertB64}const e=t.DataB64??this.base64Encode(t.Data??""),s=await((a=this.coreInstance)==null?void 0:a.pkcs7Encryption({DataB64:e,CertB64List:t.CertB64List}));return(r=s==null?void 0:s[0])==null?void 0:r.DataB64});c(this,"pkcs7Decryption",async t=>{var r,o;const e=await this.getEncryptionCert(),s=await((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(a):a});c(this,"asymmetricEncryption",async t=>{var a,r;const e=await this.appendCertBase64(t,!1),s=await((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",async t=>{var a,r;const e=await this.getEncryptionCert(),s=await((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",async t=>{var s;const e=await((s=this.coreInstance)==null?void 0:s.sm4Encryption(t));return e==null?void 0:e[0]});c(this,"sm4Decryption",async t=>{var s,a;const e=await((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",async()=>{var s;const t=await this.getSignatureCert(),e=await((s=this.coreInstance)==null?void 0:s.getCertInfo({CertB64:t==null?void 0:t.CertB64}));return{...(e==null?void 0:e[0])??{},...t??{}}});c(this,"getCertInfoByOid",async t=>{var a,r;const e=await this.getSignatureCert(),s=await((a=this.coreInstance)==null?void 0:a.getCertInfoByOid({...t??{},CertB64:e==null?void 0:e.CertB64}));return(r=s==null?void 0:s[0])==null?void 0:r.OidValue});return G.instance&&!(t!=null&&t.isCreateNew)?G.instance:(this.createGwsCore(t),G.instance=this,this)}};c(G,"instance",null);let et=G;C.GwsService=et,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
1
+ (function(C,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(C=typeof globalThis<"u"?globalThis:C||self,y(C.GZCA={}))})(this,function(C){"use strict";var le=Object.defineProperty;var de=(C,y,_)=>y in C?le(C,y,{enumerable:!0,configurable:!0,writable:!0,value:_}):C[y]=_;var c=(C,y,_)=>de(C,typeof y!="symbol"?y+"":y,_);const y=window.location.href.includes("https")?"wss://localhost:19528":"ws://localhost:9527",_="1",kt="2";var st=(n=>(n[n.MIN=0]="MIN",n[n.LOW=1]="LOW",n[n.MIDDLE=2]="MIDDLE",n[n.HIGH=3]="HIGH",n))(st||{});const Dt="00000001";var j={};j.byteLength=bt,j.toByteArray=It,j.fromByteArray=_t;for(var D=[],w=[],Bt=typeof Uint8Array<"u"?Uint8Array:Array,K="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",L=0,St=K.length;L<St;++L)D[L]=K[L],w[K.charCodeAt(L)]=L;w[45]=62,w[95]=63;function at(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var s=e===t?0:4-e%4;return[e,s]}function bt(n){var t=at(n),e=t[0],s=t[1];return(e+s)*3/4-s}function $t(n,t,e){return(t+e)*3/4-e}function It(n){var t,e=at(n),s=e[0],a=e[1],r=new Bt($t(n,s,a)),o=0,i=a>0?s-4:s,d;for(d=0;d<i;d+=4)t=w[n.charCodeAt(d)]<<18|w[n.charCodeAt(d+1)]<<12|w[n.charCodeAt(d+2)]<<6|w[n.charCodeAt(d+3)],r[o++]=t>>16&255,r[o++]=t>>8&255,r[o++]=t&255;return a===2&&(t=w[n.charCodeAt(d)]<<2|w[n.charCodeAt(d+1)]>>4,r[o++]=t&255),a===1&&(t=w[n.charCodeAt(d)]<<10|w[n.charCodeAt(d+1)]<<4|w[n.charCodeAt(d+2)]>>2,r[o++]=t>>8&255,r[o++]=t&255),r}function At(n){return D[n>>18&63]+D[n>>12&63]+D[n>>6&63]+D[n&63]}function Et(n,t,e){for(var s,a=[],r=t;r<e;r+=3)s=(n[r]<<16&16711680)+(n[r+1]<<8&65280)+(n[r+2]&255),a.push(At(s));return a.join("")}function _t(n){for(var t,e=n.length,s=e%3,a=[],r=16383,o=0,i=e-s;o<i;o+=r)a.push(Et(n,o,o+r>i?i:o+r));return s===1?(t=n[e-1],a.push(D[t>>2]+D[t<<4&63]+"==")):s===2&&(t=(n[e-2]<<8)+n[e-1],a.push(D[t>>10]+D[t>>4&63]+D[t<<2&63]+"=")),a.join("")}class Lt{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 Pt=Object.defineProperty,Tt=(n,t,e)=>t in n?Pt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,rt=(n,t,e)=>Tt(n,typeof t!="symbol"?t+"":t,e);function W(){}function Ht(n,t){for(const e in t)n[e]=t[e];return n}function ot(n){return n()}function ct(){return Object.create(null)}function Z(n){n.forEach(ot)}function N(n){return typeof n=="function"}function it(n,t){return n!=n?t==t:n!==t||n&&typeof n=="object"||typeof n=="function"}function Mt(n){return Object.keys(n).length===0}function Gt(n,t,e,s){if(n){const a=lt(n,t,e,s);return n[0](a)}}function lt(n,t,e,s){return n[1]&&s?Ht(e.ctx.slice(),n[1](s(t))):e.ctx}function Ft(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 jt(n,t,e,s,a,r){if(a){const o=lt(t,e,s,r);n.p(o,a)}}function Zt(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 dt(n){return n??""}function g(n,t){n.appendChild(t)}function J(n,t,e){n.insertBefore(t,e||null)}function R(n){n.parentNode&&n.parentNode.removeChild(n)}function Nt(n,t){for(let e=0;e<n.length;e+=1)n[e]&&n[e].d(t)}function B(n){return document.createElement(n)}function S(n){return document.createTextNode(n)}function O(){return S(" ")}function Ot(){return S("")}function z(n,t,e,s){return n.addEventListener(t,e,s),()=>n.removeEventListener(t,e,s)}function v(n,t,e){e==null?n.removeAttribute(t):n.getAttribute(t)!==e&&n.setAttribute(t,e)}function zt(n){return Array.from(n.childNodes)}function P(n,t){t=""+t,n.data!==t&&(n.data=t)}let q;function V(n){q=n}const T=[],ut=[];let H=[];const ht=[],Vt=Promise.resolve();let Q=!1;function Rt(){Q||(Q=!0,Vt.then(gt))}function X(n){H.push(n)}const Y=new Set;let M=0;function gt(){if(M!==0)return;const n=q;do{try{for(;M<T.length;){const t=T[M];M++,V(t),Ut(t.$$)}}catch(t){throw T.length=0,M=0,t}for(V(null),T.length=0,M=0;ut.length;)ut.pop()();for(let t=0;t<H.length;t+=1){const e=H[t];Y.has(e)||(Y.add(e),e())}H.length=0}while(T.length);for(;ht.length;)ht.pop()();Q=!1,Y.clear(),V(n)}function Ut(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(X)}}function Kt(n){const t=[],e=[];H.forEach(s=>n.indexOf(s)===-1?t.push(s):e.push(s)),e.forEach(s=>s()),H=t}const U=new Set;let Wt;function tt(n,t){n&&n.i&&(U.delete(n),n.i(t))}function ft(n,t,e,s){if(n&&n.o){if(U.has(n))return;U.add(n),Wt.c.push(()=>{U.delete(n)}),n.o(t)}}function pt(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function Jt(n){n&&n.c()}function yt(n,t,e){const{fragment:s,after_update:a}=n.$$;s&&s.m(t,e),X(()=>{const r=n.$$.on_mount.map(ot).filter(N);n.$$.on_destroy?n.$$.on_destroy.push(...r):Z(r),n.$$.on_mount=[]}),a.forEach(X)}function mt(n,t){const e=n.$$;e.fragment!==null&&(Kt(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&&(T.push(n),Rt(),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 d=q;V(n);const u=n.$$={fragment:null,ctx:[],props:r,update:W,not_equal:a,bound:ct(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(d?d.$$.context:[])),callbacks:ct(),dirty:i,skip_bound:!1,root:t.target||d.$$.root};o&&o(u.root);let f=!1;if(u.ctx=e?e(n,t.props||{},(l,p,...h)=>{const m=h.length?h[0]:p;return u.ctx&&a(u.ctx[l],u.ctx[l]=m)&&(!u.skip_bound&&u.bound[l]&&u.bound[l](m),f&&qt(n,l)),p}):[],u.update(),f=!0,Z(u.before_update),u.fragment=s?s(u.ctx):!1,t.target){if(t.hydrate){const l=zt(t.target);u.fragment&&u.fragment.l(l),l.forEach(R)}else u.fragment&&u.fragment.c();t.intro&&tt(n.$$.fragment),yt(n,t.target,t.anchor),gt()}V(d)}class wt{constructor(){rt(this,"$$"),rt(this,"$$set")}$destroy(){mt(this,1),this.$destroy=W}$on(t,e){if(!N(e))return W;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&&!Mt(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const Qt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Qt);function Xt(n){let t,e,s,a=(n[1]||"标题")+"",r,o,i,d,u,f,l=(n[4]||"取消")+"",p,h,m,A=(n[5]||"确认")+"",F,x,$,I;const nt=n[7].default,k=Gt(nt,n,n[6],null);return{c(){t=B("div"),e=B("div"),s=B("div"),r=S(a),o=O(),i=B("div"),k&&k.c(),d=O(),u=B("div"),f=B("button"),p=S(l),h=O(),m=B("button"),F=S(A),v(s,"class","model-title svelte-n1zwga"),v(i,"class","slot svelte-n1zwga"),v(f,"class","modal-btn svelte-n1zwga"),v(m,"class","modal-btn success svelte-n1zwga"),v(u,"class","modal-footer svelte-n1zwga"),v(e,"class","modal-content svelte-n1zwga"),v(t,"class","modal-background modal-visible svelte-n1zwga")},m(b,E){J(b,t,E),g(t,e),g(e,s),g(s,r),g(e,o),g(e,i),k&&k.m(i,null),g(e,d),g(e,u),g(u,f),g(f,p),g(u,h),g(u,m),g(m,F),x=!0,$||(I=[z(f,"click",function(){N(n[0])&&n[0].apply(this,arguments)}),z(m,"click",function(){N(n[2])&&n[2].apply(this,arguments)}),z(e,"click",Yt),z(t,"click",function(){N(n[3])&&n[3].apply(this,arguments)})],$=!0)},p(b,[E]){n=b,(!x||E&2)&&a!==(a=(n[1]||"标题")+"")&&P(r,a),k&&k.p&&(!x||E&64)&&jt(k,nt,n,n[6],x?Ft(nt,n[6],E,null):Zt(n[6]),null),(!x||E&16)&&l!==(l=(n[4]||"取消")+"")&&P(p,l),(!x||E&32)&&A!==(A=(n[5]||"确认")+"")&&P(F,A)},i(b){x||(tt(k,b),x=!0)},o(b){ft(k,b),x=!1},d(b){b&&R(t),k&&k.d(b),$=!1,Z(I)}}}const Yt=n=>n.stopPropagation();function te(n,t,e){let{$$slots:s={},$$scope:a}=t,{onCancel:r}=t,{title:o}=t,{onOk:i}=t,{onClose:d}=t,{cancelText:u}=t,{okText:f}=t;return n.$$set=l=>{"onCancel"in l&&e(0,r=l.onCancel),"title"in l&&e(1,o=l.title),"onOk"in l&&e(2,i=l.onOk),"onClose"in l&&e(3,d=l.onClose),"cancelText"in l&&e(4,u=l.cancelText),"okText"in l&&e(5,f=l.okText),"$$scope"in l&&e(6,a=l.$$scope)},[r,o,i,d,u,f,a,s]}class ee extends wt{constructor(t){super(),Ct(this,t,te,Xt,it,{onCancel:0,title:1,onOk:2,onClose:3,cancelText:4,okText:5})}}function vt(n,t,e){const s=n.slice();return s[10]=t[e],s[12]=e,s}function xt(n){let t,e,s=n[10].CN+"",a,r,o,i=n[10].DevClass+"",d,u,f=n[10].sn+"",l,p,h,m,A,F;function x(){return n[9](n[12])}return{c(){t=B("div"),e=B("span"),a=S(s),r=O(),o=B("span"),d=S(i),u=S("("),l=S(f),p=S(")"),h=O(),v(e,"class","svelte-jtc2v4"),v(o,"class","svelte-jtc2v4"),v(t,"class",m=dt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")},m($,I){J($,t,I),g(t,e),g(e,a),g(t,r),g(t,o),g(o,d),g(o,u),g(o,l),g(o,p),g(t,h),A||(F=z(t,"click",x),A=!0)},p($,I){n=$,I&1&&s!==(s=n[10].CN+"")&&P(a,s),I&1&&i!==(i=n[10].DevClass+"")&&P(d,i),I&1&&f!==(f=n[10].sn+"")&&P(l,f),I&16&&m!==(m=dt(`cert-item ${n[12]===0?"cert-item-first":""} ${n[12]===n[4]?"cert-item-selected":""}`)+" svelte-jtc2v4")&&v(t,"class",m)},d($){$&&R(t),A=!1,F()}}}function ne(n){let t,e=pt(n[0]),s=[];for(let a=0;a<e.length;a+=1)s[a]=xt(vt(n,e,a));return{c(){for(let a=0;a<s.length;a+=1)s[a].c();t=Ot()},m(a,r){for(let o=0;o<s.length;o+=1)s[o]&&s[o].m(a,r);J(a,t,r)},p(a,r){if(r&17){e=pt(a[0]);let o;for(o=0;o<e.length;o+=1){const i=vt(a,e,o);s[o]?s[o].p(i,r):(s[o]=xt(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),Nt(s,a)}}}function se(n){let t,e;return t=new ee({props:{onOk:n[6],onClose:n[1],onCancel:n[5],cancelText:n[2],okText:n[3],title:"选择证书",$$slots:{default:[ne]},$$scope:{ctx:n}}}),{c(){Jt(t.$$.fragment)},m(s,a){yt(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||(tt(t.$$.fragment,s),e=!0)},o(s){ft(t.$$.fragment,s),e=!1},d(s){mt(t,s)}}}function ae(n,t,e){let{certList:s=[]}=t,{onCancel:a}=t,{onOk:r}=t,{onClose:o}=t,{cancelText:i=""}=t,{okText:d=""}=t,u=0;const f=()=>{o==null||o()},l=()=>{r==null||r(s[u]),o==null||o()},p=h=>e(4,u=h);return n.$$set=h=>{"certList"in h&&e(0,s=h.certList),"onCancel"in h&&e(7,a=h.onCancel),"onOk"in h&&e(8,r=h.onOk),"onClose"in h&&e(1,o=h.onClose),"cancelText"in h&&e(2,i=h.cancelText),"okText"in h&&e(3,d=h.okText)},[s,o,i,d,u,f,l,a,r,p]}class re extends wt{constructor(t){super(),Ct(this,t,ae,se,it,{certList:0,onCancel:7,onOk:8,onClose:1,cancelText:2,okText:3})}}class oe{constructor(){c(this,"modalInstance",{current:null});c(this,"open",t=>new Promise((e,s)=>{this.modalInstance.current=new re({target:document.body,props:{...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 ce=new oe;class ie{constructor(t){c(this,"socketInstance",null);c(this,"eventBus",new Lt);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??{}]};(i=this.socketInstance)==null||i.send(JSON.stringify(r)),this.eventBus.on(t,d=>{d.success?s(d.data):a(d)})}));c(this,"handleEventData",async t=>{var e,s,a,r,o,i;if(t.data instanceof Blob){const d=await t.data.arrayBuffer(),f=new TextDecoder("gbk").decode(d),l=JSON.parse(f),p={data:l.data,success:(e=l.result)==null?void 0:e.success,msg:(s=l.result)==null?void 0:s.msg,errCode:(a=l.result)==null?void 0:a.errCode};this.eventBus.emit((r=l.result)==null?void 0:r.function,p),(i=(o=this.socketConfig)==null?void 0:o.onMessage)==null||i.call(o,p)}});c(this,"base64Encode",t=>{const e=new TextEncoder().encode(t);return j.fromByteArray(e)});c(this,"base64Decode",t=>{const e=j.toByteArray(t);return new TextDecoder().decode(e)});c(this,"changeIsRememberPin",async t=>{this.isRememberPin=t});c(this,"changePinPolicy",async t=>{this.pinPolicy=t});c(this,"checkCertIsLogin",async t=>await this.sendMessage("GZCA_IsLogin",t));c(this,"addUkeyEvents",async()=>{this.sendMessage("GZCA_StartListen",{Type:Dt}).then(t=>{var e,s;(s=(e=this.socketConfig)==null?void 0:e.onUkeyEvent)==null||s.call(e,t)})});c(this,"certLogin",async t=>{const e=await this.checkCertIsLogin({ContainerName:t});e!=null&&e[0].isLogin||await this.sendMessage("GZCA_Login",{ContainerName:t,IsLogin:"N",UserPin:"123456",PinPolicy:this.pinPolicy})});c(this,"getCert",async(t,e)=>{const s=e??await this.chooseCert(t);return await this.certLogin(s.ContainerName),s});c(this,"getCertList",async t=>await this.sendMessage("GZCA_GetCertList",t));c(this,"chooseCert",async t=>{const e=await this.getCertList(t);return(e==null?void 0:e.length)===1?e[0]:await ce.open({certList:e})});c(this,"pkcs1Sign",async t=>await this.sendMessage("GZCA_Pkcs1SignData",{...t,IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1Base64Sign",async t=>await this.sendMessage("GZCA_Pkcs1SignDataEx",{...t,IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySign",t));c(this,"pkcs1Base64VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySignEx",t));c(this,"getSealList",async t=>await this.sendMessage("GZCA_EnumSeals",{...t,IsLogin:this.getIsLogin()}));c(this,"sm2SignPreprocess1",async t=>await this.sendMessage("GZCA_PrepareSm2SignStep1",t));c(this,"sm2SignPreprocess2",async t=>await this.sendMessage("GZCA_PrepareSm2SignStep2",t));c(this,"pkcs1HashSign",async t=>await this.sendMessage("GZCA_Pkcs1SignDataForHash",{...t??{},IsLogin:this.getIsLogin(),PinPolicy:this.pinPolicy}));c(this,"pkcs1HashVerifySignature",async t=>await this.sendMessage("GZCA_Pkcs1VerifySignForHash",t));c(this,"pkcs7Sign",async t=>await this.sendMessage("GZCA_Pkcs7SignData",{...t,IsLogin:this.getIsLogin(),IsAuthAttr:"Y",PinPolicy:this.pinPolicy}));c(this,"pkcs7VerifySignature",async t=>await this.sendMessage("GZCA_Pkcs7VerifySign",t));c(this,"sm3Hash",async t=>await this.sendMessage("GZCA_HashData",t));c(this,"sm3HexHash",async t=>await this.sendMessage("GZCA_HashDataEx",t));c(this,"sm3FileHash",async t=>await this.sendMessage("GZCA_HashFile",t));c(this,"sm3HashEncryption",async t=>await this.sendMessage("GZCA_HMac",t));c(this,"pkcs7Encryption",async t=>await this.sendMessage("GZCA_Pkcs7EncryptData",t));c(this,"pkcs7Decryption",async t=>await this.sendMessage("GZCA_Pkcs7DecryptData",{...t,IsLogin:this.getIsLogin()}));c(this,"asymmetricEncryption",async t=>await this.sendMessage("GZCA_AsymEncryptData",t));c(this,"asymmetricDecryption",async t=>await this.sendMessage("GZCA_AsymDecryptData",{...t,IsLogin:this.getIsLogin()}));c(this,"sm4Encryption",async t=>await this.sendMessage("GZCA_EncryptDataEx",t));c(this,"sm4Decryption",async t=>await this.sendMessage("GZCA_DecryptDataEx",t));c(this,"getCertInfo",async t=>await this.sendMessage("GZCA_GetCertInfo",t));c(this,"getCertInfoByOid",async t=>await this.sendMessage("GZCA_GetCertInfoByOid",t));this.socketConfig=t,this.socketInstance=this.createSocket(t),this.isRememberPin=t.isRememberPin??!1,this.pinPolicy=t.pinPolicy??st.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 G=class G{constructor(t){c(this,"coreInstance",null);c(this,"gwsConfig",{});c(this,"createGwsCore",t=>{this.gwsConfig=t??{},this.coreInstance=new ie({...t??{},url:y})});c(this,"appendCertBase64",async(t,e=!0)=>{if(t.CertB64)return t;const s=e?await this.getSignatureCert():await this.getEncryptionCert();return{...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??this.gwsConfig,this.createGwsCore(t)});c(this,"getSocketReadyState",()=>{var t;return(t=this.coreInstance)==null?void 0:t.getSocketReadyState()});c(this,"getSignatureCert",async t=>{var s;return await((s=this.coreInstance)==null?void 0:s.getCert({CertType:_},t))});c(this,"getEncryptionCert",async t=>{var s;return await((s=this.coreInstance)==null?void 0:s.getCert({CertType:kt},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",async(t,e)=>{var r,o;const s=await this.getSignatureCert(e),a=await((r=this.coreInstance)==null?void 0:r.pkcs1Sign({...t??{},ContainerName:(s==null?void 0:s.ContainerName)??""}));return(o=a==null?void 0:a[0])==null?void 0:o.SignData});c(this,"pkcs1VerifySignature",async t=>{var a;const e=await this.appendCertBase64(t),s=await((a=this.coreInstance)==null?void 0:a.pkcs1VerifySignature(e));return Array.isArray(s)});c(this,"pkcs1Base64Sign",async(t,e)=>{var o,i;const s=await this.getSignatureCert(e),a=t.DataB64??this.base64Encode({Data:t.Data??""}),r=await((o=this.coreInstance)==null?void 0:o.pkcs1Base64Sign({ContainerName:(s==null?void 0:s.ContainerName)??"",DataB64:a}));return(i=r==null?void 0:r[0])==null?void 0:i.SignData});c(this,"pkcs1Base64VerifySignature",async t=>{var r;const e=t.DataB64??this.base64Encode({Data:t.Data??""}),s=await this.appendCertBase64(t);return!!await((r=this.coreInstance)==null?void 0:r.pkcs1Base64VerifySignature({CertB64:s.CertB64,DataB64:e,SignData:s.SignData}))});c(this,"getSealList",async()=>{var s;const t=await this.getSignatureCert(),e=await((s=this.coreInstance)==null?void 0:s.getSealList({ContainerName:(t==null?void 0:t.ContainerName)??""}));return{cert:t,sealList:e}});c(this,"sm2SignPreprocess1",async t=>{var a,r;const e=await this.appendCertBase64(t),s=await((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",async t=>{var r;const e=this.base64Encode({Data:t.Data??""}),s=await this.appendCertBase64(t),a=await((r=this.coreInstance)==null?void 0:r.sm2SignPreprocess2({CertB64:s.CertB64,DataB64:e}));return a==null?void 0:a[0].H});c(this,"pkcs1HashSign",async(t,e)=>{var r,o;const s=await this.getSignatureCert(e),a=await((r=this.coreInstance)==null?void 0:r.pkcs1HashSign({ContainerName:(s==null?void 0:s.ContainerName)??"",DataB64:t.DataB64,HashAlg:t.HashAlg??"sm3"}));return(o=a==null?void 0:a[0])==null?void 0:o.SignData});c(this,"pkcs1HashVerifySignature",async t=>{var a;const e=await this.appendCertBase64(t);return!!await((a=this.coreInstance)==null?void 0:a.pkcs1HashVerifySignature({...e,HashAlg:e.HashAlg??"sm3"}))});c(this,"pkcs7Sign",async(t,e)=>{var o,i;const s=t.DataB64??this.base64Encode({Data:t.Data??""}),a=await this.getSignatureCert(e),r=await((o=this.coreInstance)==null?void 0:o.pkcs7Sign({IsDetached:t.IsDetached,ContainerName:(a==null?void 0:a.ContainerName)??"",DataB64:s}));return(i=r==null?void 0:r[0])==null?void 0:i.SignData});c(this,"pkcs7VerifySignature",async t=>{var a;const e=t.DataB64??this.base64Encode({Data:t.Data??""});return!!await((a=this.coreInstance)==null?void 0:a.pkcs7VerifySignature({DataB64:e,SignData:t.SignData}))});c(this,"sm3Hash",async t=>{var s,a;const e=await((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",async t=>{var s,a;const e=await((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",async t=>{var s,a;const e=await((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",async t=>{var r,o;const e=t.DataB64??this.base64Encode({Data:t.Data??""}),s=t.KeyB64??this.base64Encode({Data:t.Key??""}),a=await((r=this.coreInstance)==null?void 0:r.sm3HashEncryption({dataB64:e,keyB64:s,alg:"sm3"}));return(o=a==null?void 0:a[0])==null?void 0:o.DataB64});c(this,"pkcs7Encryption",async t=>{var a,r;if(!t.CertB64List){const o=await this.getEncryptionCert();t.CertB64List=o==null?void 0:o.CertB64}const e=t.DataB64??this.base64Encode({Data:t.Data??""}),s=await((a=this.coreInstance)==null?void 0:a.pkcs7Encryption({DataB64:e,CertB64List:t.CertB64List}));return(r=s==null?void 0:s[0])==null?void 0:r.DataB64});c(this,"pkcs7Decryption",async t=>{var r,o;const e=await this.getEncryptionCert(),s=await((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",async t=>{var a,r;const e=await this.appendCertBase64(t,!1),s=await((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",async t=>{var a,r;const e=await this.getEncryptionCert(),s=await((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",async t=>{var s;const e=await((s=this.coreInstance)==null?void 0:s.sm4Encryption(t));return e==null?void 0:e[0]});c(this,"sm4Decryption",async t=>{var s,a;const e=await((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",async()=>{var s;const t=await this.getSignatureCert(),e=await((s=this.coreInstance)==null?void 0:s.getCertInfo({CertB64:t==null?void 0:t.CertB64}));return{...(e==null?void 0:e[0])??{},...t??{}}});c(this,"getCertInfoByOid",async t=>{var a,r;const e=await this.getSignatureCert(),s=await((a=this.coreInstance)==null?void 0:a.getCertInfoByOid({...t??{},CertB64:e==null?void 0:e.CertB64}));return(r=s==null?void 0:s[0])==null?void 0:r.OidValue});return G.instance&&!(t!=null&&t.isCreateNew)?G.instance:(this.createGwsCore(t),G.instance=this,this)}};c(G,"instance",null);let et=G;C.GwsService=et,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gws-client",
3
- "version": "0.1.11",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "module": "dist/index.es.js",
6
6
  "browser": "dist/index.umd.js",