homebridge 2.0.0-beta.30 → 2.0.0-beta.32

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 (88) hide show
  1. package/dist/api.d.ts +267 -3
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +92 -0
  4. package/dist/api.js.map +1 -1
  5. package/dist/bridgeService.d.ts +4 -2
  6. package/dist/bridgeService.d.ts.map +1 -1
  7. package/dist/bridgeService.js +1 -3
  8. package/dist/bridgeService.js.map +1 -1
  9. package/dist/childBridgeFork.d.ts +29 -2
  10. package/dist/childBridgeFork.d.ts.map +1 -1
  11. package/dist/childBridgeFork.js +294 -4
  12. package/dist/childBridgeFork.js.map +1 -1
  13. package/dist/childBridgeService.d.ts +19 -0
  14. package/dist/childBridgeService.d.ts.map +1 -1
  15. package/dist/childBridgeService.js +38 -3
  16. package/dist/childBridgeService.js.map +1 -1
  17. package/dist/externalPortService.d.ts +27 -6
  18. package/dist/externalPortService.d.ts.map +1 -1
  19. package/dist/externalPortService.js +73 -7
  20. package/dist/externalPortService.js.map +1 -1
  21. package/dist/index.d.ts +47 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +15 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/ipcService.d.ts +20 -0
  26. package/dist/ipcService.d.ts.map +1 -1
  27. package/dist/ipcService.js.map +1 -1
  28. package/dist/logger.d.ts +6 -0
  29. package/dist/logger.d.ts.map +1 -1
  30. package/dist/logger.js +8 -0
  31. package/dist/logger.js.map +1 -1
  32. package/dist/matter/index.d.ts +123 -0
  33. package/dist/matter/index.d.ts.map +1 -0
  34. package/dist/matter/index.js +19 -0
  35. package/dist/matter/index.js.map +1 -0
  36. package/dist/matter/matterAccessoryCache.d.ts +96 -0
  37. package/dist/matter/matterAccessoryCache.d.ts.map +1 -0
  38. package/dist/matter/matterAccessoryCache.js +192 -0
  39. package/dist/matter/matterAccessoryCache.js.map +1 -0
  40. package/dist/matter/matterBehaviors.d.ts +194 -0
  41. package/dist/matter/matterBehaviors.d.ts.map +1 -0
  42. package/dist/matter/matterBehaviors.js +665 -0
  43. package/dist/matter/matterBehaviors.js.map +1 -0
  44. package/dist/matter/matterConfigValidator.d.ts +81 -0
  45. package/dist/matter/matterConfigValidator.d.ts.map +1 -0
  46. package/dist/matter/matterConfigValidator.js +240 -0
  47. package/dist/matter/matterConfigValidator.js.map +1 -0
  48. package/dist/matter/matterErrorHandler.d.ts +106 -0
  49. package/dist/matter/matterErrorHandler.d.ts.map +1 -0
  50. package/dist/matter/matterErrorHandler.js +495 -0
  51. package/dist/matter/matterErrorHandler.js.map +1 -0
  52. package/dist/matter/matterLogFormatter.d.ts +19 -0
  53. package/dist/matter/matterLogFormatter.d.ts.map +1 -0
  54. package/dist/matter/matterLogFormatter.js +144 -0
  55. package/dist/matter/matterLogFormatter.js.map +1 -0
  56. package/dist/matter/matterNetworkMonitor.d.ts +68 -0
  57. package/dist/matter/matterNetworkMonitor.d.ts.map +1 -0
  58. package/dist/matter/matterNetworkMonitor.js +249 -0
  59. package/dist/matter/matterNetworkMonitor.js.map +1 -0
  60. package/dist/matter/matterServer.d.ts +656 -0
  61. package/dist/matter/matterServer.d.ts.map +1 -0
  62. package/dist/matter/matterServer.js +1692 -0
  63. package/dist/matter/matterServer.js.map +1 -0
  64. package/dist/matter/matterServerHelpers.d.ts +81 -0
  65. package/dist/matter/matterServerHelpers.d.ts.map +1 -0
  66. package/dist/matter/matterServerHelpers.js +323 -0
  67. package/dist/matter/matterServerHelpers.js.map +1 -0
  68. package/dist/matter/matterSharedTypes.d.ts +170 -0
  69. package/dist/matter/matterSharedTypes.d.ts.map +1 -0
  70. package/dist/matter/matterSharedTypes.js +52 -0
  71. package/dist/matter/matterSharedTypes.js.map +1 -0
  72. package/dist/matter/matterStorage.d.ts +128 -0
  73. package/dist/matter/matterStorage.d.ts.map +1 -0
  74. package/dist/matter/matterStorage.js +415 -0
  75. package/dist/matter/matterStorage.js.map +1 -0
  76. package/dist/matter/matterTypes.d.ts +843 -0
  77. package/dist/matter/matterTypes.d.ts.map +1 -0
  78. package/dist/matter/matterTypes.js +222 -0
  79. package/dist/matter/matterTypes.js.map +1 -0
  80. package/dist/server.d.ts +23 -1
  81. package/dist/server.d.ts.map +1 -1
  82. package/dist/server.js +392 -7
  83. package/dist/server.js.map +1 -1
  84. package/dist/user.d.ts +1 -0
  85. package/dist/user.d.ts.map +1 -1
  86. package/dist/user.js +3 -0
  87. package/dist/user.js.map +1 -1
  88. package/package.json +16 -15
