@gerege-systems/eid-mongolia-sdk 0.16.0 → 0.18.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 +111 -1
- package/bin/convert-assets.mjs +79 -0
- package/bin/eid-convert.worker.js +18 -0
- package/dist/convert.d.ts +113 -0
- package/dist/convert.js +1638 -0
- package/dist/index.cjs +133 -1
- package/dist/index.d.cts +122 -2
- package/dist/index.d.ts +122 -2
- package/dist/index.js +129 -1
- package/dist/pades.cjs +3 -1
- package/dist/pades.js +3 -1
- package/package.json +23 -4
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
CITIZEN_ISSUING_CA_SKI: () => CITIZEN_ISSUING_CA_SKI,
|
|
27
27
|
CertChoiceInvalidError: () => CertChoiceInvalidError,
|
|
28
28
|
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
29
|
+
DEFAULT_SHARE_TIMEOUT_MS: () => DEFAULT_SHARE_TIMEOUT_MS,
|
|
29
30
|
DEFAULT_SIGN_SESSION_TTL_MS: () => DEFAULT_SIGN_SESSION_TTL_MS,
|
|
30
31
|
DeviceLinkError: () => DeviceLinkError,
|
|
31
32
|
EidClient: () => EidClient,
|
|
@@ -42,8 +43,11 @@ __export(index_exports, {
|
|
|
42
43
|
RequestInvalidError: () => RequestInvalidError,
|
|
43
44
|
ResponseTooLargeError: () => ResponseTooLargeError,
|
|
44
45
|
ResponseValidator: () => ResponseValidator,
|
|
46
|
+
SHARE_ERROR_CODES: () => SHARE_ERROR_CODES,
|
|
47
|
+
SHARE_FORM_FIELDS: () => SHARE_FORM_FIELDS,
|
|
45
48
|
SessionApi: () => SessionApi,
|
|
46
49
|
SessionFailedError: () => SessionFailedError,
|
|
50
|
+
ShareError: () => ShareError,
|
|
47
51
|
SignApi: () => SignApi,
|
|
48
52
|
TokenApi: () => TokenApi,
|
|
49
53
|
ValidationError: () => ValidationError,
|
|
@@ -226,6 +230,10 @@ var Http = class {
|
|
|
226
230
|
const text = new TextDecoder().decode(await readLimited(res, MAX_JSON_BYTES, op));
|
|
227
231
|
return { status: res.status, body: text ? JSON.parse(text) : {} };
|
|
228
232
|
}
|
|
233
|
+
/** multipart/form-data POST (`/share`); Content-Type-ийг (boundary) fetch тавина. */
|
|
234
|
+
postForm(path, form, timeoutMs) {
|
|
235
|
+
return this.json("POST", path, form, void 0, timeoutMs);
|
|
236
|
+
}
|
|
229
237
|
get(path, timeoutMs) {
|
|
230
238
|
return this.json("GET", path, void 0, void 0, timeoutMs);
|
|
231
239
|
}
|
|
@@ -344,7 +352,8 @@ var RP_ROUTES = {
|
|
|
344
352
|
tokenCertificateResult: { method: "GET", path: "/token/certificate/{sessionID}" },
|
|
345
353
|
pdfSignatures: { method: "POST", path: "/pdf/signatures" },
|
|
346
354
|
tokenAuthChallenge: { method: "POST", path: "/token/auth/challenge" },
|
|
347
|
-
tokenAuthVerify: { method: "POST", path: "/token/auth/verify" }
|
|
355
|
+
tokenAuthVerify: { method: "POST", path: "/token/auth/verify" },
|
|
356
|
+
share: { method: "POST", path: "/share" }
|
|
348
357
|
};
|
|
349
358
|
var PDF_SIGNATURE_REGISTER_FIELDS = [
|
|
350
359
|
"docID",
|
|
@@ -362,6 +371,7 @@ var PDF_SIGNATURE_REGISTER_FIELDS = [
|
|
|
362
371
|
"onBehalfOf",
|
|
363
372
|
"signerEtsi"
|
|
364
373
|
];
|
|
374
|
+
var SHARE_FORM_FIELDS = ["file", "filename", "to", "subject", "message", "lang"];
|
|
365
375
|
function routePath(route, ...args) {
|
|
366
376
|
let i = 0;
|
|
367
377
|
const out = route.path.replace(/\{[^}]*\}/g, () => {
|
|
@@ -1378,6 +1388,109 @@ function tokenLimitOf(err) {
|
|
|
1378
1388
|
return void 0;
|
|
1379
1389
|
}
|
|
1380
1390
|
|
|
1391
|
+
// src/share.ts
|
|
1392
|
+
var DEFAULT_SHARE_TIMEOUT_MS = 15e4;
|
|
1393
|
+
var SHARE_ERROR_CODES = [
|
|
1394
|
+
"REQUEST_INVALID",
|
|
1395
|
+
"FILE_EMPTY",
|
|
1396
|
+
"RECIPIENT_REQUIRED",
|
|
1397
|
+
"TOO_MANY_RECIPIENTS",
|
|
1398
|
+
"RECIPIENT_INVALID",
|
|
1399
|
+
"RECIPIENT_DUPLICATE",
|
|
1400
|
+
"FILE_TOO_LARGE",
|
|
1401
|
+
"FILE_TYPE_NOT_SUPPORTED",
|
|
1402
|
+
"FILE_NOT_SIGNED",
|
|
1403
|
+
"RATE_LIMITED",
|
|
1404
|
+
"MAIL_FAILED",
|
|
1405
|
+
"SHARE_DISABLED",
|
|
1406
|
+
"MAIL_UNAVAILABLE",
|
|
1407
|
+
"VALIDATOR_UNAVAILABLE",
|
|
1408
|
+
"VALIDATOR_BUSY"
|
|
1409
|
+
];
|
|
1410
|
+
var ShareError = class extends ApiError {
|
|
1411
|
+
/** 422 FILE_NOT_SIGNED: no_signature | invalid | untrusted. */
|
|
1412
|
+
reason;
|
|
1413
|
+
/** 502 MAIL_FAILED: амжилттай илгээсэн тоо. */
|
|
1414
|
+
sent;
|
|
1415
|
+
/** 502 MAIL_FAILED: амжилтгүй тоо. */
|
|
1416
|
+
failed;
|
|
1417
|
+
/**
|
|
1418
|
+
* 502 MAIL_FAILED: `to`-гийн дарааллаар `"sent"` | `"failed"`. Зөвхөн `failed`-ийг дахин илгээ (амжилттайг дахин
|
|
1419
|
+
* бүү илгээ).
|
|
1420
|
+
*/
|
|
1421
|
+
recipients;
|
|
1422
|
+
constructor(status, body, code, init) {
|
|
1423
|
+
super(status, body, code, init);
|
|
1424
|
+
const o = parseObject(body);
|
|
1425
|
+
if (typeof o.reason === "string") this.reason = o.reason;
|
|
1426
|
+
if (typeof o.sent === "number") this.sent = o.sent;
|
|
1427
|
+
if (typeof o.failed === "number") this.failed = o.failed;
|
|
1428
|
+
if (Array.isArray(o.recipients)) this.recipients = o.recipients.map(String);
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
var DISCOVERY_PATH = "/.well-known/eid";
|
|
1432
|
+
function parseObject(text) {
|
|
1433
|
+
try {
|
|
1434
|
+
const v = JSON.parse(text);
|
|
1435
|
+
return v && typeof v === "object" ? v : {};
|
|
1436
|
+
} catch {
|
|
1437
|
+
return {};
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
async function shareFile(http, input) {
|
|
1441
|
+
const to = typeof input.to === "string" ? [input.to] : [...input.to];
|
|
1442
|
+
const blob = input.file instanceof Blob ? input.file : new Blob([new Uint8Array(input.file)], { type: "application/pdf" });
|
|
1443
|
+
const filename = input.filename ?? input.file.name ?? "document.pdf";
|
|
1444
|
+
const form = new FormData();
|
|
1445
|
+
for (const a of to) form.append("to", a);
|
|
1446
|
+
if (input.subject !== void 0) form.append("subject", input.subject);
|
|
1447
|
+
if (input.message !== void 0) form.append("message", input.message);
|
|
1448
|
+
if (input.lang !== void 0) form.append("lang", input.lang);
|
|
1449
|
+
if (input.filename !== void 0) form.append("filename", input.filename);
|
|
1450
|
+
form.append("file", blob.type ? blob : new Blob([blob], { type: "application/pdf" }), filename || "document.pdf");
|
|
1451
|
+
let raw;
|
|
1452
|
+
try {
|
|
1453
|
+
raw = await http.postForm(RP_ROUTES.share.path, form, input.timeoutMs ?? DEFAULT_SHARE_TIMEOUT_MS);
|
|
1454
|
+
} catch (e) {
|
|
1455
|
+
if (e instanceof ApiError && !(e instanceof ShareError)) {
|
|
1456
|
+
throw new ShareError(e.status, e.body, e.code, { headers: e.headers, retryAfterMs: e.retryAfterMs });
|
|
1457
|
+
}
|
|
1458
|
+
throw e;
|
|
1459
|
+
}
|
|
1460
|
+
const o = raw && typeof raw === "object" ? raw : {};
|
|
1461
|
+
return {
|
|
1462
|
+
sent: Number(o.sent ?? 0),
|
|
1463
|
+
sha256: String(o.sha256 ?? ""),
|
|
1464
|
+
signatures: Number(o.signatures ?? 0),
|
|
1465
|
+
...typeof o.docID === "string" && o.docID ? { docID: o.docID } : {},
|
|
1466
|
+
raw
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
async function shareInfo(http) {
|
|
1470
|
+
const d = await http.get(DISCOVERY_PATH);
|
|
1471
|
+
const s = d.share && typeof d.share === "object" ? d.share : {};
|
|
1472
|
+
const q = s.quota && typeof s.quota === "object" ? s.quota : {};
|
|
1473
|
+
return {
|
|
1474
|
+
enabled: s.enabled === true,
|
|
1475
|
+
endpoint: String(s.endpoint ?? ""),
|
|
1476
|
+
formats: Array.isArray(s.formats) ? s.formats : [],
|
|
1477
|
+
languages: Array.isArray(s.languages) ? s.languages.map(String) : [],
|
|
1478
|
+
maxFileBytes: Number(s.maxFileBytes ?? 0),
|
|
1479
|
+
maxFilenameChars: Number(s.maxFilenameChars ?? 0),
|
|
1480
|
+
maxMessageChars: Number(s.maxMessageChars ?? 0),
|
|
1481
|
+
maxRecipients: Number(s.maxRecipients ?? 0),
|
|
1482
|
+
maxSubjectChars: Number(s.maxSubjectChars ?? 0),
|
|
1483
|
+
permission: String(s.permission ?? ""),
|
|
1484
|
+
quota: {
|
|
1485
|
+
perRPHour: Number(q.perRPHour ?? 0),
|
|
1486
|
+
perRPDay: Number(q.perRPDay ?? 0),
|
|
1487
|
+
perRecipientDay: Number(q.perRecipientDay ?? 0)
|
|
1488
|
+
},
|
|
1489
|
+
requiresValidSignature: s.requiresValidSignature === true,
|
|
1490
|
+
raw: d.share
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1381
1494
|
// src/validator.ts
|
|
1382
1495
|
var import_node_crypto4 = require("crypto");
|
|
1383
1496
|
var CITIZEN_ISSUING_CA_SKI = "b8a37f2c64ad677912db7d9e34f246358a2fb909";
|
|
@@ -1983,6 +2096,7 @@ var EidClient = class {
|
|
|
1983
2096
|
validator;
|
|
1984
2097
|
/** `credentials.rpName` — иргэний утсанд харагдах RP нэр. */
|
|
1985
2098
|
rpName;
|
|
2099
|
+
http;
|
|
1986
2100
|
constructor(cfg) {
|
|
1987
2101
|
if (!cfg.credentials?.apiSecret) throw new Error("EidClient: credentials.apiSecret \u0448\u0430\u0430\u0440\u0434\u043B\u0430\u0433\u0430\u0442\u0430\u0439");
|
|
1988
2102
|
const base = resolveBaseUrl(cfg.baseUrl);
|
|
@@ -2003,6 +2117,7 @@ var EidClient = class {
|
|
|
2003
2117
|
this.session = new SessionApi(http);
|
|
2004
2118
|
this.validator = new ResponseValidator(cfg.trust ?? {});
|
|
2005
2119
|
this.rpName = cfg.credentials.rpName;
|
|
2120
|
+
this.http = http;
|
|
2006
2121
|
}
|
|
2007
2122
|
/** {@link SignApi.pdfDigest} — клиент талын PAdES-ийн DTBS-д гарын үсгийн session (PDF CA руу очихгүй). */
|
|
2008
2123
|
signPdfDigest(input) {
|
|
@@ -2012,6 +2127,19 @@ var EidClient = class {
|
|
|
2012
2127
|
registerSignature(input) {
|
|
2013
2128
|
return this.sign.registerSignature(input);
|
|
2014
2129
|
}
|
|
2130
|
+
/**
|
|
2131
|
+
* `POST /share` (SIGN эрх) — гарын үсэгтэй файлыг (PDF, eID-ийн хүчинтэй гарын үсэгтэй) 1–5 хүлээн авагч руу
|
|
2132
|
+
* имэйлээр, хавсралтаар илгээнэ; CA файлыг хадгалахгүй. Алдаа: `ShareError` (`code`, 422-д `reason`, 502-д
|
|
2133
|
+
* `sent`/`failed`/`recipients`), 401 AuthenticationError, 403 ForbiddenError. CA-ийн туг унтраалттай бол 503
|
|
2134
|
+
* SHARE_DISABLED — {@link shareInfo}-оор урьдчилан шалга.
|
|
2135
|
+
*/
|
|
2136
|
+
share(input) {
|
|
2137
|
+
return shareFile(this.http, input);
|
|
2138
|
+
}
|
|
2139
|
+
/** Discovery (`/.well-known/eid`)-ийн `share` блок: `enabled`, формат, хязгаар, квот. */
|
|
2140
|
+
shareInfo() {
|
|
2141
|
+
return shareInfo(this.http);
|
|
2142
|
+
}
|
|
2015
2143
|
};
|
|
2016
2144
|
|
|
2017
2145
|
// src/ocsp.ts
|
|
@@ -3266,6 +3394,7 @@ function createEidLogin(opts) {
|
|
|
3266
3394
|
CITIZEN_ISSUING_CA_SKI,
|
|
3267
3395
|
CertChoiceInvalidError,
|
|
3268
3396
|
DEFAULT_BASE_URL,
|
|
3397
|
+
DEFAULT_SHARE_TIMEOUT_MS,
|
|
3269
3398
|
DEFAULT_SIGN_SESSION_TTL_MS,
|
|
3270
3399
|
DeviceLinkError,
|
|
3271
3400
|
EidClient,
|
|
@@ -3282,8 +3411,11 @@ function createEidLogin(opts) {
|
|
|
3282
3411
|
RequestInvalidError,
|
|
3283
3412
|
ResponseTooLargeError,
|
|
3284
3413
|
ResponseValidator,
|
|
3414
|
+
SHARE_ERROR_CODES,
|
|
3415
|
+
SHARE_FORM_FIELDS,
|
|
3285
3416
|
SessionApi,
|
|
3286
3417
|
SessionFailedError,
|
|
3418
|
+
ShareError,
|
|
3287
3419
|
SignApi,
|
|
3288
3420
|
TokenApi,
|
|
3289
3421
|
ValidationError,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
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, P as PersonBlock, b as RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-DFnRVCfN.cjs';
|
|
2
2
|
export { c as DEFAULT_SIGN_SESSION_TTL_MS, E as EndResult, d as NavigatorLike, O as OrgResult, e as Representation, f as SessionState, g as SignContext, h as SignatureAlgorithmParameters, i as SignatureProtocol, T as TokenCertSessionBlock, j as TokenCertStatus, k as isMobileUserAgent, p as parseExpiresAt, s as sessionExpiry, l as startExpiry } from './browser-DFnRVCfN.cjs';
|
|
3
|
+
import { A as ApiError, H as HttpErrorInit } from './errors-pK1L0s4N.cjs';
|
|
4
|
+
export { a as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError, b as NoSigningCertificateError, O as ON_BEHALF_ERROR_CODES, c as OnBehalfErrorCode, R as RETRYABLE_ERROR_CODES, d as RequestInvalidError, e as ResponseTooLargeError, f as RetryableErrorCode, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-pK1L0s4N.cjs';
|
|
3
5
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
4
|
-
export { A as ApiError, a as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, H as HttpErrorInit, N as NetworkError, b as NoSigningCertificateError, O as ON_BEHALF_ERROR_CODES, c as OnBehalfErrorCode, R as RETRYABLE_ERROR_CODES, d as RequestInvalidError, e as ResponseTooLargeError, f as RetryableErrorCode, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-pK1L0s4N.cjs';
|
|
5
6
|
|
|
6
7
|
interface HttpConfig {
|
|
7
8
|
/** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
|
|
@@ -30,6 +31,8 @@ declare class Http {
|
|
|
30
31
|
status: number;
|
|
31
32
|
body: unknown;
|
|
32
33
|
}>;
|
|
34
|
+
/** multipart/form-data POST (`/share`); Content-Type-ийг (boundary) fetch тавина. */
|
|
35
|
+
postForm(path: string, form: FormData, timeoutMs?: number): Promise<unknown>;
|
|
33
36
|
get(path: string, timeoutMs?: number): Promise<unknown>;
|
|
34
37
|
private json;
|
|
35
38
|
private send;
|
|
@@ -389,6 +392,18 @@ interface PersonCertificate {
|
|
|
389
392
|
notBefore: string;
|
|
390
393
|
notAfter: string;
|
|
391
394
|
issuerDn: string;
|
|
395
|
+
/** Олгосон мөч (RFC 3339). Хуучин CA-д байхгүй. */
|
|
396
|
+
issuedAt?: string;
|
|
397
|
+
/**
|
|
398
|
+
* Цуцалсан мөч (RFC 3339) — REVOKED-д. Сунгалт/дахин бүртгэлээр солигдсон (status SUSPENDED,
|
|
399
|
+
* `revocationReason: "superseded"`) мөрд ихэвчлэн байхгүй.
|
|
400
|
+
*/
|
|
401
|
+
revokedAt?: string;
|
|
402
|
+
/**
|
|
403
|
+
* RFC 5280 CRLReason-ийн нэр: keyCompromise, cACompromise, affiliationChanged, superseded, cessationOfOperation,
|
|
404
|
+
* certificateHold, privilegeWithdrawn г.м. `status` өөрчлөгдөхгүй — солигдсоныг (SUSPENDED) `superseded`-ээр ялга.
|
|
405
|
+
*/
|
|
406
|
+
revocationReason?: string;
|
|
392
407
|
/** base64 DER (нийтийн артефакт). */
|
|
393
408
|
certValue?: string;
|
|
394
409
|
/** TOKEN мөрөнд токенд холбогдсон байгууллага; хувийн токенд алга. */
|
|
@@ -627,6 +642,95 @@ declare function tokenAuthDigest(rpUUID: string, challengeB64: string): Buffer;
|
|
|
627
642
|
*/
|
|
628
643
|
declare function tokenLimitOf(err: unknown): TokenLimit | undefined;
|
|
629
644
|
|
|
645
|
+
/** Хүсэлтийн хугацаа: CA бүх хүлээн авагчид 120 с-д илгээнэ, nginx 150 с. */
|
|
646
|
+
declare const DEFAULT_SHARE_TIMEOUT_MS = 150000;
|
|
647
|
+
/** `client.share()`-ийн оролт. Хязгаар (CA main 0329ef95): discovery-ийн `share` блок ({@link ShareInfo}). */
|
|
648
|
+
interface ShareInput {
|
|
649
|
+
/** Гарын үсэгтэй файл (одоогоор зөвхөн PDF), ≤ 3 080 192 байт. `File` бол нэр нь `filename`-ийн анхдагч. */
|
|
650
|
+
file: Blob | Uint8Array | ArrayBuffer;
|
|
651
|
+
/**
|
|
652
|
+
* Хавсралтын нэр (≤ 120 тэмдэгт). Өргөтгөл нь форматтай таарах ёстой (`.pdf`) — эс бөгөөс 415. Анхдагч: `File`-ийн
|
|
653
|
+
* нэр, байхгүй бол `document.pdf`.
|
|
654
|
+
*/
|
|
655
|
+
filename?: string;
|
|
656
|
+
/** Хүлээн авагч, 1–5 (хүн бүрт тусдаа имэйл). Давхардвал 400 RECIPIENT_DUPLICATE. */
|
|
657
|
+
to: string | readonly string[];
|
|
658
|
+
/** Имэйлийн гарчиг (≤ 150); CA үргэлж `‹RP нэр›: …` угтвар тавина. */
|
|
659
|
+
subject?: string;
|
|
660
|
+
/** Илгээгчийн тэмдэглэл (≤ 1000). */
|
|
661
|
+
message?: string;
|
|
662
|
+
/** Имэйлийн хэл: `mn` (анхдагч) | `en`. */
|
|
663
|
+
lang?: "mn" | "en";
|
|
664
|
+
/** Хүсэлтийн хугацаа (мс). Анхдагч {@link DEFAULT_SHARE_TIMEOUT_MS}. */
|
|
665
|
+
timeoutMs?: number;
|
|
666
|
+
}
|
|
667
|
+
/** 200 хариу. */
|
|
668
|
+
interface ShareResult {
|
|
669
|
+
/** Илгээсэн имэйлийн тоо (= хүлээн авагчийн тоо). */
|
|
670
|
+
sent: number;
|
|
671
|
+
/** Файлын SHA-256 (hex). */
|
|
672
|
+
sha256: string;
|
|
673
|
+
/** Хүчинтэй eID гарын үсгийн тоо. */
|
|
674
|
+
signatures: number;
|
|
675
|
+
/** CA-д (`/pdf/signatures`) бүртгэлтэй бол баримтын ID — имэйлд verify холбоос орно. */
|
|
676
|
+
docID?: string;
|
|
677
|
+
raw: unknown;
|
|
678
|
+
}
|
|
679
|
+
/** `share()`-ийн CA алдааны кодууд ({@link ShareError.code}). */
|
|
680
|
+
type ShareErrorCode = "REQUEST_INVALID" | "FILE_EMPTY" | "RECIPIENT_REQUIRED" | "TOO_MANY_RECIPIENTS" | "RECIPIENT_INVALID" | "RECIPIENT_DUPLICATE" | "FILE_TOO_LARGE" | "FILE_TYPE_NOT_SUPPORTED" | "FILE_NOT_SIGNED" | "RATE_LIMITED" | "MAIL_FAILED" | "SHARE_DISABLED" | "MAIL_UNAVAILABLE" | "VALIDATOR_UNAVAILABLE" | "VALIDATOR_BUSY";
|
|
681
|
+
/** {@link ShareErrorCode}-ийн бүх утга. */
|
|
682
|
+
declare const SHARE_ERROR_CODES: readonly ShareErrorCode[];
|
|
683
|
+
/** 422 FILE_NOT_SIGNED-ийн шалтгаан. */
|
|
684
|
+
type ShareNotSignedReason = "no_signature" | "invalid" | "untrusted";
|
|
685
|
+
/**
|
|
686
|
+
* `share()`-ийн CA алдаа (401/403-аас бусад 4xx/5xx; 401 → AuthenticationError, 403 → ForbiddenError). `code`
|
|
687
|
+
* ({@link ShareErrorCode}): 400 талбарын алдаа, 413 FILE_TOO_LARGE, 415 FILE_TYPE_NOT_SUPPORTED, 422 FILE_NOT_SIGNED
|
|
688
|
+
* (+`reason`), 429 RATE_LIMITED (+`retryAfterMs`), 502 MAIL_FAILED (+`sent`, `failed`, `recipients`), 503
|
|
689
|
+
* SHARE_DISABLED / MAIL_UNAVAILABLE / VALIDATOR_UNAVAILABLE / VALIDATOR_BUSY. JSON биш хариу (proxy) бол `code`
|
|
690
|
+
* undefined.
|
|
691
|
+
*/
|
|
692
|
+
declare class ShareError extends ApiError {
|
|
693
|
+
/** 422 FILE_NOT_SIGNED: no_signature | invalid | untrusted. */
|
|
694
|
+
readonly reason?: ShareNotSignedReason | string;
|
|
695
|
+
/** 502 MAIL_FAILED: амжилттай илгээсэн тоо. */
|
|
696
|
+
readonly sent?: number;
|
|
697
|
+
/** 502 MAIL_FAILED: амжилтгүй тоо. */
|
|
698
|
+
readonly failed?: number;
|
|
699
|
+
/**
|
|
700
|
+
* 502 MAIL_FAILED: `to`-гийн дарааллаар `"sent"` | `"failed"`. Зөвхөн `failed`-ийг дахин илгээ (амжилттайг дахин
|
|
701
|
+
* бүү илгээ).
|
|
702
|
+
*/
|
|
703
|
+
readonly recipients?: readonly string[];
|
|
704
|
+
constructor(status: number, body: string, code?: string, init?: HttpErrorInit);
|
|
705
|
+
}
|
|
706
|
+
/** Discovery (`/.well-known/eid`)-ийн `share` блок. */
|
|
707
|
+
interface ShareInfo {
|
|
708
|
+
/** CA-ийн туг. false бол `share()` → 503 SHARE_DISABLED. */
|
|
709
|
+
enabled: boolean;
|
|
710
|
+
endpoint: string;
|
|
711
|
+
formats: {
|
|
712
|
+
name: string;
|
|
713
|
+
extension: string;
|
|
714
|
+
mime: string;
|
|
715
|
+
}[];
|
|
716
|
+
languages: string[];
|
|
717
|
+
maxFileBytes: number;
|
|
718
|
+
maxFilenameChars: number;
|
|
719
|
+
maxMessageChars: number;
|
|
720
|
+
maxRecipients: number;
|
|
721
|
+
maxSubjectChars: number;
|
|
722
|
+
/** Шаардлагатай RP эрх (SIGN). */
|
|
723
|
+
permission: string;
|
|
724
|
+
/** RP тутам цаг/өдөр (хүсэлт), хүлээн авагч тутам өдөр (имэйл, RP тус бүрд). */
|
|
725
|
+
quota: {
|
|
726
|
+
perRPHour: number;
|
|
727
|
+
perRPDay: number;
|
|
728
|
+
perRecipientDay: number;
|
|
729
|
+
};
|
|
730
|
+
requiresValidSignature: boolean;
|
|
731
|
+
raw: unknown;
|
|
732
|
+
}
|
|
733
|
+
|
|
630
734
|
/** Задалсан subject. Cert-д байхгүй талбар — undefined. Давхардсан OID-ийн эхнийх нь. */
|
|
631
735
|
interface CertSubject {
|
|
632
736
|
/** 2.5.4.42 GIVENNAME. */
|
|
@@ -943,11 +1047,21 @@ declare class EidClient {
|
|
|
943
1047
|
readonly validator: ResponseValidator;
|
|
944
1048
|
/** `credentials.rpName` — иргэний утсанд харагдах RP нэр. */
|
|
945
1049
|
readonly rpName: string;
|
|
1050
|
+
private readonly http;
|
|
946
1051
|
constructor(cfg: ClientConfig);
|
|
947
1052
|
/** {@link SignApi.pdfDigest} — клиент талын PAdES-ийн DTBS-д гарын үсгийн session (PDF CA руу очихгүй). */
|
|
948
1053
|
signPdfDigest(input: PdfDigestInput): Promise<PdfDigestSession>;
|
|
949
1054
|
/** {@link SignApi.registerSignature} — `pades.complete()`-ийн CMS-ийг CA-д бүртгэнэ (`POST /pdf/signatures`). */
|
|
950
1055
|
registerSignature(input: RegisterSignatureInput): Promise<RegisterSignatureResult>;
|
|
1056
|
+
/**
|
|
1057
|
+
* `POST /share` (SIGN эрх) — гарын үсэгтэй файлыг (PDF, eID-ийн хүчинтэй гарын үсэгтэй) 1–5 хүлээн авагч руу
|
|
1058
|
+
* имэйлээр, хавсралтаар илгээнэ; CA файлыг хадгалахгүй. Алдаа: `ShareError` (`code`, 422-д `reason`, 502-д
|
|
1059
|
+
* `sent`/`failed`/`recipients`), 401 AuthenticationError, 403 ForbiddenError. CA-ийн туг унтраалттай бол 503
|
|
1060
|
+
* SHARE_DISABLED — {@link shareInfo}-оор урьдчилан шалга.
|
|
1061
|
+
*/
|
|
1062
|
+
share(input: ShareInput): Promise<ShareResult>;
|
|
1063
|
+
/** Discovery (`/.well-known/eid`)-ийн `share` блок: `enabled`, формат, хязгаар, квот. */
|
|
1064
|
+
shareInfo(): Promise<ShareInfo>;
|
|
951
1065
|
}
|
|
952
1066
|
|
|
953
1067
|
/**
|
|
@@ -956,6 +1070,12 @@ declare class EidClient {
|
|
|
956
1070
|
* `endpoints.pdf.signatures` тайлбартай гэрээний тест тулгана.
|
|
957
1071
|
*/
|
|
958
1072
|
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi"];
|
|
1073
|
+
/**
|
|
1074
|
+
* `POST /share`-ийн multipart талбарууд — CA `server/internal/httpapi/handlers_share.go` `parseShareRequest` (CA main
|
|
1075
|
+
* 0329ef95, !371). CA үл мэдэгдэх талбарыг 400 REQUEST_INVALID-аар татгалздаг. Live discovery-ийн `endpoints.share`
|
|
1076
|
+
* тайлбартай гэрээний тест тулгана.
|
|
1077
|
+
*/
|
|
1078
|
+
declare const SHARE_FORM_FIELDS: readonly ["file", "filename", "to", "subject", "message", "lang"];
|
|
959
1079
|
|
|
960
1080
|
interface OcspCheckerOptions {
|
|
961
1081
|
/** fetch (тест/proxy). Анхдагч globalThis.fetch. Redirect дагахгүй ("manual"). */
|
|
@@ -1311,4 +1431,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1311
1431
|
*/
|
|
1312
1432
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1313
1433
|
|
|
1314
|
-
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_ISSUING_CA_SKI, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, 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, Interaction, NotificationSession, type OcspCheckerOptions, 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, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SessionApi, SessionResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
|
1434
|
+
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, ApiError, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_ISSUING_CA_SKI, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, 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, NotificationSession, type OcspCheckerOptions, 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, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SessionApi, SessionResult, ShareError, type ShareErrorCode, type ShareInfo, type ShareInput, type ShareNotSignedReason, type ShareResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, 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,7 +1,8 @@
|
|
|
1
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, P as PersonBlock, b as RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-BPhROZkH.js';
|
|
2
2
|
export { c as DEFAULT_SIGN_SESSION_TTL_MS, E as EndResult, d as NavigatorLike, O as OrgResult, e as Representation, f as SessionState, g as SignContext, h as SignatureAlgorithmParameters, i as SignatureProtocol, T as TokenCertSessionBlock, j as TokenCertStatus, k as isMobileUserAgent, p as parseExpiresAt, s as sessionExpiry, l as startExpiry } from './browser-BPhROZkH.js';
|
|
3
|
+
import { A as ApiError, H as HttpErrorInit } from './errors-pK1L0s4N.js';
|
|
4
|
+
export { a as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError, b as NoSigningCertificateError, O as ON_BEHALF_ERROR_CODES, c as OnBehalfErrorCode, R as RETRYABLE_ERROR_CODES, d as RequestInvalidError, e as ResponseTooLargeError, f as RetryableErrorCode, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-pK1L0s4N.js';
|
|
3
5
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
4
|
-
export { A as ApiError, a as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, H as HttpErrorInit, N as NetworkError, b as NoSigningCertificateError, O as ON_BEHALF_ERROR_CODES, c as OnBehalfErrorCode, R as RETRYABLE_ERROR_CODES, d as RequestInvalidError, e as ResponseTooLargeError, f as RetryableErrorCode, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-pK1L0s4N.js';
|
|
5
6
|
|
|
6
7
|
interface HttpConfig {
|
|
7
8
|
/** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
|
|
@@ -30,6 +31,8 @@ declare class Http {
|
|
|
30
31
|
status: number;
|
|
31
32
|
body: unknown;
|
|
32
33
|
}>;
|
|
34
|
+
/** multipart/form-data POST (`/share`); Content-Type-ийг (boundary) fetch тавина. */
|
|
35
|
+
postForm(path: string, form: FormData, timeoutMs?: number): Promise<unknown>;
|
|
33
36
|
get(path: string, timeoutMs?: number): Promise<unknown>;
|
|
34
37
|
private json;
|
|
35
38
|
private send;
|
|
@@ -389,6 +392,18 @@ interface PersonCertificate {
|
|
|
389
392
|
notBefore: string;
|
|
390
393
|
notAfter: string;
|
|
391
394
|
issuerDn: string;
|
|
395
|
+
/** Олгосон мөч (RFC 3339). Хуучин CA-д байхгүй. */
|
|
396
|
+
issuedAt?: string;
|
|
397
|
+
/**
|
|
398
|
+
* Цуцалсан мөч (RFC 3339) — REVOKED-д. Сунгалт/дахин бүртгэлээр солигдсон (status SUSPENDED,
|
|
399
|
+
* `revocationReason: "superseded"`) мөрд ихэвчлэн байхгүй.
|
|
400
|
+
*/
|
|
401
|
+
revokedAt?: string;
|
|
402
|
+
/**
|
|
403
|
+
* RFC 5280 CRLReason-ийн нэр: keyCompromise, cACompromise, affiliationChanged, superseded, cessationOfOperation,
|
|
404
|
+
* certificateHold, privilegeWithdrawn г.м. `status` өөрчлөгдөхгүй — солигдсоныг (SUSPENDED) `superseded`-ээр ялга.
|
|
405
|
+
*/
|
|
406
|
+
revocationReason?: string;
|
|
392
407
|
/** base64 DER (нийтийн артефакт). */
|
|
393
408
|
certValue?: string;
|
|
394
409
|
/** TOKEN мөрөнд токенд холбогдсон байгууллага; хувийн токенд алга. */
|
|
@@ -627,6 +642,95 @@ declare function tokenAuthDigest(rpUUID: string, challengeB64: string): Buffer;
|
|
|
627
642
|
*/
|
|
628
643
|
declare function tokenLimitOf(err: unknown): TokenLimit | undefined;
|
|
629
644
|
|
|
645
|
+
/** Хүсэлтийн хугацаа: CA бүх хүлээн авагчид 120 с-д илгээнэ, nginx 150 с. */
|
|
646
|
+
declare const DEFAULT_SHARE_TIMEOUT_MS = 150000;
|
|
647
|
+
/** `client.share()`-ийн оролт. Хязгаар (CA main 0329ef95): discovery-ийн `share` блок ({@link ShareInfo}). */
|
|
648
|
+
interface ShareInput {
|
|
649
|
+
/** Гарын үсэгтэй файл (одоогоор зөвхөн PDF), ≤ 3 080 192 байт. `File` бол нэр нь `filename`-ийн анхдагч. */
|
|
650
|
+
file: Blob | Uint8Array | ArrayBuffer;
|
|
651
|
+
/**
|
|
652
|
+
* Хавсралтын нэр (≤ 120 тэмдэгт). Өргөтгөл нь форматтай таарах ёстой (`.pdf`) — эс бөгөөс 415. Анхдагч: `File`-ийн
|
|
653
|
+
* нэр, байхгүй бол `document.pdf`.
|
|
654
|
+
*/
|
|
655
|
+
filename?: string;
|
|
656
|
+
/** Хүлээн авагч, 1–5 (хүн бүрт тусдаа имэйл). Давхардвал 400 RECIPIENT_DUPLICATE. */
|
|
657
|
+
to: string | readonly string[];
|
|
658
|
+
/** Имэйлийн гарчиг (≤ 150); CA үргэлж `‹RP нэр›: …` угтвар тавина. */
|
|
659
|
+
subject?: string;
|
|
660
|
+
/** Илгээгчийн тэмдэглэл (≤ 1000). */
|
|
661
|
+
message?: string;
|
|
662
|
+
/** Имэйлийн хэл: `mn` (анхдагч) | `en`. */
|
|
663
|
+
lang?: "mn" | "en";
|
|
664
|
+
/** Хүсэлтийн хугацаа (мс). Анхдагч {@link DEFAULT_SHARE_TIMEOUT_MS}. */
|
|
665
|
+
timeoutMs?: number;
|
|
666
|
+
}
|
|
667
|
+
/** 200 хариу. */
|
|
668
|
+
interface ShareResult {
|
|
669
|
+
/** Илгээсэн имэйлийн тоо (= хүлээн авагчийн тоо). */
|
|
670
|
+
sent: number;
|
|
671
|
+
/** Файлын SHA-256 (hex). */
|
|
672
|
+
sha256: string;
|
|
673
|
+
/** Хүчинтэй eID гарын үсгийн тоо. */
|
|
674
|
+
signatures: number;
|
|
675
|
+
/** CA-д (`/pdf/signatures`) бүртгэлтэй бол баримтын ID — имэйлд verify холбоос орно. */
|
|
676
|
+
docID?: string;
|
|
677
|
+
raw: unknown;
|
|
678
|
+
}
|
|
679
|
+
/** `share()`-ийн CA алдааны кодууд ({@link ShareError.code}). */
|
|
680
|
+
type ShareErrorCode = "REQUEST_INVALID" | "FILE_EMPTY" | "RECIPIENT_REQUIRED" | "TOO_MANY_RECIPIENTS" | "RECIPIENT_INVALID" | "RECIPIENT_DUPLICATE" | "FILE_TOO_LARGE" | "FILE_TYPE_NOT_SUPPORTED" | "FILE_NOT_SIGNED" | "RATE_LIMITED" | "MAIL_FAILED" | "SHARE_DISABLED" | "MAIL_UNAVAILABLE" | "VALIDATOR_UNAVAILABLE" | "VALIDATOR_BUSY";
|
|
681
|
+
/** {@link ShareErrorCode}-ийн бүх утга. */
|
|
682
|
+
declare const SHARE_ERROR_CODES: readonly ShareErrorCode[];
|
|
683
|
+
/** 422 FILE_NOT_SIGNED-ийн шалтгаан. */
|
|
684
|
+
type ShareNotSignedReason = "no_signature" | "invalid" | "untrusted";
|
|
685
|
+
/**
|
|
686
|
+
* `share()`-ийн CA алдаа (401/403-аас бусад 4xx/5xx; 401 → AuthenticationError, 403 → ForbiddenError). `code`
|
|
687
|
+
* ({@link ShareErrorCode}): 400 талбарын алдаа, 413 FILE_TOO_LARGE, 415 FILE_TYPE_NOT_SUPPORTED, 422 FILE_NOT_SIGNED
|
|
688
|
+
* (+`reason`), 429 RATE_LIMITED (+`retryAfterMs`), 502 MAIL_FAILED (+`sent`, `failed`, `recipients`), 503
|
|
689
|
+
* SHARE_DISABLED / MAIL_UNAVAILABLE / VALIDATOR_UNAVAILABLE / VALIDATOR_BUSY. JSON биш хариу (proxy) бол `code`
|
|
690
|
+
* undefined.
|
|
691
|
+
*/
|
|
692
|
+
declare class ShareError extends ApiError {
|
|
693
|
+
/** 422 FILE_NOT_SIGNED: no_signature | invalid | untrusted. */
|
|
694
|
+
readonly reason?: ShareNotSignedReason | string;
|
|
695
|
+
/** 502 MAIL_FAILED: амжилттай илгээсэн тоо. */
|
|
696
|
+
readonly sent?: number;
|
|
697
|
+
/** 502 MAIL_FAILED: амжилтгүй тоо. */
|
|
698
|
+
readonly failed?: number;
|
|
699
|
+
/**
|
|
700
|
+
* 502 MAIL_FAILED: `to`-гийн дарааллаар `"sent"` | `"failed"`. Зөвхөн `failed`-ийг дахин илгээ (амжилттайг дахин
|
|
701
|
+
* бүү илгээ).
|
|
702
|
+
*/
|
|
703
|
+
readonly recipients?: readonly string[];
|
|
704
|
+
constructor(status: number, body: string, code?: string, init?: HttpErrorInit);
|
|
705
|
+
}
|
|
706
|
+
/** Discovery (`/.well-known/eid`)-ийн `share` блок. */
|
|
707
|
+
interface ShareInfo {
|
|
708
|
+
/** CA-ийн туг. false бол `share()` → 503 SHARE_DISABLED. */
|
|
709
|
+
enabled: boolean;
|
|
710
|
+
endpoint: string;
|
|
711
|
+
formats: {
|
|
712
|
+
name: string;
|
|
713
|
+
extension: string;
|
|
714
|
+
mime: string;
|
|
715
|
+
}[];
|
|
716
|
+
languages: string[];
|
|
717
|
+
maxFileBytes: number;
|
|
718
|
+
maxFilenameChars: number;
|
|
719
|
+
maxMessageChars: number;
|
|
720
|
+
maxRecipients: number;
|
|
721
|
+
maxSubjectChars: number;
|
|
722
|
+
/** Шаардлагатай RP эрх (SIGN). */
|
|
723
|
+
permission: string;
|
|
724
|
+
/** RP тутам цаг/өдөр (хүсэлт), хүлээн авагч тутам өдөр (имэйл, RP тус бүрд). */
|
|
725
|
+
quota: {
|
|
726
|
+
perRPHour: number;
|
|
727
|
+
perRPDay: number;
|
|
728
|
+
perRecipientDay: number;
|
|
729
|
+
};
|
|
730
|
+
requiresValidSignature: boolean;
|
|
731
|
+
raw: unknown;
|
|
732
|
+
}
|
|
733
|
+
|
|
630
734
|
/** Задалсан subject. Cert-д байхгүй талбар — undefined. Давхардсан OID-ийн эхнийх нь. */
|
|
631
735
|
interface CertSubject {
|
|
632
736
|
/** 2.5.4.42 GIVENNAME. */
|
|
@@ -943,11 +1047,21 @@ declare class EidClient {
|
|
|
943
1047
|
readonly validator: ResponseValidator;
|
|
944
1048
|
/** `credentials.rpName` — иргэний утсанд харагдах RP нэр. */
|
|
945
1049
|
readonly rpName: string;
|
|
1050
|
+
private readonly http;
|
|
946
1051
|
constructor(cfg: ClientConfig);
|
|
947
1052
|
/** {@link SignApi.pdfDigest} — клиент талын PAdES-ийн DTBS-д гарын үсгийн session (PDF CA руу очихгүй). */
|
|
948
1053
|
signPdfDigest(input: PdfDigestInput): Promise<PdfDigestSession>;
|
|
949
1054
|
/** {@link SignApi.registerSignature} — `pades.complete()`-ийн CMS-ийг CA-д бүртгэнэ (`POST /pdf/signatures`). */
|
|
950
1055
|
registerSignature(input: RegisterSignatureInput): Promise<RegisterSignatureResult>;
|
|
1056
|
+
/**
|
|
1057
|
+
* `POST /share` (SIGN эрх) — гарын үсэгтэй файлыг (PDF, eID-ийн хүчинтэй гарын үсэгтэй) 1–5 хүлээн авагч руу
|
|
1058
|
+
* имэйлээр, хавсралтаар илгээнэ; CA файлыг хадгалахгүй. Алдаа: `ShareError` (`code`, 422-д `reason`, 502-д
|
|
1059
|
+
* `sent`/`failed`/`recipients`), 401 AuthenticationError, 403 ForbiddenError. CA-ийн туг унтраалттай бол 503
|
|
1060
|
+
* SHARE_DISABLED — {@link shareInfo}-оор урьдчилан шалга.
|
|
1061
|
+
*/
|
|
1062
|
+
share(input: ShareInput): Promise<ShareResult>;
|
|
1063
|
+
/** Discovery (`/.well-known/eid`)-ийн `share` блок: `enabled`, формат, хязгаар, квот. */
|
|
1064
|
+
shareInfo(): Promise<ShareInfo>;
|
|
951
1065
|
}
|
|
952
1066
|
|
|
953
1067
|
/**
|
|
@@ -956,6 +1070,12 @@ declare class EidClient {
|
|
|
956
1070
|
* `endpoints.pdf.signatures` тайлбартай гэрээний тест тулгана.
|
|
957
1071
|
*/
|
|
958
1072
|
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi"];
|
|
1073
|
+
/**
|
|
1074
|
+
* `POST /share`-ийн multipart талбарууд — CA `server/internal/httpapi/handlers_share.go` `parseShareRequest` (CA main
|
|
1075
|
+
* 0329ef95, !371). CA үл мэдэгдэх талбарыг 400 REQUEST_INVALID-аар татгалздаг. Live discovery-ийн `endpoints.share`
|
|
1076
|
+
* тайлбартай гэрээний тест тулгана.
|
|
1077
|
+
*/
|
|
1078
|
+
declare const SHARE_FORM_FIELDS: readonly ["file", "filename", "to", "subject", "message", "lang"];
|
|
959
1079
|
|
|
960
1080
|
interface OcspCheckerOptions {
|
|
961
1081
|
/** fetch (тест/proxy). Анхдагч globalThis.fetch. Redirect дагахгүй ("manual"). */
|
|
@@ -1311,4 +1431,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1311
1431
|
*/
|
|
1312
1432
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1313
1433
|
|
|
1314
|
-
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_ISSUING_CA_SKI, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, 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, Interaction, NotificationSession, type OcspCheckerOptions, 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, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SessionApi, SessionResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
|
1434
|
+
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, ApiError, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_ISSUING_CA_SKI, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, 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, NotificationSession, type OcspCheckerOptions, 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, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SessionApi, SessionResult, ShareError, type ShareErrorCode, type ShareInfo, type ShareInput, type ShareNotSignedReason, type ShareResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|