@gerege-systems/eid-mongolia-sdk 0.40.2 → 0.41.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 +33 -5
- package/dist/{browser-DdxKtnvo.d.cts → browser-Cbph4U6r.d.cts} +5 -0
- package/dist/{browser-CxTMnKOc.d.ts → browser-aa_Judox.d.ts} +5 -0
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/index.cjs +49 -7
- package/dist/index.d.cts +30 -9
- package/dist/index.d.ts +30 -9
- package/dist/index.js +52 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -407,7 +407,7 @@ certificate-choice хүчингүй / хуучирсан / ашиглагдса
|
|
|
407
407
|
таарахгүй.
|
|
408
408
|
|
|
409
409
|
```ts
|
|
410
|
-
const cc = await eid.sign.certificateChoiceByEtsi("PNOMN-12345678"); // эсвэл certificateChoiceDeviceLink() (
|
|
410
|
+
const cc = await eid.sign.certificateChoiceByEtsi("PNOMN-12345678"); // эсвэл certificateChoiceDeviceLink() (QR; callbackUrl өгвөл Web2App/App2App ч)
|
|
411
411
|
const signer = eid.validator.validateCertificateChoice(await eid.session.waitForResult(cc.sessionId), cc.sessionId);
|
|
412
412
|
const dtbs = myCmsBuilder.dtbs(signer.certificate); // таных: SHA-256(signedAttrs), 32 байт, стандарт base64 (PDF бол /pades prepare)
|
|
413
413
|
const ix = [{ type: "displayTextAndPIN" as const, displayText60: "Гэрээнд гарын үсэг зурах" }];
|
|
@@ -426,6 +426,31 @@ const sig = eid.validator.validateSign(r, s.sign!.digest, {
|
|
|
426
426
|
алгоритмаар, PKCS#1 v1.5; хуучин threshold-ECDSA credential нь үргэлж `ecdsa-with-SHA256` — `expectedAlgorithm` үүнийг
|
|
427
427
|
зөвхөн EC P-256 гэрчилгээтэй үед зөвшөөрнө). Digest-ийн урт hash-тай таарахгүй бол хүсэлт явахгүй.
|
|
428
428
|
|
|
429
|
+
#### Утсан дээр linked signing (буцах URL-тай)
|
|
430
|
+
|
|
431
|
+
`certificateChoiceDeviceLink({ callbackUrl })` — нэг session-оос desktop-д QR, утсан дээр Web2App товч гаргана.
|
|
432
|
+
`callbackUrl` нь RP-ийн `callback_hosts` жагсаалтад байх `https` URL (CA зам нь `/auth/eid/callback` болгон
|
|
433
|
+
хэвийн болгоно); жагсаалтад байхгүй бол CA хаяж, session зөвхөн QR болно. Утас linked SIGN дууссаны дараа л callback-ийг
|
|
434
|
+
нээнэ: RP-ийн өөрийн query (ж: `value=<санамсаргүй>`) хэвээр + `sessionSecretDigest` + `sessionId` (certificate-choice-ийн).
|
|
435
|
+
|
|
436
|
+
```ts
|
|
437
|
+
// 1) cert-choice-ийг callback-тай эхлүүл; `value`-г эхэлсэн браузерийн cookie-д хадгал
|
|
438
|
+
const cc = await eid.sign.certificateChoiceDeviceLink({ callbackUrl: `${origin}/auth/eid/callback?value=${value}` });
|
|
439
|
+
const qr = buildDeviceLink(deviceLinkInput(cc, "QR", "mon")); // desktop (секунд тутам шинэчил)
|
|
440
|
+
const w2a = buildDeviceLink(deviceLinkInput(cc, "Web2App", "mon")); // утсан дээрх товч (нэг session)
|
|
441
|
+
// 2) validateCertificateChoice → 3) digestForSigner(signer, …) — дээрх linked sign
|
|
442
|
+
const signer = eid.validator.validateCertificateChoice(await eid.session.waitForResult(cc.sessionId), cc.sessionId);
|
|
443
|
+
const s = await eid.sign.digestForSigner(signer, dtbs, ix);
|
|
444
|
+
|
|
445
|
+
// 4) /auth/eid/callback дээр
|
|
446
|
+
const ok = q.value === cookieValue && verifySessionSecretDigest(q.sessionSecretDigest, cc.sessionSecret!);
|
|
447
|
+
// ok бол session-ийг ЗӨВХӨН НЭГ УДАА хүлээн зөвшөөр (дахин ашиглахгүй), дараа нь linked SIGN-ий үр дүнг уншина:
|
|
448
|
+
const r = await eid.session.waitForResult(s.sessionId);
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
Linked SIGN session өөрөө callback-гүй. `sessionSecretDigest` = BASE64URL(SHA-256(base64-decode(`sessionSecret`))),
|
|
452
|
+
`userChallengeVerifier` ирэхгүй. `sessionSecret`/`sessionToken` зөвхөн backend-д.
|
|
453
|
+
|
|
429
454
|
## 3a. Байгууллагын нэрийн өмнөөс гарын үсэг (onBehalfOf)
|
|
430
455
|
|
|
431
456
|
Иргэн **өөрийн PIN2 гэрчилгээгээр** зурна; тухайн мөчид байгууллагыг төлөөлөх эрхтэйг eID **өөрийн бүртгэлээр**
|
|
@@ -1068,12 +1093,15 @@ OK ирж болзошгүй. Иймд `ResponseValidator`:
|
|
|
1068
1093
|
clientAuth, sign → emailProtection — CA-ийн профайл; CA-д EKU байвал түүнд багтах), үл таних **critical
|
|
1069
1094
|
extension** → татгалзана. **Name constraints**-тэй CA гинжинд байвал fail-closed (CA-ийн бодит гинжинд алга).
|
|
1070
1095
|
Хариунд гинж ирдэггүй — `intermediatesPem` өгөөгүй бол SDK-д суусан 02, 03, 04 (`CITIZEN_INTERMEDIATES_PEM`,
|
|
1071
|
-
0.19.0-аас). certificatePolicies-ийг
|
|
1096
|
+
0.19.0-аас). Гинжинд certificatePolicies-ийг шалгахгүй (түвшинд — 3).
|
|
1072
1097
|
3. Гэрчилгээ хүчинтэй хугацаанд + шаардсан `certificateLevel` (default `QUALIFIED`). **0.19.0-аас түвшинг
|
|
1073
1098
|
гэрчилгээнээс тогтооно** (`certificateLevelOf`): гарын үсгийн гэрчилгээнд qcStatements QcCompliance → QUALIFIED
|
|
1074
|
-
(+ QcSSCD → QSCD
|
|
1075
|
-
|
|
1076
|
-
|
|
1099
|
+
(+ QcSSCD → QSCD; утас ба 2026-11-06-аас хойш олгосон USB токен QUALIFIED), qcStatements-гүй (түүнээс өмнө олгосон
|
|
1100
|
+
токен) → ADVANCED; нэвтрэлтийн гэрчилгээнд CA qcStatements бичдэггүй тул профайлаар → QUALIFIED: KeyUsage
|
|
1101
|
+
keyEncipherment (утасны P-CITIZEN-AUTH), эсвэл EKU clientAuth + emailProtection ба үндэсний policy
|
|
1102
|
+
`2.16.496.1.101.1.2.8` (токены P-CITIZEN-AUTH-TOKEN, 0.40.3-аас); бусад → ADVANCED. Хариуны `certificateLevel`
|
|
1103
|
+
түүнээс өндөр бол татгалзана; бага бол хариуныхыг авна (хуучин токены AUTH-ийг CA ADVANCED гэж зарлана). Буцаах
|
|
1104
|
+
`certificateLevel` = энэ утга.
|
|
1077
1105
|
4. Гарын үсгийг иргэний public key-ээр шалгана:
|
|
1078
1106
|
- **auth** → ACSP_V2 payload (`smart-id|ACSP_V2|serverRandom|rpChallenge|userChallenge|B64(rpName)|B64(brokeredRpName)|B64(SHA-256(interactions))|interactionTypeUsed|initialCallbackUrl|flowType`, hash = хүсэлтийн `hashAlgorithm`) дээр — `flowType`, `userChallenge`, `serverRandom` ба алгоритмын downgrade-ийг мөн шалгана;
|
|
1079
1107
|
`expectedFlowType` өгвөл `flowType` эхлүүлсэн урсгалтай ЯГ таарах, Web2App/App2App-д `userChallengeVerifier` заавал
|
|
@@ -156,6 +156,11 @@ interface DeviceLinkSession {
|
|
|
156
156
|
receivedAt: number;
|
|
157
157
|
/** auth | sign | cert ({@link deviceLinkInput}-д). Хуучин хадгалсан session-д undefined = auth. */
|
|
158
158
|
sessionType?: "auth" | "sign" | "cert";
|
|
159
|
+
/**
|
|
160
|
+
* Зөвхөн cert (certificate-choice) session: эхлүүлэхэд илгээсэн түүхий `initialCallbackUrl` (linked signing буцах
|
|
161
|
+
* URL). Web2App/App2App authCode-д орно ({@link deviceLinkInput}); байхгүй бол QR-only.
|
|
162
|
+
*/
|
|
163
|
+
initialCallbackUrl?: string;
|
|
159
164
|
/** Sign session-д ({@link deviceLinkInput}, `validateSign`); бусад үед undefined. */
|
|
160
165
|
sign?: SignContext;
|
|
161
166
|
/** Certificate-choice session-ий хүсэлтэд илгээсэн нэр (cert холбоосын authCode-д). */
|
|
@@ -156,6 +156,11 @@ interface DeviceLinkSession {
|
|
|
156
156
|
receivedAt: number;
|
|
157
157
|
/** auth | sign | cert ({@link deviceLinkInput}-д). Хуучин хадгалсан session-д undefined = auth. */
|
|
158
158
|
sessionType?: "auth" | "sign" | "cert";
|
|
159
|
+
/**
|
|
160
|
+
* Зөвхөн cert (certificate-choice) session: эхлүүлэхэд илгээсэн түүхий `initialCallbackUrl` (linked signing буцах
|
|
161
|
+
* URL). Web2App/App2App authCode-д орно ({@link deviceLinkInput}); байхгүй бол QR-only.
|
|
162
|
+
*/
|
|
163
|
+
initialCallbackUrl?: string;
|
|
159
164
|
/** Sign session-д ({@link deviceLinkInput}, `validateSign`); бусад үед undefined. */
|
|
160
165
|
sign?: SignContext;
|
|
161
166
|
/** Certificate-choice session-ий хүсэлтэд илгээсэн нэр (cert холбоосын authCode-д). */
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { D as DeviceLinkSession, d as NavigatorLike, l as isMobileUserAgent } from './browser-
|
|
1
|
+
export { D as DeviceLinkSession, d as NavigatorLike, l as isMobileUserAgent } from './browser-Cbph4U6r.cjs';
|
|
2
2
|
export { D as DeviceLinkError, E as EidError } from './errors-CgJcEjrZ.cjs';
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { D as DeviceLinkSession, d as NavigatorLike, l as isMobileUserAgent } from './browser-
|
|
1
|
+
export { D as DeviceLinkSession, d as NavigatorLike, l as isMobileUserAgent } from './browser-aa_Judox.js';
|
|
2
2
|
export { D as DeviceLinkError, E as EidError } from './errors-CgJcEjrZ.js';
|
package/dist/index.cjs
CHANGED
|
@@ -102,6 +102,7 @@ __export(index_exports, {
|
|
|
102
102
|
registrationFromCompleted: () => registrationFromCompleted,
|
|
103
103
|
resolveBaseUrl: () => resolveBaseUrl,
|
|
104
104
|
sessionExpiry: () => sessionExpiry,
|
|
105
|
+
sessionSecretDigest: () => sessionSecretDigest,
|
|
105
106
|
sha256Base64: () => sha256Base64,
|
|
106
107
|
startExpiry: () => startExpiry,
|
|
107
108
|
tokenAuthDigest: () => tokenAuthDigest,
|
|
@@ -110,6 +111,7 @@ __export(index_exports, {
|
|
|
110
111
|
verifyPayloadSignature: () => verifyPayloadSignature,
|
|
111
112
|
verifyPrehashedSignature: () => verifyPrehashedSignature,
|
|
112
113
|
verifyQrPresentation: () => verifyQrPresentation,
|
|
114
|
+
verifySessionSecretDigest: () => verifySessionSecretDigest,
|
|
113
115
|
verifyTokenCertificates: () => verifyTokenCertificates,
|
|
114
116
|
withReturnHint: () => withReturnHint
|
|
115
117
|
});
|
|
@@ -478,6 +480,16 @@ function buildAcspV2Payload(p) {
|
|
|
478
480
|
function acspV2Digest(p, hashAlgorithm) {
|
|
479
481
|
return (0, import_node_crypto.createHash)(nodeHash(hashAlgorithm)).update(buildAcspV2Payload(p)).digest();
|
|
480
482
|
}
|
|
483
|
+
function sessionSecretDigest(sessionSecret) {
|
|
484
|
+
return (0, import_node_crypto.createHash)("sha256").update(Buffer.from(sessionSecret, "base64")).digest("base64url");
|
|
485
|
+
}
|
|
486
|
+
function verifySessionSecretDigest(digest2, sessionSecret) {
|
|
487
|
+
if (typeof digest2 !== "string" || typeof sessionSecret !== "string" || !digest2 || !sessionSecret) return false;
|
|
488
|
+
if (!/^[A-Za-z0-9_-]+$/.test(digest2)) return false;
|
|
489
|
+
const got = Buffer.from(digest2, "utf8");
|
|
490
|
+
const want = Buffer.from(sessionSecretDigest(sessionSecret), "utf8");
|
|
491
|
+
return got.length === want.length && (0, import_node_crypto.timingSafeEqual)(got, want);
|
|
492
|
+
}
|
|
481
493
|
|
|
482
494
|
// src/types.ts
|
|
483
495
|
var DEFAULT_SIGN_SESSION_TTL_MS = 6e5;
|
|
@@ -920,13 +932,18 @@ var SignApi = class {
|
|
|
920
932
|
return this.notification(routePath(RP_ROUTES.certChoiceEtsi, id), this.certChoiceBody(opts));
|
|
921
933
|
}
|
|
922
934
|
/**
|
|
923
|
-
*
|
|
924
|
-
*
|
|
935
|
+
* Device link: иргэн хэн болохыг урьдчилж мэдэхгүй үед гэрчилгээ сонгуулах. `opts.callbackUrl` өгөөгүй бол
|
|
936
|
+
* ЗӨВХӨН QR (`deviceLinkInput(s, "QR", lang)`); өгвөл (CA-ийн callback_hosts-д байх https URL) Web2App/App2App
|
|
937
|
+
* холбоос мөн угсарна, linked sign дууссаны дараа утас callback-ийг нээнэ. CERT эрх.
|
|
925
938
|
*/
|
|
926
939
|
async certificateChoiceDeviceLink(opts) {
|
|
927
|
-
|
|
940
|
+
const body = this.certChoiceBody(opts);
|
|
941
|
+
const callback = opts?.callbackUrl?.trim();
|
|
942
|
+
if (callback) body.initialCallbackUrl = callback;
|
|
943
|
+
return this.deviceLink(routePath(RP_ROUTES.certChoiceDeviceLink), body, {
|
|
928
944
|
sessionType: "cert",
|
|
929
|
-
relyingPartyName: this.creds.rpName
|
|
945
|
+
relyingPartyName: this.creds.rpName,
|
|
946
|
+
...callback ? { initialCallbackUrl: callback } : {}
|
|
930
947
|
});
|
|
931
948
|
}
|
|
932
949
|
// ── Гэрчилгээ урьдчилж мэдэгдэх гарын үсэг (client-side PAdES / CMS) ──
|
|
@@ -1551,7 +1568,7 @@ var ResponseValidator = class {
|
|
|
1551
1568
|
}
|
|
1552
1569
|
/**
|
|
1553
1570
|
* Токены нэвтрэлтийн гэрчилгээ ({@link TokenApi.authVerify}) — хугацаа, зориулалт (auth), гинж, issuer. Түвшинг
|
|
1554
|
-
* шалгахгүй (
|
|
1571
|
+
* шалгахгүй (2026-11-06-аас өмнө олгосон токен CA-д ADVANCED).
|
|
1555
1572
|
* @internal
|
|
1556
1573
|
*/
|
|
1557
1574
|
verifyTokenAuthCertificate(leaf) {
|
|
@@ -1851,15 +1868,32 @@ var LEVEL_RANK = { ADVANCED: 1, QUALIFIED: 2, QSCD: 3 };
|
|
|
1851
1868
|
var OID_QC_STATEMENTS = "1.3.6.1.5.5.7.1.3";
|
|
1852
1869
|
var OID_QC_COMPLIANCE = "0.4.0.1862.1.1";
|
|
1853
1870
|
var OID_QC_SSCD = "0.4.0.1862.1.4";
|
|
1871
|
+
var OID_POLICY_NATIONAL = "2.16.496.1.101.1.2.8";
|
|
1854
1872
|
function certificateLevelOf(cert, protocol) {
|
|
1855
1873
|
const qc = qcStatementIds(cert);
|
|
1856
1874
|
if (qc) {
|
|
1857
1875
|
if (!qc.includes(OID_QC_COMPLIANCE)) return "ADVANCED";
|
|
1858
1876
|
return qc.includes(OID_QC_SSCD) ? "QSCD" : "QUALIFIED";
|
|
1859
1877
|
}
|
|
1860
|
-
if (protocol === "ACSP_V2" && keyUsageBits(cert) & 32) return "QUALIFIED";
|
|
1878
|
+
if (protocol === "ACSP_V2" && (keyUsageBits(cert) & 32 || isCitizenAuthToken(cert))) return "QUALIFIED";
|
|
1861
1879
|
return "ADVANCED";
|
|
1862
1880
|
}
|
|
1881
|
+
function isCitizenAuthToken(cert) {
|
|
1882
|
+
const eku = extKeyUsage(cert);
|
|
1883
|
+
return eku.includes(EKU_CLIENT_AUTH) && eku.includes(EKU_EMAIL_PROTECTION) && certPolicyIds(cert).includes(OID_POLICY_NATIONAL);
|
|
1884
|
+
}
|
|
1885
|
+
function certPolicyIds(cert) {
|
|
1886
|
+
const v = certExtension(cert.raw, "2.5.29.32");
|
|
1887
|
+
if (!v) return [];
|
|
1888
|
+
const seq2 = tlv(v, 0, v.length);
|
|
1889
|
+
const out = [];
|
|
1890
|
+
for (let p = seq2.start; p < seq2.end; ) {
|
|
1891
|
+
const pi = tlv(v, p, seq2.end);
|
|
1892
|
+
out.push(oidOf(v, tlv(v, pi.start, pi.end)));
|
|
1893
|
+
p = pi.end;
|
|
1894
|
+
}
|
|
1895
|
+
return out;
|
|
1896
|
+
}
|
|
1863
1897
|
function effectiveLevel(claimed, fromCert) {
|
|
1864
1898
|
const c = LEVEL_RANK[claimed];
|
|
1865
1899
|
if (c === void 0) return fromCert;
|
|
@@ -3554,7 +3588,13 @@ function deviceLinkInput(s, deviceLinkType, lang) {
|
|
|
3554
3588
|
};
|
|
3555
3589
|
}
|
|
3556
3590
|
if (s.sessionType === "cert") {
|
|
3557
|
-
return {
|
|
3591
|
+
return {
|
|
3592
|
+
...base,
|
|
3593
|
+
sessionType: "cert",
|
|
3594
|
+
relyingPartyName: s.relyingPartyName ?? "",
|
|
3595
|
+
interactions: "",
|
|
3596
|
+
initialCallbackUrl: s.initialCallbackUrl ?? ""
|
|
3597
|
+
};
|
|
3558
3598
|
}
|
|
3559
3599
|
return {
|
|
3560
3600
|
...base,
|
|
@@ -4243,6 +4283,7 @@ function createEidLogin(opts) {
|
|
|
4243
4283
|
registrationFromCompleted,
|
|
4244
4284
|
resolveBaseUrl,
|
|
4245
4285
|
sessionExpiry,
|
|
4286
|
+
sessionSecretDigest,
|
|
4246
4287
|
sha256Base64,
|
|
4247
4288
|
startExpiry,
|
|
4248
4289
|
tokenAuthDigest,
|
|
@@ -4251,6 +4292,7 @@ function createEidLogin(opts) {
|
|
|
4251
4292
|
verifyPayloadSignature,
|
|
4252
4293
|
verifyPrehashedSignature,
|
|
4253
4294
|
verifyQrPresentation,
|
|
4295
|
+
verifySessionSecretDigest,
|
|
4254
4296
|
verifyTokenCertificates,
|
|
4255
4297
|
withReturnHint
|
|
4256
4298
|
});
|
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 RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-
|
|
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-
|
|
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-Cbph4U6r.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-Cbph4U6r.cjs';
|
|
3
3
|
import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-CgJcEjrZ.cjs';
|
|
4
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';
|
|
@@ -270,6 +270,13 @@ declare function buildRegisterBody(input: RegisterSignatureInput): Record<string
|
|
|
270
270
|
/** Certificate-choice session-ий тохиргоо. */
|
|
271
271
|
interface CertChoiceOptions {
|
|
272
272
|
certificateLevel?: CertificateLevel;
|
|
273
|
+
/**
|
|
274
|
+
* Linked signing буцах URL (`initialCallbackUrl`) — зөвхөн {@link SignApi.certificateChoiceDeviceLink}. Өгвөл
|
|
275
|
+
* Web2App/App2App холбоос үүснэ; утас linked SIGN дууссаны дараа энэ URL-ийг `sessionSecretDigest` + `sessionId`
|
|
276
|
+
* query-тэй нээнэ ({@link verifySessionSecretDigest}). CA-д RP-ийн callback_hosts жагсаалтаар шалгагдана;
|
|
277
|
+
* жагсаалтад байхгүй бол CA хаяж, session зөвхөн QR болно. Notification (etsi)-д илгээгдэхгүй.
|
|
278
|
+
*/
|
|
279
|
+
callbackUrl?: string;
|
|
273
280
|
}
|
|
274
281
|
/**
|
|
275
282
|
* Гарын үсэг зурах төхөөрөмж — `validator.validateCertificateChoice`-ийн үр дүн (эсвэл түүнээс хадгалсан утга).
|
|
@@ -333,8 +340,9 @@ declare class SignApi {
|
|
|
333
340
|
*/
|
|
334
341
|
certificateChoiceByEtsi(id: string, opts?: CertChoiceOptions): Promise<NotificationSession>;
|
|
335
342
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
343
|
+
* Device link: иргэн хэн болохыг урьдчилж мэдэхгүй үед гэрчилгээ сонгуулах. `opts.callbackUrl` өгөөгүй бол
|
|
344
|
+
* ЗӨВХӨН QR (`deviceLinkInput(s, "QR", lang)`); өгвөл (CA-ийн callback_hosts-д байх https URL) Web2App/App2App
|
|
345
|
+
* холбоос мөн угсарна, linked sign дууссаны дараа утас callback-ийг нээнэ. CERT эрх.
|
|
338
346
|
*/
|
|
339
347
|
certificateChoiceDeviceLink(opts?: CertChoiceOptions): Promise<DeviceLinkSession>;
|
|
340
348
|
private signerBody;
|
|
@@ -817,7 +825,7 @@ declare class ResponseValidator {
|
|
|
817
825
|
private leafOf;
|
|
818
826
|
/**
|
|
819
827
|
* Токены нэвтрэлтийн гэрчилгээ ({@link TokenApi.authVerify}) — хугацаа, зориулалт (auth), гинж, issuer. Түвшинг
|
|
820
|
-
* шалгахгүй (
|
|
828
|
+
* шалгахгүй (2026-11-06-аас өмнө олгосон токен CA-д ADVANCED).
|
|
821
829
|
* @internal
|
|
822
830
|
*/
|
|
823
831
|
verifyTokenAuthCertificate(leaf: X509Certificate): void;
|
|
@@ -877,9 +885,11 @@ declare function verifyPayloadSignature(payload: Buffer, sigB64: string, key: Ke
|
|
|
877
885
|
declare function verifyPrehashedSignature(digest: Buffer, sigB64: string, key: KeyObject, alg: string, hash: string): boolean;
|
|
878
886
|
/**
|
|
879
887
|
* Гэрчилгээнээс тогтоох түвшин (CA `crypto/ca_profile.go`): qcStatements-д QcCompliance → QUALIFIED (+ QcSSCD →
|
|
880
|
-
* QSCD); qcStatements алга бол — гарын үсгийн гэрчилгээ ADVANCED (USB токен), нэвтрэлтийн
|
|
881
|
-
* qcStatements бичдэггүй)
|
|
882
|
-
* P-CITIZEN-AUTH
|
|
888
|
+
* QSCD); qcStatements алга бол — гарын үсгийн гэрчилгээ ADVANCED (2026-11-06-аас өмнө олгосон USB токен), нэвтрэлтийн
|
|
889
|
+
* гэрчилгээ (CA AUTH-д qcStatements бичдэггүй) профайлаар → QUALIFIED: KeyUsage keyEncipherment (утасны
|
|
890
|
+
* P-CITIZEN-AUTH), эсвэл EKU clientAuth + emailProtection ба үндэсний policy 2.16.496.1.101.1.2.8 (токены
|
|
891
|
+
* P-CITIZEN-AUTH-TOKEN, EC — keyEncipherment үгүй); бусад → ADVANCED. Хариуны түвшин үүнээс бага бол хариуных хүчинтэй.
|
|
892
|
+
* `protocol` — "ACSP_V2" (auth) эсвэл "RAW_DIGEST_SIGNATURE" (sign). Go SDK-ийн `eid.CertificateLevelOf`-тэй ижил.
|
|
883
893
|
*/
|
|
884
894
|
declare function certificateLevelOf(cert: X509Certificate, protocol: string): CertificateLevel;
|
|
885
895
|
|
|
@@ -1523,6 +1533,17 @@ interface AcspV2Params {
|
|
|
1523
1533
|
declare function buildAcspV2Payload(p: AcspV2Params): Buffer;
|
|
1524
1534
|
/** HASH_{hashAlgorithm}(payload). */
|
|
1525
1535
|
declare function acspV2Digest(p: AcspV2Params, hashAlgorithm: HashAlgorithm | string): Buffer;
|
|
1536
|
+
/**
|
|
1537
|
+
* Linked signing буцах URL-ийн `sessionSecretDigest` = BASE64URL-NOPAD(SHA-256(base64-decode(sessionSecret))).
|
|
1538
|
+
* `sessionSecret` — certificate-choice device-link session-ий нууц (стандарт base64). Smart-ID RP-API v3
|
|
1539
|
+
* `CallbackUrlUtil`-тай ижил.
|
|
1540
|
+
*/
|
|
1541
|
+
declare function sessionSecretDigest(sessionSecret: string): string;
|
|
1542
|
+
/**
|
|
1543
|
+
* Callback-ийн `sessionSecretDigest`-ийг certificate-choice session-ий `sessionSecret`-тэй тулгана (timing-safe).
|
|
1544
|
+
* Буруу хэлбэр / хоосон оролтод `false` (throw хийхгүй).
|
|
1545
|
+
*/
|
|
1546
|
+
declare function verifySessionSecretDigest(digest: string, sessionSecret: string): boolean;
|
|
1526
1547
|
|
|
1527
1548
|
/** Холбоосын төрөл — апп гарын үсгийн `flowType`-д яг энэ утгыг зурна (authCode-оор хамгаалагдсан). */
|
|
1528
1549
|
type DeviceLinkType = "QR" | "Web2App" | "App2App";
|
|
@@ -1852,4 +1873,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1852
1873
|
*/
|
|
1853
1874
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1854
1875
|
|
|
1855
|
-
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_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, 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 ParsedQr, 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_CLOCK_SKEW_SECONDS, QR_ERROR_CODES, QR_LIMITS, QR_MAX_AGE_SECONDS, QR_PREFIX, QrApi, type QrApiDeps, type QrCheck, type QrClaims, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrPresentation, type QrSession, type QrSigner, 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, qrStatement, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, verifyTokenCertificates, withReturnHint };
|
|
1876
|
+
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_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, 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 ParsedQr, 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_CLOCK_SKEW_SECONDS, QR_ERROR_CODES, QR_LIMITS, QR_MAX_AGE_SECONDS, QR_PREFIX, QrApi, type QrApiDeps, type QrCheck, type QrClaims, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrPresentation, type QrSession, type QrSigner, 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, qrStatement, randomChallenge, registrationFromCompleted, resolveBaseUrl, sessionSecretDigest, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, verifySessionSecretDigest, 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 RepresentationsResponse, A as AcspContext, F as FlowType } from './browser-
|
|
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-
|
|
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-aa_Judox.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-aa_Judox.js';
|
|
3
3
|
import { O as OnBehalfErrorCode, R as RetryableErrorCode, E as EidError, A as ApiError, H as HttpErrorInit } from './errors-CgJcEjrZ.js';
|
|
4
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';
|
|
@@ -270,6 +270,13 @@ declare function buildRegisterBody(input: RegisterSignatureInput): Record<string
|
|
|
270
270
|
/** Certificate-choice session-ий тохиргоо. */
|
|
271
271
|
interface CertChoiceOptions {
|
|
272
272
|
certificateLevel?: CertificateLevel;
|
|
273
|
+
/**
|
|
274
|
+
* Linked signing буцах URL (`initialCallbackUrl`) — зөвхөн {@link SignApi.certificateChoiceDeviceLink}. Өгвөл
|
|
275
|
+
* Web2App/App2App холбоос үүснэ; утас linked SIGN дууссаны дараа энэ URL-ийг `sessionSecretDigest` + `sessionId`
|
|
276
|
+
* query-тэй нээнэ ({@link verifySessionSecretDigest}). CA-д RP-ийн callback_hosts жагсаалтаар шалгагдана;
|
|
277
|
+
* жагсаалтад байхгүй бол CA хаяж, session зөвхөн QR болно. Notification (etsi)-д илгээгдэхгүй.
|
|
278
|
+
*/
|
|
279
|
+
callbackUrl?: string;
|
|
273
280
|
}
|
|
274
281
|
/**
|
|
275
282
|
* Гарын үсэг зурах төхөөрөмж — `validator.validateCertificateChoice`-ийн үр дүн (эсвэл түүнээс хадгалсан утга).
|
|
@@ -333,8 +340,9 @@ declare class SignApi {
|
|
|
333
340
|
*/
|
|
334
341
|
certificateChoiceByEtsi(id: string, opts?: CertChoiceOptions): Promise<NotificationSession>;
|
|
335
342
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
343
|
+
* Device link: иргэн хэн болохыг урьдчилж мэдэхгүй үед гэрчилгээ сонгуулах. `opts.callbackUrl` өгөөгүй бол
|
|
344
|
+
* ЗӨВХӨН QR (`deviceLinkInput(s, "QR", lang)`); өгвөл (CA-ийн callback_hosts-д байх https URL) Web2App/App2App
|
|
345
|
+
* холбоос мөн угсарна, linked sign дууссаны дараа утас callback-ийг нээнэ. CERT эрх.
|
|
338
346
|
*/
|
|
339
347
|
certificateChoiceDeviceLink(opts?: CertChoiceOptions): Promise<DeviceLinkSession>;
|
|
340
348
|
private signerBody;
|
|
@@ -817,7 +825,7 @@ declare class ResponseValidator {
|
|
|
817
825
|
private leafOf;
|
|
818
826
|
/**
|
|
819
827
|
* Токены нэвтрэлтийн гэрчилгээ ({@link TokenApi.authVerify}) — хугацаа, зориулалт (auth), гинж, issuer. Түвшинг
|
|
820
|
-
* шалгахгүй (
|
|
828
|
+
* шалгахгүй (2026-11-06-аас өмнө олгосон токен CA-д ADVANCED).
|
|
821
829
|
* @internal
|
|
822
830
|
*/
|
|
823
831
|
verifyTokenAuthCertificate(leaf: X509Certificate): void;
|
|
@@ -877,9 +885,11 @@ declare function verifyPayloadSignature(payload: Buffer, sigB64: string, key: Ke
|
|
|
877
885
|
declare function verifyPrehashedSignature(digest: Buffer, sigB64: string, key: KeyObject, alg: string, hash: string): boolean;
|
|
878
886
|
/**
|
|
879
887
|
* Гэрчилгээнээс тогтоох түвшин (CA `crypto/ca_profile.go`): qcStatements-д QcCompliance → QUALIFIED (+ QcSSCD →
|
|
880
|
-
* QSCD); qcStatements алга бол — гарын үсгийн гэрчилгээ ADVANCED (USB токен), нэвтрэлтийн
|
|
881
|
-
* qcStatements бичдэггүй)
|
|
882
|
-
* P-CITIZEN-AUTH
|
|
888
|
+
* QSCD); qcStatements алга бол — гарын үсгийн гэрчилгээ ADVANCED (2026-11-06-аас өмнө олгосон USB токен), нэвтрэлтийн
|
|
889
|
+
* гэрчилгээ (CA AUTH-д qcStatements бичдэггүй) профайлаар → QUALIFIED: KeyUsage keyEncipherment (утасны
|
|
890
|
+
* P-CITIZEN-AUTH), эсвэл EKU clientAuth + emailProtection ба үндэсний policy 2.16.496.1.101.1.2.8 (токены
|
|
891
|
+
* P-CITIZEN-AUTH-TOKEN, EC — keyEncipherment үгүй); бусад → ADVANCED. Хариуны түвшин үүнээс бага бол хариуных хүчинтэй.
|
|
892
|
+
* `protocol` — "ACSP_V2" (auth) эсвэл "RAW_DIGEST_SIGNATURE" (sign). Go SDK-ийн `eid.CertificateLevelOf`-тэй ижил.
|
|
883
893
|
*/
|
|
884
894
|
declare function certificateLevelOf(cert: X509Certificate, protocol: string): CertificateLevel;
|
|
885
895
|
|
|
@@ -1523,6 +1533,17 @@ interface AcspV2Params {
|
|
|
1523
1533
|
declare function buildAcspV2Payload(p: AcspV2Params): Buffer;
|
|
1524
1534
|
/** HASH_{hashAlgorithm}(payload). */
|
|
1525
1535
|
declare function acspV2Digest(p: AcspV2Params, hashAlgorithm: HashAlgorithm | string): Buffer;
|
|
1536
|
+
/**
|
|
1537
|
+
* Linked signing буцах URL-ийн `sessionSecretDigest` = BASE64URL-NOPAD(SHA-256(base64-decode(sessionSecret))).
|
|
1538
|
+
* `sessionSecret` — certificate-choice device-link session-ий нууц (стандарт base64). Smart-ID RP-API v3
|
|
1539
|
+
* `CallbackUrlUtil`-тай ижил.
|
|
1540
|
+
*/
|
|
1541
|
+
declare function sessionSecretDigest(sessionSecret: string): string;
|
|
1542
|
+
/**
|
|
1543
|
+
* Callback-ийн `sessionSecretDigest`-ийг certificate-choice session-ий `sessionSecret`-тэй тулгана (timing-safe).
|
|
1544
|
+
* Буруу хэлбэр / хоосон оролтод `false` (throw хийхгүй).
|
|
1545
|
+
*/
|
|
1546
|
+
declare function verifySessionSecretDigest(digest: string, sessionSecret: string): boolean;
|
|
1526
1547
|
|
|
1527
1548
|
/** Холбоосын төрөл — апп гарын үсгийн `flowType`-д яг энэ утгыг зурна (authCode-оор хамгаалагдсан). */
|
|
1528
1549
|
type DeviceLinkType = "QR" | "Web2App" | "App2App";
|
|
@@ -1852,4 +1873,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1852
1873
|
*/
|
|
1853
1874
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1854
1875
|
|
|
1855
|
-
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_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, 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 ParsedQr, 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_CLOCK_SKEW_SECONDS, QR_ERROR_CODES, QR_LIMITS, QR_MAX_AGE_SECONDS, QR_PREFIX, QrApi, type QrApiDeps, type QrCheck, type QrClaims, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrPresentation, type QrSession, type QrSigner, 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, qrStatement, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, verifyTokenCertificates, withReturnHint };
|
|
1876
|
+
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_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, 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 ParsedQr, 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_CLOCK_SKEW_SECONDS, QR_ERROR_CODES, QR_LIMITS, QR_MAX_AGE_SECONDS, QR_PREFIX, QrApi, type QrApiDeps, type QrCheck, type QrClaims, type QrConfig, type QrDeviceLinkTickerOptions, QrError, type QrErrorCode, type QrExpect, type QrPresentation, type QrSession, type QrSigner, 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, qrStatement, randomChallenge, registrationFromCompleted, resolveBaseUrl, sessionSecretDigest, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyQrPresentation, verifySessionSecretDigest, verifyTokenCertificates, withReturnHint };
|
package/dist/index.js
CHANGED
|
@@ -207,7 +207,7 @@ function routePath(route, ...args) {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
// src/crypto.ts
|
|
210
|
-
import { createHash, randomBytes } from "crypto";
|
|
210
|
+
import { createHash, randomBytes, timingSafeEqual } from "crypto";
|
|
211
211
|
function sha256Base64(data) {
|
|
212
212
|
return createHash("sha256").update(data).digest("base64");
|
|
213
213
|
}
|
|
@@ -243,6 +243,16 @@ function buildAcspV2Payload(p) {
|
|
|
243
243
|
function acspV2Digest(p, hashAlgorithm) {
|
|
244
244
|
return createHash(nodeHash(hashAlgorithm)).update(buildAcspV2Payload(p)).digest();
|
|
245
245
|
}
|
|
246
|
+
function sessionSecretDigest(sessionSecret) {
|
|
247
|
+
return createHash("sha256").update(Buffer.from(sessionSecret, "base64")).digest("base64url");
|
|
248
|
+
}
|
|
249
|
+
function verifySessionSecretDigest(digest, sessionSecret) {
|
|
250
|
+
if (typeof digest !== "string" || typeof sessionSecret !== "string" || !digest || !sessionSecret) return false;
|
|
251
|
+
if (!/^[A-Za-z0-9_-]+$/.test(digest)) return false;
|
|
252
|
+
const got = Buffer.from(digest, "utf8");
|
|
253
|
+
const want = Buffer.from(sessionSecretDigest(sessionSecret), "utf8");
|
|
254
|
+
return got.length === want.length && timingSafeEqual(got, want);
|
|
255
|
+
}
|
|
246
256
|
|
|
247
257
|
// src/types.ts
|
|
248
258
|
var DEFAULT_SIGN_SESSION_TTL_MS = 6e5;
|
|
@@ -685,13 +695,18 @@ var SignApi = class {
|
|
|
685
695
|
return this.notification(routePath(RP_ROUTES.certChoiceEtsi, id), this.certChoiceBody(opts));
|
|
686
696
|
}
|
|
687
697
|
/**
|
|
688
|
-
*
|
|
689
|
-
*
|
|
698
|
+
* Device link: иргэн хэн болохыг урьдчилж мэдэхгүй үед гэрчилгээ сонгуулах. `opts.callbackUrl` өгөөгүй бол
|
|
699
|
+
* ЗӨВХӨН QR (`deviceLinkInput(s, "QR", lang)`); өгвөл (CA-ийн callback_hosts-д байх https URL) Web2App/App2App
|
|
700
|
+
* холбоос мөн угсарна, linked sign дууссаны дараа утас callback-ийг нээнэ. CERT эрх.
|
|
690
701
|
*/
|
|
691
702
|
async certificateChoiceDeviceLink(opts) {
|
|
692
|
-
|
|
703
|
+
const body = this.certChoiceBody(opts);
|
|
704
|
+
const callback = opts?.callbackUrl?.trim();
|
|
705
|
+
if (callback) body.initialCallbackUrl = callback;
|
|
706
|
+
return this.deviceLink(routePath(RP_ROUTES.certChoiceDeviceLink), body, {
|
|
693
707
|
sessionType: "cert",
|
|
694
|
-
relyingPartyName: this.creds.rpName
|
|
708
|
+
relyingPartyName: this.creds.rpName,
|
|
709
|
+
...callback ? { initialCallbackUrl: callback } : {}
|
|
695
710
|
});
|
|
696
711
|
}
|
|
697
712
|
// ── Гэрчилгээ урьдчилж мэдэгдэх гарын үсэг (client-side PAdES / CMS) ──
|
|
@@ -943,7 +958,7 @@ var PersonApi = class {
|
|
|
943
958
|
};
|
|
944
959
|
|
|
945
960
|
// src/token.ts
|
|
946
|
-
import { X509Certificate as X509Certificate3, createHash as createHash3, createPublicKey, timingSafeEqual } from "crypto";
|
|
961
|
+
import { X509Certificate as X509Certificate3, createHash as createHash3, createPublicKey, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
947
962
|
|
|
948
963
|
// src/subject.ts
|
|
949
964
|
import { X509Certificate } from "crypto";
|
|
@@ -1298,7 +1313,7 @@ var ResponseValidator = class {
|
|
|
1298
1313
|
}
|
|
1299
1314
|
/**
|
|
1300
1315
|
* Токены нэвтрэлтийн гэрчилгээ ({@link TokenApi.authVerify}) — хугацаа, зориулалт (auth), гинж, issuer. Түвшинг
|
|
1301
|
-
* шалгахгүй (
|
|
1316
|
+
* шалгахгүй (2026-11-06-аас өмнө олгосон токен CA-д ADVANCED).
|
|
1302
1317
|
* @internal
|
|
1303
1318
|
*/
|
|
1304
1319
|
verifyTokenAuthCertificate(leaf) {
|
|
@@ -1598,15 +1613,32 @@ var LEVEL_RANK = { ADVANCED: 1, QUALIFIED: 2, QSCD: 3 };
|
|
|
1598
1613
|
var OID_QC_STATEMENTS = "1.3.6.1.5.5.7.1.3";
|
|
1599
1614
|
var OID_QC_COMPLIANCE = "0.4.0.1862.1.1";
|
|
1600
1615
|
var OID_QC_SSCD = "0.4.0.1862.1.4";
|
|
1616
|
+
var OID_POLICY_NATIONAL = "2.16.496.1.101.1.2.8";
|
|
1601
1617
|
function certificateLevelOf(cert, protocol) {
|
|
1602
1618
|
const qc = qcStatementIds(cert);
|
|
1603
1619
|
if (qc) {
|
|
1604
1620
|
if (!qc.includes(OID_QC_COMPLIANCE)) return "ADVANCED";
|
|
1605
1621
|
return qc.includes(OID_QC_SSCD) ? "QSCD" : "QUALIFIED";
|
|
1606
1622
|
}
|
|
1607
|
-
if (protocol === "ACSP_V2" && keyUsageBits(cert) & 32) return "QUALIFIED";
|
|
1623
|
+
if (protocol === "ACSP_V2" && (keyUsageBits(cert) & 32 || isCitizenAuthToken(cert))) return "QUALIFIED";
|
|
1608
1624
|
return "ADVANCED";
|
|
1609
1625
|
}
|
|
1626
|
+
function isCitizenAuthToken(cert) {
|
|
1627
|
+
const eku = extKeyUsage(cert);
|
|
1628
|
+
return eku.includes(EKU_CLIENT_AUTH) && eku.includes(EKU_EMAIL_PROTECTION) && certPolicyIds(cert).includes(OID_POLICY_NATIONAL);
|
|
1629
|
+
}
|
|
1630
|
+
function certPolicyIds(cert) {
|
|
1631
|
+
const v = certExtension(cert.raw, "2.5.29.32");
|
|
1632
|
+
if (!v) return [];
|
|
1633
|
+
const seq = tlv(v, 0, v.length);
|
|
1634
|
+
const out = [];
|
|
1635
|
+
for (let p = seq.start; p < seq.end; ) {
|
|
1636
|
+
const pi = tlv(v, p, seq.end);
|
|
1637
|
+
out.push(oidOf(v, tlv(v, pi.start, pi.end)));
|
|
1638
|
+
p = pi.end;
|
|
1639
|
+
}
|
|
1640
|
+
return out;
|
|
1641
|
+
}
|
|
1610
1642
|
function effectiveLevel(claimed, fromCert) {
|
|
1611
1643
|
const c = LEVEL_RANK[claimed];
|
|
1612
1644
|
if (c === void 0) return fromCert;
|
|
@@ -1740,7 +1772,7 @@ function rec4(v) {
|
|
|
1740
1772
|
}
|
|
1741
1773
|
function hexSha256Equal(hex, data) {
|
|
1742
1774
|
if (typeof hex !== "string" || !/^[0-9a-fA-F]{64}$/.test(hex)) return false;
|
|
1743
|
-
return
|
|
1775
|
+
return timingSafeEqual2(createHash3("sha256").update(data).digest(), Buffer.from(hex, "hex"));
|
|
1744
1776
|
}
|
|
1745
1777
|
var TOKEN_CONFLICT_CODES = ["TOKEN_LIMIT_REACHED", "TOKEN_IN_USE", "TOKEN_SCOPE_CHANGE", "ACCOUNT_DELETE_PENDING"];
|
|
1746
1778
|
var TOKEN_ISSUANCE_PENDING = "TOKEN_ISSUANCE_PENDING";
|
|
@@ -2670,7 +2702,13 @@ function deviceLinkInput(s, deviceLinkType, lang) {
|
|
|
2670
2702
|
};
|
|
2671
2703
|
}
|
|
2672
2704
|
if (s.sessionType === "cert") {
|
|
2673
|
-
return {
|
|
2705
|
+
return {
|
|
2706
|
+
...base,
|
|
2707
|
+
sessionType: "cert",
|
|
2708
|
+
relyingPartyName: s.relyingPartyName ?? "",
|
|
2709
|
+
interactions: "",
|
|
2710
|
+
initialCallbackUrl: s.initialCallbackUrl ?? ""
|
|
2711
|
+
};
|
|
2674
2712
|
}
|
|
2675
2713
|
return {
|
|
2676
2714
|
...base,
|
|
@@ -2691,7 +2729,7 @@ function qrDeviceLinkTicker(input, onLink, opts) {
|
|
|
2691
2729
|
}
|
|
2692
2730
|
|
|
2693
2731
|
// src/login.ts
|
|
2694
|
-
import { createHash as createHash6, createHmac as createHmac2, randomBytes as randomBytes3, randomInt, randomUUID, timingSafeEqual as
|
|
2732
|
+
import { createHash as createHash6, createHmac as createHmac2, randomBytes as randomBytes3, randomInt, randomUUID, timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
2695
2733
|
var MEMORY_LOGIN_STORE_MAX = 1e4;
|
|
2696
2734
|
var LoginStoreFullError = class extends Error {
|
|
2697
2735
|
constructor() {
|
|
@@ -2834,7 +2872,7 @@ var sha256hex = (s) => createHash6("sha256").update(s).digest("hex");
|
|
|
2834
2872
|
function safeEqualHex(a, b) {
|
|
2835
2873
|
const x = Buffer.from(a, "hex");
|
|
2836
2874
|
const y = Buffer.from(b, "hex");
|
|
2837
|
-
return x.length === y.length && x.length > 0 &&
|
|
2875
|
+
return x.length === y.length && x.length > 0 && timingSafeEqual3(x, y);
|
|
2838
2876
|
}
|
|
2839
2877
|
function sleep(ms2, signal) {
|
|
2840
2878
|
return new Promise((resolve) => {
|
|
@@ -3358,6 +3396,7 @@ export {
|
|
|
3358
3396
|
registrationFromCompleted,
|
|
3359
3397
|
resolveBaseUrl,
|
|
3360
3398
|
sessionExpiry,
|
|
3399
|
+
sessionSecretDigest,
|
|
3361
3400
|
sha256Base64,
|
|
3362
3401
|
startExpiry,
|
|
3363
3402
|
tokenAuthDigest,
|
|
@@ -3366,6 +3405,7 @@ export {
|
|
|
3366
3405
|
verifyPayloadSignature,
|
|
3367
3406
|
verifyPrehashedSignature,
|
|
3368
3407
|
verifyQrPresentation,
|
|
3408
|
+
verifySessionSecretDigest,
|
|
3369
3409
|
verifyTokenCertificates,
|
|
3370
3410
|
withReturnHint
|
|
3371
3411
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gerege-systems/eid-mongolia-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "e-ID Mongolia Relying Party SDK — иргэнээр утсаар нь нэвтрэлт ба хууль ёсны цахим гарын үсэг (RP-API v3, Smart-ID нийцтэй).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|