@gerege-systems/eid-mongolia-sdk 0.22.0 → 0.24.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 +74 -9
- package/bin/convert-assets.mjs +176 -20
- package/dist/{browser-DBR6ziM5.d.ts → browser-BYY0cP2D.d.ts} +1 -1
- package/dist/{browser-2PTCiFt_.d.cts → browser-Df4wTfZx.d.cts} +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +1 -1
- package/dist/{chunk-ZB7LEWA5.js → chunk-H7JOACAZ.js} +3 -0
- package/dist/convert.d.ts +2 -2
- package/dist/convert.js +2 -2
- package/dist/{errors-xTmsGXyo.d.ts → errors-BM8D3VEw.d.cts} +7 -1
- package/dist/{errors-xTmsGXyo.d.cts → errors-BM8D3VEw.d.ts} +7 -1
- package/dist/index.cjs +114 -24
- package/dist/index.d.cts +67 -6
- package/dist/index.d.ts +67 -6
- package/dist/index.js +111 -25
- package/dist/pades.d.cts +1 -1
- package/dist/pades.d.ts +1 -1
- package/dist/pades.js +1 -1
- package/dist/validate.d.cts +1 -1
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,9 @@ var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: tr
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
APP_ATTESTATION_INVALID: () => APP_ATTESTATION_INVALID,
|
|
23
24
|
ApiError: () => ApiError,
|
|
25
|
+
AppTransactionTooLargeError: () => AppTransactionTooLargeError,
|
|
24
26
|
AuthApi: () => AuthApi,
|
|
25
27
|
AuthenticationError: () => AuthenticationError,
|
|
26
28
|
CITIZEN_INTERMEDIATES_PEM: () => CITIZEN_INTERMEDIATES_PEM,
|
|
@@ -36,6 +38,7 @@ __export(index_exports, {
|
|
|
36
38
|
ForbiddenError: () => ForbiddenError,
|
|
37
39
|
Http: () => Http,
|
|
38
40
|
LoginStoreFullError: () => LoginStoreFullError,
|
|
41
|
+
MAX_APP_TRANSACTION_BYTES: () => MAX_APP_TRANSACTION_BYTES,
|
|
39
42
|
MEMORY_LOGIN_STORE_MAX: () => MEMORY_LOGIN_STORE_MAX,
|
|
40
43
|
NATIONAL_ROOT_CA_PEM: () => NATIONAL_ROOT_CA_PEM,
|
|
41
44
|
NetworkError: () => NetworkError,
|
|
@@ -239,6 +242,8 @@ var SessionFailedError = class extends EidError {
|
|
|
239
242
|
};
|
|
240
243
|
var ValidationError = class extends EidError {
|
|
241
244
|
};
|
|
245
|
+
var AppTransactionTooLargeError = class extends EidError {
|
|
246
|
+
};
|
|
242
247
|
var DeviceLinkError = class extends EidError {
|
|
243
248
|
};
|
|
244
249
|
|
|
@@ -537,6 +542,15 @@ var AuthApi = class {
|
|
|
537
542
|
...expiresAt !== void 0 ? { expiresAt } : {}
|
|
538
543
|
};
|
|
539
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Discovery (`/.well-known/eid`)-ийн `sessionTtl` — CA-ийн нэвтрэлт / гарын үсгийн session-ий хугацаа (мс; CA-ийн
|
|
547
|
+
* «Системийн тохиргоо»-оос амьд). Хуучин CA-д (талбар алга) 0.
|
|
548
|
+
*/
|
|
549
|
+
async sessionTtl() {
|
|
550
|
+
const t = rec(rec(await this.http.get("/.well-known/eid")).sessionTtl);
|
|
551
|
+
const ms2 = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 ? Math.floor(v) * 1e3 : 0;
|
|
552
|
+
return { authMs: ms2(t.auth), signMs: ms2(t.sign) };
|
|
553
|
+
}
|
|
540
554
|
/** Push — РД/иргэний дугаар/ETSI-ээр (сервер төрлийг таьна). Иргэний утас руу мэдэгдэл очно. */
|
|
541
555
|
async notificationByEtsi(id, interactions, opts) {
|
|
542
556
|
const { body, acsp } = this.baseBody(randomChallenge(), interactions, ["Notification"], opts);
|
|
@@ -1897,6 +1911,8 @@ function basicConstraintsPathLen(cert) {
|
|
|
1897
1911
|
}
|
|
1898
1912
|
|
|
1899
1913
|
// src/token.ts
|
|
1914
|
+
var MAX_APP_TRANSACTION_BYTES = 16 * 1024;
|
|
1915
|
+
var APP_ATTESTATION_INVALID = "APP_ATTESTATION_INVALID";
|
|
1900
1916
|
function rec4(v) {
|
|
1901
1917
|
return v && typeof v === "object" ? v : {};
|
|
1902
1918
|
}
|
|
@@ -1905,6 +1921,9 @@ function hexSha256Equal(hex, data) {
|
|
|
1905
1921
|
return (0, import_node_crypto4.timingSafeEqual)((0, import_node_crypto4.createHash)("sha256").update(data).digest(), Buffer.from(hex, "hex"));
|
|
1906
1922
|
}
|
|
1907
1923
|
var TOKEN_CONFLICT_CODES = ["TOKEN_LIMIT_REACHED", "TOKEN_IN_USE", "TOKEN_SCOPE_CHANGE", "ACCOUNT_DELETE_PENDING"];
|
|
1924
|
+
function supersedesOf(v) {
|
|
1925
|
+
return Array.isArray(v) ? { supersedes: v.map((x) => ({ tokenSerial: String(rec4(x).tokenSerial ?? "") })) } : {};
|
|
1926
|
+
}
|
|
1908
1927
|
var DISCOVERY_PATH = "/.well-known/eid";
|
|
1909
1928
|
var TOKEN_RESULT_TIMEOUT_MS = 3e4;
|
|
1910
1929
|
var TokenApi = class {
|
|
@@ -1924,11 +1943,44 @@ var TokenApi = class {
|
|
|
1924
1943
|
* байгууллагын токен зөвхөн тэр байгууллагаар (`onBehalfOf` ижил), хувийн токен зөвхөн хувиараа. Өөр scope бол
|
|
1925
1944
|
* 409 `TOKEN_SCOPE_CHANGE` (override үгүй); scope солих = иргэн eID апп-аас токеноо цуцлаад шинээр олгуулна.
|
|
1926
1945
|
* Бусад 409: `TOKEN_LIMIT_REACHED` ({@link tokenLimitOf}), `TOKEN_IN_USE` ({@link TokenConflictCode}).
|
|
1946
|
+
* 400 {@link APP_ATTESTATION_INVALID} — `appTransaction` хүчингүй; {@link MAX_APP_TRANSACTION_BYTES}-аас их бол
|
|
1947
|
+
* {@link AppTransactionTooLargeError} (илгээхгүй).
|
|
1927
1948
|
*/
|
|
1928
1949
|
async issueCertificate(input) {
|
|
1950
|
+
const r = rec4(await this.http.post(routePath(RP_ROUTES.tokenCertificate), this.certBody(input)));
|
|
1951
|
+
if (!hexSha256Equal(r.csrAuthSha256, input.csrAuth) || !hexSha256Equal(r.csrSignSha256, input.csrSign)) {
|
|
1952
|
+
throw new ValidationError("token: CA-\u0438\u0439\u043D csrAuthSha256/csrSignSha256 \u0438\u043B\u0433\u044D\u044D\u0441\u044D\u043D CSR-\u0442\u044D\u0439 \u0442\u0430\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439");
|
|
1953
|
+
}
|
|
1954
|
+
const vc = rec4(r.vc).value ?? (typeof r.vc === "string" ? r.vc : void 0);
|
|
1955
|
+
return {
|
|
1956
|
+
sessionId: String(r.sessionID ?? ""),
|
|
1957
|
+
vc: vc != null ? String(vc) : null,
|
|
1958
|
+
csrAuthSha256: String(r.csrAuthSha256).toLowerCase(),
|
|
1959
|
+
csrSignSha256: String(r.csrSignSha256).toLowerCase(),
|
|
1960
|
+
...typeof r.expiresAt === "string" ? { expiresAt: r.expiresAt } : {},
|
|
1961
|
+
...supersedesOf(r.supersedes)
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1965
|
+
* POST /token/certificate `{"dryRun": true}` (CA 2026-10-19, discovery `tokenCertificate.dryRun`): {@link issueCertificate}-ийн
|
|
1966
|
+
* бүх шалгалт ижил алдааны кодтой, гэхдээ session / утас руу push үүсэхгүй. Урсгал: CSR → previewCertificate →
|
|
1967
|
+
* `supersedes` байвал иргэнд анхааруулж зөвшөөрүүлэх → issueCertificate (ижил оролт). Хурдны хязгаар (RP, иргэн) 20/мин
|
|
1968
|
+
* (push-ийн 3/цагийг зарцуулахгүй). Хариунд `dryRun: true` алга бол ValidationError. Хуучин CA-д 400 (танихгүй талбар).
|
|
1969
|
+
*/
|
|
1970
|
+
async previewCertificate(input) {
|
|
1971
|
+
const r = rec4(await this.http.post(routePath(RP_ROUTES.tokenCertificate), { ...this.certBody(input), dryRun: true }));
|
|
1972
|
+
if (r.dryRun !== true) throw new ValidationError("token: dryRun \u0445\u0430\u0440\u0438\u0443 \u0431\u0438\u0448 (CA dryRun-\u0438\u0439\u0433 \u0434\u044D\u043C\u0436\u0438\u0445\u0433\u04AF\u0439)");
|
|
1973
|
+
return { ...supersedesOf(r.supersedes) };
|
|
1974
|
+
}
|
|
1975
|
+
/** Оролтыг шалгаж POST /token/certificate-ийн биеийг угсарна. CA DisallowUnknownFields — яг эдгээр талбар. */
|
|
1976
|
+
certBody(input) {
|
|
1929
1977
|
if (!input.signerEtsi?.trim() || !input.csrAuth?.length || !input.csrSign?.length || !input.tokenSerial?.trim()) {
|
|
1930
1978
|
throw new Error("token: signerEtsi, csrAuth, csrSign, tokenSerial \u0448\u0430\u0430\u0440\u0434\u043B\u0430\u0433\u0430\u0442\u0430\u0439");
|
|
1931
1979
|
}
|
|
1980
|
+
const appTransaction = input.appTransaction?.trim() ?? "";
|
|
1981
|
+
if (Buffer.byteLength(input.appTransaction ?? "", "utf8") > MAX_APP_TRANSACTION_BYTES) {
|
|
1982
|
+
throw new AppTransactionTooLargeError("token: appTransaction 16 KiB-\u0430\u0430\u0441 \u0438\u0445");
|
|
1983
|
+
}
|
|
1932
1984
|
const body = {
|
|
1933
1985
|
relyingPartyUUID: this.creds.rpUUID,
|
|
1934
1986
|
relyingPartyName: this.creds.rpName,
|
|
@@ -1940,18 +1992,8 @@ var TokenApi = class {
|
|
|
1940
1992
|
flow: "notification"
|
|
1941
1993
|
};
|
|
1942
1994
|
if (input.tokenLabel) body.tokenLabel = input.tokenLabel;
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
throw new ValidationError("token: CA-\u0438\u0439\u043D csrAuthSha256/csrSignSha256 \u0438\u043B\u0433\u044D\u044D\u0441\u044D\u043D CSR-\u0442\u044D\u0439 \u0442\u0430\u0430\u0440\u0441\u0430\u043D\u0433\u04AF\u0439");
|
|
1946
|
-
}
|
|
1947
|
-
const vc = rec4(r.vc).value ?? (typeof r.vc === "string" ? r.vc : void 0);
|
|
1948
|
-
return {
|
|
1949
|
-
sessionId: String(r.sessionID ?? ""),
|
|
1950
|
-
vc: vc != null ? String(vc) : null,
|
|
1951
|
-
csrAuthSha256: String(r.csrAuthSha256).toLowerCase(),
|
|
1952
|
-
csrSignSha256: String(r.csrSignSha256).toLowerCase(),
|
|
1953
|
-
...typeof r.expiresAt === "string" ? { expiresAt: r.expiresAt } : {}
|
|
1954
|
-
};
|
|
1995
|
+
if (appTransaction) body.appTransaction = appTransaction;
|
|
1996
|
+
return body;
|
|
1955
1997
|
}
|
|
1956
1998
|
/** Discovery-ийн `tokenCertificate` блок. Блок байхгүй (хуучин CA) бол `enabled: false`. */
|
|
1957
1999
|
async certificateInfo() {
|
|
@@ -1966,6 +2008,9 @@ var TokenApi = class {
|
|
|
1966
2008
|
keyAlgorithm: String(t.keyAlgorithm ?? ""),
|
|
1967
2009
|
onBehalfOf: String(t.onBehalfOf ?? ""),
|
|
1968
2010
|
scopeLockedOnRenewal: t.scopeLockedOnRenewal === true,
|
|
2011
|
+
appTransaction: String(t.appTransaction ?? ""),
|
|
2012
|
+
personalAutoSupersede: t.personalAutoSupersede === true,
|
|
2013
|
+
dryRun: t.dryRun === true,
|
|
1969
2014
|
raw: d.tokenCertificate
|
|
1970
2015
|
};
|
|
1971
2016
|
}
|
|
@@ -3332,6 +3377,38 @@ function createEidLogin(opts) {
|
|
|
3332
3377
|
const revocation = opts.revocation === false ? void 0 : opts.revocation ?? ocspRevocationChecker();
|
|
3333
3378
|
const revocationMode = opts.revocationMode ?? "soft-fail";
|
|
3334
3379
|
const auditKey = opts.auditKey ?? (0, import_node_crypto7.randomBytes)(32);
|
|
3380
|
+
let caTtl = 0;
|
|
3381
|
+
let caTtlNext = 0;
|
|
3382
|
+
let caTtlInflight;
|
|
3383
|
+
function authTtl(ctx2) {
|
|
3384
|
+
if (Date.now() < caTtlNext) return Promise.resolve(caTtl);
|
|
3385
|
+
caTtlInflight ??= (async () => {
|
|
3386
|
+
caTtlNext = Date.now() + 6e4;
|
|
3387
|
+
let timer;
|
|
3388
|
+
try {
|
|
3389
|
+
const t = await Promise.race([
|
|
3390
|
+
client.auth.sessionTtl(),
|
|
3391
|
+
new Promise((_, rej) => {
|
|
3392
|
+
timer = setTimeout(() => rej(new Error("discovery timeout")), 2e3);
|
|
3393
|
+
})
|
|
3394
|
+
]);
|
|
3395
|
+
caTtlNext = Date.now() + 6e5;
|
|
3396
|
+
if (t.authMs > 0) caTtl = t.authMs;
|
|
3397
|
+
} catch (e) {
|
|
3398
|
+
onError(new Error(`eid-login: discovery sessionTtl: ${e instanceof Error ? e.message : e}`), ctx2);
|
|
3399
|
+
} finally {
|
|
3400
|
+
clearTimeout(timer);
|
|
3401
|
+
caTtlInflight = void 0;
|
|
3402
|
+
}
|
|
3403
|
+
return caTtl;
|
|
3404
|
+
})();
|
|
3405
|
+
return caTtlInflight;
|
|
3406
|
+
}
|
|
3407
|
+
function observeAuthTtl(sent, expiresAt) {
|
|
3408
|
+
if (expiresAt === void 0 || caTtl > 0) return;
|
|
3409
|
+
const d = Math.round((expiresAt - sent) / 1e3) * 1e3;
|
|
3410
|
+
if (d > 0) caTtl = d;
|
|
3411
|
+
}
|
|
3335
3412
|
const pushKey = (idCode) => (0, import_node_crypto7.createHmac)("sha256", auditKey).update(`eid-push-audit:${idCode}`).digest("hex").slice(0, 32);
|
|
3336
3413
|
async function emit(kind, sessionId, meta, ctx2) {
|
|
3337
3414
|
if (!opts.onEvent) return;
|
|
@@ -3406,17 +3483,20 @@ function createEidLogin(opts) {
|
|
|
3406
3483
|
interactions: tx.acsp.interactions
|
|
3407
3484
|
});
|
|
3408
3485
|
}
|
|
3409
|
-
async function begin(req, mode, idCode, lang) {
|
|
3486
|
+
async function begin(req, mode, idCode, lang, ttlMs) {
|
|
3487
|
+
const sent = Date.now();
|
|
3410
3488
|
const level = opts.certificateLevel ? { certificateLevel: opts.certificateLevel } : {};
|
|
3411
3489
|
let tx;
|
|
3412
3490
|
let appLink;
|
|
3413
3491
|
if (mode === "push") {
|
|
3414
3492
|
const s = await client.auth.notificationByEtsi(idCode, interactions, level);
|
|
3415
3493
|
tx = { sessionId: s.sessionId, mode, vc: s.vc, acsp: s.acsp };
|
|
3494
|
+
observeAuthTtl(sent, s.expiresAt);
|
|
3416
3495
|
} else {
|
|
3417
3496
|
const callbackUrl = mode === "web2app" ? withReturnHint(opts.callbackUrl, header(req.headers, "user-agent")) : void 0;
|
|
3418
3497
|
const s = await client.auth.deviceLinkAnonymous(interactions, { ...level, callbackUrl });
|
|
3419
3498
|
if (!s.deviceLinkBase || !s.sessionToken || !s.sessionSecret || !s.acsp) throw new Error("eID \u0445\u0430\u0440\u0438\u0443\u043D\u0434 device link \u0442\u0430\u043B\u0431\u0430\u0440 \u0434\u0443\u0442\u0443\u0443");
|
|
3499
|
+
if (s.expiresAt !== void 0) ttlMs = Math.min(ttlMs, Math.floor((s.expiresAt - Date.now()) / 1e3) * 1e3);
|
|
3420
3500
|
tx = {
|
|
3421
3501
|
sessionId: s.sessionId,
|
|
3422
3502
|
mode,
|
|
@@ -3439,18 +3519,20 @@ function createEidLogin(opts) {
|
|
|
3439
3519
|
});
|
|
3440
3520
|
}
|
|
3441
3521
|
}
|
|
3442
|
-
|
|
3522
|
+
if (ttlMs < 1e3) throw new Error("eID session-\u0438\u0439 \u0445\u0443\u0433\u0430\u0446\u0430\u0430 \u0434\u0443\u0443\u0441\u0441\u0430\u043D (expiresAt)");
|
|
3523
|
+
return { ...await save(tx, ttlMs), appLink };
|
|
3443
3524
|
}
|
|
3444
|
-
async function save(tx) {
|
|
3525
|
+
async function save(tx, ttlMs) {
|
|
3445
3526
|
const binding = (0, import_node_crypto7.randomBytes)(32).toString("base64url");
|
|
3446
|
-
const full = { ...tx, bindingHash: sha256hex(binding), expiresAt: Date.now() +
|
|
3447
|
-
await store.set(full.sessionId, full,
|
|
3448
|
-
const
|
|
3449
|
-
|
|
3527
|
+
const full = { ...tx, bindingHash: sha256hex(binding), expiresAt: Date.now() + ttlMs };
|
|
3528
|
+
await store.set(full.sessionId, full, ttlMs);
|
|
3529
|
+
const expiresIn = Math.ceil(ttlMs / 1e3);
|
|
3530
|
+
const setCookie = `${cookieName}=${full.sessionId}.${binding}; ${cookieAttrs(expiresIn)}`;
|
|
3531
|
+
return { tx: full, setCookie, expiresIn, appLink: void 0 };
|
|
3450
3532
|
}
|
|
3451
|
-
function startDecoy() {
|
|
3533
|
+
function startDecoy(ttlMs) {
|
|
3452
3534
|
const acsp = void 0;
|
|
3453
|
-
return save({ sessionId: (0, import_node_crypto7.randomUUID)(), mode: "push", vc: String((0, import_node_crypto7.randomInt)(1e5)).padStart(5, "0"), acsp, decoy: true });
|
|
3535
|
+
return save({ sessionId: (0, import_node_crypto7.randomUUID)(), mode: "push", vc: String((0, import_node_crypto7.randomInt)(1e5)).padStart(5, "0"), acsp, decoy: true }, ttlMs);
|
|
3454
3536
|
}
|
|
3455
3537
|
async function start(req) {
|
|
3456
3538
|
const url = new URL(req.url, "http://x");
|
|
@@ -3488,11 +3570,16 @@ function createEidLogin(opts) {
|
|
|
3488
3570
|
if (ip && !await rateLimit(`start:${ip}`)) return limited();
|
|
3489
3571
|
if (mode === "push" && !await rateLimit(`push:${idCode}`)) return limited();
|
|
3490
3572
|
const began = Date.now();
|
|
3573
|
+
let ttlMs = ttl;
|
|
3574
|
+
if (mode === "push") {
|
|
3575
|
+
const ca = await authTtl(ctx2);
|
|
3576
|
+
if (ca > 0) ttlMs = Math.min(ttlMs, ca);
|
|
3577
|
+
}
|
|
3491
3578
|
let r;
|
|
3492
3579
|
let err;
|
|
3493
3580
|
let decoy = false;
|
|
3494
3581
|
try {
|
|
3495
|
-
r = await begin(req, mode, idCode, lang);
|
|
3582
|
+
r = await begin(req, mode, idCode, lang, ttlMs);
|
|
3496
3583
|
} catch (e) {
|
|
3497
3584
|
err = e;
|
|
3498
3585
|
}
|
|
@@ -3501,7 +3588,7 @@ function createEidLogin(opts) {
|
|
|
3501
3588
|
onError(new Error(`eid-login: eID push-\u0438\u0439\u0433 \u0442\u0430\u0442\u0433\u0430\u043B\u0437\u0430\u0432 (${ae.status}${ae.code ? ` ${ae.code}` : ""}); decoy session-\u043E\u043E\u0440 \u0445\u0430\u0440\u0438\u0443\u043B\u0430\u0432`), ctx2);
|
|
3502
3589
|
err = void 0;
|
|
3503
3590
|
try {
|
|
3504
|
-
r = await startDecoy();
|
|
3591
|
+
r = await startDecoy(ttlMs);
|
|
3505
3592
|
decoy = true;
|
|
3506
3593
|
} catch (e) {
|
|
3507
3594
|
err = e;
|
|
@@ -3520,7 +3607,7 @@ function createEidLogin(opts) {
|
|
|
3520
3607
|
}
|
|
3521
3608
|
return json(
|
|
3522
3609
|
200,
|
|
3523
|
-
{ mode, vc: r.tx.vc, ...mode === "qr" ? { qr: qrLink(r.tx) } : {}, expiresIn:
|
|
3610
|
+
{ mode, vc: r.tx.vc, ...mode === "qr" ? { qr: qrLink(r.tx) } : {}, expiresIn: r.expiresIn },
|
|
3524
3611
|
{ "Set-Cookie": r.setCookie }
|
|
3525
3612
|
);
|
|
3526
3613
|
}
|
|
@@ -3657,7 +3744,9 @@ function createEidLogin(opts) {
|
|
|
3657
3744
|
}
|
|
3658
3745
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3659
3746
|
0 && (module.exports = {
|
|
3747
|
+
APP_ATTESTATION_INVALID,
|
|
3660
3748
|
ApiError,
|
|
3749
|
+
AppTransactionTooLargeError,
|
|
3661
3750
|
AuthApi,
|
|
3662
3751
|
AuthenticationError,
|
|
3663
3752
|
CITIZEN_INTERMEDIATES_PEM,
|
|
@@ -3673,6 +3762,7 @@ function createEidLogin(opts) {
|
|
|
3673
3762
|
ForbiddenError,
|
|
3674
3763
|
Http,
|
|
3675
3764
|
LoginStoreFullError,
|
|
3765
|
+
MAX_APP_TRANSACTION_BYTES,
|
|
3676
3766
|
MEMORY_LOGIN_STORE_MAX,
|
|
3677
3767
|
NATIONAL_ROOT_CA_PEM,
|
|
3678
3768
|
NetworkError,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { R as RpCredentials, C as CertificateLevel, I as Interaction, S as SignatureAlgorithm, H as HashAlgorithm, N as NotificationSession, D as DeviceLinkSession, a as SessionResult, 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 SessionState, g as SignContext, h as SignatureAlgorithmParameters, i as SignatureProtocol, T as TokenCertSessionBlock, j as TokenCertStatus, k as isMobileUserAgent, p as parseExpiresAt, s as sessionExpiry, l 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-Df4wTfZx.cjs';
|
|
2
|
+
export { c as DEFAULT_SIGN_SESSION_TTL_MS, E as EndResult, d as NavigatorLike, O as OrgResult, e as Representation, f as SessionState, g as SignContext, h as SignatureAlgorithmParameters, i as SignatureProtocol, T as TokenCertSessionBlock, j as TokenCertStatus, k as isMobileUserAgent, p as parseExpiresAt, s as sessionExpiry, l as startExpiry } from './browser-Df4wTfZx.cjs';
|
|
3
3
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
4
|
-
import { A as ApiError, H as HttpErrorInit } from './errors-
|
|
5
|
-
export { a as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError,
|
|
4
|
+
import { A as ApiError, H as HttpErrorInit } from './errors-BM8D3VEw.cjs';
|
|
5
|
+
export { a as AppTransactionTooLargeError, b as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError, c as NoSigningCertificateError, O as ON_BEHALF_ERROR_CODES, d as OnBehalfErrorCode, P as PDF_REGISTER_ERROR_CODES, e as PdfRegisterErrorCode, R as RETRYABLE_ERROR_CODES, f as RequestInvalidError, g as ResponseTooLargeError, h as RetryableErrorCode, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-BM8D3VEw.cjs';
|
|
6
6
|
|
|
7
7
|
interface HttpConfig {
|
|
8
8
|
/** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
|
|
@@ -67,6 +67,11 @@ interface AuthOptions {
|
|
|
67
67
|
/** ACSP_V2 payload-ийн hash (default SHA-512 — Smart-ID v3 жишээтэй ижил). */
|
|
68
68
|
hashAlgorithm?: HashAlgorithm;
|
|
69
69
|
}
|
|
70
|
+
/** Discovery-ийн `sessionTtl` (мс). 0 = хуучин CA. */
|
|
71
|
+
interface SessionTtl {
|
|
72
|
+
authMs: number;
|
|
73
|
+
signMs: number;
|
|
74
|
+
}
|
|
70
75
|
declare class AuthApi {
|
|
71
76
|
private readonly http;
|
|
72
77
|
private readonly creds;
|
|
@@ -76,6 +81,11 @@ declare class AuthApi {
|
|
|
76
81
|
private baseBody;
|
|
77
82
|
private parseNotification;
|
|
78
83
|
private parseDeviceLink;
|
|
84
|
+
/**
|
|
85
|
+
* Discovery (`/.well-known/eid`)-ийн `sessionTtl` — CA-ийн нэвтрэлт / гарын үсгийн session-ий хугацаа (мс; CA-ийн
|
|
86
|
+
* «Системийн тохиргоо»-оос амьд). Хуучин CA-д (талбар алга) 0.
|
|
87
|
+
*/
|
|
88
|
+
sessionTtl(): Promise<SessionTtl>;
|
|
79
89
|
/** Push — РД/иргэний дугаар/ETSI-ээр (сервер төрлийг таьна). Иргэний утас руу мэдэгдэл очно. */
|
|
80
90
|
notificationByEtsi(id: string, interactions: Interaction[], opts?: AuthOptions): Promise<NotificationSession>;
|
|
81
91
|
/** Push — баримтын дугаараар (тодорхой төхөөрөмж рүү). */
|
|
@@ -858,7 +868,20 @@ interface TokenCertInput {
|
|
|
858
868
|
tokenLabel?: string;
|
|
859
869
|
/** Байгууллагын токен (NTRMN-…); хоосон/алга = хувийн токен. */
|
|
860
870
|
onBehalfOf?: string;
|
|
871
|
+
/**
|
|
872
|
+
* Заавал биш: macOS App Store build-ийн StoreKit 2 AppTransaction JWS (compact, ≤ {@link MAX_APP_TRANSACTION_BYTES}).
|
|
873
|
+
* Хоосон/алга бол илгээхгүй (Windows — баталгаагүй олголт). Ирсэн бол CA offline шалгана; хүчингүй бол 400
|
|
874
|
+
* {@link APP_ATTESTATION_INVALID}, утас руу push явахгүй (CA docs/TOKEN_CERT.md §App Store баталгаа).
|
|
875
|
+
*/
|
|
876
|
+
appTransaction?: string;
|
|
861
877
|
}
|
|
878
|
+
/** `appTransaction`-ий дээд хэмжээ (UTF-8 байт; CA-ийн хязгаар, 16 KiB). */
|
|
879
|
+
declare const MAX_APP_TRANSACTION_BYTES: number;
|
|
880
|
+
/**
|
|
881
|
+
* 400 `APP_ATTESTATION_INVALID` (`ApiError.code`) — `appTransaction` ирсэн боловч хүчингүй (гинж Apple Root CA - G3
|
|
882
|
+
* биш, гарын үсэг, bundleId, орчин Xcode, signedDate > 30 хоног …); аль алхам унасныг CA хэлэхгүй. Утас руу push явахгүй.
|
|
883
|
+
*/
|
|
884
|
+
declare const APP_ATTESTATION_INVALID = "APP_ATTESTATION_INVALID";
|
|
862
885
|
interface TokenCertStart {
|
|
863
886
|
sessionId: string;
|
|
864
887
|
/** Иргэнд ХАРУУЛАХ баталгаажуулах код (ПИН биш). */
|
|
@@ -867,6 +890,14 @@ interface TokenCertStart {
|
|
|
867
890
|
csrAuthSha256: string;
|
|
868
891
|
csrSignSha256: string;
|
|
869
892
|
expiresAt?: string;
|
|
893
|
+
/**
|
|
894
|
+
* Хувийн олголтод, иргэний хувийн токены хязгаар хүрсэн үед: олголт амжилттай болоход AUTH + SIGN нь superseded (4)-оор
|
|
895
|
+
* автоматаар цуцлагдах өөр serial-тай хувийн токенууд (CA 2026-10-19). Бусад үед алга. Эхлэлийн мөчийнх — PIN2-оос өмнө
|
|
896
|
+
* иргэнд анхааруул («Таны өмнөх USB токен (…)-ийн гэрчилгээ хүчингүй болно»).
|
|
897
|
+
*/
|
|
898
|
+
supersedes?: {
|
|
899
|
+
tokenSerial: string;
|
|
900
|
+
}[];
|
|
870
901
|
}
|
|
871
902
|
interface TokenCertItem {
|
|
872
903
|
/** base64 DER. */
|
|
@@ -930,6 +961,12 @@ interface TokenLimit {
|
|
|
930
961
|
type TokenConflictCode = "TOKEN_LIMIT_REACHED" | "TOKEN_IN_USE" | "TOKEN_SCOPE_CHANGE" | "ACCOUNT_DELETE_PENDING";
|
|
931
962
|
/** {@link TokenConflictCode}-ийн бүх утга (runtime шалгалтад). */
|
|
932
963
|
declare const TOKEN_CONFLICT_CODES: readonly TokenConflictCode[];
|
|
964
|
+
/** {@link TokenApi.previewCertificate}-ийн хариу. `supersedes` — бодит олголт амжилттай болоход солигдох хувийн токенууд. */
|
|
965
|
+
interface TokenCertPreview {
|
|
966
|
+
supersedes?: {
|
|
967
|
+
tokenSerial: string;
|
|
968
|
+
}[];
|
|
969
|
+
}
|
|
933
970
|
/** Discovery (`/.well-known/eid`)-ийн `tokenCertificate` блок. */
|
|
934
971
|
interface TokenCertInfo {
|
|
935
972
|
enabled: boolean;
|
|
@@ -948,6 +985,15 @@ interface TokenCertInfo {
|
|
|
948
985
|
* `TOKEN_SCOPE_CHANGE`. Хуучин CA-д талбар алга → false.
|
|
949
986
|
*/
|
|
950
987
|
scopeLockedOnRenewal: boolean;
|
|
988
|
+
/** `"optional"` — `appTransaction`-ийг CA хүлээн авна. Хуучин CA-д "" (талбар илгээвэл 400). */
|
|
989
|
+
appTransaction: string;
|
|
990
|
+
/**
|
|
991
|
+
* true — хувийн хязгаар хүрсэн үед өөр serial-тай шинэ хувийн токен 409 биш: `supersedes` ирж, олголт амжилттай болоход
|
|
992
|
+
* өмнөх хувийн токен солигдоно; 409 `TOKEN_LIMIT_REACHED` kind=PERSONAL зөвхөн limit=0 үед. Хуучин CA-д false.
|
|
993
|
+
*/
|
|
994
|
+
personalAutoSupersede: boolean;
|
|
995
|
+
/** true — {@link TokenApi.previewCertificate} (`dryRun`) дэмжигдэнэ. Хуучин CA-д false. */
|
|
996
|
+
dryRun: boolean;
|
|
951
997
|
raw: unknown;
|
|
952
998
|
}
|
|
953
999
|
declare class TokenApi {
|
|
@@ -966,8 +1012,19 @@ declare class TokenApi {
|
|
|
966
1012
|
* байгууллагын токен зөвхөн тэр байгууллагаар (`onBehalfOf` ижил), хувийн токен зөвхөн хувиараа. Өөр scope бол
|
|
967
1013
|
* 409 `TOKEN_SCOPE_CHANGE` (override үгүй); scope солих = иргэн eID апп-аас токеноо цуцлаад шинээр олгуулна.
|
|
968
1014
|
* Бусад 409: `TOKEN_LIMIT_REACHED` ({@link tokenLimitOf}), `TOKEN_IN_USE` ({@link TokenConflictCode}).
|
|
1015
|
+
* 400 {@link APP_ATTESTATION_INVALID} — `appTransaction` хүчингүй; {@link MAX_APP_TRANSACTION_BYTES}-аас их бол
|
|
1016
|
+
* {@link AppTransactionTooLargeError} (илгээхгүй).
|
|
969
1017
|
*/
|
|
970
1018
|
issueCertificate(input: TokenCertInput): Promise<TokenCertStart>;
|
|
1019
|
+
/**
|
|
1020
|
+
* POST /token/certificate `{"dryRun": true}` (CA 2026-10-19, discovery `tokenCertificate.dryRun`): {@link issueCertificate}-ийн
|
|
1021
|
+
* бүх шалгалт ижил алдааны кодтой, гэхдээ session / утас руу push үүсэхгүй. Урсгал: CSR → previewCertificate →
|
|
1022
|
+
* `supersedes` байвал иргэнд анхааруулж зөвшөөрүүлэх → issueCertificate (ижил оролт). Хурдны хязгаар (RP, иргэн) 20/мин
|
|
1023
|
+
* (push-ийн 3/цагийг зарцуулахгүй). Хариунд `dryRun: true` алга бол ValidationError. Хуучин CA-д 400 (танихгүй талбар).
|
|
1024
|
+
*/
|
|
1025
|
+
previewCertificate(input: TokenCertInput): Promise<TokenCertPreview>;
|
|
1026
|
+
/** Оролтыг шалгаж POST /token/certificate-ийн биеийг угсарна. CA DisallowUnknownFields — яг эдгээр талбар. */
|
|
1027
|
+
private certBody;
|
|
971
1028
|
/** Discovery-ийн `tokenCertificate` блок. Блок байхгүй (хуучин CA) бол `enabled: false`. */
|
|
972
1029
|
certificateInfo(): Promise<TokenCertInfo>;
|
|
973
1030
|
/**
|
|
@@ -1441,7 +1498,11 @@ interface EidLoginOptions {
|
|
|
1441
1498
|
/** Утсанд харагдах текст (≤60). Анхдагч «<rpName>-д нэвтрэх». */
|
|
1442
1499
|
displayText?: string;
|
|
1443
1500
|
certificateLevel?: CertificateLevel;
|
|
1444
|
-
/**
|
|
1501
|
+
/**
|
|
1502
|
+
* Нэвтрэлтийн хугацаа (мс). Анхдагч 120 000. CA-ийн session-оос урт байхгүй: QR/web2app-д min(ttlMs, CA-ийн
|
|
1503
|
+
* `expiresAt` − одоо); push-д (бодит ба decoy ижил) min(ttlMs, discovery `sessionTtl.auth`) — decoy-д CA хариу
|
|
1504
|
+
* байхгүй тул хугацааны зөрүү бүртгэлтэй эсэхийн oracle болохгүй.
|
|
1505
|
+
*/
|
|
1445
1506
|
ttlMs?: number;
|
|
1446
1507
|
/** Status-ийн нэг дуудлагад eID-ийг хүлээх (мс). Анхдагч 1000. */
|
|
1447
1508
|
pollMs?: number;
|
|
@@ -1550,4 +1611,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1550
1611
|
*/
|
|
1551
1612
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1552
1613
|
|
|
1553
|
-
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, ApiError, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_INTERMEDIATES_PEM, CITIZEN_ISSUING_CA_SKI, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, DEFAULT_PDF_TIMEOUT_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, 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, LoginStoreFullError, MEMORY_LOGIN_STORE_MAX, NATIONAL_ROOT_CA_PEM, NotificationSession, type OcspCheckerOptions, OrganizationApi, PDF_SIGNATURE_REGISTER_FIELDS, type PdfDigestInput, type PdfDigestSession, type PdfDigestSigner, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type PriorSignature, type QrDeviceLinkTickerOptions, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SessionApi, SessionResult, ShareError, type ShareErrorCode, type ShareInfo, type ShareInput, type ShareNotSignedReason, type ShareResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TOKEN_CONFLICT_CODES, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInfo, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenConflictCode, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, certificateLevelOf, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
|
1614
|
+
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, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, DEFAULT_PDF_TIMEOUT_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, 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, LoginStoreFullError, MAX_APP_TRANSACTION_BYTES, MEMORY_LOGIN_STORE_MAX, NATIONAL_ROOT_CA_PEM, NotificationSession, type OcspCheckerOptions, OrganizationApi, PDF_SIGNATURE_REGISTER_FIELDS, type PdfDigestInput, type PdfDigestSession, type PdfDigestSigner, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type PriorSignature, type QrDeviceLinkTickerOptions, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, 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, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInfo, type TokenCertInput, type TokenCertItem, type TokenCertPreview, type TokenCertResult, type TokenCertStart, type TokenConflictCode, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, certificateLevelOf, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { R as RpCredentials, C as CertificateLevel, I as Interaction, S as SignatureAlgorithm, H as HashAlgorithm, N as NotificationSession, D as DeviceLinkSession, a as SessionResult, 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 SessionState, g as SignContext, h as SignatureAlgorithmParameters, i as SignatureProtocol, T as TokenCertSessionBlock, j as TokenCertStatus, k as isMobileUserAgent, p as parseExpiresAt, s as sessionExpiry, l 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-BYY0cP2D.js';
|
|
2
|
+
export { c as DEFAULT_SIGN_SESSION_TTL_MS, E as EndResult, d as NavigatorLike, O as OrgResult, e as Representation, f as SessionState, g as SignContext, h as SignatureAlgorithmParameters, i as SignatureProtocol, T as TokenCertSessionBlock, j as TokenCertStatus, k as isMobileUserAgent, p as parseExpiresAt, s as sessionExpiry, l as startExpiry } from './browser-BYY0cP2D.js';
|
|
3
3
|
import { X509Certificate, KeyObject } from 'node:crypto';
|
|
4
|
-
import { A as ApiError, H as HttpErrorInit } from './errors-
|
|
5
|
-
export { a as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError,
|
|
4
|
+
import { A as ApiError, H as HttpErrorInit } from './errors-BM8D3VEw.js';
|
|
5
|
+
export { a as AppTransactionTooLargeError, b as AuthenticationError, C as CertChoiceInvalidError, D as DeviceLinkError, E as EidError, F as ForbiddenError, N as NetworkError, c as NoSigningCertificateError, O as ON_BEHALF_ERROR_CODES, d as OnBehalfErrorCode, P as PDF_REGISTER_ERROR_CODES, e as PdfRegisterErrorCode, R as RETRYABLE_ERROR_CODES, f as RequestInvalidError, g as ResponseTooLargeError, h as RetryableErrorCode, S as SessionFailedError, V as ValidationError, p as parseRetryAfter } from './errors-BM8D3VEw.js';
|
|
6
6
|
|
|
7
7
|
interface HttpConfig {
|
|
8
8
|
/** RP-API-ийн бүтэн суурь URL. Ж: https://rp.eidmongolia.mn */
|
|
@@ -67,6 +67,11 @@ interface AuthOptions {
|
|
|
67
67
|
/** ACSP_V2 payload-ийн hash (default SHA-512 — Smart-ID v3 жишээтэй ижил). */
|
|
68
68
|
hashAlgorithm?: HashAlgorithm;
|
|
69
69
|
}
|
|
70
|
+
/** Discovery-ийн `sessionTtl` (мс). 0 = хуучин CA. */
|
|
71
|
+
interface SessionTtl {
|
|
72
|
+
authMs: number;
|
|
73
|
+
signMs: number;
|
|
74
|
+
}
|
|
70
75
|
declare class AuthApi {
|
|
71
76
|
private readonly http;
|
|
72
77
|
private readonly creds;
|
|
@@ -76,6 +81,11 @@ declare class AuthApi {
|
|
|
76
81
|
private baseBody;
|
|
77
82
|
private parseNotification;
|
|
78
83
|
private parseDeviceLink;
|
|
84
|
+
/**
|
|
85
|
+
* Discovery (`/.well-known/eid`)-ийн `sessionTtl` — CA-ийн нэвтрэлт / гарын үсгийн session-ий хугацаа (мс; CA-ийн
|
|
86
|
+
* «Системийн тохиргоо»-оос амьд). Хуучин CA-д (талбар алга) 0.
|
|
87
|
+
*/
|
|
88
|
+
sessionTtl(): Promise<SessionTtl>;
|
|
79
89
|
/** Push — РД/иргэний дугаар/ETSI-ээр (сервер төрлийг таьна). Иргэний утас руу мэдэгдэл очно. */
|
|
80
90
|
notificationByEtsi(id: string, interactions: Interaction[], opts?: AuthOptions): Promise<NotificationSession>;
|
|
81
91
|
/** Push — баримтын дугаараар (тодорхой төхөөрөмж рүү). */
|
|
@@ -858,7 +868,20 @@ interface TokenCertInput {
|
|
|
858
868
|
tokenLabel?: string;
|
|
859
869
|
/** Байгууллагын токен (NTRMN-…); хоосон/алга = хувийн токен. */
|
|
860
870
|
onBehalfOf?: string;
|
|
871
|
+
/**
|
|
872
|
+
* Заавал биш: macOS App Store build-ийн StoreKit 2 AppTransaction JWS (compact, ≤ {@link MAX_APP_TRANSACTION_BYTES}).
|
|
873
|
+
* Хоосон/алга бол илгээхгүй (Windows — баталгаагүй олголт). Ирсэн бол CA offline шалгана; хүчингүй бол 400
|
|
874
|
+
* {@link APP_ATTESTATION_INVALID}, утас руу push явахгүй (CA docs/TOKEN_CERT.md §App Store баталгаа).
|
|
875
|
+
*/
|
|
876
|
+
appTransaction?: string;
|
|
861
877
|
}
|
|
878
|
+
/** `appTransaction`-ий дээд хэмжээ (UTF-8 байт; CA-ийн хязгаар, 16 KiB). */
|
|
879
|
+
declare const MAX_APP_TRANSACTION_BYTES: number;
|
|
880
|
+
/**
|
|
881
|
+
* 400 `APP_ATTESTATION_INVALID` (`ApiError.code`) — `appTransaction` ирсэн боловч хүчингүй (гинж Apple Root CA - G3
|
|
882
|
+
* биш, гарын үсэг, bundleId, орчин Xcode, signedDate > 30 хоног …); аль алхам унасныг CA хэлэхгүй. Утас руу push явахгүй.
|
|
883
|
+
*/
|
|
884
|
+
declare const APP_ATTESTATION_INVALID = "APP_ATTESTATION_INVALID";
|
|
862
885
|
interface TokenCertStart {
|
|
863
886
|
sessionId: string;
|
|
864
887
|
/** Иргэнд ХАРУУЛАХ баталгаажуулах код (ПИН биш). */
|
|
@@ -867,6 +890,14 @@ interface TokenCertStart {
|
|
|
867
890
|
csrAuthSha256: string;
|
|
868
891
|
csrSignSha256: string;
|
|
869
892
|
expiresAt?: string;
|
|
893
|
+
/**
|
|
894
|
+
* Хувийн олголтод, иргэний хувийн токены хязгаар хүрсэн үед: олголт амжилттай болоход AUTH + SIGN нь superseded (4)-оор
|
|
895
|
+
* автоматаар цуцлагдах өөр serial-тай хувийн токенууд (CA 2026-10-19). Бусад үед алга. Эхлэлийн мөчийнх — PIN2-оос өмнө
|
|
896
|
+
* иргэнд анхааруул («Таны өмнөх USB токен (…)-ийн гэрчилгээ хүчингүй болно»).
|
|
897
|
+
*/
|
|
898
|
+
supersedes?: {
|
|
899
|
+
tokenSerial: string;
|
|
900
|
+
}[];
|
|
870
901
|
}
|
|
871
902
|
interface TokenCertItem {
|
|
872
903
|
/** base64 DER. */
|
|
@@ -930,6 +961,12 @@ interface TokenLimit {
|
|
|
930
961
|
type TokenConflictCode = "TOKEN_LIMIT_REACHED" | "TOKEN_IN_USE" | "TOKEN_SCOPE_CHANGE" | "ACCOUNT_DELETE_PENDING";
|
|
931
962
|
/** {@link TokenConflictCode}-ийн бүх утга (runtime шалгалтад). */
|
|
932
963
|
declare const TOKEN_CONFLICT_CODES: readonly TokenConflictCode[];
|
|
964
|
+
/** {@link TokenApi.previewCertificate}-ийн хариу. `supersedes` — бодит олголт амжилттай болоход солигдох хувийн токенууд. */
|
|
965
|
+
interface TokenCertPreview {
|
|
966
|
+
supersedes?: {
|
|
967
|
+
tokenSerial: string;
|
|
968
|
+
}[];
|
|
969
|
+
}
|
|
933
970
|
/** Discovery (`/.well-known/eid`)-ийн `tokenCertificate` блок. */
|
|
934
971
|
interface TokenCertInfo {
|
|
935
972
|
enabled: boolean;
|
|
@@ -948,6 +985,15 @@ interface TokenCertInfo {
|
|
|
948
985
|
* `TOKEN_SCOPE_CHANGE`. Хуучин CA-д талбар алга → false.
|
|
949
986
|
*/
|
|
950
987
|
scopeLockedOnRenewal: boolean;
|
|
988
|
+
/** `"optional"` — `appTransaction`-ийг CA хүлээн авна. Хуучин CA-д "" (талбар илгээвэл 400). */
|
|
989
|
+
appTransaction: string;
|
|
990
|
+
/**
|
|
991
|
+
* true — хувийн хязгаар хүрсэн үед өөр serial-тай шинэ хувийн токен 409 биш: `supersedes` ирж, олголт амжилттай болоход
|
|
992
|
+
* өмнөх хувийн токен солигдоно; 409 `TOKEN_LIMIT_REACHED` kind=PERSONAL зөвхөн limit=0 үед. Хуучин CA-д false.
|
|
993
|
+
*/
|
|
994
|
+
personalAutoSupersede: boolean;
|
|
995
|
+
/** true — {@link TokenApi.previewCertificate} (`dryRun`) дэмжигдэнэ. Хуучин CA-д false. */
|
|
996
|
+
dryRun: boolean;
|
|
951
997
|
raw: unknown;
|
|
952
998
|
}
|
|
953
999
|
declare class TokenApi {
|
|
@@ -966,8 +1012,19 @@ declare class TokenApi {
|
|
|
966
1012
|
* байгууллагын токен зөвхөн тэр байгууллагаар (`onBehalfOf` ижил), хувийн токен зөвхөн хувиараа. Өөр scope бол
|
|
967
1013
|
* 409 `TOKEN_SCOPE_CHANGE` (override үгүй); scope солих = иргэн eID апп-аас токеноо цуцлаад шинээр олгуулна.
|
|
968
1014
|
* Бусад 409: `TOKEN_LIMIT_REACHED` ({@link tokenLimitOf}), `TOKEN_IN_USE` ({@link TokenConflictCode}).
|
|
1015
|
+
* 400 {@link APP_ATTESTATION_INVALID} — `appTransaction` хүчингүй; {@link MAX_APP_TRANSACTION_BYTES}-аас их бол
|
|
1016
|
+
* {@link AppTransactionTooLargeError} (илгээхгүй).
|
|
969
1017
|
*/
|
|
970
1018
|
issueCertificate(input: TokenCertInput): Promise<TokenCertStart>;
|
|
1019
|
+
/**
|
|
1020
|
+
* POST /token/certificate `{"dryRun": true}` (CA 2026-10-19, discovery `tokenCertificate.dryRun`): {@link issueCertificate}-ийн
|
|
1021
|
+
* бүх шалгалт ижил алдааны кодтой, гэхдээ session / утас руу push үүсэхгүй. Урсгал: CSR → previewCertificate →
|
|
1022
|
+
* `supersedes` байвал иргэнд анхааруулж зөвшөөрүүлэх → issueCertificate (ижил оролт). Хурдны хязгаар (RP, иргэн) 20/мин
|
|
1023
|
+
* (push-ийн 3/цагийг зарцуулахгүй). Хариунд `dryRun: true` алга бол ValidationError. Хуучин CA-д 400 (танихгүй талбар).
|
|
1024
|
+
*/
|
|
1025
|
+
previewCertificate(input: TokenCertInput): Promise<TokenCertPreview>;
|
|
1026
|
+
/** Оролтыг шалгаж POST /token/certificate-ийн биеийг угсарна. CA DisallowUnknownFields — яг эдгээр талбар. */
|
|
1027
|
+
private certBody;
|
|
971
1028
|
/** Discovery-ийн `tokenCertificate` блок. Блок байхгүй (хуучин CA) бол `enabled: false`. */
|
|
972
1029
|
certificateInfo(): Promise<TokenCertInfo>;
|
|
973
1030
|
/**
|
|
@@ -1441,7 +1498,11 @@ interface EidLoginOptions {
|
|
|
1441
1498
|
/** Утсанд харагдах текст (≤60). Анхдагч «<rpName>-д нэвтрэх». */
|
|
1442
1499
|
displayText?: string;
|
|
1443
1500
|
certificateLevel?: CertificateLevel;
|
|
1444
|
-
/**
|
|
1501
|
+
/**
|
|
1502
|
+
* Нэвтрэлтийн хугацаа (мс). Анхдагч 120 000. CA-ийн session-оос урт байхгүй: QR/web2app-д min(ttlMs, CA-ийн
|
|
1503
|
+
* `expiresAt` − одоо); push-д (бодит ба decoy ижил) min(ttlMs, discovery `sessionTtl.auth`) — decoy-д CA хариу
|
|
1504
|
+
* байхгүй тул хугацааны зөрүү бүртгэлтэй эсэхийн oracle болохгүй.
|
|
1505
|
+
*/
|
|
1445
1506
|
ttlMs?: number;
|
|
1446
1507
|
/** Status-ийн нэг дуудлагад eID-ийг хүлээх (мс). Анхдагч 1000. */
|
|
1447
1508
|
pollMs?: number;
|
|
@@ -1550,4 +1611,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1550
1611
|
*/
|
|
1551
1612
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1552
1613
|
|
|
1553
|
-
export { AcspContext, type AcspV2Params, type ActivityCounts, type ActivityItem, type ActivityQuery, ApiError, AuthApi, type AuthDefaults, type AuthOptions, type BuildDeviceLinkInput, CITIZEN_INTERMEDIATES_PEM, CITIZEN_ISSUING_CA_SKI, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, DEFAULT_PDF_TIMEOUT_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, 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, LoginStoreFullError, MEMORY_LOGIN_STORE_MAX, NATIONAL_ROOT_CA_PEM, NotificationSession, type OcspCheckerOptions, OrganizationApi, PDF_SIGNATURE_REGISTER_FIELDS, type PdfDigestInput, type PdfDigestSession, type PdfDigestSigner, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type PriorSignature, type QrDeviceLinkTickerOptions, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, type RevocationChecker, type RevocationOutcome, type RevocationStatus, RpCredentials, SHARE_ERROR_CODES, SHARE_FORM_FIELDS, SessionApi, SessionResult, ShareError, type ShareErrorCode, type ShareInfo, type ShareInput, type ShareNotSignedReason, type ShareResult, SignApi, type SignDefaults, type SignOptions, SignatureAlgorithm, type Signer, type SignerRef, TOKEN_CONFLICT_CODES, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInfo, type TokenCertInput, type TokenCertItem, type TokenCertResult, type TokenCertStart, type TokenConflictCode, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, certificateLevelOf, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|
|
1614
|
+
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, type CertChoiceOptions, type CertCounts, type CertSubject, CertificateLevel, type ClientConfig, type CompletedForRegistration, DEFAULT_BASE_URL, DEFAULT_PDF_TIMEOUT_MS, DEFAULT_SHARE_TIMEOUT_MS, DeviceLinkSession, type DeviceLinkSessionType, type DeviceLinkType, EidClient, 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, LoginStoreFullError, MAX_APP_TRANSACTION_BYTES, MEMORY_LOGIN_STORE_MAX, NATIONAL_ROOT_CA_PEM, NotificationSession, type OcspCheckerOptions, OrganizationApi, PDF_SIGNATURE_REGISTER_FIELDS, type PdfDigestInput, type PdfDigestSession, type PdfDigestSigner, type PersonActivity, PersonApi, PersonBlock, type PersonCertificate, type PersonCertificates, type PersonChild, type PersonChildren, type PersonDevice, type PersonDevices, type PersonSummary, type PriorSignature, type QrDeviceLinkTickerOptions, type RegisterSignatureInput, type RegisterSignatureResult, RepresentationsResponse, ResponseValidator, 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, TokenApi, type TokenAuthChallenge, type TokenAuthResult, type TokenCertInfo, type TokenCertInput, type TokenCertItem, type TokenCertPreview, type TokenCertResult, type TokenCertStart, type TokenConflictCode, type TokenIdentity, type TokenLimit, type TokenOrganization, type TrustConfig, type ValidateAuthOptions, type ValidateSignOptions, type VerifiedIdentity, type VerifiedSignature, acspV2Digest, buildAcspV2Payload, buildDeviceLink, buildRegisterBody, certificateLevelOf, createEidLogin, defaultRateLimit, deviceLinkInput, forwardedClientIp, interactionsToBase64, memoryLoginStore, ocspRevocationChecker, parseSessionResult, parseSubject, personMatchesCertificate, qrDeviceLinkTicker, randomChallenge, registrationFromCompleted, resolveBaseUrl, sha256Base64, tokenAuthDigest, tokenLimitOf, userChallengeOf, verifyPayloadSignature, verifyPrehashedSignature, verifyTokenCertificates, withReturnHint };
|