@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.
@@ -1,19 +1,3 @@
1
- import './errors-3JEfE-FW.cjs';
2
-
3
- /** isMobileUserAgent-ийн уншдаг navigator-ийн хэсэг (тестэд орлуулна). */
4
- interface NavigatorLike {
5
- userAgent?: string;
6
- maxTouchPoints?: number;
7
- userAgentData?: {
8
- mobile?: boolean;
9
- };
10
- }
11
- /**
12
- * Анхдагч гар утас/таблет илрүүлэгч: Android, iPhone/iPod/iPad, UA-CH `mobile`, мөн desktop UA
13
- * илгээдэг iPadOS (Macintosh + мэдрэгч дэлгэц, maxTouchPoints > 1).
14
- */
15
- declare function isMobileUserAgent(nav?: NavigatorLike): boolean;
16
-
17
1
  /** Сертификатын баталгаажуулалтын түвшин (eIDAS LoA). QUALIFIED — хууль ёсны гарын үсэгт. */
18
2
  type CertificateLevel = "ADVANCED" | "QUALIFIED" | "QSCD";
19
3
  /** Гарын үсгийн протокол: auth → ACSP_V2, sign → RAW_DIGEST_SIGNATURE (Smart-ID v3). */
@@ -204,9 +188,19 @@ interface SessionResult {
204
188
  person?: PersonBlock | null;
205
189
  /** USB токены гэрчилгээ олголтын session-ий `tokenCertificate` блок (`token.issueCertificate`); бусад урсгалд null. */
206
190
  tokenCertificate?: TokenCertSessionBlock | null;
191
+ /**
192
+ * «Миний QR» session-ий CA-ийн presentation (`qr.result` шалгана): `jws` (ES256) ба `claims` (payload-ийн хуулбар —
193
+ * ШАЛГААГҮЙ; итгэхдээ `qr.result` / `verifyQrPresentation`-ийн үр дүнг л хэрэглэ). Бусад урсгалд null.
194
+ */
195
+ presentation?: SessionPresentation | null;
207
196
  /** Серверийн хариуны түүхий JSON (`parseSessionResult`-ийн оролт) — SDK задлаагүй талбарт. */
208
197
  raw?: unknown;
209
198
  }
199
+ /** QR session-ий `presentation` блок. */
200
+ interface SessionPresentation {
201
+ jws: string;
202
+ claims?: Record<string, unknown>;
203
+ }
210
204
  /**
211
205
  * Session-ий `person` блок (CA `dto.PersonBlock`). Нэршил core.gerege.mn-тэй нэг мөр — гурван нэр ӨӨР ойлголт:
212
206
  * `firstName` = нэр, `lastName` = ЭЦГИЙН нэр (гэрчилгээнд ордог), `familyName` = УРГИЙН овог (гэрчилгээнд ОРОХГҮЙ).
@@ -274,6 +268,55 @@ interface Representation {
274
268
  validFrom: string;
275
269
  /** ISO 8601; байхгүй = хугацаагүй. */
276
270
  validTo?: string;
271
+ /** Байгууллагад тамганы зураг хадгалсан эсэх (хуучин CA-д байхгүй). */
272
+ stampImageSet?: boolean;
273
+ /**
274
+ * Тамганы зураг — зөвхөн SIGN эрхтэй RP-д, зураг байвал. PDF-д: `appearance.stampImage = stampImage.pdfImage`
275
+ * (`claimedRole`-той).
276
+ */
277
+ stampImage?: EidImage;
278
+ }
279
+ /**
280
+ * CA-ийн хадгалсан ил тод PNG — иргэний гарын үсгийн зураг (`person.signatureImage()`) эсвэл байгууллагын тамга
281
+ * (`Representation.stampImage`); CA docs/SIGNATURE_IMAGES.md.
282
+ */
283
+ interface EidImage {
284
+ /** base64 ил тод PNG. */
285
+ png: string;
286
+ /** PNG-ийн sha256, жижиг hex. */
287
+ sha256: string;
288
+ width: number;
289
+ height: number;
290
+ /** RFC 3339 (UTC). */
291
+ updatedAt?: string;
292
+ /**
293
+ * Харагдах гарын үсэгт шигтгэх «PDF зураг» — `appearance.signatureImage` / `stampImage`-д хэвээр өгнө; CA PNG-ийг
294
+ * хөрвүүлж чадаагүй (олон өнгө, alpha > 300 KiB) бол байхгүй.
295
+ */
296
+ pdfImage?: PdfImage;
297
+ }
298
+ /**
299
+ * A "PDF image" as the CA serves it (Go `pades.PDFImage`, APPEARANCE_SPEC.md §6.1): one ink colour + an 8-bit alpha
300
+ * channel. The SDK writes `alpha` into the PDF verbatim (/SMask, /FlateDecode) — nothing is compressed at runtime, so
301
+ * every SDK writes the same bytes. Not a PNG.
302
+ */
303
+ interface PdfImage {
304
+ /** px, 1…1600. */
305
+ width: number;
306
+ /** px, 1…1600. */
307
+ height: number;
308
+ /** Ink colour `[r, g, b]`, 0…255. */
309
+ color: [number, number, number];
310
+ /**
311
+ * Standard base64 of a zlib stream (RFC 1950, no preset dictionary, nothing after the Adler-32) inflating to exactly
312
+ * `width·height` bytes, rows top-down, no PNG filter bytes; ≤ 300 KiB decoded.
313
+ */
314
+ alpha: string;
315
+ /**
316
+ * Lowercase hex SHA-256 of the PNG the CA stores; not written into the PDF — carried to the registration
317
+ * (`PadesCompleted.images` → `registrationFromCompleted` → `images`).
318
+ */
319
+ sha256: string;
277
320
  }
