homebridge 2.0.0-alpha.41 → 2.0.0-alpha.43

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 (91) hide show
  1. package/dist/api.d.ts +81 -20
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +71 -11
  4. package/dist/api.js.map +1 -1
  5. package/dist/bridgeService.d.ts +14 -12
  6. package/dist/bridgeService.d.ts.map +1 -1
  7. package/dist/bridgeService.js +17 -3
  8. package/dist/bridgeService.js.map +1 -1
  9. package/dist/bridgeTypes.d.ts +54 -0
  10. package/dist/bridgeTypes.d.ts.map +1 -0
  11. package/dist/bridgeTypes.js +8 -0
  12. package/dist/bridgeTypes.js.map +1 -0
  13. package/dist/childBridgeFork.d.ts +23 -0
  14. package/dist/childBridgeFork.d.ts.map +1 -1
  15. package/dist/childBridgeFork.js +240 -4
  16. package/dist/childBridgeFork.js.map +1 -1
  17. package/dist/childBridgeService.d.ts +47 -7
  18. package/dist/childBridgeService.d.ts.map +1 -1
  19. package/dist/childBridgeService.js +67 -2
  20. package/dist/childBridgeService.js.map +1 -1
  21. package/dist/cli.d.ts.map +1 -1
  22. package/dist/cli.js +3 -1
  23. package/dist/cli.js.map +1 -1
  24. package/dist/index.d.ts +5 -6
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +4 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/ipcService.d.ts +3 -1
  29. package/dist/ipcService.d.ts.map +1 -1
  30. package/dist/ipcService.js +2 -0
  31. package/dist/ipcService.js.map +1 -1
  32. package/dist/matter/index.d.ts +4 -6
  33. package/dist/matter/index.d.ts.map +1 -1
  34. package/dist/matter/index.js +4 -5
  35. package/dist/matter/index.js.map +1 -1
  36. package/dist/matter/matterConfigValidator.d.ts +2 -3
  37. package/dist/matter/matterConfigValidator.d.ts.map +1 -1
  38. package/dist/matter/matterConfigValidator.js +47 -38
  39. package/dist/matter/matterConfigValidator.js.map +1 -1
  40. package/dist/matter/matterErrorHandler.d.ts +6 -25
  41. package/dist/matter/matterErrorHandler.d.ts.map +1 -1
  42. package/dist/matter/matterErrorHandler.js +89 -99
  43. package/dist/matter/matterErrorHandler.js.map +1 -1
  44. package/dist/matter/matterServer.d.ts +126 -39
  45. package/dist/matter/matterServer.d.ts.map +1 -1
  46. package/dist/matter/matterServer.js +528 -226
  47. package/dist/matter/matterServer.js.map +1 -1
  48. package/dist/matter/matterSharedTypes.d.ts +16 -38
  49. package/dist/matter/matterSharedTypes.d.ts.map +1 -1
  50. package/dist/matter/matterSharedTypes.js +3 -4
  51. package/dist/matter/matterSharedTypes.js.map +1 -1
  52. package/dist/matter/matterStorage.d.ts +116 -0
  53. package/dist/matter/matterStorage.d.ts.map +1 -0
  54. package/dist/matter/matterStorage.js +442 -0
  55. package/dist/matter/matterStorage.js.map +1 -0
  56. package/dist/matter/matterTypes.d.ts +148 -20
  57. package/dist/matter/matterTypes.d.ts.map +1 -1
  58. package/dist/matter/matterTypes.js +91 -263
  59. package/dist/matter/matterTypes.js.map +1 -1
  60. package/dist/plugin.d.ts.map +1 -1
  61. package/dist/plugin.js +4 -2
  62. package/dist/plugin.js.map +1 -1
  63. package/dist/server.d.ts +18 -4
  64. package/dist/server.d.ts.map +1 -1
  65. package/dist/server.js +376 -349
  66. package/dist/server.js.map +1 -1
  67. package/dist/user.d.ts +1 -0
  68. package/dist/user.d.ts.map +1 -1
  69. package/dist/user.js +3 -0
  70. package/dist/user.js.map +1 -1
  71. package/package.json +6 -7
  72. package/dist/childMatterBridgeFork.d.ts +0 -108
  73. package/dist/childMatterBridgeFork.d.ts.map +0 -1
  74. package/dist/childMatterBridgeFork.js +0 -330
  75. package/dist/childMatterBridgeFork.js.map +0 -1
  76. package/dist/childMatterBridgeService.d.ts +0 -166
  77. package/dist/childMatterBridgeService.d.ts.map +0 -1
  78. package/dist/childMatterBridgeService.js +0 -623
  79. package/dist/childMatterBridgeService.js.map +0 -1
  80. package/dist/matter/matterBridge.d.ts +0 -64
  81. package/dist/matter/matterBridge.d.ts.map +0 -1
  82. package/dist/matter/matterBridge.js +0 -154
  83. package/dist/matter/matterBridge.js.map +0 -1
  84. package/dist/matter/matterDevice.d.ts +0 -107
  85. package/dist/matter/matterDevice.d.ts.map +0 -1
  86. package/dist/matter/matterDevice.js +0 -913
  87. package/dist/matter/matterDevice.js.map +0 -1
  88. package/dist/matter/portAllocator.d.ts +0 -85
  89. package/dist/matter/portAllocator.d.ts.map +0 -1
  90. package/dist/matter/portAllocator.js +0 -296
  91. package/dist/matter/portAllocator.js.map +0 -1
