matrix-nodejs-homeserver 0.2.0 → 0.3.2

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.
Files changed (99) hide show
  1. package/README.md +89 -11
  2. package/dist/adapters/cluster.d.ts +1 -26
  3. package/dist/adapters/cluster.js +50 -103
  4. package/dist/api/account.js +407 -354
  5. package/dist/api/admin.js +82 -61
  6. package/dist/api/appservice.js +37 -25
  7. package/dist/api/backup.js +73 -62
  8. package/dist/api/federation.js +172 -138
  9. package/dist/api/filters.js +4 -3
  10. package/dist/api/legacy.js +91 -78
  11. package/dist/api/media.js +71 -55
  12. package/dist/api/misc.js +46 -37
  13. package/dist/api/preview.js +37 -73
  14. package/dist/api/profile.js +108 -97
  15. package/dist/api/push.js +114 -99
  16. package/dist/api/relationships.js +64 -58
  17. package/dist/api/rooms.js +703 -580
  18. package/dist/api/rtc.d.ts +0 -1
  19. package/dist/api/rtc.js +48 -34
  20. package/dist/api/search.js +133 -127
  21. package/dist/api/slidingsync.js +41 -31
  22. package/dist/api/spaces.js +82 -77
  23. package/dist/api/sync.js +325 -135
  24. package/dist/api/threadsubs.js +72 -61
  25. package/dist/api/threepid.js +99 -66
  26. package/dist/api/uia.js +17 -16
  27. package/dist/api/user.js +221 -178
  28. package/dist/core/admin.d.ts +0 -1
  29. package/dist/core/admin.js +6 -5
  30. package/dist/core/adminroom.js +9 -8
  31. package/dist/core/appservices.d.ts +2 -1
  32. package/dist/core/appservices.js +5 -4
  33. package/dist/core/audit.d.ts +0 -1
  34. package/dist/core/authrules.js +26 -25
  35. package/dist/core/cluster.d.ts +12 -5
  36. package/dist/core/cluster.js +46 -29
  37. package/dist/core/delayed.js +2 -1
  38. package/dist/core/events.js +11 -10
  39. package/dist/core/html.js +13 -0
  40. package/dist/core/identity.js +1 -1
  41. package/dist/core/invitefilter.js +2 -1
  42. package/dist/core/json.js +10 -1
  43. package/dist/core/keys.d.ts +10 -1
  44. package/dist/core/keys.js +62 -42
  45. package/dist/core/m.d.ts +209 -0
  46. package/dist/core/m.js +182 -0
  47. package/dist/core/outbound.d.ts +16 -0
  48. package/dist/core/outbound.js +172 -0
  49. package/dist/core/partialstate.js +2 -1
  50. package/dist/core/policy.js +4 -3
  51. package/dist/core/push.d.ts +0 -1
  52. package/dist/core/push.js +41 -28
  53. package/dist/core/pushrules.js +36 -35
  54. package/dist/core/ratelimit.d.ts +1 -1
  55. package/dist/core/rooms.d.ts +10 -1
  56. package/dist/core/rooms.js +101 -74
  57. package/dist/core/semaphore.js +23 -0
  58. package/dist/core/sso.d.ts +15 -1
  59. package/dist/core/sso.js +38 -2
  60. package/dist/core/stateres.js +7 -6
  61. package/dist/core/threepid.js +1 -9
  62. package/dist/federation/client.js +9 -1
  63. package/dist/federation/index.d.ts +2 -2
  64. package/dist/federation/index.js +43 -35
  65. package/dist/homeserver.d.ts +23 -4
  66. package/dist/homeserver.js +12 -3
  67. package/dist/http/handler.js +2 -23
  68. package/dist/http/input.js +2 -2
  69. package/dist/http/procedure.js +25 -0
  70. package/dist/http/router.d.ts +9 -26
  71. package/dist/http/router.js +10 -30
  72. package/dist/index.d.ts +4 -3
  73. package/dist/index.js +3 -2
  74. package/dist/storage/batch.js +11 -0
  75. package/dist/storage/memory.js +1 -0
  76. package/dist/storage/schema.js +1 -1
  77. package/dist/storage/sql.js +20 -1
  78. package/dist/storage/types.d.ts +16 -0
  79. package/dist/vendor/zod/LICENSE +21 -0
  80. package/dist/vendor/zod/v4/classic/errors.js +54 -0
  81. package/dist/vendor/zod/v4/classic/parse.js +17 -0
  82. package/dist/vendor/zod/v4/classic/schemas.js +865 -0
  83. package/dist/vendor/zod/v4/core/api.js +512 -0
  84. package/dist/vendor/zod/v4/core/checks.js +300 -0
  85. package/dist/vendor/zod/v4/core/core.js +109 -0
  86. package/dist/vendor/zod/v4/core/doc.js +35 -0
  87. package/dist/vendor/zod/v4/core/errors.js +118 -0
  88. package/dist/vendor/zod/v4/core/json-schema-processors.js +428 -0
  89. package/dist/vendor/zod/v4/core/memoizer.js +255 -0
  90. package/dist/vendor/zod/v4/core/parse.js +206 -0
  91. package/dist/vendor/zod/v4/core/regexes.js +73 -0
  92. package/dist/vendor/zod/v4/core/registries.js +48 -0
  93. package/dist/vendor/zod/v4/core/schemas.js +1378 -0
  94. package/dist/vendor/zod/v4/core/to-json-schema.js +448 -0
  95. package/dist/vendor/zod/v4/core/util.js +537 -0
  96. package/dist/vendor/zod/v4/core/versions.js +8 -0
  97. package/dist/vendor/zod/v4/locales/en.js +110 -0
  98. package/package.json +8 -6
  99. package/dist/core/pushrules.d.ts +0 -1
