@gerege-systems/eid-mongolia-sdk 0.14.0 → 0.14.1
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 +105 -4
- package/dist/{browser-C6JHm0lR.d.cts → browser-CuMH5IVG.d.cts} +40 -1
- package/dist/{browser-C6JHm0lR.d.ts → browser-CuMH5IVG.d.ts} +40 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/button.cjs +72 -19
- package/dist/button.d.cts +17 -3
- package/dist/button.d.ts +17 -3
- package/dist/button.js +70 -18
- package/dist/index.cjs +244 -26
- package/dist/index.d.cts +136 -8
- package/dist/index.d.ts +136 -8
- package/dist/index.js +240 -26
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 PdfSessionBlock, c as RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-
|
|
2
|
-
export { d as ApiError, e as AuthenticationError, f as
|
|
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 PdfSessionBlock, c as RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-CuMH5IVG.cjs';
|
|
2
|
+
export { d as ApiError, e as AuthenticationError, f as DEFAULT_SIGN_SESSION_TTL_MS, g as DeviceLinkError, h as DeviceLinkInput, E as EidError, i as EndResult, j as ForbiddenError, k as HttpErrorInit, l as NavigatorLike, m as NetworkError, O as ON_BEHALF_ERROR_CODES, n as OnBehalfErrorCode, o as OpenOrShowQROptions, p as OrgResult, q as PdfDocumentStatus, r as PdfSigner, s as RETRYABLE_ERROR_CODES, t as Representation, u as ResponseTooLargeError, v as RetryableErrorCode, w as SessionFailedError, x as SessionState, y as SignContext, z as SignatureAlgorithmParameters, B as SignatureProtocol, T as TokenCertSessionBlock, G as TokenCertStatus, V as ValidationError, J as deviceLink, K as isMobileUserAgent, L as openOrShowQR, M as parseRetryAfter, Q as sessionExpiry } from './browser-CuMH5IVG.cjs';
|
|
3
3
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
4
4
|
|
|
5
5
|
interface HttpConfig {
|
|
@@ -83,17 +83,23 @@ declare class AuthApi {
|
|
|
83
83
|
|
|
84
84
|
interface SignDefaults {
|
|
85
85
|
certificateLevel: CertificateLevel;
|
|
86
|
+
/** Sign / certificate-choice session-ий `expiresAt`-ийг тооцоолох хугацаа (мс); undefined = 600000. */
|
|
87
|
+
sessionTtlMs?: number;
|
|
86
88
|
}
|
|
87
89
|
interface SignOptions {
|
|
88
90
|
certificateLevel?: CertificateLevel;
|
|
89
91
|
/**
|
|
90
|
-
* Same-device App2App буцах URL.
|
|
92
|
+
* Same-device App2App/Web2App буцах URL (initialCallbackUrl). Device link-д Web2App/App2App холбоос зөвхөн үүнтэй
|
|
93
|
+
* session-д хүчинтэй; host нь RP-ийн callbackHosts-д байх ёстой. Query-д буцах browser-ийн hint нэмэхийг ЗӨВЛӨНӨ
|
|
91
94
|
* (`?retScheme=` iOS / `?retPkg=` Android) — docs/RP_GEREGE_INTEGRATION.md §1.1b.
|
|
92
95
|
*/
|
|
93
96
|
callbackUrl?: string;
|
|
94
97
|
/** digest-ийн hash (default SHA-256). digest-ийг өөрөө бэлдсэн бол тааруулна (урт = hLen). */
|
|
95
98
|
hashAlgorithm?: HashAlgorithm;
|
|
96
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Гарын үсгийн алгоритм (default rsassa-pss; PKCS#1 v1.5 нь deprecated). `digestForSigner` / `deviceLinkForSigner`-д
|
|
101
|
+
* default `sha256WithRSAEncryption` (PAdES/CMS).
|
|
102
|
+
*/
|
|
97
103
|
signatureAlgorithm?: SignatureAlgorithm;
|
|
98
104
|
/**
|
|
99
105
|
* Байгууллагын нэрийн өмнөөс гарын үсэг (docs/ORG_LOGIN.md) — байгууллагын ETSI
|
|
@@ -108,22 +114,72 @@ interface SignOptions {
|
|
|
108
114
|
*/
|
|
109
115
|
fileName?: string;
|
|
110
116
|
}
|
|
117
|
+
/** Certificate-choice session-ий тохиргоо. */
|
|
118
|
+
interface CertChoiceOptions {
|
|
119
|
+
certificateLevel?: CertificateLevel;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Гарын үсэг зурах төхөөрөмж — `validator.validateCertificateChoice`-ийн үр дүн (эсвэл түүнээс хадгалсан утга).
|
|
123
|
+
* `documentNumber` — гэрчилгээг сонгосон ЯГ ТЭР төхөөрөмж; `certChoiceSessionId` байвал linked sign.
|
|
124
|
+
*/
|
|
125
|
+
interface SignerRef {
|
|
126
|
+
documentNumber: string;
|
|
127
|
+
certChoiceSessionId?: string | null;
|
|
128
|
+
}
|
|
111
129
|
declare class SignApi {
|
|
112
130
|
private readonly http;
|
|
113
131
|
private readonly creds;
|
|
114
132
|
private readonly defaults;
|
|
115
133
|
constructor(http: Http, creds: RpCredentials, defaults: SignDefaults);
|
|
116
134
|
private body;
|
|
117
|
-
private
|
|
135
|
+
private notification;
|
|
136
|
+
private deviceLink;
|
|
118
137
|
/**
|
|
119
138
|
* Бэлэн digest-ээр push sign (РД/civil_id/ETSI). Баримт (PDF/файл)-ын байтын SHA-256
|
|
120
139
|
* digest-ийг гаднаас бэлдэж өгнө — текст бус бинар баримтад тохиромжтой.
|
|
140
|
+
*
|
|
141
|
+
* ⚠️ Олон утастай иргэнд CA etsi-г ЭХНИЙ идэвхтэй төхөөрөмж рүү шийднэ. Гэрчилгээг урьдчилж мэдэх шаардлагатай бол
|
|
142
|
+
* (PAdES/CMS) {@link certificateChoiceByEtsi} → {@link digestForSigner}.
|
|
121
143
|
*/
|
|
122
144
|
digestByEtsi(id: string, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<NotificationSession>;
|
|
123
|
-
/** Бэлэн digest-ээр push sign — баримтын дугаараар (auth
|
|
145
|
+
/** Бэлэн digest-ээр push sign — баримтын дугаараар (auth / certificate-choice-оос гарсан documentNumber дээр). */
|
|
124
146
|
digestByDocument(documentNumber: string, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<NotificationSession>;
|
|
125
147
|
/** Текстийн SHA-256 digest-ийг дотроо тооцоод push sign (богино текст баримтад тохиромжтой). */
|
|
126
148
|
textByEtsi(id: string, text: string, interactions: Interaction[], opts?: SignOptions): Promise<NotificationSession>;
|
|
149
|
+
/**
|
|
150
|
+
* QR / Web2App / App2App sign — тодорхой иргэн (РД/civil_id/ETSI). Холбоосыг backend-д
|
|
151
|
+
* `buildDeviceLink(deviceLinkInput(s, type, lang))`-ээр; Web2App/App2App-д `callbackUrl` заавал.
|
|
152
|
+
* `validateSign`-д `expectedFlowType` = харуулсан холбоосын төрөл.
|
|
153
|
+
*/
|
|
154
|
+
deviceLinkByEtsi(id: string, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<DeviceLinkSession>;
|
|
155
|
+
/** QR / Web2App / App2App sign — баримтын дугаараар (тодорхой төхөөрөмж). */
|
|
156
|
+
deviceLinkByDocument(documentNumber: string, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<DeviceLinkSession>;
|
|
157
|
+
private certChoiceBody;
|
|
158
|
+
/**
|
|
159
|
+
* Push: иргэний (РД/civil_id/ETSI) утас руу гарын үсгийн гэрчилгээ сонгуулах хүсэлт (PIN-гүй). Үр дүнг
|
|
160
|
+
* `session.waitForResult` → `validator.validateCertificateChoice`. CERT эрх шаардана.
|
|
161
|
+
*/
|
|
162
|
+
certificateChoiceByEtsi(id: string, opts?: CertChoiceOptions): Promise<NotificationSession>;
|
|
163
|
+
/**
|
|
164
|
+
* QR: иргэн хэн болохыг урьдчилж мэдэхгүй үед гэрчилгээ сонгуулах. CA-ийн certificate-choice хүсэлт
|
|
165
|
+
* initialCallbackUrl авдаггүй тул ЗӨВХӨН QR холбоос (`deviceLinkInput(s, "QR", lang)`). CERT эрх.
|
|
166
|
+
*/
|
|
167
|
+
certificateChoiceDeviceLink(opts?: CertChoiceOptions): Promise<DeviceLinkSession>;
|
|
168
|
+
private signerBody;
|
|
169
|
+
/**
|
|
170
|
+
* Certificate-choice-оор сонгосон ЯГ ТЭР төхөөрөмж (`signer.documentNumber`) рүү push sign. Олон утастай иргэнд
|
|
171
|
+
* etsi-ээр эхлүүлбэл өөр утас (өөр гэрчилгээ) зурж, гэрчилгээг урьдчилж оруулсан CMS (PAdES signingCertificateV2)
|
|
172
|
+
* хүчингүй болдог — тиймээс digest-ийг ҮРГЭЛЖ documentNumber-аар зуруулна.
|
|
173
|
+
*
|
|
174
|
+
* `signer.certChoiceSessionId` байвал `/signature/notification/linked/{documentNumber}` (`linkedSessionID`), эс
|
|
175
|
+
* бөгөөс `/signature/notification/document/{documentNumber}`. Default `sha256WithRSAEncryption` + SHA-256 (digest =
|
|
176
|
+
* 32 байт DTBS); digest-ийн урт буруу бол хүсэлт явахгүй. Хариуг:
|
|
177
|
+
* `validator.validateSign(r, s.sign.digest, { hashAlgorithm: s.sign.hashAlgorithm, expectedAlgorithm:
|
|
178
|
+
* s.sign.signatureAlgorithm, expectedCertificate: signer.certificate, expectedFlowType: "Notification" })`.
|
|
179
|
+
*/
|
|
180
|
+
digestForSigner(signer: SignerRef, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<NotificationSession>;
|
|
181
|
+
/** {@link digestForSigner}-ийн QR / Web2App / App2App хувилбар: `/signature/device-link/document/{documentNumber}`. */
|
|
182
|
+
deviceLinkForSigner(signer: SignerRef, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<DeviceLinkSession>;
|
|
127
183
|
}
|
|
128
184
|
|
|
129
185
|
/** RP-API-ийн session JSON-ийг SessionResult болгон задална (rpclient.ts-тэй ижил mapping). */
|
|
@@ -625,6 +681,34 @@ interface ValidateSignOptions {
|
|
|
625
681
|
* тулгалт, криптограф баталгаа биш.
|
|
626
682
|
*/
|
|
627
683
|
expectedFlowType?: FlowType;
|
|
684
|
+
/**
|
|
685
|
+
* Хүсэлтэд илгээсэн signatureAlgorithm (`s.sign.signatureAlgorithm`). Өгвөл хариуны RSA алгоритм ЯГ ИЖИЛ байх ёстой:
|
|
686
|
+
* `sha256WithRSAEncryption` хүссэн session-д `rsassa-pss` (эсвэл эсрэгээр) хариу → `ValidationError`. CA-ийн хуучин
|
|
687
|
+
* threshold-ECDSA credential хүссэнээс үл хамааран `ecdsa-with-SHA256` буцаадаг (түлхүүрийн төрөл гэрчилгээнд
|
|
688
|
+
* бэхлэгдсэн) — зөвхөн EC P-256 гэрчилгээ + SHA-256 үед зөвшөөрнө. Өгөөгүй бол хуучин зан (RSA алгоритмыг тулгахгүй).
|
|
689
|
+
*/
|
|
690
|
+
expectedAlgorithm?: SignatureAlgorithm;
|
|
691
|
+
/**
|
|
692
|
+
* Урьдчилж мэдсэн гэрчилгээ (certificate-choice: `signer.certificate`). Өгвөл хариуны гэрчилгээ байт-ижил байх ёстой —
|
|
693
|
+
* өөр төхөөрөмж/гэрчилгээгээр зурсан бол (олон утастай иргэн) `ValidationError`.
|
|
694
|
+
*/
|
|
695
|
+
expectedCertificate?: X509Certificate;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Certificate-choice-оор баталгаажсан гарын үсэг зурагч ({@link ResponseValidator.validateCertificateChoice}) —
|
|
699
|
+
* `sign.digestForSigner` / `sign.deviceLinkForSigner`-д өгнө.
|
|
700
|
+
*/
|
|
701
|
+
interface Signer {
|
|
702
|
+
/** Гэрчилгээг сонгосон ЯГ ТЭР төхөөрөмж — sign session-ийг ҮҮГЭЭР эхлүүлнэ. */
|
|
703
|
+
documentNumber: string;
|
|
704
|
+
/** Иргэний SIGN гэрчилгээ (KeyUsage contentCommitment). */
|
|
705
|
+
certificate: X509Certificate;
|
|
706
|
+
/** DER, стандарт base64. */
|
|
707
|
+
certificateDerB64: string;
|
|
708
|
+
certificateLevel: string;
|
|
709
|
+
parsedSubject: CertSubject;
|
|
710
|
+
/** Certificate-choice session (linked sign-ийн `linkedSessionID`). */
|
|
711
|
+
certChoiceSessionId: string | null;
|
|
628
712
|
}
|
|
629
713
|
/**
|
|
630
714
|
* RevocationChecker — иргэний cert revoke хийгдсэн эсэхийг шалгах hook (OCSP/CRL).
|
|
@@ -728,6 +812,13 @@ declare class ResponseValidator {
|
|
|
728
812
|
* @param opts — `hashAlgorithm` мөр (хуучин хэлбэр; default SHA-256) эсвэл {@link ValidateSignOptions}.
|
|
729
813
|
*/
|
|
730
814
|
validateSign(result: SessionResult, digestB64: string, opts?: string | ValidateSignOptions): VerifiedSignature;
|
|
815
|
+
/**
|
|
816
|
+
* Certificate-choice session-ий хариуг шалгана: COMPLETE/OK (эс бөгөөс `SessionFailedError`), гэрчилгээ ба
|
|
817
|
+
* documentNumber байгаа, хугацаа, certLevel, зориулалт (гарын үсгийн — contentCommitment, `checkKeyUsage` үед), гинж,
|
|
818
|
+
* issuer. Энэ хариунд гарын үсэг БАЙХГҮЙ — иргэнийг таниагүй (нэвтрэлт биш); зөвхөн дараагийн sign session-ий
|
|
819
|
+
* гэрчилгээг урьдчилж мэдэхэд. `sessionId` — certificate-choice session.
|
|
820
|
+
*/
|
|
821
|
+
validateCertificateChoice(result: SessionResult, sessionId?: string | null): Signer;
|
|
731
822
|
/**
|
|
732
823
|
* Хариуны signatureAlgorithm + hashAlgorithm-ийг RP-ийн хүссэнтэй ба иргэний түлхүүрийн төрөлтэй тулгана
|
|
733
824
|
* (downgrade / alg confusion хаалт).
|
|
@@ -744,6 +835,10 @@ declare class ResponseValidator {
|
|
|
744
835
|
private algorithmOf;
|
|
745
836
|
/** state/endResult, cert байгаа эсэх, chain, validity, certLevel — нийтлэг шалгалт. */
|
|
746
837
|
private precheck;
|
|
838
|
+
/** COMPLETE + OK; амжилтгүй endResult → SessionFailedError. */
|
|
839
|
+
private sessionDone;
|
|
840
|
+
/** Хариуны гэрчилгээ: documentNumber, задлалт, хугацаа, certLevel, зориулалт (protocol), гинж, issuer. */
|
|
841
|
+
private leafOf;
|
|
747
842
|
/**
|
|
748
843
|
* checkKeyUsage үед гэрчилгээний зориулалт протоколд тохирох эсэх (CA crypto/ca_profile.go): ACSP_V2 (auth) → KU
|
|
749
844
|
* digitalSignature + EKU clientAuth (эсвэл anyExtendedKeyUsage); RAW_DIGEST_SIGNATURE (sign) → KU contentCommitment.
|
|
@@ -813,6 +908,12 @@ interface ClientConfig {
|
|
|
813
908
|
* Анхдагч: илгээхгүй (сервер mn).
|
|
814
909
|
*/
|
|
815
910
|
language?: string;
|
|
911
|
+
/**
|
|
912
|
+
* Sign / certificate-choice session-ий `expiresAt`-ийг тооцоолох хугацаа (мс). Анхдагч 600000
|
|
913
|
+
* ({@link DEFAULT_SIGN_SESSION_TTL_MS}, CA-ийн анхдагч); CA-ийн админ тохиргоог өөрчилсөн бол тааруул. CA session start
|
|
914
|
+
* хариунд хугацаа буцаадаггүй.
|
|
915
|
+
*/
|
|
916
|
+
signSessionTtlMs?: number;
|
|
816
917
|
/** Trust anchor (Root CA) — validator-д. Production-д ЗААВАЛ. */
|
|
817
918
|
trust?: TrustConfig;
|
|
818
919
|
}
|
|
@@ -916,6 +1017,12 @@ interface BuildDeviceLinkInput {
|
|
|
916
1017
|
* @throws {DeviceLinkError} оролт буруу (base https биш, token/lang/secret хэлбэр, төрөлд хэрэгтэй талбар дутуу).
|
|
917
1018
|
*/
|
|
918
1019
|
declare function buildDeviceLink(p: BuildDeviceLinkInput): string;
|
|
1020
|
+
/**
|
|
1021
|
+
* Session start-ын хариу + хүсэлтийн утгуудаас {@link buildDeviceLink}-ийн оролт (auth: `acsp`, sign: `sign`, cert:
|
|
1022
|
+
* `relyingPartyName`). `lang` — ISO 639-2 (`mon`, `eng`). Web2App/App2App-д session нь `callbackUrl`-тай эхэлсэн байх
|
|
1023
|
+
* ёстой (эс бөгөөс `buildDeviceLink` DeviceLinkError). sessionToken/sessionSecret алга бол buildDeviceLink татгалзана.
|
|
1024
|
+
*/
|
|
1025
|
+
declare function deviceLinkInput(s: DeviceLinkSession, deviceLinkType: DeviceLinkType, lang: string): BuildDeviceLinkInput;
|
|
919
1026
|
interface QrDeviceLinkTickerOptions {
|
|
920
1027
|
/** Шинэчлэх давтамж (мс). Анхдагч 1000 — Smart-ID-ийн шаардлага. */
|
|
921
1028
|
intervalMs?: number;
|
|
@@ -933,6 +1040,8 @@ declare function qrDeviceLinkTicker(input: Omit<BuildDeviceLinkInput, "deviceLin
|
|
|
933
1040
|
type EidLoginMode = "qr" | "push" | "web2app";
|
|
934
1041
|
/** Баталгаажсан иргэн — onSuccess-д. */
|
|
935
1042
|
interface EidLoginIdentity {
|
|
1043
|
+
/** RP-API session-ий id (`sessionId`) — аудит, эсвэл энэ нэвтрэлтийг дараагийн алхамтай (гарын үсэг г.м.) холбоход. */
|
|
1044
|
+
sessionId: string;
|
|
936
1045
|
/** Гэрчилгээний SERIALNUMBER (`PNOMN-<иргэний дугаар>`). Хэрэглэгчийг ҮҮГЭЭР таньна (нэрээр биш). */
|
|
937
1046
|
etsi: string;
|
|
938
1047
|
/** `PNOMN-`-гүй иргэний дугаар (цифр); ETSI өөр хэлбэртэй бол null. */
|
|
@@ -942,9 +1051,10 @@ interface EidLoginIdentity {
|
|
|
942
1051
|
surname: string | null;
|
|
943
1052
|
name: string | null;
|
|
944
1053
|
country: string | null;
|
|
1054
|
+
/** Иргэний баримтын дугаар (`PNOMN-…-MOBILE-Q` г.м.) — `client.sign.*ByDocument`-аар ижил төхөөрөмж рүү гарын үсэг. */
|
|
945
1055
|
documentNumber: string;
|
|
946
1056
|
certificateLevel: string;
|
|
947
|
-
/** Иргэний гэрчилгээ (DER, base64)
|
|
1057
|
+
/** Иргэний нэвтрэлтийн гэрчилгээ (DER, base64) — validateAuth-аар гинж шалгагдсан. */
|
|
948
1058
|
certificateDerB64: string;
|
|
949
1059
|
/** Гарын үсэг зурагдсан урсгал: QR | Notification | Web2App. */
|
|
950
1060
|
flowType: FlowType;
|
|
@@ -1026,6 +1136,19 @@ interface EidLoginOptions {
|
|
|
1026
1136
|
* Анхдагч: push-д нэг дугаарт 60 секундэд 3 (санах ойд) — хохирогчийн утсыг мэдэгдлээр дарахаас (MFA fatigue).
|
|
1027
1137
|
*/
|
|
1028
1138
|
rateLimit?: (key: string) => boolean | Promise<boolean>;
|
|
1139
|
+
/**
|
|
1140
|
+
* `handle(Request)`-ийн клиент IP (`start:<ip>` хязгаарт). Web-standard `Request`-д IP байдаггүй тул эсвэл энийг, эсвэл
|
|
1141
|
+
* {@link EidLoginOptions.trustProxy}-г өг; аль нь ч үгүй бол IP-ээр хязгаарлахгүй (анхны дуудлагад onError-оор анхааруулна).
|
|
1142
|
+
* Ж: Vercel/Next `req.headers.get("x-real-ip")`, Bun `server.requestIP(req)?.address`, Deno `info.remoteAddr.hostname`.
|
|
1143
|
+
*/
|
|
1144
|
+
getClientIp?: (req: Request) => string | undefined | null;
|
|
1145
|
+
/**
|
|
1146
|
+
* Итгэмжит reverse proxy-ийн ард: IP-г `X-Forwarded-For`-оос (байхгүй бол `X-Real-IP`) уншина.
|
|
1147
|
+
* `true` — XFF-ийн хамгийн зүүн утга (бүх hop итгэмжит; зөвхөн proxy нь клиентийн XFF-ийг дарж бичдэг бол);
|
|
1148
|
+
* тоо `n` — баруунаас n дахь утга (n = таны итгэмжит proxy-ийн тоо; nginx нэг бол 1). Proxy-гүй үед бүү асаа —
|
|
1149
|
+
* header-ийг клиент хуурамчаар илгээж хязгаарыг тойрно. `handleRequest`-д `req.ip` өгөөгүй үед ч хэрэглэгдэнэ.
|
|
1150
|
+
*/
|
|
1151
|
+
trustProxy?: boolean | number;
|
|
1029
1152
|
/** Дотоод алдаа (eID API, store). Анхдагч console.error (мессеж л). */
|
|
1030
1153
|
onError?: (err: unknown, ctx: EidLoginContext) => void;
|
|
1031
1154
|
}
|
|
@@ -1050,6 +1173,11 @@ interface EidLogin {
|
|
|
1050
1173
|
/** Web-standard (Next.js App Router, Hono, Bun, Deno). */
|
|
1051
1174
|
handle(req: Request): Promise<Response>;
|
|
1052
1175
|
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Итгэмжит proxy-ийн header-ээс клиент IP (`trustProxy`-ийн дүрэм). XFF-д хангалттай hop байхгүй бол хамгийн зүүн
|
|
1178
|
+
* утгыг (proxy-д ирсэн анхны) биш undefined буцаана — хуурамч header-ээр тойрохоос.
|
|
1179
|
+
*/
|
|
1180
|
+
declare function forwardedClientIp(headers: EidLoginRequest["headers"], trustProxy: boolean | number): string | undefined;
|
|
1053
1181
|
/** `callbackUrl`-д буцах хөтчийн hint (`retScheme` iOS / `retPkg` Android) нэмнэ; танихгүй бол хэвээр. */
|
|
1054
1182
|
declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
1055
1183
|
/**
|
|
@@ -1059,4 +1187,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1059
1187
|
*/
|
|
1060
1188
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1061
1189
|
|
|
1062
|
-
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_ISSUING_CA_SKI, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, DEFAULT_BASE_URL, DEFAULT_PDF_MAX_BYTES, DEFAULT_PDF_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, type EidLogin, type EidLoginContext, type EidLoginIdentity, type EidLoginMode, type EidLoginOptions, type EidLoginRequest, type EidLoginResponse, type EidLoginStore, type EidLoginSuccess, type EidLoginTx, FlowType, HashAlgorithm, Http, type HttpConfig, Interaction, NotificationSession, OrganizationApi, PdfApi, type PdfDefaults, type PdfPrepareInput, type PdfPrepareSession, PdfSessionBlock, type PdfSignerRef, type PdfTokenPrepareInput, type PdfTokenPrepareSession, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type QrDeviceLinkTickerOptions, RepresentationsResponse, ResponseValidator, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SessionApi, SessionResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, createEidLogin, interactionsToBase64, memoryLoginStore, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
|
1190
|
+
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_ISSUING_CA_SKI, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, DEFAULT_BASE_URL, DEFAULT_PDF_MAX_BYTES, DEFAULT_PDF_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, type EidLogin, type EidLoginContext, type EidLoginIdentity, type EidLoginMode, type EidLoginOptions, type EidLoginRequest, type EidLoginResponse, type EidLoginStore, type EidLoginSuccess, type EidLoginTx, FlowType, HashAlgorithm, Http, type HttpConfig, Interaction, NotificationSession, OrganizationApi, PdfApi, type PdfDefaults, type PdfPrepareInput, type PdfPrepareSession, PdfSessionBlock, type PdfSignerRef, type PdfTokenPrepareInput, type PdfTokenPrepareSession, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type QrDeviceLinkTickerOptions, RepresentationsResponse, ResponseValidator, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SessionApi, SessionResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, createEidLogin, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 PdfSessionBlock, c as RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-
|
|
2
|
-
export { d as ApiError, e as AuthenticationError, f as
|
|
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 PdfSessionBlock, c as RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-CuMH5IVG.js';
|
|
2
|
+
export { d as ApiError, e as AuthenticationError, f as DEFAULT_SIGN_SESSION_TTL_MS, g as DeviceLinkError, h as DeviceLinkInput, E as EidError, i as EndResult, j as ForbiddenError, k as HttpErrorInit, l as NavigatorLike, m as NetworkError, O as ON_BEHALF_ERROR_CODES, n as OnBehalfErrorCode, o as OpenOrShowQROptions, p as OrgResult, q as PdfDocumentStatus, r as PdfSigner, s as RETRYABLE_ERROR_CODES, t as Representation, u as ResponseTooLargeError, v as RetryableErrorCode, w as SessionFailedError, x as SessionState, y as SignContext, z as SignatureAlgorithmParameters, B as SignatureProtocol, T as TokenCertSessionBlock, G as TokenCertStatus, V as ValidationError, J as deviceLink, K as isMobileUserAgent, L as openOrShowQR, M as parseRetryAfter, Q as sessionExpiry } from './browser-CuMH5IVG.js';
|
|
3
3
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
4
4
|
|
|
5
5
|
interface HttpConfig {
|
|
@@ -83,17 +83,23 @@ declare class AuthApi {
|
|
|
83
83
|
|
|
84
84
|
interface SignDefaults {
|
|
85
85
|
certificateLevel: CertificateLevel;
|
|
86
|
+
/** Sign / certificate-choice session-ий `expiresAt`-ийг тооцоолох хугацаа (мс); undefined = 600000. */
|
|
87
|
+
sessionTtlMs?: number;
|
|
86
88
|
}
|
|
87
89
|
interface SignOptions {
|
|
88
90
|
certificateLevel?: CertificateLevel;
|
|
89
91
|
/**
|
|
90
|
-
* Same-device App2App буцах URL.
|
|
92
|
+
* Same-device App2App/Web2App буцах URL (initialCallbackUrl). Device link-д Web2App/App2App холбоос зөвхөн үүнтэй
|
|
93
|
+
* session-д хүчинтэй; host нь RP-ийн callbackHosts-д байх ёстой. Query-д буцах browser-ийн hint нэмэхийг ЗӨВЛӨНӨ
|
|
91
94
|
* (`?retScheme=` iOS / `?retPkg=` Android) — docs/RP_GEREGE_INTEGRATION.md §1.1b.
|
|
92
95
|
*/
|
|
93
96
|
callbackUrl?: string;
|
|
94
97
|
/** digest-ийн hash (default SHA-256). digest-ийг өөрөө бэлдсэн бол тааруулна (урт = hLen). */
|
|
95
98
|
hashAlgorithm?: HashAlgorithm;
|
|
96
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Гарын үсгийн алгоритм (default rsassa-pss; PKCS#1 v1.5 нь deprecated). `digestForSigner` / `deviceLinkForSigner`-д
|
|
101
|
+
* default `sha256WithRSAEncryption` (PAdES/CMS).
|
|
102
|
+
*/
|
|
97
103
|
signatureAlgorithm?: SignatureAlgorithm;
|
|
98
104
|
/**
|
|
99
105
|
* Байгууллагын нэрийн өмнөөс гарын үсэг (docs/ORG_LOGIN.md) — байгууллагын ETSI
|
|
@@ -108,22 +114,72 @@ interface SignOptions {
|
|
|
108
114
|
*/
|
|
109
115
|
fileName?: string;
|
|
110
116
|
}
|
|
117
|
+
/** Certificate-choice session-ий тохиргоо. */
|
|
118
|
+
interface CertChoiceOptions {
|
|
119
|
+
certificateLevel?: CertificateLevel;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Гарын үсэг зурах төхөөрөмж — `validator.validateCertificateChoice`-ийн үр дүн (эсвэл түүнээс хадгалсан утга).
|
|
123
|
+
* `documentNumber` — гэрчилгээг сонгосон ЯГ ТЭР төхөөрөмж; `certChoiceSessionId` байвал linked sign.
|
|
124
|
+
*/
|
|
125
|
+
interface SignerRef {
|
|
126
|
+
documentNumber: string;
|
|
127
|
+
certChoiceSessionId?: string | null;
|
|
128
|
+
}
|
|
111
129
|
declare class SignApi {
|
|
112
130
|
private readonly http;
|
|
113
131
|
private readonly creds;
|
|
114
132
|
private readonly defaults;
|
|
115
133
|
constructor(http: Http, creds: RpCredentials, defaults: SignDefaults);
|
|
116
134
|
private body;
|
|
117
|
-
private
|
|
135
|
+
private notification;
|
|
136
|
+
private deviceLink;
|
|
118
137
|
/**
|
|
119
138
|
* Бэлэн digest-ээр push sign (РД/civil_id/ETSI). Баримт (PDF/файл)-ын байтын SHA-256
|
|
120
139
|
* digest-ийг гаднаас бэлдэж өгнө — текст бус бинар баримтад тохиромжтой.
|
|
140
|
+
*
|
|
141
|
+
* ⚠️ Олон утастай иргэнд CA etsi-г ЭХНИЙ идэвхтэй төхөөрөмж рүү шийднэ. Гэрчилгээг урьдчилж мэдэх шаардлагатай бол
|
|
142
|
+
* (PAdES/CMS) {@link certificateChoiceByEtsi} → {@link digestForSigner}.
|
|
121
143
|
*/
|
|
122
144
|
digestByEtsi(id: string, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<NotificationSession>;
|
|
123
|
-
/** Бэлэн digest-ээр push sign — баримтын дугаараар (auth
|
|
145
|
+
/** Бэлэн digest-ээр push sign — баримтын дугаараар (auth / certificate-choice-оос гарсан documentNumber дээр). */
|
|
124
146
|
digestByDocument(documentNumber: string, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<NotificationSession>;
|
|
125
147
|
/** Текстийн SHA-256 digest-ийг дотроо тооцоод push sign (богино текст баримтад тохиромжтой). */
|
|
126
148
|
textByEtsi(id: string, text: string, interactions: Interaction[], opts?: SignOptions): Promise<NotificationSession>;
|
|
149
|
+
/**
|
|
150
|
+
* QR / Web2App / App2App sign — тодорхой иргэн (РД/civil_id/ETSI). Холбоосыг backend-д
|
|
151
|
+
* `buildDeviceLink(deviceLinkInput(s, type, lang))`-ээр; Web2App/App2App-д `callbackUrl` заавал.
|
|
152
|
+
* `validateSign`-д `expectedFlowType` = харуулсан холбоосын төрөл.
|
|
153
|
+
*/
|
|
154
|
+
deviceLinkByEtsi(id: string, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<DeviceLinkSession>;
|
|
155
|
+
/** QR / Web2App / App2App sign — баримтын дугаараар (тодорхой төхөөрөмж). */
|
|
156
|
+
deviceLinkByDocument(documentNumber: string, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<DeviceLinkSession>;
|
|
157
|
+
private certChoiceBody;
|
|
158
|
+
/**
|
|
159
|
+
* Push: иргэний (РД/civil_id/ETSI) утас руу гарын үсгийн гэрчилгээ сонгуулах хүсэлт (PIN-гүй). Үр дүнг
|
|
160
|
+
* `session.waitForResult` → `validator.validateCertificateChoice`. CERT эрх шаардана.
|
|
161
|
+
*/
|
|
162
|
+
certificateChoiceByEtsi(id: string, opts?: CertChoiceOptions): Promise<NotificationSession>;
|
|
163
|
+
/**
|
|
164
|
+
* QR: иргэн хэн болохыг урьдчилж мэдэхгүй үед гэрчилгээ сонгуулах. CA-ийн certificate-choice хүсэлт
|
|
165
|
+
* initialCallbackUrl авдаггүй тул ЗӨВХӨН QR холбоос (`deviceLinkInput(s, "QR", lang)`). CERT эрх.
|
|
166
|
+
*/
|
|
167
|
+
certificateChoiceDeviceLink(opts?: CertChoiceOptions): Promise<DeviceLinkSession>;
|
|
168
|
+
private signerBody;
|
|
169
|
+
/**
|
|
170
|
+
* Certificate-choice-оор сонгосон ЯГ ТЭР төхөөрөмж (`signer.documentNumber`) рүү push sign. Олон утастай иргэнд
|
|
171
|
+
* etsi-ээр эхлүүлбэл өөр утас (өөр гэрчилгээ) зурж, гэрчилгээг урьдчилж оруулсан CMS (PAdES signingCertificateV2)
|
|
172
|
+
* хүчингүй болдог — тиймээс digest-ийг ҮРГЭЛЖ documentNumber-аар зуруулна.
|
|
173
|
+
*
|
|
174
|
+
* `signer.certChoiceSessionId` байвал `/signature/notification/linked/{documentNumber}` (`linkedSessionID`), эс
|
|
175
|
+
* бөгөөс `/signature/notification/document/{documentNumber}`. Default `sha256WithRSAEncryption` + SHA-256 (digest =
|
|
176
|
+
* 32 байт DTBS); digest-ийн урт буруу бол хүсэлт явахгүй. Хариуг:
|
|
177
|
+
* `validator.validateSign(r, s.sign.digest, { hashAlgorithm: s.sign.hashAlgorithm, expectedAlgorithm:
|
|
178
|
+
* s.sign.signatureAlgorithm, expectedCertificate: signer.certificate, expectedFlowType: "Notification" })`.
|
|
179
|
+
*/
|
|
180
|
+
digestForSigner(signer: SignerRef, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<NotificationSession>;
|
|
181
|
+
/** {@link digestForSigner}-ийн QR / Web2App / App2App хувилбар: `/signature/device-link/document/{documentNumber}`. */
|
|
182
|
+
deviceLinkForSigner(signer: SignerRef, digestB64: string, interactions: Interaction[], opts?: SignOptions): Promise<DeviceLinkSession>;
|
|
127
183
|
}
|
|
128
184
|
|
|
129
185
|
/** RP-API-ийн session JSON-ийг SessionResult болгон задална (rpclient.ts-тэй ижил mapping). */
|
|
@@ -625,6 +681,34 @@ interface ValidateSignOptions {
|
|
|
625
681
|
* тулгалт, криптограф баталгаа биш.
|
|
626
682
|
*/
|
|
627
683
|
expectedFlowType?: FlowType;
|
|
684
|
+
/**
|
|
685
|
+
* Хүсэлтэд илгээсэн signatureAlgorithm (`s.sign.signatureAlgorithm`). Өгвөл хариуны RSA алгоритм ЯГ ИЖИЛ байх ёстой:
|
|
686
|
+
* `sha256WithRSAEncryption` хүссэн session-д `rsassa-pss` (эсвэл эсрэгээр) хариу → `ValidationError`. CA-ийн хуучин
|
|
687
|
+
* threshold-ECDSA credential хүссэнээс үл хамааран `ecdsa-with-SHA256` буцаадаг (түлхүүрийн төрөл гэрчилгээнд
|
|
688
|
+
* бэхлэгдсэн) — зөвхөн EC P-256 гэрчилгээ + SHA-256 үед зөвшөөрнө. Өгөөгүй бол хуучин зан (RSA алгоритмыг тулгахгүй).
|
|
689
|
+
*/
|
|
690
|
+
expectedAlgorithm?: SignatureAlgorithm;
|
|
691
|
+
/**
|
|
692
|
+
* Урьдчилж мэдсэн гэрчилгээ (certificate-choice: `signer.certificate`). Өгвөл хариуны гэрчилгээ байт-ижил байх ёстой —
|
|
693
|
+
* өөр төхөөрөмж/гэрчилгээгээр зурсан бол (олон утастай иргэн) `ValidationError`.
|
|
694
|
+
*/
|
|
695
|
+
expectedCertificate?: X509Certificate;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Certificate-choice-оор баталгаажсан гарын үсэг зурагч ({@link ResponseValidator.validateCertificateChoice}) —
|
|
699
|
+
* `sign.digestForSigner` / `sign.deviceLinkForSigner`-д өгнө.
|
|
700
|
+
*/
|
|
701
|
+
interface Signer {
|
|
702
|
+
/** Гэрчилгээг сонгосон ЯГ ТЭР төхөөрөмж — sign session-ийг ҮҮГЭЭР эхлүүлнэ. */
|
|
703
|
+
documentNumber: string;
|
|
704
|
+
/** Иргэний SIGN гэрчилгээ (KeyUsage contentCommitment). */
|
|
705
|
+
certificate: X509Certificate;
|
|
706
|
+
/** DER, стандарт base64. */
|
|
707
|
+
certificateDerB64: string;
|
|
708
|
+
certificateLevel: string;
|
|
709
|
+
parsedSubject: CertSubject;
|
|
710
|
+
/** Certificate-choice session (linked sign-ийн `linkedSessionID`). */
|
|
711
|
+
certChoiceSessionId: string | null;
|
|
628
712
|
}
|
|
629
713
|
/**
|
|
630
714
|
* RevocationChecker — иргэний cert revoke хийгдсэн эсэхийг шалгах hook (OCSP/CRL).
|
|
@@ -728,6 +812,13 @@ declare class ResponseValidator {
|
|
|
728
812
|
* @param opts — `hashAlgorithm` мөр (хуучин хэлбэр; default SHA-256) эсвэл {@link ValidateSignOptions}.
|
|
729
813
|
*/
|
|
730
814
|
validateSign(result: SessionResult, digestB64: string, opts?: string | ValidateSignOptions): VerifiedSignature;
|
|
815
|
+
/**
|
|
816
|
+
* Certificate-choice session-ий хариуг шалгана: COMPLETE/OK (эс бөгөөс `SessionFailedError`), гэрчилгээ ба
|
|
817
|
+
* documentNumber байгаа, хугацаа, certLevel, зориулалт (гарын үсгийн — contentCommitment, `checkKeyUsage` үед), гинж,
|
|
818
|
+
* issuer. Энэ хариунд гарын үсэг БАЙХГҮЙ — иргэнийг таниагүй (нэвтрэлт биш); зөвхөн дараагийн sign session-ий
|
|
819
|
+
* гэрчилгээг урьдчилж мэдэхэд. `sessionId` — certificate-choice session.
|
|
820
|
+
*/
|
|
821
|
+
validateCertificateChoice(result: SessionResult, sessionId?: string | null): Signer;
|
|
731
822
|
/**
|
|
732
823
|
* Хариуны signatureAlgorithm + hashAlgorithm-ийг RP-ийн хүссэнтэй ба иргэний түлхүүрийн төрөлтэй тулгана
|
|
733
824
|
* (downgrade / alg confusion хаалт).
|
|
@@ -744,6 +835,10 @@ declare class ResponseValidator {
|
|
|
744
835
|
private algorithmOf;
|
|
745
836
|
/** state/endResult, cert байгаа эсэх, chain, validity, certLevel — нийтлэг шалгалт. */
|
|
746
837
|
private precheck;
|
|
838
|
+
/** COMPLETE + OK; амжилтгүй endResult → SessionFailedError. */
|
|
839
|
+
private sessionDone;
|
|
840
|
+
/** Хариуны гэрчилгээ: documentNumber, задлалт, хугацаа, certLevel, зориулалт (protocol), гинж, issuer. */
|
|
841
|
+
private leafOf;
|
|
747
842
|
/**
|
|
748
843
|
* checkKeyUsage үед гэрчилгээний зориулалт протоколд тохирох эсэх (CA crypto/ca_profile.go): ACSP_V2 (auth) → KU
|
|
749
844
|
* digitalSignature + EKU clientAuth (эсвэл anyExtendedKeyUsage); RAW_DIGEST_SIGNATURE (sign) → KU contentCommitment.
|
|
@@ -813,6 +908,12 @@ interface ClientConfig {
|
|
|
813
908
|
* Анхдагч: илгээхгүй (сервер mn).
|
|
814
909
|
*/
|
|
815
910
|
language?: string;
|
|
911
|
+
/**
|
|
912
|
+
* Sign / certificate-choice session-ий `expiresAt`-ийг тооцоолох хугацаа (мс). Анхдагч 600000
|
|
913
|
+
* ({@link DEFAULT_SIGN_SESSION_TTL_MS}, CA-ийн анхдагч); CA-ийн админ тохиргоог өөрчилсөн бол тааруул. CA session start
|
|
914
|
+
* хариунд хугацаа буцаадаггүй.
|
|
915
|
+
*/
|
|
916
|
+
signSessionTtlMs?: number;
|
|
816
917
|
/** Trust anchor (Root CA) — validator-д. Production-д ЗААВАЛ. */
|
|
817
918
|
trust?: TrustConfig;
|
|
818
919
|
}
|
|
@@ -916,6 +1017,12 @@ interface BuildDeviceLinkInput {
|
|
|
916
1017
|
* @throws {DeviceLinkError} оролт буруу (base https биш, token/lang/secret хэлбэр, төрөлд хэрэгтэй талбар дутуу).
|
|
917
1018
|
*/
|
|
918
1019
|
declare function buildDeviceLink(p: BuildDeviceLinkInput): string;
|
|
1020
|
+
/**
|
|
1021
|
+
* Session start-ын хариу + хүсэлтийн утгуудаас {@link buildDeviceLink}-ийн оролт (auth: `acsp`, sign: `sign`, cert:
|
|
1022
|
+
* `relyingPartyName`). `lang` — ISO 639-2 (`mon`, `eng`). Web2App/App2App-д session нь `callbackUrl`-тай эхэлсэн байх
|
|
1023
|
+
* ёстой (эс бөгөөс `buildDeviceLink` DeviceLinkError). sessionToken/sessionSecret алга бол buildDeviceLink татгалзана.
|
|
1024
|
+
*/
|
|
1025
|
+
declare function deviceLinkInput(s: DeviceLinkSession, deviceLinkType: DeviceLinkType, lang: string): BuildDeviceLinkInput;
|
|
919
1026
|
interface QrDeviceLinkTickerOptions {
|
|
920
1027
|
/** Шинэчлэх давтамж (мс). Анхдагч 1000 — Smart-ID-ийн шаардлага. */
|
|
921
1028
|
intervalMs?: number;
|
|
@@ -933,6 +1040,8 @@ declare function qrDeviceLinkTicker(input: Omit<BuildDeviceLinkInput, "deviceLin
|
|
|
933
1040
|
type EidLoginMode = "qr" | "push" | "web2app";
|
|
934
1041
|
/** Баталгаажсан иргэн — onSuccess-д. */
|
|
935
1042
|
interface EidLoginIdentity {
|
|
1043
|
+
/** RP-API session-ий id (`sessionId`) — аудит, эсвэл энэ нэвтрэлтийг дараагийн алхамтай (гарын үсэг г.м.) холбоход. */
|
|
1044
|
+
sessionId: string;
|
|
936
1045
|
/** Гэрчилгээний SERIALNUMBER (`PNOMN-<иргэний дугаар>`). Хэрэглэгчийг ҮҮГЭЭР таньна (нэрээр биш). */
|
|
937
1046
|
etsi: string;
|
|
938
1047
|
/** `PNOMN-`-гүй иргэний дугаар (цифр); ETSI өөр хэлбэртэй бол null. */
|
|
@@ -942,9 +1051,10 @@ interface EidLoginIdentity {
|
|
|
942
1051
|
surname: string | null;
|
|
943
1052
|
name: string | null;
|
|
944
1053
|
country: string | null;
|
|
1054
|
+
/** Иргэний баримтын дугаар (`PNOMN-…-MOBILE-Q` г.м.) — `client.sign.*ByDocument`-аар ижил төхөөрөмж рүү гарын үсэг. */
|
|
945
1055
|
documentNumber: string;
|
|
946
1056
|
certificateLevel: string;
|
|
947
|
-
/** Иргэний гэрчилгээ (DER, base64)
|
|
1057
|
+
/** Иргэний нэвтрэлтийн гэрчилгээ (DER, base64) — validateAuth-аар гинж шалгагдсан. */
|
|
948
1058
|
certificateDerB64: string;
|
|
949
1059
|
/** Гарын үсэг зурагдсан урсгал: QR | Notification | Web2App. */
|
|
950
1060
|
flowType: FlowType;
|
|
@@ -1026,6 +1136,19 @@ interface EidLoginOptions {
|
|
|
1026
1136
|
* Анхдагч: push-д нэг дугаарт 60 секундэд 3 (санах ойд) — хохирогчийн утсыг мэдэгдлээр дарахаас (MFA fatigue).
|
|
1027
1137
|
*/
|
|
1028
1138
|
rateLimit?: (key: string) => boolean | Promise<boolean>;
|
|
1139
|
+
/**
|
|
1140
|
+
* `handle(Request)`-ийн клиент IP (`start:<ip>` хязгаарт). Web-standard `Request`-д IP байдаггүй тул эсвэл энийг, эсвэл
|
|
1141
|
+
* {@link EidLoginOptions.trustProxy}-г өг; аль нь ч үгүй бол IP-ээр хязгаарлахгүй (анхны дуудлагад onError-оор анхааруулна).
|
|
1142
|
+
* Ж: Vercel/Next `req.headers.get("x-real-ip")`, Bun `server.requestIP(req)?.address`, Deno `info.remoteAddr.hostname`.
|
|
1143
|
+
*/
|
|
1144
|
+
getClientIp?: (req: Request) => string | undefined | null;
|
|
1145
|
+
/**
|
|
1146
|
+
* Итгэмжит reverse proxy-ийн ард: IP-г `X-Forwarded-For`-оос (байхгүй бол `X-Real-IP`) уншина.
|
|
1147
|
+
* `true` — XFF-ийн хамгийн зүүн утга (бүх hop итгэмжит; зөвхөн proxy нь клиентийн XFF-ийг дарж бичдэг бол);
|
|
1148
|
+
* тоо `n` — баруунаас n дахь утга (n = таны итгэмжит proxy-ийн тоо; nginx нэг бол 1). Proxy-гүй үед бүү асаа —
|
|
1149
|
+
* header-ийг клиент хуурамчаар илгээж хязгаарыг тойрно. `handleRequest`-д `req.ip` өгөөгүй үед ч хэрэглэгдэнэ.
|
|
1150
|
+
*/
|
|
1151
|
+
trustProxy?: boolean | number;
|
|
1029
1152
|
/** Дотоод алдаа (eID API, store). Анхдагч console.error (мессеж л). */
|
|
1030
1153
|
onError?: (err: unknown, ctx: EidLoginContext) => void;
|
|
1031
1154
|
}
|
|
@@ -1050,6 +1173,11 @@ interface EidLogin {
|
|
|
1050
1173
|
/** Web-standard (Next.js App Router, Hono, Bun, Deno). */
|
|
1051
1174
|
handle(req: Request): Promise<Response>;
|
|
1052
1175
|
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Итгэмжит proxy-ийн header-ээс клиент IP (`trustProxy`-ийн дүрэм). XFF-д хангалттай hop байхгүй бол хамгийн зүүн
|
|
1178
|
+
* утгыг (proxy-д ирсэн анхны) биш undefined буцаана — хуурамч header-ээр тойрохоос.
|
|
1179
|
+
*/
|
|
1180
|
+
declare function forwardedClientIp(headers: EidLoginRequest["headers"], trustProxy: boolean | number): string | undefined;
|
|
1053
1181
|
/** `callbackUrl`-д буцах хөтчийн hint (`retScheme` iOS / `retPkg` Android) нэмнэ; танихгүй бол хэвээр. */
|
|
1054
1182
|
declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
1055
1183
|
/**
|
|
@@ -1059,4 +1187,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1059
1187
|
*/
|
|
1060
1188
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1061
1189
|
|
|
1062
|
-
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_ISSUING_CA_SKI, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, DEFAULT_BASE_URL, DEFAULT_PDF_MAX_BYTES, DEFAULT_PDF_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, type EidLogin, type EidLoginContext, type EidLoginIdentity, type EidLoginMode, type EidLoginOptions, type EidLoginRequest, type EidLoginResponse, type EidLoginStore, type EidLoginSuccess, type EidLoginTx, FlowType, HashAlgorithm, Http, type HttpConfig, Interaction, NotificationSession, OrganizationApi, PdfApi, type PdfDefaults, type PdfPrepareInput, type PdfPrepareSession, PdfSessionBlock, type PdfSignerRef, type PdfTokenPrepareInput, type PdfTokenPrepareSession, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type QrDeviceLinkTickerOptions, RepresentationsResponse, ResponseValidator, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SessionApi, SessionResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, createEidLogin, interactionsToBase64, memoryLoginStore, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
|
1190
|
+
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_ISSUING_CA_SKI, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, DEFAULT_BASE_URL, DEFAULT_PDF_MAX_BYTES, DEFAULT_PDF_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, type EidLogin, type EidLoginContext, type EidLoginIdentity, type EidLoginMode, type EidLoginOptions, type EidLoginRequest, type EidLoginResponse, type EidLoginStore, type EidLoginSuccess, type EidLoginTx, FlowType, HashAlgorithm, Http, type HttpConfig, Interaction, NotificationSession, OrganizationApi, PdfApi, type PdfDefaults, type PdfPrepareInput, type PdfPrepareSession, PdfSessionBlock, type PdfSignerRef, type PdfTokenPrepareInput, type PdfTokenPrepareSession, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type QrDeviceLinkTickerOptions, RepresentationsResponse, ResponseValidator, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SessionApi, SessionResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, createEidLogin, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|