@gerege-systems/eid-mongolia-sdk 0.20.0 → 0.21.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 +23 -4
- package/bin/convert-assets.mjs +27 -1
- package/dist/browser.js +1 -1
- package/dist/{chunk-HLSFSIWP.js → chunk-ISTWNY6N.js} +461 -39
- package/dist/{chunk-ARITEQLS.js → chunk-T3QLOY6J.js} +369 -50
- package/dist/{chunk-D5NPS7ET.js → chunk-ZB7LEWA5.js} +1 -1
- package/dist/convert.js +16 -25
- package/dist/index.cjs +61 -4
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -2
- package/dist/pades.cjs +589 -71
- package/dist/pades.d.cts +7 -1
- package/dist/pades.d.ts +7 -1
- package/dist/pades.js +24 -4
- package/dist/validate.cjs +704 -312
- package/dist/validate.d.cts +6 -2
- package/dist/validate.d.ts +6 -2
- package/dist/validate.js +116 -431
- package/package.json +2 -2
package/dist/pades.d.cts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { E as EidError } from './errors-xTmsGXyo.cjs';
|
|
2
2
|
import { F as FetchFn } from './fetch-BjfH46q9.cjs';
|
|
3
3
|
|
|
4
|
+
/** Олгогчийн гарын үсэгтэй «revoked» хариу (OCSP эсвэл CRL) — complete-д дахин оролдохгүй хатуу алдаа (Go ErrCertificateRevoked). */
|
|
5
|
+
declare class CertificateRevokedError extends Error {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
/** PDF/CMS профайлын хувилбар (Go reference `ProfileVersion`). */
|
|
5
10
|
declare const PROFILE_VERSION = "pades-client/1";
|
|
6
11
|
/** Тогтвортой алдааны кодууд (бүх платформд ижил). */
|
|
@@ -21,6 +26,7 @@ declare class PadesError extends EidError {
|
|
|
21
26
|
constructor(code: PadesErrorCode, message: string, options?: {
|
|
22
27
|
cause?: unknown;
|
|
23
28
|
});
|
|
29
|
+
/** TSA_UNAVAILABLE / LTV_UNAVAILABLE — гэхдээ гэрчилгээ цуцлагдсан (`cause` нь {@link CertificateRevokedError}) бол үгүй. */
|
|
24
30
|
get retryable(): boolean;
|
|
25
31
|
}
|
|
26
32
|
interface PadesPrepareOptions {
|
|
@@ -147,4 +153,4 @@ declare function prepare(pdf: Uint8Array | ArrayBuffer, opts: PadesPrepareOption
|
|
|
147
153
|
*/
|
|
148
154
|
declare function complete(state: Uint8Array | ArrayBuffer, signature: Uint8Array | string, opts?: PadesCompleteOptions): Promise<PadesCompleted>;
|
|
149
155
|
|
|
150
|
-
export { PADES_ERROR_CODES, PROFILE_VERSION, type PadesAppearance, type PadesCompleteOptions, type PadesCompleted, PadesError, type PadesErrorCode, type PadesPrepareOptions, type PadesPrepared, complete, prepare, profileVersion };
|
|
156
|
+
export { CertificateRevokedError, PADES_ERROR_CODES, PROFILE_VERSION, type PadesAppearance, type PadesCompleteOptions, type PadesCompleted, PadesError, type PadesErrorCode, type PadesPrepareOptions, type PadesPrepared, complete, prepare, profileVersion };
|
package/dist/pades.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { E as EidError } from './errors-xTmsGXyo.js';
|
|
2
2
|
import { F as FetchFn } from './fetch-BjfH46q9.js';
|
|
3
3
|
|
|
4
|
+
/** Олгогчийн гарын үсэгтэй «revoked» хариу (OCSP эсвэл CRL) — complete-д дахин оролдохгүй хатуу алдаа (Go ErrCertificateRevoked). */
|
|
5
|
+
declare class CertificateRevokedError extends Error {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
/** PDF/CMS профайлын хувилбар (Go reference `ProfileVersion`). */
|
|
5
10
|
declare const PROFILE_VERSION = "pades-client/1";
|
|
6
11
|
/** Тогтвортой алдааны кодууд (бүх платформд ижил). */
|
|
@@ -21,6 +26,7 @@ declare class PadesError extends EidError {
|
|
|
21
26
|
constructor(code: PadesErrorCode, message: string, options?: {
|
|
22
27
|
cause?: unknown;
|
|
23
28
|
});
|
|
29
|
+
/** TSA_UNAVAILABLE / LTV_UNAVAILABLE — гэхдээ гэрчилгээ цуцлагдсан (`cause` нь {@link CertificateRevokedError}) бол үгүй. */
|
|
24
30
|
get retryable(): boolean;
|
|
25
31
|
}
|
|
26
32
|
interface PadesPrepareOptions {
|
|
@@ -147,4 +153,4 @@ declare function prepare(pdf: Uint8Array | ArrayBuffer, opts: PadesPrepareOption
|
|
|
147
153
|
*/
|
|
148
154
|
declare function complete(state: Uint8Array | ArrayBuffer, signature: Uint8Array | string, opts?: PadesCompleteOptions): Promise<PadesCompleted>;
|
|
149
155
|
|
|
150
|
-
export { PADES_ERROR_CODES, PROFILE_VERSION, type PadesAppearance, type PadesCompleteOptions, type PadesCompleted, PadesError, type PadesErrorCode, type PadesPrepareOptions, type PadesPrepared, complete, prepare, profileVersion };
|
|
156
|
+
export { CertificateRevokedError, PADES_ERROR_CODES, PROFILE_VERSION, type PadesAppearance, type PadesCompleteOptions, type PadesCompleted, PadesError, type PadesErrorCode, type PadesPrepareOptions, type PadesPrepared, complete, prepare, profileVersion };
|
package/dist/pades.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Reader,
|
|
9
9
|
appearanceObjects,
|
|
10
10
|
appendVerifyPage,
|
|
11
|
+
checkStructure,
|
|
11
12
|
escapeName,
|
|
12
13
|
hexString,
|
|
13
14
|
isBrowser,
|
|
@@ -18,9 +19,10 @@ import {
|
|
|
18
19
|
serialize,
|
|
19
20
|
visibleRect,
|
|
20
21
|
visibleWidget
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-T3QLOY6J.js";
|
|
22
23
|
import {
|
|
23
24
|
CLAIMED_ROLE_MAX_RUNES,
|
|
25
|
+
CertificateRevokedError,
|
|
24
26
|
EID_ISSUERS,
|
|
25
27
|
INTERMEDIATES,
|
|
26
28
|
LTVError,
|
|
@@ -50,10 +52,10 @@ import {
|
|
|
50
52
|
toHex,
|
|
51
53
|
verifyCitizen,
|
|
52
54
|
verifySignedData
|
|
53
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-ISTWNY6N.js";
|
|
54
56
|
import {
|
|
55
57
|
EidError
|
|
56
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-ZB7LEWA5.js";
|
|
57
59
|
|
|
58
60
|
// src/pades/limits.ts
|
|
59
61
|
var MAX_INPUT_BYTES = (10 << 20) - (256 << 10);
|
|
@@ -355,7 +357,7 @@ var PrecheckError = class extends Error {
|
|
|
355
357
|
}
|
|
356
358
|
code;
|
|
357
359
|
};
|
|
358
|
-
var ENCRYPT_KEY = /\/Encrypt
|
|
360
|
+
var ENCRYPT_KEY = /\/Encrypt(?:\s+\d+\s+\d+\s+R|\s*<<)/;
|
|
359
361
|
function openReader(doc) {
|
|
360
362
|
try {
|
|
361
363
|
return new Reader(doc);
|
|
@@ -596,7 +598,9 @@ var PadesError = class extends EidError {
|
|
|
596
598
|
if (options?.cause !== void 0) this.cause = options.cause;
|
|
597
599
|
}
|
|
598
600
|
code;
|
|
601
|
+
/** TSA_UNAVAILABLE / LTV_UNAVAILABLE — гэхдээ гэрчилгээ цуцлагдсан (`cause` нь {@link CertificateRevokedError}) бол үгүй. */
|
|
599
602
|
get retryable() {
|
|
603
|
+
if (this.cause instanceof CertificateRevokedError) return false;
|
|
600
604
|
return this.code === "TSA_UNAVAILABLE" || this.code === "LTV_UNAVAILABLE";
|
|
601
605
|
}
|
|
602
606
|
};
|
|
@@ -673,6 +677,11 @@ async function prepare(pdf, opts) {
|
|
|
673
677
|
const doc = u8(pdf, "pdf");
|
|
674
678
|
if (doc.length > MAX_INPUT_BYTES) throw new PadesError("PDF_TOO_LARGE", "PDF 9.75 MB-\u0430\u0430\u0441 \u0438\u0445 \u0431\u0430\u0439\u043D\u0430");
|
|
675
679
|
if (doc.length < 5 || String.fromCharCode(...doc.subarray(0, 5)) !== "%PDF-") throw new PadesError("PDF_INVALID", "PDF \u0431\u0438\u0448 \u044D\u0441\u0432\u044D\u043B \u044D\u0432\u0434\u044D\u0440\u0441\u044D\u043D");
|
|
680
|
+
try {
|
|
681
|
+
checkStructure(doc);
|
|
682
|
+
} catch (e) {
|
|
683
|
+
throw new PadesError("PDF_INVALID", "PDF-\u0438\u0439\u043D \u0431\u04AF\u0442\u044D\u0446 \u0445\u044D\u0442 \u0433\u04AF\u043D \u044D\u0441\u0432\u044D\u043B \u0442\u04E9\u0432\u04E9\u0433\u0442\u044D\u0439", { cause: e });
|
|
684
|
+
}
|
|
676
685
|
let cert;
|
|
677
686
|
try {
|
|
678
687
|
cert = parseCertificate(u8(opts.signerCert, "signerCert"));
|
|
@@ -843,6 +852,15 @@ async function complete(state, signature, opts = {}) {
|
|
|
843
852
|
let chain;
|
|
844
853
|
try {
|
|
845
854
|
st = await decodeState(u8(state, "state"));
|
|
855
|
+
} catch (e) {
|
|
856
|
+
throw new PadesError("STATE_INVALID", "state \u0437\u0430\u0434\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439", { cause: e });
|
|
857
|
+
}
|
|
858
|
+
try {
|
|
859
|
+
checkStructure(st.pdf);
|
|
860
|
+
} catch (e) {
|
|
861
|
+
throw new PadesError("STATE_INVALID", "state-\u0438\u0439\u043D PDF-\u0438\u0439\u043D \u0431\u04AF\u0442\u044D\u0446 \u0445\u044D\u0442 \u0433\u04AF\u043D \u044D\u0441\u0432\u044D\u043B \u0442\u04E9\u0432\u04E9\u0433\u0442\u044D\u0439", { cause: e });
|
|
862
|
+
}
|
|
863
|
+
try {
|
|
846
864
|
cert = parseCertificate(st.signerCert);
|
|
847
865
|
chain = st.chain.map((c) => parseCertificate(c));
|
|
848
866
|
} catch (e) {
|
|
@@ -897,6 +915,7 @@ async function complete(state, signature, opts = {}) {
|
|
|
897
915
|
break;
|
|
898
916
|
} catch (e) {
|
|
899
917
|
throwIfAborted(signal);
|
|
918
|
+
if (e instanceof CertificateRevokedError) throw new PadesError("LTV_UNAVAILABLE", "\u0433\u044D\u0440\u0447\u0438\u043B\u0433\u044D\u044D \u0446\u0443\u0446\u043B\u0430\u0433\u0434\u0441\u0430\u043D", { cause: e });
|
|
900
919
|
if (attempt >= ltvRetries) {
|
|
901
920
|
throw new PadesError("LTV_UNAVAILABLE", `OCSP/CRL \u0431\u04AF\u0440\u044D\u043D \u0430\u0432\u0447 \u0447\u0430\u0434\u0441\u0430\u043D\u0433\u04AF\u0439${e instanceof LTVError ? ": " + e.message : ""}`, { cause: e });
|
|
902
921
|
}
|
|
@@ -937,6 +956,7 @@ async function complete(state, signature, opts = {}) {
|
|
|
937
956
|
};
|
|
938
957
|
}
|
|
939
958
|
export {
|
|
959
|
+
CertificateRevokedError,
|
|
940
960
|
PADES_ERROR_CODES,
|
|
941
961
|
PROFILE_VERSION,
|
|
942
962
|
PadesError,
|