278
321
  /** GET /organization/representations/etsi/{personEtsi} хариу. */
279
322
  interface RepresentationsResponse {
@@ -309,4 +352,4 @@ interface RpCredentials {
309
352
  apiSecret: string;
310
353
  }
311
354
 
312
- export { type AcspContext as A, type CertificateLevel as C, type DeviceLinkSession as D, type EndResult as E, type FlowType as F, type HashAlgorithm as H, type Interaction as I, type NotificationSession as N, type OrgResult as O, type PersonBlock as P, type RpCredentials as R, type SignatureAlgorithm as S, type TokenCertSessionBlock as T, type SessionResult as a, type RepresentationsResponse as b, DEFAULT_SIGN_SESSION_TTL_MS as c, type NavigatorLike as d, type Representation as e, type SessionState as f, type SignContext as g, type SignatureAlgorithmParameters as h, type SignatureProtocol as i, type TokenCertStatus as j, isMobileUserAgent as k, startExpiry as l, parseExpiresAt as p, sessionExpiry as s };
355
+ export { type AcspContext as A, type CertificateLevel as C, type DeviceLinkSession as D, type EidImage as E, type FlowType as F, type HashAlgorithm as H, type Interaction as I, type NotificationSession as N, type OrgResult as O, type PdfImage as P, type RpCredentials as R, type SignatureAlgorithm as S, type TokenCertSessionBlock as T, type SessionResult as a, type PersonBlock as b, type RepresentationsResponse as c, DEFAULT_SIGN_SESSION_TTL_MS as d, type EndResult as e, type Representation as f, type SessionPresentation as g, type SessionState as h, type SignContext as i, type SignatureAlgorithmParameters as j, type SignatureProtocol as k, type TokenCertStatus as l, startExpiry as m, parseExpiresAt as p, sessionExpiry as s };
@@ -1,19 +1,3 @@
1
- import './errors-3JEfE-FW.js';
2
-
3
- /** isMobileUserAgent-ийн уншдаг navigator-ийн хэсэг (тестэд орлуулна). */
4
- interface NavigatorLike {
5
- userAgent?: string;
6
- maxTouchPoints?: number;
7
- userAgentData?: {
8
- mobile?: boolean;
9
- };
10
- }
11
- /**
12
- * Анхдагч гар утас/таблет илрүүлэгч: Android, iPhone/iPod/iPad, UA-CH `mobile`, мөн desktop UA
13
- * илгээдэг iPadOS (Macintosh + мэдрэгч дэлгэц, maxTouchPoints > 1).
14
- */
15
- declare function isMobileUserAgent(nav?: NavigatorLike): boolean;
16
-
17
1
  /** Сертификатын баталгаажуулалтын түвшин (eIDAS LoA). QUALIFIED — хууль ёсны гарын үсэгт. */
18
2
  type CertificateLevel = "ADVANCED" | "QUALIFIED" | "QSCD";
19
3
  /** Гарын үсгийн протокол: auth → ACSP_V2, sign → RAW_DIGEST_SIGNATURE (Smart-ID v3). */
@@ -204,9 +188,19 @@ interface SessionResult {
204
188
  person?: PersonBlock | null;
205
189
  /** USB токены гэрчилгээ олголтын session-ий `tokenCertificate` блок (`token.issueCertificate`); бусад урсгалд null. */
206
190
  tokenCertificate?: TokenCertSessionBlock | null;
191
+ /**
192
+ * «Миний QR» session-ий CA-ийн presentation (`qr.result` шалгана): `jws` (ES256) ба `claims` (payload-ийн хуулбар —
193
+ * ШАЛГААГҮЙ; итгэхдээ `qr.result` / `verifyQrPresentation`-ийн үр дүнг л хэрэглэ). Бусад урсгалд null.
194
+ */
195
+ presentation?: SessionPresentation | null;
207
196
  /** Серверийн хариуны түүхий JSON (`parseSessionResult`-ийн оролт) — SDK задлаагүй талбарт. */
208
197
  raw?: unknown;
209
198
  }
199
+ /** QR session-ий `presentation` блок. */
200
+ interface SessionPresentation {
201
+ jws: string;
202
+ claims?: Record<string, unknown>;
203
+ }
210
204
  /**
211
205
  * Session-ий `person` блок (CA `dto.PersonBlock`). Нэршил core.gerege.mn-тэй нэг мөр — гурван нэр ӨӨР ойлголт:
212
206
  * `firstName` = нэр, `lastName` = ЭЦГИЙН нэр (гэрчилгээнд ордог), `familyName` = УРГИЙН овог (гэрчилгээнд ОРОХГҮЙ).
@@ -274,6 +268,55 @@ interface Representation {
274
268
  validFrom: string;
275
269
  /** ISO 8601; байхгүй = хугацаагүй. */
276
270
  validTo?: string;
271
+ /** Байгууллагад тамганы зураг хадгалсан эсэх (хуучин CA-д байхгүй). */
272
+ stampImageSet?: boolean;
273
+ /**
274
+ * Тамганы зураг — зөвхөн SIGN эрхтэй RP-д, зураг байвал. PDF-д: `appearance.stampImage = stampImage.pdfImage`
275
+ * (`claimedRole`-той).
276
+ */
277
+ stampImage?: EidImage;
278
+ }
279
+ /**
280
+ * CA-ийн хадгалсан ил тод PNG — иргэний гарын үсгийн зураг (`person.signatureImage()`) эсвэл байгууллагын тамга
281
+ * (`Representation.stampImage`); CA docs/SIGNATURE_IMAGES.md.
282
+ */
283
+ interface EidImage {
284
+ /** base64 ил тод PNG. */
285
+ png: string;
286
+ /** PNG-ийн sha256, жижиг hex. */
287
+ sha256: string;
288
+ width: number;
289
+ height: number;
290
+ /** RFC 3339 (UTC). */
291
+ updatedAt?: string;
292
+ /**
293
+ * Харагдах гарын үсэгт шигтгэх «PDF зураг» — `appearance.signatureImage` / `stampImage`-д хэвээр өгнө; CA PNG-ийг
294
+ * хөрвүүлж чадаагүй (олон өнгө, alpha > 300 KiB) бол байхгүй.
295
+ */
296
+ pdfImage?: PdfImage;
297
+ }
298
+ /**
299
+ * A "PDF image" as the CA serves it (Go `pades.PDFImage`, APPEARANCE_SPEC.md §6.1): one ink colour + an 8-bit alpha
300
+ * channel. The SDK writes `alpha` into the PDF verbatim (/SMask, /FlateDecode) — nothing is compressed at runtime, so
301
+ * every SDK writes the same bytes. Not a PNG.
302
+ */
303
+ interface PdfImage {
304
+ /** px, 1…1600. */
305
+ width: number;
306
+ /** px, 1…1600. */
307
+ height: number;
308
+ /** Ink colour `[r, g, b]`, 0…255. */
309
+ color: [number, number, number];
310
+ /**
311
+ * Standard base64 of a zlib stream (RFC 1950, no preset dictionary, nothing after the Adler-32) inflating to exactly
312
+ * `width·height` bytes, rows top-down, no PNG filter bytes; ≤ 300 KiB decoded.
313
+ */
314
+ alpha: string;
315
+ /**
316
+ * Lowercase hex SHA-256 of the PNG the CA stores; not written into the PDF — carried to the registration
317
+ * (`PadesCompleted.images` → `registrationFromCompleted` → `images`).
318
+ */
319
+ sha256: string;
277
320
  }
