@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 in the format `YYMMDD` to a complete
3
- * `YYYYMMDD` date format, taking into account the current century.
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
- * **Note:** This method is limited to interpreting dates based on the current year.
6
- * It may not handle dates correctly for years beyond the range determined by the
7
- * current century (e.g., for dates after 2050 when the current year is in the 21st century).
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: 2024
16
- * convertMRTDDate("240101"); // Returns "20240101"
17
- * convertMRTDDate("991231"); // Returns "19991231"
18
- * convertMRTDDate("abcd12"); // Returns "abcd12" (invalid input)
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;
@@ -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 in the format `YYMMDD` to a complete
7
- * `YYYYMMDD` date format, taking into account the current century.
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
- * **Note:** This method is limited to interpreting dates based on the current year.
10
- * It may not handle dates correctly for years beyond the range determined by the
11
- * current century (e.g., for dates after 2050 when the current year is in the 21st century).
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: 2024
20
- * convertMRTDDate("240101"); // Returns "20240101"
21
- * convertMRTDDate("991231"); // Returns "19991231"
22
- * convertMRTDDate("abcd12"); // Returns "abcd12" (invalid input)
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 currentCentury = Math.floor(currentYear / 100);
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
- if (year <= currentYear % 100) {
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
- if (year <= currentYear % 100) {
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}${month}${day}`;
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":";;;AAmBA,4CA4BC;AA/CD;;;;;;;;;;;;;;;;;;GAkBG;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,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC,CAAA;IACpD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAE5B,IAAI,QAAgB,CAAA;IAEpB,IAAI,gBAAgB,EAAE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ACd,CAAC,CAAA;AAPY,QAAA,UAAU,cAOtB"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@verana-labs/vs-agent-model",
3
3
  "main": "build/index",
4
4
  "types": "build/index",
5
- "version": "1.8.2-dev.1",
5
+ "version": "1.8.2-dev.3",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/verana-labs/vs-agent"