@gerege-systems/eid-mongolia-sdk 0.34.0 → 0.35.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 +2 -27
- package/dist/{types-Cf3GT4wh.d.cts → browser-CCP--VGv.d.ts} +17 -50
- package/dist/{types-Cf3GT4wh.d.ts → browser-w1Ca6FdZ.d.cts} +17 -50
- package/dist/browser.d.cts +2 -18
- package/dist/browser.d.ts +2 -18
- package/dist/browser.js +1 -1
- package/dist/{chunk-M4NS4UFP.js → chunk-MA4RMWBO.js} +13 -102
- package/dist/{chunk-TNXO4QLU.js → chunk-PWFTN52X.js} +0 -1
- package/dist/{errors-mcDbKiz_.d.cts → errors-CgJcEjrZ.d.cts} +2 -2
- package/dist/{errors-mcDbKiz_.d.ts → errors-CgJcEjrZ.d.ts} +2 -2
- package/dist/index.cjs +1 -24
- package/dist/index.d.cts +7 -29
- package/dist/index.d.ts +7 -29
- package/dist/index.js +2 -24
- package/dist/pades.cjs +20 -169
- package/dist/pades.d.cts +2 -44
- package/dist/pades.d.ts +2 -44
- package/dist/pades.js +9 -71
- package/dist/validate.cjs +15 -150
- package/dist/validate.d.cts +1 -1
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +5 -35
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
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,
|
|
2
|
-
export {
|
|
3
|
-
import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-
|
|
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-
|
|
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-w1Ca6FdZ.cjs';
|
|
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-w1Ca6FdZ.cjs';
|
|
3
|
+
import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-CgJcEjrZ.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-CgJcEjrZ.cjs';
|
|
5
5
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
6
|
-
export { NavigatorLike, isMobileUserAgent } from './browser.cjs';
|
|
7
6
|
|
|
8
7
|
interface HttpConfig {
|
|
9
8
|
/** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
|
|
@@ -220,18 +219,6 @@ interface RegisterSignatureInput {
|
|
|
220
219
|
onBehalfOf?: string;
|
|
221
220
|
/** Заавал биш (`PNOMN-…`): ирвэл CMS-ийн зурагчийн SERIALNUMBER-тэй тэнцүү (эс бөгөөс 409 `SIGNER_MISMATCH`). */
|
|
222
221
|
signerEtsi?: string;
|
|
223
|
-
/**
|
|
224
|
-
* `complete().images` (0.31.0+) — харагдах дүрслэлд шигтгэсэн зураг бүрийн `{kind, sha256}` (pades APPEARANCE_SPEC.md
|
|
225
|
-
* §6.6): CA зурагчийн/байгууллагын хадгалсан PNG-тэй тулгана. Зураггүй бол илгээхгүй.
|
|
226
|
-
*/
|
|
227
|
-
images?: PdfSignatureImage[];
|
|
228
|
-
}
|
|
229
|
-
/** {@link RegisterSignatureInput.images}-ийн нэг мөр (Go `eid.PDFSignatureImage`). */
|
|
230
|
-
interface PdfSignatureImage {
|
|
231
|
-
/** `signature` — иргэний гарын үсгийн зураг; `stamp` — байгууллагын тамганы зураг. */
|
|
232
|
-
kind: "signature" | "stamp";
|
|
233
|
-
/** CA-ийн хадгалсан PNG-ийн SHA-256 (64 жижиг hex). */
|
|
234
|
-
sha256: string;
|
|
235
222
|
}
|
|
236
223
|
/** Өмнөх нэг гарын үсгийн хоёр түлхүүр ({@link RegisterSignatureInput.priorSignatures}). */
|
|
237
224
|
interface PriorSignature {
|
|
@@ -255,8 +242,6 @@ interface CompletedForRegistration {
|
|
|
255
242
|
priorRevisionSha256?: string[];
|
|
256
243
|
/** `complete().claimedRole` (0.27.0+) — хоосон биш бол `onBehalfOf` заавал. */
|
|
257
244
|
claimedRole?: string;
|
|
258
|
-
/** `complete().images` (0.31.0+) — байвал `images` болж илгээгдэнэ. */
|
|
259
|
-
images?: PdfSignatureImage[];
|
|
260
245
|
}
|
|
261
246
|
/**
|
|
262
247
|
* `pades.complete()`-ийн үр дүнгээс `registerSignature`-ийн биеийг бөглөнө (`hasPage`-ийг илгээхгүй — CA `revIndex`-ээс
|
|
@@ -578,12 +563,6 @@ declare class PersonApi {
|
|
|
578
563
|
summary(personEtsi: string): Promise<PersonSummary>;
|
|
579
564
|
/** Асран хамгаалж буй хүүхдүүд (зөвхөн унших). */
|
|
580
565
|
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>;
|
|
587
566
|
}
|
|
588
567
|
|
|
589
568
|
/** Задалсан subject. Cert-д байхгүй талбар — undefined. Давхардсан OID-ийн эхнийх нь. */
|
|
@@ -1470,11 +1449,10 @@ declare class EidClient {
|
|
|
1470
1449
|
|
|
1471
1450
|
/**
|
|
1472
1451
|
* `POST /pdf/signatures`-ийн биеийн талбарууд — CA `server/internal/dto/pdf.go` `PDFSignatureRegisterRequest`-ийн JSON
|
|
1473
|
-
* tag (CA main d948fdd4, !355
|
|
1474
|
-
* тул SDK зөвхөн эдгээрийг илгээнэ. Live discovery-ийн
|
|
1452
|
+
* tag (CA main d948fdd4, !355). CA `DisallowUnknownFields` тул SDK зөвхөн эдгээрийг илгээнэ. Live discovery-ийн
|
|
1475
1453
|
* `endpoints.pdf.signatures` тайлбартай гэрээний тест тулгана.
|
|
1476
1454
|
*/
|
|
1477
|
-
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi"
|
|
1455
|
+
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi"];
|
|
1478
1456
|
/**
|
|
1479
1457
|
* `POST /share`-ийн multipart талбарууд — CA `server/internal/httpapi/handlers_share.go` `parseShareRequest` (CA main
|
|
1480
1458
|
* 0329ef95, !371). CA үл мэдэгдэх талбарыг 400 REQUEST_INVALID-аар татгалздаг. Live discovery-ийн `endpoints.share`
|
|
@@ -1859,4 +1837,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1859
1837
|
*/
|
|
1860
1838
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1861
1839
|
|
|
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,
|
|
1840
|
+
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, 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 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
|
@@ -1,9 +1,8 @@
|
|
|
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,
|
|
2
|
-
export {
|
|
3
|
-
import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-
|
|
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-
|
|
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-CCP--VGv.js';
|
|
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-CCP--VGv.js';
|
|
3
|
+
import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-CgJcEjrZ.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-CgJcEjrZ.js';
|
|
5
5
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
6
|
-
export { NavigatorLike, isMobileUserAgent } from './browser.js';
|
|
7
6
|
|
|
8
7
|
interface HttpConfig {
|
|
9
8
|
/** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
|
|
@@ -220,18 +219,6 @@ interface RegisterSignatureInput {
|
|
|
220
219
|
onBehalfOf?: string;
|
|
221
220
|
/** Заавал биш (`PNOMN-…`): ирвэл CMS-ийн зурагчийн SERIALNUMBER-тэй тэнцүү (эс бөгөөс 409 `SIGNER_MISMATCH`). */
|
|
222
221
|
signerEtsi?: string;
|
|
223
|
-
/**
|
|
224
|
-
* `complete().images` (0.31.0+) — харагдах дүрслэлд шигтгэсэн зураг бүрийн `{kind, sha256}` (pades APPEARANCE_SPEC.md
|
|
225
|
-
* §6.6): CA зурагчийн/байгууллагын хадгалсан PNG-тэй тулгана. Зураггүй бол илгээхгүй.
|
|
226
|
-
*/
|
|
227
|
-
images?: PdfSignatureImage[];
|
|
228
|
-
}
|
|
229
|
-
/** {@link RegisterSignatureInput.images}-ийн нэг мөр (Go `eid.PDFSignatureImage`). */
|
|
230
|
-
interface PdfSignatureImage {
|
|
231
|
-
/** `signature` — иргэний гарын үсгийн зураг; `stamp` — байгууллагын тамганы зураг. */
|
|
232
|
-
kind: "signature" | "stamp";
|
|
233
|
-
/** CA-ийн хадгалсан PNG-ийн SHA-256 (64 жижиг hex). */
|
|
234
|
-
sha256: string;
|
|
235
222
|
}
|
|
236
223
|
/** Өмнөх нэг гарын үсгийн хоёр түлхүүр ({@link RegisterSignatureInput.priorSignatures}). */
|
|
237
224
|
interface PriorSignature {
|
|
@@ -255,8 +242,6 @@ interface CompletedForRegistration {
|
|
|
255
242
|
priorRevisionSha256?: string[];
|
|
256
243
|
/** `complete().claimedRole` (0.27.0+) — хоосон биш бол `onBehalfOf` заавал. */
|
|
257
244
|
claimedRole?: string;
|
|
258
|
-
/** `complete().images` (0.31.0+) — байвал `images` болж илгээгдэнэ. */
|
|
259
|
-
images?: PdfSignatureImage[];
|
|
260
245
|
}
|
|
261
246
|
/**
|
|
262
247
|
* `pades.complete()`-ийн үр дүнгээс `registerSignature`-ийн биеийг бөглөнө (`hasPage`-ийг илгээхгүй — CA `revIndex`-ээс
|
|
@@ -578,12 +563,6 @@ declare class PersonApi {
|
|
|
578
563
|
summary(personEtsi: string): Promise<PersonSummary>;
|
|
579
564
|
/** Асран хамгаалж буй хүүхдүүд (зөвхөн унших). */
|
|
580
565
|
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>;
|
|
587
566
|
}
|
|
588
567
|
|
|
589
568
|
/** Задалсан subject. Cert-д байхгүй талбар — undefined. Давхардсан OID-ийн эхнийх нь. */
|
|
@@ -1470,11 +1449,10 @@ declare class EidClient {
|
|
|
1470
1449
|
|
|
1471
1450
|
/**
|
|
1472
1451
|
* `POST /pdf/signatures`-ийн биеийн талбарууд — CA `server/internal/dto/pdf.go` `PDFSignatureRegisterRequest`-ийн JSON
|
|
1473
|
-
* tag (CA main d948fdd4, !355
|
|
1474
|
-
* тул SDK зөвхөн эдгээрийг илгээнэ. Live discovery-ийн
|
|
1452
|
+
* tag (CA main d948fdd4, !355). CA `DisallowUnknownFields` тул SDK зөвхөн эдгээрийг илгээнэ. Live discovery-ийн
|
|
1475
1453
|
* `endpoints.pdf.signatures` тайлбартай гэрээний тест тулгана.
|
|
1476
1454
|
*/
|
|
1477
|
-
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi"
|
|
1455
|
+
declare const PDF_SIGNATURE_REGISTER_FIELDS: readonly ["docID", "revIndex", "medium", "sessionID", "cms", "fileName", "inSha256", "pageSha256", "sigRevSha256", "outSha256", "priorCmsSha256", "priorRevisionSha256", "onBehalfOf", "signerEtsi"];
|
|
1478
1456
|
/**
|
|
1479
1457
|
* `POST /share`-ийн multipart талбарууд — CA `server/internal/httpapi/handlers_share.go` `parseShareRequest` (CA main
|
|
1480
1458
|
* 0329ef95, !371). CA үл мэдэгдэх талбарыг 400 REQUEST_INVALID-аар татгалздаг. Live discovery-ийн `endpoints.share`
|
|
@@ -1859,4 +1837,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1859
1837
|
*/
|
|
1860
1838
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1861
1839
|
|
|
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,
|
|
1840
|
+
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, 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 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
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
ValidationError,
|
|
32
32
|
maskPath,
|
|
33
33
|
parseRetryAfter
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-PWFTN52X.js";
|
|
35
35
|
|
|
36
36
|
// src/http.ts
|
|
37
37
|
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
@@ -169,7 +169,6 @@ var RP_ROUTES = {
|
|
|
169
169
|
personActivity: { method: "GET", path: "/rp/activity/etsi/{personEtsi}" },
|
|
170
170
|
personSummary: { method: "GET", path: "/person/summary/etsi/{personEtsi}" },
|
|
171
171
|
personChildren: { method: "GET", path: "/person/children/etsi/{personEtsi}" },
|
|
172
|
-
personSignatureImage: { method: "GET", path: "/person/etsi/{personEtsi}/signature-image" },
|
|
173
172
|
tokenCertificate: { method: "POST", path: "/token/certificate" },
|
|
174
173
|
tokenCertificateResult: { method: "GET", path: "/token/certificate/{sessionID}" },
|
|
175
174
|
pdfSignatures: { method: "POST", path: "/pdf/signatures" },
|
|
@@ -193,8 +192,7 @@ var PDF_SIGNATURE_REGISTER_FIELDS = [
|
|
|
193
192
|
"priorCmsSha256",
|
|
194
193
|
"priorRevisionSha256",
|
|
195
194
|
"onBehalfOf",
|
|
196
|
-
"signerEtsi"
|
|
197
|
-
"images"
|
|
195
|
+
"signerEtsi"
|
|
198
196
|
];
|
|
199
197
|
var SHARE_FORM_FIELDS = ["file", "filename", "to", "subject", "message", "lang"];
|
|
200
198
|
function routePath(route, ...args) {
|
|
@@ -402,7 +400,6 @@ function registrationFromCompleted(done, extra) {
|
|
|
402
400
|
}
|
|
403
401
|
if (extra.onBehalfOf) out.onBehalfOf = extra.onBehalfOf;
|
|
404
402
|
if (extra.signerEtsi) out.signerEtsi = extra.signerEtsi;
|
|
405
|
-
if (done.images?.length) out.images = done.images.map((x) => ({ kind: x.kind, sha256: x.sha256 }));
|
|
406
403
|
return out;
|
|
407
404
|
}
|
|
408
405
|
function priorSplits(n) {
|
|
@@ -464,12 +461,6 @@ function buildRegisterBody(input) {
|
|
|
464
461
|
if (priorRev.length) body.priorRevisionSha256 = priorRev;
|
|
465
462
|
if (input.onBehalfOf?.trim()) body.onBehalfOf = input.onBehalfOf.trim();
|
|
466
463
|
if (input.signerEtsi?.trim()) body.signerEtsi = input.signerEtsi.trim();
|
|
467
|
-
if (input.images?.length) {
|
|
468
|
-
body.images = input.images.map((x, i) => {
|
|
469
|
-
if (x?.kind !== "signature" && x?.kind !== "stamp") fail2(`images[${i}].kind: signature | stamp`);
|
|
470
|
-
return { kind: x.kind, sha256: hex(`images[${i}].sha256`, x.sha256) };
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
464
|
for (const k of Object.keys(body)) if (!PDF_SIGNATURE_REGISTER_FIELDS.includes(k)) fail2(`\u0434\u043E\u0442\u043E\u043E\u0434: \u04AF\u043B \u043C\u044D\u0434\u044D\u0433\u0434\u044D\u0445 \u0442\u0430\u043B\u0431\u0430\u0440 ${k}`);
|
|
474
465
|
return body;
|
|
475
466
|
}
|
|
@@ -949,19 +940,6 @@ var PersonApi = class {
|
|
|
949
940
|
children(personEtsi) {
|
|
950
941
|
return this.get(routePath(RP_ROUTES.personChildren, personEtsi));
|
|
951
942
|
}
|
|
952
|
-
/**
|
|
953
|
-
* GET /person/etsi/{personEtsi}/signature-image — иргэний гарын үсгийн зураг (харагдах гарын үсэгт:
|
|
954
|
-
* `appearance.signatureImage = img.pdfImage`). PKI_READ биш, **SIGN** эрх; иргэн сүүлийн 24 цагт танай RP-ээр
|
|
955
|
-
* нэвтэрсэн байх ёстой (эс бөгөөс `ForbiddenError`). Иргэн зураг хадгалаагүй (404) бол `null`.
|
|
956
|
-
*/
|
|
957
|
-
async signatureImage(personEtsi) {
|
|
958
|
-
try {
|
|
959
|
-
return rec3(await this.http.get(routePath(RP_ROUTES.personSignatureImage, personEtsi)));
|
|
960
|
-
} catch (e) {
|
|
961
|
-
if (e instanceof ApiError && e.status === 404) return null;
|
|
962
|
-
throw e;
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
943
|
};
|
|
966
944
|
|
|
967
945
|
// src/token.ts
|
package/dist/pades.cjs
CHANGED
|
@@ -21,9 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var pades_exports = {};
|
|
22
22
|
__export(pades_exports, {
|
|
23
23
|
CertificateRevokedError: () => CertificateRevokedError,
|
|
24
|
-
DEFAULT_ORG_STAMP_SIZE: () => DEFAULT_ORG_STAMP_SIZE,
|
|
25
|
-
DEFAULT_SIGNATURE_STAMP_SIZE: () => DEFAULT_SIGNATURE_STAMP_SIZE,
|
|
26
|
-
DEFAULT_STAMP_SIZE: () => DEFAULT_STAMP_SIZE,
|
|
27
24
|
PADES_ERROR_CODES: () => PADES_ERROR_CODES,
|
|
28
25
|
PROFILE_VERSION: () => PROFILE_VERSION,
|
|
29
26
|
PadesError: () => PadesError,
|
|
@@ -1410,7 +1407,7 @@ function zlibInflate(src, limit = 64 << 20, initial) {
|
|
|
1410
1407
|
function inflateRaw(src, limit = 64 << 20, info, initial) {
|
|
1411
1408
|
return inflate(src, limit, info, initial, false);
|
|
1412
1409
|
}
|
|
1413
|
-
function zlibInflateStrict(src, limit
|
|
1410
|
+
function zlibInflateStrict(src, limit) {
|
|
1414
1411
|
if (src.length < 2) throw new InflateError("zlib: header \u0430\u043B\u0433\u0430");
|
|
1415
1412
|
const cmf = src[0];
|
|
1416
1413
|
const flg = src[1];
|
|
@@ -1428,7 +1425,6 @@ function zlibInflateStrict(src, limit, exact = false) {
|
|
|
1428
1425
|
if (at + 4 > src.length) throw new InflateError("zlib: adler32 \u0430\u043B\u0433\u0430");
|
|
1429
1426
|
const want = (src[at] << 24 | src[at + 1] << 16 | src[at + 2] << 8 | src[at + 3]) >>> 0;
|
|
1430
1427
|
if (adler32(out) !== want) throw new InflateError("zlib: adler32 \u0442\u0430\u0430\u0440\u0430\u0445\u0433\u04AF\u0439");
|
|
1431
|
-
if (exact && at + 4 !== src.length) throw new InflateError("zlib: stream-\u0438\u0439\u043D \u0430\u0440\u0434 \u0438\u043B\u04AF\u04AF \u0431\u0430\u0439\u0442");
|
|
1432
1428
|
return out;
|
|
1433
1429
|
}
|
|
1434
1430
|
function adler32(b) {
|
|
@@ -3347,61 +3343,6 @@ function toUnicode(f) {
|
|
|
3347
3343
|
// src/pades/page/appearance.ts
|
|
3348
3344
|
var AppearanceError = class extends PdfError {
|
|
3349
3345
|
};
|
|
3350
|
-
var MAX_IMAGE_SIDE = 1600;
|
|
3351
|
-
var MAX_IMAGE_ALPHA_BYTES = 300 << 10;
|
|
3352
|
-
var isIntIn = (v, lo, hi) => Number.isInteger(v) && v >= lo && v <= hi;
|
|
3353
|
-
function checkPdfImage(im) {
|
|
3354
|
-
const bad = (msg) => new AppearanceError(`\u0437\u0443\u0440\u0430\u0433: ${msg}`);
|
|
3355
|
-
if (!isIntIn(im.w, 1, MAX_IMAGE_SIDE) || !isIntIn(im.h, 1, MAX_IMAGE_SIDE)) throw bad("\u0445\u044D\u043C\u0436\u044D\u044D 1\u20261600 px");
|
|
3356
|
-
if (!Array.isArray(im.color) || im.color.length !== 3) throw bad("\u04E9\u043D\u0433\u04E9 0\u2026255");
|
|
3357
|
-
for (const c of im.color) if (!isIntIn(c, 0, 255)) throw bad("\u04E9\u043D\u0433\u04E9 0\u2026255");
|
|
3358
|
-
if (!(im.alpha instanceof Uint8Array) || im.alpha.length === 0 || im.alpha.length > MAX_IMAGE_ALPHA_BYTES) throw bad("alpha 1 B\u2026300 KiB");
|
|
3359
|
-
if (im.alpha.length >= 2 && im.alpha[1] & 32) throw bad("alpha preset dictionary (FDICT)");
|
|
3360
|
-
let n;
|
|
3361
|
-
try {
|
|
3362
|
-
n = zlibInflateStrict(im.alpha, im.w * im.h, true).length;
|
|
3363
|
-
} catch (e) {
|
|
3364
|
-
if (!(e instanceof InflateError)) throw e;
|
|
3365
|
-
n = -1;
|
|
3366
|
-
}
|
|
3367
|
-
if (n !== im.w * im.h) throw bad("alpha \u043D\u044C \u044F\u0433 \u04E9\u0440\u0433\u04E9\u043D\xD7\u04E9\u043D\u0434\u04E9\u0440 \u0431\u0430\u0439\u0442 \u0431\u0438\u0448 (\u044D\u0441\u0432\u044D\u043B \u044D\u0432\u0434\u044D\u0440\u0441\u044D\u043D)");
|
|
3368
|
-
}
|
|
3369
|
-
var idiv = (a, b) => Math.trunc(a / b);
|
|
3370
|
-
function apFit(iw, ih, bw, bh) {
|
|
3371
|
-
if (iw * bh >= ih * bw) return [bw, Math.max(1, idiv(bw * ih, iw))];
|
|
3372
|
-
return [Math.max(1, idiv(bh * iw, ih)), bh];
|
|
3373
|
-
}
|
|
3374
|
-
function apLayoutImages(p) {
|
|
3375
|
-
const l = { boxH: p.h, rowH: p.h, sig: [0, 0, 0, 0], stamp: [0, 0, 0, 0] };
|
|
3376
|
-
if (!p.sig && !p.stamp) return l;
|
|
3377
|
-
const small = () => new AppearanceError("\u0445\u044D\u0442 \u0436\u0438\u0436\u0438\u0433 (\u0437\u0443\u0440\u0430\u0433\u0442\u0430\u0439 \u0434\u04AF\u0440\u0441\u043B\u044D\u043B)");
|
|
3378
|
-
if (p.stamp) l.boxH = idiv(p.h * 4, 5);
|
|
3379
|
-
const band = idiv(l.boxH * 9, 22);
|
|
3380
|
-
l.rowH = l.boxH - band;
|
|
3381
|
-
const sh = idiv(band * 14, 15);
|
|
3382
|
-
const sy = l.rowH - idiv(band * 2, 15);
|
|
3383
|
-
let sw = idiv(p.w * 15, 22);
|
|
3384
|
-
let sx = idiv(p.w - sw, 2);
|
|
3385
|
-
if (p.stamp) {
|
|
3386
|
-
const d = idiv(l.boxH * 2, 3);
|
|
3387
|
-
const qx = Math.min(idiv(p.w * 41, 60) - idiv(d, 2), p.w - d);
|
|
3388
|
-
if (qx < 0 || d <= 0) throw small();
|
|
3389
|
-
const [dw, dh] = apFit(p.stamp.w, p.stamp.h, d, d);
|
|
3390
|
-
l.stamp = [qx + idiv(d - dw, 2), p.h - d + idiv(d - dh, 2), dw, dh];
|
|
3391
|
-
sx = idiv(p.w, 30);
|
|
3392
|
-
sw = qx + idiv(d, 2) - sx;
|
|
3393
|
-
}
|
|
3394
|
-
if (p.sig) {
|
|
3395
|
-
if (sw <= 0 || sh <= 0) throw small();
|
|
3396
|
-
const [dw, dh] = apFit(p.sig.w, p.sig.h, sw, sh);
|
|
3397
|
-
const dx = p.stamp ? sx : sx + idiv(sw - dw, 2);
|
|
3398
|
-
l.sig = [dx, sy + idiv(sh - dh, 2), dw, dh];
|
|
3399
|
-
}
|
|
3400
|
-
return l;
|
|
3401
|
-
}
|
|
3402
|
-
function apDrawImage(w, name, r) {
|
|
3403
|
-
w.op(`q ${num100(r[2])} 0 0 ${num100(r[3])} ${num100(r[0])} ${num100(r[1])} cm /${name} Do Q`);
|
|
3404
|
-
}
|
|
3405
3346
|
var AP_PAD = 400;
|
|
3406
3347
|
var AP_GAP = 400;
|
|
3407
3348
|
var AP_MIN_MODULE = 100;
|
|
@@ -3447,10 +3388,6 @@ function appearanceContent(p) {
|
|
|
3447
3388
|
if (label === void 0) throw new AppearanceError(`\u0445\u044D\u043B ${p.lang}`);
|
|
3448
3389
|
if (!asciiURL(p.url)) throw new AppearanceError("URL ASCII \u0431\u0438\u0448");
|
|
3449
3390
|
if (p.w <= 0 || p.h <= 0 || p.w > MAX_APPEARANCE_SIDE || p.h > MAX_APPEARANCE_SIDE) throw new AppearanceError("\u0445\u044D\u043C\u0436\u044D\u044D");
|
|
3450
|
-
if (p.stamp && p.role === "") throw new AppearanceError("\u0442\u0430\u043C\u0433\u044B\u043D \u0437\u0443\u0440\u0430\u0433 \u0437\u04E9\u0432\u0445\u04E9\u043D \u0431\u0430\u0439\u0433\u0443\u0443\u043B\u043B\u0430\u0433\u044B\u043D \u043D\u044D\u0440\u0438\u0439\u043D \u04E9\u043C\u043D\u04E9\u04E9\u0441 (claimedRole)");
|
|
3451
|
-
for (const im of [p.sig, p.stamp]) if (im) checkPdfImage(im);
|
|
3452
|
-
const il = apLayoutImages(p);
|
|
3453
|
-
const rowH = il.rowH;
|
|
3454
3391
|
let m;
|
|
3455
3392
|
try {
|
|
3456
3393
|
m = qrEncode(latin1(p.url));
|
|
@@ -3458,14 +3395,14 @@ function appearanceContent(p) {
|
|
|
3458
3395
|
throw new AppearanceError(String(e));
|
|
3459
3396
|
}
|
|
3460
3397
|
const n = m.length;
|
|
3461
|
-
const mod = Math.trunc((
|
|
3398
|
+
const mod = Math.trunc((p.h - 2 * AP_PAD) / n);
|
|
3462
3399
|
if (mod < AP_MIN_MODULE) throw new AppearanceError(`\u0445\u044D\u0442 \u0436\u0438\u0436\u0438\u0433 (\u04E9\u043D\u0434\u04E9\u0440 \u2265 ${num100(2 * AP_PAD + n * AP_MIN_MODULE)} pt)`);
|
|
3463
3400
|
const tx = AP_PAD + mod * n + AP_GAP;
|
|
3464
3401
|
const tw = p.w - tx - AP_PAD;
|
|
3465
3402
|
const [reg, bld] = loadFonts();
|
|
3466
3403
|
const w = new PageWriter(reg, bld);
|
|
3467
3404
|
let lines;
|
|
3468
|
-
for (let f = AP_MAX_SIZE; f >= AP_MIN_SIZE && lines === void 0 && tw > 0; f--) lines = apLayout(w, p, label, f, tw
|
|
3405
|
+
for (let f = AP_MAX_SIZE; f >= AP_MIN_SIZE && lines === void 0 && tw > 0; f--) lines = apLayout(w, p, label, f, tw);
|
|
3469
3406
|
if (lines === void 0) throw new AppearanceError("\u0445\u044D\u0442 \u0436\u0438\u0436\u0438\u0433 (\u0431\u0438\u0447\u0432\u044D\u0440 \u0431\u0430\u0433\u0442\u0430\u0445\u0433\u04AF\u0439)");
|
|
3470
3407
|
let total = 0;
|
|
3471
3408
|
for (const l of lines) total += l.size * AP_LEADING;
|
|
@@ -3477,13 +3414,8 @@ function appearanceContent(p) {
|
|
|
3477
3414
|
}
|
|
3478
3415
|
w.op(`${C_OK} RG`);
|
|
3479
3416
|
w.op("1 w");
|
|
3480
|
-
w.op(`0.5 0.5 ${num100(p.w - 100)} ${num100(
|
|
3481
|
-
|
|
3482
|
-
w.op("0.5 w");
|
|
3483
|
-
w.op(`0 ${num100(rowH)} m ${num100(p.w)} ${num100(rowH)} l S`);
|
|
3484
|
-
}
|
|
3485
|
-
if (p.sig) apDrawImage(w, "Sig", il.sig);
|
|
3486
|
-
w.op(`q ${num100(mod)} 0 0 ${num100(mod)} ${num100(AP_PAD)} ${num100(Math.trunc((rowH - mod * n) / 2))} cm`);
|
|
3417
|
+
w.op(`0.5 0.5 ${num100(p.w - 100)} ${num100(p.h - 100)} re S`);
|
|
3418
|
+
w.op(`q ${num100(mod)} 0 0 ${num100(mod)} ${num100(AP_PAD)} ${num100(Math.trunc((p.h - mod * n) / 2))} cm`);
|
|
3487
3419
|
w.op("0 0 0 rg");
|
|
3488
3420
|
for (let r = 0; r < n; r++) {
|
|
3489
3421
|
for (let c = 0; c < n; ) {
|
|
@@ -3498,18 +3430,17 @@ function appearanceContent(p) {
|
|
|
3498
3430
|
}
|
|
3499
3431
|
w.op("f");
|
|
3500
3432
|
w.op("Q");
|
|
3501
|
-
let cursor =
|
|
3433
|
+
let cursor = p.h - AP_PAD - Math.trunc((p.h - 2 * AP_PAD - total) / 2);
|
|
3502
3434
|
for (const l of lines) {
|
|
3503
3435
|
cursor -= l.size * AP_LEADING;
|
|
3504
3436
|
w.op(`${l.color} rg`);
|
|
3505
3437
|
w.op(`BT /F${l.font} ${l.size} Tf ${num100(tx)} ${num100(cursor + l.size * AP_DESCENT)} Td ${w.glyphHex(l.font, l.text)} Tj ET`);
|
|
3506
3438
|
}
|
|
3507
|
-
if (p.stamp) apDrawImage(w, "Stamp", il.stamp);
|
|
3508
3439
|
if (cm !== "") w.op("Q");
|
|
3509
3440
|
w.op("EMC");
|
|
3510
3441
|
return w.ops;
|
|
3511
3442
|
}
|
|
3512
|
-
function apLayout(w, p, label, f, tw
|
|
3443
|
+
function apLayout(w, p, label, f, tw) {
|
|
3513
3444
|
const b = f - AP_BODY_DELTA;
|
|
3514
3445
|
const limit = tw * 10;
|
|
3515
3446
|
const lines = [];
|
|
@@ -3523,40 +3454,20 @@ function apLayout(w, p, label, f, tw, rowH) {
|
|
|
3523
3454
|
if (l.text === "" || w.width1000(l.font, l.size, l.text) > limit) return void 0;
|
|
3524
3455
|
total += l.size * AP_LEADING;
|
|
3525
3456
|
}
|
|
3526
|
-
if (total >
|
|
3457
|
+
if (total > p.h - 2 * AP_PAD) return void 0;
|
|
3527
3458
|
return lines;
|
|
3528
3459
|
}
|
|
3529
|
-
function appearanceObjectCount(p) {
|
|
3530
|
-
return 11 + (p.sig ? 2 : 0) + (p.stamp ? 2 : 0);
|
|
3531
|
-
}
|
|
3532
3460
|
function appearanceObjects(p, ids) {
|
|
3533
|
-
if (ids.length !== appearanceObjectCount(p)) throw new AppearanceError("\u043E\u0431\u044A\u0435\u043A\u0442\u044B\u043D \u0442\u043E\u043E");
|
|
3534
3461
|
const [reg, bld] = loadFonts();
|
|
3535
3462
|
const { bw, bh } = apRotation(p.rotate, p.w, p.h);
|
|
3536
3463
|
const content = appearanceContent(p);
|
|
3537
|
-
let res = `/Font << /F1 ${ids[1]} 0 R /F2 ${ids[6]} 0 R >>`;
|
|
3538
|
-
const imgs = [];
|
|
3539
|
-
let next = 11;
|
|
3540
|
-
if (p.sig || p.stamp) {
|
|
3541
|
-
res += " /XObject <<";
|
|
3542
|
-
for (const [name, im] of [["Sig", p.sig], ["Stamp", p.stamp]]) {
|
|
3543
|
-
if (!im) continue;
|
|
3544
|
-
const base = ids[next];
|
|
3545
|
-
const mask = ids[next + 1];
|
|
3546
|
-
next += 2;
|
|
3547
|
-
res += ` /${name} ${base} 0 R`;
|
|
3548
|
-
imgs.push(
|
|
3549
|
-
streamObj(` /Type /XObject /Subtype /Image /Width 1 /Height 1 /ColorSpace /DeviceRGB /BitsPerComponent 8 /SMask ${mask} 0 R`, Uint8Array.from(im.color)),
|
|
3550
|
-
streamObj(` /Type /XObject /Subtype /Image /Width ${im.w} /Height ${im.h} /ColorSpace /DeviceGray /BitsPerComponent 8 /Filter /FlateDecode`, im.alpha)
|
|
3551
|
-
);
|
|
3552
|
-
}
|
|
3553
|
-
res += " >>";
|
|
3554
|
-
}
|
|
3555
3464
|
return [
|
|
3556
|
-
streamObj(
|
|
3465
|
+
streamObj(
|
|
3466
|
+
` /Type /XObject /Subtype /Form /BBox [0 0 ${num100(bw)} ${num100(bh)}] /Resources << /Font << /F1 ${ids[1]} 0 R /F2 ${ids[6]} 0 R >> >>`,
|
|
3467
|
+
latin1(content)
|
|
3468
|
+
),
|
|
3557
3469
|
...fontBodies(ids.slice(1, 6), reg),
|
|
3558
|
-
...fontBodies(ids.slice(6, 11), bld)
|
|
3559
|
-
...imgs
|
|
3470
|
+
...fontBodies(ids.slice(6, 11), bld)
|
|
3560
3471
|
];
|
|
3561
3472
|
}
|
|
3562
3473
|
function visibleWidget(fieldName, rect, pageID, pageGen, sigID, formID) {
|
|
@@ -4737,7 +4648,7 @@ async function prepareSignature(base, signingTime, signerName, reason, vis) {
|
|
|
4737
4648
|
const sigID = inc.reserve();
|
|
4738
4649
|
const fieldID = inc.reserve();
|
|
4739
4650
|
const catID = inc.reserve();
|
|
4740
|
-
const apIDs = vis ? Array.from({ length:
|
|
4651
|
+
const apIDs = vis ? Array.from({ length: 11 }, () => inc.reserve()) : [];
|
|
4741
4652
|
let sig = `<<
|
|
4742
4653
|
/Type /Sig
|
|
4743
4654
|
/Filter /Adobe.PPKLite
|
|
@@ -4779,10 +4690,7 @@ async function prepareSignature(base, signingTime, signerName, reason, vis) {
|
|
|
4779
4690
|
placement = placeOnPage(page, box, rot, vis.x, vis.y, vis.w, vis.h, vis.exact === true);
|
|
4780
4691
|
if (placement.x !== vis.x || placement.y !== vis.y) rect = visibleRect(box, rot, placement.x, placement.y, vis.w, vis.h);
|
|
4781
4692
|
}
|
|
4782
|
-
const bodies = appearanceObjects(
|
|
4783
|
-
{ w: vis.w, h: vis.h, rotate: rot, name: vis.name, role: vis.role, lang: vis.lang, date: vis.date, url: vis.url, sig: vis.sig, stamp: vis.stamp },
|
|
4784
|
-
apIDs
|
|
4785
|
-
);
|
|
4693
|
+
const bodies = appearanceObjects({ w: vis.w, h: vis.h, rotate: rot, name: vis.name, role: vis.role, lang: vis.lang, date: vis.date, url: vis.url }, apIDs);
|
|
4786
4694
|
inc.writeObject(fieldID, visibleWidget(fieldName, rect, page.ptr.id, page.ptr.gen, sigID, apIDs[0]));
|
|
4787
4695
|
bodies.forEach((b2, i) => inc.writeObject(apIDs[i], b2));
|
|
4788
4696
|
}
|
|
@@ -5127,7 +5035,6 @@ function encodeState(s) {
|
|
|
5127
5035
|
};
|
|
5128
5036
|
if (s.pageSha256) head.pageSha256 = s.pageSha256;
|
|
5129
5037
|
if (s.claimedRole) head.claimedRole = s.claimedRole;
|
|
5130
|
-
if (s.images?.length) head.images = s.images.map((x) => ({ kind: x.kind, sha256: x.sha256 }));
|
|
5131
5038
|
head.preparedSha256 = s.preparedSha256;
|
|
5132
5039
|
const h = enc.encode(JSON.stringify(head));
|
|
5133
5040
|
const len = new Uint8Array(4);
|
|
@@ -5153,7 +5060,6 @@ async function decodeState(b) {
|
|
|
5153
5060
|
hasPage: j.hasPage === true,
|
|
5154
5061
|
pageSha256: str("pageSha256"),
|
|
5155
5062
|
claimedRole: str("claimedRole"),
|
|
5156
|
-
images: stateImages(j.images),
|
|
5157
5063
|
preparedSha256: str("preparedSha256"),
|
|
5158
5064
|
pdf
|
|
5159
5065
|
};
|
|
@@ -5163,16 +5069,6 @@ async function decodeState(b) {
|
|
|
5163
5069
|
}
|
|
5164
5070
|
return s;
|
|
5165
5071
|
}
|
|
5166
|
-
function stateImages(v) {
|
|
5167
|
-
if (v === void 0 || v === null) return void 0;
|
|
5168
|
-
if (!Array.isArray(v)) throw new Error("state images \u0431\u0443\u0440\u0443\u0443");
|
|
5169
|
-
const out = v.map((x) => {
|
|
5170
|
-
const o = x;
|
|
5171
|
-
if (!o || o.kind !== "signature" && o.kind !== "stamp" || typeof o.sha256 !== "string") throw new Error("state images \u0431\u0443\u0440\u0443\u0443");
|
|
5172
|
-
return { kind: o.kind, sha256: o.sha256 };
|
|
5173
|
-
});
|
|
5174
|
-
return out.length ? out : void 0;
|
|
5175
|
-
}
|
|
5176
5072
|
|
|
5177
5073
|
// src/pades.ts
|
|
5178
5074
|
var PROFILE_VERSION = "pades-client/1";
|
|
@@ -5207,21 +5103,6 @@ var PadesError = class extends EidError {
|
|
|
5207
5103
|
return this.code === "TSA_UNAVAILABLE" || this.code === "LTV_UNAVAILABLE";
|
|
5208
5104
|
}
|
|
5209
5105
|
};
|
|
5210
|
-
var DEFAULT_STAMP_SIZE = { width: 220, height: 64 };
|
|
5211
|
-
var DEFAULT_SIGNATURE_STAMP_SIZE = { width: 220, height: 110 };
|
|
5212
|
-
var DEFAULT_ORG_STAMP_SIZE = { width: 240, height: 147.5 };
|
|
5213
|
-
function appearanceSize(a) {
|
|
5214
|
-
if (a.width !== 0 || a.height !== 0) return { width: a.width, height: a.height };
|
|
5215
|
-
if (a.stampImage) return DEFAULT_ORG_STAMP_SIZE;
|
|
5216
|
-
if (a.signatureImage) return DEFAULT_SIGNATURE_STAMP_SIZE;
|
|
5217
|
-
return DEFAULT_STAMP_SIZE;
|
|
5218
|
-
}
|
|
5219
|
-
var SHA256_HEX_RE = /^[0-9a-f]{64}$/;
|
|
5220
|
-
var BASE64_STD_RE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
5221
|
-
function imageData(im) {
|
|
5222
|
-
if (im === void 0) return void 0;
|
|
5223
|
-
return { w: im.width, h: im.height, color: im.color, alpha: fromB64(im.alpha) };
|
|
5224
|
-
}
|
|
5225
5106
|
var MAX_OUTPUT_BYTES = 10 << 20;
|
|
5226
5107
|
var MAX_FILE_NAME = 120;
|
|
5227
5108
|
var PAGE_BRAND = "eID Mongolia";
|
|
@@ -5321,9 +5202,6 @@ async function prepare(pdf, opts) {
|
|
|
5321
5202
|
}
|
|
5322
5203
|
const first = pos === "first";
|
|
5323
5204
|
checkAppearance(opts);
|
|
5324
|
-
if (opts.appearance?.stampImage && !opts.claimedRole) {
|
|
5325
|
-
throw new PadesError("REQUEST_INVALID", "appearance: stampImage \u0437\u04E9\u0432\u0445\u04E9\u043D claimedRole (onBehalfOf)-\u0442\u043E\u0439");
|
|
5326
|
-
}
|
|
5327
5205
|
const now = opts.signingTime ?? /* @__PURE__ */ new Date();
|
|
5328
5206
|
if (Number.isNaN(now.getTime())) throw new PadesError("REQUEST_INVALID", "signingTime \u0431\u0443\u0440\u0443\u0443 Date");
|
|
5329
5207
|
const inHex = toHex(await sha256(doc));
|
|
@@ -5397,7 +5275,6 @@ async function prepare(pdf, opts) {
|
|
|
5397
5275
|
hasPage,
|
|
5398
5276
|
pageSha256: pageHex,
|
|
5399
5277
|
claimedRole: role,
|
|
5400
|
-
images: prepImages(opts.appearance),
|
|
5401
5278
|
preparedSha256: toHex(await sha256(prep.pdf)),
|
|
5402
5279
|
pdf: prep.pdf
|
|
5403
5280
|
});
|
|
@@ -5421,24 +5298,6 @@ function checkAppearance(o) {
|
|
|
5421
5298
|
if (a.exact !== void 0 && typeof a.exact !== "boolean") throw bad("exact: boolean");
|
|
5422
5299
|
const role = o.claimedRole ?? "";
|
|
5423
5300
|
if (role !== "" && /[\p{Cc}\p{Cf}\p{Cs}]/u.test(role)) throw bad("claimedRole-\u0434 \u0443\u0434\u0438\u0440\u0434\u0430\u0445 \u0442\u044D\u043C\u0434\u044D\u0433\u0442");
|
|
5424
|
-
for (const [name, im] of [["signatureImage", a.signatureImage], ["stampImage", a.stampImage]]) {
|
|
5425
|
-
if (im === void 0) continue;
|
|
5426
|
-
if (im === null || typeof im !== "object") throw bad(`${name}: \u043E\u0431\u044A\u0435\u043A\u0442`);
|
|
5427
|
-
if (typeof im.sha256 !== "string" || !SHA256_HEX_RE.test(im.sha256)) throw bad(`${name}.sha256: \u0436\u0438\u0436\u0438\u0433 hex SHA-256`);
|
|
5428
|
-
if (typeof im.alpha !== "string" || !BASE64_STD_RE.test(im.alpha)) throw bad(`${name}.alpha: \u0441\u0442\u0430\u043D\u0434\u0430\u0440\u0442 base64`);
|
|
5429
|
-
try {
|
|
5430
|
-
checkPdfImage(imageData(im));
|
|
5431
|
-
} catch (e) {
|
|
5432
|
-
if (e instanceof AppearanceError) throw bad(`${name}: ${e.message.replace(/^зураг: /, "")}`);
|
|
5433
|
-
throw e;
|
|
5434
|
-
}
|
|
5435
|
-
}
|
|
5436
|
-
}
|
|
5437
|
-
function prepImages(a) {
|
|
5438
|
-
const out = [];
|
|
5439
|
-
if (a?.signatureImage) out.push({ kind: "signature", sha256: a.signatureImage.sha256 });
|
|
5440
|
-
if (a?.stampImage) out.push({ kind: "stamp", sha256: a.stampImage.sha256 });
|
|
5441
|
-
return out.length ? out : void 0;
|
|
5442
5301
|
}
|
|
5443
5302
|
function visibleSpec(doc, o, name, now, docId, revIndex) {
|
|
5444
5303
|
const a = o.appearance;
|
|
@@ -5453,15 +5312,12 @@ function visibleSpec(doc, o, name, now, docId, revIndex) {
|
|
|
5453
5312
|
if (page > n) throw new PadesError("REQUEST_INVALID", `appearance: page ${page} > \u0445\u0443\u0443\u0434\u0430\u0441\u043D\u044B \u0442\u043E\u043E ${n}`);
|
|
5454
5313
|
const z = new Date(now.getTime() + 8 * 36e5);
|
|
5455
5314
|
const p2 = (v) => String(v).padStart(2, "0");
|
|
5456
|
-
const size = appearanceSize(a);
|
|
5457
5315
|
return {
|
|
5458
5316
|
page,
|
|
5459
5317
|
x: round100(a.x),
|
|
5460
5318
|
y: round100(a.y),
|
|
5461
|
-
w: round100(
|
|
5462
|
-
h: round100(
|
|
5463
|
-
sig: imageData(a.signatureImage),
|
|
5464
|
-
stamp: imageData(a.stampImage),
|
|
5319
|
+
w: round100(a.width),
|
|
5320
|
+
h: round100(a.height),
|
|
5465
5321
|
name: goTrim(name),
|
|
5466
5322
|
role: o.claimedRole ?? "",
|
|
5467
5323
|
lang: a.lang || o.lang || "mn",
|
|
@@ -5494,9 +5350,8 @@ async function suggestPlacement(pdf, appearance) {
|
|
|
5494
5350
|
const id = docIdFromPage(doc);
|
|
5495
5351
|
if (id !== "") verifyUri = VERIFY_URL_PREFIX + id;
|
|
5496
5352
|
}
|
|
5497
|
-
const
|
|
5498
|
-
const
|
|
5499
|
-
const h = round100(size.height);
|
|
5353
|
+
const w = round100(appearance.width);
|
|
5354
|
+
const h = round100(appearance.height);
|
|
5500
5355
|
let s;
|
|
5501
5356
|
try {
|
|
5502
5357
|
s = suggestVisible(doc, verifyUri, appearance.page ?? 0, round100(appearance.x), round100(appearance.y), w, h, appearance.exact === true);
|
|
@@ -5657,16 +5512,12 @@ async function complete2(state, signature, opts = {}) {
|
|
|
5657
5512
|
priorCmsSha256: prior,
|
|
5658
5513
|
priorRevisionSha256: priorRev,
|
|
5659
5514
|
signerCert: cert.raw,
|
|
5660
|
-
claimedRole: st.claimedRole
|
|
5661
|
-
...st.images?.length ? { images: st.images.map((x) => ({ ...x })) } : {}
|
|
5515
|
+
claimedRole: st.claimedRole
|
|
5662
5516
|
};
|
|
5663
5517
|
}
|
|
5664
5518
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5665
5519
|
0 && (module.exports = {
|
|
5666
5520
|
CertificateRevokedError,
|
|
5667
|
-
DEFAULT_ORG_STAMP_SIZE,
|
|
5668
|
-
DEFAULT_SIGNATURE_STAMP_SIZE,
|
|
5669
|
-
DEFAULT_STAMP_SIZE,
|
|
5670
5521
|
PADES_ERROR_CODES,
|
|
5671
5522
|
PROFILE_VERSION,
|
|
5672
5523
|
PadesError,
|