278
321
  /** GET /organization/representations/etsi/{personEtsi} хариу. */
279
322
  interface RepresentationsResponse {
@@ -309,4 +352,4 @@ interface RpCredentials {
309
352
  apiSecret: string;
310
353
  }
311
354
 
312
- export { type AcspContext as A, type CertificateLevel as C, type DeviceLinkSession as D, type EndResult as E, type FlowType as F, type HashAlgorithm as H, type Interaction as I, type NotificationSession as N, type OrgResult as O, type PersonBlock as P, type RpCredentials as R, type SignatureAlgorithm as S, type TokenCertSessionBlock as T, type SessionResult as a, type RepresentationsResponse as b, DEFAULT_SIGN_SESSION_TTL_MS as c, type NavigatorLike as d, type Representation as e, type SessionState as f, type SignContext as g, type SignatureAlgorithmParameters as h, type SignatureProtocol as i, type TokenCertStatus as j, isMobileUserAgent as k, startExpiry as l, parseExpiresAt as p, sessionExpiry as s };
355
+ export { type AcspContext as A, type CertificateLevel as C, type DeviceLinkSession as D, type EidImage as E, type FlowType as F, type HashAlgorithm as H, type Interaction as I, type NotificationSession as N, type OrgResult as O, type PdfImage as P, type RpCredentials as R, type SignatureAlgorithm as S, type TokenCertSessionBlock as T, type SessionResult as a, type PersonBlock as b, type RepresentationsResponse as c, DEFAULT_SIGN_SESSION_TTL_MS as d, type EndResult as e, type Representation as f, type SessionPresentation as g, type SessionState as h, type SignContext as i, type SignatureAlgorithmParameters as j, type SignatureProtocol as k, type TokenCertStatus as l, startExpiry as m, parseExpiresAt as p, sessionExpiry as s };
@@ -1,4 +1,4 @@
1
- import { E as EidError } from './errors-3JEfE-FW.cjs';
1
+ import { E as EidError } from './errors-mcDbKiz_.cjs';
2
2
  import { F as FetchFn } from './fetch-BjfH46q9.cjs';
3
3
 
4
4
  type Indication = "valid" | "invalid" | "indeterminate";
@@ -1,4 +1,4 @@
1
- import { E as EidError } from './errors-3JEfE-FW.js';
1
+ import { E as EidError } from './errors-mcDbKiz_.js';
2
2
  import { F as FetchFn } from './fetch-BjfH46q9.js';
3
3
 
4
4
  type Indication = "valid" | "invalid" | "indeterminate";
package/dist/validate.js CHANGED
@@ -66,7 +66,7 @@ import {
66
66
  } from "./chunk-ISTWNY6N.js";
67
67
  import {
68
68
  EidError
69
- } from "./chunk-R73IR6OH.js";
69
+ } from "./chunk-TNXO4QLU.js";
70
70
 