@@ -0,0 +1,442 @@
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 * as fs from 'node:fs';
10
+ import * as fsp from 'node:fs/promises';
11
+ import * as path 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 = path.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 = fs.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
+ * This handles cases where objects weren't fully deserialized by the JSON reviver
89
+ */
90
+ deserializeValue(value) {
91
+ if (value && typeof value === 'object') {
92
+ // Handle special type markers
93
+ const obj = value;
94
+ if (obj.__type === 'bigint' && typeof obj.value === 'string') {
95
+ return BigInt(obj.value);
96
+ }
97
+ if (obj.__type === 'Uint8Array' && Array.isArray(obj.value)) {
98
+ return new Uint8Array(obj.value);
99
+ }
100
+ // Handle Node.js Buffer JSON format: {type: "Buffer", data: [...]}
101
+ if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
102
+ return new Uint8Array(obj.data);
103
+ }
104
+ // Recursively process arrays
105
+ if (Array.isArray(value)) {
106
+ return value.map(item => this.deserializeValue(item));
107
+ }
108
+ // Recursively process plain objects
109
+ if (Object.getPrototypeOf(value) === Object.prototype) {
110
+ const result = {};
111
+ for (const [k, v] of Object.entries(value)) {
112
+ result[k] = this.deserializeValue(v);
113
+ }
114
+ return result;
115
+ }
116
+ }
117
+ return value;
118
+ }
119
+ /**
120
+ * Get a value from storage (Matter.js interface)
121
+ */
122
+ get(contexts, key) {
123
+ // Storage is initialized in constructor, so this should always work
124
+ const fullKey = contexts.length ? `${this.buildContextKey(contexts)}.${key}` : key;
125
+ const value = this.storage.get(fullKey);
126
+ // Debug logging for fabric data
127
+ if (fullKey.includes('fabric')) {
128
+ log.info(`[STORAGE GET] ${fullKey}`);
129
+ log.info(` Before deserialize: type=${typeof value}, constructor=${value?.constructor?.name}, isUint8Array=${value instanceof Uint8Array}`);
130
+ if (value && typeof value === 'object' && !(value instanceof Uint8Array)) {
131
+ const obj = value;
132
+ if (obj.__type) {
133
+ log.info(` Has __type: ${obj.__type}`);
134
+ }
135
+ // Check for nested Uint8Arrays
136
+ for (const key of Object.keys(obj).slice(0, 5)) {
137
+ const val = obj[key];
138
+ if (val && typeof val === 'object') {
139
+ log.info(` ${key}: type=${typeof val}, constructor=${val?.constructor?.name}, __type=${val.__type}, isUint8Array=${val instanceof Uint8Array}`);
140
+ }
141
+ }
142
+ }
143
+ }
144
+ // Ensure value is fully deserialized (handles nested special types)
145
+ const result = this.deserializeValue(value);
146
+ // Debug logging after deserialization
147
+ if (fullKey.includes('fabric')) {
148
+ log.info(` After deserialize: type=${typeof result}, constructor=${result?.constructor?.name}, isUint8Array=${result instanceof Uint8Array}`);
149
+ if (result && typeof result === 'object' && !(result instanceof Uint8Array)) {
150
+ const obj = result;
151
+ // Check for nested Uint8Arrays
152
+ for (const key of Object.keys(obj).slice(0, 5)) {
153
+ const val = obj[key];
154
+ if (val && typeof val === 'object') {
155
+ log.info(` ${key}: isUint8Array=${val instanceof Uint8Array}`);
156
+ }
157
+ }
158
+ }
159
+ }
160
+ return result;
161
+ }
162
+ set(contexts, keyOrValues, value) {
163
+ const contextKey = this.buildContextKey(contexts);
164
+ if (typeof keyOrValues === 'string') {
165
+ const fullKey = contextKey ? `${contextKey}.${keyOrValues}` : keyOrValues;
166
+ this.storage.set(fullKey, value);
167
+ }
168
+ else {
169
+ for (const [k, v] of Object.entries(keyOrValues)) {
170
+ const fullKey = contextKey ? `${contextKey}.${k}` : k;
171
+ this.storage.set(fullKey, v);
172
+ }
173
+ }
174
+ // Debounce writes to avoid excessive disk I/O
175
+ void this.schedulePersist();
176
+ }
177
+ /**
178
+ * Delete a key from storage (Matter.js interface)
179
+ */
180
+ delete(contexts, key) {
181
+ const fullKey = contexts.length ? `${this.buildContextKey(contexts)}.${key}` : key;
182
+ const deleted = this.storage.delete(fullKey);
183
+ if (deleted) {
184
+ void this.schedulePersist();
185
+ }
186
+ }
187
+ /**
188
+ * Clear all storage in a context (Matter.js interface)
189
+ */
190
+ clearAll(contexts) {
191
+ const contextKey = this.buildContextKey(contexts);
192
+ const prefix = contextKey ? `${contextKey}.` : '';
193
+ // Collect keys to delete first to avoid modifying during iteration
194
+ const keysToDelete = [];
195
+ for (const key of this.storage.keys()) {
196
+ if (!prefix || key.startsWith(prefix)) {
197
+ keysToDelete.push(key);
198
+ }
199
+ }
200
+ // Delete collected keys
201
+ for (const key of keysToDelete) {
202
+ this.storage.delete(key);
203
+ }
204
+ if (keysToDelete.length > 0) {
205
+ void this.schedulePersist();
206
+ }
207
+ }
208
+ /**
209
+ * Get all keys in a context (Matter.js interface)
210
+ */
211
+ keys(contexts) {
212
+ if (!this.isInitialized) {
213
+ return [];
214
+ }
215
+ const contextKey = this.buildContextKey(contexts);
216
+ const prefix = contextKey ? `${contextKey}.` : '';
217
+ const contextKeys = [];
218
+ for (const key of this.storage.keys()) {
219
+ if (prefix) {
220
+ // Return keys within this context (strip context prefix)
221
+ if (key.startsWith(prefix)) {
222
+ const subKey = key.substring(prefix.length);
223
+ // Only include direct children (no further nesting)
224
+ if (!subKey.includes('.')) {
225
+ contextKeys.push(subKey);
226
+ }
227
+ }
228
+ }
229
+ else {
230
+ // Root level - return keys with no dots
231
+ if (!key.includes('.')) {
232
+ contextKeys.push(key);
233
+ }
234
+ }
235
+ }
236
+ return contextKeys;
237
+ }
238
+ /**
239
+ * Get all child context names (Matter.js interface)
240
+ */
241
+ contexts(contexts) {
242
+ if (!this.isInitialized) {
243
+ return [];
244
+ }
245
+ const contextKey = this.buildContextKey(contexts);
246
+ const prefix = contextKey ? `${contextKey}.` : '';
247
+ const childContexts = new Set();
248
+ for (const key of this.storage.keys()) {
249
+ if (prefix) {
250
+ // Find sub-contexts within this context
251
+ if (key.startsWith(prefix)) {
252
+ const subKey = key.substring(prefix.length);
253
+ const nextDot = subKey.indexOf('.');
254
+ if (nextDot > 0) {
255
+ childContexts.add(subKey.substring(0, nextDot));
256
+ }
257
+ }
258
+ }
259
+ else {
260
+ // Root level - find top-level contexts
261
+ const dotIndex = key.indexOf('.');
262
+ if (dotIndex > 0) {
263
+ childContexts.add(key.substring(0, dotIndex));
264
+ }
265
+ }
266
+ }
267
+ return Array.from(childContexts);
268
+ }
269
+ /**
270
+ * Check if a key exists (Matter.js interface)
271
+ */
272
+ has(contexts, key) {
273
+ if (!this.isInitialized) {
274
+ return false;
275
+ }
276
+ const fullKey = contexts.length ? `${this.buildContextKey(contexts)}.${key}` : key;
277
+ return this.storage.has(fullKey);
278
+ }
279
+ /**
280
+ * Get all values in a context
281
+ */
282
+ async values(contexts) {
283
+ await this.initialize();
284
+ const contextKey = this.buildContextKey(contexts);
285
+ const prefix = contextKey ? `${contextKey}.` : '';
286
+ const values = {};
287
+ for (const [key, value] of this.storage.entries()) {
288
+ if (prefix) {
289
+ if (key.startsWith(prefix)) {
290
+ const subKey = key.substring(prefix.length);
291
+ if (!subKey.includes('.')) {
292
+ values[subKey] = this.deserializeValue(value);
293
+ }
294
+ }
295
+ }
296
+ else {
297
+ if (!key.includes('.')) {
298
+ values[key] = this.deserializeValue(value);
299
+ }
300
+ }
301
+ }
302
+ return values;
303
+ }
304
+ /**
305
+ * Schedule a persist operation (debounced)
306
+ */
307
+ async schedulePersist() {
308
+ if (this.writeTimer) {
309
+ clearTimeout(this.writeTimer);
310
+ }
311
+ this.pendingWrite = true;
312
+ // Immediate persist for critical data (fabric information)
313
+ const hasCriticalData = Array.from(this.storage.keys()).some(key => key.includes('fabric') || key.includes('commissioning'));
314
+ if (hasCriticalData) {
315
+ await this.persist();
316
+ }
317
+ else {
318
+ // Debounce non-critical writes
319
+ this.writeTimer = setTimeout(() => {
320
+ void this.persist();
321
+ }, STORAGE_WRITE_DEBOUNCE_MS);
322
+ }
323
+ }
324
+ /**
325
+ * Persist storage to disk with atomic write
326
+ */
327
+ async persist() {
328
+ // Wait for any in-progress persist operation to complete
329
+ if (this.persistLock) {
330
+ await this.persistLock;
331
+ }
332
+ if (!this.pendingWrite) {
333
+ return;
334
+ }
335
+ // Create a new lock for this persist operation
336
+ this.persistLock = (async () => {
337
+ try {
338
+ const data = Object.fromEntries(this.storage.entries());
339
+ const dir = path.dirname(this.filePath);
340
+ // Ensure directory exists
341
+ await fsp.mkdir(dir, { recursive: true });
342
+ // Atomic write: write to temp file then rename
343
+ // Use a unique temp file to avoid conflicts
344
+ const tempFile = `${this.filePath}.tmp.${Date.now()}`;
345
+ // Custom replacer to handle BigInt, Uint8Array, and Buffer serialization
346
+ const jsonString = JSON.stringify(data, (_key, value) => {
347
+ if (typeof value === 'bigint') {
348
+ return { __type: 'bigint', value: value.toString() };
349
+ }
350
+ // Handle Buffer before Uint8Array since Buffer extends Uint8Array
351
+ // Note: Buffer.toJSON() returns {type: 'Buffer', data: [...]}, but we want consistent format
352
+ if (Buffer.isBuffer(value)) {
353
+ return { __type: 'Uint8Array', value: Array.from(value) };
354
+ }
355
+ if (value instanceof Uint8Array) {
356
+ return { __type: 'Uint8Array', value: Array.from(value) };
357
+ }
358
+ return value;
359
+ }, 2);
360
+ await fsp.writeFile(tempFile, jsonString, 'utf-8');
361
+ await fsp.rename(tempFile, this.filePath);
362
+ this.pendingWrite = false;
363
+ log.debug(`Persisted ${this.storage.size} entries for namespace: ${this.namespace}`);
364
+ }
365
+ catch (error) {
366
+ log.error(`Failed to persist storage for ${this.namespace}:`, error);
367
+ // Don't throw - we don't want to break Matter operations
368
+ }
369
+ finally {
370
+ this.persistLock = null;
371
+ }
372
+ })();
373
+ await this.persistLock;
374
+ }
375
+ /**
376
+ * Force immediate persist (for shutdown)
377
+ */
378
+ async forcePersist() {
379
+ if (this.writeTimer) {
380
+ clearTimeout(this.writeTimer);
381
+ this.writeTimer = null;
382
+ }
383
+ if (this.pendingWrite) {
384
+ await this.persist();
385
+ }
386
+ }
387
+ /**
388
+ * Close and cleanup storage
389
+ */
390
+ async close() {
391
+ await this.forcePersist();
392
+ this.storage.clear();
393
+ this.isInitialized = false;
394
+ }
395
+ /**
396
+ * Get storage statistics
397
+ */
398
+ getStats() {
399
+ return {
400
+ entries: this.storage.size,
401
+ namespace: this.namespace,
402
+ path: this.filePath,
403
+ };
404
+ }
405
+ }
406
+ /**
407
+ * Storage Manager for Matter.js
408
+ * Manages multiple storage contexts for different namespaces
409
+ */
410
+ export class MatterStorageManager {
411
+ storagePath;
412
+ storages = new Map();
413
+ constructor(storagePath) {
414
+ this.storagePath = storagePath;
415
+ }
416
+ /**
417
+ * Get or create a storage context for a namespace
418
+ */
419
+ getStorage(namespace) {
420
+ let storage = this.storages.get(namespace);
421
+ if (!storage) {
422
+ storage = new HomebridgeMatterStorage(namespace, this.storagePath);
423
+ this.storages.set(namespace, storage);
424
+ }
425
+ return storage;
426
+ }
427
+ /**
428
+ * Close all storage contexts
429
+ */
430
+ async closeAll() {
431
+ const promises = Array.from(this.storages.values()).map(storage => storage.close());
432
+ await Promise.all(promises);
433
+ this.storages.clear();
434
+ }
435
+ /**
436
+ * Get statistics for all storage contexts
437
+ */
438
+ getAllStats() {
439
+ return Array.from(this.storages.values()).map(storage => storage.getStats());
440
+ }
441
+ }
442
+ //# 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,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,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;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IASxB;IARF,OAAO,GAAqB,IAAI,GAAG,EAAE,CAAA;IAC5B,QAAQ,CAAQ;IACzB,aAAa,GAAG,KAAK,CAAA;IACrB,UAAU,GAA0B,IAAI,CAAA;IACxC,YAAY,GAAG,KAAK,CAAA;IACpB,WAAW,GAAyB,IAAI,CAAA;IAEhD,YACU,SAAiB,EACzB,WAAmB;QADX,cAAS,GAAT,SAAS,CAAQ;QAGzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,SAAS,OAAO,CAAC,CAAA;QAE3D,2EAA2E;QAC3E,wDAAwD;QACxD,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,CAAC;IAED;;;OAGG;IACK,cAAc;QACpB,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YAC3D,uDAAuD;YACvD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CA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AI,EAAE,IAAI,CAAC,QAAQ;SACpB,CAAA;IACH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAGX;IAFZ,QAAQ,GAAyC,IAAI,GAAG,EAAE,CAAA;IAElE,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;IAAG,CAAC;IAE3C;;OAEG;IACH,UAAU,CAAC,SAAiB;QAC1B,IAAI,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,IAAI,uBAAuB,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;YAClE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QACvC,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACnF,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC3B,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC9E,CAAC;CACF"}
@@ -1,35 +1,163 @@
1
- import { HomebridgeOptions } from '../server.js';
2
1
  /**
3
- * Matter bridge configuration interface
2
+ * Matter Types for Homebridge Plugin API
3
+ *
4
+ * This module provides types and interfaces for plugin developers
5
+ * to create Matter-compatible accessories.
4
6
  */
