@gerege-systems/eid-mongolia-sdk 0.30.1 → 0.32.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 +27 -2
- package/dist/browser.d.cts +18 -2
- package/dist/browser.d.ts +18 -2
- package/dist/browser.js +1 -1
- package/dist/{chunk-MA4RMWBO.js → chunk-M4NS4UFP.js} +102 -13
- package/dist/{chunk-H7JOACAZ.js → chunk-R73IR6OH.js} +1 -0
- package/dist/{errors-CxAr-WIA.d.cts → errors-3JEfE-FW.d.cts} +2 -2
- package/dist/{errors-CxAr-WIA.d.ts → errors-3JEfE-FW.d.ts} +2 -2
- package/dist/index.cjs +24 -1
- package/dist/index.d.cts +29 -7
- package/dist/index.d.ts +29 -7
- package/dist/index.js +24 -2
- package/dist/pades.cjs +169 -20
- package/dist/pades.d.cts +44 -2
- package/dist/pades.d.ts +44 -2
- package/dist/pades.js +71 -9
- package/dist/{browser-CYpvoCRr.d.cts → types-ByGHVzuP.d.cts} +50 -17
- package/dist/{browser-DturMWIL.d.ts → types-ByGHVzuP.d.ts} +50 -17
- package/dist/validate.cjs +150 -15
- package/dist/validate.d.cts +1 -1
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +35 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -674,6 +674,31 @@ 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.31.0+).** `appearance.signatureImage` (иргэний гарын үсгийн зураг) ба
|
|
678
|
+
`appearance.stampImage` (байгууллагын тамга — зөвхөн `claimedRole`/onBehalfOf-той, эс бөгөөс `REQUEST_INVALID`) —
|
|
679
|
+
`PdfImage { width, height, color: [r, g, b], alpha: "<base64 zlib>", sha256 }`, CA-ийн өгөх «PDF зураг» (PNG биш; SDK
|
|
680
|
+
`alpha`-г байтаар нь /SMask болгон бичнэ, шахалт хийхгүй — бүх SDK байт-ижил). Зураг дүрслэлийн ДОТОР (дээд зурвас; тамга
|
|
681
|
+
баруун дээд буланд хайрцгийг давж) зурагдана — тусдаа annotation биш тул өмнөх гарын үсэг «өөрчлөгдөөгүй» хэвээр.
|
|
682
|
+
`width`, `height` хоёулаа 0 бол анхдагч хэмжээ: 220×64 / гарын үсэгтэй 220×110 / тамгатай 240×147.5 (`suggestPlacement`-д ч —
|
|
683
|
+
ижил `appearance`-ийг өг). Зургийн оролт буруу (хэмжээ 1…1600 px, өнгө 0…255, alpha ≤ 300 KiB, нэг zlib stream яг
|
|
684
|
+
`width·height` байт, `sha256` жижиг hex) бол `REQUEST_INVALID`. Зургийн sha256 `complete().images` →
|
|
685
|
+
`registrationFromCompleted` → `images` болж CA-д очно. Дүрэм: `APPEARANCE_SPEC.md` §6, `PLACEMENT_SPEC.md` §6c.
|
|
686
|
+
|
|
687
|
+
Зургийг RP backend-ээс (0.32.0+): `eid.person.signatureImage(personEtsi)` → `GET /person/etsi/{personEtsi}/signature-image`
|
|
688
|
+
(**SIGN** эрх + иргэн сүүлийн 24 цагт нэвтэрсэн; зураг хадгалаагүй бол `null`, 403 → `ForbiddenError`) →
|
|
689
|
+
`EidImage { png, sha256, width, height, updatedAt, pdfImage }`; тамга — `organization.getRepresentations()`-ийн
|
|
690
|
+
`representations[].stampImage` (`stampImageSet` — бий эсэх; зураг зөвхөн SIGN эрхтэй RP-д). `pdfImage`-ийг хэвээр дамжуулна:
|
|
691
|
+
|
|
692
|
+
```ts
|
|
693
|
+
// backend
|
|
694
|
+
const sig = await eid.person.signatureImage(signerEtsi); // EidImage | null
|
|
695
|
+
const rep = (await eid.organization.getRepresentations(signerEtsi)).representations.find((r) => r.orgEtsi === orgEtsi);
|
|
696
|
+
const signatureImage = sig?.pdfImage, stampImage = rep?.stampImage?.pdfImage;
|
|
697
|
+
// клиент (/pades)
|
|
698
|
+
const p = await prepare(pdfBytes, { signerCert, claimedRole, verifyPage: true, fileName: "Гэрээ №12.pdf",
|
|
699
|
+
appearance: { x: 340, y: 36, width: 0, height: 0, signatureImage, stampImage } }); // 240 × 147.5
|
|
700
|
+
```
|
|
701
|
+
|
|
677
702
|
**Баталгаажуулах хуудсыг эхэнд (0.30.0+).** `verifyPagePosition: "first"` — QR хуудас баримтын 1-р хуудас болно (анхдагч
|
|
678
703
|
`"last"` — төгсгөлд, өмнөхтэй байт-ижил; бусад утга `REQUEST_INVALID`). Хуудас нэмэгдэх үед л (гарын үсэггүй баримт,
|
|
679
704
|
`verifyPage: true`) нөлөөтэй. `appearance.page`, `suggestPlacement`, `placement.page` үргэлж **оролтын** PDF-ийн хуудсаар
|
|
@@ -1089,8 +1114,8 @@ npm run test:convert-e2e # /convert жинхэнэ LibreOffice Chromium-д (BR
|
|
|
1089
1114
|
|
|
1090
1115
|
`/pades`-ийн conformance fixture (golden: оролт, тестийн PKI-ийн гэрчилгээ, TSA/OCSP/CRL-ийн тогтмол хариу, хүлээгдэх
|
|
1091
1116
|
sha256) ба фонт/гинжийн asset-ийг Go reference-ээс `node scripts/sync-pades-golden.mjs` хуулна (`GO_SDK_COMMIT` —
|
|
1092
|
-
|
|
1093
|
-
`expect.suggestion`); CI `--check`-ээр бэхэлсэн commit-тэй тулгана. Профайл:
|
|
1117
|
+
Go `pades-golden-v10` — зургийн кейсүүд `img-*`; v7-оос `placement/` scanner vectors-той, page 0 verify хуудас алгасна,
|
|
1118
|
+
`exact` + `expect.suggestion`); CI `--check`-ээр бэхэлсэн commit-тэй тулгана. Профайл:
|
|
1094
1119
|
Go репогийн `pades/PROFILE.md`, `PAGE_SPEC.md`, `PRECHECKS.md`, `WIRE.md`, `APPEARANCE_SPEC.md`, `PLACEMENT_SPEC.md`.
|
|
1095
1120
|
|
|
1096
1121
|
### Гэрээний шалгалт
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
export { D as
|
|
2
|
-
export { D as
|
|
1
|
+
export { D as DeviceLinkError, E as EidError } from './errors-3JEfE-FW.cjs';
|
|
2
|
+
export { D as DeviceLinkSession } from './types-ByGHVzuP.cjs';
|
|
3
|
+
|
|
4
|
+
/** isMobileUserAgent-ийн уншдаг navigator-ийн хэсэг (тестэд орлуулна). */
|
|
5
|
+
interface NavigatorLike {
|
|
6
|
+
userAgent?: string;
|
|
7
|
+
maxTouchPoints?: number;
|
|
8
|
+
userAgentData?: {
|
|
9
|
+
mobile?: boolean;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Анхдагч гар утас/таблет илрүүлэгч: Android, iPhone/iPod/iPad, UA-CH `mobile`, мөн desktop UA
|
|
14
|
+
* илгээдэг iPadOS (Macintosh + мэдрэгч дэлгэц, maxTouchPoints > 1).
|
|
15
|
+
*/
|
|
16
|
+
declare function isMobileUserAgent(nav?: NavigatorLike): boolean;
|
|
17
|
+
|
|
18
|
+
export { type NavigatorLike, isMobileUserAgent };
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
export { D as
|
|
2
|
-
export { D as
|
|
1
|
+
export { D as DeviceLinkError, E as EidError } from './errors-3JEfE-FW.js';
|
|
2
|
+
export { D as DeviceLinkSession } from './types-ByGHVzuP.js';
|
|
3
|
+
|
|
4
|
+
/** isMobileUserAgent-ийн уншдаг navigator-ийн хэсэг (тестэд орлуулна). */
|
|
5
|
+
interface NavigatorLike {
|
|
6
|
+
userAgent?: string;
|
|
7
|
+
maxTouchPoints?: number;
|
|
8
|
+
userAgentData?: {
|
|
9
|
+
mobile?: boolean;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Анхдагч гар утас/таблет илрүүлэгч: Android, iPhone/iPod/iPad, UA-CH `mobile`, мөн desktop UA
|
|
14
|
+
* илгээдэг iPadOS (Macintosh + мэдрэгч дэлгэц, maxTouchPoints > 1).
|
|
15
|
+
*/
|
|
16
|
+
declare function isMobileUserAgent(nav?: NavigatorLike): boolean;
|
|
17
|
+
|
|
18
|
+
export { type NavigatorLike, isMobileUserAgent };
|
package/dist/browser.js
CHANGED
|
@@ -151,7 +151,7 @@ function zlibInflate(src, limit = 64 << 20, initial) {
|
|
|
151
151
|
function inflateRaw(src, limit = 64 << 20, info, initial) {
|
|
152
152
|
return inflate(src, limit, info, initial, false);
|
|
153
153
|
}
|
|
154
|
-
function zlibInflateStrict(src, limit) {
|
|
154
|
+
function zlibInflateStrict(src, limit, exact = false) {
|
|
155
155
|
if (src.length < 2) throw new InflateError("zlib: header \u0430\u043B\u0433\u0430");
|
|
156
156
|
const cmf = src[0];
|
|
157
157
|
const flg = src[1];
|
|
@@ -169,6 +169,7 @@ function zlibInflateStrict(src, limit) {
|
|
|
169
169
|
if (at + 4 > src.length) throw new InflateError("zlib: adler32 \u0430\u043B\u0433\u0430");
|
|
170
170
|
const want = (src[at] << 24 | src[at + 1] << 16 | src[at + 2] << 8 | src[at + 3]) >>> 0;
|
|
171
171
|
if (adler32(out) !== want) throw new InflateError("zlib: adler32 \u0442\u0430\u0430\u0440\u0430\u0445\u0433\u04AF\u0439");
|
|
172
|
+
if (exact && at + 4 !== src.length) throw new InflateError("zlib: stream-\u0438\u0439\u043D \u0430\u0440\u0434 \u0438\u043B\u04AF\u04AF \u0431\u0430\u0439\u0442");
|
|
172
173
|
return out;
|
|
173
174
|
}
|
|
174
175
|
function adler32(b) {
|
|
@@ -2084,6 +2085,61 @@ function toUnicode(f) {
|
|
|
2084
2085
|
// src/pades/page/appearance.ts
|
|
2085
2086
|
var AppearanceError = class extends PdfError {
|
|
2086
2087
|
};
|
|
2088
|
+
var MAX_IMAGE_SIDE = 1600;
|
|
2089
|
+
var MAX_IMAGE_ALPHA_BYTES = 300 << 10;
|
|
2090
|
+
var isIntIn = (v, lo, hi) => Number.isInteger(v) && v >= lo && v <= hi;
|
|
2091
|
+
function checkPdfImage(im) {
|
|
2092
|
+
const bad = (msg) => new AppearanceError(`\u0437\u0443\u0440\u0430\u0433: ${msg}`);
|
|
2093
|
+
if (!isIntIn(im.w, 1, MAX_IMAGE_SIDE) || !isIntIn(im.h, 1, MAX_IMAGE_SIDE)) throw bad("\u0445\u044D\u043C\u0436\u044D\u044D 1\u20261600 px");
|
|
2094
|
+
if (!Array.isArray(im.color) || im.color.length !== 3) throw bad("\u04E9\u043D\u0433\u04E9 0\u2026255");
|
|
2095
|
+
for (const c of im.color) if (!isIntIn(c, 0, 255)) throw bad("\u04E9\u043D\u0433\u04E9 0\u2026255");
|
|
2096
|
+
if (!(im.alpha instanceof Uint8Array) || im.alpha.length === 0 || im.alpha.length > MAX_IMAGE_ALPHA_BYTES) throw bad("alpha 1 B\u2026300 KiB");
|
|
2097
|
+
if (im.alpha.length >= 2 && im.alpha[1] & 32) throw bad("alpha preset dictionary (FDICT)");
|
|
2098
|
+
let n;
|
|
2099
|
+
try {
|
|
2100
|
+
n = zlibInflateStrict(im.alpha, im.w * im.h, true).length;
|
|
2101
|
+
} catch (e) {
|
|
2102
|
+
if (!(e instanceof InflateError)) throw e;
|
|
2103
|
+
n = -1;
|
|
2104
|
+
}
|
|
2105
|
+
if (n !== im.w * im.h) throw bad("alpha \u043D\u044C \u044F\u0433 \u04E9\u0440\u0433\u04E9\u043D\xD7\u04E9\u043D\u0434\u04E9\u0440 \u0431\u0430\u0439\u0442 \u0431\u0438\u0448 (\u044D\u0441\u0432\u044D\u043B \u044D\u0432\u0434\u044D\u0440\u0441\u044D\u043D)");
|
|
2106
|
+
}
|
|
2107
|
+
var idiv = (a, b) => Math.trunc(a / b);
|
|
2108
|
+
function apFit(iw, ih, bw, bh) {
|
|
2109
|
+
if (iw * bh >= ih * bw) return [bw, Math.max(1, idiv(bw * ih, iw))];
|
|
2110
|
+
return [Math.max(1, idiv(bh * iw, ih)), bh];
|
|
2111
|
+
}
|
|
2112
|
+
function apLayoutImages(p) {
|
|
2113
|
+
const l = { boxH: p.h, rowH: p.h, sig: [0, 0, 0, 0], stamp: [0, 0, 0, 0] };
|
|
2114
|
+
if (!p.sig && !p.stamp) return l;
|
|
2115
|
+
const small = () => new AppearanceError("\u0445\u044D\u0442 \u0436\u0438\u0436\u0438\u0433 (\u0437\u0443\u0440\u0430\u0433\u0442\u0430\u0439 \u0434\u04AF\u0440\u0441\u043B\u044D\u043B)");
|
|
2116
|
+
if (p.stamp) l.boxH = idiv(p.h * 4, 5);
|
|
2117
|
+
const band = idiv(l.boxH * 9, 22);
|
|
2118
|
+
l.rowH = l.boxH - band;
|
|
2119
|
+
const sh = idiv(band * 14, 15);
|
|
2120
|
+
const sy = l.rowH - idiv(band * 2, 15);
|
|
2121
|
+
let sw = idiv(p.w * 15, 22);
|
|
2122
|
+
let sx = idiv(p.w - sw, 2);
|
|
2123
|
+
if (p.stamp) {
|
|
2124
|
+
const d = idiv(l.boxH * 2, 3);
|
|
2125
|
+
const qx = Math.min(idiv(p.w * 41, 60) - idiv(d, 2), p.w - d);
|
|
2126
|
+
if (qx < 0 || d <= 0) throw small();
|
|
2127
|
+
const [dw, dh] = apFit(p.stamp.w, p.stamp.h, d, d);
|
|
2128
|
+
l.stamp = [qx + idiv(d - dw, 2), p.h - d + idiv(d - dh, 2), dw, dh];
|
|
2129
|
+
sx = idiv(p.w, 30);
|
|
2130
|
+
sw = qx + idiv(d, 2) - sx;
|
|
2131
|
+
}
|
|
2132
|
+
if (p.sig) {
|
|
2133
|
+
if (sw <= 0 || sh <= 0) throw small();
|
|
2134
|
+
const [dw, dh] = apFit(p.sig.w, p.sig.h, sw, sh);
|
|
2135
|
+
const dx = p.stamp ? sx : sx + idiv(sw - dw, 2);
|
|
2136
|
+
l.sig = [dx, sy + idiv(sh - dh, 2), dw, dh];
|
|
2137
|
+
}
|
|
2138
|
+
return l;
|
|
2139
|
+
}
|
|
2140
|
+
function apDrawImage(w, name, r) {
|
|
2141
|
+
w.op(`q ${num100(r[2])} 0 0 ${num100(r[3])} ${num100(r[0])} ${num100(r[1])} cm /${name} Do Q`);
|
|
2142
|
+
}
|
|
2087
2143
|
var AP_PAD = 400;
|
|
2088
2144
|
var AP_GAP = 400;
|
|
2089
2145
|
var AP_MIN_MODULE = 100;
|
|
@@ -2129,6 +2185,10 @@ function appearanceContent(p) {
|
|
|
2129
2185
|
if (label === void 0) throw new AppearanceError(`\u0445\u044D\u043B ${p.lang}`);
|
|
2130
2186
|
if (!asciiURL(p.url)) throw new AppearanceError("URL ASCII \u0431\u0438\u0448");
|
|
2131
2187
|
if (p.w <= 0 || p.h <= 0 || p.w > MAX_APPEARANCE_SIDE || p.h > MAX_APPEARANCE_SIDE) throw new AppearanceError("\u0445\u044D\u043C\u0436\u044D\u044D");
|
|
2188
|
+
if (p.stamp && p.role === "") throw new AppearanceError("\u0442\u0430\u043C\u0433\u044B\u043D \u0437\u0443\u0440\u0430\u0433 \u0437\u04E9\u0432\u0445\u04E9\u043D \u0431\u0430\u0439\u0433\u0443\u0443\u043B\u043B\u0430\u0433\u044B\u043D \u043D\u044D\u0440\u0438\u0439\u043D \u04E9\u043C\u043D\u04E9\u04E9\u0441 (claimedRole)");
|
|
2189
|
+
for (const im of [p.sig, p.stamp]) if (im) checkPdfImage(im);
|
|
2190
|
+
const il = apLayoutImages(p);
|
|
2191
|
+
const rowH = il.rowH;
|
|
2132
2192
|
let m;
|
|
2133
2193
|
try {
|
|
2134
2194
|
m = qrEncode(latin1(p.url));
|
|
@@ -2136,14 +2196,14 @@ function appearanceContent(p) {
|
|
|
2136
2196
|
throw new AppearanceError(String(e));
|
|
2137
2197
|
}
|
|
2138
2198
|
const n = m.length;
|
|
2139
|
-
const mod = Math.trunc((
|
|
2199
|
+
const mod = Math.trunc((rowH - 2 * AP_PAD) / n);
|
|
2140
2200
|
if (mod < AP_MIN_MODULE) throw new AppearanceError(`\u0445\u044D\u0442 \u0436\u0438\u0436\u0438\u0433 (\u04E9\u043D\u0434\u04E9\u0440 \u2265 ${num100(2 * AP_PAD + n * AP_MIN_MODULE)} pt)`);
|
|
2141
2201
|
const tx = AP_PAD + mod * n + AP_GAP;
|
|
2142
2202
|
const tw = p.w - tx - AP_PAD;
|
|
2143
2203
|
const [reg, bld] = loadFonts();
|
|
2144
2204
|
const w = new PageWriter(reg, bld);
|
|
2145
2205
|
let lines;
|
|
2146
|
-
for (let f = AP_MAX_SIZE; f >= AP_MIN_SIZE && lines === void 0 && tw > 0; f--) lines = apLayout(w, p, label, f, tw);
|
|
2206
|
+
for (let f = AP_MAX_SIZE; f >= AP_MIN_SIZE && lines === void 0 && tw > 0; f--) lines = apLayout(w, p, label, f, tw, rowH);
|
|
2147
2207
|
if (lines === void 0) throw new AppearanceError("\u0445\u044D\u0442 \u0436\u0438\u0436\u0438\u0433 (\u0431\u0438\u0447\u0432\u044D\u0440 \u0431\u0430\u0433\u0442\u0430\u0445\u0433\u04AF\u0439)");
|
|
2148
2208
|
let total = 0;
|
|
2149
2209
|
for (const l of lines) total += l.size * AP_LEADING;
|
|
@@ -2155,8 +2215,13 @@ function appearanceContent(p) {
|
|
|
2155
2215
|
}
|
|
2156
2216
|
w.op(`${C_OK} RG`);
|
|
2157
2217
|
w.op("1 w");
|
|
2158
|
-
w.op(`0.5 0.5 ${num100(p.w - 100)} ${num100(
|
|
2159
|
-
|
|
2218
|
+
w.op(`0.5 0.5 ${num100(p.w - 100)} ${num100(il.boxH - 100)} re S`);
|
|
2219
|
+
if (p.sig || p.stamp) {
|
|
2220
|
+
w.op("0.5 w");
|
|
2221
|
+
w.op(`0 ${num100(rowH)} m ${num100(p.w)} ${num100(rowH)} l S`);
|
|
2222
|
+
}
|
|
2223
|
+
if (p.sig) apDrawImage(w, "Sig", il.sig);
|
|
2224
|
+
w.op(`q ${num100(mod)} 0 0 ${num100(mod)} ${num100(AP_PAD)} ${num100(Math.trunc((rowH - mod * n) / 2))} cm`);
|
|
2160
2225
|
w.op("0 0 0 rg");
|
|
2161
2226
|
for (let r = 0; r < n; r++) {
|
|
2162
2227
|
for (let c = 0; c < n; ) {
|
|
@@ -2171,17 +2236,18 @@ function appearanceContent(p) {
|
|
|
2171
2236
|
}
|
|
2172
2237
|
w.op("f");
|
|
2173
2238
|
w.op("Q");
|
|
2174
|
-
let cursor =
|
|
2239
|
+
let cursor = rowH - AP_PAD - Math.trunc((rowH - 2 * AP_PAD - total) / 2);
|
|
2175
2240
|
for (const l of lines) {
|
|
2176
2241
|
cursor -= l.size * AP_LEADING;
|
|
2177
2242
|
w.op(`${l.color} rg`);
|
|
2178
2243
|
w.op(`BT /F${l.font} ${l.size} Tf ${num100(tx)} ${num100(cursor + l.size * AP_DESCENT)} Td ${w.glyphHex(l.font, l.text)} Tj ET`);
|
|
2179
2244
|
}
|
|
2245
|
+
if (p.stamp) apDrawImage(w, "Stamp", il.stamp);
|
|
2180
2246
|
if (cm !== "") w.op("Q");
|
|
2181
2247
|
w.op("EMC");
|
|
2182
2248
|
return w.ops;
|
|
2183
2249
|
}
|
|
2184
|
-
function apLayout(w, p, label, f, tw) {
|
|
2250
|
+
function apLayout(w, p, label, f, tw, rowH) {
|
|
2185
2251
|
const b = f - AP_BODY_DELTA;
|
|
2186
2252
|
const limit = tw * 10;
|
|
2187
2253
|
const lines = [];
|
|
@@ -2195,20 +2261,40 @@ function apLayout(w, p, label, f, tw) {
|
|
|
2195
2261
|
if (l.text === "" || w.width1000(l.font, l.size, l.text) > limit) return void 0;
|
|
2196
2262
|
total += l.size * AP_LEADING;
|
|
2197
2263
|
}
|
|
2198
|
-
if (total >
|
|
2264
|
+
if (total > rowH - 2 * AP_PAD) return void 0;
|
|
2199
2265
|
return lines;
|
|
2200
2266
|
}
|
|
2267
|
+
function appearanceObjectCount(p) {
|
|
2268
|
+
return 11 + (p.sig ? 2 : 0) + (p.stamp ? 2 : 0);
|
|
2269
|
+
}
|
|
2201
2270
|
function appearanceObjects(p, ids) {
|
|
2271
|
+
if (ids.length !== appearanceObjectCount(p)) throw new AppearanceError("\u043E\u0431\u044A\u0435\u043A\u0442\u044B\u043D \u0442\u043E\u043E");
|
|
2202
2272
|
const [reg, bld] = loadFonts();
|
|
2203
2273
|
const { bw, bh } = apRotation(p.rotate, p.w, p.h);
|
|
2204
2274
|
const content = appearanceContent(p);
|
|
2275
|
+
let res = `/Font << /F1 ${ids[1]} 0 R /F2 ${ids[6]} 0 R >>`;
|
|
2276
|
+
const imgs = [];
|
|
2277
|
+
let next = 11;
|
|
2278
|
+
if (p.sig || p.stamp) {
|
|
2279
|
+
res += " /XObject <<";
|
|
2280
|
+
for (const [name, im] of [["Sig", p.sig], ["Stamp", p.stamp]]) {
|
|
2281
|
+
if (!im) continue;
|
|
2282
|
+
const base = ids[next];
|
|
2283
|
+
const mask = ids[next + 1];
|
|
2284
|
+
next += 2;
|
|
2285
|
+
res += ` /${name} ${base} 0 R`;
|
|
2286
|
+
imgs.push(
|
|
2287
|
+
streamObj(` /Type /XObject /Subtype /Image /Width 1 /Height 1 /ColorSpace /DeviceRGB /BitsPerComponent 8 /SMask ${mask} 0 R`, Uint8Array.from(im.color)),
|
|
2288
|
+
streamObj(` /Type /XObject /Subtype /Image /Width ${im.w} /Height ${im.h} /ColorSpace /DeviceGray /BitsPerComponent 8 /Filter /FlateDecode`, im.alpha)
|
|
2289
|
+
);
|
|
2290
|
+
}
|
|
2291
|
+
res += " >>";
|
|
2292
|
+
}
|
|
2205
2293
|
return [
|
|
2206
|
-
streamObj(
|
|
2207
|
-
` /Type /XObject /Subtype /Form /BBox [0 0 ${num100(bw)} ${num100(bh)}] /Resources << /Font << /F1 ${ids[1]} 0 R /F2 ${ids[6]} 0 R >> >>`,
|
|
2208
|
-
latin1(content)
|
|
2209
|
-
),
|
|
2294
|
+
streamObj(` /Type /XObject /Subtype /Form /BBox [0 0 ${num100(bw)} ${num100(bh)}] /Resources << ${res} >>`, latin1(content)),
|
|
2210
2295
|
...fontBodies(ids.slice(1, 6), reg),
|
|
2211
|
-
...fontBodies(ids.slice(6, 11), bld)
|
|
2296
|
+
...fontBodies(ids.slice(6, 11), bld),
|
|
2297
|
+
...imgs
|
|
2212
2298
|
];
|
|
2213
2299
|
}
|
|
2214
2300
|
function visibleWidget(fieldName, rect, pageID, pageGen, sigID, formID) {
|
|
@@ -2365,7 +2451,10 @@ export {
|
|
|
2365
2451
|
Incremental,
|
|
2366
2452
|
appendVerifyPage,
|
|
2367
2453
|
AppearanceError,
|
|
2454
|
+
MAX_IMAGE_SIDE,
|
|
2455
|
+
checkPdfImage,
|
|
2368
2456
|
round100,
|
|
2457
|
+
appearanceObjectCount,
|
|
2369
2458
|
appearanceObjects,
|
|
2370
2459
|
visibleWidget,
|
|
2371
2460
|
visibleRect,
|
|
@@ -106,10 +106,10 @@ declare const ON_BEHALF_ERROR_CODES: readonly OnBehalfErrorCode[];
|
|
|
106
106
|
* `pades_register.go`, `handlers_pdf.go`). 400: REQUEST_INVALID, CMS_INVALID, SIGNATURE_INVALID, TIMESTAMP_INVALID;
|
|
107
107
|
* 403: TOKEN_ORG_MISMATCH, REPRESENTATION_REVOKED; 404: DOC_NOT_FOUND; 409: SIGNER_MISMATCH, SIGNER_CERT_INVALID,
|
|
108
108
|
* TOKEN_CERT_INVALID, SESSION_MISMATCH, SESSION_NOT_COMPLETE, SESSION_FAILED, CLAIMED_ROLE_MISMATCH, DOC_ID_CONFLICT,
|
|
109
|
-
* REGISTRY_CONFLICT, PRIOR_MISMATCH; 413: REQUEST_TOO_LARGE; 429: RATE_LIMITED; 503: STATE_UNAVAILABLE (сүүлийн хоёр
|
|
109
|
+
* REGISTRY_CONFLICT, PRIOR_MISMATCH, IMAGE_MISMATCH (images[] ≠ CA-ийн одоогийн зураг); 413: REQUEST_TOO_LARGE; 429: RATE_LIMITED; 503: STATE_UNAVAILABLE (сүүлийн хоёр
|
|
110
110
|
* {@link RETRYABLE_ERROR_CODES}). Session олдоогүй бол 404 code-гүй.
|
|
111
111
|
*/
|
|
112
|
-
type PdfRegisterErrorCode = "REQUEST_INVALID" | "REQUEST_TOO_LARGE" | "CMS_INVALID" | "SIGNATURE_INVALID" | "TIMESTAMP_INVALID" | "SIGNER_MISMATCH" | "SIGNER_CERT_INVALID" | "TOKEN_CERT_INVALID" | "TOKEN_ORG_MISMATCH" | "SESSION_MISMATCH" | "SESSION_NOT_COMPLETE" | "SESSION_FAILED" | "CLAIMED_ROLE_MISMATCH" | "REPRESENTATION_REVOKED" | "DOC_ID_CONFLICT" | "REGISTRY_CONFLICT" | "DOC_NOT_FOUND" | "PRIOR_MISMATCH" | "RATE_LIMITED" | "STATE_UNAVAILABLE";
|
|
112
|
+
type PdfRegisterErrorCode = "REQUEST_INVALID" | "REQUEST_TOO_LARGE" | "CMS_INVALID" | "SIGNATURE_INVALID" | "TIMESTAMP_INVALID" | "SIGNER_MISMATCH" | "SIGNER_CERT_INVALID" | "TOKEN_CERT_INVALID" | "TOKEN_ORG_MISMATCH" | "SESSION_MISMATCH" | "SESSION_NOT_COMPLETE" | "SESSION_FAILED" | "CLAIMED_ROLE_MISMATCH" | "REPRESENTATION_REVOKED" | "DOC_ID_CONFLICT" | "REGISTRY_CONFLICT" | "DOC_NOT_FOUND" | "PRIOR_MISMATCH" | "IMAGE_MISMATCH" | "RATE_LIMITED" | "STATE_UNAVAILABLE";
|
|
113
113
|
/** {@link PdfRegisterErrorCode}-ийн бүх утга (runtime шалгалтад). */
|
|
114
114
|
declare const PDF_REGISTER_ERROR_CODES: readonly PdfRegisterErrorCode[];
|
|
115
115
|
/**
|
|
@@ -106,10 +106,10 @@ declare const ON_BEHALF_ERROR_CODES: readonly OnBehalfErrorCode[];
|
|
|
106
106
|
* `pades_register.go`, `handlers_pdf.go`). 400: REQUEST_INVALID, CMS_INVALID, SIGNATURE_INVALID, TIMESTAMP_INVALID;
|
|
107
107
|
* 403: TOKEN_ORG_MISMATCH, REPRESENTATION_REVOKED; 404: DOC_NOT_FOUND; 409: SIGNER_MISMATCH, SIGNER_CERT_INVALID,
|
|
108
108
|
* TOKEN_CERT_INVALID, SESSION_MISMATCH, SESSION_NOT_COMPLETE, SESSION_FAILED, CLAIMED_ROLE_MISMATCH, DOC_ID_CONFLICT,
|
|
109
|
-
* REGISTRY_CONFLICT, PRIOR_MISMATCH; 413: REQUEST_TOO_LARGE; 429: RATE_LIMITED; 503: STATE_UNAVAILABLE (сүүлийн хоёр
|
|
109
|
+
* REGISTRY_CONFLICT, PRIOR_MISMATCH, IMAGE_MISMATCH (images[] ≠ CA-ийн одоогийн зураг); 413: REQUEST_TOO_LARGE; 429: RATE_LIMITED; 503: STATE_UNAVAILABLE (сүүлийн хоёр
|
|
110
110
|
* {@link RETRYABLE_ERROR_CODES}). Session олдоогүй бол 404 code-гүй.
|
|
111
111
|
*/
|
|
112
|
-
type PdfRegisterErrorCode = "REQUEST_INVALID" | "REQUEST_TOO_LARGE" | "CMS_INVALID" | "SIGNATURE_INVALID" | "TIMESTAMP_INVALID" | "SIGNER_MISMATCH" | "SIGNER_CERT_INVALID" | "TOKEN_CERT_INVALID" | "TOKEN_ORG_MISMATCH" | "SESSION_MISMATCH" | "SESSION_NOT_COMPLETE" | "SESSION_FAILED" | "CLAIMED_ROLE_MISMATCH" | "REPRESENTATION_REVOKED" | "DOC_ID_CONFLICT" | "REGISTRY_CONFLICT" | "DOC_NOT_FOUND" | "PRIOR_MISMATCH" | "RATE_LIMITED" | "STATE_UNAVAILABLE";
|
|
112
|
+
type PdfRegisterErrorCode = "REQUEST_INVALID" | "REQUEST_TOO_LARGE" | "CMS_INVALID" | "SIGNATURE_INVALID" | "TIMESTAMP_INVALID" | "SIGNER_MISMATCH" | "SIGNER_CERT_INVALID" | "TOKEN_CERT_INVALID" | "TOKEN_ORG_MISMATCH" | "SESSION_MISMATCH" | "SESSION_NOT_COMPLETE" | "SESSION_FAILED" | "CLAIMED_ROLE_MISMATCH" | "REPRESENTATION_REVOKED" | "DOC_ID_CONFLICT" | "REGISTRY_CONFLICT" | "DOC_NOT_FOUND" | "PRIOR_MISMATCH" | "IMAGE_MISMATCH" | "RATE_LIMITED" | "STATE_UNAVAILABLE";
|
|
113
113
|
/** {@link PdfRegisterErrorCode}-ийн бүх утга (runtime шалгалтад). */
|
|
114
114
|
declare const PDF_REGISTER_ERROR_CODES: readonly PdfRegisterErrorCode[];
|
|
115
115
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -214,6 +214,7 @@ var PDF_REGISTER_ERROR_CODES = [
|
|
|
214
214
|
"REGISTRY_CONFLICT",
|
|
215
215
|
"DOC_NOT_FOUND",
|
|
216
216
|
"PRIOR_MISMATCH",
|
|
217
|
+
"IMAGE_MISMATCH",
|
|
217
218
|
"RATE_LIMITED",
|
|
218
219
|
"STATE_UNAVAILABLE"
|
|
219
220
|
];
|
|
@@ -390,6 +391,7 @@ var RP_ROUTES = {
|
|
|
390
391
|
personActivity: { method: "GET", path: "/rp/activity/etsi/{personEtsi}" },
|
|
391
392
|
personSummary: { method: "GET", path: "/person/summary/etsi/{personEtsi}" },
|
|
392
393
|
personChildren: { method: "GET", path: "/person/children/etsi/{personEtsi}" },
|
|
394
|
+
personSignatureImage: { method: "GET", path: "/person/etsi/{personEtsi}/signature-image" },
|
|
393
395
|
tokenCertificate: { method: "POST", path: "/token/certificate" },
|
|
394
396
|
tokenCertificateResult: { method: "GET", path: "/token/certificate/{sessionID}" },
|
|
395
397
|
pdfSignatures: { method: "POST", path: "/pdf/signatures" },
|
|
@@ -411,7 +413,8 @@ var PDF_SIGNATURE_REGISTER_FIELDS = [
|
|
|
411
413
|
"priorCmsSha256",
|
|
412
414
|
"priorRevisionSha256",
|
|
413
415
|
"onBehalfOf",
|
|
414
|
-
"signerEtsi"
|
|
416
|
+
"signerEtsi",
|
|
417
|
+
"images"
|
|
415
418
|
];
|
|
416
419
|
var SHARE_FORM_FIELDS = ["file", "filename", "to", "subject", "message", "lang"];
|
|
417
420
|
function routePath(route, ...args) {
|
|
@@ -619,6 +622,7 @@ function registrationFromCompleted(done, extra) {
|
|
|
619
622
|
}
|
|
620
623
|
if (extra.onBehalfOf) out.onBehalfOf = extra.onBehalfOf;
|
|
621
624
|
if (extra.signerEtsi) out.signerEtsi = extra.signerEtsi;
|
|
625
|
+
if (done.images?.length) out.images = done.images.map((x) => ({ kind: x.kind, sha256: x.sha256 }));
|
|
622
626
|
return out;
|
|
623
627
|
}
|
|
624
628
|
function priorSplits(n) {
|
|
@@ -680,6 +684,12 @@ function buildRegisterBody(input) {
|
|
|
680
684
|
if (priorRev.length) body.priorRevisionSha256 = priorRev;
|
|
681
685
|
if (input.onBehalfOf?.trim()) body.onBehalfOf = input.onBehalfOf.trim();
|
|
682
686
|
if (input.signerEtsi?.trim()) body.signerEtsi = input.signerEtsi.trim();
|
|
687
|
+
if (input.images?.length) {
|
|
688
|
+
body.images = input.images.map((x, i) => {
|
|
689
|
+
if (x?.kind !== "signature" && x?.kind !== "stamp") fail2(`images[${i}].kind: signature | stamp`);
|
|
690
|
+
return { kind: x.kind, sha256: hex(`images[${i}].sha256`, x.sha256) };
|
|
691
|
+
});
|
|
692
|
+
}
|
|
683
693
|
for (const k of Object.keys(body)) if (!PDF_SIGNATURE_REGISTER_FIELDS.includes(k)) fail2(`\u0434\u043E\u0442\u043E\u043E\u0434: \u04AF\u043B \u043C\u044D\u0434\u044D\u0433\u0434\u044D\u0445 \u0442\u0430\u043B\u0431\u0430\u0440 ${k}`);
|
|
684
694
|
return body;
|
|
685
695
|
}
|
|
@@ -1153,6 +1163,19 @@ var PersonApi = class {
|
|
|
1153
1163
|
children(personEtsi) {
|
|
1154
1164
|
return this.get(routePath(RP_ROUTES.personChildren, personEtsi));
|
|
1155
1165
|
}
|
|
1166
|
+
/**
|
|
1167
|
+
* GET /person/etsi/{personEtsi}/signature-image — иргэний гарын үсгийн зураг (харагдах гарын үсэгт:
|
|
1168
|
+
* `appearance.signatureImage = img.pdfImage`). PKI_READ биш, **SIGN** эрх; иргэн сүүлийн 24 цагт танай RP-ээр
|
|
1169
|
+
* нэвтэрсэн байх ёстой (эс бөгөөс `ForbiddenError`). Иргэн зураг хадгалаагүй (404) бол `null`.
|
|
1170
|
+
*/
|
|
1171
|
+
async signatureImage(personEtsi) {
|
|
1172
|
+
try {
|
|
1173
|
+
return rec3(await this.http.get(routePath(RP_ROUTES.personSignatureImage, personEtsi)));
|
|
1174
|
+
} catch (e) {
|
|
1175
|
+
if (e instanceof ApiError && e.status === 404) return null;
|
|
1176
|
+
throw e;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1156
1179
|
};
|
|
1157
1180
|
|
|
1158
1181
|
// src/token.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { R as RpCredentials, C as CertificateLevel, I as Interaction, S as SignatureAlgorithm, H as HashAlgorithm, N as NotificationSession, D as DeviceLinkSession, a as SessionResult,
|
|
2
|
-
export {
|
|
3
|
-
import { O as OnBehalfErrorCode, R as RetryableErrorCode, A as ApiError, H as HttpErrorInit } from './errors-
|
|
4
|
-
export { a as AppTransactionTooLargeError, b as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError, c as NoSigningCertificateError, d as ON_BEHALF_ERROR_CODES, P as PDF_REGISTER_ERROR_CODES, e as PdfRegisterErrorCode, f as RETRYABLE_ERROR_CODES, g as RequestInvalidError, h as ResponseTooLargeError, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-
|
|
1
|
+
import { R as RpCredentials, C as CertificateLevel, I as Interaction, S as SignatureAlgorithm, H as HashAlgorithm, N as NotificationSession, D as DeviceLinkSession, a as SessionResult, b as PersonBlock, c as RepresentationsResponse, E as EidImage, A as AcspContext, F as FlowType } from './types-ByGHVzuP.cjs';
|
|
2
|
+
export { d as DEFAULT_SIGN_SESSION_TTL_MS, e as EndResult, O as OrgResult, P as PdfImage, f as Representation, g as SessionState, h as SignContext, i as SignatureAlgorithmParameters, j as SignatureProtocol, T as TokenCertSessionBlock, k as TokenCertStatus, p as parseExpiresAt, s as sessionExpiry, l as startExpiry } from './types-ByGHVzuP.cjs';
|
|
3
|
+
import { O as OnBehalfErrorCode, R as RetryableErrorCode, A as ApiError, H as HttpErrorInit } from './errors-3JEfE-FW.cjs';
|
|
4
|
+
export { a as AppTransactionTooLargeError, b as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError, c as NoSigningCertificateError, d as ON_BEHALF_ERROR_CODES, P as PDF_REGISTER_ERROR_CODES, e as PdfRegisterErrorCode, f as RETRYABLE_ERROR_CODES, g as RequestInvalidError, h as ResponseTooLargeError, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-3JEfE-FW.cjs';
|
|
5
5
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
6
|
+
export { NavigatorLike, isMobileUserAgent } from './browser.cjs';
|
|
6
7
|
|
|
7
8
|
interface HttpConfig {
|
|
8
9
|
/** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
|
|
@@ -219,6 +220,18 @@ interface RegisterSignatureInput {
|
|
|
219
220
|
onBehalfOf?: string;
|
|
220
221
|
/** Заавал биш (`PNOMN-…`): ирвэл CMS-ийн зурагчийн SERIALNUMBER-тэй тэнцүү (эс бөгөөс 409 `SIGNER_MISMATCH`). */
|
|
221
222
|
signerEtsi?: string;
|
|
223
|
+
/**
|
|
224
|
+
* `complete().images` (0.31.0+) — харагдах дүрслэлд шигтгэсэн зураг бүрийн `{kind, sha256}` (pades APPEARANCE_SPEC.md
|
|
225
|
+
* §6.6): CA зурагчийн/байгууллагын хадгалсан PNG-тэй тулгана. Зураггүй бол илгээхгүй.
|
|
226
|
+
*/
|
|
227
|
+
images?: PdfSignatureImage[];
|
|
228
|
+
}
|
|
229
|
+
/** {@link RegisterSignatureInput.images}-ийн нэг мөр (Go `eid.PDFSignatureImage`). */
|
|
230
|
+
interface PdfSignatureImage {
|
|
231
|
+
/** `signature` — иргэний гарын үсгийн зураг; `stamp` — байгууллагын тамганы зураг. */
|
|
232
|
+
kind: "signature" | "stamp";
|
|
233
|
+
/** CA-ийн хадгалсан PNG-ийн SHA-256 (64 жижиг hex). */
|
|
234
|
+
sha256: string;
|
|
222
235
|
}
|
|
223
236
|
/** Өмнөх нэг гарын үсгийн хоёр түлхүүр ({@link RegisterSignatureInput.priorSignatures}). */
|
|
224
237
|
interface PriorSignature {
|
|
@@ -242,6 +255,8 @@ interface CompletedForRegistration {
|
|
|
242
255
|
priorRevisionSha256?: string[];
|
|
243
256
|
/** `complete().claimedRole` (0.27.0+) — хоосон биш бол `onBehalfOf` заавал. */
|
|
244
257
|
claimedRole?: string;
|
|
258
|
+
/** `complete().images` (0.31.0+) — байвал `images` болж илгээгдэнэ. */
|
|
259
|
+
images?: PdfSignatureImage[];
|
|
245
260
|
}
|
|
246
261
|
/**
|
|
247
262
|
* `pades.complete()`-ийн үр дүнгээс `registerSignature`-ийн биеийг бөглөнө (`hasPage`-ийг илгээхгүй — CA `revIndex`-ээс
|
|
@@ -563,6 +578,12 @@ declare class PersonApi {
|
|
|
563
578
|
summary(personEtsi: string): Promise<PersonSummary>;
|
|
564
579
|
/** Асран хамгаалж буй хүүхдүүд (зөвхөн унших). */
|
|
565
580
|
children(personEtsi: string): Promise<PersonChildren>;
|
|
581
|
+
/**
|
|
582
|
+
* GET /person/etsi/{personEtsi}/signature-image — иргэний гарын үсгийн зураг (харагдах гарын үсэгт:
|
|
583
|
+
* `appearance.signatureImage = img.pdfImage`). PKI_READ биш, **SIGN** эрх; иргэн сүүлийн 24 цагт танай RP-ээр
|
|
584
|
+
* нэвтэрсэн байх ёстой (эс бөгөөс `ForbiddenError`). Иргэн зураг хадгалаагүй (404) бол `null`.
|
|
585
|
+
*/
|
|
586
|
+
signatureImage(personEtsi: string): Promise<EidImage | null>;
|
|
566
587
|
}
|
|
567
588
|
|
|
568
589
|
/** Задалсан subject. Cert-д байхгүй талбар — undefined. Давхардсан OID-ийн эхнийх нь. */
|
|
@@ -1277,10 +1298,11 @@ declare class EidClient {
|
|
|
1277
1298
|
|
|
1278
1299
|
/**
|
|
1279
1300
|
* `POST /pdf/signatures`-ийн биеийн талбарууд — CA `server/internal/dto/pdf.go` `PDFSignatureRegisterRequest`-ийн JSON
|
|
1280
|
-
* tag (CA main d948fdd4, !355
|
|
1301
|
+
* tag (CA main d948fdd4, !355; `images` — APPEARANCE_SPEC §6.6, Go SDK #44, CA талд нэмэгдэж буй). CA `DisallowUnknownFields`
|
|
1302
|
+
* тул SDK зөвхөн эдгээрийг илгээнэ. Live discovery-ийн
|
|
1281
1303
|
* `endpoints.pdf.signatures` тайлбартай гэрээний тест тулгана.
|
|
1282
1304
|
*/
|
|
1283
|
-
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi"];
|
|
1305
|
+
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi", "images"];
|
|
1284
1306
|
/**
|
|
1285
1307
|
* `POST /share`-ийн multipart талбарууд — CA `server/internal/httpapi/handlers_share.go` `parseShareRequest` (CA main
|
|
1286
1308
|
* 0329ef95, !371). CA үл мэдэгдэх талбарыг 400 REQUEST_INVALID-аар татгалздаг. Live discovery-ийн `endpoints.share`
|
|
@@ -1665,4 +1687,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1665
1687
|
*/
|
|
1666
1688
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1667
1689
|
|
|
1668
|
-
export { APP_ATTESTATION_INVALID, AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, ApiError, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_INTERMEDIATES_PEM, CITIZEN_ISSUING_CA_SKI, CSR_KEY_REUSED, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, DEFAULT_MAX_WAIT_MS, DEFAULT_PDF_TIMEOUT_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, type EidLogin, type EidLoginContext, type EidLoginEvent, type EidLoginEventKind, type EidLoginIdentity, type EidLoginMode, type EidLoginOptions, type EidLoginRateLimitFn, type EidLoginRateLimits, type EidLoginRateRule, type EidLoginRequest, type EidLoginResponse, type EidLoginStore, type EidLoginSuccess, type EidLoginTx, FlowType, HashAlgorithm, Http, type HttpConfig, HttpErrorInit, Interaction, KYC_INCOMPLETE, LoginStoreFullError, MAX_APP_TRANSACTION_BYTES, MEMORY_LOGIN_STORE_MAX, NATIONAL_ROOT_CA_PEM, NO_ACTIVE_DEVICE, NotificationSession, type OcspCheckerOptions, OnBehalfErrorCode, OrganizationApi, PDF_SIGNATURE_REGISTER_FIELDS, type PdfDigestInput, type PdfDigestSession, type PdfDigestSigner, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type PriorSignature, type QrDeviceLinkTickerOptions, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, RetryableErrorCode, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SessionApi, SessionResult, type SessionTtl, ShareError, type ShareErrorCode, type ShareInfo, type ShareInput, type ShareNotSignedReason, type ShareResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TOKEN_CONFLICT_CODES, TOKEN_ERROR_CODES, TOKEN_ISSUANCE_PENDING, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInfo, type TokenCertInput, type TokenCertItem, type TokenCertPreview, type TokenCertResult, type TokenCertStart, type TokenConflictCode, type TokenErrorCode, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, WAIT_GRACE_MS, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, certificateLevelOf, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
|
1690
|
+
export { APP_ATTESTATION_INVALID, AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, ApiError, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_INTERMEDIATES_PEM, CITIZEN_ISSUING_CA_SKI, CSR_KEY_REUSED, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, DEFAULT_MAX_WAIT_MS, DEFAULT_PDF_TIMEOUT_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, EidImage, type EidLogin, type EidLoginContext, type EidLoginEvent, type EidLoginEventKind, type EidLoginIdentity, type EidLoginMode, type EidLoginOptions, type EidLoginRateLimitFn, type EidLoginRateLimits, type EidLoginRateRule, type EidLoginRequest, type EidLoginResponse, type EidLoginStore, type EidLoginSuccess, type EidLoginTx, FlowType, HashAlgorithm, Http, type HttpConfig, HttpErrorInit, Interaction, KYC_INCOMPLETE, LoginStoreFullError, MAX_APP_TRANSACTION_BYTES, MEMORY_LOGIN_STORE_MAX, NATIONAL_ROOT_CA_PEM, NO_ACTIVE_DEVICE, NotificationSession, type OcspCheckerOptions, OnBehalfErrorCode, OrganizationApi, PDF_SIGNATURE_REGISTER_FIELDS, type PdfDigestInput, type PdfDigestSession, type PdfDigestSigner, type PdfSignatureImage, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type PriorSignature, type QrDeviceLinkTickerOptions, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, RetryableErrorCode, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SessionApi, SessionResult, type SessionTtl, ShareError, type ShareErrorCode, type ShareInfo, type ShareInput, type ShareNotSignedReason, type ShareResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TOKEN_CONFLICT_CODES, TOKEN_ERROR_CODES, TOKEN_ISSUANCE_PENDING, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInfo, type TokenCertInput, type TokenCertItem, type TokenCertPreview, type TokenCertResult, type TokenCertStart, type TokenConflictCode, type TokenErrorCode, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, WAIT_GRACE_MS, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, certificateLevelOf, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { R as RpCredentials, C as CertificateLevel, I as Interaction, S as SignatureAlgorithm, H as HashAlgorithm, N as NotificationSession, D as DeviceLinkSession, a as SessionResult,
|
|
2
|
-
export {
|
|
3
|
-
import { O as OnBehalfErrorCode, R as RetryableErrorCode, A as ApiError, H as HttpErrorInit } from './errors-
|
|
4
|
-
export { a as AppTransactionTooLargeError, b as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError, c as NoSigningCertificateError, d as ON_BEHALF_ERROR_CODES, P as PDF_REGISTER_ERROR_CODES, e as PdfRegisterErrorCode, f as RETRYABLE_ERROR_CODES, g as RequestInvalidError, h as ResponseTooLargeError, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-
|
|
1
|
+
import { R as RpCredentials, C as CertificateLevel, I as Interaction, S as SignatureAlgorithm, H as HashAlgorithm, N as NotificationSession, D as DeviceLinkSession, a as SessionResult, b as PersonBlock, c as RepresentationsResponse, E as EidImage, A as AcspContext, F as FlowType } from './types-ByGHVzuP.js';
|
|
2
|
+
export { d as DEFAULT_SIGN_SESSION_TTL_MS, e as EndResult, O as OrgResult, P as PdfImage, f as Representation, g as SessionState, h as SignContext, i as SignatureAlgorithmParameters, j as SignatureProtocol, T as TokenCertSessionBlock, k as TokenCertStatus, p as parseExpiresAt, s as sessionExpiry, l as startExpiry } from './types-ByGHVzuP.js';
|
|
3
|
+
import { O as OnBehalfErrorCode, R as RetryableErrorCode, A as ApiError, H as HttpErrorInit } from './errors-3JEfE-FW.js';
|
|
4
|
+
export { a as AppTransactionTooLargeError, b as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError, c as NoSigningCertificateError, d as ON_BEHALF_ERROR_CODES, P as PDF_REGISTER_ERROR_CODES, e as PdfRegisterErrorCode, f as RETRYABLE_ERROR_CODES, g as RequestInvalidError, h as ResponseTooLargeError, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-3JEfE-FW.js';
|
|
5
5
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
6
|
+
export { NavigatorLike, isMobileUserAgent } from './browser.js';
|
|
6
7
|
|
|
7
8
|
interface HttpConfig {
|
|
8
9
|
/** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
|
|
@@ -219,6 +220,18 @@ interface RegisterSignatureInput {
|
|
|
219
220
|
onBehalfOf?: string;
|
|
220
221
|
/** Заавал биш (`PNOMN-…`): ирвэл CMS-ийн зурагчийн SERIALNUMBER-тэй тэнцүү (эс бөгөөс 409 `SIGNER_MISMATCH`). */
|
|
221
222
|
signerEtsi?: string;
|
|
223
|
+
/**
|
|
224
|
+
* `complete().images` (0.31.0+) — харагдах дүрслэлд шигтгэсэн зураг бүрийн `{kind, sha256}` (pades APPEARANCE_SPEC.md
|
|
225
|
+
* §6.6): CA зурагчийн/байгууллагын хадгалсан PNG-тэй тулгана. Зураггүй бол илгээхгүй.
|
|
226
|
+
*/
|
|
227
|
+
images?: PdfSignatureImage[];
|
|
228
|
+
}
|
|
229
|
+
/** {@link RegisterSignatureInput.images}-ийн нэг мөр (Go `eid.PDFSignatureImage`). */
|
|
230
|
+
interface PdfSignatureImage {
|
|
231
|
+
/** `signature` — иргэний гарын үсгийн зураг; `stamp` — байгууллагын тамганы зураг. */
|
|
232
|
+
kind: "signature" | "stamp";
|
|
233
|
+
/** CA-ийн хадгалсан PNG-ийн SHA-256 (64 жижиг hex). */
|
|
234
|
+
sha256: string;
|
|
222
235
|
}
|
|
223
236
|
/** Өмнөх нэг гарын үсгийн хоёр түлхүүр ({@link RegisterSignatureInput.priorSignatures}). */
|
|
224
237
|
interface PriorSignature {
|
|
@@ -242,6 +255,8 @@ interface CompletedForRegistration {
|
|
|
242
255
|
priorRevisionSha256?: string[];
|
|
243
256
|
/** `complete().claimedRole` (0.27.0+) — хоосон биш бол `onBehalfOf` заавал. */
|
|
244
257
|
claimedRole?: string;
|
|
258
|
+
/** `complete().images` (0.31.0+) — байвал `images` болж илгээгдэнэ. */
|
|
259
|
+
images?: PdfSignatureImage[];
|
|
245
260
|
}
|
|
246
261
|
/**
|
|
247
262
|
* `pades.complete()`-ийн үр дүнгээс `registerSignature`-ийн биеийг бөглөнө (`hasPage`-ийг илгээхгүй — CA `revIndex`-ээс
|
|
@@ -563,6 +578,12 @@ declare class PersonApi {
|
|
|
563
578
|
summary(personEtsi: string): Promise<PersonSummary>;
|
|
564
579
|
/** Асран хамгаалж буй хүүхдүүд (зөвхөн унших). */
|
|
565
580
|
children(personEtsi: string): Promise<PersonChildren>;
|
|
581
|
+
/**
|
|
582
|
+
* GET /person/etsi/{personEtsi}/signature-image — иргэний гарын үсгийн зураг (харагдах гарын үсэгт:
|
|
583
|
+
* `appearance.signatureImage = img.pdfImage`). PKI_READ биш, **SIGN** эрх; иргэн сүүлийн 24 цагт танай RP-ээр
|
|
584
|
+
* нэвтэрсэн байх ёстой (эс бөгөөс `ForbiddenError`). Иргэн зураг хадгалаагүй (404) бол `null`.
|
|
585
|
+
*/
|
|
586
|
+
signatureImage(personEtsi: string): Promise<EidImage | null>;
|
|
566
587
|
}
|
|
567
588
|
|
|
568
589
|
/** Задалсан subject. Cert-д байхгүй талбар — undefined. Давхардсан OID-ийн эхнийх нь. */
|
|
@@ -1277,10 +1298,11 @@ declare class EidClient {
|
|
|
1277
1298
|
|
|
1278
1299
|
/**
|
|
1279
1300
|
* `POST /pdf/signatures`-ийн биеийн талбарууд — CA `server/internal/dto/pdf.go` `PDFSignatureRegisterRequest`-ийн JSON
|
|
1280
|
-
* tag (CA main d948fdd4, !355
|
|
1301
|
+
* tag (CA main d948fdd4, !355; `images` — APPEARANCE_SPEC §6.6, Go SDK #44, CA талд нэмэгдэж буй). CA `DisallowUnknownFields`
|
|
1302
|
+
* тул SDK зөвхөн эдгээрийг илгээнэ. Live discovery-ийн
|
|
1281
1303
|
* `endpoints.pdf.signatures` тайлбартай гэрээний тест тулгана.
|
|
1282
1304
|
*/
|
|
1283
|
-
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi"];
|
|
1305
|
+
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi", "images"];
|
|
1284
1306
|
/**
|
|
1285
1307
|
* `POST /share`-ийн multipart талбарууд — CA `server/internal/httpapi/handlers_share.go` `parseShareRequest` (CA main
|
|
1286
1308
|
* 0329ef95, !371). CA үл мэдэгдэх талбарыг 400 REQUEST_INVALID-аар татгалздаг. Live discovery-ийн `endpoints.share`
|
|
@@ -1665,4 +1687,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1665
1687
|
*/
|
|
1666
1688
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1667
1689
|
|
|
1668
|
-
export { APP_ATTESTATION_INVALID, AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, ApiError, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_INTERMEDIATES_PEM, CITIZEN_ISSUING_CA_SKI, CSR_KEY_REUSED, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, DEFAULT_MAX_WAIT_MS, DEFAULT_PDF_TIMEOUT_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, type EidLogin, type EidLoginContext, type EidLoginEvent, type EidLoginEventKind, type EidLoginIdentity, type EidLoginMode, type EidLoginOptions, type EidLoginRateLimitFn, type EidLoginRateLimits, type EidLoginRateRule, type EidLoginRequest, type EidLoginResponse, type EidLoginStore, type EidLoginSuccess, type EidLoginTx, FlowType, HashAlgorithm, Http, type HttpConfig, HttpErrorInit, Interaction, KYC_INCOMPLETE, LoginStoreFullError, MAX_APP_TRANSACTION_BYTES, MEMORY_LOGIN_STORE_MAX, NATIONAL_ROOT_CA_PEM, NO_ACTIVE_DEVICE, NotificationSession, type OcspCheckerOptions, OnBehalfErrorCode, OrganizationApi, PDF_SIGNATURE_REGISTER_FIELDS, type PdfDigestInput, type PdfDigestSession, type PdfDigestSigner, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type PriorSignature, type QrDeviceLinkTickerOptions, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, RetryableErrorCode, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SessionApi, SessionResult, type SessionTtl, ShareError, type ShareErrorCode, type ShareInfo, type ShareInput, type ShareNotSignedReason, type ShareResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TOKEN_CONFLICT_CODES, TOKEN_ERROR_CODES, TOKEN_ISSUANCE_PENDING, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInfo, type TokenCertInput, type TokenCertItem, type TokenCertPreview, type TokenCertResult, type TokenCertStart, type TokenConflictCode, type TokenErrorCode, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, WAIT_GRACE_MS, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, certificateLevelOf, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
|
1690
|
+
export { APP_ATTESTATION_INVALID, AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, ApiError, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_INTERMEDIATES_PEM, CITIZEN_ISSUING_CA_SKI, CSR_KEY_REUSED, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, DEFAULT_MAX_WAIT_MS, DEFAULT_PDF_TIMEOUT_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, EidImage, type EidLogin, type EidLoginContext, type EidLoginEvent, type EidLoginEventKind, type EidLoginIdentity, type EidLoginMode, type EidLoginOptions, type EidLoginRateLimitFn, type EidLoginRateLimits, type EidLoginRateRule, type EidLoginRequest, type EidLoginResponse, type EidLoginStore, type EidLoginSuccess, type EidLoginTx, FlowType, HashAlgorithm, Http, type HttpConfig, HttpErrorInit, Interaction, KYC_INCOMPLETE, LoginStoreFullError, MAX_APP_TRANSACTION_BYTES, MEMORY_LOGIN_STORE_MAX, NATIONAL_ROOT_CA_PEM, NO_ACTIVE_DEVICE, NotificationSession, type OcspCheckerOptions, OnBehalfErrorCode, OrganizationApi, PDF_SIGNATURE_REGISTER_FIELDS, type PdfDigestInput, type PdfDigestSession, type PdfDigestSigner, type PdfSignatureImage, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type PriorSignature, type QrDeviceLinkTickerOptions, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, RetryableErrorCode, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SessionApi, SessionResult, type SessionTtl, ShareError, type ShareErrorCode, type ShareInfo, type ShareInput, type ShareNotSignedReason, type ShareResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TOKEN_CONFLICT_CODES, TOKEN_ERROR_CODES, TOKEN_ISSUANCE_PENDING, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInfo, type TokenCertInput, type TokenCertItem, type TokenCertPreview, type TokenCertResult, type TokenCertStart, type TokenConflictCode, type TokenErrorCode, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, WAIT_GRACE_MS, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, certificateLevelOf, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|