@gerege-systems/eid-mongolia-sdk 0.31.0 → 0.33.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/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, P as PersonBlock, b as RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-B3cWNpRM.cjs';
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-B3cWNpRM.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';
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-Cf3GT4wh.cjs';
2
+ export { d as DEFAULT_SIGN_SESSION_TTL_MS, e as EndResult, O as OrgResult, P as PdfImage, f as Representation, g as SessionPresentation, h as SessionState, i as SignContext, j as SignatureAlgorithmParameters, k as SignatureProtocol, T as TokenCertSessionBlock, l as TokenCertStatus, p as parseExpiresAt, s as sessionExpiry, m as startExpiry } from './types-Cf3GT4wh.cjs';
3
+ import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-mcDbKiz_.cjs';
4
+ export { a as AppTransactionTooLargeError, b as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, F as ForbiddenError, N as NetworkError, c as NoSigningCertificateError, d as ON_BEHALF_ERROR_CODES, P as PDF_REGISTER_ERROR_CODES, e as PdfRegisterErrorCode, Q as QrTokenInvalidError, f as RETRYABLE_ERROR_CODES, g as RequestInvalidError, h as ResponseTooLargeError, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-mcDbKiz_.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 */
@@ -577,6 +578,12 @@ declare class PersonApi {
577
578
  summary(personEtsi: string): Promise<PersonSummary>;
578
579
  /** Асран хамгаалж буй хүүхдүүд (зөвхөн унших). */
579
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>;
580
587
  }
581
588
 
582
589
  /** Задалсан subject. Cert-д байхгүй талбар — undefined. Давхардсан OID-ийн эхнийх нь. */
@@ -1132,6 +1139,156 @@ declare function tokenAuthDigest(rpUUID: string, challengeB64: string): Buffer;
1132
1139
  */
1133
1140
  declare function tokenLimitOf(err: unknown): TokenLimit | undefined;
1134
1141
 
1142
+ /** Аттрибутын каталог (CA гэрээ v1, 2026-10-23). */
1143
+ declare const QR_ATTRIBUTES: readonly ["age_over_18", "age_over_21", "full_name", "phone", "birth_date", "civil_id"];
1144
+ type QrAttribute = (typeof QR_ATTRIBUTES)[number];
1145
+ /** Иргэний аппын QR-ийн угтвар: `EIDMN-QR1:<token>`. */
1146
+ declare const QR_PREFIX = "EIDMN-QR1:";
1147
+ declare const DEFAULT_QR_ISSUER = "https://ca.eidmongolia.mn";
1148
+ declare const DEFAULT_QR_JWKS_URL = "https://ca.eidmongolia.mn/.well-known/eid-jwks.json";
1149
+ declare const DEFAULT_QR_JWKS_CACHE_TTL_MS = 3600000;
1150
+ /** Presentation-ийн `iat`-аас хойш хүлээн авах дээд хугацаа (мс). */
1151
+ declare const DEFAULT_QR_MAX_AGE_MS = 600000;
1152
+ /** `iat` ирээдүйд байж болох зөрүү (мс). */
1153
+ declare const QR_CLOCK_SKEW_MS = 60000;
1154
+ /**
1155
+ * QR алдааны кодууд ({@link QrError.code}). CA-ийн 404 `QR_TOKEN_INVALID` нь {@link QrTokenInvalidError}
1156
+ * (`ApiError`, `code === "QR_TOKEN_INVALID"`) болж ирнэ.
1157
+ * - `QR_FORMAT_INVALID` — скан хийсэн мөр eID «Миний QR» биш (клиент талын)
1158
+ * - `QR_TOKEN_INVALID` — токен танигдахгүй / хугацаа дууссан (120 с) / ашиглагдсан → шинэ QR гаргуул
1159
+ * - `QR_ATTRIBUTES_INVALID` — аттрибут хоосон / каталогид алга / давхардсан (клиент талын, CA руу явахгүй)
1160
+ * - `QR_PRESENTATION_INVALID` — JWS шалгалт унасан — хариунд ИТГЭХГҮЙ
1161
+ * - `QR_JWKS_UNAVAILABLE` — CA-ийн JWKS татагдсангүй (түр; дахин оролдож болно)
1162
+ */
1163
+ declare const QR_ERROR_CODES: readonly ["QR_FORMAT_INVALID", "QR_TOKEN_INVALID", "QR_ATTRIBUTES_INVALID", "QR_PRESENTATION_INVALID", "QR_JWKS_UNAVAILABLE"];
1164
+ type QrErrorCode = (typeof QR_ERROR_CODES)[number];
1165
+ /** «Миний QR»-ийн клиент талын алдаа. */
1166
+ declare class QrError extends EidError {
1167
+ readonly code: QrErrorCode;
1168
+ readonly reason: string;
1169
+ constructor(code: QrErrorCode, reason: string);
1170
+ }
1171
+ /** Скан хийсэн QR-ээс токен: `EIDMN-QR1:<token>` эсвэл зөвхөн токен (43 тэмдэгт base64url). Буруу бол QR_FORMAT_INVALID. */
1172
+ declare function parseQr(scanned: string): string;
1173
+ interface QrConfig {
1174
+ /** Анхдагч {@link DEFAULT_QR_JWKS_URL}. https (http зөвхөн localhost). */
1175
+ jwksUrl?: string;
1176
+ /** Хүлээгдэх `iss`; анхдагч {@link DEFAULT_QR_ISSUER}. */
1177
+ issuer?: string;
1178
+ jwksCacheTtlMs?: number;
1179
+ maxAgeMs?: number;
1180
+ }
1181
+ interface QrStartInput {
1182
+ /** Скан хийсэн агуулга (`EIDMN-QR1:<token>`) эсвэл {@link parseQr}-ийн токен. */
1183
+ qr: string;
1184
+ /** Хүсэх аттрибутууд (≥ 1, давхардалгүй); RP-д аттрибут бүрийн `QR_ATTR:<нэр>` эрх. */
1185
+ attributes: readonly QrAttribute[];
1186
+ /** RP-ийн nonce (сонголттой) — JWS-ийн `nonce`-д буцна; өгөөгүй бол rpChallenge. */
1187
+ nonce?: string;
1188
+ }
1189
+ /** `qr.start`-ийн хариу — JSON-оор хадгалж (stateless backend) `qr.result`-д дамжуулна. `vc`-г кассын дэлгэцэнд харуул. */
1190
+ interface QrSession {
1191
+ sessionId: string;
1192
+ vc: string;
1193
+ nonce: string;
1194
+ attributes: QrAttribute[];
1195
+ /** CA-ийн session дуусах мөч (мс epoch), байвал. */
1196
+ expiresAt?: number;
1197
+ }
1198
+ interface QrFullName {
1199
+ surname: string;
1200
+ givenName: string;
1201
+ }
1202
+ /** Баталгаажсан аттрибутууд — хүсээгүй / байхгүй нь алга. */
1203
+ interface QrAttrs {
1204
+ age_over_18?: boolean;
1205
+ age_over_21?: boolean;
1206
+ full_name?: QrFullName;
1207
+ phone?: string;
1208
+ birth_date?: string;
1209
+ civil_id?: string;
1210
+ }
1211
+ interface QrPresentation {
1212
+ /** Энэ RP-д зориулсан тогтмол pairwise id (иргэний дугаар биш). */
1213
+ sub: string;
1214
+ attrs: QrAttrs;
1215
+ /** Хүссэн боловч бүртгэлд байхгүй (алдаа биш). */
1216
+ unavailable: QrAttribute[];
1217
+ sessionId: string;
1218
+ /** `iat`, мс epoch. */
1219
+ issuedAt: number;
1220
+ /** Түүхий compact JWS (аудитад хадгалж болно). */
1221
+ jws: string;
1222
+ }
1223
+ interface QrExpect {
1224
+ issuer?: string;
1225
+ /** RP UUID. */
1226
+ audience: string;
1227
+ sessionId: string;
1228
+ nonce: string;
1229
+ attributes: readonly string[];
1230
+ /** мс epoch; анхдагч Date.now(). */
1231
+ now?: number;
1232
+ maxAgeMs?: number;
1233
+ }
1234
+ interface Jwk {
1235
+ kty?: string;
1236
+ crv?: string;
1237
+ x?: string;
1238
+ y?: string;
1239
+ kid?: string;
1240
+ alg?: string;
1241
+ use?: string;
1242
+ }
1243
+ interface Jwks {
1244
+ keys: Jwk[];
1245
+ }
1246
+ /**
1247
+ * Compact JWS-ийг `jwks`-ээр шалгаж (ES256, kid) claim-уудыг тулгана: iss, aud (RP UUID), sid, nonce, iat (≤ now+60 с,
1248
+ * ≥ now−maxAge), exp (байвал), attrs ∪ unavailable = хүссэн аттрибутууд яг, аттрибут бүрийн төрөл. Алдаа бол
1249
+ * {@link QrError} `QR_PRESENTATION_INVALID` — хариунд ИТГЭХГҮЙ. Сүлжээгүй (хадгалсан presentation-ийг дахин шалгах, тест).
1250
+ */
1251
+ declare function verifyQrPresentation(jws: string, jwks: Jwks | null | undefined, expect: QrExpect): QrPresentation;
1252
+ interface QrApiDeps {
1253
+ http: Http;
1254
+ session: SessionApi;
1255
+ credentials: RpCredentials;
1256
+ config?: QrConfig;
1257
+ fetchImpl?: typeof fetch;
1258
+ dispatcher?: unknown;
1259
+ timeoutMs?: number;
1260
+ }
1261
+ /** `client.qr` — «Миний QR»: parse → start → result. */
1262
+ declare class QrApi {
1263
+ private readonly d;
1264
+ private jwks;
1265
+ private fetchedAt;
1266
+ private lastAttempt;
1267
+ private inflight;
1268
+ constructor(d: QrApiDeps);
1269
+ /** {@link parseQr}. */
1270
+ parse(scanned: string): string;
1271
+ /**
1272
+ * `POST /authentication/qr` — QR-ийн токеныг (нэг удаагийн) CA-д өгч иргэний утас руу хүсэлт илгээнэ; `vc`-г кассын
1273
+ * дэлгэцэнд харуул. Алдаа: {@link QrError} (FORMAT / ATTRIBUTES — CA руу явахгүй), 404 {@link QrTokenInvalidError}
1274
+ * (шинэ QR гаргуул), 403 ForbiddenError (QR_PRESENT / QR_ATTR:* эрх алга).
1275
+ */
1276
+ start(input: QrStartInput): Promise<QrSession>;
1277
+ /**
1278
+ * Session дуустал long-poll хийж presentation-ийг CA-ийн JWKS-ээр шалгана. Татгалзсан / хугацаа дууссан бол
1279
+ * SessionFailedError (`USER_REFUSED`, `TIMEOUT` г.м.); шалгалт унавал {@link QrError} `QR_PRESENTATION_INVALID`;
1280
+ * JWKS татагдахгүй бол `QR_JWKS_UNAVAILABLE` (дахин оролдож болно).
1281
+ */
1282
+ result(session: QrSession, opts?: {
1283
+ maxWaitMs?: number;
1284
+ serverPollMs?: number;
1285
+ }): Promise<QrPresentation>;
1286
+ /** Хадгалсан presentation JWS-ийг QrSession-тэй тулгаж шалгана (JWKS кэш; танихгүй kid → нэг удаа дахин татна). */
1287
+ verify(jws: string, session: QrSession): Promise<QrPresentation>;
1288
+ private keys;
1289
+ private fetchJwks;
1290
+ }
1291
+
1135
1292
  /** Хүсэлтийн хугацаа: CA бүх хүлээн авагчид 120 с-д илгээнэ, nginx 150 с. */
1136
1293
  declare const DEFAULT_SHARE_TIMEOUT_MS = 150000;
1137
1294
  /** `client.share()`-ийн оролт. Хязгаар (CA main 0329ef95): discovery-ийн `share` блок ({@link ShareInfo}). */
@@ -1255,6 +1412,8 @@ interface ClientConfig {
1255
1412
  signSessionTtlMs?: number;
1256
1413
  /** Trust anchor (Root CA) — validator-д. Production-д ЗААВАЛ. */
1257
1414
  trust?: TrustConfig;
1415
+ /** «Миний QR»-ийн presentation шалгалт (JWKS URL, issuer, кэш). Анхдагч = prod CA. */
1416
+ qr?: QrConfig;
1258
1417
  }
1259
1418
  /** RP-API-ийн албан ёсны хост (2026-09-28-наас бүх RP, /v3-гүй). */
1260
1419
  declare const DEFAULT_BASE_URL = "https://rp.eidmongolia.mn";
@@ -1268,6 +1427,8 @@ declare class EidClient {
1268
1427
  readonly organization: OrganizationApi;
1269
1428
  readonly person: PersonApi;
1270
1429
  readonly token: TokenApi;
1430
+ /** «Миний QR» (биечлэн шалгах): parse → start → result. */
1431
+ readonly qr: QrApi;
1271
1432
  readonly session: SessionApi;
1272
1433
  readonly validator: ResponseValidator;
1273
1434
  /** `credentials.rpName` — иргэний утсанд харагдах RP нэр. */
@@ -1680,4 +1841,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
1680
1841
  */
1681
1842
  declare function createEidLogin(opts: EidLoginOptions): EidLogin;
1682
1843
 
1683
- 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 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 };
1844
+ 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_QR_ISSUER, DEFAULT_QR_JWKS_CACHE_TTL_MS, DEFAULT_QR_JWKS_URL, DEFAULT_QR_MAX_AGE_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, EidError, 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, type Jwk, type Jwks, 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, QR_ATTRIBUTES, QR_CLOCK_SKEW_MS, QR_ERROR_CODES, QR_PREFIX, QrApi, type QrAttribute, type QrAttrs, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrFullName, type QrPresentation, type QrSession, type QrStartInput, 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, parseQr, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, 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, P as PersonBlock, b as RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-X_HjiWxc.js';
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-X_HjiWxc.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';
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-Cf3GT4wh.js';
2
+ export { d as DEFAULT_SIGN_SESSION_TTL_MS, e as EndResult, O as OrgResult, P as PdfImage, f as Representation, g as SessionPresentation, h as SessionState, i as SignContext, j as SignatureAlgorithmParameters, k as SignatureProtocol, T as TokenCertSessionBlock, l as TokenCertStatus, p as parseExpiresAt, s as sessionExpiry, m as startExpiry } from './types-Cf3GT4wh.js';
3
+ import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-mcDbKiz_.js';
4
+ export { a as AppTransactionTooLargeError, b as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, F as ForbiddenError, N as NetworkError, c as NoSigningCertificateError, d as ON_BEHALF_ERROR_CODES, P as PDF_REGISTER_ERROR_CODES, e as PdfRegisterErrorCode, Q as QrTokenInvalidError, f as RETRYABLE_ERROR_CODES, g as RequestInvalidError, h as ResponseTooLargeError, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-mcDbKiz_.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 */
@@ -577,6 +578,12 @@ declare class PersonApi {
577
578
  summary(personEtsi: string): Promise<PersonSummary>;
578
579
  /** Асран хамгаалж буй хүүхдүүд (зөвхөн унших). */
579
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>;
580
587
  }
581
588
 
582
589
  /** Задалсан subject. Cert-д байхгүй талбар — undefined. Давхардсан OID-ийн эхнийх нь. */
@@ -1132,6 +1139,156 @@ declare function tokenAuthDigest(rpUUID: string, challengeB64: string): Buffer;
1132
1139
  */
1133
1140
  declare function tokenLimitOf(err: unknown): TokenLimit | undefined;
1134
1141
 
1142
+ /** Аттрибутын каталог (CA гэрээ v1, 2026-10-23). */
1143
+ declare const QR_ATTRIBUTES: readonly ["age_over_18", "age_over_21", "full_name", "phone", "birth_date", "civil_id"];
1144
+ type QrAttribute = (typeof QR_ATTRIBUTES)[number];
1145
+ /** Иргэний аппын QR-ийн угтвар: `EIDMN-QR1:<token>`. */
1146
+ declare const QR_PREFIX = "EIDMN-QR1:";
1147
+ declare const DEFAULT_QR_ISSUER = "https://ca.eidmongolia.mn";
1148
+ declare const DEFAULT_QR_JWKS_URL = "https://ca.eidmongolia.mn/.well-known/eid-jwks.json";
1149
+ declare const DEFAULT_QR_JWKS_CACHE_TTL_MS = 3600000;
1150
+ /** Presentation-ийн `iat`-аас хойш хүлээн авах дээд хугацаа (мс). */
1151
+ declare const DEFAULT_QR_MAX_AGE_MS = 600000;
1152
+ /** `iat` ирээдүйд байж болох зөрүү (мс). */
1153
+ declare const QR_CLOCK_SKEW_MS = 60000;
1154
+ /**
1155
+ * QR алдааны кодууд ({@link QrError.code}). CA-ийн 404 `QR_TOKEN_INVALID` нь {@link QrTokenInvalidError}
1156
+ * (`ApiError`, `code === "QR_TOKEN_INVALID"`) болж ирнэ.
1157
+ * - `QR_FORMAT_INVALID` — скан хийсэн мөр eID «Миний QR» биш (клиент талын)
1158
+ * - `QR_TOKEN_INVALID` — токен танигдахгүй / хугацаа дууссан (120 с) / ашиглагдсан → шинэ QR гаргуул
1159
+ * - `QR_ATTRIBUTES_INVALID` — аттрибут хоосон / каталогид алга / давхардсан (клиент талын, CA руу явахгүй)
1160
+ * - `QR_PRESENTATION_INVALID` — JWS шалгалт унасан — хариунд ИТГЭХГҮЙ
1161
+ * - `QR_JWKS_UNAVAILABLE` — CA-ийн JWKS татагдсангүй (түр; дахин оролдож болно)
1162
+ */
1163
+ declare const QR_ERROR_CODES: readonly ["QR_FORMAT_INVALID", "QR_TOKEN_INVALID", "QR_ATTRIBUTES_INVALID", "QR_PRESENTATION_INVALID", "QR_JWKS_UNAVAILABLE"];
1164
+ type QrErrorCode = (typeof QR_ERROR_CODES)[number];
1165
+ /** «Миний QR»-ийн клиент талын алдаа. */
1166
+ declare class QrError extends EidError {
1167
+ readonly code: QrErrorCode;
1168
+ readonly reason: string;
1169
+ constructor(code: QrErrorCode, reason: string);
1170
+ }
1171
+ /** Скан хийсэн QR-ээс токен: `EIDMN-QR1:<token>` эсвэл зөвхөн токен (43 тэмдэгт base64url). Буруу бол QR_FORMAT_INVALID. */
1172
+ declare function parseQr(scanned: string): string;
1173
+ interface QrConfig {
1174
+ /** Анхдагч {@link DEFAULT_QR_JWKS_URL}. https (http зөвхөн localhost). */
1175
+ jwksUrl?: string;
1176
+ /** Хүлээгдэх `iss`; анхдагч {@link DEFAULT_QR_ISSUER}. */
1177
+ issuer?: string;
1178
+ jwksCacheTtlMs?: number;
1179
+ maxAgeMs?: number;
1180
+ }
1181
+ interface QrStartInput {
1182
+ /** Скан хийсэн агуулга (`EIDMN-QR1:<token>`) эсвэл {@link parseQr}-ийн токен. */
1183
+ qr: string;
1184
+ /** Хүсэх аттрибутууд (≥ 1, давхардалгүй); RP-д аттрибут бүрийн `QR_ATTR:<нэр>` эрх. */
1185
+ attributes: readonly QrAttribute[];
1186
+ /** RP-ийн nonce (сонголттой) — JWS-ийн `nonce`-д буцна; өгөөгүй бол rpChallenge. */
1187
+ nonce?: string;
1188
+ }
1189
+ /** `qr.start`-ийн хариу — JSON-оор хадгалж (stateless backend) `qr.result`-д дамжуулна. `vc`-г кассын дэлгэцэнд харуул. */
1190
+ interface QrSession {
1191
+ sessionId: string;
1192
+ vc: string;
1193
+ nonce: string;
1194
+ attributes: QrAttribute[];
1195
+ /** CA-ийн session дуусах мөч (мс epoch), байвал. */
1196
+ expiresAt?: number;
1197
+ }
1198
+ interface QrFullName {
1199
+ surname: string;
1200
+ givenName: string;
1201
+ }
1202
+ /** Баталгаажсан аттрибутууд — хүсээгүй / байхгүй нь алга. */
1203
+ interface QrAttrs {
1204
+ age_over_18?: boolean;
1205
+ age_over_21?: boolean;
1206
+ full_name?: QrFullName;
1207
+ phone?: string;
1208
+ birth_date?: string;
1209
+ civil_id?: string;
1210
+ }
1211
+ interface QrPresentation {
1212
+ /** Энэ RP-д зориулсан тогтмол pairwise id (иргэний дугаар биш). */
1213
+ sub: string;
1214
+ attrs: QrAttrs;
1215
+ /** Хүссэн боловч бүртгэлд байхгүй (алдаа биш). */
1216
+ unavailable: QrAttribute[];
1217
+ sessionId: string;
1218
+ /** `iat`, мс epoch. */
1219
+ issuedAt: number;
1220
+ /** Түүхий compact JWS (аудитад хадгалж болно). */
1221
+ jws: string;
1222
+ }
1223
+ interface QrExpect {
1224
+ issuer?: string;
1225
+ /** RP UUID. */
1226
+ audience: string;
1227
+ sessionId: string;
1228
+ nonce: string;
1229
+ attributes: readonly string[];
1230
+ /** мс epoch; анхдагч Date.now(). */
1231
+ now?: number;
1232
+ maxAgeMs?: number;
1233
+ }
1234
+ interface Jwk {
1235
+ kty?: string;
1236
+ crv?: string;
1237
+ x?: string;
1238
+ y?: string;
1239
+ kid?: string;
1240
+ alg?: string;
1241
+ use?: string;
1242
+ }
1243
+ interface Jwks {
1244
+ keys: Jwk[];
1245
+ }
1246
+ /**
1247
+ * Compact JWS-ийг `jwks`-ээр шалгаж (ES256, kid) claim-уудыг тулгана: iss, aud (RP UUID), sid, nonce, iat (≤ now+60 с,
1248
+ * ≥ now−maxAge), exp (байвал), attrs ∪ unavailable = хүссэн аттрибутууд яг, аттрибут бүрийн төрөл. Алдаа бол
1249
+ * {@link QrError} `QR_PRESENTATION_INVALID` — хариунд ИТГЭХГҮЙ. Сүлжээгүй (хадгалсан presentation-ийг дахин шалгах, тест).
1250
+ */
1251
+ declare function verifyQrPresentation(jws: string, jwks: Jwks | null | undefined, expect: QrExpect): QrPresentation;
1252
+ interface QrApiDeps {
1253
+ http: Http;
1254
+ session: SessionApi;
1255
+ credentials: RpCredentials;
1256
+ config?: QrConfig;
1257
+ fetchImpl?: typeof fetch;
1258
+ dispatcher?: unknown;
1259
+ timeoutMs?: number;
1260
+ }
1261
+ /** `client.qr` — «Миний QR»: parse → start → result. */
1262
+ declare class QrApi {
1263
+ private readonly d;
1264
+ private jwks;
1265
+ private fetchedAt;
1266
+ private lastAttempt;
1267
+ private inflight;
1268
+ constructor(d: QrApiDeps);
1269
+ /** {@link parseQr}. */
1270
+ parse(scanned: string): string;
1271
+ /**
1272
+ * `POST /authentication/qr` — QR-ийн токеныг (нэг удаагийн) CA-д өгч иргэний утас руу хүсэлт илгээнэ; `vc`-г кассын
1273
+ * дэлгэцэнд харуул. Алдаа: {@link QrError} (FORMAT / ATTRIBUTES — CA руу явахгүй), 404 {@link QrTokenInvalidError}
1274
+ * (шинэ QR гаргуул), 403 ForbiddenError (QR_PRESENT / QR_ATTR:* эрх алга).
1275
+ */
1276
+ start(input: QrStartInput): Promise<QrSession>;
1277
+ /**
1278
+ * Session дуустал long-poll хийж presentation-ийг CA-ийн JWKS-ээр шалгана. Татгалзсан / хугацаа дууссан бол
1279
+ * SessionFailedError (`USER_REFUSED`, `TIMEOUT` г.м.); шалгалт унавал {@link QrError} `QR_PRESENTATION_INVALID`;
1280
+ * JWKS татагдахгүй бол `QR_JWKS_UNAVAILABLE` (дахин оролдож болно).
1281
+ */
1282
+ result(session: QrSession, opts?: {
1283
+ maxWaitMs?: number;
1284
+ serverPollMs?: number;
1285
+ }): Promise<QrPresentation>;
1286
+ /** Хадгалсан presentation JWS-ийг QrSession-тэй тулгаж шалгана (JWKS кэш; танихгүй kid → нэг удаа дахин татна). */
1287
+ verify(jws: string, session: QrSession): Promise<QrPresentation>;
1288
+ private keys;
1289
+ private fetchJwks;
1290
+ }
1291
+
1135
1292
  /** Хүсэлтийн хугацаа: CA бүх хүлээн авагчид 120 с-д илгээнэ, nginx 150 с. */
1136
1293
  declare const DEFAULT_SHARE_TIMEOUT_MS = 150000;
1137
1294
  /** `client.share()`-ийн оролт. Хязгаар (CA main 0329ef95): discovery-ийн `share` блок ({@link ShareInfo}). */
@@ -1255,6 +1412,8 @@ interface ClientConfig {
1255
1412
  signSessionTtlMs?: number;
1256
1413
  /** Trust anchor (Root CA) — validator-д. Production-д ЗААВАЛ. */
1257
1414
  trust?: TrustConfig;
1415
+ /** «Миний QR»-ийн presentation шалгалт (JWKS URL, issuer, кэш). Анхдагч = prod CA. */
1416
+ qr?: QrConfig;
1258
1417
  }
1259
1418
  /** RP-API-ийн албан ёсны хост (2026-09-28-наас бүх RP, /v3-гүй). */
1260
1419
  declare const DEFAULT_BASE_URL = "https://rp.eidmongolia.mn";
@@ -1268,6 +1427,8 @@ declare class EidClient {
1268
1427
  readonly organization: OrganizationApi;
1269
1428
  readonly person: PersonApi;
1270
1429
  readonly token: TokenApi;
1430
+ /** «Миний QR» (биечлэн шалгах): parse → start → result. */
1431
+ readonly qr: QrApi;
1271
1432
  readonly session: SessionApi;
1272
1433
  readonly validator: ResponseValidator;
1273
1434
  /** `credentials.rpName` — иргэний утсанд харагдах RP нэр. */
@@ -1680,4 +1841,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
1680
1841
  */
1681
1842
  declare function createEidLogin(opts: EidLoginOptions): EidLogin;
1682
1843
 
1683
- 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 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 };
1844
+ 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_QR_ISSUER, DEFAULT_QR_JWKS_CACHE_TTL_MS, DEFAULT_QR_JWKS_URL, DEFAULT_QR_MAX_AGE_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, EidError, 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, type Jwk, type Jwks, 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, QR_ATTRIBUTES, QR_CLOCK_SKEW_MS, QR_ERROR_CODES, QR_PREFIX, QrApi, type QrAttribute, type QrAttrs, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrFullName, type QrPresentation, type QrSession, type QrStartInput, 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, parseQr, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, verifyTokenCertificates, withReturnHint };