@gerege-systems/eid-mongolia-sdk 0.41.0 → 0.42.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,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-Cbph4U6r.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 SessionPresentation, g as SessionState, h as SignContext, i as SignatureAlgorithmParameters, j as SignatureProtocol, T as TokenCertSessionBlock, k as TokenCertStatus, l as isMobileUserAgent, p as parseExpiresAt, s as sessionExpiry, m as startExpiry } from './browser-Cbph4U6r.cjs';
3
+ import { X509Certificate, KeyObject } from 'node:crypto';
3
4
  import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-CgJcEjrZ.cjs';
4
5
  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-CgJcEjrZ.cjs';
5
- import { X509Certificate, KeyObject } from 'node:crypto';
6
6
 
7
7
  interface HttpConfig {
8
8
  /** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
@@ -410,6 +410,54 @@ declare class OrganizationApi {
410
410
  getRepresentations(personEtsi: string): Promise<RepresentationsResponse>;
411
411
  }
412
412
 
413
+ /** `GET /seal/certificate/{orgEtsi}` (CA `dto.SealCertificateResponse`). */
414
+ interface SealCertificate {
415
+ orgEtsi: string;
416
+ /** DER. */
417
+ certificate: Uint8Array;
418
+ serialNumber: string;
419
+ subjectDn: string;
420
+ issuerDn: string;
421
+ /** RFC 3339. */
422
+ notBefore: string;
423
+ notAfter: string;
424
+ certificateLevel: CertificateLevel | string;
425
+ /** Серверийн түүхий JSON. */
426
+ raw: unknown;
427
+ }
428
+ /** `POST /seal/{orgEtsi}` (CA `dto.SealResponse`). */
429
+ interface SealResult {
430
+ orgEtsi: string;
431
+ /** digest дээрх ECDSA гарын үсэг (ASN.1 DER). */
432
+ signature: Uint8Array;
433
+ /** ж: `ecdsa-with-SHA256` (digest-ийн hash-аас). */
434
+ signatureAlgorithm: string;
435
+ /** Тамгалсан гэрчилгээ (DER). */
436
+ certificate: Uint8Array;
437
+ certificateLevel: CertificateLevel | string;
438
+ /** RFC 3339. */
439
+ sealedAt: string;
440
+ raw: unknown;
441
+ }
442
+ /**
443
+ * e-Seal профайл: KeyUsage-д nonRepudiation (contentCommitment) байгаа, digitalSignature байхгүй, EKU байхгүй, CA биш
444
+ * (CA/SDK шалгагчийн `usage: "seal"` ангилалтай ижил; Go `eid.IsSealCertificate`).
445
+ */
446
+ declare function isSealCertificate(cert: X509Certificate | Uint8Array): boolean;
447
+ declare class SealApi {
448
+ private readonly http;
449
+ constructor(http: Http);
450
+ /** `GET /seal/certificate/{orgEtsi}` — байгууллагын идэвхтэй тамганы гэрчилгээ (PAdES-ийн signerCert). */
451
+ getCertificate(orgEtsi: string): Promise<SealCertificate>;
452
+ /**
453
+ * `POST /seal/{orgEtsi}` — digest-ийг байгууллагын тамгаар тамгална. `hashAlgorithm`: SHA-256 (анхдагч) | SHA-384 |
454
+ * SHA-512; digest-ийн урт таарахгүй бол сүлжээнд гарахгүй. Хариуны гарын үсгийг хариуны гэрчилгээгээр digest дээр
455
+ * шалгаж, гэрчилгээ e-Seal ({@link isSealCertificate}) эсэхийг тулгана — эс бөгөөс ValidationError. Гинж/цуцлалтыг
456
+ * `sealPdf` (OCSP/CRL) шалгана.
457
+ */
458
+ seal(orgEtsi: string, digest: Uint8Array, hashAlgorithm?: HashAlgorithm): Promise<SealResult>;
459
+ }
460
+
413
461
  /** Токенд холбогдсон байгууллага. */
414
462
  interface TokenOrganization {
415
463
  etsi: string;
@@ -1447,6 +1495,8 @@ declare class EidClient {
1447
1495
  readonly auth: AuthApi;
1448
1496
  readonly sign: SignApi;
1449
1497
  readonly organization: OrganizationApi;
1498
+ /** Байгууллагын цахим тамга (e-Seal) — `SEAL:<orgEtsi>` эрх. */
1499
+ readonly seal: SealApi;
1450
1500
  readonly person: PersonApi;
1451
1501
  readonly token: TokenApi;
1452
1502
  /** «Миний QR» (биечлэн шалгах): parse → start → result / check. */
@@ -1483,6 +1533,11 @@ declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "med
1483
1533
  * 0329ef95, !371). CA үл мэдэгдэх талбарыг 400 REQUEST_INVALID-аар татгалздаг. Live discovery-ийн `endpoints.share`
1484
1534
  * тайлбартай гэрээний тест тулгана.
1485
1535
  */
1536
+ /**
1537
+ * `POST /seal/{orgEtsi}`-ийн биеийн талбарууд, SDK-ийн илгээдэг — CA `server/internal/dto/org_dtos.go` `SealRequest`-ийн
1538
+ * JSON tag (`relyingPartyUUID`/`relyingPartyName` нь CA-д заавал биш). CA `DisallowUnknownFields`.
1539
+ */
1540
+ declare const SEAL_REQUEST_FIELDS: readonly ["digest", "hashType"];
1486
1541
  declare const SHARE_FORM_FIELDS: readonly ["file", "filename", "to", "subject", "message", "lang"];
1487
1542
 
1488
1543
  interface OcspCheckerOptions {
@@ -1873,4 +1928,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
1873
1928
  */
1874
1929
  declare function createEidLogin(opts: EidLoginOptions): EidLogin;
1875
1930
 
1876
- 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_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, EidError, 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 ParsedQr, 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, QR_CLOCK_SKEW_SECONDS, QR_ERROR_CODES, QR_LIMITS, QR_MAX_AGE_SECONDS, QR_PREFIX, QrApi, type QrApiDeps, type QrCheck, type QrClaims, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrPresentation, type QrSession, type QrSigner, 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, qrStatement, randomChallenge, registrationFromCompleted, resolveBaseUrl, sessionSecretDigest, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, verifySessionSecretDigest, verifyTokenCertificates, withReturnHint };
1931
+ 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_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, EidError, 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 ParsedQr, 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, QR_CLOCK_SKEW_SECONDS, QR_ERROR_CODES, QR_LIMITS, QR_MAX_AGE_SECONDS, QR_PREFIX, QrApi, type QrApiDeps, type QrCheck, type QrClaims, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrPresentation, type QrSession, type QrSigner, type QrStartInput, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, RetryableErrorCode, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SEAL_REQUEST_FIELDS, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SealApi, type SealCertificate, type SealResult, 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, isSealCertificate, memoryLoginStore, ocspRevocationChecker, parseQr, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, qrStatement, randomChallenge, registrationFromCompleted, resolveBaseUrl, sessionSecretDigest, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, verifySessionSecretDigest, verifyTokenCertificates, withReturnHint };
package/dist/index.d.ts CHANGED
@@ -1,8 +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-aa_Judox.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 SessionPresentation, g as SessionState, h as SignContext, i as SignatureAlgorithmParameters, j as SignatureProtocol, T as TokenCertSessionBlock, k as TokenCertStatus, l as isMobileUserAgent, p as parseExpiresAt, s as sessionExpiry, m as startExpiry } from './browser-aa_Judox.js';
3
+ import { X509Certificate, KeyObject } from 'node:crypto';
3
4
  import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-CgJcEjrZ.js';
