@remit/backend 0.0.97 → 0.0.98

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/backend",
3
- "version": "0.0.97",
3
+ "version": "0.0.98",
4
4
  "description": "Remit Mail Inspector API backend",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -15,6 +15,7 @@ import {
15
15
  deleteCalendarObject,
16
16
  listBusySpans,
17
17
  listCalendarInstances,
18
+ OFFSET_BEARING,
18
19
  parseCalendar,
19
20
  projectCalendar,
20
21
  putCalendarObject,
@@ -90,7 +91,12 @@ export const readWindow = (
90
91
  }
91
92
  const fromMs = Date.parse(from);
92
93
  const toMs = Date.parse(to);
93
- if (Number.isNaN(fromMs) || Number.isNaN(toMs)) {
94
+ if (
95
+ Number.isNaN(fromMs) ||
96
+ Number.isNaN(toMs) ||
97
+ !OFFSET_BEARING.test(from) ||
98
+ !OFFSET_BEARING.test(to)
99
+ ) {
94
100
  return refuseCalendar(
95
101
  "InvalidWindow",
96
102
  "`from` and `to` must be ISO 8601 date-times with a zone offset",
@@ -308,6 +308,27 @@ describe("readWindow", () => {
308
308
  );
309
309
  });
310
310
 
311
+ it("refuses an end that carries no zone offset", () => {
312
+ const wallTime = readWindow("2026-01-01T00:00:00", "2026-01-08T00:00:00Z");
313
+ assert.ok(!wallTime.ok);
314
+ assert.equal(wallTime.error.code, "InvalidWindow");
315
+
316
+ const dateOnly = readWindow("2026-01-01T00:00:00Z", "2026-01-08");
317
+ assert.ok(!dateOnly.ok);
318
+ assert.equal(dateOnly.error.code, "InvalidWindow");
319
+ });
320
+
321
+ it("accepts either spelling of an offset", () => {
322
+ assert.equal(
323
+ readWindow("2026-01-01T00:00:00Z", "2026-01-08T00:00:00Z").ok,
324
+ true,
325
+ );
326
+ assert.equal(
327
+ readWindow("2026-01-01T00:00:00+02:00", "2026-01-08T00:00:00+02:00").ok,
328
+ true,
329
+ );
330
+ });
331
+
311
332
  it("normalises both ends to UTC instants", () => {
312
333
  const window = readWindow(
313
334
  "2026-09-07T02:00:00+02:00",