@gerege-systems/eid-mongolia-sdk 0.40.0 → 0.40.2
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 +1 -1
- package/dist/button.cjs +2 -1
- package/dist/button.js +2 -1
- package/dist/{chunk-MA4RMWBO.js → chunk-4JAA4RON.js} +31 -17
- package/dist/convert.js +3 -3
- package/dist/pades.cjs +32 -22
- package/dist/pades.js +2 -6
- package/dist/validate.cjs +32 -18
- package/dist/validate.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -221,7 +221,7 @@ eid-login-button::part(icon) { height: 18px; }
|
|
|
221
221
|
| `--eid-fg-muted` | хоёрдогч текст | `hsl(215 19% 35%)` | `hsl(213 27% 84%)` |
|
|
222
222
|
| `--eid-fg-subtle` | тайлбар, placeholder | `hsl(215 16% 45%)` | `hsl(215 20% 65%)` |
|
|
223
223
|
| `--eid-border` | цонх, QR, тусгаарлагч | `hsl(214 32% 91%)` | `hsl(217 33% 17%)` |
|
|
224
|
-
| `--eid-border-strong` | outline товч, input | `hsl(213 27% 84%)` | `hsl(215
|
|
224
|
+
| `--eid-border-strong` | outline товч, input | `hsl(213 27% 84%)` | `hsl(215 20% 45%)` |
|
|
225
225
|
| `--eid-warning-bg` / `-border` / `-fg` | сүлжээний анхааруулга | `hsl(48 100% 96%)` / `hsl(45 95% 78%)` / `hsl(23 75% 33%)` | `hsl(20 60% 10%)` / `hsl(22 70% 26%)` / `hsl(40 92% 65%)` |
|
|
226
226
|
| `--eid-danger-fg` | алдаа | `hsl(0 74% 42%)` | `hsl(0 91% 71%)` |
|
|
227
227
|
| `--eid-radius` / `--eid-radius-lg` (theme-гүй) | булан | `6px` / `8px` | — |
|
package/dist/button.cjs
CHANGED
|
@@ -705,7 +705,7 @@ var EID_COLOR_TOKENS = [
|
|
|
705
705
|
["fg-muted", "hsl(215 19% 35%)", "hsl(213 27% 84%)"],
|
|
706
706
|
["fg-subtle", "hsl(215 16% 45%)", "hsl(215 20% 65%)"],
|
|
707
707
|
["border", "hsl(214 32% 91%)", "hsl(217 33% 17%)"],
|
|
708
|
-
["border-strong", "hsl(213 27% 84%)", "hsl(215
|
|
708
|
+
["border-strong", "hsl(213 27% 84%)", "hsl(215 20% 45%)"],
|
|
709
709
|
["accent", "oklch(0.534 0.2 259)", "oklch(0.64 0.15 259)"],
|
|
710
710
|
["accent-fg", "#fff", "hsl(229 50% 6%)"],
|
|
711
711
|
["accent-subtle", "oklch(0.97 0.03 259)", "oklch(0.24 0.06 259)"],
|
|
@@ -726,6 +726,7 @@ button, input { font-family: inherit; }
|
|
|
726
726
|
`;
|
|
727
727
|
var DARK_CSS = `:host { color-scheme: dark;
|
|
728
728
|
${darkVars} }
|
|
729
|
+
.btn:disabled { opacity: 1; background: var(--_eid-bg-muted); color: var(--_eid-fg-subtle); border-color: var(--_eid-border-strong); }
|
|
729
730
|
`;
|
|
730
731
|
var CSS_REST = `
|
|
731
732
|
*, *::before, *::after { box-sizing: border-box; }
|
package/dist/button.js
CHANGED
|
@@ -674,7 +674,7 @@ var EID_COLOR_TOKENS = [
|
|
|
674
674
|
["fg-muted", "hsl(215 19% 35%)", "hsl(213 27% 84%)"],
|
|
675
675
|
["fg-subtle", "hsl(215 16% 45%)", "hsl(215 20% 65%)"],
|
|
676
676
|
["border", "hsl(214 32% 91%)", "hsl(217 33% 17%)"],
|
|
677
|
-
["border-strong", "hsl(213 27% 84%)", "hsl(215
|
|
677
|
+
["border-strong", "hsl(213 27% 84%)", "hsl(215 20% 45%)"],
|
|
678
678
|
["accent", "oklch(0.534 0.2 259)", "oklch(0.64 0.15 259)"],
|
|
679
679
|
["accent-fg", "#fff", "hsl(229 50% 6%)"],
|
|
680
680
|
["accent-subtle", "oklch(0.97 0.03 259)", "oklch(0.24 0.06 259)"],
|
|
@@ -695,6 +695,7 @@ button, input { font-family: inherit; }
|
|
|
695
695
|
`;
|
|
696
696
|
var DARK_CSS = `:host { color-scheme: dark;
|
|
697
697
|
${darkVars} }
|
|
698
|
+
.btn:disabled { opacity: 1; background: var(--_eid-bg-muted); color: var(--_eid-fg-subtle); border-color: var(--_eid-border-strong); }
|
|
698
699
|
`;
|
|
699
700
|
var CSS_REST = `
|
|
700
701
|
*, *::before, *::after { box-sizing: border-box; }
|
|
@@ -148,8 +148,16 @@ function zlibInflate(src, limit = 64 << 20, initial) {
|
|
|
148
148
|
if (flg & 32) throw new InflateError("zlib: preset dictionary");
|
|
149
149
|
return inflateRaw(src.subarray(2), limit, void 0, initial);
|
|
150
150
|
}
|
|
151
|
+
function zlibInflatePrefix(src, limit, initial) {
|
|
152
|
+
if (src.length < 2) throw new InflateError("zlib: header \u0430\u043B\u0433\u0430");
|
|
153
|
+
const cmf = src[0];
|
|
154
|
+
const flg = src[1];
|
|
155
|
+
if ((cmf & 15) !== 8 || cmf >> 4 > 7 || (cmf << 8 | flg) % 31 !== 0) throw new InflateError("zlib: header \u0431\u0443\u0440\u0443\u0443");
|
|
156
|
+
if (flg & 32) throw new InflateError("zlib: preset dictionary");
|
|
157
|
+
return inflate(src.subarray(2), limit, void 0, initial, false, true);
|
|
158
|
+
}
|
|
151
159
|
function inflateRaw(src, limit = 64 << 20, info, initial) {
|
|
152
|
-
return inflate(src, limit, info, initial, false);
|
|
160
|
+
return inflate(src, limit, info, initial, false, false);
|
|
153
161
|
}
|
|
154
162
|
function zlibInflateStrict(src, limit) {
|
|
155
163
|
if (src.length < 2) throw new InflateError("zlib: header \u0430\u043B\u0433\u0430");
|
|
@@ -163,7 +171,7 @@ function zlibInflateStrict(src, limit) {
|
|
|
163
171
|
start = 6;
|
|
164
172
|
}
|
|
165
173
|
const info = { end: 0, truncated: false };
|
|
166
|
-
const out = inflate(src.subarray(start), limit, info, void 0, true);
|
|
174
|
+
const out = inflate(src.subarray(start), limit, info, void 0, true, false);
|
|
167
175
|
if (info.truncated) throw new InflateError("inflate: \u04E9\u0433\u04E9\u0433\u0434\u04E9\u043B \u0434\u0443\u0442\u0443\u0443");
|
|
168
176
|
const at = start + info.end;
|
|
169
177
|
if (at + 4 > src.length) throw new InflateError("zlib: adler32 \u0430\u043B\u0433\u0430");
|
|
@@ -200,7 +208,7 @@ function complete(lengths, n) {
|
|
|
200
208
|
}
|
|
201
209
|
return sum === 2 ** max || sum === 1 && max === 1 && count === 1;
|
|
202
210
|
}
|
|
203
|
-
function inflate(src, limit, info, initial, strict) {
|
|
211
|
+
function inflate(src, limit, info, initial, strict, prefix) {
|
|
204
212
|
let pos = 0;
|
|
205
213
|
let bitBuf = 0;
|
|
206
214
|
let bitCnt = 0;
|
|
@@ -244,7 +252,7 @@ function inflate(src, limit, info, initial, strict) {
|
|
|
244
252
|
try {
|
|
245
253
|
inflateBlocks();
|
|
246
254
|
} catch (e) {
|
|
247
|
-
if (!(e instanceof Truncated)) throw e;
|
|
255
|
+
if (!(e instanceof Truncated) && !(prefix && e instanceof InflateError && !(e instanceof InflateLimitError))) throw e;
|
|
248
256
|
if (info) info.truncated = true;
|
|
249
257
|
}
|
|
250
258
|
if (info) info.end = pos;
|
|
@@ -1070,7 +1078,6 @@ var StructureError = class extends Error {
|
|
|
1070
1078
|
this.name = "StructureError";
|
|
1071
1079
|
}
|
|
1072
1080
|
};
|
|
1073
|
-
var ENCRYPT_REF = /\/Encrypt(?:[\t\n\f\r ]+\d+[\t\n\f\r ]+\d+[\t\n\f\r ]+R|[\t\n\f\r ]*<<)/;
|
|
1074
1081
|
var isSpace2 = (c) => c === 0 || c === 9 || c === 10 || c === 12 || c === 13 || c === 32;
|
|
1075
1082
|
var isDelim2 = (c) => c === 40 || c === 41 || c === 60 || c === 62 || c === 91 || c === 93 || c === 123 || c === 125 || c === 47 || c === 37;
|
|
1076
1083
|
var INT_RE = /^[+-]?\d+$/;
|
|
@@ -1161,14 +1168,12 @@ var Lex = class {
|
|
|
1161
1168
|
}
|
|
1162
1169
|
};
|
|
1163
1170
|
var Scan = class {
|
|
1164
|
-
constructor(budget, inflateLeft
|
|
1171
|
+
constructor(budget, inflateLeft) {
|
|
1165
1172
|
this.budget = budget;
|
|
1166
1173
|
this.inflateLeft = inflateLeft;
|
|
1167
|
-
this.encrypted = encrypted;
|
|
1168
1174
|
}
|
|
1169
1175
|
budget;
|
|
1170
1176
|
inflateLeft;
|
|
1171
|
-
encrypted;
|
|
1172
1177
|
/** Дээд түвшний /Size > MAX_XREF_SIZE. */
|
|
1173
1178
|
bigSize = false;
|
|
1174
1179
|
/** b[start:]-аас reader-ийн нэг объектыг (давхар `N G obj`-ийг оруулаад) гүнээр шалгана. */
|
|
@@ -1215,6 +1220,10 @@ var Scan = class {
|
|
|
1215
1220
|
case 4 /* Dict */:
|
|
1216
1221
|
if (stack.length >= MAX_NESTING) throw new StructureError();
|
|
1217
1222
|
if (stack.length === 1 && stack[0].dict && stack[0].key === "DecodeParms") info.parms = true;
|
|
1223
|
+
if (stack.length === 1 && stack[0].dict && stack[0].key === "Filter") {
|
|
1224
|
+
info.filter = "";
|
|
1225
|
+
info.filters = 0;
|
|
1226
|
+
}
|
|
1218
1227
|
stack.push({ dict: tok === 4 /* Dict */, expectKey: tok === 4 /* Dict */, key: "" });
|
|
1219
1228
|
continue;
|
|
1220
1229
|
case 3 /* ArrEnd */:
|
|
@@ -1229,6 +1238,7 @@ var Scan = class {
|
|
|
1229
1238
|
const t3 = l.next();
|
|
1230
1239
|
if (t3 === 7 /* Word */ && l.val === "R") {
|
|
1231
1240
|
if (stack.length === 1 && stack[0].dict && ["Type", "Filter", "DecodeParms", "N", "First"].includes(stack[0].key)) info.indirect = true;
|
|
1241
|
+
if (stack.length === 2 && stack[0].dict && stack[0].key === "Filter") info.indirect = true;
|
|
1232
1242
|
done = true;
|
|
1233
1243
|
} else if (t3 === 7 /* Word */ && l.val === "obj") {
|
|
1234
1244
|
continue;
|
|
@@ -1262,6 +1272,9 @@ var Scan = class {
|
|
|
1262
1272
|
if (tok === 6 /* Name */) {
|
|
1263
1273
|
info.filter = val;
|
|
1264
1274
|
info.filters = 1;
|
|
1275
|
+
} else {
|
|
1276
|
+
info.filter = "";
|
|
1277
|
+
info.filters = 0;
|
|
1265
1278
|
}
|
|
1266
1279
|
break;
|
|
1267
1280
|
case "DecodeParms":
|
|
@@ -1284,7 +1297,7 @@ var Scan = class {
|
|
|
1284
1297
|
}
|
|
1285
1298
|
/** `stream`-ийн араас FlateDecode өгөгдлийг (zlib өөрөө төгсөнө) задалж, толгойн offset бүрээс объектыг шалгана. */
|
|
1286
1299
|
objStm(l, info) {
|
|
1287
|
-
if (l.next() !== 7 /* Word */ || l.val !== "stream"
|
|
1300
|
+
if (l.next() !== 7 /* Word */ || l.val !== "stream") return;
|
|
1288
1301
|
if (info.indirect) throw new StructureError();
|
|
1289
1302
|
if (info.typ !== "ObjStm") return;
|
|
1290
1303
|
const b = l.b;
|
|
@@ -1295,11 +1308,12 @@ var Scan = class {
|
|
|
1295
1308
|
this.objStmData(b.subarray(p), info);
|
|
1296
1309
|
return;
|
|
1297
1310
|
}
|
|
1298
|
-
if (info.filters
|
|
1311
|
+
if (info.filters > 1) throw new StructureError();
|
|
1312
|
+
if (info.filter !== "FlateDecode") return;
|
|
1299
1313
|
if (info.parms) throw new StructureError();
|
|
1300
1314
|
let data;
|
|
1301
1315
|
try {
|
|
1302
|
-
data =
|
|
1316
|
+
data = zlibInflatePrefix(b.subarray(p), this.inflateLeft, 64 << 10);
|
|
1303
1317
|
} catch (e) {
|
|
1304
1318
|
if (e instanceof InflateLimitError) throw new StructureError();
|
|
1305
1319
|
return;
|
|
@@ -1312,19 +1326,19 @@ var Scan = class {
|
|
|
1312
1326
|
const l = new Lex(data, 0);
|
|
1313
1327
|
for (let i = 0; i < info.nCount; i++) {
|
|
1314
1328
|
if (l.next() === 0 /* EOF */) break;
|
|
1315
|
-
|
|
1316
|
-
if (
|
|
1317
|
-
const
|
|
1318
|
-
if (
|
|
1329
|
+
const t = l.next();
|
|
1330
|
+
if (t === 0 /* EOF */) break;
|
|
1331
|
+
const at = info.first + (t === 7 /* Word */ ? parseInt64(l.val) : 0);
|
|
1332
|
+
if (at < 0 || at >= data.length) continue;
|
|
1319
1333
|
if (this.budget < 0) throw new StructureError();
|
|
1320
|
-
this.object(data,
|
|
1334
|
+
this.object(data, at, false);
|
|
1321
1335
|
}
|
|
1322
1336
|
if (this.budget < 0) throw new StructureError();
|
|
1323
1337
|
}
|
|
1324
1338
|
};
|
|
1325
1339
|
function checkStructure(doc) {
|
|
1326
1340
|
const text = fromLatin1(doc);
|
|
1327
|
-
const s = new Scan(NEST_SCAN_FACTOR * doc.length + (1 << 20), MAX_OBJSTM_BYTES
|
|
1341
|
+
const s = new Scan(NEST_SCAN_FACTOR * doc.length + (1 << 20), MAX_OBJSTM_BYTES);
|
|
1328
1342
|
for (const kw of ["obj", "trailer"]) {
|
|
1329
1343
|
for (let i = 0; ; ) {
|
|
1330
1344
|
const k = text.indexOf(kw, i);
|
package/dist/convert.js
CHANGED
|
@@ -77,7 +77,7 @@ function zlibInflate(src, limit = 64 << 20, initial) {
|
|
|
77
77
|
return inflateRaw(src.subarray(2), limit, void 0, initial);
|
|
78
78
|
}
|
|
79
79
|
function inflateRaw(src, limit = 64 << 20, info, initial) {
|
|
80
|
-
return inflate(src, limit, info, initial, false);
|
|
80
|
+
return inflate(src, limit, info, initial, false, false);
|
|
81
81
|
}
|
|
82
82
|
function complete(lengths, n) {
|
|
83
83
|
let max = 0;
|
|
@@ -94,7 +94,7 @@ function complete(lengths, n) {
|
|
|
94
94
|
}
|
|
95
95
|
return sum === 2 ** max || sum === 1 && max === 1 && count === 1;
|
|
96
96
|
}
|
|
97
|
-
function inflate(src, limit, info, initial, strict) {
|
|
97
|
+
function inflate(src, limit, info, initial, strict, prefix) {
|
|
98
98
|
let pos = 0;
|
|
99
99
|
let bitBuf = 0;
|
|
100
100
|
let bitCnt = 0;
|
|
@@ -138,7 +138,7 @@ function inflate(src, limit, info, initial, strict) {
|
|
|
138
138
|
try {
|
|
139
139
|
inflateBlocks();
|
|
140
140
|
} catch (e) {
|
|
141
|
-
if (!(e instanceof Truncated)) throw e;
|
|
141
|
+
if (!(e instanceof Truncated) && !(prefix && e instanceof InflateError && !(e instanceof InflateLimitError))) throw e;
|
|
142
142
|
if (info) info.truncated = true;
|
|
143
143
|
}
|
|
144
144
|
if (info) info.end = pos;
|
package/dist/pades.cjs
CHANGED
|
@@ -1404,8 +1404,16 @@ function zlibInflate(src, limit = 64 << 20, initial) {
|
|
|
1404
1404
|
if (flg & 32) throw new InflateError("zlib: preset dictionary");
|
|
1405
1405
|
return inflateRaw(src.subarray(2), limit, void 0, initial);
|
|
1406
1406
|
}
|
|
1407
|
+
function zlibInflatePrefix(src, limit, initial) {
|
|
1408
|
+
if (src.length < 2) throw new InflateError("zlib: header \u0430\u043B\u0433\u0430");
|
|
1409
|
+
const cmf = src[0];
|
|
1410
|
+
const flg = src[1];
|
|
1411
|
+
if ((cmf & 15) !== 8 || cmf >> 4 > 7 || (cmf << 8 | flg) % 31 !== 0) throw new InflateError("zlib: header \u0431\u0443\u0440\u0443\u0443");
|
|
1412
|
+
if (flg & 32) throw new InflateError("zlib: preset dictionary");
|
|
1413
|
+
return inflate(src.subarray(2), limit, void 0, initial, false, true);
|
|
1414
|
+
}
|
|
1407
1415
|
function inflateRaw(src, limit = 64 << 20, info, initial) {
|
|
1408
|
-
return inflate(src, limit, info, initial, false);
|
|
1416
|
+
return inflate(src, limit, info, initial, false, false);
|
|
1409
1417
|
}
|
|
1410
1418
|
function zlibInflateStrict(src, limit) {
|
|
1411
1419
|
if (src.length < 2) throw new InflateError("zlib: header \u0430\u043B\u0433\u0430");
|
|
@@ -1419,7 +1427,7 @@ function zlibInflateStrict(src, limit) {
|
|
|
1419
1427
|
start = 6;
|
|
1420
1428
|
}
|
|
1421
1429
|
const info = { end: 0, truncated: false };
|
|
1422
|
-
const out = inflate(src.subarray(start), limit, info, void 0, true);
|
|
1430
|
+
const out = inflate(src.subarray(start), limit, info, void 0, true, false);
|
|
1423
1431
|
if (info.truncated) throw new InflateError("inflate: \u04E9\u0433\u04E9\u0433\u0434\u04E9\u043B \u0434\u0443\u0442\u0443\u0443");
|
|
1424
1432
|
const at = start + info.end;
|
|
1425
1433
|
if (at + 4 > src.length) throw new InflateError("zlib: adler32 \u0430\u043B\u0433\u0430");
|
|
@@ -1456,7 +1464,7 @@ function complete(lengths, n) {
|
|
|
1456
1464
|
}
|
|
1457
1465
|
return sum === 2 ** max || sum === 1 && max === 1 && count === 1;
|
|
1458
1466
|
}
|
|
1459
|
-
function inflate(src, limit, info, initial, strict) {
|
|
1467
|
+
function inflate(src, limit, info, initial, strict, prefix) {
|
|
1460
1468
|
let pos = 0;
|
|
1461
1469
|
let bitBuf = 0;
|
|
1462
1470
|
let bitCnt = 0;
|
|
@@ -1500,7 +1508,7 @@ function inflate(src, limit, info, initial, strict) {
|
|
|
1500
1508
|
try {
|
|
1501
1509
|
inflateBlocks();
|
|
1502
1510
|
} catch (e) {
|
|
1503
|
-
if (!(e instanceof Truncated)) throw e;
|
|
1511
|
+
if (!(e instanceof Truncated) && !(prefix && e instanceof InflateError && !(e instanceof InflateLimitError))) throw e;
|
|
1504
1512
|
if (info) info.truncated = true;
|
|
1505
1513
|
}
|
|
1506
1514
|
if (info) info.end = pos;
|
|
@@ -2326,7 +2334,6 @@ var StructureError = class extends Error {
|
|
|
2326
2334
|
this.name = "StructureError";
|
|
2327
2335
|
}
|
|
2328
2336
|
};
|
|
2329
|
-
var ENCRYPT_REF = /\/Encrypt(?:[\t\n\f\r ]+\d+[\t\n\f\r ]+\d+[\t\n\f\r ]+R|[\t\n\f\r ]*<<)/;
|
|
2330
2337
|
var isSpace2 = (c) => c === 0 || c === 9 || c === 10 || c === 12 || c === 13 || c === 32;
|
|
2331
2338
|
var isDelim2 = (c) => c === 40 || c === 41 || c === 60 || c === 62 || c === 91 || c === 93 || c === 123 || c === 125 || c === 47 || c === 37;
|
|
2332
2339
|
var INT_RE = /^[+-]?\d+$/;
|
|
@@ -2417,14 +2424,12 @@ var Lex = class {
|
|
|
2417
2424
|
}
|
|
2418
2425
|
};
|
|
2419
2426
|
var Scan = class {
|
|
2420
|
-
constructor(budget, inflateLeft
|
|
2427
|
+
constructor(budget, inflateLeft) {
|
|
2421
2428
|
this.budget = budget;
|
|
2422
2429
|
this.inflateLeft = inflateLeft;
|
|
2423
|
-
this.encrypted = encrypted2;
|
|
2424
2430
|
}
|
|
2425
2431
|
budget;
|
|
2426
2432
|
inflateLeft;
|
|
2427
|
-
encrypted;
|
|
2428
2433
|
/** Дээд түвшний /Size > MAX_XREF_SIZE. */
|
|
2429
2434
|
bigSize = false;
|
|
2430
2435
|
/** b[start:]-аас reader-ийн нэг объектыг (давхар `N G obj`-ийг оруулаад) гүнээр шалгана. */
|
|
@@ -2471,6 +2476,10 @@ var Scan = class {
|
|
|
2471
2476
|
case 4 /* Dict */:
|
|
2472
2477
|
if (stack.length >= MAX_NESTING) throw new StructureError();
|
|
2473
2478
|
if (stack.length === 1 && stack[0].dict && stack[0].key === "DecodeParms") info.parms = true;
|
|
2479
|
+
if (stack.length === 1 && stack[0].dict && stack[0].key === "Filter") {
|
|
2480
|
+
info.filter = "";
|
|
2481
|
+
info.filters = 0;
|
|
2482
|
+
}
|
|
2474
2483
|
stack.push({ dict: tok === 4 /* Dict */, expectKey: tok === 4 /* Dict */, key: "" });
|
|
2475
2484
|
continue;
|
|
2476
2485
|
case 3 /* ArrEnd */:
|
|
@@ -2485,6 +2494,7 @@ var Scan = class {
|
|
|
2485
2494
|
const t3 = l.next();
|
|
2486
2495
|
if (t3 === 7 /* Word */ && l.val === "R") {
|
|
2487
2496
|
if (stack.length === 1 && stack[0].dict && ["Type", "Filter", "DecodeParms", "N", "First"].includes(stack[0].key)) info.indirect = true;
|
|
2497
|
+
if (stack.length === 2 && stack[0].dict && stack[0].key === "Filter") info.indirect = true;
|
|
2488
2498
|
done = true;
|
|
2489
2499
|
} else if (t3 === 7 /* Word */ && l.val === "obj") {
|
|
2490
2500
|
continue;
|
|
@@ -2518,6 +2528,9 @@ var Scan = class {
|
|
|
2518
2528
|
if (tok === 6 /* Name */) {
|
|
2519
2529
|
info.filter = val;
|
|
2520
2530
|
info.filters = 1;
|
|
2531
|
+
} else {
|
|
2532
|
+
info.filter = "";
|
|
2533
|
+
info.filters = 0;
|
|
2521
2534
|
}
|
|
2522
2535
|
break;
|
|
2523
2536
|
case "DecodeParms":
|
|
@@ -2540,7 +2553,7 @@ var Scan = class {
|
|
|
2540
2553
|
}
|
|
2541
2554
|
/** `stream`-ийн араас FlateDecode өгөгдлийг (zlib өөрөө төгсөнө) задалж, толгойн offset бүрээс объектыг шалгана. */
|
|
2542
2555
|
objStm(l, info) {
|
|
2543
|
-
if (l.next() !== 7 /* Word */ || l.val !== "stream"
|
|
2556
|
+
if (l.next() !== 7 /* Word */ || l.val !== "stream") return;
|
|
2544
2557
|
if (info.indirect) throw new StructureError();
|
|
2545
2558
|
if (info.typ !== "ObjStm") return;
|
|
2546
2559
|
const b = l.b;
|
|
@@ -2551,11 +2564,12 @@ var Scan = class {
|
|
|
2551
2564
|
this.objStmData(b.subarray(p), info);
|
|
2552
2565
|
return;
|
|
2553
2566
|
}
|
|
2554
|
-
if (info.filters
|
|
2567
|
+
if (info.filters > 1) throw new StructureError();
|
|
2568
|
+
if (info.filter !== "FlateDecode") return;
|
|
2555
2569
|
if (info.parms) throw new StructureError();
|
|
2556
2570
|
let data;
|
|
2557
2571
|
try {
|
|
2558
|
-
data =
|
|
2572
|
+
data = zlibInflatePrefix(b.subarray(p), this.inflateLeft, 64 << 10);
|
|
2559
2573
|
} catch (e) {
|
|
2560
2574
|
if (e instanceof InflateLimitError) throw new StructureError();
|
|
2561
2575
|
return;
|
|
@@ -2568,19 +2582,19 @@ var Scan = class {
|
|
|
2568
2582
|
const l = new Lex(data, 0);
|
|
2569
2583
|
for (let i = 0; i < info.nCount; i++) {
|
|
2570
2584
|
if (l.next() === 0 /* EOF */) break;
|
|
2571
|
-
|
|
2572
|
-
if (
|
|
2573
|
-
const
|
|
2574
|
-
if (
|
|
2585
|
+
const t = l.next();
|
|
2586
|
+
if (t === 0 /* EOF */) break;
|
|
2587
|
+
const at = info.first + (t === 7 /* Word */ ? parseInt64(l.val) : 0);
|
|
2588
|
+
if (at < 0 || at >= data.length) continue;
|
|
2575
2589
|
if (this.budget < 0) throw new StructureError();
|
|
2576
|
-
this.object(data,
|
|
2590
|
+
this.object(data, at, false);
|
|
2577
2591
|
}
|
|
2578
2592
|
if (this.budget < 0) throw new StructureError();
|
|
2579
2593
|
}
|
|
2580
2594
|
};
|
|
2581
2595
|
function checkStructure(doc) {
|
|
2582
2596
|
const text = fromLatin1(doc);
|
|
2583
|
-
const s = new Scan(NEST_SCAN_FACTOR * doc.length + (1 << 20), MAX_OBJSTM_BYTES
|
|
2597
|
+
const s = new Scan(NEST_SCAN_FACTOR * doc.length + (1 << 20), MAX_OBJSTM_BYTES);
|
|
2584
2598
|
for (const kw of ["obj", "trailer"]) {
|
|
2585
2599
|
for (let i = 0; ; ) {
|
|
2586
2600
|
const k = text.indexOf(kw, i);
|
|
@@ -4844,11 +4858,7 @@ function openReader(doc) {
|
|
|
4844
4858
|
function encrypted(doc) {
|
|
4845
4859
|
const r = openReader(doc);
|
|
4846
4860
|
if (!r) return ENCRYPT_KEY.test(fromLatin1(doc));
|
|
4847
|
-
|
|
4848
|
-
return !r.trailerValue().key("Encrypt").isNull();
|
|
4849
|
-
} catch {
|
|
4850
|
-
return false;
|
|
4851
|
-
}
|
|
4861
|
+
return r.trailerValue().keys().includes("Encrypt");
|
|
4852
4862
|
}
|
|
4853
4863
|
function docMDPP1(sig) {
|
|
4854
4864
|
const ref = sig.key("Reference");
|
package/dist/pades.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
visibleRect,
|
|
24
24
|
visibleWidget,
|
|
25
25
|
zlibInflateStrict
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-4JAA4RON.js";
|
|
27
27
|
import {
|
|
28
28
|
CLAIMED_ROLE_MAX_RUNES,
|
|
29
29
|
CertificateRevokedError,
|
|
@@ -1304,11 +1304,7 @@ function openReader(doc) {
|
|
|
1304
1304
|
function encrypted(doc) {
|
|
1305
1305
|
const r = openReader(doc);
|
|
1306
1306
|
if (!r) return ENCRYPT_KEY.test(fromLatin1(doc));
|
|
1307
|
-
|
|
1308
|
-
return !r.trailerValue().key("Encrypt").isNull();
|
|
1309
|
-
} catch {
|
|
1310
|
-
return false;
|
|
1311
|
-
}
|
|
1307
|
+
return r.trailerValue().keys().includes("Encrypt");
|
|
1312
1308
|
}
|
|
1313
1309
|
function docMDPP1(sig) {
|
|
1314
1310
|
const ref = sig.key("Reference");
|
package/dist/validate.cjs
CHANGED
|
@@ -1746,8 +1746,16 @@ function zlibInflate(src, limit = 64 << 20, initial) {
|
|
|
1746
1746
|
if (flg & 32) throw new InflateError("zlib: preset dictionary");
|
|
1747
1747
|
return inflateRaw(src.subarray(2), limit, void 0, initial);
|
|
1748
1748
|
}
|
|
1749
|
+
function zlibInflatePrefix(src, limit, initial) {
|
|
1750
|
+
if (src.length < 2) throw new InflateError("zlib: header \u0430\u043B\u0433\u0430");
|
|
1751
|
+
const cmf = src[0];
|
|
1752
|
+
const flg = src[1];
|
|
1753
|
+
if ((cmf & 15) !== 8 || cmf >> 4 > 7 || (cmf << 8 | flg) % 31 !== 0) throw new InflateError("zlib: header \u0431\u0443\u0440\u0443\u0443");
|
|
1754
|
+
if (flg & 32) throw new InflateError("zlib: preset dictionary");
|
|
1755
|
+
return inflate(src.subarray(2), limit, void 0, initial, false, true);
|
|
1756
|
+
}
|
|
1749
1757
|
function inflateRaw(src, limit = 64 << 20, info, initial) {
|
|
1750
|
-
return inflate(src, limit, info, initial, false);
|
|
1758
|
+
return inflate(src, limit, info, initial, false, false);
|
|
1751
1759
|
}
|
|
1752
1760
|
function adler32(b) {
|
|
1753
1761
|
let a = 1;
|
|
@@ -1778,7 +1786,7 @@ function complete(lengths, n) {
|
|
|
1778
1786
|
}
|
|
1779
1787
|
return sum === 2 ** max || sum === 1 && max === 1 && count === 1;
|
|
1780
1788
|
}
|
|
1781
|
-
function inflate(src, limit, info, initial, strict) {
|
|
1789
|
+
function inflate(src, limit, info, initial, strict, prefix) {
|
|
1782
1790
|
let pos = 0;
|
|
1783
1791
|
let bitBuf = 0;
|
|
1784
1792
|
let bitCnt = 0;
|
|
@@ -1822,7 +1830,7 @@ function inflate(src, limit, info, initial, strict) {
|
|
|
1822
1830
|
try {
|
|
1823
1831
|
inflateBlocks();
|
|
1824
1832
|
} catch (e) {
|
|
1825
|
-
if (!(e instanceof Truncated)) throw e;
|
|
1833
|
+
if (!(e instanceof Truncated) && !(prefix && e instanceof InflateError && !(e instanceof InflateLimitError))) throw e;
|
|
1826
1834
|
if (info) info.truncated = true;
|
|
1827
1835
|
}
|
|
1828
1836
|
if (info) info.end = pos;
|
|
@@ -2648,7 +2656,6 @@ var StructureError = class extends Error {
|
|
|
2648
2656
|
this.name = "StructureError";
|
|
2649
2657
|
}
|
|
2650
2658
|
};
|
|
2651
|
-
var ENCRYPT_REF = /\/Encrypt(?:[\t\n\f\r ]+\d+[\t\n\f\r ]+\d+[\t\n\f\r ]+R|[\t\n\f\r ]*<<)/;
|
|
2652
2659
|
var isSpace2 = (c) => c === 0 || c === 9 || c === 10 || c === 12 || c === 13 || c === 32;
|
|
2653
2660
|
var isDelim2 = (c) => c === 40 || c === 41 || c === 60 || c === 62 || c === 91 || c === 93 || c === 123 || c === 125 || c === 47 || c === 37;
|
|
2654
2661
|
var INT_RE = /^[+-]?\d+$/;
|
|
@@ -2739,14 +2746,12 @@ var Lex = class {
|
|
|
2739
2746
|
}
|
|
2740
2747
|
};
|
|
2741
2748
|
var Scan = class {
|
|
2742
|
-
constructor(budget, inflateLeft
|
|
2749
|
+
constructor(budget, inflateLeft) {
|
|
2743
2750
|
this.budget = budget;
|
|
2744
2751
|
this.inflateLeft = inflateLeft;
|
|
2745
|
-
this.encrypted = encrypted;
|
|
2746
2752
|
}
|
|
2747
2753
|
budget;
|
|
2748
2754
|
inflateLeft;
|
|
2749
|
-
encrypted;
|
|
2750
2755
|
/** Дээд түвшний /Size > MAX_XREF_SIZE. */
|
|
2751
2756
|
bigSize = false;
|
|
2752
2757
|
/** b[start:]-аас reader-ийн нэг объектыг (давхар `N G obj`-ийг оруулаад) гүнээр шалгана. */
|
|
@@ -2793,6 +2798,10 @@ var Scan = class {
|
|
|
2793
2798
|
case 4 /* Dict */:
|
|
2794
2799
|
if (stack.length >= MAX_NESTING) throw new StructureError();
|
|
2795
2800
|
if (stack.length === 1 && stack[0].dict && stack[0].key === "DecodeParms") info.parms = true;
|
|
2801
|
+
if (stack.length === 1 && stack[0].dict && stack[0].key === "Filter") {
|
|
2802
|
+
info.filter = "";
|
|
2803
|
+
info.filters = 0;
|
|
2804
|
+
}
|
|
2796
2805
|
stack.push({ dict: tok === 4 /* Dict */, expectKey: tok === 4 /* Dict */, key: "" });
|
|
2797
2806
|
continue;
|
|
2798
2807
|
case 3 /* ArrEnd */:
|
|
@@ -2807,6 +2816,7 @@ var Scan = class {
|
|
|
2807
2816
|
const t3 = l.next();
|
|
2808
2817
|
if (t3 === 7 /* Word */ && l.val === "R") {
|
|
2809
2818
|
if (stack.length === 1 && stack[0].dict && ["Type", "Filter", "DecodeParms", "N", "First"].includes(stack[0].key)) info.indirect = true;
|
|
2819
|
+
if (stack.length === 2 && stack[0].dict && stack[0].key === "Filter") info.indirect = true;
|
|
2810
2820
|
done = true;
|
|
2811
2821
|
} else if (t3 === 7 /* Word */ && l.val === "obj") {
|
|
2812
2822
|
continue;
|
|
@@ -2840,6 +2850,9 @@ var Scan = class {
|
|
|
2840
2850
|
if (tok === 6 /* Name */) {
|
|
2841
2851
|
info.filter = val;
|
|
2842
2852
|
info.filters = 1;
|
|
2853
|
+
} else {
|
|
2854
|
+
info.filter = "";
|
|
2855
|
+
info.filters = 0;
|
|
2843
2856
|
}
|
|
2844
2857
|
break;
|
|
2845
2858
|
case "DecodeParms":
|
|
@@ -2862,7 +2875,7 @@ var Scan = class {
|
|
|
2862
2875
|
}
|
|
2863
2876
|
/** `stream`-ийн араас FlateDecode өгөгдлийг (zlib өөрөө төгсөнө) задалж, толгойн offset бүрээс объектыг шалгана. */
|
|
2864
2877
|
objStm(l, info) {
|
|
2865
|
-
if (l.next() !== 7 /* Word */ || l.val !== "stream"
|
|
2878
|
+
if (l.next() !== 7 /* Word */ || l.val !== "stream") return;
|
|
2866
2879
|
if (info.indirect) throw new StructureError();
|
|
2867
2880
|
if (info.typ !== "ObjStm") return;
|
|
2868
2881
|
const b = l.b;
|
|
@@ -2873,11 +2886,12 @@ var Scan = class {
|
|
|
2873
2886
|
this.objStmData(b.subarray(p), info);
|
|
2874
2887
|
return;
|
|
2875
2888
|
}
|
|
2876
|
-
if (info.filters
|
|
2889
|
+
if (info.filters > 1) throw new StructureError();
|
|
2890
|
+
if (info.filter !== "FlateDecode") return;
|
|
2877
2891
|
if (info.parms) throw new StructureError();
|
|
2878
2892
|
let data;
|
|
2879
2893
|
try {
|
|
2880
|
-
data =
|
|
2894
|
+
data = zlibInflatePrefix(b.subarray(p), this.inflateLeft, 64 << 10);
|
|
2881
2895
|
} catch (e) {
|
|
2882
2896
|
if (e instanceof InflateLimitError) throw new StructureError();
|
|
2883
2897
|
return;
|
|
@@ -2890,19 +2904,19 @@ var Scan = class {
|
|
|
2890
2904
|
const l = new Lex(data, 0);
|
|
2891
2905
|
for (let i = 0; i < info.nCount; i++) {
|
|
2892
2906
|
if (l.next() === 0 /* EOF */) break;
|
|
2893
|
-
|
|
2894
|
-
if (
|
|
2895
|
-
const
|
|
2896
|
-
if (
|
|
2907
|
+
const t = l.next();
|
|
2908
|
+
if (t === 0 /* EOF */) break;
|
|
2909
|
+
const at = info.first + (t === 7 /* Word */ ? parseInt64(l.val) : 0);
|
|
2910
|
+
if (at < 0 || at >= data.length) continue;
|
|
2897
2911
|
if (this.budget < 0) throw new StructureError();
|
|
2898
|
-
this.object(data,
|
|
2912
|
+
this.object(data, at, false);
|
|
2899
2913
|
}
|
|
2900
2914
|
if (this.budget < 0) throw new StructureError();
|
|
2901
2915
|
}
|
|
2902
2916
|
};
|
|
2903
2917
|
function checkStructure(doc) {
|
|
2904
2918
|
const text = fromLatin1(doc);
|
|
2905
|
-
const s = new Scan(NEST_SCAN_FACTOR * doc.length + (1 << 20), MAX_OBJSTM_BYTES
|
|
2919
|
+
const s = new Scan(NEST_SCAN_FACTOR * doc.length + (1 << 20), MAX_OBJSTM_BYTES);
|
|
2906
2920
|
for (const kw of ["obj", "trailer"]) {
|
|
2907
2921
|
for (let i = 0; ; ) {
|
|
2908
2922
|
const k = text.indexOf(kw, i);
|
|
@@ -5332,7 +5346,7 @@ var ExtractError = class extends Error {
|
|
|
5332
5346
|
}
|
|
5333
5347
|
code;
|
|
5334
5348
|
};
|
|
5335
|
-
var
|
|
5349
|
+
var ENCRYPT_REF = /\/Encrypt(?:\s+\d+\s+\d+\s+R|\s*<<)/;
|
|
5336
5350
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
5337
5351
|
var AP_VERIFY_PREFIX2 = "https://ca.eidmongolia.mn/verify/";
|
|
5338
5352
|
async function extract(doc, profile = "own") {
|
|
@@ -5346,7 +5360,7 @@ async function extract(doc, profile = "own") {
|
|
|
5346
5360
|
try {
|
|
5347
5361
|
rdr = new Reader(doc);
|
|
5348
5362
|
} catch {
|
|
5349
|
-
throw new ExtractError(
|
|
5363
|
+
throw new ExtractError(ENCRYPT_REF.test(fromLatin1(doc)) ? "encrypted" : "not_pdf");
|
|
5350
5364
|
}
|
|
5351
5365
|
if (rdr.trailerValue().keys().includes("Encrypt")) throw new ExtractError("encrypted");
|
|
5352
5366
|
const sigs = [];
|
package/dist/validate.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gerege-systems/eid-mongolia-sdk",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.2",
|
|
4
4
|
"description": "e-ID Mongolia Relying Party SDK — иргэнээр утсаар нь нэвтрэлт ба хууль ёсны цахим гарын үсэг (RP-API v3, Smart-ID нийцтэй).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsup src/index.ts src/browser.ts src/pades.ts src/validate.ts --format esm,cjs --dts --clean && tsup src/button.ts --format esm,cjs --dts --tsconfig tsconfig.button.json && tsup src/convert.ts --format esm --dts --tsconfig tsconfig.button.json",
|
|
52
|
-
"test": "npm run build && node --test --experimental-strip-types test/sdk.test.ts test/portal-gaps.test.ts test/chain.test.ts test/qr.test.ts test/myqr.test.ts test/login.test.ts test/button.test.ts test/sign-gaps.test.ts test/session-start.test.ts test/pades-session.test.ts test/pades-golden.test.ts test/pades-placement.test.ts test/pades-unit.test.ts test/convert.test.ts test/share.test.ts test/validate-golden.test.ts test/validate-revisions.test.ts test/validate-env.test.ts test/pades-revocation.test.ts test/pades-encrypt.test.ts test/pades-objstm.test.ts test/validate-fuzz.test.ts test/pades-lexer-loop.test.ts",
|
|
52
|
+
"test": "npm run build && node --test --experimental-strip-types test/sdk.test.ts test/portal-gaps.test.ts test/chain.test.ts test/qr.test.ts test/myqr.test.ts test/login.test.ts test/button.test.ts test/sign-gaps.test.ts test/session-start.test.ts test/pades-session.test.ts test/pades-golden.test.ts test/pades-placement.test.ts test/pades-unit.test.ts test/convert.test.ts test/share.test.ts test/validate-golden.test.ts test/validate-revisions.test.ts test/validate-env.test.ts test/pades-revocation.test.ts test/pades-encrypt.test.ts test/pades-objstm.test.ts test/pades-objstm-encrypt.test.ts test/validate-fuzz.test.ts test/pades-lexer-loop.test.ts",
|
|
53
53
|
"test:contract": "npm run build && node --experimental-strip-types test/contract.test.ts",
|
|
54
54
|
"lint": "tsc --noEmit && tsc --noEmit -p tsconfig.button.json",
|
|
55
55
|
"golden:check": "node scripts/sync-pades-golden.mjs --check",
|