n20-common-lib 2.10.20 → 2.10.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "2.10.20",
3
+ "version": "2.10.21",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -34,11 +34,8 @@ async function disposeSign(config, p1, p2, p3) {
34
34
  config = CaMap['SkfSign']
35
35
  }
36
36
 
37
- const path =
38
- typeof config.path === 'function' ? config.path(p3) : config.path
39
- const module = await importG(config.type, () =>
40
- import(`${path}`)
41
- )
37
+ const path = typeof config.path === 'function' ? config.path(p3) : config.path
38
+ const module = await importG(config.type, () => import(`${path}`))
42
39
 
43
40
  if (config.needAvailable) {
44
41
  await new Promise((resolve, reject) => {
@@ -89,29 +86,38 @@ export async function getSign(p1, p2, p3) {
89
86
  * @param {string} dn - 证书DN
90
87
  * @returns {Promise<*>} 证书信息
91
88
  */
92
- export async function getCert(dn) {
93
- const signType = window.sessionStorage.getItem('signType')
94
- const signModules = {
95
- inetSign: { path: './sign.js', method: 'getCertInfo' },
96
- SkfSign: { path: './SkfSign/index.js', method: 'getCertInfo' },
97
- NetSM3: { path: './NetSM3/index.js', method: 'getCertInfo' },
98
- ItrusSign: { path: './Itrus/index.js', method: 'getCert' }
99
- }
100
-
101
- const module = signModules[signType]
102
- if (!module) {
103
- throw new Error('不支持的签名类型')
104
- }
105
-
106
- try {
107
- const { [module.method]: certMethod } = await importG(signType, () =>
108
- import(/*webpackChunkName: "[request]"*/ module.path)
109
- )
110
- return await certMethod(dn)
111
- } catch (error) {
112
- console.error('获取证书失败:', error)
113
- throw error
114
- }
89
+ export function getCert(dn) {
90
+ let signType = window.sessionStorage.getItem('signType')
91
+ return new Promise((resolve, reject) => {
92
+ if (signType === 'inetSign' /* 信安CA */) {
93
+ importG('inetSign', () => import(/*webpackChunkName: "inetSign"*/ './sign.js')).then(({ getCertInfo }) => {
94
+ getCertInfo(dn).then((res) => {
95
+ resolve(res)
96
+ })
97
+ })
98
+ } else if (signType === 'SkfSign') {
99
+ importG('SkfSign', () => import(/*webpackChunkName: "SkfSign"*/ './SkfSign/index.js')).then(({ getCertInfo }) => {
100
+ getCertInfo(dn).then((res) => {
101
+ resolve(res)
102
+ })
103
+ })
104
+ } else if (signType === 'NetSM3') {
105
+ importG('NetSM3', () => import(/*webpackChunkName: "NetSM3"*/ './NetSM3/index.js')).then(({ getCertInfo }) => {
106
+ getCertInfo(dn).then((res) => {
107
+ resolve(res)
108
+ })
109
+ })
110
+ } else if (signType === 'ItrusSign') {
111
+ importG('ItrusSign', () => import(/*webpackChunkName: "ItrusSign"*/ './Itrus/index.js')).then(({ getCert }) => {
112
+ try {
113
+ const itrusGetCert = getCert(dn)
114
+ resolve(itrusGetCert)
115
+ } catch (error) {
116
+ reject()
117
+ }
118
+ })
119
+ }
120
+ })
115
121
  }
116
122
 
117
123
  /**
@@ -120,9 +126,7 @@ export async function getCert(dn) {
120
126
  * @returns {Promise<void>}
121
127
  */
122
128
  export async function updateCert(cspName) {
123
- const { updateCert } = await importG('NetV3', () =>
124
- import(/*webpackChunkName: "NetV3"*/ './NetV3/index.js')
125
- )
129
+ const { updateCert } = await importG('NetV3', () => import(/*webpackChunkName: "NetV3"*/ './NetV3/index.js'))
126
130
  await updateCert(cspName)
127
131
  }
128
132
 
@@ -132,8 +136,6 @@ export async function updateCert(cspName) {
132
136
  * @returns {Promise<void>}
133
137
  */
134
138
  export async function updateCertHG(uno) {
135
- const { updateCertHG } = await importG('NetV3', () =>
136
- import(/*webpackChunkName: "NetV3"*/ './NetV3/index.js')
137
- )
139
+ const { updateCertHG } = await importG('NetV3', () => import(/*webpackChunkName: "NetV3"*/ './NetV3/index.js'))
138
140
  await updateCertHG(uno)
139
141
  }