71
71
  // src/pades/validate/evaluate.ts
72
72
  var PROBLEMS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gerege-systems/eid-mongolia-sdk",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "description": "e-ID Mongolia Relying Party SDK — иргэнээр утсаар нь нэвтрэлт ба хууль ёсны цахим гарын үсэг (RP-API v3, Smart-ID нийцтэй).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsup src/index.ts src/browser.ts src/pades.ts src/validate.ts --format esm,cjs --dts --clean && tsup src/button.ts --format esm,cjs --dts --tsconfig tsconfig.button.json && tsup src/convert.ts --format esm --dts --tsconfig tsconfig.button.json",
52
- "test": "npm run build && node --test --experimental-strip-types test/sdk.test.ts test/portal-gaps.test.ts test/chain.test.ts test/qr.test.ts test/login.test.ts test/button.test.ts test/sign-gaps.test.ts test/session-start.test.ts test/pades-session.test.ts test/pades-golden.test.ts test/pades-placement.test.ts test/pades-unit.test.ts test/convert.test.ts test/share.test.ts test/validate-golden.test.ts test/validate-revisions.test.ts test/validate-env.test.ts test/pades-revocation.test.ts test/pades-encrypt.test.ts test/pades-objstm.test.ts test/validate-fuzz.test.ts test/pades-lexer-loop.test.ts",
52
+ "test": "npm run build && node --test --experimental-strip-types test/sdk.test.ts test/portal-gaps.test.ts test/chain.test.ts test/qr.test.ts test/myqr.test.ts test/login.test.ts test/button.test.ts test/sign-gaps.test.ts test/session-start.test.ts test/pades-session.test.ts test/pades-golden.test.ts test/pades-placement.test.ts test/pades-unit.test.ts test/convert.test.ts test/share.test.ts test/validate-golden.test.ts test/validate-revisions.test.ts test/validate-env.test.ts test/pades-revocation.test.ts test/pades-encrypt.test.ts test/pades-objstm.test.ts test/validate-fuzz.test.ts test/pades-lexer-loop.test.ts",
53
53
  "test:contract": "npm run build && node --experimental-strip-types test/contract.test.ts",
54
54
  "lint": "tsc --noEmit && tsc --noEmit -p tsconfig.button.json",
55
55
  "golden:check": "node scripts/sync-pades-golden.mjs --check",