@@ -0,0 +1,415 @@
1
+ /* global NodeJS */
2
+ /**
3
+ * Custom Matter.js Storage Implementation for Homebridge
4
+ *
5
+ * Provides persistent storage for Matter fabric data and device configuration.
6
+ * This ensures commissioning data persists across Homebridge restarts.
7
+ */
8
+ import { Buffer } from 'node:buffer';
9
+ import { readFileSync } from 'node:fs';
10
+ import { mkdir, rename, writeFile } from 'node:fs/promises';
11
+ import { dirname, join } from 'node:path';
12
+ import { Logger } from '../logger.js';
13
+ const log = Logger.withPrefix('Matter/Storage');
14
+ // Storage configuration constants
15
+ const STORAGE_WRITE_DEBOUNCE_MS = 100; // Delay for non-critical writes
16
+ /**
17
+ * Custom Matter.js StorageContext implementation for Homebridge
18
+ * Provides persistent storage for fabric data and device configuration
19
+ */
20
+ export class HomebridgeMatterStorage {
21
+ namespace;
22
+ storage = new Map();
23
+ filePath;
24
+ isInitialized = false;
25
+ writeTimer = null;
26
+ pendingWrite = false;
27
+ persistLock = null;
28
+ constructor(namespace, storagePath) {
29
+ this.namespace = namespace;
30
+ this.filePath = join(storagePath, `${namespace}.json`);
31
+ // Synchronously load existing data to avoid race conditions with Matter.js
32
+ // Matter.js expects storage to be immediately available
33
+ this.initializeSync();
34
+ }
35
+ /**
36
+ * Synchronously initialize storage by loading existing data
37
+ * This is called in the constructor to ensure storage is ready immediately
38
+ */
39
+ initializeSync() {
40
+ try {
41
+ const fileContent = readFileSync(this.filePath, 'utf-8');
42
+ // Parse WITHOUT a reviver - we'll deserialize manually
43
+ const data = JSON.parse(fileContent);
44
+ // Ensure data is valid before loading
45
+ if (data && typeof data === 'object') {
46
+ // Deserialize ALL values as we load them into the Map
47
+ const entries = Object.entries(data).map(([key, value]) => [
48
+ key,
49
+ this.deserializeValue(value),
50
+ ]);
51
+ this.storage = new Map(entries);
52
+ log.debug(`Loaded ${this.storage.size} entries for namespace: ${this.namespace}`);
53
+ }
54
+ else {
55
+ log.warn(`Invalid storage data for ${this.namespace}, starting fresh`);
56
+ this.storage = new Map();
57
+ }
58
+ this.isInitialized = true;
59
+ }
60
+ catch (error) {
61
+ if (error.code === 'ENOENT') {
62
+ log.debug(`No existing storage for namespace: ${this.namespace}`);
63
+ }
64
+ else {
65
+ log.warn(`Failed to load storage for ${this.namespace} (${error.message}), starting fresh`);
66
+ }
67
+ // Create fresh storage if file doesn't exist or is corrupted
68
+ this.storage = new Map();
69
+ this.isInitialized = true;
70
+ }
71
+ }
72
+ /**
73
+ * Initialize storage and load existing data (async for compatibility)
74
+ * Note: Storage is now initialized synchronously in constructor
75
+ */
76
+ async initialize() {
77
+ // Storage is already initialized in constructor
78
+ return Promise.resolve();
79
+ }
80
+ /**
81
+ * Build a context key from an array of contexts
82
+ */
83
+ buildContextKey(contexts) {
84
+ return contexts.join('.');
85
+ }
86
+ /**
87
+ * Recursively convert special serialized types back to their original types
88
+ *
89
+ * This is necessary because JSON.parse() doesn't automatically reconstruct:
90
+ * - BigInt values (serialized as {__type: 'bigint', value: string})
91
+ * - Uint8Array values (serialized as {__type: 'Uint8Array', value: number[]})
92
+ * - Buffer values (Node.js format: {type: 'Buffer', data: number[]})
93
+ *
94
+ * Matter.js fabric data contains these types which must be properly restored
95
+ * for commissioning to work across restarts.
96
+ *
97
+ * @param value - The value to deserialize (might be nested object/array)
98
+ * @returns The deserialized value with proper types restored
99
+ */
100
+ deserializeValue(value) {
101
+ if (value && typeof value === 'object') {
102
+ // Handle special type markers
103
+ const obj = value;
104
+ if (obj.__type === 'bigint' && typeof obj.value === 'string') {
105
+ return BigInt(obj.value);
106
+ }
107
+ if (obj.__type === 'Uint8Array' && Array.isArray(obj.value)) {
108
+ return new Uint8Array(obj.value);
109
+ }
110
+ // Handle Node.js Buffer JSON format: {type: "Buffer", data: [...]}
111
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
112
+ return new Uint8Array(obj.data);
113
+ }
114
+ // Recursively process arrays
115
+ if (Array.isArray(value)) {
116
+ return value.map(item => this.deserializeValue(item));
117
+ }
118
+ // Recursively process plain objects
119
+ if (Object.getPrototypeOf(value) === Object.prototype) {
120
+ const result = {};
121
+ for (const [k, v] of Object.entries(value)) {
122
+ result[k] = this.deserializeValue(v);
123
+ }
124
+ return result;
125
+ }
126
+ }
127
+ return value;
128
+ }
129
+ /**
130
+ * Get a value from storage (Matter.js interface)
131
+ * Values are already deserialized during load, so no additional deserialization needed
132
+ */
133
+ get(contexts, key) {
134
+ // Storage is initialized in constructor, so this should always work
135
+ const fullKey = contexts.length ? `${this.buildContextKey(contexts)}.${key}` : key;
136
+ return this.storage.get(fullKey);
137
+ }
138
+ set(contexts, keyOrValues, value) {
139
+ const contextKey = this.buildContextKey(contexts);
140
+ if (typeof keyOrValues === 'string') {
141
+ const fullKey = contextKey ? `${contextKey}.${keyOrValues}` : keyOrValues;
142
+ this.storage.set(fullKey, value);
143
+ }
144
+ else {
145
+ for (const [k, v] of Object.entries(keyOrValues)) {
146
+ const fullKey = contextKey ? `${contextKey}.${k}` : k;
147
+ this.storage.set(fullKey, v);
148
+ }
149
+ }
150
+ // Debounce writes to avoid excessive disk I/O
151
+ void this.schedulePersist();
152
+ }
153
+ /**
154
+ * Delete a key from storage (Matter.js interface)
155
+ */
156
+ delete(contexts, key) {
157
+ const fullKey = contexts.length ? `${this.buildContextKey(contexts)}.${key}` : key;
158
+ const deleted = this.storage.delete(fullKey);
159
+ if (deleted) {
160
+ void this.schedulePersist();
161
+ }
162
+ }
163
+ /**
164
+ * Clear all storage in a context (Matter.js interface)
165
+ */
166
+ clearAll(contexts) {
167
+ const contextKey = this.buildContextKey(contexts);
168
+ const prefix = contextKey ? `${contextKey}.` : '';
169
+ // Collect keys to delete first to avoid modifying during iteration
170
+ const keysToDelete = [];
171
+ for (const key of this.storage.keys()) {
172
+ if (!prefix || key.startsWith(prefix)) {
173
+ keysToDelete.push(key);
174
+ }
175
+ }
176
+ // Delete collected keys
177
+ for (const key of keysToDelete) {
178
+ this.storage.delete(key);
179
+ }
180
+ if (keysToDelete.length > 0) {
181
+ void this.schedulePersist();
182
+ }
183
+ }
184
+ /**
185
+ * Get all keys in a context (Matter.js interface)
186
+ */
187
+ keys(contexts) {
188
+ if (!this.isInitialized) {
189
+ return [];
190
+ }
191
+ const contextKey = this.buildContextKey(contexts);
192
+ const prefix = contextKey ? `${contextKey}.` : '';
193
+ const contextKeys = [];
194
+ for (const key of this.storage.keys()) {
195
+ if (prefix) {
196
+ // Return keys within this context (strip context prefix)
197
+ if (key.startsWith(prefix)) {
198
+ const subKey = key.substring(prefix.length);
199
+ // Only include direct children (no further nesting)
200
+ if (!subKey.includes('.')) {
201
+ contextKeys.push(subKey);
202
+ }
203
+ }
204
+ }
205
+ else {
206
+ // Root level - return keys with no dots
207
+ if (!key.includes('.')) {
208
+ contextKeys.push(key);
209
+ }
210
+ }
211
+ }
212
+ return contextKeys;
213
+ }
214
+ /**
215
+ * Get all child context names (Matter.js interface)
216
+ */
217
+ contexts(contexts) {
218
+ if (!this.isInitialized) {
219
+ return [];
220
+ }
221
+ const contextKey = this.buildContextKey(contexts);
222
+ const prefix = contextKey ? `${contextKey}.` : '';
223
+ const childContexts = new Set();
224
+ for (const key of this.storage.keys()) {
225
+ if (prefix) {
226
+ // Find sub-contexts within this context
227
+ if (key.startsWith(prefix)) {
228
+ const subKey = key.substring(prefix.length);
229
+ const nextDot = subKey.indexOf('.');
230
+ if (nextDot > 0) {
231
+ childContexts.add(subKey.substring(0, nextDot));
232
+ }
233
+ }
234
+ }
235
+ else {
236
+ // Root level - find top-level contexts
237
+ const dotIndex = key.indexOf('.');
238
+ if (dotIndex > 0) {
239
+ childContexts.add(key.substring(0, dotIndex));
240
+ }
241
+ }
242
+ }
243
+ return Array.from(childContexts);
244
+ }
245
+ /**
246
+ * Check if a key exists (Matter.js interface)
247
+ */
248
+ has(contexts, key) {
249
+ if (!this.isInitialized) {
250
+ return false;
251
+ }
252
+ const fullKey = contexts.length ? `${this.buildContextKey(contexts)}.${key}` : key;
253
+ return this.storage.has(fullKey);
254
+ }
255
+ /**
256
+ * Get all values in a context
257
+ * Returns direct children only (does not include nested contexts)
258
+ */
259
+ async values(contexts) {
260
+ await this.initialize();
261
+ const contextKey = this.buildContextKey(contexts);
262
+ const prefix = contextKey ? `${contextKey}.` : '';
263
+ const values = {};
264
+ for (const [key, value] of this.storage.entries()) {
265
+ // Check if key is in the requested context
266
+ if (prefix && !key.startsWith(prefix)) {
267
+ continue;
268
+ }
269
+ const subKey = prefix ? key.substring(prefix.length) : key;
270
+ // Only include direct children (no nested contexts)
271
+ if (!subKey.includes('.')) {
272
+ values[subKey] = value; // values are already deserialized
273
+ }
274
+ }
275
+ return values;
276
+ }
277
+ /**
278
+ * Schedule a persist operation (debounced)
279
+ */
280
+ async schedulePersist() {
281
+ if (this.writeTimer) {
282
+ clearTimeout(this.writeTimer);
283
+ }
284
+ this.pendingWrite = true;
285
+ // Immediate persist for critical data (fabric information)
286
+ const hasCriticalData = Array.from(this.storage.keys()).some(key => key.includes('fabric'));
287
+ if (hasCriticalData) {
288
+ await this.persist();
289
+ }
290
+ else {
291
+ // Debounce non-critical writes
292
+ this.writeTimer = setTimeout(() => {
293
+ void this.persist();
294
+ }, STORAGE_WRITE_DEBOUNCE_MS);
295
+ }
296
+ }
297
+ /**
298
+ * Persist storage to disk with atomic write
299
+ */
300
+ async persist() {
301
+ // Wait for any in-progress persist operation to complete
302
+ if (this.persistLock) {
303
+ await this.persistLock;
304
+ }
305
+ if (!this.pendingWrite) {
306
+ return;
307
+ }
308
+ // Create a new lock for this persist operation
309
+ this.persistLock = (async () => {
310
+ try {
311
+ const data = Object.fromEntries(this.storage.entries());
312
+ const dir = dirname(this.filePath);
313
+ // Ensure directory exists
314
+ await mkdir(dir, { recursive: true });
315
+ // Atomic write: write to temp file then rename
316
+ // Use a unique temp file to avoid conflicts
317
+ const tempFile = `${this.filePath}.tmp.${Date.now()}`;
318
+ // Custom replacer to handle BigInt, Uint8Array, and Buffer serialization
319
+ const jsonString = JSON.stringify(data, (_key, value) => {
320
+ if (typeof value === 'bigint') {
321
+ return { __type: 'bigint', value: value.toString() };
322
+ }
323
+ // Handle Buffer before Uint8Array since Buffer extends Uint8Array
324
+ // Note: Buffer.toJSON() returns {type: 'Buffer', data: [...]}, but we want consistent format
325
+ if (Buffer.isBuffer(value)) {
326
+ return { __type: 'Uint8Array', value: Array.from(value) };
327
+ }
328
+ if (value instanceof Uint8Array) {
329
+ return { __type: 'Uint8Array', value: Array.from(value) };
330
+ }
331
+ return value;
332
+ }, 2);
333
+ await writeFile(tempFile, jsonString, 'utf-8');
334
+ await rename(tempFile, this.filePath);
335
+ this.pendingWrite = false;
336
+ log.debug(`Persisted ${this.storage.size} entries for namespace: ${this.namespace}`);
337
+ }
338
+ catch (error) {
339
+ log.error(`Failed to persist storage for ${this.namespace}:`, error);
340
+ // Don't throw - we don't want to break Matter operations
341
+ }
342
+ finally {
343
+ this.persistLock = null;
344
+ }
345
+ })();
346
+ await this.persistLock;
347
+ }
348
+ /**
349
+ * Force immediate persist (for shutdown)
350
+ */
351
+ async forcePersist() {
352
+ if (this.writeTimer) {
353
+ clearTimeout(this.writeTimer);
354
+ this.writeTimer = null;
355
+ }
356
+ if (this.pendingWrite) {
357
+ await this.persist();
358
+ }
359
+ }
360
+ /**
361
+ * Close and cleanup storage
362
+ */
363
+ async close() {
364
+ await this.forcePersist();
365
+ this.storage.clear();
366
+ this.isInitialized = false;
367
+ }
368
+ /**
369
+ * Get storage statistics
370
+ */
371
+ getStats() {
372
+ return {
373
+ entries: this.storage.size,
374
+ namespace: this.namespace,
375
+ path: this.filePath,
376
+ };
377
+ }
378
+ }
379
+ /**
380
+ * Storage Manager for Matter.js
381
+ * Manages multiple storage contexts for different namespaces
382
+ */
383
+ export class MatterStorageManager {
384
+ storagePath;
385
+ storages = new Map();
386
+ constructor(storagePath) {
387
+ this.storagePath = storagePath;
388
+ }
389
+ /**
390
+ * Get or create a storage context for a namespace
391
+ */
392
+ getStorage(namespace) {
393
+ let storage = this.storages.get(namespace);
394
+ if (!storage) {
395
+ storage = new HomebridgeMatterStorage(namespace, this.storagePath);
396
+ this.storages.set(namespace, storage);
397
+ }
398
+ return storage;
399
+ }
400
+ /**
401
+ * Close all storage contexts
402
+ */
403
+ async closeAll() {
404
+ const promises = Array.from(this.storages.values()).map(storage => storage.close());
405
+ await Promise.all(promises);
406
+ this.storages.clear();
407
+ }
408
+ /**
409
+ * Get statistics for all storage contexts
410
+ */
411
+ getAllStats() {
412
+ return Array.from(this.storages.values()).map(storage => storage.getStats());
413
+ }
414
+ }
415
+ //# sourceMappingURL=matterStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterStorage.js","sourceRoot":"","sources":["../../src/matter/matterStorage.ts"],"names":[],"mappings":"AAAA,mBAAmB;AAEnB;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAA;AAE/C,kCAAkC;AAClC,MAAM,yBAAyB,GAAG,GAAG,CAAA,CAAC,gCAAgC;AAEtE;;;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