5
- export interface MatterConfiguration {
6
- port?: number;
7
- name?: string;
7
+ import type { Endpoint, EndpointType } from '@matter/main';
8
+ import * as clusters from '@matter/main/clusters';
9
+ import * as devices from '@matter/main/devices';
10
+ /**
11
+ * Matter Accessory - Plugin API Interface
12
+ *
13
+ * This is the main interface that plugin developers use to register
14
+ * Matter accessories with Homebridge.
15
+ */
16
+ export interface MatterAccessory<T = Record<string, any>> {
17
+ /** Unique identifier for this accessory (must be unique across all accessories) */
18
+ uuid: string;
19
+ /** Display name for the accessory */
20
+ displayName: string;
21
+ /** Matter device type (e.g., OnOffLightDevice, DimmableLightDevice, etc.) */
22
+ deviceType: EndpointType;
23
+ /** Serial number for the device */
24
+ serialNumber: string;
25
+ /** Manufacturer name */
26
+ manufacturer: string;
27
+ /** Model name/identifier */
28
+ model: string;
29
+ /** Firmware revision (optional) */
30
+ firmwareRevision?: string;
31
+ /** Hardware revision (optional) */
32
+ hardwareRevision?: string;
33
+ /** Software version (optional) */
34
+ softwareVersion?: string;
35
+ /**
36
+ * Plugin developer storage - persists across restarts
37
+ * This is a way for plugin developers to store custom data with their accessory
38
+ * Similar to PlatformAccessory.context for HAP accessories
39
+ */
40
+ context?: T;
41
+ /**
42
+ * Initial cluster states
43
+ * Key is the cluster name, value is an object of attribute name -> value
44
+ *
45
+ * Example:
46
+ * {
47
+ * onOff: { onOff: true },
48
+ * levelControl: { currentLevel: 127, minLevel: 1, maxLevel: 254 }
49
+ * }
50
+ */
51
+ clusters: {
52
+ [clusterName: string]: {
53
+ [attributeName: string]: unknown;
54
+ };
55
+ };
56
+ /**
57
+ * Handlers for Matter commands
58
+ * Key is the cluster name, value is an object of command name -> handler function
59
+ *
60
+ * Example:
61
+ * {
62
+ * onOff: {
63
+ * on: async () => { ... },
64
+ * off: async () => { ... }
65
+ * }
66
+ * }
67
+ */
68
+ handlers?: {
69
+ [clusterName: string]: {
70
+ [commandName: string]: (...args: unknown[]) => Promise<void> | void;
71
+ };
72
+ };
73
+ /**
74
+ * Optional: Get current state handler
75
+ * Called when a Matter controller reads an attribute
76
+ * If not provided, the last set value is returned
77
+ */
78
+ getState?: (cluster: string, attribute: string) => Promise<any> | any;
8
79
  }
9
80
  /**
10
- * Matter bridge options extending Homebridge options
81
+ * Matter Configuration (for bridge or child bridge)
11
82
  */
12
- export interface MatterBridgeOptions extends HomebridgeOptions {
13
- matterBridgeServerPort?: number;
14
- configPath?: string;
83
+ export interface MatterConfig {
84
+ /** Port for Matter server (optional, will auto-assign if not specified) */
85
+ port?: number;
86
+ /** Name for the Matter bridge (optional) */
87
+ name?: string;
15
88
  }
16
- declare const MatterClusters: Record<string, unknown>;
17
- declare const MatterDeviceTypes: Record<string, unknown>;
18
89
  /**
19
- * Maps common HomeKit service types to appropriate Matter clusters
90
+ * Internal Matter accessory representation
91
+ * (Used internally by MatterServer)
20
92
  */
21
- export declare const HAPToMatterClusterMapping: Record<string, string[]>;
93
+ export interface InternalMatterAccessory extends MatterAccessory {
94
+ endpoint?: Endpoint;
95
+ registered: boolean;
96
+ }
22
97
  /**
23
- * Maps common HomeKit service types to appropriate Matter device types
98
+ * Matter error type enum (for error handler categorization)
24
99
  */
25
- export declare const HAPToMatterDeviceMapping: Record<string, string>;
100
+ export declare enum MatterErrorType {
101
+ INITIALIZATION = "INITIALIZATION",
102
+ NETWORK = "NETWORK",
103
+ COMMISSIONING = "COMMISSIONING",
104
+ DEVICE_SYNC = "DEVICE_SYNC",
105
+ SERVER = "SERVER",
106
+ STORAGE = "STORAGE",
107
+ CONFIGURATION = "CONFIGURATION",
108
+ DEVICE_ERROR = "DEVICE_ERROR",
109
+ UNKNOWN = "UNKNOWN"
110
+ }
26
111
  /**
27
- * Helper function to get Matter device type for a HomeKit service
112
+ * Matter error types
28
113
  */
29
- export declare function getMatterDeviceTypeForHAPService(serviceType: string, characteristics?: string[]): string | null;
114
+ export declare class MatterError extends Error {
115
+ readonly code: string;
116
+ readonly details?: unknown | undefined;
117
+ readonly type: MatterErrorType;
118
+ readonly timestamp: Date;
119
+ readonly recoverable: boolean;
120
+ constructor(message: string, code: string, details?: unknown | undefined, type?: MatterErrorType, recoverable?: boolean);
121
+ }
122
+ export declare class MatterCommissioningError extends MatterError {
123
+ constructor(message: string, details?: unknown);
124
+ }
125
+ export declare class MatterStorageError extends MatterError {
126
+ constructor(message: string, details?: unknown);
127
+ }
128
+ export declare class MatterDeviceError extends MatterError {
129
+ constructor(message: string, details?: unknown);
130
+ }
131
+ export declare class MatterNetworkError extends MatterError {
132
+ constructor(message: string, details?: unknown);
133
+ }
134
+ export { clusters };
135
+ export { devices };
30
136
  /**
31
- * Helper function to get Matter clusters for a HomeKit service
137
+ * Friendly device type names for the Plugin API
138
+ * Maps simplified names to actual Matter.js device types
32
139
  */
33
- export declare function getMatterClustersForHAPService(serviceType: string, characteristics?: string[]): string[];
34
- export { MatterClusters, MatterDeviceTypes };
140
+ export declare const deviceTypes: {
141
+ readonly OnOffLight: devices.OnOffLightDevice;
142
+ readonly DimmableLight: devices.DimmableLightDevice;
143
+ readonly ColorTemperatureLight: devices.ColorTemperatureLightDevice;
144
+ readonly ExtendedColorLight: devices.ExtendedColorLightDevice;
145
+ readonly OnOffSwitch: devices.OnOffLightSwitchDevice;
146
+ readonly OnOffOutlet: devices.OnOffPlugInUnitDevice;
147
+ readonly DimmableOutlet: devices.DimmablePlugInUnitDevice;
148
+ readonly TemperatureSensor: devices.TemperatureSensorDevice;
149
+ readonly HumiditySensor: devices.HumiditySensorDevice;
150
+ readonly LightSensor: devices.LightSensorDevice;
151
+ readonly MotionSensor: devices.OccupancySensorDevice;
152
+ readonly ContactSensor: devices.ContactSensorDevice;
153
+ readonly LeakSensor: devices.WaterLeakDetectorDevice;
154
+ readonly SmokeSensor: devices.SmokeCoAlarmDevice;
155
+ readonly Thermostat: devices.ThermostatDevice;
156
+ readonly Fan: devices.FanDevice;
157
+ readonly DoorLock: devices.DoorLockDevice;
158
+ readonly WindowCovering: devices.WindowCoveringDevice;
159
+ readonly GenericSwitch: devices.GenericSwitchDevice;
160
+ readonly Pump: devices.PumpDevice;
161
+ readonly RoomAirConditioner: devices.RoomAirConditionerDevice;
162
+ };
35
163
  //# sourceMappingURL=matterTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matterTypes.d.ts","sourceRoot":"","sources":["../../src/matter/matterTypes.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAGD,QAAA,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAA;AAClD,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAA;AAuHrD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAoF9D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAmC3D,CAAA;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAwB/G;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA2BxG;AAED,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,CAAA"}
1
+ {"version":3,"file":"matterTypes.d.ts","sourceRoot":"","sources":["../../src/matter/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