@gerege-systems/eid-mongolia-sdk 0.23.0 → 0.25.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 +50 -10
- package/bin/convert-assets.mjs +176 -20
- package/dist/{chunk-T3QLOY6J.js → chunk-CRXEUCMP.js} +60 -0
- package/dist/convert.d.ts +2 -2
- package/dist/convert.js +25 -2
- package/dist/pades.cjs +991 -8
- package/dist/pades.d.cts +26 -1
- package/dist/pades.d.ts +26 -1
- package/dist/pades.js +936 -8
- package/dist/validate.cjs +37 -14
- package/dist/validate.js +2 -15
- package/package.json +2 -2
package/dist/validate.cjs
CHANGED
|
@@ -1747,6 +1747,38 @@ function zlibInflate(src, limit = 64 << 20, initial) {
|
|
|
1747
1747
|
return inflateRaw(src.subarray(2), limit, void 0, initial);
|
|
1748
1748
|
}
|
|
1749
1749
|
function inflateRaw(src, limit = 64 << 20, info, initial) {
|
|
1750
|
+
return inflate(src, limit, info, initial, false);
|
|
1751
|
+
}
|
|
1752
|
+
function adler32(b) {
|
|
1753
|
+
let a = 1;
|
|
1754
|
+
let s = 0;
|
|
1755
|
+
for (let i = 0; i < b.length; ) {
|
|
1756
|
+
const n = Math.min(5552, b.length - i);
|
|
1757
|
+
for (let j = 0; j < n; j++, i++) {
|
|
1758
|
+
a += b[i];
|
|
1759
|
+
s += a;
|
|
1760
|
+
}
|
|
1761
|
+
a %= 65521;
|
|
1762
|
+
s %= 65521;
|
|
1763
|
+
}
|
|
1764
|
+
return (s << 16 | a) >>> 0;
|
|
1765
|
+
}
|
|
1766
|
+
function complete(lengths, n) {
|
|
1767
|
+
let max = 0;
|
|
1768
|
+
let sum = 0;
|
|
1769
|
+
let count = 0;
|
|
1770
|
+
for (let i = 0; i < n; i++) if (lengths[i] > max) max = lengths[i];
|
|
1771
|
+
if (max === 0) return true;
|
|
1772
|
+
for (let i = 0; i < n; i++) {
|
|
1773
|
+
const l = lengths[i];
|
|
1774
|
+
if (l) {
|
|
1775
|
+
sum += 2 ** (max - l);
|
|
1776
|
+
count++;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
return sum === 2 ** max || sum === 1 && max === 1 && count === 1;
|
|
1780
|
+
}
|
|
1781
|
+
function inflate(src, limit, info, initial, strict) {
|
|
1750
1782
|
let pos = 0;
|
|
1751
1783
|
let bitBuf = 0;
|
|
1752
1784
|
let bitCnt = 0;
|
|
@@ -1821,8 +1853,10 @@ function inflateRaw(src, limit = 64 << 20, info, initial) {
|
|
|
1821
1853
|
const hlit = bits(5) + 257;
|
|
1822
1854
|
const hdist = bits(5) + 1;
|
|
1823
1855
|
const hclen = bits(4) + 4;
|
|
1856
|
+
if (strict && (hlit > 286 || hdist > 30)) throw new InflateError("inflate: HLIT/HDIST");
|
|
1824
1857
|
const cl = new Uint8Array(19);
|
|
1825
1858
|
for (let i = 0; i < hclen; i++) cl[CL_ORDER[i]] = bits(3);
|
|
1859
|
+
if (strict && !complete(cl, 19)) throw new InflateError("inflate: \u043A\u043E\u0434 \u0431\u04AF\u0440\u044D\u043D \u0431\u0438\u0448");
|
|
1826
1860
|
const clh = build(cl, 19);
|
|
1827
1861
|
const lens = new Uint8Array(hlit + hdist);
|
|
1828
1862
|
for (let i = 0; i < hlit + hdist; ) {
|
|
@@ -1843,6 +1877,9 @@ function inflateRaw(src, limit = 64 << 20, info, initial) {
|
|
|
1843
1877
|
lens.fill(val, i, i + rep);
|
|
1844
1878
|
i += rep;
|
|
1845
1879
|
}
|
|
1880
|
+
if (strict && (!complete(lens.subarray(0, hlit), hlit) || !complete(lens.subarray(hlit), hdist))) {
|
|
1881
|
+
throw new InflateError("inflate: \u043A\u043E\u0434 \u0431\u04AF\u0440\u044D\u043D \u0431\u0438\u0448");
|
|
1882
|
+
}
|
|
1846
1883
|
lit = build(lens.subarray(0, hlit), hlit);
|
|
1847
1884
|
dist = build(lens.subarray(hlit), hdist);
|
|
1848
1885
|
}
|
|
@@ -3533,20 +3570,6 @@ function zlibStrict(src, limit) {
|
|
|
3533
3570
|
if (adler32(out) !== want) throw errPDFSyntax();
|
|
3534
3571
|
return out;
|
|
3535
3572
|
}
|
|
3536
|
-
function adler32(b) {
|
|
3537
|
-
let a = 1;
|
|
3538
|
-
let s = 0;
|
|
3539
|
-
for (let i = 0; i < b.length; ) {
|
|
3540
|
-
const n = Math.min(5552, b.length - i);
|
|
3541
|
-
for (let j = 0; j < n; j++, i++) {
|
|
3542
|
-
a += b[i];
|
|
3543
|
-
s += a;
|
|
3544
|
-
}
|
|
3545
|
-
a %= 65521;
|
|
3546
|
-
s %= 65521;
|
|
3547
|
-
}
|
|
3548
|
-
return (s << 16 | a) >>> 0;
|
|
3549
|
-
}
|
|
3550
3573
|
function unPNG(input, cols) {
|
|
3551
3574
|
if (input.length % (cols + 1) !== 0) throw errPDFSyntax();
|
|
3552
3575
|
const rows = input.length / (cols + 1);
|
package/dist/validate.js
CHANGED
|
@@ -4,13 +4,14 @@ import {
|
|
|
4
4
|
PRef,
|
|
5
5
|
Reader,
|
|
6
6
|
StructureError,
|
|
7
|
+
adler32,
|
|
7
8
|
appearanceObjects,
|
|
8
9
|
checkStructure,
|
|
9
10
|
inflateRaw,
|
|
10
11
|
isBrowser,
|
|
11
12
|
round100,
|
|
12
13
|
visibleWidget
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-CRXEUCMP.js";
|
|
14
15
|
import {
|
|
15
16
|
EID_ISSUERS,
|
|
16
17
|
INTERMEDIATES,
|
|
@@ -749,20 +750,6 @@ function zlibStrict(src, limit) {
|
|
|
749
750
|
if (adler32(out) !== want) throw errPDFSyntax();
|
|
750
751
|
return out;
|
|
751
752
|
}
|
|
752
|
-
function adler32(b) {
|
|
753
|
-
let a = 1;
|
|
754
|
-
let s = 0;
|
|
755
|
-
for (let i = 0; i < b.length; ) {
|
|
756
|
-
const n = Math.min(5552, b.length - i);
|
|
757
|
-
for (let j = 0; j < n; j++, i++) {
|
|
758
|
-
a += b[i];
|
|
759
|
-
s += a;
|
|
760
|
-
}
|
|
761
|
-
a %= 65521;
|
|
762
|
-
s %= 65521;
|
|
763
|
-
}
|
|
764
|
-
return (s << 16 | a) >>> 0;
|
|
765
|
-
}
|
|
766
753
|
function unPNG(input, cols) {
|
|
767
754
|
if (input.length % (cols + 1) !== 0) throw errPDFSyntax();
|
|
768
755
|
const rows = input.length / (cols + 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gerege-systems/eid-mongolia-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
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-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",
|
|
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",
|