eimzo-sign-core 0.1.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/README.md +62 -0
- package/dist/index.cjs +1340 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +247 -0
- package/dist/index.d.ts +247 -0
- package/dist/index.js +1330 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
- package/src/cert-utils.ts +53 -0
- package/src/client.ts +456 -0
- package/src/errors.ts +73 -0
- package/src/index.ts +45 -0
- package/src/raw-types.ts +65 -0
- package/src/types.ts +112 -0
- package/src/util.ts +69 -0
- package/src/vendor/VENDOR.md +59 -0
- package/src/vendor/e-imzo-client.js +477 -0
- package/src/vendor/e-imzo.js +483 -0
- package/src/vendor/index.ts +46 -0
- package/src/vendor/vendor.d.ts +15 -0
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
Date.prototype.yyyymmdd = function () {
|
|
3
|
+
var yyyy = this.getFullYear().toString();
|
|
4
|
+
var mm = (this.getMonth() + 1).toString(); // getMonth() is zero-based
|
|
5
|
+
var dd = this.getDate().toString();
|
|
6
|
+
return yyyy + (mm[1] ? mm : "0" + mm[0]) + (dd[1] ? dd : "0" + dd[0]); // padding
|
|
7
|
+
};
|
|
8
|
+
Date.prototype.ddmmyyyy = function () {
|
|
9
|
+
var yyyy = this.getFullYear().toString();
|
|
10
|
+
var mm = (this.getMonth() + 1).toString(); // getMonth() is zero-based
|
|
11
|
+
var dd = this.getDate().toString();
|
|
12
|
+
return (dd[1] ? dd : "0" + dd[0]) + "." + (mm[1] ? mm : "0" + mm[0]) + "." + yyyy; // padding
|
|
13
|
+
};
|
|
14
|
+
var dates = {
|
|
15
|
+
convert: function (d) {
|
|
16
|
+
// Converts the date in d to a date-object. The input can be:
|
|
17
|
+
// a date object: returned without modification
|
|
18
|
+
// an array : Interpreted as [year,month,day]. NOTE: month is 0-11.
|
|
19
|
+
// a number : Interpreted as number of milliseconds
|
|
20
|
+
// since 1 Jan 1970 (a timestamp)
|
|
21
|
+
// a string : Any format supported by the javascript engine, like
|
|
22
|
+
// "YYYY/MM/DD", "MM/DD/YYYY", "Jan 31 2009" etc.
|
|
23
|
+
// an object : Interpreted as an object with year, month and date
|
|
24
|
+
// attributes. **NOTE** month is 0-11.
|
|
25
|
+
return (
|
|
26
|
+
d.constructor === Date ? d :
|
|
27
|
+
d.constructor === Array ? new Date(d[0], d[1], d[2]) :
|
|
28
|
+
d.constructor === Number ? new Date(d) :
|
|
29
|
+
d.constructor === String ? new Date(d) :
|
|
30
|
+
typeof d === "object" ? new Date(d.year, d.month, d.date) :
|
|
31
|
+
NaN
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
compare: function (a, b) {
|
|
35
|
+
// Compare two dates (could be of any type supported by the convert
|
|
36
|
+
// function above) and returns:
|
|
37
|
+
// -1 : if a < b
|
|
38
|
+
// 0 : if a = b
|
|
39
|
+
// 1 : if a > b
|
|
40
|
+
// NaN : if a or b is an illegal date
|
|
41
|
+
// NOTE: The code inside isFinite does an assignment (=).
|
|
42
|
+
return (
|
|
43
|
+
isFinite(a = this.convert(a).valueOf()) &&
|
|
44
|
+
isFinite(b = this.convert(b).valueOf()) ?
|
|
45
|
+
(a > b) - (a < b) :
|
|
46
|
+
NaN
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
inRange: function (d, start, end) {
|
|
50
|
+
// Checks if date in d is between dates in start and end.
|
|
51
|
+
// Returns a boolean or NaN:
|
|
52
|
+
// true : if d is between start and end (inclusive)
|
|
53
|
+
// false : if d is before start or after end
|
|
54
|
+
// NaN : if one or more of the dates is illegal.
|
|
55
|
+
// NOTE: The code inside isFinite does an assignment (=).
|
|
56
|
+
return (
|
|
57
|
+
isFinite(d = this.convert(d).valueOf()) &&
|
|
58
|
+
isFinite(start = this.convert(start).valueOf()) &&
|
|
59
|
+
isFinite(end = this.convert(end).valueOf()) ?
|
|
60
|
+
start <= d && d <= end :
|
|
61
|
+
NaN
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
String.prototype.splitKeep = function (splitter, ahead) {
|
|
66
|
+
var self = this;
|
|
67
|
+
var result = [];
|
|
68
|
+
if (splitter != '') {
|
|
69
|
+
// Substitution of matched string
|
|
70
|
+
function getSubst(value) {
|
|
71
|
+
var substChar = value[0] == '0' ? '1' : '0';
|
|
72
|
+
var subst = '';
|
|
73
|
+
for (var i = 0; i < value.length; i++) {
|
|
74
|
+
subst += substChar;
|
|
75
|
+
}
|
|
76
|
+
return subst;
|
|
77
|
+
};
|
|
78
|
+
var matches = [];
|
|
79
|
+
// Getting mached value and its index
|
|
80
|
+
var replaceName = splitter instanceof RegExp ? "replace" : "replaceAll";
|
|
81
|
+
var r = self[replaceName](splitter, function (m, i, e) {
|
|
82
|
+
matches.push({value: m, index: i});
|
|
83
|
+
return getSubst(m);
|
|
84
|
+
});
|
|
85
|
+
// Finds split substrings
|
|
86
|
+
var lastIndex = 0;
|
|
87
|
+
for (var i = 0; i < matches.length; i++) {
|
|
88
|
+
var m = matches[i];
|
|
89
|
+
var nextIndex = ahead == true ? m.index : m.index + m.value.length;
|
|
90
|
+
if (nextIndex != lastIndex) {
|
|
91
|
+
var part = self.substring(lastIndex, nextIndex);
|
|
92
|
+
result.push(part);
|
|
93
|
+
lastIndex = nextIndex;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
;
|
|
97
|
+
if (lastIndex < self.length) {
|
|
98
|
+
var part = self.substring(lastIndex, self.length);
|
|
99
|
+
result.push(part);
|
|
100
|
+
}
|
|
101
|
+
;
|
|
102
|
+
} else {
|
|
103
|
+
result.add(self);
|
|
104
|
+
}
|
|
105
|
+
;
|
|
106
|
+
return result;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const EIMZOClient = {
|
|
110
|
+
NEW_API: false,
|
|
111
|
+
NEW_API2: false,
|
|
112
|
+
API_KEYS: [
|
|
113
|
+
'localhost', '96D0C1491615C82B9A54D9989779DF825B690748224C2B04F500F370D51827CE2644D8D4A82C18184D73AB8530BB8ED537269603F61DB0D03D2104ABF789970B',
|
|
114
|
+
'127.0.0.1', 'A7BCFA5D490B351BE0754130DF03A068F855DB4333D43921125B9CF2670EF6A40370C646B90401955E1F7BC9CDBF59CE0B2C5467D820BE189C845D0B79CFC96F'
|
|
115
|
+
],
|
|
116
|
+
checkVersion: function (success, fail) {
|
|
117
|
+
CAPIWS.version(function (event, data) {
|
|
118
|
+
if (data.success === true) {
|
|
119
|
+
if (data.major && data.minor) {
|
|
120
|
+
var installedVersion = parseInt(data.major) * 100 + parseInt(data.minor);
|
|
121
|
+
EIMZOClient.NEW_API = installedVersion >= 336;
|
|
122
|
+
EIMZOClient.NEW_API2 = installedVersion >= 412;
|
|
123
|
+
success(data.major, data.minor);
|
|
124
|
+
} else {
|
|
125
|
+
fail(null, 'E-IMZO Version is undefined');
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
fail(null, data.reason);
|
|
129
|
+
}
|
|
130
|
+
}, function (e) {
|
|
131
|
+
fail(e, null);
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
installApiKeys: function (success, fail) {
|
|
135
|
+
CAPIWS.apikey(EIMZOClient.API_KEYS, function (event, data) {
|
|
136
|
+
if (data.success) {
|
|
137
|
+
success();
|
|
138
|
+
} else {
|
|
139
|
+
fail(null, data.reason);
|
|
140
|
+
}
|
|
141
|
+
}, function (e) {
|
|
142
|
+
fail(e, null);
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
listAllUserKeys: function (itemIdGen, itemUiGen, success, fail) {
|
|
146
|
+
var items = [];
|
|
147
|
+
var errors = [];
|
|
148
|
+
if (!EIMZOClient.NEW_API) {
|
|
149
|
+
fail(null, 'Please install new version of E-IMZO');
|
|
150
|
+
} else {
|
|
151
|
+
if (EIMZOClient.NEW_API2) {
|
|
152
|
+
EIMZOClient._findPfxs2(itemIdGen, itemUiGen, items, errors, function (firstItmId2) {
|
|
153
|
+
if (items.length === 0 && errors.length > 0) {
|
|
154
|
+
fail(errors[0].e, errors[0].r);
|
|
155
|
+
} else {
|
|
156
|
+
var firstId = null;
|
|
157
|
+
if (items.length === 1) {
|
|
158
|
+
if (firstItmId2) {
|
|
159
|
+
firstId = firstItmId2;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
success(items, firstId);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
EIMZOClient._findPfxs2(itemIdGen, itemUiGen, items, errors, function (firstItmId2) {
|
|
167
|
+
EIMZOClient._findTokens2(itemIdGen, itemUiGen, items, errors, function (firstItmId3) {
|
|
168
|
+
if (items.length === 0 && errors.length > 0) {
|
|
169
|
+
fail(errors[0].e, errors[0].r);
|
|
170
|
+
} else {
|
|
171
|
+
var firstId = null;
|
|
172
|
+
if (items.length === 1) {
|
|
173
|
+
if (firstItmId2) {
|
|
174
|
+
firstId = firstItmId2;
|
|
175
|
+
} else if (firstItmId3) {
|
|
176
|
+
firstId = firstItmId3;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
success(items, firstId);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
idCardIsPLuggedIn: function (success, fail) {
|
|
187
|
+
if (!EIMZOClient.NEW_API2) {
|
|
188
|
+
success(false);
|
|
189
|
+
} else {
|
|
190
|
+
CAPIWS.callFunction({plugin: "idcard", name: "list_readers"}, function (event, data) {
|
|
191
|
+
if (data.success) {
|
|
192
|
+
success(data.readers.length > 0);
|
|
193
|
+
} else {
|
|
194
|
+
fail(null, data.reason);
|
|
195
|
+
}
|
|
196
|
+
}, function (e) {
|
|
197
|
+
fail(e, null);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
loadKey: function (itemObject, success, fail, verifyPassword) {
|
|
202
|
+
if (itemObject) {
|
|
203
|
+
var vo = itemObject;
|
|
204
|
+
if (vo.type === "pfx") {
|
|
205
|
+
CAPIWS.callFunction({
|
|
206
|
+
plugin: "pfx",
|
|
207
|
+
name: "load_key",
|
|
208
|
+
arguments: [vo.disk, vo.path, vo.name, vo.alias]
|
|
209
|
+
}, function (event, data) {
|
|
210
|
+
if (data.success) {
|
|
211
|
+
var id = data.keyId;
|
|
212
|
+
if (verifyPassword) {
|
|
213
|
+
CAPIWS.callFunction({
|
|
214
|
+
name: "verify_password",
|
|
215
|
+
plugin: "pfx",
|
|
216
|
+
arguments: [id]
|
|
217
|
+
}, function (event, data) {
|
|
218
|
+
if (data.success) {
|
|
219
|
+
success(id);
|
|
220
|
+
} else {
|
|
221
|
+
fail(null, data.reason);
|
|
222
|
+
}
|
|
223
|
+
}, function (e) {
|
|
224
|
+
fail(e, null);
|
|
225
|
+
});
|
|
226
|
+
} else {
|
|
227
|
+
success(id);
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
fail(null, data.reason);
|
|
231
|
+
}
|
|
232
|
+
}, function (e) {
|
|
233
|
+
fail(e, null);
|
|
234
|
+
});
|
|
235
|
+
} else if (vo.type === "ftjc") {
|
|
236
|
+
CAPIWS.callFunction({
|
|
237
|
+
plugin: "ftjc",
|
|
238
|
+
name: "load_key",
|
|
239
|
+
arguments: [vo.cardUID]
|
|
240
|
+
}, function (event, data) {
|
|
241
|
+
if (data.success) {
|
|
242
|
+
var id = data.keyId;
|
|
243
|
+
if (verifyPassword) {
|
|
244
|
+
CAPIWS.callFunction({
|
|
245
|
+
plugin: "ftjc",
|
|
246
|
+
name: "verify_pin",
|
|
247
|
+
arguments: [id, '1']
|
|
248
|
+
}, function (event, data) {
|
|
249
|
+
if (data.success) {
|
|
250
|
+
success(id);
|
|
251
|
+
} else {
|
|
252
|
+
fail(null, data.reason);
|
|
253
|
+
}
|
|
254
|
+
}, function (e) {
|
|
255
|
+
fail(e, null);
|
|
256
|
+
});
|
|
257
|
+
} else {
|
|
258
|
+
success(id);
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
fail(null, data.reason);
|
|
262
|
+
}
|
|
263
|
+
}, function (e) {
|
|
264
|
+
fail(e, null);
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
changeKeyPassword: function (itemObject, success, fail) {
|
|
270
|
+
if (itemObject) {
|
|
271
|
+
var vo = itemObject;
|
|
272
|
+
if (vo.type === "pfx") {
|
|
273
|
+
CAPIWS.callFunction({
|
|
274
|
+
plugin: "pfx",
|
|
275
|
+
name: "load_key",
|
|
276
|
+
arguments: [vo.disk, vo.path, vo.name, vo.alias]
|
|
277
|
+
}, function (event, data) {
|
|
278
|
+
if (data.success) {
|
|
279
|
+
var id = data.keyId;
|
|
280
|
+
CAPIWS.callFunction({
|
|
281
|
+
name: "change_password",
|
|
282
|
+
plugin: "pfx",
|
|
283
|
+
arguments: [id]
|
|
284
|
+
}, function (event, data) {
|
|
285
|
+
if (data.success) {
|
|
286
|
+
success();
|
|
287
|
+
} else {
|
|
288
|
+
fail(null, data.reason);
|
|
289
|
+
}
|
|
290
|
+
}, function (e) {
|
|
291
|
+
fail(e, null);
|
|
292
|
+
});
|
|
293
|
+
} else {
|
|
294
|
+
fail(null, data.reason);
|
|
295
|
+
}
|
|
296
|
+
}, function (e) {
|
|
297
|
+
fail(e, null);
|
|
298
|
+
});
|
|
299
|
+
} else if (vo.type === "ftjc") {
|
|
300
|
+
CAPIWS.callFunction({
|
|
301
|
+
plugin: "ftjc",
|
|
302
|
+
name: "load_key",
|
|
303
|
+
arguments: [vo.cardUID]
|
|
304
|
+
}, function (event, data) {
|
|
305
|
+
if (data.success) {
|
|
306
|
+
var id = data.keyId;
|
|
307
|
+
CAPIWS.callFunction({
|
|
308
|
+
name: "change_pin",
|
|
309
|
+
plugin: "ftjc",
|
|
310
|
+
arguments: [id, '1']
|
|
311
|
+
}, function (event, data) {
|
|
312
|
+
if (data.success) {
|
|
313
|
+
success();
|
|
314
|
+
} else {
|
|
315
|
+
fail(null, data.reason);
|
|
316
|
+
}
|
|
317
|
+
}, function (e) {
|
|
318
|
+
fail(e, null);
|
|
319
|
+
});
|
|
320
|
+
} else {
|
|
321
|
+
fail(null, data.reason);
|
|
322
|
+
}
|
|
323
|
+
}, function (e) {
|
|
324
|
+
fail(e, null);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
createPkcs7: function (id, data, timestamper, success, fail, detached, isDataBase64Encoded, enableAttachTimestamp = true) {
|
|
330
|
+
var data64;
|
|
331
|
+
if (isDataBase64Encoded === true) {
|
|
332
|
+
data64 = data
|
|
333
|
+
} else {
|
|
334
|
+
data64 = Base64.encode(data);
|
|
335
|
+
}
|
|
336
|
+
if (detached === true) {
|
|
337
|
+
detached = 'yes';
|
|
338
|
+
} else {
|
|
339
|
+
detached = 'no';
|
|
340
|
+
}
|
|
341
|
+
CAPIWS.callFunction({
|
|
342
|
+
plugin: "pkcs7",
|
|
343
|
+
name: "create_pkcs7",
|
|
344
|
+
arguments: [data64, id, detached]
|
|
345
|
+
}, function (event, data) {
|
|
346
|
+
if (data.success) {
|
|
347
|
+
var pkcs7 = data.pkcs7_64;
|
|
348
|
+
if (timestamper) {
|
|
349
|
+
var sn = data.signer_serial_number;
|
|
350
|
+
timestamper(data.signature_hex, function (tst) {
|
|
351
|
+
if(enableAttachTimestamp) {
|
|
352
|
+
CAPIWS.callFunction({
|
|
353
|
+
plugin: "pkcs7",
|
|
354
|
+
name: "attach_timestamp_token_pkcs7",
|
|
355
|
+
arguments: [pkcs7, sn, tst]
|
|
356
|
+
}, function (event, data) {
|
|
357
|
+
if (data.success) {
|
|
358
|
+
var pkcs7tst = data.pkcs7_64;
|
|
359
|
+
success(pkcs7tst);
|
|
360
|
+
} else {
|
|
361
|
+
fail(null, data.reason);
|
|
362
|
+
}
|
|
363
|
+
}, function (e) {
|
|
364
|
+
fail(e, null);
|
|
365
|
+
});
|
|
366
|
+
} else {
|
|
367
|
+
success(tst);
|
|
368
|
+
}
|
|
369
|
+
}, fail, data.pkcs7_64);
|
|
370
|
+
} else {
|
|
371
|
+
success(pkcs7);
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
fail(null, data.reason);
|
|
375
|
+
}
|
|
376
|
+
}, function (e) {
|
|
377
|
+
fail(e, null);
|
|
378
|
+
});
|
|
379
|
+
},
|
|
380
|
+
_getX500Val: function (s, f) {
|
|
381
|
+
var res = s.splitKeep(/,[A-Z]+=/g, true);
|
|
382
|
+
for (var i in res) {
|
|
383
|
+
var n = res[i].search((i > 0 ? "," : "") + f + "=");
|
|
384
|
+
if (n !== -1) {
|
|
385
|
+
return res[i].slice(n + f.length + 1 + (i > 0 ? 1 : 0));
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return "";
|
|
389
|
+
},
|
|
390
|
+
_findPfxs2: function (itemIdGen, itemUiGen, items, errors, callback) {
|
|
391
|
+
var itmkey0;
|
|
392
|
+
CAPIWS.callFunction({plugin: "pfx", name: "list_all_certificates"}, function (event, data) {
|
|
393
|
+
if (data.success) {
|
|
394
|
+
for (var rec in data.certificates) {
|
|
395
|
+
var el = data.certificates[rec];
|
|
396
|
+
var x500name_ex = el.alias.toUpperCase();
|
|
397
|
+
x500name_ex = x500name_ex.replace("1.2.860.3.16.1.1=", "INN=");
|
|
398
|
+
x500name_ex = x500name_ex.replace("1.2.860.3.16.1.2=", "PINFL=");
|
|
399
|
+
var vo = {
|
|
400
|
+
disk: el.disk,
|
|
401
|
+
path: el.path,
|
|
402
|
+
name: el.name,
|
|
403
|
+
alias: el.alias,
|
|
404
|
+
serialNumber: EIMZOClient._getX500Val(x500name_ex, "SERIALNUMBER"),
|
|
405
|
+
validFrom: new Date(EIMZOClient._getX500Val(x500name_ex, "VALIDFROM").replace(/\./g, "-").replace(" ", "T")),
|
|
406
|
+
validTo: new Date(EIMZOClient._getX500Val(x500name_ex, "VALIDTO").replace(/\./g, "-").replace(" ", "T")),
|
|
407
|
+
CN: EIMZOClient._getX500Val(x500name_ex, "CN"),
|
|
408
|
+
TIN: (EIMZOClient._getX500Val(x500name_ex, "INN") ? EIMZOClient._getX500Val(x500name_ex, "INN") : EIMZOClient._getX500Val(x500name_ex, "UID")),
|
|
409
|
+
UID: EIMZOClient._getX500Val(x500name_ex, "UID"),
|
|
410
|
+
PINFL: EIMZOClient._getX500Val(x500name_ex, "PINFL"),
|
|
411
|
+
O: EIMZOClient._getX500Val(x500name_ex, "O"),
|
|
412
|
+
T: EIMZOClient._getX500Val(x500name_ex, "T"),
|
|
413
|
+
type: 'pfx'
|
|
414
|
+
};
|
|
415
|
+
if (!vo.TIN && !vo.PINFL)
|
|
416
|
+
continue;
|
|
417
|
+
var itmkey = itemIdGen(vo, rec);
|
|
418
|
+
if (!itmkey0) {
|
|
419
|
+
itmkey0 = itmkey;
|
|
420
|
+
}
|
|
421
|
+
var itm = itemUiGen(itmkey, vo);
|
|
422
|
+
items.push(itm);
|
|
423
|
+
}
|
|
424
|
+
} else {
|
|
425
|
+
errors.push({r: data.reason});
|
|
426
|
+
}
|
|
427
|
+
callback(itmkey0);
|
|
428
|
+
}, function (e) {
|
|
429
|
+
errors.push({e: e});
|
|
430
|
+
callback(itmkey0);
|
|
431
|
+
});
|
|
432
|
+
},
|
|
433
|
+
_findTokens2: function (itemIdGen, itemUiGen, items, errors, callback) {
|
|
434
|
+
var itmkey0;
|
|
435
|
+
CAPIWS.callFunction({plugin: "ftjc", name: "list_all_keys", arguments: ['']}, function (event, data) {
|
|
436
|
+
if (data.success) {
|
|
437
|
+
for (var rec in data.tokens) {
|
|
438
|
+
var el = data.tokens[rec];
|
|
439
|
+
var x500name_ex = el.info.toUpperCase();
|
|
440
|
+
x500name_ex = x500name_ex.replace("1.2.860.3.16.1.1=", "INN=");
|
|
441
|
+
x500name_ex = x500name_ex.replace("1.2.860.3.16.1.2=", "PINFL=");
|
|
442
|
+
var vo = {
|
|
443
|
+
cardUID: el.cardUID,
|
|
444
|
+
statusInfo: el.statusInfo,
|
|
445
|
+
ownerName: el.ownerName,
|
|
446
|
+
info: el.info,
|
|
447
|
+
serialNumber: EIMZOClient._getX500Val(x500name_ex, "SERIALNUMBER"),
|
|
448
|
+
validFrom: new Date(EIMZOClient._getX500Val(x500name_ex, "VALIDFROM")),
|
|
449
|
+
validTo: new Date(EIMZOClient._getX500Val(x500name_ex, "VALIDTO")),
|
|
450
|
+
CN: EIMZOClient._getX500Val(x500name_ex, "CN"),
|
|
451
|
+
TIN: (EIMZOClient._getX500Val(x500name_ex, "INN") ? EIMZOClient._getX500Val(x500name_ex, "INN") : EIMZOClient._getX500Val(x500name_ex, "UID")),
|
|
452
|
+
UID: EIMZOClient._getX500Val(x500name_ex, "UID"),
|
|
453
|
+
PINFL: EIMZOClient._getX500Val(x500name_ex, "PINFL"),
|
|
454
|
+
O: EIMZOClient._getX500Val(x500name_ex, "O"),
|
|
455
|
+
T: EIMZOClient._getX500Val(x500name_ex, "T"),
|
|
456
|
+
type: 'ftjc'
|
|
457
|
+
};
|
|
458
|
+
if (!vo.TIN && !vo.PINFL)
|
|
459
|
+
continue;
|
|
460
|
+
var itmkey = itemIdGen(vo, rec);
|
|
461
|
+
if (!itmkey0) {
|
|
462
|
+
itmkey0 = itmkey;
|
|
463
|
+
}
|
|
464
|
+
var itm = itemUiGen(itmkey, vo);
|
|
465
|
+
items.push(itm);
|
|
466
|
+
}
|
|
467
|
+
} else {
|
|
468
|
+
errors.push({r: data.reason});
|
|
469
|
+
}
|
|
470
|
+
callback(itmkey0);
|
|
471
|
+
}, function (e) {
|
|
472
|
+
errors.push({e: e});
|
|
473
|
+
callback(itmkey0);
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
|