4
5
  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-CgJcEjrZ.js';
5
- import { X509Certificate, KeyObject } from 'node:crypto';
6
6
 
7
7
  interface HttpConfig {
8
8
  /** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
@@ -410,6 +410,54 @@ declare class OrganizationApi {
410
410
  getRepresentations(personEtsi: string): Promise<RepresentationsResponse>;
411
411
  }
412
412
 
413
+ /** `GET /seal/certificate/{orgEtsi}` (CA `dto.SealCertificateResponse`). */
414
+ interface SealCertificate {
415
+ orgEtsi: string;
416
+ /** DER. */
417
+ certificate: Uint8Array;
418
+ serialNumber: string;
419
+ subjectDn: string;
420
+ issuerDn: string;
421
+ /** RFC 3339. */
422
+ notBefore: string;
423
+ notAfter: string;
424
+ certificateLevel: CertificateLevel | string;
425
+ /** Серверийн түүхий JSON. */
426
+ raw: unknown;
427
+ }
428
+ /** `POST /seal/{orgEtsi}` (CA `dto.SealResponse`). */
429
+ interface SealResult {
430
+ orgEtsi: string;
431
+ /** digest дээрх ECDSA гарын үсэг (ASN.1 DER). */
432
+ signature: Uint8Array;
433
+ /** ж: `ecdsa-with-SHA256` (digest-ийн hash-аас). */
434
+ signatureAlgorithm: string;
435
+ /** Тамгалсан гэрчилгээ (DER). */
436
+ certificate: Uint8Array;
437
+ certificateLevel: CertificateLevel | string;
438
+ /** RFC 3339. */
439
+ sealedAt: string;
440
+ raw: unknown;
441
+ }
442
+ /**
443
+ * e-Seal профайл: KeyUsage-д nonRepudiation (contentCommitment) байгаа, digitalSignature байхгүй, EKU байхгүй, CA биш
444
+ * (CA/SDK шалгагчийн `usage: "seal"` ангилалтай ижил; Go `eid.IsSealCertificate`).
445
+ */
446
+ declare function isSealCertificate(cert: X509Certificate | Uint8Array): boolean;
447
+ declare class SealApi {
448
+ private readonly http;
449
+ constructor(http: Http);
450
+ /** `GET /seal/certificate/{orgEtsi}` — байгууллагын идэвхтэй тамганы гэрчилгээ (PAdES-ийн signerCert). */
451
+ getCertificate(orgEtsi: string): Promise<SealCertificate>;
452
+ /**
453
+ * `POST /seal/{orgEtsi}` — digest-ийг байгууллагын тамгаар тамгална. `hashAlgorithm`: SHA-256 (анхдагч) | SHA-384 |
454
+ * SHA-512; digest-ийн урт таарахгүй бол сүлжээнд гарахгүй. Хариуны гарын үсгийг хариуны гэрчилгээгээр digest дээр
455
+ * шалгаж, гэрчилгээ e-Seal ({@link isSealCertificate}) эсэхийг тулгана — эс бөгөөс ValidationError. Гинж/цуцлалтыг
456
+ * `sealPdf` (OCSP/CRL) шалгана.
457
+ */
458
+ seal(orgEtsi: string, digest: Uint8Array, hashAlgorithm?: HashAlgorithm): Promise<SealResult>;
459
+ }
460
+
413
461
  /** Токенд холбогдсон байгууллага. */
414
462
  interface TokenOrganization {
415
463
  etsi: string;
@@ -1447,6 +1495,8 @@ declare class EidClient {
1447
1495
  readonly auth: AuthApi;
1448
1496
  readonly sign: SignApi;
1449
1497
  readonly organization: OrganizationApi;
1498
+ /** Байгууллагын цахим тамга (e-Seal) — `SEAL:<orgEtsi>` эрх. */
1499
+ readonly seal: SealApi;
1450
1500
  readonly person: PersonApi;
1451
1501
  readonly token: TokenApi;
1452
1502
  /** «Миний QR» (биечлэн шалгах): parse → start → result / check. */
@@ -1483,6 +1533,11 @@ declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "med
1483
1533
  * 0329ef95, !371). CA үл мэдэгдэх талбарыг 400 REQUEST_INVALID-аар татгалздаг. Live discovery-ийн `endpoints.share`
1484
1534
  * тайлбартай гэрээний тест тулгана.
1485
1535
  */
1536
+ /**
1537
+ * `POST /seal/{orgEtsi}`-ийн биеийн талбарууд, SDK-ийн илгээдэг — CA `server/internal/dto/org_dtos.go` `SealRequest`-ийн
1538
+ * JSON tag (`relyingPartyUUID`/`relyingPartyName` нь CA-д заавал биш). CA `DisallowUnknownFields`.
1539
+ */
1540
+ declare const SEAL_REQUEST_FIELDS: readonly ["digest", "hashType"];
1486
1541
  declare const SHARE_FORM_FIELDS: readonly ["file", "filename", "to", "subject", "message", "lang"];
1487
1542
 
1488
1543
  interface OcspCheckerOptions {
@@ -1873,4 +1928,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
1873
1928
  */
1874
1929
  declare function createEidLogin(opts: EidLoginOptions): EidLogin;
1875
1930
 
1876
- 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_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, EidError, 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 ParsedQr, 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, QR_CLOCK_SKEW_SECONDS, QR_ERROR_CODES, QR_LIMITS, QR_MAX_AGE_SECONDS, QR_PREFIX, QrApi, type QrApiDeps, type QrCheck, type QrClaims, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrPresentation, type QrSession, type QrSigner, 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, qrStatement, randomChallenge, registrationFromCompleted, resolveBaseUrl, sessionSecretDigest, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, verifySessionSecretDigest, verifyTokenCertificates, withReturnHint };
1931
+ 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_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, EidError, 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 ParsedQr, 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, QR_CLOCK_SKEW_SECONDS, QR_ERROR_CODES, QR_LIMITS, QR_MAX_AGE_SECONDS, QR_PREFIX, QrApi, type QrApiDeps, type QrCheck, type QrClaims, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrPresentation, type QrSession, type QrSigner, type QrStartInput, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, RetryableErrorCode, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SEAL_REQUEST_FIELDS, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SealApi, type SealCertificate, type SealResult, 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, isSealCertificate, memoryLoginStore, ocspRevocationChecker, parseQr, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, qrStatement, randomChallenge, registrationFromCompleted, resolveBaseUrl, sessionSecretDigest, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, verifySessionSecretDigest, verifyTokenCertificates, withReturnHint };
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import {
31
31
  ValidationError,
32
32
  maskPath,
33
33
  parseRetryAfter
34
- } from "./chunk-PWFTN52X.js";
34
+ } from "./chunk-A6FYBPRV.js";
35
35
 