@@ -0,0 +1,537 @@
1
+ import { globalConfig } from "./core.js";
2
+ //#region node_modules/zod/v4/core/util.js
3
+ function getEnumValues(entries) {
4
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
5
+ return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
6
+ }
7
+ function joinValues(array, separator = "|") {
8
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
9
+ }
10
+ function jsonStringifyReplacer(_, value) {
11
+ if (typeof value === "bigint") return value.toString();
12
+ return value;
13
+ }
14
+ var Cached = class {
15
+ constructor(getter) {
16
+ this._getter = getter;
17
+ this._value = void 0;
18
+ }
19
+ get value() {
20
+ const getter = this._getter;
21
+ if (getter !== void 0) {
22
+ this._value = getter();
23
+ this._getter = void 0;
24
+ }
25
+ return this._value;
26
+ }
27
+ };
28
+ function cached(getter) {
29
+ return new Cached(getter);
30
+ }
31
+ function nullish(input) {
32
+ return input === null || input === void 0;
33
+ }
34
+ function cleanRegex(source) {
35
+ const start = source.startsWith("^") ? 1 : 0;
36
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
37
+ return source.slice(start, end);
38
+ }
39
+ function floatSafeRemainder(val, step) {
40
+ const ratio = val / step;
41
+ const roundedRatio = Math.round(ratio);
42
+ const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
43
+ if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
44
+ return ratio - roundedRatio;
45
+ }
46
+ function assignProp(target, prop, value) {
47
+ Object.defineProperty(target, prop, {
48
+ value,
49
+ writable: true,
50
+ enumerable: true,
51
+ configurable: true
52
+ });
53
+ }
54
+ /**
55
+ * Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
56
+ *
57
+ * Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
58
+ */
59
+ function rawShape(def) {
60
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
61
+ return desc?.get ? desc.get.raw : desc?.value;
62
+ }
63
+ function sourceShape(schema) {
64
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
65
+ }
66
+ function deferProp(target, key, getter) {
67
+ Object.defineProperty(target, key, {
68
+ get() {
69
+ const value = getter();
70
+ assignProp(this, key, value);
71
+ return value;
72
+ },
73
+ enumerable: true,
74
+ configurable: true
75
+ });
76
+ }
77
+ function putProp(target, key, value) {
78
+ if (key in target) assignProp(target, key, value);
79
+ else target[key] = value;
80
+ }
81
+ /**
82
+ * Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
83
+ *
84
+ * A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
85
+ */
86
+ function mirrorShape(target, source, keys, wrap) {
87
+ const raw = sourceShape(source);
88
+ for (const key of keys) {
89
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
90
+ if (!desc.enumerable) continue;
91
+ if (desc.get) deferProp(target, key, () => {
92
+ const value = source._zod.def.shape[key];
93
+ return wrap ? wrap(value, key) : value;
94
+ });
95
+ else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
96
+ }
97
+ }
98
+ function mirrorProps(target, source) {
99
+ for (const key of Reflect.ownKeys(source)) {
100
+ const desc = Object.getOwnPropertyDescriptor(source, key);
101
+ if (!desc.enumerable) continue;
102
+ if (desc.get) deferProp(target, key, () => source[key]);
103
+ else putProp(target, key, desc.value);
104
+ }
105
+ }
106
+ function mergeDefs(...defs) {
107
+ const mergedDescriptors = {};
108
+ for (const def of defs) {
109
+ const descriptors = Object.getOwnPropertyDescriptors(def);
110
+ Object.assign(mergedDescriptors, descriptors);
111
+ }
112
+ return Object.defineProperties({}, mergedDescriptors);
113
+ }
114
+ function esc(str) {
115
+ return JSON.stringify(str);
116
+ }
117
+ function slugify(input) {
118
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
119
+ }
120
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
121
+ function isObject(data) {
122
+ return typeof data === "object" && data !== null && !Array.isArray(data);
123
+ }
124
+ const allowsEval = /* @__PURE__*/ cached(() => {
125
+ if (globalConfig.jitless) return false;
126
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
127
+ try {
128
+ new Function("");
129
+ return true;
130
+ } catch (_) {
131
+ return false;
132
+ }
133
+ });
134
+ function isPlainObject(o) {
135
+ if (isObject(o) === false) return false;
136
+ const ctor = o.constructor;
137
+ if (ctor === void 0) return true;
138
+ if (typeof ctor !== "function") return true;
139
+ const prot = ctor.prototype;
140
+ if (isObject(prot) === false) return false;
141
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
142
+ return true;
143
+ }
144
+ function shallowClone(o) {
145
+ if (isPlainObject(o)) return { ...o };
146
+ if (Array.isArray(o)) return [...o];
147
+ if (o instanceof Map) return new Map(o);
148
+ if (o instanceof Set) return new Set(o);
149
+ return o;
150
+ }
151
+ const propertyKeyTypes = /* @__PURE__*/ new Set([
152
+ "string",
153
+ "number",
154
+ "symbol"
155
+ ]);
156
+ function escapeRegex(str) {
157
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
158
+ }
159
+ function clone(inst, def, params) {
160
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
161
+ if (!def || params?.parent) cl._zod.parent = inst;
162
+ return cl;
163
+ }
164
+ function normalizeParams(_params) {
165
+ const params = _params;
166
+ if (!params) return {};
167
+ if (typeof params === "string") return { error: () => params };
168
+ if (params?.message !== void 0) {
169
+ if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
170
+ params.error = params.message;
171
+ }
172
+ delete params.message;
173
+ if (typeof params.error === "string") return {
174
+ ...params,
175
+ error: () => params.error
176
+ };
177
+ return params;
178
+ }
179
+ function stringifyPrimitive(value) {
180
+ if (typeof value === "bigint") return value.toString() + "n";
181
+ if (typeof value === "string") return `"${value}"`;
182
+ return `${value}`;
183
+ }
184
+ function optionalKeys(shape) {
185
+ return Object.keys(shape).filter((k) => {
186
+ return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
187
+ });
188
+ }
189
+ const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
190
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
191
+ int32: [-2147483648, 2147483647],
192
+ uint32: [0, 4294967295],
193
+ float32: [-34028234663852886e22, 34028234663852886e22],
194
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
195
+ }))();
196
+ const BIGINT_FORMAT_RANGES = {
197
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
198
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
199
+ };
200
+ function pick(schema, mask) {
201
+ const currDef = schema._zod.def;
202
+ const checks = currDef.checks;
203
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
204
+ const newShape = {};
205
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
206
+ return clone(schema, mergeDefs(currDef, {
207
+ shape: newShape,
208
+ checks: []
209
+ }));
210
+ }
211
+ function maskedKeys(schema, mask) {
212
+ const raw = sourceShape(schema);
213
+ const keys = [];
214
+ for (const key of Reflect.ownKeys(mask)) {
215
+ if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
216
+ if (mask[key]) keys.push(key);
217
+ }
218
+ return keys;
219
+ }
220
+ function omit(schema, mask) {
221
+ const currDef = schema._zod.def;
222
+ const checks = currDef.checks;
223
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
224
+ const omitted = new Set(maskedKeys(schema, mask));
225
+ const newShape = {};
226
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
227
+ return clone(schema, mergeDefs(currDef, {
228
+ shape: newShape,
229
+ checks: []
230
+ }));
231
+ }
232
+ function extend(schema, shape) {
233
+ if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
234
+ const checks = schema._zod.def.checks;
235
+ if (checks && checks.length > 0) {
236
+ const existingShape = sourceShape(schema);
237
+ for (const key of Reflect.ownKeys(shape)) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
238
+ }
239
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
240
+ }
241
+ function extended(schema, shape) {
242
+ const newShape = {};
243
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
244
+ mirrorProps(newShape, shape);
245
+ return newShape;
246
+ }
247
+ function safeExtend(schema, shape) {
248
+ if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
249
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
250
+ }
251
+ function merge(a, b) {
252
+ if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
253
+ if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
254
+ const newShape = {};
255
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
256
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
257
+ return clone(a, mergeDefs(a._zod.def, {
258
+ shape: newShape,
259
+ get catchall() {
260
+ return b._zod.def.catchall;
261
+ },
262
+ checks: b._zod.def.checks ?? []
263
+ }));
264
+ }
265
+ function partial(Class, schema, mask, name = "partial") {
266
+ const checks = schema._zod.def.checks;
267
+ if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
268
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
269
+ const newShape = {};
270
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
271
+ type: "optional",
272
+ innerType: value
273
+ })));
274
+ return clone(schema, mergeDefs(schema._zod.def, {
275
+ shape: newShape,
276
+ checks: []
277
+ }));
278
+ }
279
+ function required(Class, schema, mask) {
280
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
281
+ const newShape = {};
282
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
283
+ type: "nonoptional",
284
+ innerType: value
285
+ }));
286
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
287
+ }
288
+ function aborted(x, startIndex = 0) {
289
+ if (x.aborted === true) return true;
290
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
291
+ return false;
292
+ }
293
+ function explicitlyAborted(x, startIndex = 0) {
294
+ if (x.aborted === true) return true;
295
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
296
+ return false;
297
+ }
298
+ function prefixIssues(path, issues) {
299
+ return issues.map((iss) => {
300
+ var _a;
301
+ (_a = iss).path ?? (_a.path = []);
302
+ iss.path.unshift(path);
303
+ return iss;
304
+ });
305
+ }
306
+ function unwrapMessage(message) {
307
+ return typeof message === "string" ? message : message?.message;
308
+ }
309
+ /** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
310
+ function sizeCaps(defChecks) {
311
+ const caps = [];
312
+ for (const ch of defChecks ?? []) {
313
+ const d = ch._zod.def;
314
+ if (!/_(length|size)$|_equals$/.test(d.check)) break;
315
+ const max = d.maximum ?? d.length ?? d.size;
316
+ if (max >= 0) caps.push([max, ch]);
317
+ }
318
+ return caps;
319
+ }
320
+ function attachSchema(issues, start, inst) {
321
+ var _a;
322
+ for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
323
+ }
324
+ function finalizeIssue(iss, ctx, config) {
325
+ var _a;
326
+ const traits = iss.inst?._zod?.traits;
327
+ if (traits?.has("$ZodType")) {
328
+ if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
329
+ else iss.schema = iss.inst;
330
+ }
331
+ const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
332
+ const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
333
+ const full = {};
334
+ for (const k of Object.keys(iss)) {
335
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
336
+ full[k] = iss[k];
337
+ }
338
+ full.path ?? (full.path = []);
339
+ full.message = message;
340
+ if (ctx?.reportInput) full.input = iss.input;
341
+ return full;
342
+ }
343
+ const highSurrogate = /[\uD800-\uDBFF]/;
344
+ function codePointLength(str) {
345
+ const units = str.length;
346
+ if (!highSurrogate.test(str)) return units;
347
+ let count = units;
348
+ for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
349
+ count--;
350
+ i++;
351
+ }
352
+ return count;
353
+ }
354
+ function getLengthableOrigin(input) {
355
+ if (Array.isArray(input)) return "array";
356
+ if (typeof input === "string") return "string";
357
+ return "unknown";
358
+ }
359
+ function parsedType(data) {
360
+ const t = typeof data;
361
+ switch (t) {
362
+ case "number": return Number.isNaN(data) ? "nan" : "number";
363
+ case "object": {
364
+ if (data === null) return "null";
365
+ if (Array.isArray(data)) return "array";
366
+ const obj = data;
367
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
368
+ }
369
+ }
370
+ return t;
371
+ }
372
+ function issue(...args) {
373
+ const [iss, input, inst] = args;
374
+ if (typeof iss === "string") return {
375
+ message: iss,
376
+ code: "custom",
377
+ input,
378
+ inst
379
+ };
380
+ return { ...iss };
381
+ }
382
+ /**
383
+ * Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.
384
+ *
385
+ * Call this from a `proto` initializer, which runs once per prototype — never per instance.
386
+ */
387
+ function members(proto, table) {
388
+ for (const key in table) {
389
+ const desc = Object.getOwnPropertyDescriptor(table, key);
390
+ if (desc.get) Object.defineProperty(proto, key, {
391
+ ...desc,
392
+ enumerable: false
393
+ });
394
+ else defineBound(proto, key, desc.value);
395
+ }
396
+ }
397
+ /** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
398
+ function own(inst, key, value, enumerable = true) {
399
+ Object.defineProperty(inst, key, {
400
+ configurable: true,
401
+ writable: true,
402
+ enumerable,
403
+ value
404
+ });
405
+ return value;
406
+ }
407
+ /** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
408
+ function hide(inst, key, value) {
409
+ return own(inst, key, value, false);
410
+ }
411
+ /** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
412
+ /* @__NO_SIDE_EFFECTS__ */
413
+ function derived(computes, table) {
414
+ for (const key in computes) {
415
+ const compute = computes[key];
416
+ Object.defineProperty(table, key, {
417
+ configurable: true,
418
+ enumerable: true,
419
+ get() {
420
+ return own(this, key, compute(this));
421
+ },
422
+ set(value) {
423
+ own(this, key, value);
424
+ }
425
+ });
426
+ }
427
+ return table;
428
+ }
429
+ function defineBound(proto, key, fn) {
430
+ Object.defineProperty(proto, key, {
431
+ configurable: true,
432
+ get() {
433
+ return this == null ? fn : own(this, key, fn.bind(this));
434
+ },
435
+ set(value) {
436
+ own(this, key, value);
437
+ }
438
+ });
439
+ }
440
+ /** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
441
+ function claim(inst, sentinel) {
442
+ const proto = Object.getPrototypeOf(inst);
443
+ return sentinel in proto ? void 0 : proto;
444
+ }
445
+ let installing;
446
+ let broke = false;
447
+ const breaker = {
448
+ configurable: true,
449
+ get() {
450
+ broke = true;
451
+ }
452
+ };
453
+ /**
454
+ * Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
455
+ * constructor, computed from the internals object itself and cached there on
456
+ * first read. One accessor per constructor rather than one per instance.
457
+ */
458
+ function defineLazyInternal(inst, key, compute) {
459
+ const proto = Object.getPrototypeOf(inst._zod);
460
+ if (key in proto && installing !== inst._zod) {
461
+ installing = void 0;
462
+ return;
463
+ }
464
+ installing = inst._zod;
465
+ Object.defineProperty(proto, key, {
466
+ configurable: true,
467
+ get() {
468
+ Object.defineProperty(this, key, breaker);
469
+ const outer = broke;
470
+ broke = false;
471
+ try {
472
+ const value = compute(this);
473
+ if (broke) delete this[key];
474
+ else Object.defineProperty(this, key, {
475
+ configurable: true,
476
+ writable: true,
477
+ value
478
+ });
479
+ broke = broke || outer;
480
+ return value;
481
+ } catch (err) {
482
+ delete this[key];
483
+ broke = broke || outer;
484
+ throw err;
485
+ }
486
+ },
487
+ set(value) {
488
+ Object.defineProperty(this, key, {
489
+ configurable: true,
490
+ writable: true,
491
+ value
492
+ });
493
+ }
494
+ });
495
+ }
496
+ /**
497
+ * Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
498
+ * data property. One accessor per constructor rather than one per instance, because an own accessor
499
+ * puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
500
+ */
501
+ function installLazyProp(inst, key, make, enumerable) {
502
+ const proto = claim(inst, key);
503
+ if (!proto) return;
504
+ Object.defineProperty(proto, key, {
505
+ configurable: true,
506
+ get() {
507
+ const desc = {
508
+ configurable: true,
509
+ writable: true,
510
+ enumerable,
511
+ value: void 0
512
+ };
513
+ Object.defineProperty(this, key, desc);
514
+ desc.value = make(this);
515
+ Object.defineProperty(this, key, desc);
516
+ return desc.value;
517
+ },
518
+ set(value) {
519
+ Object.defineProperty(this, key, {
520
+ configurable: true,
521
+ writable: true,
522
+ enumerable,
523
+ value
524
+ });
525
+ }
526
+ });
527
+ }
528
+ /** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */
529
+ const CONSTANT_CATCH = "~constantCatch";
530
+ /** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
531
+ function constantCatch(value) {
532
+ const fn = () => value;
533
+ fn[CONSTANT_CATCH] = true;
534
+ return fn;
535
+ }
536
+ //#endregion
537
+ export { BIGINT_FORMAT_RANGES, CONSTANT_CATCH, NUMBER_FORMAT_RANGES, aborted, allowsEval, assignProp, attachSchema, cached, captureStackTrace, cleanRegex, clone, codePointLength, constantCatch, defineLazyInternal, derived, esc, escapeRegex, explicitlyAborted, extend, finalizeIssue, floatSafeRemainder, getEnumValues, getLengthableOrigin, hide, installLazyProp, isObject, isPlainObject, issue, joinValues, jsonStringifyReplacer, members, merge, mergeDefs, normalizeParams, nullish, omit, optionalKeys, own, parsedType, partial, pick, prefixIssues, propertyKeyTypes, rawShape, required, safeExtend, shallowClone, sizeCaps, slugify, stringifyPrimitive, unwrapMessage };
@@ -0,0 +1,8 @@
1
+ //#region node_modules/zod/v4/core/versions.js
2
+ const version = {
3
+ major: 4,
4
+ minor: 6,
5
+ patch: 7
6
+ };
7
+ //#endregion
8
+ export { version };
@@ -0,0 +1,110 @@
1
+ import { joinValues, parsedType, stringifyPrimitive } from "../core/util.js";
2
+ //#region node_modules/zod/v4/locales/en.js
3
+ const error = () => {
4
+ const Sizable = {
5
+ string: {
6
+ unit: "characters",
7
+ verb: "to have"
8
+ },
9
+ file: {
10
+ unit: "bytes",
11
+ verb: "to have"
12
+ },
13
+ array: {
14
+ unit: "items",
15
+ verb: "to have"
16
+ },
17
+ set: {
18
+ unit: "items",
19
+ verb: "to have"
20
+ },
21
+ map: {
22
+ unit: "entries",
23
+ verb: "to have"
24
+ }
25
+ };
26
+ function getSizing(origin) {
27
+ return Sizable[origin] ?? null;
28
+ }
29
+ const FormatDictionary = {
30
+ regex: "input",
31
+ email: "email address",
32
+ url: "URL",
33
+ emoji: "emoji",
34
+ uuid: "UUID",
35
+ uuidv4: "UUIDv4",
36
+ uuidv6: "UUIDv6",
37
+ nanoid: "nanoid",
38
+ guid: "GUID",
39
+ cuid: "cuid",
40
+ cuid2: "cuid2",
41
+ ulid: "ULID",
42
+ xid: "XID",
43
+ ksuid: "KSUID",
44
+ datetime: "ISO datetime",
45
+ date: "ISO date",
46
+ time: "ISO time",
47
+ duration: "ISO duration",
48
+ ipv4: "IPv4 address",
49
+ ipv6: "IPv6 address",
50
+ mac: "MAC address",
51
+ cidrv4: "IPv4 range",
52
+ cidrv6: "IPv6 range",
53
+ base64: "base64-encoded string",
54
+ base64url: "base64url-encoded string",
55
+ json_string: "JSON string",
56
+ e164: "E.164 number",
57
+ currency_code: "currency code",
58
+ credit_card: "credit card number",
59
+ iban: "IBAN",
60
+ jwt: "JWT",
61
+ template_literal: "input"
62
+ };
63
+ const TypeDictionary = { nan: "NaN" };
64
+ function getTypeName(type, input) {
65
+ if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
66
+ return TypeDictionary[type] ?? type;
67
+ }
68
+ return (issue) => {
69
+ switch (issue.code) {
70
+ case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
71
+ case "invalid_value":
72
+ if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
73
+ return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
74
+ case "too_big": {
75
+ const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
76
+ const sizing = getSizing(issue.origin);
77
+ if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
78
+ return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
79
+ }
80
+ case "too_small": {
81
+ const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
82
+ const sizing = getSizing(issue.origin);
83
+ if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
84
+ return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
85
+ }
86
+ case "invalid_format": {
87
+ const _issue = issue;
88
+ if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
89
+ if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
90
+ if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
91
+ if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
92
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
93
+ }
94
+ case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
95
+ case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
96
+ case "invalid_key": return `Invalid key in ${issue.origin}`;
97
+ case "invalid_union":
98
+ if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
99
+ if (issue.inclusive === false) return "Invalid input: more than one option matched";
100
+ return "Invalid input";
101
+ case "invalid_element": return `Invalid value in ${issue.origin}`;
102
+ default: return `Invalid input`;
103
+ }
104
+ };
105
+ };
106
+ function en_default() {
107
+ return { localeError: error() };
108
+ }
109
+ //#endregion
110
+ export { en_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matrix-nodejs-homeserver",
3
- "version": "0.2.0",
3
+ "version": "0.3.2",
4
4
  "description": "A framework- and database-agnostic Matrix homeserver library for Node.js",
5
5
  "keywords": [
6
6
  "chat",
@@ -41,10 +41,12 @@
41
41
  },
42
42
  "scripts": {
43
43
  "typecheck": "tsc -p tsconfig.json",
44
+ "test": "node --test \"test/**/*.test.ts\"",
44
45
  "lint": "oxlint",
