@gerege-systems/eid-mongolia-sdk 0.29.2 → 0.30.1
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 +12 -1
- package/dist/{chunk-P65FCDR5.js → chunk-MA4RMWBO.js} +16 -5
- package/dist/convert.js +7 -2
- package/dist/pades.cjs +23 -7
- package/dist/pades.d.cts +6 -0
- package/dist/pades.d.ts +6 -0
- package/dist/pades.js +8 -3
- package/dist/validate.cjs +7 -2
- package/dist/validate.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -557,7 +557,7 @@ DSS-д), Adobe / EU DSS-д «LTV enabled», баталгаажуулах (QR) х
|
|
|
557
557
|
|
|
558
558
|
| Функц | Хаана | Тайлбар |
|
|
559
559
|
|---|---|---|
|
|
560
|
-
| `prepare(pdf, { signerCert, claimedRole?, verifyPage?, fileName?, lang?, docId?, appearance?, … })` | браузер / Node | `{ dtbs, digest, docId, state, placement? }` — сүлжээгүй |
|
|
560
|
+
| `prepare(pdf, { signerCert, claimedRole?, verifyPage?, verifyPagePosition?, fileName?, lang?, docId?, appearance?, … })` | браузер / Node | `{ dtbs, digest, docId, state, placement? }` — сүлжээгүй |
|
|
561
561
|
| `suggestPlacement(pdf, appearance)` | браузер / Node | гарын үсэггүйгээр тэмдгийн байршил + хуудасны хэмжээ (урьдчилан харах, 0.29.0+) — сүлжээгүй |
|
|
562
562
|
| `eid.signPdfDigest({ dtbs, fileName, signer, flow?, onBehalfOf? })` | RP backend | DTBS-д гарын үсгийн session (push эсвэл device-link) |
|
|
563
563
|
| `complete(state, signature)` | браузер / Node | TSA + OCSP/CRL → `{ pdf, cms, docId, outSha256, inSha256, hasPage, pageSha256, … }` |
|
|
@@ -674,6 +674,17 @@ const p = await prepare(pdfBytes, { signerCert, verifyPage: true, fileName: "Г
|
|
|
674
674
|
appearance: { page, x, y, width: s.width, height: s.height, exact: true } });
|
|
675
675
|
```
|
|
676
676
|
|
|
677
|
+
**Баталгаажуулах хуудсыг эхэнд (0.30.0+).** `verifyPagePosition: "first"` — QR хуудас баримтын 1-р хуудас болно (анхдагч
|
|
678
|
+
`"last"` — төгсгөлд, өмнөхтэй байт-ижил; бусад утга `REQUEST_INVALID`). Хуудас нэмэгдэх үед л (гарын үсэггүй баримт,
|
|
679
|
+
`verifyPage: true`) нөлөөтэй. `appearance.page`, `suggestPlacement`, `placement.page` үргэлж **оролтын** PDF-ийн хуудсаар
|
|
680
|
+
тоологдоно — нэмэгдсэн хуудсыг тоолохгүй, тиймээс preview-ийн хуудасны дугаарыг шууд өгнө. Дүрэм: `PAGE_SPEC.md` §8a,
|
|
681
|
+
`PLACEMENT_SPEC.md` §1b.
|
|
682
|
+
|
|
683
|
+
```ts
|
|
684
|
+
const p = await prepare(pdfBytes, { signerCert, verifyPage: true, verifyPagePosition: "first", fileName: "Гэрээ №12.pdf",
|
|
685
|
+
appearance: { page: 2, x: 340, y: 36, width: 220, height: 64, exact: true } }); // гаралтын 3-р хуудсан дээр
|
|
686
|
+
```
|
|
687
|
+
|
|
677
688
|
### Зөвхөн Node (backend бүгдийг хийнэ)
|
|
678
689
|
|
|
679
690
|
```ts
|
|
@@ -476,10 +476,12 @@ var Lexer = class {
|
|
|
476
476
|
const out = [];
|
|
477
477
|
for (; ; ) {
|
|
478
478
|
let c = this.readByte();
|
|
479
|
-
while (isSpace(c)) c = this.readByte();
|
|
479
|
+
while (isSpace(c) && !this.eof) c = this.readByte();
|
|
480
|
+
if (this.eof) throw new PdfError("unterminated hex string");
|
|
480
481
|
if (c === 62) break;
|
|
481
482
|
let c2 = this.readByte();
|
|
482
|
-
while (isSpace(c2)) c2 = this.readByte();
|
|
483
|
+
while (isSpace(c2) && !this.eof) c2 = this.readByte();
|
|
484
|
+
if (this.eof) throw new PdfError("unterminated hex string");
|
|
483
485
|
const x = unhex(c) << 4 | unhex(c2);
|
|
484
486
|
if (unhex(c) < 0 || unhex(c2) < 0 || x < 0) throw new PdfError("malformed hex string");
|
|
485
487
|
out.push(x);
|
|
@@ -491,6 +493,7 @@ var Lexer = class {
|
|
|
491
493
|
let depth = 1;
|
|
492
494
|
for (; ; ) {
|
|
493
495
|
let c = this.readByte();
|
|
496
|
+
if (this.eof) throw new PdfError("unterminated literal string");
|
|
494
497
|
if (c === 40) {
|
|
495
498
|
depth++;
|
|
496
499
|
out.push(c);
|
|
@@ -635,6 +638,7 @@ var Lexer = class {
|
|
|
635
638
|
const tok = this.readToken();
|
|
636
639
|
if (isKw(tok, "]")) break;
|
|
637
640
|
if (tok === EOF_TOKEN) throw new PdfError("unterminated array");
|
|
641
|
+
if (isKw(tok, "endobj")) throw new PdfError("unterminated array");
|
|
638
642
|
this.unreadToken(tok);
|
|
639
643
|
x.push(asObj(this.readObject()));
|
|
640
644
|
}
|
|
@@ -993,6 +997,7 @@ var Reader = class {
|
|
|
993
997
|
for (let i = 0; i < n; i++) {
|
|
994
998
|
const id = b.readToken();
|
|
995
999
|
const off = b.readToken();
|
|
1000
|
+
if (id === EOF_TOKEN || off === EOF_TOKEN) break;
|
|
996
1001
|
const idn = id instanceof PInt ? Number(BigInt.asUintN(32, id.v)) : 0;
|
|
997
1002
|
if (idn === ptr.id) {
|
|
998
1003
|
const o = off instanceof PInt ? Number(off.v) : 0;
|
|
@@ -1991,7 +1996,7 @@ function streamObj(extra, data) {
|
|
|
1991
1996
|
stream
|
|
1992
1997
|
`), data, latin1("\nendstream")]);
|
|
1993
1998
|
}
|
|
1994
|
-
function appendVerifyPage(base, p) {
|
|
1999
|
+
function appendVerifyPage(base, p, first = false) {
|
|
1995
2000
|
const [reg, bld] = loadFonts();
|
|
1996
2001
|
const { content, links } = pageContent(p);
|
|
1997
2002
|
const inc = new Incremental(base);
|
|
@@ -2028,8 +2033,14 @@ function appendVerifyPage(base, p) {
|
|
|
2028
2033
|
const kids = pages.key("Kids");
|
|
2029
2034
|
const kp = kids.ptr;
|
|
2030
2035
|
pn += " /Kids [";
|
|
2031
|
-
|
|
2032
|
-
|
|
2036
|
+
if (first) {
|
|
2037
|
+
pn += `${pageID} 0 R`;
|
|
2038
|
+
for (let i = 0; i < kids.len(); i++) pn += " " + serialize(kids.index(i), kp.id, 0);
|
|
2039
|
+
pn += `] /Count ${count + 1} >>`;
|
|
2040
|
+
} else {
|
|
2041
|
+
for (let i = 0; i < kids.len(); i++) pn += serialize(kids.index(i), kp.id, 0) + " ";
|
|
2042
|
+
pn += `${pageID} 0 R] /Count ${count + 1} >>`;
|
|
2043
|
+
}
|
|
2033
2044
|
inc.writeObject(pp.id, pn, pp.gen);
|
|
2034
2045
|
return inc.finish(rp.id);
|
|
2035
2046
|
}
|
package/dist/convert.js
CHANGED
|
@@ -423,10 +423,12 @@ var Lexer = class {
|
|
|
423
423
|
const out = [];
|
|
424
424
|
for (; ; ) {
|
|
425
425
|
let c = this.readByte();
|
|
426
|
-
while (isSpace(c)) c = this.readByte();
|
|
426
|
+
while (isSpace(c) && !this.eof) c = this.readByte();
|
|
427
|
+
if (this.eof) throw new PdfError("unterminated hex string");
|
|
427
428
|
if (c === 62) break;
|
|
428
429
|
let c2 = this.readByte();
|
|
429
|
-
while (isSpace(c2)) c2 = this.readByte();
|
|
430
|
+
while (isSpace(c2) && !this.eof) c2 = this.readByte();
|
|
431
|
+
if (this.eof) throw new PdfError("unterminated hex string");
|
|
430
432
|
const x = unhex(c) << 4 | unhex(c2);
|
|
431
433
|
if (unhex(c) < 0 || unhex(c2) < 0 || x < 0) throw new PdfError("malformed hex string");
|
|
432
434
|
out.push(x);
|
|
@@ -438,6 +440,7 @@ var Lexer = class {
|
|
|
438
440
|
let depth = 1;
|
|
439
441
|
for (; ; ) {
|
|
440
442
|
let c = this.readByte();
|
|
443
|
+
if (this.eof) throw new PdfError("unterminated literal string");
|
|
441
444
|
if (c === 40) {
|
|
442
445
|
depth++;
|
|
443
446
|
out.push(c);
|
|
@@ -582,6 +585,7 @@ var Lexer = class {
|
|
|
582
585
|
const tok = this.readToken();
|
|
583
586
|
if (isKw(tok, "]")) break;
|
|
584
587
|
if (tok === EOF_TOKEN) throw new PdfError("unterminated array");
|
|
588
|
+
if (isKw(tok, "endobj")) throw new PdfError("unterminated array");
|
|
585
589
|
this.unreadToken(tok);
|
|
586
590
|
x.push(asObj(this.readObject()));
|
|
587
591
|
}
|
|
@@ -940,6 +944,7 @@ var Reader = class {
|
|
|
940
944
|
for (let i = 0; i < n; i++) {
|
|
941
945
|
const id = b.readToken();
|
|
942
946
|
const off = b.readToken();
|
|
947
|
+
if (id === EOF_TOKEN || off === EOF_TOKEN) break;
|
|
943
948
|
const idn = id instanceof PInt ? Number(BigInt.asUintN(32, id.v)) : 0;
|
|
944
949
|
if (idn === ptr.id) {
|
|
945
950
|
const o = off instanceof PInt ? Number(off.v) : 0;
|
package/dist/pades.cjs
CHANGED
|
@@ -1732,10 +1732,12 @@ var Lexer = class {
|
|
|
1732
1732
|
const out = [];
|
|
1733
1733
|
for (; ; ) {
|
|
1734
1734
|
let c = this.readByte();
|
|
1735
|
-
while (isSpace(c)) c = this.readByte();
|
|
1735
|
+
while (isSpace(c) && !this.eof) c = this.readByte();
|
|
1736
|
+
if (this.eof) throw new PdfError("unterminated hex string");
|
|
1736
1737
|
if (c === 62) break;
|
|
1737
1738
|
let c2 = this.readByte();
|
|
1738
|
-
while (isSpace(c2)) c2 = this.readByte();
|
|
1739
|
+
while (isSpace(c2) && !this.eof) c2 = this.readByte();
|
|
1740
|
+
if (this.eof) throw new PdfError("unterminated hex string");
|
|
1739
1741
|
const x = unhex(c) << 4 | unhex(c2);
|
|
1740
1742
|
if (unhex(c) < 0 || unhex(c2) < 0 || x < 0) throw new PdfError("malformed hex string");
|
|
1741
1743
|
out.push(x);
|
|
@@ -1747,6 +1749,7 @@ var Lexer = class {
|
|
|
1747
1749
|
let depth = 1;
|
|
1748
1750
|
for (; ; ) {
|
|
1749
1751
|
let c = this.readByte();
|
|
1752
|
+
if (this.eof) throw new PdfError("unterminated literal string");
|
|
1750
1753
|
if (c === 40) {
|
|
1751
1754
|
depth++;
|
|
1752
1755
|
out.push(c);
|
|
@@ -1891,6 +1894,7 @@ var Lexer = class {
|
|
|
1891
1894
|
const tok = this.readToken();
|
|
1892
1895
|
if (isKw(tok, "]")) break;
|
|
1893
1896
|
if (tok === EOF_TOKEN) throw new PdfError("unterminated array");
|
|
1897
|
+
if (isKw(tok, "endobj")) throw new PdfError("unterminated array");
|
|
1894
1898
|
this.unreadToken(tok);
|
|
1895
1899
|
x.push(asObj(this.readObject()));
|
|
1896
1900
|
}
|
|
@@ -2249,6 +2253,7 @@ var Reader = class {
|
|
|
2249
2253
|
for (let i = 0; i < n; i++) {
|
|
2250
2254
|
const id = b.readToken();
|
|
2251
2255
|
const off = b.readToken();
|
|
2256
|
+
if (id === EOF_TOKEN || off === EOF_TOKEN) break;
|
|
2252
2257
|
const idn = id instanceof PInt ? Number(BigInt.asUintN(32, id.v)) : 0;
|
|
2253
2258
|
if (idn === ptr.id) {
|
|
2254
2259
|
const o = off instanceof PInt ? Number(off.v) : 0;
|
|
@@ -3250,7 +3255,7 @@ function streamObj(extra, data) {
|
|
|
3250
3255
|
stream
|
|
3251
3256
|
`), data, latin1("\nendstream")]);
|
|
3252
3257
|
}
|
|
3253
|
-
function appendVerifyPage(base, p) {
|
|
3258
|
+
function appendVerifyPage(base, p, first = false) {
|
|
3254
3259
|
const [reg, bld] = loadFonts();
|
|
3255
3260
|
const { content, links } = pageContent(p);
|
|
3256
3261
|
const inc = new Incremental(base);
|
|
@@ -3287,8 +3292,14 @@ function appendVerifyPage(base, p) {
|
|
|
3287
3292
|
const kids = pages.key("Kids");
|
|
3288
3293
|
const kp = kids.ptr;
|
|
3289
3294
|
pn += " /Kids [";
|
|
3290
|
-
|
|
3291
|
-
|
|
3295
|
+
if (first) {
|
|
3296
|
+
pn += `${pageID} 0 R`;
|
|
3297
|
+
for (let i = 0; i < kids.len(); i++) pn += " " + serialize(kids.index(i), kp.id, 0);
|
|
3298
|
+
pn += `] /Count ${count + 1} >>`;
|
|
3299
|
+
} else {
|
|
3300
|
+
for (let i = 0; i < kids.len(); i++) pn += serialize(kids.index(i), kp.id, 0) + " ";
|
|
3301
|
+
pn += `${pageID} 0 R] /Count ${count + 1} >>`;
|
|
3302
|
+
}
|
|
3292
3303
|
inc.writeObject(pp.id, pn, pp.gen);
|
|
3293
3304
|
return inc.finish(rp.id);
|
|
3294
3305
|
}
|
|
@@ -5185,6 +5196,11 @@ async function prepare(pdf, opts) {
|
|
|
5185
5196
|
if (opts.lang !== void 0 && opts.lang !== "" && opts.lang !== "mn" && opts.lang !== "en") {
|
|
5186
5197
|
throw new PadesError("REQUEST_INVALID", "lang: mn | en");
|
|
5187
5198
|
}
|
|
5199
|
+
const pos = opts.verifyPagePosition;
|
|
5200
|
+
if (pos !== void 0 && pos !== "" && pos !== "last" && pos !== "first") {
|
|
5201
|
+
throw new PadesError("REQUEST_INVALID", "verifyPagePosition: last | first");
|
|
5202
|
+
}
|
|
5203
|
+
const first = pos === "first";
|
|
5188
5204
|
checkAppearance(opts);
|
|
5189
5205
|
const now = opts.signingTime ?? /* @__PURE__ */ new Date();
|
|
5190
5206
|
if (Number.isNaN(now.getTime())) throw new PadesError("REQUEST_INVALID", "signingTime \u0431\u0443\u0440\u0443\u0443 Date");
|
|
@@ -5224,7 +5240,7 @@ async function prepare(pdf, opts) {
|
|
|
5224
5240
|
tsaName: PAGE_TSA_NAME,
|
|
5225
5241
|
provider: PAGE_PROVIDER,
|
|
5226
5242
|
lang: opts.lang ?? ""
|
|
5227
|
-
});
|
|
5243
|
+
}, first);
|
|
5228
5244
|
} catch (e) {
|
|
5229
5245
|
throw new PadesError("PDF_INVALID", "PDF \u0437\u0430\u0434\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439 (\u0445\u0443\u0443\u0434\u0430\u0441 \u043D\u044D\u043C\u0436 \u0447\u0430\u0434\u0441\u0430\u043D\u0433\u04AF\u0439)", { cause: e });
|
|
5230
5246
|
}
|
|
@@ -5234,7 +5250,7 @@ async function prepare(pdf, opts) {
|
|
|
5234
5250
|
const vis = opts.appearance ? visibleSpec(doc, opts, name, now, docId, pc.revIndex) : void 0;
|
|
5235
5251
|
let prep;
|
|
5236
5252
|
try {
|
|
5237
|
-
prep = await prepareSignature(base, now, name, opts.reason ?? "", vis);
|
|
5253
|
+
prep = await prepareSignature(base, now, name, opts.reason ?? "", vis && hasPage && first ? { ...vis, page: vis.page + 1 } : vis);
|
|
5238
5254
|
} catch (e) {
|
|
5239
5255
|
if (e instanceof AppearanceError) throw new PadesError("REQUEST_INVALID", `appearance: ${e.message}`, { cause: e });
|
|
5240
5256
|
throw new PadesError("PDF_INVALID", "PDF-\u0434 \u0433\u0430\u0440\u044B\u043D \u04AF\u0441\u0433\u0438\u0439\u043D revision \u0431\u0438\u0447\u0438\u0436 \u0447\u0430\u0434\u0441\u0430\u043D\u0433\u04AF\u0439", { cause: e });
|
package/dist/pades.d.cts
CHANGED
|
@@ -46,6 +46,12 @@ interface PadesPrepareOptions {
|
|
|
46
46
|
docId?: string;
|
|
47
47
|
/** Баталгаажуулах (QR) хуудас нэмэх — зөвхөн гарын үсэггүй баримтын эхний гарын үсэгт. */
|
|
48
48
|
verifyPage?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Where the verify page goes when it is added (`verifyPage` on an unsigned document): `"last"` (default) or `"first"`
|
|
51
|
+
* (it becomes page 1). `appearance.page`, {@link suggestPlacement} and `placement.page` always count the pages of the
|
|
52
|
+
* input PDF as given — never the added page (PAGE_SPEC.md §8a, PLACEMENT_SPEC.md §1b). Other values → REQUEST_INVALID.
|
|
53
|
+
*/
|
|
54
|
+
verifyPagePosition?: "last" | "first";
|
|
49
55
|
/** Хуудасны хэл: `mn` (анхдагч) | `en`. */
|
|
50
56
|
lang?: "mn" | "en";
|
|
51
57
|
/** Баримтын нэр — `verifyPage` үед заавал (≤ 120 тэмдэгт). */
|
package/dist/pades.d.ts
CHANGED
|
@@ -46,6 +46,12 @@ interface PadesPrepareOptions {
|
|
|
46
46
|
docId?: string;
|
|
47
47
|
/** Баталгаажуулах (QR) хуудас нэмэх — зөвхөн гарын үсэггүй баримтын эхний гарын үсэгт. */
|
|
48
48
|
verifyPage?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Where the verify page goes when it is added (`verifyPage` on an unsigned document): `"last"` (default) or `"first"`
|
|
51
|
+
* (it becomes page 1). `appearance.page`, {@link suggestPlacement} and `placement.page` always count the pages of the
|
|
52
|
+
* input PDF as given — never the added page (PAGE_SPEC.md §8a, PLACEMENT_SPEC.md §1b). Other values → REQUEST_INVALID.
|
|
53
|
+
*/
|
|
54
|
+
verifyPagePosition?: "last" | "first";
|
|
49
55
|
/** Хуудасны хэл: `mn` (анхдагч) | `en`. */
|
|
50
56
|
lang?: "mn" | "en";
|
|
51
57
|
/** Баримтын нэр — `verifyPage` үед заавал (≤ 120 тэмдэгт). */
|
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-MA4RMWBO.js";
|
|
27
27
|
import {
|
|
28
28
|
CLAIMED_ROLE_MAX_RUNES,
|
|
29
29
|
CertificateRevokedError,
|
|
@@ -1656,6 +1656,11 @@ async function prepare(pdf, opts) {
|
|
|
1656
1656
|
if (opts.lang !== void 0 && opts.lang !== "" && opts.lang !== "mn" && opts.lang !== "en") {
|
|
1657
1657
|
throw new PadesError("REQUEST_INVALID", "lang: mn | en");
|
|
1658
1658
|
}
|
|
1659
|
+
const pos = opts.verifyPagePosition;
|
|
1660
|
+
if (pos !== void 0 && pos !== "" && pos !== "last" && pos !== "first") {
|
|
1661
|
+
throw new PadesError("REQUEST_INVALID", "verifyPagePosition: last | first");
|
|
1662
|
+
}
|
|
1663
|
+
const first = pos === "first";
|
|
1659
1664
|
checkAppearance(opts);
|
|
1660
1665
|
const now = opts.signingTime ?? /* @__PURE__ */ new Date();
|
|
1661
1666
|
if (Number.isNaN(now.getTime())) throw new PadesError("REQUEST_INVALID", "signingTime \u0431\u0443\u0440\u0443\u0443 Date");
|
|
@@ -1695,7 +1700,7 @@ async function prepare(pdf, opts) {
|
|
|
1695
1700
|
tsaName: PAGE_TSA_NAME,
|
|
1696
1701
|
provider: PAGE_PROVIDER,
|
|
1697
1702
|
lang: opts.lang ?? ""
|
|
1698
|
-
});
|
|
1703
|
+
}, first);
|
|
1699
1704
|
} catch (e) {
|
|
1700
1705
|
throw new PadesError("PDF_INVALID", "PDF \u0437\u0430\u0434\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439 (\u0445\u0443\u0443\u0434\u0430\u0441 \u043D\u044D\u043C\u0436 \u0447\u0430\u0434\u0441\u0430\u043D\u0433\u04AF\u0439)", { cause: e });
|
|
1701
1706
|
}
|
|
@@ -1705,7 +1710,7 @@ async function prepare(pdf, opts) {
|
|
|
1705
1710
|
const vis = opts.appearance ? visibleSpec(doc, opts, name, now, docId, pc.revIndex) : void 0;
|
|
1706
1711
|
let prep;
|
|
1707
1712
|
try {
|
|
1708
|
-
prep = await prepareSignature(base, now, name, opts.reason ?? "", vis);
|
|
1713
|
+
prep = await prepareSignature(base, now, name, opts.reason ?? "", vis && hasPage && first ? { ...vis, page: vis.page + 1 } : vis);
|
|
1709
1714
|
} catch (e) {
|
|
1710
1715
|
if (e instanceof AppearanceError) throw new PadesError("REQUEST_INVALID", `appearance: ${e.message}`, { cause: e });
|
|
1711
1716
|
throw new PadesError("PDF_INVALID", "PDF-\u0434 \u0433\u0430\u0440\u044B\u043D \u04AF\u0441\u0433\u0438\u0439\u043D revision \u0431\u0438\u0447\u0438\u0436 \u0447\u0430\u0434\u0441\u0430\u043D\u0433\u04AF\u0439", { cause: e });
|
package/dist/validate.cjs
CHANGED
|
@@ -2054,10 +2054,12 @@ var Lexer = class {
|
|
|
2054
2054
|
const out = [];
|
|
2055
2055
|
for (; ; ) {
|
|
2056
2056
|
let c = this.readByte();
|
|
2057
|
-
while (isSpace(c)) c = this.readByte();
|
|
2057
|
+
while (isSpace(c) && !this.eof) c = this.readByte();
|
|
2058
|
+
if (this.eof) throw new PdfError("unterminated hex string");
|
|
2058
2059
|
if (c === 62) break;
|
|
2059
2060
|
let c2 = this.readByte();
|
|
2060
|
-
while (isSpace(c2)) c2 = this.readByte();
|
|
2061
|
+
while (isSpace(c2) && !this.eof) c2 = this.readByte();
|
|
2062
|
+
if (this.eof) throw new PdfError("unterminated hex string");
|
|
2061
2063
|
const x = unhex(c) << 4 | unhex(c2);
|
|
2062
2064
|
if (unhex(c) < 0 || unhex(c2) < 0 || x < 0) throw new PdfError("malformed hex string");
|
|
2063
2065
|
out.push(x);
|
|
@@ -2069,6 +2071,7 @@ var Lexer = class {
|
|
|
2069
2071
|
let depth = 1;
|
|
2070
2072
|
for (; ; ) {
|
|
2071
2073
|
let c = this.readByte();
|
|
2074
|
+
if (this.eof) throw new PdfError("unterminated literal string");
|
|
2072
2075
|
if (c === 40) {
|
|
2073
2076
|
depth++;
|
|
2074
2077
|
out.push(c);
|
|
@@ -2213,6 +2216,7 @@ var Lexer = class {
|
|
|
2213
2216
|
const tok = this.readToken();
|
|
2214
2217
|
if (isKw(tok, "]")) break;
|
|
2215
2218
|
if (tok === EOF_TOKEN) throw new PdfError("unterminated array");
|
|
2219
|
+
if (isKw(tok, "endobj")) throw new PdfError("unterminated array");
|
|
2216
2220
|
this.unreadToken(tok);
|
|
2217
2221
|
x.push(asObj(this.readObject()));
|
|
2218
2222
|
}
|
|
@@ -2571,6 +2575,7 @@ var Reader = class {
|
|
|
2571
2575
|
for (let i = 0; i < n; i++) {
|
|
2572
2576
|
const id = b.readToken();
|
|
2573
2577
|
const off = b.readToken();
|
|
2578
|
+
if (id === EOF_TOKEN || off === EOF_TOKEN) break;
|
|
2574
2579
|
const idn = id instanceof PInt ? Number(BigInt.asUintN(32, id.v)) : 0;
|
|
2575
2580
|
if (idn === ptr.id) {
|
|
2576
2581
|
const o = off instanceof PInt ? Number(off.v) : 0;
|
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.
|
|
3
|
+
"version": "0.30.1",
|
|
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/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",
|
|
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/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",
|
|
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",
|