@gerege-systems/eid-mongolia-sdk 0.40.3 → 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 +26 -1
- 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 +30 -5
- package/dist/index.d.cts +24 -5
- package/dist/index.d.ts +24 -5
- package/dist/index.js +33 -10
- 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 **өөрийн бүртгэлээр**
|
|
@@ -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) ──
|
|
@@ -3571,7 +3588,13 @@ function deviceLinkInput(s, deviceLinkType, lang) {
|
|
|
3571
3588
|
};
|
|
3572
3589
|
}
|
|
3573
3590
|
if (s.sessionType === "cert") {
|
|
3574
|
-
return {
|
|
3591
|
+
return {
|
|
3592
|
+
...base,
|
|
3593
|
+
sessionType: "cert",
|
|
3594
|
+
relyingPartyName: s.relyingPartyName ?? "",
|
|
3595
|
+
interactions: "",
|
|
3596
|
+
initialCallbackUrl: s.initialCallbackUrl ?? ""
|
|
3597
|
+
};
|
|
3575
3598
|
}
|
|
3576
3599
|
return {
|
|
3577
3600
|
...base,
|
|
@@ -4260,6 +4283,7 @@ function createEidLogin(opts) {
|
|
|
4260
4283
|
registrationFromCompleted,
|
|
4261
4284
|
resolveBaseUrl,
|
|
4262
4285
|
sessionExpiry,
|
|
4286
|
+
sessionSecretDigest,
|
|
4263
4287
|
sha256Base64,
|
|
4264
4288
|
startExpiry,
|
|
4265
4289
|
tokenAuthDigest,
|
|
@@ -4268,6 +4292,7 @@ function createEidLogin(opts) {
|
|
|
4268
4292
|
verifyPayloadSignature,
|
|
4269
4293
|
verifyPrehashedSignature,
|
|
4270
4294
|
verifyQrPresentation,
|
|
4295
|
+
verifySessionSecretDigest,
|
|
4271
4296
|
verifyTokenCertificates,
|
|
4272
4297
|
withReturnHint
|
|
4273
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;
|
|
@@ -1525,6 +1533,17 @@ interface AcspV2Params {
|
|
|
1525
1533
|
declare function buildAcspV2Payload(p: AcspV2Params): Buffer;
|
|
1526
1534
|
/** HASH_{hashAlgorithm}(payload). */
|
|
1527
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;
|
|
1528
1547
|
|
|
1529
1548
|
/** Холбоосын төрөл — апп гарын үсгийн `flowType`-д яг энэ утгыг зурна (authCode-оор хамгаалагдсан). */
|
|
1530
1549
|
type DeviceLinkType = "QR" | "Web2App" | "App2App";
|
|
@@ -1854,4 +1873,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1854
1873
|
*/
|
|
1855
1874
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1856
1875
|
|
|
1857
|
-
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;
|
|
@@ -1525,6 +1533,17 @@ interface AcspV2Params {
|
|
|
1525
1533
|
declare function buildAcspV2Payload(p: AcspV2Params): Buffer;
|
|
1526
1534
|
/** HASH_{hashAlgorithm}(payload). */
|
|
1527
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;
|
|
1528
1547
|
|
|
1529
1548
|
/** Холбоосын төрөл — апп гарын үсгийн `flowType`-д яг энэ утгыг зурна (authCode-оор хамгаалагдсан). */
|
|
1530
1549
|
type DeviceLinkType = "QR" | "Web2App" | "App2App";
|
|
@@ -1854,4 +1873,4 @@ declare function withReturnHint(callbackUrl: string, userAgent: string): string;
|
|
|
1854
1873
|
*/
|
|
1855
1874
|
declare function createEidLogin(opts: EidLoginOptions): EidLogin;
|
|
1856
1875
|
|
|
1857
|
-
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";
|
|
@@ -1757,7 +1772,7 @@ function rec4(v) {
|
|
|
1757
1772
|
}
|
|
1758
1773
|
function hexSha256Equal(hex, data) {
|
|
1759
1774
|
if (typeof hex !== "string" || !/^[0-9a-fA-F]{64}$/.test(hex)) return false;
|
|
1760
|
-
return
|
|
1775
|
+
return timingSafeEqual2(createHash3("sha256").update(data).digest(), Buffer.from(hex, "hex"));
|
|
1761
1776
|
}
|
|
1762
1777
|
var TOKEN_CONFLICT_CODES = ["TOKEN_LIMIT_REACHED", "TOKEN_IN_USE", "TOKEN_SCOPE_CHANGE", "ACCOUNT_DELETE_PENDING"];
|
|
1763
1778
|
var TOKEN_ISSUANCE_PENDING = "TOKEN_ISSUANCE_PENDING";
|
|
@@ -2687,7 +2702,13 @@ function deviceLinkInput(s, deviceLinkType, lang) {
|
|
|
2687
2702
|
};
|
|
2688
2703
|
}
|
|
2689
2704
|
if (s.sessionType === "cert") {
|
|
2690
|
-
return {
|
|
2705
|
+
return {
|
|
2706
|
+
...base,
|
|
2707
|
+
sessionType: "cert",
|
|
2708
|
+
relyingPartyName: s.relyingPartyName ?? "",
|
|
2709
|
+
interactions: "",
|
|
2710
|
+
initialCallbackUrl: s.initialCallbackUrl ?? ""
|
|
2711
|
+
};
|
|
2691
2712
|
}
|
|
2692
2713
|
return {
|
|
2693
2714
|
...base,
|
|
@@ -2708,7 +2729,7 @@ function qrDeviceLinkTicker(input, onLink, opts) {
|
|
|
2708
2729
|
}
|
|
2709
2730
|
|
|
2710
2731
|
// src/login.ts
|
|
2711
|
-
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";
|
|
2712
2733
|
var MEMORY_LOGIN_STORE_MAX = 1e4;
|
|
2713
2734
|
var LoginStoreFullError = class extends Error {
|
|
2714
2735
|
constructor() {
|
|
@@ -2851,7 +2872,7 @@ var sha256hex = (s) => createHash6("sha256").update(s).digest("hex");
|
|
|
2851
2872
|
function safeEqualHex(a, b) {
|
|
2852
2873
|
const x = Buffer.from(a, "hex");
|
|
2853
2874
|
const y = Buffer.from(b, "hex");
|
|
2854
|
-
return x.length === y.length && x.length > 0 &&
|
|
2875
|
+
return x.length === y.length && x.length > 0 && timingSafeEqual3(x, y);
|
|
2855
2876
|
}
|
|
2856
2877
|
function sleep(ms2, signal) {
|
|
2857
2878
|
return new Promise((resolve) => {
|
|
@@ -3375,6 +3396,7 @@ export {
|
|
|
3375
3396
|
registrationFromCompleted,
|
|
3376
3397
|
resolveBaseUrl,
|
|
3377
3398
|
sessionExpiry,
|
|
3399
|
+
sessionSecretDigest,
|
|
3378
3400
|
sha256Base64,
|
|
3379
3401
|
startExpiry,
|
|
3380
3402
|
tokenAuthDigest,
|
|
@@ -3383,6 +3405,7 @@ export {
|
|
|
3383
3405
|
verifyPayloadSignature,
|
|
3384
3406
|
verifyPrehashedSignature,
|
|
3385
3407
|
verifyQrPresentation,
|
|
3408
|
+
verifySessionSecretDigest,
|
|
3386
3409
|
verifyTokenCertificates,
|
|
3387
3410
|
withReturnHint
|
|
3388
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",
|