45
46
  "format": "oxfmt .",
46
47
  "format:check": "oxfmt --check .",
47
48
  "build": "tsdown",
49
+ "check:package": "publint && attw --pack . --profile esm-only",
48
50
  "prepare": "npm run build",
49
51
  "start:example": "node examples/node-http.ts",
50
52
  "start:multi-node-example": "node examples/multi-node.ts",
@@ -52,18 +54,18 @@
52
54
  "version-packages": "changeset version && oxfmt package.json",
53
55
  "release": "changeset publish"
54
56
  },
55
- "dependencies": {
56
- "zod": "^4.6.7"
57
- },
58
57
  "devDependencies": {
58
+ "@arethetypeswrong/cli": "^0.18.5",
59
59
  "@changesets/cli": "^3.0.3",
60
60
  "@types/node": "^26.6.5",
61
61
  "oxfmt": "^0.73.0",
62
62
  "oxlint": "^1.88.0",
63
+ "publint": "^0.3.25",
63
64
  "tsdown": "^0.23.1",
64
- "typescript": "7.0.2"
65
+ "typescript": "7.0.2",
66
+ "zod": "^4.6.7"
65
67
  },
66
68
  "engines": {
67
- "node": ">=26"
69
+ "node": ">=22"
68
70
  }
69
71
  }
@@ -1 +0,0 @@
1
- import "../homeserver.js";