36
36
  // src/http.ts
37
37
  var DEFAULT_TIMEOUT_MS = 15e3;
@@ -176,7 +176,11 @@ var RP_ROUTES = {
176
176
  tokenAuthVerify: { method: "POST", path: "/token/auth/verify" },
177
177
  share: { method: "POST", path: "/share" },
178
178
  /** «Миний QR» (CA гэрээ myqr-2026-10-26): `{qr, relyingPartyUUID, relyingPartyName, nonce}` → `{sessionID}`. */
179
- authQr: { method: "POST", path: "/authentication/qr" }
179
+ authQr: { method: "POST", path: "/authentication/qr" },
180
+ /** Байгууллагын тамганы гэрчилгээ (CA `dto.SealCertificateResponse`). */
181
+ sealCertificate: { method: "GET", path: "/seal/certificate/{orgEtsi}" },
182
+ /** Байгууллагын тамга (CA `dto.SealRequest` `{digest, hashType}` → `dto.SealResponse`). */
183
+ seal: { method: "POST", path: "/seal/{orgEtsi}" }
180
184
  };
181
185
  var PDF_SIGNATURE_REGISTER_FIELDS = [
182
186
  "docID",
@@ -194,6 +198,7 @@ var PDF_SIGNATURE_REGISTER_FIELDS = [
194
198
  "onBehalfOf",
195
199
  "signerEtsi"
196
200
  ];
201
+ var SEAL_REQUEST_FIELDS = ["digest", "hashType"];
197
202
  var SHARE_FORM_FIELDS = ["file", "filename", "to", "subject", "message", "lang"];
198
203
  function routePath(route, ...args) {
199
204
  let i = 0;
@@ -917,48 +922,11 @@ var OrganizationApi = class {
917
922
  }
918
923
  };
919
924
 
920
- // src/person.ts
921
- function rec3(v) {
922
- return v && typeof v === "object" ? v : {};
923
- }
924
- var PersonApi = class {
925
- constructor(http) {
926
- this.http = http;
927
- }
928
- http;
929
- async get(path) {
930
- const raw = await this.http.get(path);
931
- return { ...rec3(raw), raw };
932
- }
933
- /** Иргэний бүх гэрчилгээ + статусын тоолол. */
934
- certificates(personEtsi) {
935
- return this.get(routePath(RP_ROUTES.personCertificates, personEtsi));
936
- }
937
- /** Иргэний холбоотой төхөөрөмжүүд (идэвхтэй + идэвхгүй). */
938
- devices(personEtsi) {
939
- return this.get(routePath(RP_ROUTES.personDevices, personEtsi));
940
- }
941
- /** Иргэний үйл ажиллагааны түүх. */
942
- activity(personEtsi, query) {
943
- const q = new URLSearchParams();
944
- if (query?.flow) q.set("flow", query.flow);
945
- if (query?.limit && query.limit > 0) q.set("limit", String(query.limit));
946
- if (query?.offset && query.offset > 0) q.set("offset", String(query.offset));
947
- const qs = q.toString();
948
- return this.get(routePath(RP_ROUTES.personActivity, personEtsi) + (qs ? `?${qs}` : ""));
949
- }
950
- /** Самбарын нэгдсэн тоо. */
951
- summary(personEtsi) {
952
- return this.get(routePath(RP_ROUTES.personSummary, personEtsi));
953
- }
954
- /** Асран хамгаалж буй хүүхдүүд (зөвхөн унших). */
955
- children(personEtsi) {
956
- return this.get(routePath(RP_ROUTES.personChildren, personEtsi));
957
- }
958
- };
925
+ // src/seal.ts
926
+ import { X509Certificate as X509Certificate3 } from "crypto";
959
927
 
960
- // src/token.ts
961
- import { X509Certificate as X509Certificate3, createHash as createHash3, createPublicKey, timingSafeEqual as timingSafeEqual2 } from "crypto";
928
+ // src/validator.ts
929
+ import { X509Certificate as X509Certificate2, constants, createHash as createHash2, publicDecrypt, verify } from "crypto";
962
930
 
963
931
  // src/subject.ts
964
932
  import { X509Certificate } from "crypto";
@@ -1099,10 +1067,9 @@ function certExtensions(der) {
1099
1067
  }
1100
1068
 
1101
1069
  // src/validator.ts
1102
- import { X509Certificate as X509Certificate2, constants, createHash as createHash2, publicDecrypt, verify } from "crypto";
1103
1070
  var CITIZEN_ISSUING_CA_SKI = "b8a37f2c64ad677912db7d9e34f246358a2fb909";
1104
- var derB64ToPem = (b643) => `-----BEGIN CERTIFICATE-----
1105
- ${b643.match(/.{1,64}/g).join("\n")}
1071
+ var derB64ToPem = (b644) => `-----BEGIN CERTIFICATE-----
1072
+ ${b644.match(/.{1,64}/g).join("\n")}
1106
1073
  -----END CERTIFICATE-----
1107
1074
  `;
1108
1075
  var NATIONAL_ROOT_CA_PEM = derB64ToPem(NATIONAL_ROOT[0]);
@@ -1764,10 +1731,138 @@ function basicConstraintsPathLen(cert) {
1764
1731
  return void 0;
1765
1732
  }
1766
1733
 
1734
+ // src/seal.ts
1735
+ var rec3 = (v) => v && typeof v === "object" ? v : {};
1736
+ var b642 = (s, what) => {
1737
+ if (typeof s !== "string" || s === "" || !/^[A-Za-z0-9+/]+={0,2}$/.test(s)) throw new ValidationError(`seal: ${what} base64 \u0431\u0438\u0448 \u044D\u0441\u0432\u044D\u043B \u0445\u043E\u043E\u0441\u043E\u043D`);
1738
+ return new Uint8Array(Buffer.from(s, "base64"));
1739
+ };
1740
+ function isSealCertificate(cert) {
1741
+ let c;
1742
+ try {
1743
+ c = cert instanceof X509Certificate3 ? cert : new X509Certificate3(Buffer.from(cert));
1744
+ } catch {
1745
+ return false;
1746
+ }
1747
+ if (c.ca || certExtension(c.raw, "2.5.29.37")) return false;
1748
+ const v = certExtension(c.raw, "2.5.29.15");
1749
+ if (!v) return false;
1750
+ const bs = tlv(v, 0, v.length);
1751
+ if (bs.tag !== 3 || bs.end - bs.start < 2) return false;
1752
+ const bits = v[bs.start + 1];
1753
+ return (bits & 64) !== 0 && (bits & 128) === 0;
1754
+ }
1755
+ var SealApi = class {
1756
+ constructor(http) {
1757
+ this.http = http;
1758
+ }
1759
+ http;
1760
+ /** `GET /seal/certificate/{orgEtsi}` — байгууллагын идэвхтэй тамганы гэрчилгээ (PAdES-ийн signerCert). */
1761
+ async getCertificate(orgEtsi) {
1762
+ const raw = await this.http.get(routePath(RP_ROUTES.sealCertificate, orgEtsi));
1763
+ const r = rec3(raw);
1764
+ return {
1765
+ orgEtsi: String(r.orgEtsi ?? orgEtsi),
1766
+ certificate: b642(r.certificate, "certificate"),
1767
+ serialNumber: String(r.serialNumber ?? ""),
1768
+ subjectDn: String(r.subjectDn ?? ""),
1769
+ issuerDn: String(r.issuerDn ?? ""),
1770
+ notBefore: String(r.notBefore ?? ""),
1771
+ notAfter: String(r.notAfter ?? ""),
1772
+ certificateLevel: String(r.certificateLevel ?? ""),
1773
+ raw
1774
+ };
1775
+ }
1776
+ /**
1777
+ * `POST /seal/{orgEtsi}` — digest-ийг байгууллагын тамгаар тамгална. `hashAlgorithm`: SHA-256 (анхдагч) | SHA-384 |
1778
+ * SHA-512; digest-ийн урт таарахгүй бол сүлжээнд гарахгүй. Хариуны гарын үсгийг хариуны гэрчилгээгээр digest дээр
1779
+ * шалгаж, гэрчилгээ e-Seal ({@link isSealCertificate}) эсэхийг тулгана — эс бөгөөс ValidationError. Гинж/цуцлалтыг
1780
+ * `sealPdf` (OCSP/CRL) шалгана.
1781
+ */
1782
+ async seal(orgEtsi, digest, hashAlgorithm = "SHA-256") {
1783
+ if (!["SHA-256", "SHA-384", "SHA-512"].includes(hashAlgorithm)) throw new ValidationError(`seal: \u0434\u044D\u043C\u0436\u0438\u0433\u0434\u044D\u044D\u0433\u04AF\u0439 hashAlgorithm ${hashAlgorithm}`);
1784
+ if (!(digest instanceof Uint8Array) || digest.length !== hashLen(hashAlgorithm)) {
1785
+ throw new ValidationError(`seal: digest \u043D\u044C ${hashAlgorithm}-\u0438\u0439\u043D \u0443\u0440\u0442 (${hashLen(hashAlgorithm)} \u0431\u0430\u0439\u0442) \u0431\u0430\u0439\u0445 \u0451\u0441\u0442\u043E\u0439`);
1786
+ }
1787
+ const body = {
1788
+ digest: Buffer.from(digest).toString("base64"),
1789
+ hashType: hashAlgorithm.replace("-", "")
1790
+ };
1791
+ const raw = await this.http.post(routePath(RP_ROUTES.seal, orgEtsi), body);
1792
+ const r = rec3(raw);
1793
+ const sig = rec3(r.signature);
1794
+ const cert = rec3(r.cert);
1795
+ const signature = b642(sig.value, "signature.value");
1796
+ const certificate = b642(cert.value, "cert.value");
1797
+ let x;
1798
+ try {
1799
+ x = new X509Certificate3(Buffer.from(certificate));
1800
+ } catch (e) {
1801
+ const err = new ValidationError("seal: cert \u0437\u0430\u0434\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439");
1802
+ err.cause = e;
1803
+ throw err;
1804
+ }
1805
+ if (!isSealCertificate(x)) throw new ValidationError("seal: \u0445\u0430\u0440\u0438\u0443\u043D\u044B \u0433\u044D\u0440\u0447\u0438\u043B\u0433\u044D\u044D e-Seal \u0431\u0438\u0448 (KeyUsage)");
1806
+ if (x.publicKey.asymmetricKeyType !== "ec" || !verifyPrehashedSignature(Buffer.from(digest), String(sig.value), x.publicKey, "ecdsa-with-SHA256", hashAlgorithm)) {
1807
+ throw new ValidationError("seal: \u0433\u0430\u0440\u044B\u043D \u04AF\u0441\u044D\u0433 digest-\u0442\u044D\u0439 \u0442\u0430\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439");
1808
+ }
1809
+ return {
1810
+ orgEtsi: String(r.orgEtsi ?? orgEtsi),
1811
+ signature,
1812
+ signatureAlgorithm: String(sig.signatureAlgorithm ?? ""),
1813
+ certificate,
1814
+ certificateLevel: String(cert.certificateLevel ?? ""),
1815
+ sealedAt: String(r.sealedAt ?? ""),
1816
+ raw
1817
+ };
1818
+ }
1819
+ };
1820
+
1821
+ // src/person.ts
1822
+ function rec4(v) {
1823
+ return v && typeof v === "object" ? v : {};
1824
+ }
1825
+ var PersonApi = class {
1826
+ constructor(http) {
1827
+ this.http = http;
1828
+ }
1829
+ http;
1830
+ async get(path) {
1831
+ const raw = await this.http.get(path);
1832
+ return { ...rec4(raw), raw };
1833
+ }
1834
+ /** Иргэний бүх гэрчилгээ + статусын тоолол. */
1835
+ certificates(personEtsi) {
1836
+ return this.get(routePath(RP_ROUTES.personCertificates, personEtsi));
1837
+ }
1838
+ /** Иргэний холбоотой төхөөрөмжүүд (идэвхтэй + идэвхгүй). */
1839
+ devices(personEtsi) {
1840
+ return this.get(routePath(RP_ROUTES.personDevices, personEtsi));
1841
+ }
1842
+ /** Иргэний үйл ажиллагааны түүх. */
1843
+ activity(personEtsi, query) {
1844
+ const q = new URLSearchParams();
1845
+ if (query?.flow) q.set("flow", query.flow);
1846
+ if (query?.limit && query.limit > 0) q.set("limit", String(query.limit));
1847
+ if (query?.offset && query.offset > 0) q.set("offset", String(query.offset));
1848
+ const qs = q.toString();
1849
+ return this.get(routePath(RP_ROUTES.personActivity, personEtsi) + (qs ? `?${qs}` : ""));
1850
+ }
1851
+ /** Самбарын нэгдсэн тоо. */
1852
+ summary(personEtsi) {
1853
+ return this.get(routePath(RP_ROUTES.personSummary, personEtsi));
1854
+ }
1855
+ /** Асран хамгаалж буй хүүхдүүд (зөвхөн унших). */
1856
+ children(personEtsi) {
1857
+ return this.get(routePath(RP_ROUTES.personChildren, personEtsi));
1858
+ }
1859
+ };
1860
+
1767
1861
  // src/token.ts
1862
+ import { X509Certificate as X509Certificate4, createHash as createHash3, createPublicKey, timingSafeEqual as timingSafeEqual2 } from "crypto";
1768
1863
  var MAX_APP_TRANSACTION_BYTES = 16 * 1024;
1769
1864
  var APP_ATTESTATION_INVALID = "APP_ATTESTATION_INVALID";
1770
- function rec4(v) {
1865
+ function rec5(v) {
1771
1866
  return v && typeof v === "object" ? v : {};
1772
1867
  }
1773
1868
  function hexSha256Equal(hex, data) {
@@ -1810,7 +1905,7 @@ var TOKEN_ERROR_CODES = [
1810
1905
  ...RETRYABLE_ERROR_CODES
1811
1906
  ];
1812
1907
  function supersedesOf(v) {
1813
- return Array.isArray(v) ? { supersedes: v.map((x) => ({ tokenSerial: String(rec4(x).tokenSerial ?? "") })) } : {};
1908
+ return Array.isArray(v) ? { supersedes: v.map((x) => ({ tokenSerial: String(rec5(x).tokenSerial ?? "") })) } : {};
1814
1909
  }
1815
1910
  var DISCOVERY_PATH = "/.well-known/eid";
1816
1911
  var TOKEN_RESULT_TIMEOUT_MS = 3e4;
@@ -1837,11 +1932,11 @@ var TokenApi = class {
1837
1932
  * {@link AppTransactionTooLargeError} (илгээхгүй).
1838
1933
  */
1839
1934
  async issueCertificate(input) {
1840
- const r = rec4(await this.http.post(routePath(RP_ROUTES.tokenCertificate), this.certBody(input)));
1935
+ const r = rec5(await this.http.post(routePath(RP_ROUTES.tokenCertificate), this.certBody(input)));
1841
1936
  if (!hexSha256Equal(r.csrAuthSha256, input.csrAuth) || !hexSha256Equal(r.csrSignSha256, input.csrSign)) {
1842
1937
  throw new ValidationError("token: CA-\u0438\u0439\u043D csrAuthSha256/csrSignSha256 \u0438\u043B\u0433\u044D\u044D\u0441\u044D\u043D CSR-\u0442\u044D\u0439 \u0442\u0430\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439");
1843
1938
  }
1844
- const vc = rec4(r.vc).value ?? (typeof r.vc === "string" ? r.vc : void 0);
1939
+ const vc = rec5(r.vc).value ?? (typeof r.vc === "string" ? r.vc : void 0);
1845
1940
  return {
1846
1941
  sessionId: String(r.sessionID ?? ""),
1847
1942
  vc: vc != null ? String(vc) : null,
@@ -1859,7 +1954,7 @@ var TokenApi = class {
1859
1954
  * Иргэн бүртгэл устгах хүсэлттэй бол 409 `ACCOUNT_DELETE_PENDING` (CA !403-оос). Зөвхөн `TOKEN_ISSUE` эрх.
1860
1955
  */
1861
1956
  async previewCertificate(input) {
1862
- const r = rec4(await this.http.post(routePath(RP_ROUTES.tokenCertificate), { ...this.certBody(input), dryRun: true }));
1957
+ const r = rec5(await this.http.post(routePath(RP_ROUTES.tokenCertificate), { ...this.certBody(input), dryRun: true }));
1863
1958
  if (r.dryRun !== true) throw new ValidationError("token: dryRun \u0445\u0430\u0440\u0438\u0443 \u0431\u0438\u0448 (CA dryRun-\u0438\u0439\u0433 \u0434\u044D\u043C\u0436\u0438\u0445\u0433\u04AF\u0439)");
1864
1959
  return { ...supersedesOf(r.supersedes) };
1865
1960
  }
@@ -1888,8 +1983,8 @@ var TokenApi = class {
1888
1983
  }
1889
1984
  /** Discovery-ийн `tokenCertificate` блок. Блок байхгүй (хуучин CA) бол `enabled: false`. */
1890
1985
  async certificateInfo() {
1891
- const d = rec4(await this.http.get(DISCOVERY_PATH));
1892
- const t = rec4(d.tokenCertificate);
1986
+ const d = rec5(await this.http.get(DISCOVERY_PATH));
1987
+ const t = rec5(d.tokenCertificate);
1893
1988
  return {
1894
1989
  enabled: t.enabled === true,
1895
1990
  issue: String(t.issue ?? ""),
@@ -1912,7 +2007,7 @@ var TokenApi = class {
1912
2007
  */
1913
2008
  async certificateResult(sessionId) {
1914
2009
  const raw = await this.http.get(routePath(RP_ROUTES.tokenCertificateResult, sessionId), TOKEN_RESULT_TIMEOUT_MS);
1915
- const r = rec4(raw);
2010
+ const r = rec5(raw);
1916
2011
  const item = (v) => v && typeof v === "object" ? v : null;
1917
2012
  return {
1918
2013
  status: String(r.status ?? ""),
@@ -1928,7 +2023,7 @@ var TokenApi = class {
1928
2023
  }
1929
2024
  /** POST /token/auth/challenge — энэ RP-д холбогдсон нэг удаагийн challenge (2 мин). */
1930
2025
  async authChallenge() {
1931
- const r = rec4(
2026
+ const r = rec5(
1932
2027
  await this.http.post(routePath(RP_ROUTES.tokenAuthChallenge), {
1933
2028
  relyingPartyUUID: this.creds.rpUUID,
1934
2029
  relyingPartyName: this.creds.rpName
@@ -1959,7 +2054,7 @@ var TokenApi = class {
1959
2054
  let leaf;
1960
2055
  let serial;
1961
2056
  try {
1962
- leaf = new X509Certificate3(certDer);
2057
+ leaf = new X509Certificate4(certDer);
1963
2058
  serial = parseSubject(leaf).serialNumber;
1964
2059
  } catch {
1965
2060
  throw new Error("token auth: \u0433\u044D\u0440\u0447\u0438\u043B\u0433\u044D\u044D \u0437\u0430\u0434\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439");
@@ -1982,12 +2077,12 @@ var TokenApi = class {
1982
2077
  certificate: Buffer.from(certDer).toString("base64"),
1983
2078
  signature: Buffer.from(signature).toString("base64")
1984
2079
  });
1985
- const r = rec4(raw);
1986
- if (rec4(r.result).endResult !== "OK") throw new ValidationError("token auth: endResult OK \u0431\u0438\u0448");
1987
- const id = rec4(r.identity);
2080
+ const r = rec5(raw);
2081
+ if (rec5(r.result).endResult !== "OK") throw new ValidationError("token auth: endResult OK \u0431\u0438\u0448");
2082
+ const id = rec5(r.identity);
1988
2083
  if (!id.etsi || id.etsi !== serial) throw new ValidationError("token auth: identity.etsi \u043D\u044C \u0433\u044D\u0440\u0447\u0438\u043B\u0433\u044D\u044D\u043D\u0438\u0439 SERIALNUMBER \u0431\u0438\u0448");
1989
- const org = rec4(r.organization);
1990
- const cert = rec4(r.cert);
2084
+ const org = rec5(r.organization);
2085
+ const cert = rec5(r.cert);
1991
2086
  return {
1992
2087
  identity: { etsi: String(id.etsi), givenName: String(id.givenName ?? ""), surname: String(id.surname ?? "") },
1993
2088
  serialHex: String(cert.serialHex ?? ""),
@@ -2033,7 +2128,7 @@ function verifyTokenCertificates(result, csrAuth, csrSign) {
2033
2128
  }
2034
2129
  let got;
2035
2130
  try {
2036
- got = new X509Certificate3(Buffer.from(item.certificate, "base64")).publicKey.export({ format: "der", type: "spki" });
2131
+ got = new X509Certificate4(Buffer.from(item.certificate, "base64")).publicKey.export({ format: "der", type: "spki" });
2037
2132
  } catch {
2038
2133
  throw new ValidationError(`token: ${name} \u0433\u044D\u0440\u0447\u0438\u043B\u0433\u044D\u044D \u0437\u0430\u0434\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439`);
2039
2134
  }
@@ -2052,7 +2147,7 @@ function tokenLimitOf(err) {
2052
2147
  if (!(err instanceof ApiError) || err.code !== "TOKEN_LIMIT_REACHED") return void 0;
2053
2148
  let b;
2054
2149
  try {
2055
- b = rec4(JSON.parse(err.body));
2150
+ b = rec5(JSON.parse(err.body));
2056
2151
  } catch {
2057
2152
  return void 0;
2058
2153
  }
@@ -2065,7 +2160,7 @@ function tokenLimitOf(err) {
2065
2160
  }
2066
2161
 
2067
2162
  // src/myqr.ts
2068
- import { X509Certificate as X509Certificate4, constants as constants2, createHash as createHash5, randomBytes as randomBytes2, verify as cryptoVerify } from "crypto";
2163
+ import { X509Certificate as X509Certificate5, constants as constants2, createHash as createHash5, randomBytes as randomBytes2, verify as cryptoVerify } from "crypto";
2069
2164
 
2070
2165
  // src/ocsp.ts
2071
2166
  import { createHash as createHash4 } from "crypto";
@@ -2266,7 +2361,7 @@ async function verifyQrPresentation(jws, expect, trust) {
2266
2361
  const der = stdBase64(c2);
2267
2362
  if (!der) throw badHeader("x5c base64 \u0431\u0438\u0448");
2268
2363
  try {
2269
- const cert = new X509Certificate4(der);
2364
+ const cert = new X509Certificate5(der);
2270
2365
  if (!cert.raw.equals(der)) throw new Error("trailing");
2271
2366
  return cert;
2272
2367
  } catch {
@@ -2560,6 +2655,8 @@ var EidClient = class {
2560
2655
  auth;
2561
2656
  sign;
2562
2657
  organization;
2658
+ /** Байгууллагын цахим тамга (e-Seal) — `SEAL:<orgEtsi>` эрх. */
2659
+ seal;
2563
2660
  person;
2564
2661
  token;
2565
2662
  /** «Миний QR» (биечлэн шалгах): parse → start → result / check. */
@@ -2584,6 +2681,7 @@ var EidClient = class {
2584
2681
  this.auth = new AuthApi(http, cfg.credentials, { certificateLevel: level });
2585
2682
  this.sign = new SignApi(http, cfg.credentials, { certificateLevel: level, sessionTtlMs: cfg.signSessionTtlMs, pdfTimeoutMs: cfg.pdfTimeoutMs });
2586
2683
  this.organization = new OrganizationApi(http);
2684
+ this.seal = new SealApi(http);
2587
2685
  this.person = new PersonApi(http);
2588
2686
  this.validator = new ResponseValidator(cfg.trust ?? {});
2589
2687
  this.token = new TokenApi(http, cfg.credentials, this.validator);
@@ -2628,7 +2726,7 @@ var PROTOCOL = { auth: "ACSP_V2", sign: "RAW_DIGEST_SIGNATURE", cert: "" };
2628
2726
  var TOKEN_RE2 = /^[A-Za-z0-9_-]+$/;
2629
2727
  var LANG_RE = /^[a-z]{3}$/;
2630
2728
  var STD_B64_RE2 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
2631
- var b642 = (s) => Buffer.from(s, "utf8").toString("base64");
2729
+ var b643 = (s) => Buffer.from(s, "utf8").toString("base64");
2632
2730
  var ms = (t) => t instanceof Date ? t.getTime() : t;
2633
2731
  function fail2(msg) {
2634
2732
  throw new DeviceLinkError(`buildDeviceLink: ${msg}`);
@@ -2673,8 +2771,8 @@ function buildDeviceLink(p) {
2673
2771
  p.schemeName ?? "smart-id",
2674
2772
  PROTOCOL[p.sessionType],
2675
2773
  challenge,
2676
- b642(p.relyingPartyName),
2677
- b642(p.brokeredRpName ?? ""),
2774
+ b643(p.relyingPartyName),
2775
+ b643(p.brokeredRpName ?? ""),
2678
2776
  p.interactions ?? "",
2679
2777
  callback,
2680
2778
  unprotected
@@ -3359,8 +3457,10 @@ export {
3359
3457
  RequestInvalidError,
3360
3458
  ResponseTooLargeError,
3361
3459
  ResponseValidator,
3460
+ SEAL_REQUEST_FIELDS,
3362
3461
  SHARE_ERROR_CODES,
3363
3462
  SHARE_FORM_FIELDS,
3463
+ SealApi,
3364
3464
  SessionApi,
3365
3465
  SessionFailedError,
3366
3466
  ShareError,
@@ -3382,6 +3482,7 @@ export {
3382
3482
  forwardedClientIp,
3383
3483
  interactionsToBase64,
3384
3484
  isMobileUserAgent,
3485
+ isSealCertificate,
3385
3486
  memoryLoginStore,
3386
3487
  ocspRevocationChecker,
3387
3488
  parseExpiresAt,