n20-common-lib 3.2.25 → 3.2.27

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": "3.2.25",
3
+ "version": "3.2.27",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -11,6 +11,20 @@
11
11
  background: #e9f2ff !important;
12
12
  }
13
13
 
14
+ &-item.notStyle{
15
+ border: 0px;
16
+ background: transparent !important;
17
+ padding: 0;
18
+ .el-form-item__label{
19
+ display: none;
20
+ }
21
+
22
+ .el-form-item__content{
23
+ height: auto;
24
+ }
25
+ }
26
+
27
+
14
28
  &-body {
15
29
 
16
30
  .el-form-item,
@@ -5,7 +5,7 @@
5
5
  <el-form-item
6
6
  v-for="item in GroupData"
7
7
  :key="getOnlyKey(item)"
8
- :class="[prefixCls + '-item', activeClassMap[item.value || item[onlyKey]] || '']"
8
+ :class="[prefixCls + '-item', activeClassMap[item.value || item[onlyKey]] || '',{notStyle: item.notStyle}]"
9
9
  :label="item.label"
10
10
  :required="!!item.required"
11
11
  :disabled="item.props && item.props.disabled"
@@ -249,14 +249,16 @@ export default {
249
249
  this.GroupData.forEach((item) => {
250
250
  const key = item.value || item[this.onlyKey]
251
251
  let isActive = false
252
- if (item.type === 'numberrange') {
253
- isActive = hasRange(item.startValue, item.endValue)
254
- } else if (rangeTypes.includes(item.type)) {
255
- isActive = hasRange(item.startDate, item.endDate)
256
- } else if (item.slotFields && item.slotFields.length > 0) {
257
- isActive = item.slotFields.some((field) => hasValue(model[field]))
258
- } else {
259
- isActive = hasValue(model[item.value])
252
+ if(!item.notActive) {
253
+ if (item.type === 'numberrange') {
254
+ isActive = hasRange(item.startValue, item.endValue)
255
+ } else if (rangeTypes.includes(item.type)) {
256
+ isActive = hasRange(item.startDate, item.endDate)
257
+ } else if (item.slotFields && item.slotFields.length > 0) {
258
+ isActive = item.slotFields.some((field) => hasValue(model[field]))
259
+ } else {
260
+ isActive = hasValue(model[item.value])
261
+ }
260
262
  }
261
263
  map[key] = isActive ? this.prefixCls + '-active' : ''
262
264
  })
@@ -814,7 +814,7 @@ export default {
814
814
 
815
815
  <style scoped>
816
816
  .filter.is-hidden {
817
- padding: 4px;
817
+ padding:0 !important;
818
818
  border-bottom: none !important;
819
819
  }
820
820
  </style>
@@ -1,6 +1,7 @@
1
1
  import { Message, MessageBox, Notification } from 'element-ui'
2
2
  import { codeDate } from '../codeMap.js'
3
3
  import { IWSAgent } from './InfosecNetSignCNGAgent.min.js'
4
+ import { isDnMatched } from '../dn.js'
4
5
  /*
5
6
  获取证书列表接口:2.7.1 IWSASkfGetCertList (DllFilePath, SucceedFunction)
6
7
  Attached签名接口:2.7.2 IWSASkfSignData (PlainText, CertIndex, UsbKeyPin, DigestArithmetic, SucceedFunction)
@@ -62,17 +63,14 @@ function checkAvailable(fn, url, count) {
62
63
  }
63
64
 
64
65
  function verifyDn(dnList, dn) {
65
- if (dnList.length === 0) return 'dnListEmpty'
66
66
  if (!dnList) return 'Empty'
67
+ if (dnList.length === 0) return 'dnListEmpty'
67
68
  if (!dn) return 'dnIsEmpty'
68
69
 
69
- let userDnAttrsArr = dn.split(',').map((c) => c.trim())
70
-
71
70
  let isIn = false
72
71
  let index = 0
73
72
  dnList.find((C, i) => {
74
- let dnAttrsArr = C.certDN.split(',').map((c) => c.trim())
75
- if (dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
73
+ if (isDnMatched(C.certDN, dn)) {
76
74
  index = i
77
75
  return (isIn = true)
78
76
  }
@@ -1,6 +1,7 @@
1
1
  import { Message, MessageBox, Notification } from 'element-ui'
2
2
  import { codeDate } from '../codeMap.js'
3
3
  import { IWSAgent } from './InfosecNetSignCNGAgent.min.js'
4
+ import { isDnMatched } from '../dn.js'
4
5
  /*
5
6
  获取证书列表接口:2.7.1 IWSASkfGetCertList (DllFilePath, SucceedFunction)
6
7
  Attached签名接口:2.7.2 IWSASkfSignData (PlainText, CertIndex, UsbKeyPin, DigestArithmetic, SucceedFunction)
@@ -62,17 +63,14 @@ function checkAvailable(fn, url, count) {
62
63
  }
63
64
 
64
65
  function verifyDn(dnList, dn) {
65
- if (dnList.length === 0) return 'dnListEmpty'
66
66
  if (!dnList) return 'Empty'
67
+ if (dnList.length === 0) return 'dnListEmpty'
67
68
  if (!dn) return 'dnIsEmpty'
68
69
 
69
70
  let checkRes = 0
70
- let userDnAttrsArr = dn.split(',').map((c) => c.trim())
71
-
72
71
  let isIn = false
73
72
  dnList.find((C) => {
74
- let dnAttrsArr = C.certDN.split(',').map((c) => c.trim())
75
- if (dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
73
+ if (isDnMatched(C.certDN, dn)) {
76
74
  return (isIn = true)
77
75
  }
78
76
  })
@@ -0,0 +1,57 @@
1
+ function parseDnAttrs(dn) {
2
+ if (!dn || typeof dn !== 'string') return []
3
+ return dn
4
+ .split(',')
5
+ .map(item => item.trim())
6
+ .filter(Boolean)
7
+ .map(item => {
8
+ const matched = item.match(/^([^=]+)\s*=\s*(.*)$/)
9
+ if (!matched) return null
10
+ return {
11
+ key: matched[1].trim().toUpperCase(),
12
+ value: matched[2].trim().replace(/\s+/g, ' ')
13
+ }
14
+ })
15
+ .filter(item => item && item.key && item.value)
16
+ }
17
+
18
+ function hasAttr(attrs, target) {
19
+ return attrs.some(
20
+ item => item.key === target.key && item.value === target.value
21
+ )
22
+ }
23
+
24
+ function getCn(attrs) {
25
+ const cn = attrs.find(item => item.key === 'CN')
26
+ return cn && cn.value
27
+ }
28
+
29
+ export function parseCA(dn) {
30
+ return getCn(parseDnAttrs(dn)) || ''
31
+ }
32
+
33
+ export function isCertCheckFailed(result) {
34
+ return (
35
+ result === -1 ||
36
+ result === false ||
37
+ ['dnListEmpty', 'Empty', 'dnIsEmpty'].includes(result)
38
+ )
39
+ }
40
+
41
+ export function isDnMatched(certDn, userDn) {
42
+ if (!certDn || !userDn) return false
43
+ if (certDn.trim() === userDn.trim()) return true
44
+
45
+ const certAttrs = parseDnAttrs(certDn)
46
+ const userAttrs = parseDnAttrs(userDn)
47
+ if (!certAttrs.length || !userAttrs.length) return false
48
+
49
+ if (userAttrs.every(attr => hasAttr(certAttrs, attr))) return true
50
+ if (certAttrs.every(attr => hasAttr(userAttrs, attr))) return true
51
+
52
+ if (certAttrs.length > 1 && userAttrs.length > 1) return false
53
+
54
+ const certCn = getCn(certAttrs)
55
+ const userCn = getCn(userAttrs)
56
+ return certCn && userCn && certCn === userCn
57
+ }
@@ -1,7 +1,7 @@
1
- import importG from '../../utils/importGlobal.js'
2
-
3
1
  import CaMap from './CaMap.js'
4
2
 
3
+ import importG from '../../utils/importGlobal.js'
4
+
5
5
  /**
6
6
  * 统一处理签名逻辑
7
7
  * @param {Object} config - 签名配置
@@ -93,7 +93,6 @@ export async function getSign(p1, p2, p3) {
93
93
  */
94
94
  export function getCert(dn) {
95
95
  let signType = window.sessionStorage.getItem('signType')
96
- console.log('signType', signType)
97
96
  return new Promise((resolve, reject) => {
98
97
  if (signType === 'inetSign' /* 信安CA */) {
99
98
  // 是否使用信安3.0版本sdk (默认使用2.0版本)
@@ -1,6 +1,8 @@
1
1
  // Attached方式签名
2
2
  import { Message, Notification } from 'element-ui'
3
+
3
4
  import { IWSAgent } from './InfosecNetSignCNGAgent.min.js'
5
+ import { isCertCheckFailed, isDnMatched, parseCA } from './dn.js'
4
6
 
5
7
  const {
6
8
  IWSASetTimeOut,
@@ -81,7 +83,7 @@ export function verifySign(signedMsg) {
81
83
  */
82
84
  export async function getSign(plain, dn) {
83
85
  let index = await getCertInfo(dn)
84
- if (index === -1) return
86
+ if (isCertCheckFailed(index)) return
85
87
  let plainText = typeof plain === 'object' ? JSON.stringify(plain) : plain
86
88
 
87
89
  return await performSign(plainText, index)
@@ -98,22 +100,25 @@ export function getCertInfo(dn) {
98
100
  }
99
101
  if (!dn) {
100
102
  Message.error('没有获取到签名参数DN!')
101
- return false
103
+ return 'dnIsEmpty'
102
104
  }
103
105
  return new Promise((resolve, reject) => {
104
106
  let certInfo
105
107
  IWSAGetAllCertsListInfoByCertDN('', 'Sign', parseCA(dn), 0, (dnList) => {
106
108
  if (!dn) {
107
109
  Message.error('没有获取到签名参数DN!')
108
- reject()
110
+ resolve('dnIsEmpty')
111
+ return
109
112
  }
110
113
  if (!dnList) {
111
114
  Message.error('没有获取到证书列表!')
112
- reject()
115
+ resolve('Empty')
116
+ return
113
117
  }
114
118
  if (dnList.length === 0) {
115
119
  Message.error('获取到的证书列表为空!')
116
- reject()
120
+ resolve('dnListEmpty')
121
+ return
117
122
  }
118
123
 
119
124
  certInfo = verifyDn(dnList, dn)
@@ -149,12 +154,6 @@ export async function performSign(plain, index) {
149
154
  * @param {string} dn 要解析的Dn
150
155
  * @returns {string} 解析后的CN
151
156
  */
152
- function parseCA(dn) {
153
- const mark = /^CN=/
154
- let CN = dn.split(',').find((b) => mark.test(b))
155
- return CN ? CN.replace(mark, '') : ''
156
- }
157
-
158
157
  /**
159
158
  * 验证Dn是否存在于Dn列表中
160
159
  * @param {Array} dnList 获取到的Dn列表
@@ -162,12 +161,9 @@ function parseCA(dn) {
162
161
  * @returns {number} - 如果找到匹配的 DN,则返回其在 dnList 中的索引;如果未找到,则返回 -1
163
162
  */
164
163
  function verifyDn(dnList, dn) {
165
- let userDnAttrsArr = dn.split(',').map((c) => c.trim())
166
-
167
164
  let index = -1
168
165
  dnList.find((C, i) => {
169
- let dnAttrsArr = C.certDN.split(',').map((c) => c.trim())
170
- if (dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
166
+ if (isDnMatched(C.certDN, dn)) {
171
167
  index = i
172
168
  return true
173
169
  }
@@ -1,6 +1,8 @@
1
1
  // Attached方式签名
2
- import { Message, MessageBox,Notification } from 'element-ui'
2
+ import { Message, MessageBox, Notification } from 'element-ui'
3
+
3
4
  import { IWSAgent } from './InfosecNetSignCNGAgent.min.js'
5
+ import { isCertCheckFailed, isDnMatched } from '../dn.js'
4
6
 
5
7
  const {
6
8
  IWSASetTimeOut,
@@ -15,7 +17,7 @@ const {
15
17
  IWSASetTimeOut(6000)
16
18
  let certIndex = 0
17
19
  let certDN = ''
18
- let certType='SHA1'
20
+ let certType = 'SHA1'
19
21
  function getDN() {
20
22
  let dn
21
23
  let userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
@@ -83,14 +85,15 @@ export function verifySign(signedMsg) {
83
85
  */
84
86
  export async function getSign(plain, dn) {
85
87
  let index = await getCertInfo(dn)
86
- if (index === -1) return
88
+ if (isCertCheckFailed(index)) return
87
89
  let plainText = typeof plain === 'object' ? JSON.stringify(plain) : plain
88
90
  if (
89
91
  navigator.platform.toLowerCase().includes('linux') ||
90
92
  navigator.userAgent.toLowerCase().includes('linux') ||
91
93
  // 检查是否为银河麒麟特有的环境变量或特征
92
94
  typeof window.KylinOS !== 'undefined' ||
93
- document.documentElement.dataset.osType === 'kylin'||certType==='SM3'
95
+ document.documentElement.dataset.osType === 'kylin' ||
96
+ certType === 'SM3'
94
97
  ) {
95
98
  // 签名
96
99
  return await MessageBox.prompt('请输入PIN码', '提示', {
@@ -101,10 +104,9 @@ export async function getSign(plain, dn) {
101
104
  }).then(({ value }) => {
102
105
  return performSignSkf(plainText, value)
103
106
  })
104
- }else{
107
+ } else {
105
108
  return await performSign(plainText, index)
106
109
  }
107
-
108
110
  }
109
111
 
110
112
  /**
@@ -118,7 +120,7 @@ export function getCertInfo(dn) {
118
120
  }
119
121
  if (!dn) {
120
122
  Message.error('没有获取到签名参数DN!')
121
- return false
123
+ return 'dnIsEmpty'
122
124
  }
123
125
  if (
124
126
  navigator.platform.toLowerCase().includes('linux') ||
@@ -134,15 +136,18 @@ export function getCertInfo(dn) {
134
136
  IWSAGetAllCertsListInfo('infosec.sm2', 'Sign', 0, (dnList) => {
135
137
  if (!dn) {
136
138
  Message.error('没有获取到签名参数DN!')
137
- reject()
139
+ resolve('dnIsEmpty')
140
+ return
138
141
  }
139
142
  if (!dnList) {
140
143
  Message.error('没有获取到证书列表!')
141
- reject()
144
+ resolve('Empty')
145
+ return
142
146
  }
143
147
  if (dnList.length === 0) {
144
148
  Message.error('用户证书信息与当前用户不匹配!')
145
- reject()
149
+ resolve('dnListEmpty')
150
+ return
146
151
  }
147
152
 
148
153
  certInfo = verifyDn(dnList, dn)
@@ -216,7 +221,7 @@ async function performSignSkf(plainText, value) {
216
221
  } else {
217
222
  arg = process.env.VUE_APP_NetSign_ARG || window.VUE_APP_NetSign_ARG || 'WTSKFInterface.dll'
218
223
  }
219
- IWSASkfDetachedSignDefaultDN(plainText, certDN, value, certType,arg,'1', (errorCode, signedData) => {
224
+ IWSASkfDetachedSignDefaultDN(plainText, certDN, value, certType, arg, '1', (errorCode, signedData) => {
220
225
  if (errorCode === 0 || errorCode === '0') {
221
226
  resolve(signedData)
222
227
  } else {
@@ -234,18 +239,15 @@ async function performSignSkf(plainText, value) {
234
239
  * @returns {number} - 如果找到匹配的 DN,则返回其在 dnList 中的索引;如果未找到,则返回 -1
235
240
  */
236
241
  function verifyDn(dnList, dn) {
237
- let userDnAttrsArr = dn.split(',').map((c) => c.trim())
238
242
  let index = -1
239
243
  // 先过滤满足证书的条件
240
244
  let dnListA = JSON.parse(JSON.stringify(dnList)).filter((C, i) => {
241
- let dnAttrsArr = C.certDN.split(',').map((c) => c.trim())
242
- if (dnAttrsArr.every((dnAttr) => userDnAttrsArr.includes(dnAttr))) {
245
+ if (isDnMatched(C.certDN, dn)) {
243
246
  C.index = i
244
247
  certDN = C.certDN
245
248
  return C
246
249
  }
247
250
  })
248
- console.log(dnListA)
249
251
  if (dnListA.length > 0) {
250
252
  for (let i = 0; i < dnListA.length; i++) {
251
253
  if (dnListA[i].CertType === 'SM2' && dnListA[i].KeyUsage === 'signature') {
@@ -253,8 +255,6 @@ function verifyDn(dnList, dn) {
253
255
  certIndex = dnListA[i].index
254
256
  certType = 'SM3'
255
257
  break
256
- } else {
257
- index = -1
258
258
  }
259
259
  }
260
260
  }
@@ -266,8 +266,6 @@ function verifyDn(dnList, dn) {
266
266
  certIndex = dnListA[i].index
267
267
  certType = 'SHA1'
268
268
  break
269
- } else {
270
- index = -1
271
269
  }
272
270
  }
273
271
  }