@gerege-systems/eid-mongolia-sdk 0.13.0 → 0.14.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 +78 -102
- package/dist/button.cjs +952 -0
- package/dist/button.d.cts +79 -0
- package/dist/button.d.ts +79 -0
- package/dist/button.js +923 -0
- package/dist/index.cjs +350 -282
- package/dist/index.d.cts +122 -142
- package/dist/index.d.ts +122 -142
- package/dist/index.js +349 -278
- package/package.json +12 -4
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
|
|
2
|
-
export { d as ApiError, e as AuthenticationError, f as DeviceLinkError, g as DeviceLinkInput, h as EndResult, i as ForbiddenError, j as HttpErrorInit, k as NavigatorLike, l as NetworkError, O as ON_BEHALF_ERROR_CODES, m as OnBehalfErrorCode, n as OpenOrShowQROptions, o as OrgResult, p as PdfDocumentStatus, q as PdfSigner, r as RETRYABLE_ERROR_CODES, s as Representation, t as ResponseTooLargeError, u as RetryableErrorCode, v as SessionFailedError, w as SessionState, x as SignatureAlgorithmParameters, y as SignatureProtocol, T as TokenCertSessionBlock, z as TokenCertStatus, V as ValidationError, B as deviceLink, G as isMobileUserAgent, J as openOrShowQR, K as parseRetryAfter } from './browser-C6JHm0lR.cjs';
|
|
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-C6JHm0lR.cjs';
|
|
2
|
+
export { d as ApiError, e as AuthenticationError, f as DeviceLinkError, g as DeviceLinkInput, E as EidError, h as EndResult, i as ForbiddenError, j as HttpErrorInit, k as NavigatorLike, l as NetworkError, O as ON_BEHALF_ERROR_CODES, m as OnBehalfErrorCode, n as OpenOrShowQROptions, o as OrgResult, p as PdfDocumentStatus, q as PdfSigner, r as RETRYABLE_ERROR_CODES, s as Representation, t as ResponseTooLargeError, u as RetryableErrorCode, v as SessionFailedError, w as SessionState, x as SignatureAlgorithmParameters, y as SignatureProtocol, T as TokenCertSessionBlock, z as TokenCertStatus, V as ValidationError, B as deviceLink, G as isMobileUserAgent, J as openOrShowQR, K as parseRetryAfter } from './browser-C6JHm0lR.cjs';
|
|
3
3
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
4
4
|
|
|
5
5
|
interface HttpConfig {
|
|
@@ -829,6 +829,8 @@ declare class EidClient {
|
|
|
829
829
|
readonly token: TokenApi;
|
|
830
830
|
readonly session: SessionApi;
|
|
831
831
|
readonly validator: ResponseValidator;
|
|
832
|
+
/** `credentials.rpName` — иргэний утсанд харагдах RP нэр. */
|
|
833
|
+
readonly rpName: string;
|
|
832
834
|
constructor(cfg: ClientConfig);
|
|
833
835
|
}
|
|
834
836
|
|
|
@@ -927,156 +929,134 @@ interface QrDeviceLinkTickerOptions {
|
|
|
927
929
|
*/
|
|
928
930
|
declare function qrDeviceLinkTicker(input: Omit<BuildDeviceLinkInput, "deviceLinkType" | "now">, onLink: (link: string) => void, opts?: QrDeviceLinkTickerOptions): () => void;
|
|
929
931
|
|
|
930
|
-
/**
|
|
931
|
-
|
|
932
|
-
/**
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
*/
|
|
950
|
-
|
|
951
|
-
readonly code: EidOidcErrorCode;
|
|
952
|
-
readonly description?: string | undefined;
|
|
953
|
-
constructor(code: EidOidcErrorCode, message: string, description?: string | undefined);
|
|
954
|
-
}
|
|
955
|
-
interface EidOidcClientConfig {
|
|
956
|
-
/** RP UUID (`relyingPartyUUID`). */
|
|
957
|
-
clientId: string;
|
|
958
|
-
/** RP API secret (`rp_sk_…`) — зөвхөн backend-д. */
|
|
959
|
-
clientSecret: string;
|
|
960
|
-
/** Бүртгэлтэй redirect URI — тэмдэгт бүрээрээ таарах ёстой. */
|
|
961
|
-
redirectUri: string;
|
|
962
|
-
/** Анхдагч {@link EID_OIDC_ISSUER}. */
|
|
963
|
-
issuer?: string;
|
|
964
|
-
/** Анхдагч `"openid"`. Иргэний ETSI дугаар хэрэгтэй бол `"openid pnomn"` (RP-д `PNOMN` эрх). */
|
|
965
|
-
scope?: string;
|
|
966
|
-
/** HTTP timeout (мс), анхдагч 10000. */
|
|
967
|
-
timeoutMs?: number;
|
|
968
|
-
/**
|
|
969
|
-
* undici Dispatcher (mTLS client cert) — RP-API client-ийн `dispatcher`-тэй ижил:
|
|
970
|
-
* `new Agent({ connect: { cert, key } })`. Дамжуулсан бол OIDC-ийн бүх fetch-д хэрэглэнэ. Зөвхөн Node орчинд.
|
|
971
|
-
*/
|
|
972
|
-
dispatcher?: unknown;
|
|
973
|
-
/**
|
|
974
|
-
* RFC 8705 §5: `true` бол code солих хүсэлт discovery-ийн `mtls_endpoint_aliases.token_endpoint` руу явна
|
|
975
|
-
* (`require_mtls`-тэй RP — `dispatcher`-т RP-ийн client cert заавал). Discovery-д alias байхгүй бол
|
|
976
|
-
* `token_endpoint` руу буцна; alias https биш бол `discovery_failed`. Анхдагч `false`.
|
|
977
|
-
*/
|
|
978
|
-
useMtlsEndpointAliases?: boolean;
|
|
979
|
-
/** fetch орлуулагч (тест). */
|
|
980
|
-
fetchImpl?: typeof fetch;
|
|
981
|
-
}
|
|
982
|
-
interface EidOidcDiscovery {
|
|
983
|
-
issuer: string;
|
|
984
|
-
authorization_endpoint: string;
|
|
985
|
-
token_endpoint: string;
|
|
986
|
-
jwks_uri: string;
|
|
987
|
-
/** RFC 8705 §5 — mTLS-тэй client-ийн endpoint-ууд (ж: `token_endpoint` → `https://rp.eidmongolia.mn/oauth2/token`). */
|
|
988
|
-
mtls_endpoint_aliases?: Record<string, string>;
|
|
989
|
-
[k: string]: unknown;
|
|
990
|
-
}
|
|
991
|
-
interface CreateAuthorizationOptions {
|
|
992
|
-
/** Энэ хүсэлтэд scope-ыг дарна. */
|
|
993
|
-
scope?: string;
|
|
994
|
-
/**
|
|
995
|
-
* `touch` (анхдагч) — утасны хөтчөөс шууд eID апп; `page` — үргэлж нэвтрэх хуудас (QR / push), ж: таблет киоск.
|
|
996
|
-
*/
|
|
997
|
-
display?: "page" | "touch";
|
|
932
|
+
/** Нэвтрэлтийн горим: desktop QR, регистрээр push, утасны хөтчөөс Web2App. */
|
|
933
|
+
type EidLoginMode = "qr" | "push" | "web2app";
|
|
934
|
+
/** Баталгаажсан иргэн — onSuccess-д. */
|
|
935
|
+
interface EidLoginIdentity {
|
|
936
|
+
/** Гэрчилгээний SERIALNUMBER (`PNOMN-<иргэний дугаар>`). Хэрэглэгчийг ҮҮГЭЭР таньна (нэрээр биш). */
|
|
937
|
+
etsi: string;
|
|
938
|
+
/** `PNOMN-`-гүй иргэний дугаар (цифр); ETSI өөр хэлбэртэй бол null. */
|
|
939
|
+
civilId: string | null;
|
|
940
|
+
/** Гэрчилгээний нэр (латин): GIVENNAME / SURNAME, харуулах нэр. */
|
|
941
|
+
givenName: string | null;
|
|
942
|
+
surname: string | null;
|
|
943
|
+
name: string | null;
|
|
944
|
+
country: string | null;
|
|
945
|
+
documentNumber: string;
|
|
946
|
+
certificateLevel: string;
|
|
947
|
+
/** Иргэний гэрчилгээ (DER, base64). */
|
|
948
|
+
certificateDerB64: string;
|
|
949
|
+
/** Гарын үсэг зурагдсан урсгал: QR | Notification | Web2App. */
|
|
950
|
+
flowType: FlowType;
|
|
951
|
+
/** Session-ийн `person` блок (кирилл нэр г.м.) — гэрчилгээтэй таарсан үед л, эс бөгөөс null. */
|
|
952
|
+
person: PersonBlock | null;
|
|
998
953
|
}
|
|
999
|
-
/**
|
|
1000
|
-
interface
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
954
|
+
/** Серверт хадгалах нэвтрэлтийн төлөв (JSON-д хувирна). */
|
|
955
|
+
interface EidLoginTx {
|
|
956
|
+
sessionId: string;
|
|
957
|
+
/** Cookie-ийн binding-ийн SHA-256 (hex) — түүхий утга хөтчид л. */
|
|
958
|
+
bindingHash: string;
|
|
959
|
+
mode: EidLoginMode;
|
|
960
|
+
expiresAt: number;
|
|
961
|
+
vc: string | null;
|
|
962
|
+
acsp: AcspContext;
|
|
963
|
+
/** QR/Web2App: холбоос угсрах материал. sessionSecret — ЗӨВХӨН серверт. */
|
|
964
|
+
link?: {
|
|
965
|
+
base: string;
|
|
966
|
+
token: string;
|
|
967
|
+
secret: string;
|
|
968
|
+
receivedAt: number;
|
|
969
|
+
lang: string;
|
|
970
|
+
};
|
|
1006
971
|
}
|
|
1007
|
-
/**
|
|
1008
|
-
interface
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
972
|
+
/** Төлөвийн сан. Анхдагч — процессын санах ой ({@link memoryLoginStore}); олон instance бол Redis г.м. */
|
|
973
|
+
interface EidLoginStore {
|
|
974
|
+
get(sessionId: string): Promise<EidLoginTx | undefined> | EidLoginTx | undefined;
|
|
975
|
+
set(sessionId: string, tx: EidLoginTx, ttlMs: number): Promise<void> | void;
|
|
976
|
+
/** Устгана; байсан бол true. Амжилтыг нэг л удаа гаргахад ашиглана (атомар байх ёстой — Redis `DEL`). */
|
|
977
|
+
delete(sessionId: string): Promise<boolean> | boolean;
|
|
1012
978
|
}
|
|
1013
|
-
/**
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
sub: string;
|
|
1020
|
-
exp: number;
|
|
1021
|
-
iat: number;
|
|
1022
|
-
nonce: string;
|
|
1023
|
-
/** Иргэн баталгаажуулсан мөч (Unix сек). */
|
|
1024
|
-
auth_time: number;
|
|
1025
|
-
/** {@link EID_ACR_QUALIFIED} эсвэл {@link EID_ACR_ADVANCED}. */
|
|
1026
|
-
acr: string;
|
|
1027
|
-
/** Гэрчилгээний GIVENNAME — латин (ICAO, том үсэг). */
|
|
1028
|
-
given_name: string;
|
|
1029
|
-
/** Гэрчилгээний SURNAME (эцэг/эхийн нэр) — латин. */
|
|
1030
|
-
family_name: string;
|
|
1031
|
-
/** Нэр — кирилл (бүртгэлд байхгүй бол алга). */
|
|
1032
|
-
given_name_mn?: string;
|
|
1033
|
-
/** Эцэг/эхийн нэр — кирилл (бүртгэлд байхгүй бол алга). */
|
|
1034
|
-
family_name_mn?: string;
|
|
1035
|
-
/** `PNOMN-<иргэний дугаар>` — зөвхөн `pnomn` scope + `PNOMN` эрхтэй үед. */
|
|
1036
|
-
pnomn?: string;
|
|
1037
|
-
[k: string]: unknown;
|
|
979
|
+
/** Нэг процессын санах ойн сан (TTL-тэй). Олон instance / serverless-д тохирохгүй. */
|
|
980
|
+
declare function memoryLoginStore(): EidLoginStore;
|
|
981
|
+
/** Хүсэлтийн хүрээ — onSuccess / rateLimit / onError-д. */
|
|
982
|
+
interface EidLoginContext {
|
|
983
|
+
request: EidLoginRequest;
|
|
984
|
+
mode: EidLoginMode;
|
|
1038
985
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
986
|
+
/** onSuccess-ийн хариу: хаашаа явуулах, хөтчид буцаах өгөгдөл, нэмэлт header (ж: таны session-ийн Set-Cookie). */
|
|
987
|
+
interface EidLoginSuccess {
|
|
988
|
+
/** Нэвтэрсний дараах хуудас (same-origin зам эсвэл URL). Callback (Web2App)-д анхдагч `successRedirect`. */
|
|
989
|
+
redirect?: string;
|
|
990
|
+
/** QR/push-д status хариунд `data` болж хөтчид очно (JSON). Нууц бүү оруул. */
|
|
991
|
+
data?: unknown;
|
|
992
|
+
headers?: Record<string, string | string[]>;
|
|
1042
993
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
readonly issuer: string;
|
|
1046
|
-
private readonly scope;
|
|
1047
|
-
private discovery?;
|
|
1048
|
-
private jwks?;
|
|
1049
|
-
constructor(cfg: EidOidcClientConfig);
|
|
1050
|
-
/** Discovery document (1 цаг cache). `issuer` нь тохиргоотой яг таарах ёстой (OIDC Discovery §4.3). */
|
|
1051
|
-
discover(): Promise<EidOidcDiscovery>;
|
|
1052
|
-
private fetchDiscovery;
|
|
994
|
+
interface EidLoginOptions {
|
|
995
|
+
client: EidClient;
|
|
1053
996
|
/**
|
|
1054
|
-
*
|
|
1055
|
-
*
|
|
997
|
+
* RP-ийн session-ийг ЭНД үүсгэнэ (иргэн баталгаажсан). Хэрэглэгчийг `identity.etsi`-ээр таньж, шинэ session
|
|
998
|
+
* (session fixation-аас сэргийлж шинэ id) үүсгээд Set-Cookie-г `headers`-ээр буцаа.
|
|
1056
999
|
*/
|
|
1057
|
-
|
|
1000
|
+
onSuccess: (identity: EidLoginIdentity, ctx: EidLoginContext) => Promise<EidLoginSuccess | void> | EidLoginSuccess | void;
|
|
1058
1001
|
/**
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
* Амжилтгүй бүх тохиолдолд {@link EidOidcError} (эсвэл {@link NetworkError}) шиднэ.
|
|
1002
|
+
* Web2App буцах https URL — host нь RP-ийн `callbackHosts`-д, зам нь ЗААВАЛ `/auth/eid/callback`. Өгөөгүй бол
|
|
1003
|
+
* утасны хөтчийн урсгал (`mode=web2app`) 400 — QR/push л ажиллана.
|
|
1062
1004
|
*/
|
|
1063
|
-
|
|
1064
|
-
/**
|
|
1065
|
-
|
|
1066
|
-
/**
|
|
1067
|
-
|
|
1005
|
+
callbackUrl?: string;
|
|
1006
|
+
/** Callback амжилттай болоход (onSuccess redirect өгөөгүй бол). Анхдагч "/". */
|
|
1007
|
+
successRedirect?: string;
|
|
1008
|
+
/** Callback амжилтгүй болоход — `?eid_error=<код>` нэмэгдэнэ. Анхдагч "/". */
|
|
1009
|
+
failureRedirect?: string;
|
|
1010
|
+
/** Утсанд харагдах текст (≤60). Анхдагч «<rpName>-д нэвтрэх». */
|
|
1011
|
+
displayText?: string;
|
|
1012
|
+
certificateLevel?: CertificateLevel;
|
|
1013
|
+
/** Нэвтрэлтийн хугацаа (мс). Анхдагч 120 000. */
|
|
1014
|
+
ttlMs?: number;
|
|
1015
|
+
/** Status-ийн нэг дуудлагад eID-ийг хүлээх (мс). Анхдагч 1000. */
|
|
1016
|
+
pollMs?: number;
|
|
1017
|
+
store?: EidLoginStore;
|
|
1018
|
+
cookie?: {
|
|
1019
|
+
name?: string;
|
|
1020
|
+
path?: string;
|
|
1021
|
+
secure?: boolean;
|
|
1022
|
+
domain?: string;
|
|
1023
|
+
};
|
|
1068
1024
|
/**
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1025
|
+
* Хязгаарлалт: `start:<ip>` (ip мэдэгдэж байвал) ба `push:<idCode>` түлхүүрээр дуудагдана; false → 429.
|
|
1026
|
+
* Анхдагч: push-д нэг дугаарт 60 секундэд 3 (санах ойд) — хохирогчийн утсыг мэдэгдлээр дарахаас (MFA fatigue).
|
|
1071
1027
|
*/
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1028
|
+
rateLimit?: (key: string) => boolean | Promise<boolean>;
|
|
1029
|
+
/** Дотоод алдаа (eID API, store). Анхдагч console.error (мессеж л). */
|
|
1030
|
+
onError?: (err: unknown, ctx: EidLoginContext) => void;
|
|
1031
|
+
}
|
|
1032
|
+
/** Framework-аас хамааралгүй хүсэлт (Express: `req.headers`, `req.body`, `req.ip`). */
|
|
1033
|
+
interface EidLoginRequest {
|
|
1034
|
+
method: string;
|
|
1035
|
+
/** Зам + query (`/auth/eid/status?…`) эсвэл бүтэн URL. */
|
|
1036
|
+
url: string;
|
|
1037
|
+
headers: Record<string, string | string[] | undefined>;
|
|
1038
|
+
/** POST-ийн задалсан JSON (Express `express.json()`), эсвэл түүхий мөр. */
|
|
1039
|
+
body?: unknown;
|
|
1040
|
+
ip?: string;
|
|
1041
|
+
}
|
|
1042
|
+
interface EidLoginResponse {
|
|
1043
|
+
status: number;
|
|
1044
|
+
headers: Record<string, string | string[]>;
|
|
1045
|
+
body: string;
|
|
1078
1046
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1047
|
+
interface EidLogin {
|
|
1048
|
+
/** Сүүлийн замын хэсгээр (`start` | `status` | `callback`) чиглүүлнэ. */
|
|
1049
|
+
handleRequest(req: EidLoginRequest): Promise<EidLoginResponse>;
|
|
1050
|
+
/** Web-standard (Next.js App Router, Hono, Bun, Deno). */
|
|
1051
|
+
handle(req: Request): Promise<Response>;
|
|
1052
|
+
}
|
|
1053
|
+
/** `callbackUrl`-д буцах хөтчийн hint (`retScheme` iOS / `retPkg` Android) нэмнэ; танихгүй бол хэвээр. */
|
|
1054
|
+
declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
1055
|
+
/**
|
|
1056
|
+
* «eID-ээр нэвтрэх»-ийн backend handler-ууд. Нэг instance-ийг модулийн түвшинд үүсгээд бүх хүсэлтэд ашиглана.
|
|
1057
|
+
*
|
|
1058
|
+
* @throws Error `callbackUrl` https биш эсвэл зам нь `/auth/eid/callback` биш бол.
|
|
1059
|
+
*/
|
|
1060
|
+
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1081
1061
|
|
|
1082
|
-
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,
|
|
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 };
|
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
|
|
2
|
-
export { d as ApiError, e as AuthenticationError, f as DeviceLinkError, g as DeviceLinkInput, h as EndResult, i as ForbiddenError, j as HttpErrorInit, k as NavigatorLike, l as NetworkError, O as ON_BEHALF_ERROR_CODES, m as OnBehalfErrorCode, n as OpenOrShowQROptions, o as OrgResult, p as PdfDocumentStatus, q as PdfSigner, r as RETRYABLE_ERROR_CODES, s as Representation, t as ResponseTooLargeError, u as RetryableErrorCode, v as SessionFailedError, w as SessionState, x as SignatureAlgorithmParameters, y as SignatureProtocol, T as TokenCertSessionBlock, z as TokenCertStatus, V as ValidationError, B as deviceLink, G as isMobileUserAgent, J as openOrShowQR, K as parseRetryAfter } from './browser-C6JHm0lR.js';
|
|
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-C6JHm0lR.js';
|
|
2
|
+
export { d as ApiError, e as AuthenticationError, f as DeviceLinkError, g as DeviceLinkInput, E as EidError, h as EndResult, i as ForbiddenError, j as HttpErrorInit, k as NavigatorLike, l as NetworkError, O as ON_BEHALF_ERROR_CODES, m as OnBehalfErrorCode, n as OpenOrShowQROptions, o as OrgResult, p as PdfDocumentStatus, q as PdfSigner, r as RETRYABLE_ERROR_CODES, s as Representation, t as ResponseTooLargeError, u as RetryableErrorCode, v as SessionFailedError, w as SessionState, x as SignatureAlgorithmParameters, y as SignatureProtocol, T as TokenCertSessionBlock, z as TokenCertStatus, V as ValidationError, B as deviceLink, G as isMobileUserAgent, J as openOrShowQR, K as parseRetryAfter } from './browser-C6JHm0lR.js';
|
|
3
3
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
4
4
|
|
|
5
5
|
interface HttpConfig {
|
|
@@ -829,6 +829,8 @@ declare class EidClient {
|
|
|
829
829
|
readonly token: TokenApi;
|
|
830
830
|
readonly session: SessionApi;
|
|
831
831
|
readonly validator: ResponseValidator;
|
|
832
|
+
/** `credentials.rpName` — иргэний утсанд харагдах RP нэр. */
|
|
833
|
+
readonly rpName: string;
|
|
832
834
|
constructor(cfg: ClientConfig);
|
|
833
835
|
}
|
|
834
836
|
|
|
@@ -927,156 +929,134 @@ interface QrDeviceLinkTickerOptions {
|
|
|
927
929
|
*/
|
|
928
930
|
declare function qrDeviceLinkTicker(input: Omit<BuildDeviceLinkInput, "deviceLinkType" | "now">, onLink: (link: string) => void, opts?: QrDeviceLinkTickerOptions): () => void;
|
|
929
931
|
|
|
930
|
-
/**
|
|
931
|
-
|
|
932
|
-
/**
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
*/
|
|
950
|
-
|
|
951
|
-
readonly code: EidOidcErrorCode;
|
|
952
|
-
readonly description?: string | undefined;
|
|
953
|
-
constructor(code: EidOidcErrorCode, message: string, description?: string | undefined);
|
|
954
|
-
}
|
|
955
|
-
interface EidOidcClientConfig {
|
|
956
|
-
/** RP UUID (`relyingPartyUUID`). */
|
|
957
|
-
clientId: string;
|
|
958
|
-
/** RP API secret (`rp_sk_…`) — зөвхөн backend-д. */
|
|
959
|
-
clientSecret: string;
|
|
960
|
-
/** Бүртгэлтэй redirect URI — тэмдэгт бүрээрээ таарах ёстой. */
|
|
961
|
-
redirectUri: string;
|
|
962
|
-
/** Анхдагч {@link EID_OIDC_ISSUER}. */
|
|
963
|
-
issuer?: string;
|
|
964
|
-
/** Анхдагч `"openid"`. Иргэний ETSI дугаар хэрэгтэй бол `"openid pnomn"` (RP-д `PNOMN` эрх). */
|
|
965
|
-
scope?: string;
|
|
966
|
-
/** HTTP timeout (мс), анхдагч 10000. */
|
|
967
|
-
timeoutMs?: number;
|
|
968
|
-
/**
|
|
969
|
-
* undici Dispatcher (mTLS client cert) — RP-API client-ийн `dispatcher`-тэй ижил:
|
|
970
|
-
* `new Agent({ connect: { cert, key } })`. Дамжуулсан бол OIDC-ийн бүх fetch-д хэрэглэнэ. Зөвхөн Node орчинд.
|
|
971
|
-
*/
|
|
972
|
-
dispatcher?: unknown;
|
|
973
|
-
/**
|
|
974
|
-
* RFC 8705 §5: `true` бол code солих хүсэлт discovery-ийн `mtls_endpoint_aliases.token_endpoint` руу явна
|
|
975
|
-
* (`require_mtls`-тэй RP — `dispatcher`-т RP-ийн client cert заавал). Discovery-д alias байхгүй бол
|
|
976
|
-
* `token_endpoint` руу буцна; alias https биш бол `discovery_failed`. Анхдагч `false`.
|
|
977
|
-
*/
|
|
978
|
-
useMtlsEndpointAliases?: boolean;
|
|
979
|
-
/** fetch орлуулагч (тест). */
|
|
980
|
-
fetchImpl?: typeof fetch;
|
|
981
|
-
}
|
|
982
|
-
interface EidOidcDiscovery {
|
|
983
|
-
issuer: string;
|
|
984
|
-
authorization_endpoint: string;
|
|
985
|
-
token_endpoint: string;
|
|
986
|
-
jwks_uri: string;
|
|
987
|
-
/** RFC 8705 §5 — mTLS-тэй client-ийн endpoint-ууд (ж: `token_endpoint` → `https://rp.eidmongolia.mn/oauth2/token`). */
|
|
988
|
-
mtls_endpoint_aliases?: Record<string, string>;
|
|
989
|
-
[k: string]: unknown;
|
|
990
|
-
}
|
|
991
|
-
interface CreateAuthorizationOptions {
|
|
992
|
-
/** Энэ хүсэлтэд scope-ыг дарна. */
|
|
993
|
-
scope?: string;
|
|
994
|
-
/**
|
|
995
|
-
* `touch` (анхдагч) — утасны хөтчөөс шууд eID апп; `page` — үргэлж нэвтрэх хуудас (QR / push), ж: таблет киоск.
|
|
996
|
-
*/
|
|
997
|
-
display?: "page" | "touch";
|
|
932
|
+
/** Нэвтрэлтийн горим: desktop QR, регистрээр push, утасны хөтчөөс Web2App. */
|
|
933
|
+
type EidLoginMode = "qr" | "push" | "web2app";
|
|
934
|
+
/** Баталгаажсан иргэн — onSuccess-д. */
|
|
935
|
+
interface EidLoginIdentity {
|
|
936
|
+
/** Гэрчилгээний SERIALNUMBER (`PNOMN-<иргэний дугаар>`). Хэрэглэгчийг ҮҮГЭЭР таньна (нэрээр биш). */
|
|
937
|
+
etsi: string;
|
|
938
|
+
/** `PNOMN-`-гүй иргэний дугаар (цифр); ETSI өөр хэлбэртэй бол null. */
|
|
939
|
+
civilId: string | null;
|
|
940
|
+
/** Гэрчилгээний нэр (латин): GIVENNAME / SURNAME, харуулах нэр. */
|
|
941
|
+
givenName: string | null;
|
|
942
|
+
surname: string | null;
|
|
943
|
+
name: string | null;
|
|
944
|
+
country: string | null;
|
|
945
|
+
documentNumber: string;
|
|
946
|
+
certificateLevel: string;
|
|
947
|
+
/** Иргэний гэрчилгээ (DER, base64). */
|
|
948
|
+
certificateDerB64: string;
|
|
949
|
+
/** Гарын үсэг зурагдсан урсгал: QR | Notification | Web2App. */
|
|
950
|
+
flowType: FlowType;
|
|
951
|
+
/** Session-ийн `person` блок (кирилл нэр г.м.) — гэрчилгээтэй таарсан үед л, эс бөгөөс null. */
|
|
952
|
+
person: PersonBlock | null;
|
|
998
953
|
}
|
|
999
|
-
/**
|
|
1000
|
-
interface
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
954
|
+
/** Серверт хадгалах нэвтрэлтийн төлөв (JSON-д хувирна). */
|
|
955
|
+
interface EidLoginTx {
|
|
956
|
+
sessionId: string;
|
|
957
|
+
/** Cookie-ийн binding-ийн SHA-256 (hex) — түүхий утга хөтчид л. */
|
|
958
|
+
bindingHash: string;
|
|
959
|
+
mode: EidLoginMode;
|
|
960
|
+
expiresAt: number;
|
|
961
|
+
vc: string | null;
|
|
962
|
+
acsp: AcspContext;
|
|
963
|
+
/** QR/Web2App: холбоос угсрах материал. sessionSecret — ЗӨВХӨН серверт. */
|
|
964
|
+
link?: {
|
|
965
|
+
base: string;
|
|
966
|
+
token: string;
|
|
967
|
+
secret: string;
|
|
968
|
+
receivedAt: number;
|
|
969
|
+
lang: string;
|
|
970
|
+
};
|
|
1006
971
|
}
|
|
1007
|
-
/**
|
|
1008
|
-
interface
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
972
|
+
/** Төлөвийн сан. Анхдагч — процессын санах ой ({@link memoryLoginStore}); олон instance бол Redis г.м. */
|
|
973
|
+
interface EidLoginStore {
|
|
974
|
+
get(sessionId: string): Promise<EidLoginTx | undefined> | EidLoginTx | undefined;
|
|
975
|
+
set(sessionId: string, tx: EidLoginTx, ttlMs: number): Promise<void> | void;
|
|
976
|
+
/** Устгана; байсан бол true. Амжилтыг нэг л удаа гаргахад ашиглана (атомар байх ёстой — Redis `DEL`). */
|
|
977
|
+
delete(sessionId: string): Promise<boolean> | boolean;
|
|
1012
978
|
}
|
|
1013
|
-
/**
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
sub: string;
|
|
1020
|
-
exp: number;
|
|
1021
|
-
iat: number;
|
|
1022
|
-
nonce: string;
|
|
1023
|
-
/** Иргэн баталгаажуулсан мөч (Unix сек). */
|
|
1024
|
-
auth_time: number;
|
|
1025
|
-
/** {@link EID_ACR_QUALIFIED} эсвэл {@link EID_ACR_ADVANCED}. */
|
|
1026
|
-
acr: string;
|
|
1027
|
-
/** Гэрчилгээний GIVENNAME — латин (ICAO, том үсэг). */
|
|
1028
|
-
given_name: string;
|
|
1029
|
-
/** Гэрчилгээний SURNAME (эцэг/эхийн нэр) — латин. */
|
|
1030
|
-
family_name: string;
|
|
1031
|
-
/** Нэр — кирилл (бүртгэлд байхгүй бол алга). */
|
|
1032
|
-
given_name_mn?: string;
|
|
1033
|
-
/** Эцэг/эхийн нэр — кирилл (бүртгэлд байхгүй бол алга). */
|
|
1034
|
-
family_name_mn?: string;
|
|
1035
|
-
/** `PNOMN-<иргэний дугаар>` — зөвхөн `pnomn` scope + `PNOMN` эрхтэй үед. */
|
|
1036
|
-
pnomn?: string;
|
|
1037
|
-
[k: string]: unknown;
|
|
979
|
+
/** Нэг процессын санах ойн сан (TTL-тэй). Олон instance / serverless-д тохирохгүй. */
|
|
980
|
+
declare function memoryLoginStore(): EidLoginStore;
|
|
981
|
+
/** Хүсэлтийн хүрээ — onSuccess / rateLimit / onError-д. */
|
|
982
|
+
interface EidLoginContext {
|
|
983
|
+
request: EidLoginRequest;
|
|
984
|
+
mode: EidLoginMode;
|
|
1038
985
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
986
|
+
/** onSuccess-ийн хариу: хаашаа явуулах, хөтчид буцаах өгөгдөл, нэмэлт header (ж: таны session-ийн Set-Cookie). */
|
|
987
|
+
interface EidLoginSuccess {
|
|
988
|
+
/** Нэвтэрсний дараах хуудас (same-origin зам эсвэл URL). Callback (Web2App)-д анхдагч `successRedirect`. */
|
|
989
|
+
redirect?: string;
|
|
990
|
+
/** QR/push-д status хариунд `data` болж хөтчид очно (JSON). Нууц бүү оруул. */
|
|
991
|
+
data?: unknown;
|
|
992
|
+
headers?: Record<string, string | string[]>;
|
|
1042
993
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
readonly issuer: string;
|
|
1046
|
-
private readonly scope;
|
|
1047
|
-
private discovery?;
|
|
1048
|
-
private jwks?;
|
|
1049
|
-
constructor(cfg: EidOidcClientConfig);
|
|
1050
|
-
/** Discovery document (1 цаг cache). `issuer` нь тохиргоотой яг таарах ёстой (OIDC Discovery §4.3). */
|
|
1051
|
-
discover(): Promise<EidOidcDiscovery>;
|
|
1052
|
-
private fetchDiscovery;
|
|
994
|
+
interface EidLoginOptions {
|
|
995
|
+
client: EidClient;
|
|
1053
996
|
/**
|
|
1054
|
-
*
|
|
1055
|
-
*
|
|
997
|
+
* RP-ийн session-ийг ЭНД үүсгэнэ (иргэн баталгаажсан). Хэрэглэгчийг `identity.etsi`-ээр таньж, шинэ session
|
|
998
|
+
* (session fixation-аас сэргийлж шинэ id) үүсгээд Set-Cookie-г `headers`-ээр буцаа.
|
|
1056
999
|
*/
|
|
1057
|
-
|
|
1000
|
+
onSuccess: (identity: EidLoginIdentity, ctx: EidLoginContext) => Promise<EidLoginSuccess | void> | EidLoginSuccess | void;
|
|
1058
1001
|
/**
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1061
|
-
* Амжилтгүй бүх тохиолдолд {@link EidOidcError} (эсвэл {@link NetworkError}) шиднэ.
|
|
1002
|
+
* Web2App буцах https URL — host нь RP-ийн `callbackHosts`-д, зам нь ЗААВАЛ `/auth/eid/callback`. Өгөөгүй бол
|
|
1003
|
+
* утасны хөтчийн урсгал (`mode=web2app`) 400 — QR/push л ажиллана.
|
|
1062
1004
|
*/
|
|
1063
|
-
|
|
1064
|
-
/**
|
|
1065
|
-
|
|
1066
|
-
/**
|
|
1067
|
-
|
|
1005
|
+
callbackUrl?: string;
|
|
1006
|
+
/** Callback амжилттай болоход (onSuccess redirect өгөөгүй бол). Анхдагч "/". */
|
|
1007
|
+
successRedirect?: string;
|
|
1008
|
+
/** Callback амжилтгүй болоход — `?eid_error=<код>` нэмэгдэнэ. Анхдагч "/". */
|
|
1009
|
+
failureRedirect?: string;
|
|
1010
|
+
/** Утсанд харагдах текст (≤60). Анхдагч «<rpName>-д нэвтрэх». */
|
|
1011
|
+
displayText?: string;
|
|
1012
|
+
certificateLevel?: CertificateLevel;
|
|
1013
|
+
/** Нэвтрэлтийн хугацаа (мс). Анхдагч 120 000. */
|
|
1014
|
+
ttlMs?: number;
|
|
1015
|
+
/** Status-ийн нэг дуудлагад eID-ийг хүлээх (мс). Анхдагч 1000. */
|
|
1016
|
+
pollMs?: number;
|
|
1017
|
+
store?: EidLoginStore;
|
|
1018
|
+
cookie?: {
|
|
1019
|
+
name?: string;
|
|
1020
|
+
path?: string;
|
|
1021
|
+
secure?: boolean;
|
|
1022
|
+
domain?: string;
|
|
1023
|
+
};
|
|
1068
1024
|
/**
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1025
|
+
* Хязгаарлалт: `start:<ip>` (ip мэдэгдэж байвал) ба `push:<idCode>` түлхүүрээр дуудагдана; false → 429.
|
|
1026
|
+
* Анхдагч: push-д нэг дугаарт 60 секундэд 3 (санах ойд) — хохирогчийн утсыг мэдэгдлээр дарахаас (MFA fatigue).
|
|
1071
1027
|
*/
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1028
|
+
rateLimit?: (key: string) => boolean | Promise<boolean>;
|
|
1029
|
+
/** Дотоод алдаа (eID API, store). Анхдагч console.error (мессеж л). */
|
|
1030
|
+
onError?: (err: unknown, ctx: EidLoginContext) => void;
|
|
1031
|
+
}
|
|
1032
|
+
/** Framework-аас хамааралгүй хүсэлт (Express: `req.headers`, `req.body`, `req.ip`). */
|
|
1033
|
+
interface EidLoginRequest {
|
|
1034
|
+
method: string;
|
|
1035
|
+
/** Зам + query (`/auth/eid/status?…`) эсвэл бүтэн URL. */
|
|
1036
|
+
url: string;
|
|
1037
|
+
headers: Record<string, string | string[] | undefined>;
|
|
1038
|
+
/** POST-ийн задалсан JSON (Express `express.json()`), эсвэл түүхий мөр. */
|
|
1039
|
+
body?: unknown;
|
|
1040
|
+
ip?: string;
|
|
1041
|
+
}
|
|
1042
|
+
interface EidLoginResponse {
|
|
1043
|
+
status: number;
|
|
1044
|
+
headers: Record<string, string | string[]>;
|
|
1045
|
+
body: string;
|
|
1078
1046
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1047
|
+
interface EidLogin {
|
|
1048
|
+
/** Сүүлийн замын хэсгээр (`start` | `status` | `callback`) чиглүүлнэ. */
|
|
1049
|
+
handleRequest(req: EidLoginRequest): Promise<EidLoginResponse>;
|
|
1050
|
+
/** Web-standard (Next.js App Router, Hono, Bun, Deno). */
|
|
1051
|
+
handle(req: Request): Promise<Response>;
|
|
1052
|
+
}
|
|
1053
|
+
/** `callbackUrl`-д буцах хөтчийн hint (`retScheme` iOS / `retPkg` Android) нэмнэ; танихгүй бол хэвээр. */
|
|
1054
|
+
declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
1055
|
+
/**
|
|
1056
|
+
* «eID-ээр нэвтрэх»-ийн backend handler-ууд. Нэг instance-ийг модулийн түвшинд үүсгээд бүх хүсэлтэд ашиглана.
|
|
1057
|
+
*
|
|
1058
|
+
* @throws Error `callbackUrl` https биш эсвэл зам нь `/auth/eid/callback` биш бол.
|
|
1059
|
+
*/
|
|
1060
|
+
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1081
1061
|
|
|
1082
|
-
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,
|
|
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 };
|