@gerege-systems/eid-mongolia-sdk 0.33.0 → 0.34.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 CHANGED
@@ -980,7 +980,11 @@ try {
980
980
  `sid` = session, `nonce` = таны nonce (өгөөгүй бол SDK-ийн rpChallenge), `iat` ≤ одоо+60 с ба ≥ одоо−10 мин,
981
981
  `attrs` ∪ `unavailable` = хүссэн аттрибутууд яг (илүү/дутуу → татгалзана), аттрибут бүрийн төрөл (bool, E.164,
982
982
  YYYY-MM-DD, {surname, givenName}). Токен нэг удаагийн, 120 с; хариунд гэрчилгээ, person блок, иргэний дугаар
983
- (`civil_id` хүсээгүй бол) ирэхгүй. `sub` — энэ RP-д зориулсан тогтмол pairwise id. CA-ийн бусад код (`code`): 400 `REQUEST_INVALID` (үл мэдэгдэх талбар ч), 403 `PERMISSION_DENIED` / `RP_REQUIRED`, 429 `RATE_LIMITED`, 503 `QR_UNAVAILABLE` (түр), 410 `QR_PRESENTATION_EXPIRED` (session-ийн үр дүнг иргэн зөвшөөрснөөс хойш 10 минутын дотор л уншина), 410 `QR_SUBJECT_GONE` (ховор); RP-ийн эрх уншилт бүрд дахин шалгагдана (хураагдвал 403). `aud` том/жижиг үсэг ялгахгүй тулгана (CA жижиг үсгээр бичнэ). `qr` тохиргоо (`jwksUrl`, `issuer`, `jwksCacheTtlMs`, `maxAgeMs`) — тест орчинд л. Хадгалсан JWS-ийг
983
+ (`civil_id` хүсээгүй бол) ирэхгүй. `sub` — энэ RP-д зориулсан тогтмол pairwise id. **Polling UI** (0.34.0+): `eid.qr.check(s)` — нэг удаа шалгана → `{ state: "RUNNING" }` эсвэл `{ state: "COMPLETE",
984
+ presentation }`. `result`-ийн `maxWaitMs` дуусахад иргэн хараахан хариулаагүй бол `QrError` `QR_PENDING` (дахин дуудаж болно);
985
+ CA-ийн жинхэнэ хугацаа дуусалт нь `SessionFailedError` `TIMEOUT`.
986
+
987
+ CA-ийн бусад код (`code`): 400 `REQUEST_INVALID` (үл мэдэгдэх талбар ч), 403 `PERMISSION_DENIED` / `RP_REQUIRED`, 429 `RATE_LIMITED`, 503 `QR_UNAVAILABLE` (түр), 410 `QR_PRESENTATION_EXPIRED` (session-ийн үр дүнг иргэн зөвшөөрснөөс хойш 10 минутын дотор л уншина), 410 `QR_SUBJECT_GONE` (ховор); RP-ийн эрх уншилт бүрд дахин шалгагдана (хураагдвал 403). `aud` том/жижиг үсэг ялгахгүй тулгана (CA жижиг үсгээр бичнэ). `qr` тохиргоо (`jwksUrl`, `issuer`, `jwksCacheTtlMs`, `maxAgeMs`) — тест орчинд л. Хадгалсан JWS-ийг
984
988
  сүлжээгүй дахин шалгах: `verifyQrPresentation(jws, jwks, expect)`.
985
989
 
986
990
  ## 4. QR ба ижил төхөөрөмж — device link v3
package/dist/index.cjs CHANGED
@@ -2311,7 +2311,8 @@ var QR_ERROR_CODES = [
2311
2311
  "QR_TOKEN_INVALID",
2312
2312
  "QR_ATTRIBUTES_INVALID",
2313
2313
  "QR_PRESENTATION_INVALID",
2314
- "QR_JWKS_UNAVAILABLE"
2314
+ "QR_JWKS_UNAVAILABLE",
2315
+ "QR_PENDING"
2315
2316
  ];
2316
2317
  var QrError = class extends EidError {
2317
2318
  constructor(code, reason) {
@@ -2524,7 +2525,21 @@ var QrApi = class {
2524
2525
  async result(session, opts) {
2525
2526
  if (!session?.sessionId) throw new EidError("qr.result: QrSession \u0448\u0430\u0430\u0440\u0434\u043B\u0430\u0433\u0430\u0442\u0430\u0439");
2526
2527
  const r = await this.d.session.waitForResult(session.sessionId, { expiresAt: session.expiresAt, ...opts });
2527
- if (r.state !== "COMPLETE") throw new SessionFailedError("TIMEOUT");
2528
+ if (r.state !== "COMPLETE") throw new QrError("QR_PENDING", "\u0438\u0440\u0433\u044D\u043D \u0445\u0430\u0440\u0430\u0430\u0445\u0430\u043D \u0445\u0430\u0440\u0438\u0443\u043B\u0430\u0430\u0433\u04AF\u0439");
2529
+ return this.finish(r, session);
2530
+ }
2531
+ /**
2532
+ * Нэг удаагийн шалгалт (polling UI-д): `GET /session/{id}` (`serverPollMs` хүртэл, анхдагч 1000 мс) — иргэн хараахан
2533
+ * хариулаагүй бол `{ state: "RUNNING" }`, зөвшөөрсөн бол JWS/JWKS-ээр шалгасан `{ state: "COMPLETE", presentation }`.
2534
+ * Татгалзсан / CA-ийн хугацаа дууссан бол SessionFailedError; бусад алдаа {@link result}-тэй ижил.
2535
+ */
2536
+ async check(session, opts) {
2537
+ if (!session?.sessionId) throw new EidError("qr.check: QrSession \u0448\u0430\u0430\u0440\u0434\u043B\u0430\u0433\u0430\u0442\u0430\u0439");
2538
+ const r = await this.d.session.poll(session.sessionId, opts?.serverPollMs ?? 1e3);
2539
+ if (r.state !== "COMPLETE") return { state: "RUNNING" };
2540
+ return { state: "COMPLETE", presentation: await this.finish(r, session) };
2541
+ }
2542
+ finish(r, session) {
2528
2543
  if (r.endResult !== "OK") throw new SessionFailedError(r.endResult ?? "UNKNOWN");
2529
2544
  const jws = r.presentation?.jws;
2530
2545
  if (!jws) throw bad("\u0445\u0430\u0440\u0438\u0443\u043D\u0434 presentation \u0430\u043B\u0433\u0430");
package/dist/index.d.cts CHANGED
@@ -1159,8 +1159,10 @@ declare const QR_CLOCK_SKEW_MS = 60000;
1159
1159
  * - `QR_ATTRIBUTES_INVALID` — аттрибут хоосон / каталогид алга / давхардсан (клиент талын, CA руу явахгүй)
1160
1160
  * - `QR_PRESENTATION_INVALID` — JWS шалгалт унасан — хариунд ИТГЭХГҮЙ
1161
1161
  * - `QR_JWKS_UNAVAILABLE` — CA-ийн JWKS татагдсангүй (түр; дахин оролдож болно)
1162
+ * - `QR_PENDING` — `qr.result`-ийн хүлээх хугацаа (`maxWaitMs`) дууссан ч иргэн хараахан хариулаагүй (CA-ийн session
1163
+ * идэвхтэй хэвээр) — дахин `result` / `check` дуудаж болно. CA-ийн жинхэнэ хугацаа дуусалт = SessionFailedError TIMEOUT.
1162
1164
  */
1163
- declare const QR_ERROR_CODES: readonly ["QR_FORMAT_INVALID", "QR_TOKEN_INVALID", "QR_ATTRIBUTES_INVALID", "QR_PRESENTATION_INVALID", "QR_JWKS_UNAVAILABLE"];
1165
+ declare const QR_ERROR_CODES: readonly ["QR_FORMAT_INVALID", "QR_TOKEN_INVALID", "QR_ATTRIBUTES_INVALID", "QR_PRESENTATION_INVALID", "QR_JWKS_UNAVAILABLE", "QR_PENDING"];
1164
1166
  type QrErrorCode = (typeof QR_ERROR_CODES)[number];
1165
1167
  /** «Миний QR»-ийн клиент талын алдаа. */
1166
1168
  declare class QrError extends EidError {
@@ -1220,6 +1222,13 @@ interface QrPresentation {
1220
1222
  /** Түүхий compact JWS (аудитад хадгалж болно). */
1221
1223
  jws: string;
1222
1224
  }
1225
+ /** `qr.check`-ийн хариу: иргэн хараахан хариулаагүй, эсвэл шалгагдсан presentation. */
1226
+ type QrCheck = {
1227
+ state: "RUNNING";
1228
+ } | {
1229
+ state: "COMPLETE";
1230
+ presentation: QrPresentation;
1231
+ };
1223
1232
  interface QrExpect {
1224
1233
  issuer?: string;
1225
1234
  /** RP UUID. */
@@ -1283,6 +1292,15 @@ declare class QrApi {
1283
1292
  maxWaitMs?: number;
1284
1293
  serverPollMs?: number;
1285
1294
  }): Promise<QrPresentation>;
1295
+ /**
1296
+ * Нэг удаагийн шалгалт (polling UI-д): `GET /session/{id}` (`serverPollMs` хүртэл, анхдагч 1000 мс) — иргэн хараахан
1297
+ * хариулаагүй бол `{ state: "RUNNING" }`, зөвшөөрсөн бол JWS/JWKS-ээр шалгасан `{ state: "COMPLETE", presentation }`.
1298
+ * Татгалзсан / CA-ийн хугацаа дууссан бол SessionFailedError; бусад алдаа {@link result}-тэй ижил.
1299
+ */
1300
+ check(session: QrSession, opts?: {
1301
+ serverPollMs?: number;
1302
+ }): Promise<QrCheck>;
1303
+ private finish;
1286
1304
  /** Хадгалсан presentation JWS-ийг QrSession-тэй тулгаж шалгана (JWKS кэш; танихгүй kid → нэг удаа дахин татна). */
1287
1305
  verify(jws: string, session: QrSession): Promise<QrPresentation>;
1288
1306
  private keys;
@@ -1841,4 +1859,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
1841
1859
  */
1842
1860
  declare function createEidLogin(opts: EidLoginOptions): EidLogin;
1843
1861
 
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 };
1862
+ 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 QrCheck, 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
@@ -1159,8 +1159,10 @@ declare const QR_CLOCK_SKEW_MS = 60000;
1159
1159
  * - `QR_ATTRIBUTES_INVALID` — аттрибут хоосон / каталогид алга / давхардсан (клиент талын, CA руу явахгүй)
1160
1160
  * - `QR_PRESENTATION_INVALID` — JWS шалгалт унасан — хариунд ИТГЭХГҮЙ
1161
1161
  * - `QR_JWKS_UNAVAILABLE` — CA-ийн JWKS татагдсангүй (түр; дахин оролдож болно)
1162
+ * - `QR_PENDING` — `qr.result`-ийн хүлээх хугацаа (`maxWaitMs`) дууссан ч иргэн хараахан хариулаагүй (CA-ийн session
1163
+ * идэвхтэй хэвээр) — дахин `result` / `check` дуудаж болно. CA-ийн жинхэнэ хугацаа дуусалт = SessionFailedError TIMEOUT.
1162
1164
  */
1163
- declare const QR_ERROR_CODES: readonly ["QR_FORMAT_INVALID", "QR_TOKEN_INVALID", "QR_ATTRIBUTES_INVALID", "QR_PRESENTATION_INVALID", "QR_JWKS_UNAVAILABLE"];
1165
+ declare const QR_ERROR_CODES: readonly ["QR_FORMAT_INVALID", "QR_TOKEN_INVALID", "QR_ATTRIBUTES_INVALID", "QR_PRESENTATION_INVALID", "QR_JWKS_UNAVAILABLE", "QR_PENDING"];
1164
1166
  type QrErrorCode = (typeof QR_ERROR_CODES)[number];
1165
1167
  /** «Миний QR»-ийн клиент талын алдаа. */
1166
1168
  declare class QrError extends EidError {
@@ -1220,6 +1222,13 @@ interface QrPresentation {
1220
1222
  /** Түүхий compact JWS (аудитад хадгалж болно). */
1221
1223
  jws: string;
1222
1224
  }
1225
+ /** `qr.check`-ийн хариу: иргэн хараахан хариулаагүй, эсвэл шалгагдсан presentation. */
1226
+ type QrCheck = {
1227
+ state: "RUNNING";
1228
+ } | {
1229
+ state: "COMPLETE";
1230
+ presentation: QrPresentation;
1231
+ };
1223
1232
  interface QrExpect {
1224
1233
  issuer?: string;
1225
1234
  /** RP UUID. */
@@ -1283,6 +1292,15 @@ declare class QrApi {
1283
1292
  maxWaitMs?: number;
1284
1293
  serverPollMs?: number;
1285
1294
  }): Promise<QrPresentation>;
1295
+ /**
1296
+ * Нэг удаагийн шалгалт (polling UI-д): `GET /session/{id}` (`serverPollMs` хүртэл, анхдагч 1000 мс) — иргэн хараахан
1297
+ * хариулаагүй бол `{ state: "RUNNING" }`, зөвшөөрсөн бол JWS/JWKS-ээр шалгасан `{ state: "COMPLETE", presentation }`.
1298
+ * Татгалзсан / CA-ийн хугацаа дууссан бол SessionFailedError; бусад алдаа {@link result}-тэй ижил.
1299
+ */
1300
+ check(session: QrSession, opts?: {
1301
+ serverPollMs?: number;
1302
+ }): Promise<QrCheck>;
1303
+ private finish;
1286
1304
  /** Хадгалсан presentation JWS-ийг QrSession-тэй тулгаж шалгана (JWKS кэш; танихгүй kid → нэг удаа дахин татна). */
1287
1305
  verify(jws: string, session: QrSession): Promise<QrPresentation>;
1288
1306
  private keys;
@@ -1841,4 +1859,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
1841
1859
  */
1842
1860
  declare function createEidLogin(opts: EidLoginOptions): EidLogin;
1843
1861
 
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 };
1862
+ 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 QrCheck, 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.js CHANGED
@@ -2056,7 +2056,8 @@ var QR_ERROR_CODES = [
2056
2056
  "QR_TOKEN_INVALID",
2057
2057
  "QR_ATTRIBUTES_INVALID",
2058
2058
  "QR_PRESENTATION_INVALID",
2059
- "QR_JWKS_UNAVAILABLE"
2059
+ "QR_JWKS_UNAVAILABLE",
2060
+ "QR_PENDING"
2060
2061
  ];
2061
2062
  var QrError = class extends EidError {
2062
2063
  constructor(code, reason) {
@@ -2269,7 +2270,21 @@ var QrApi = class {
2269
2270
  async result(session, opts) {
2270
2271
  if (!session?.sessionId) throw new EidError("qr.result: QrSession \u0448\u0430\u0430\u0440\u0434\u043B\u0430\u0433\u0430\u0442\u0430\u0439");
2271
2272
  const r = await this.d.session.waitForResult(session.sessionId, { expiresAt: session.expiresAt, ...opts });
2272
- if (r.state !== "COMPLETE") throw new SessionFailedError("TIMEOUT");
2273
+ if (r.state !== "COMPLETE") throw new QrError("QR_PENDING", "\u0438\u0440\u0433\u044D\u043D \u0445\u0430\u0440\u0430\u0430\u0445\u0430\u043D \u0445\u0430\u0440\u0438\u0443\u043B\u0430\u0430\u0433\u04AF\u0439");
2274
+ return this.finish(r, session);
2275
+ }
2276
+ /**
2277
+ * Нэг удаагийн шалгалт (polling UI-д): `GET /session/{id}` (`serverPollMs` хүртэл, анхдагч 1000 мс) — иргэн хараахан
2278
+ * хариулаагүй бол `{ state: "RUNNING" }`, зөвшөөрсөн бол JWS/JWKS-ээр шалгасан `{ state: "COMPLETE", presentation }`.
2279
+ * Татгалзсан / CA-ийн хугацаа дууссан бол SessionFailedError; бусад алдаа {@link result}-тэй ижил.
2280
+ */
2281
+ async check(session, opts) {
2282
+ if (!session?.sessionId) throw new EidError("qr.check: QrSession \u0448\u0430\u0430\u0440\u0434\u043B\u0430\u0433\u0430\u0442\u0430\u0439");
2283
+ const r = await this.d.session.poll(session.sessionId, opts?.serverPollMs ?? 1e3);
2284
+ if (r.state !== "COMPLETE") return { state: "RUNNING" };
2285
+ return { state: "COMPLETE", presentation: await this.finish(r, session) };
2286
+ }
2287
+ finish(r, session) {
2273
2288
  if (r.endResult !== "OK") throw new SessionFailedError(r.endResult ?? "UNKNOWN");
2274
2289
  const jws = r.presentation?.jws;
2275
2290
  if (!jws) throw bad("\u0445\u0430\u0440\u0438\u0443\u043D\u0434 presentation \u0430\u043B\u0433\u0430");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gerege-systems/eid-mongolia-sdk",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "description": "e-ID Mongolia Relying Party SDK — иргэнээр утсаар нь нэвтрэлт ба хууль ёсны цахим гарын үсэг (RP-API v3, Smart-ID нийцтэй).",
5
5
  "license": "MIT",
6
6
  "type": "module",