@verana-labs/vs-agent-model 1.8.2-dev.1 → 1.8.2-dev.3
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.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Converts a Machine Readable Travel Document (MRTD) date
|
|
3
|
-
*
|
|
2
|
+
* Converts a Machine Readable Travel Document (MRTD) date from `YYMMDD` to `YYYYMMDD`,
|
|
3
|
+
* inferring the century based on the current year and the date type.
|
|
4
4
|
*
|
|
5
|
-
* **
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* - **Expiration dates:** Assumes a maximum of 10 years into the future (passport validity window).
|
|
6
|
+
* Years beyond that threshold are interpreted as the previous century.
|
|
7
|
+
* - **Birth dates:** Never resolved to a future year — if the candidate year exceeds
|
|
8
|
+
* the current year, it falls back to the previous century.
|
|
8
9
|
*
|
|
9
10
|
* @param {string} date - The MRTD date string in the format `YYMMDD`.
|
|
10
11
|
* @param {boolean} isExpirationDate - A boolean flag indicating whether the date is an expiration date.
|
|
@@ -12,10 +13,11 @@
|
|
|
12
13
|
* if the input is not a valid `YYMMDD` date.
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
|
-
* // Current year:
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* // Current year: 2026
|
|
17
|
+
* convertShortDate("350531", true); // "20350531" — within 10-year window
|
|
18
|
+
* convertShortDate("990531", false); // "19990531" — birth date, previous century
|
|
19
|
+
* convertShortDate("abcd12", true); // undefined — invalid format
|
|
20
|
+
* convertShortDate(null, true); // undefined
|
|
19
21
|
*/
|
|
20
22
|
export declare function convertShortDate(date: string | null | undefined, isExpirationDate: boolean): string | undefined;
|
|
21
23
|
export declare const DateParser: (value: unknown) => unknown;
|
package/build/utils/dateUtils.js
CHANGED
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DateParser = void 0;
|
|
4
4
|
exports.convertShortDate = convertShortDate;
|
|
5
5
|
/**
|
|
6
|
-
* Converts a Machine Readable Travel Document (MRTD) date
|
|
7
|
-
*
|
|
6
|
+
* Converts a Machine Readable Travel Document (MRTD) date from `YYMMDD` to `YYYYMMDD`,
|
|
7
|
+
* inferring the century based on the current year and the date type.
|
|
8
8
|
*
|
|
9
|
-
* **
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* - **Expiration dates:** Assumes a maximum of 10 years into the future (passport validity window).
|
|
10
|
+
* Years beyond that threshold are interpreted as the previous century.
|
|
11
|
+
* - **Birth dates:** Never resolved to a future year — if the candidate year exceeds
|
|
12
|
+
* the current year, it falls back to the previous century.
|
|
12
13
|
*
|
|
13
14
|
* @param {string} date - The MRTD date string in the format `YYMMDD`.
|
|
14
15
|
* @param {boolean} isExpirationDate - A boolean flag indicating whether the date is an expiration date.
|
|
@@ -16,40 +17,25 @@ exports.convertShortDate = convertShortDate;
|
|
|
16
17
|
* if the input is not a valid `YYMMDD` date.
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
19
|
-
* // Current year:
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* // Current year: 2026
|
|
21
|
+
* convertShortDate("350531", true); // "20350531" — within 10-year window
|
|
22
|
+
* convertShortDate("990531", false); // "19990531" — birth date, previous century
|
|
23
|
+
* convertShortDate("abcd12", true); // undefined — invalid format
|
|
24
|
+
* convertShortDate(null, true); // undefined
|
|
23
25
|
*/
|
|
24
26
|
function convertShortDate(date, isExpirationDate) {
|
|
25
27
|
if (!date || !/^\d{6}$/.test(date))
|
|
26
28
|
return date !== null && date !== void 0 ? date : undefined;
|
|
27
29
|
const currentYear = new Date().getFullYear();
|
|
28
|
-
const
|
|
29
|
-
const year = parseInt(date.slice(0, 2), 10);
|
|
30
|
-
const month = date.slice(2, 4);
|
|
31
|
-
const day = date.slice(4, 6);
|
|
30
|
+
const year = Math.floor(currentYear / 100) * 100 + parseInt(date.slice(0, 2), 10);
|
|
32
31
|
let fullYear;
|
|
33
32
|
if (isExpirationDate) {
|
|
34
|
-
|
|
35
|
-
fullYear = currentCentury * 100 + year;
|
|
36
|
-
if (fullYear < currentYear) {
|
|
37
|
-
fullYear += 100;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
fullYear = currentCentury * 100 + year;
|
|
42
|
-
}
|
|
33
|
+
fullYear = year > currentYear + 10 ? year - 100 : year;
|
|
43
34
|
}
|
|
44
35
|
else {
|
|
45
|
-
|
|
46
|
-
fullYear = currentCentury * 100 + year;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
fullYear = (currentCentury - 1) * 100 + year;
|
|
50
|
-
}
|
|
36
|
+
fullYear = year > currentYear ? year - 100 : year;
|
|
51
37
|
}
|
|
52
|
-
return `${fullYear}${
|
|
38
|
+
return `${fullYear}${date.slice(2)}`;
|
|
53
39
|
}
|
|
54
40
|
// Local helper: credo-ts/didcomm’s DateParser isn’t a public export; importing from build/* breaks bundlers/resolvers.
|
|
55
41
|
const DateParser = (value) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateUtils.js","sourceRoot":"","sources":["../../src/utils/dateUtils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"dateUtils.js","sourceRoot":"","sources":["../../src/utils/dateUtils.ts"],"names":[],"mappings":";;;AAqBA,4CAcC;AAnCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,gBAAgB,CAAC,IAA+B,EAAE,gBAAyB;IACzF,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,SAAS,CAAA;IAE5D,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,KA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