indigo-matter-bridge 0.5.0 → 0.6.0

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/README.md CHANGED
@@ -4,8 +4,9 @@ The Matter **bridge node** for the
4
4
  [indigo-matter](https://github.com/simons-plugins/indigo-matter) Indigo plugin.
5
5
 
6
6
  It exports selected [Indigo](https://www.indigodomo.com) devices as Matter
7
- accessories, so Apple Home, Alexa, Google Home and SmartThings see them as
8
- ordinary Matter devices on a bridge.
7
+ accessories, so an ecosystem sees them as ordinary Matter devices on a bridge.
8
+ **Apple Home** is the ecosystem this is built and documented for; Alexa, Google
9
+ Home and SmartThings are untested and unclaimed.
9
10
 
10
11
  > **This package is not useful on its own.** It has no configuration of its own,
11
12
  > no discovery, and no idea what an Indigo device is. It is one half of a pair:
@@ -25,6 +25,18 @@
25
25
  * baseline stays, so the drift keeps being reported until a human resolves it
26
26
  * with §3.11.
27
27
  *
28
+ * **It also carries what it takes to REBUILD an endpoint** (issue #141). Numbers
29
+ * alone were enough while the file was only a witness, but a node that comes
30
+ * online with an empty aggregator and waits for the plugin tells every paired
31
+ * ecosystem that every accessory has gone — Apple re-adds them as new arrivals
32
+ * and the user's room assignments are destroyed on every restart. So each entry
33
+ * also records the `role` and `label` the endpoint was last created with, which
34
+ * is exactly (and only) what `createEndpoint` needs; `node.ts` restores the set
35
+ * from here before the stack goes online. `options` is deliberately NOT stored:
36
+ * nothing in this node reads it (window-covering polarity is applied
37
+ * plugin-side), so persisting it would be storing a field to satisfy a sentence
38
+ * rather than a caller.
39
+ *
28
40
  * Stdlib only — no matter.js import — which is what lets the whole detector be
29
41
  * tested without a Matter stack. Callers hand in `{uniqueId, endpointNumber}`
30
42
  * pairs; deriving `uniqueId` from an Indigo device id is `endpoints.ts`'s job.
@@ -80,28 +92,79 @@ export interface EndpointIdentityState {
80
92
  export declare function refuseReasonFor(state: EndpointIdentityState): string | undefined;
81
93
  /** Sibling of `identity.json` in the bridge storage dir. */
82
94
  export declare const ENDPOINT_MAP_FILE = "endpoint-map.json";
83
- /** Schema version of the persisted file. Bump only on an incompatible change. */
84
- export declare const ENDPOINT_MAP_VERSION = 1;
85
- /** The on-disk shape. */
95
+ /**
96
+ * Schema version of the persisted file.
97
+ *
98
+ * **2 since issue #141**, which added `role`/`label` to every entry so the
99
+ * endpoint set can be rebuilt without the plugin. Version 1 files are still
100
+ * read — see {@link ENDPOINT_MAP_VERSION_LEGACY} — because a v1 file holds the
101
+ * one thing that can never be re-derived: the numbers paired ecosystems know.
102
+ */
103
+ export declare const ENDPOINT_MAP_VERSION = 2;
104
+ /** The numbers-only shape shipped by E5. Still read; never written again. */
105
+ export declare const ENDPOINT_MAP_VERSION_LEGACY = 1;
106
+ /**
107
+ * One persisted endpoint.
108
+ *
109
+ * `number` is the identity half and is always there. `role`/`label` are the
110
+ * *restoration* half and are optional, because a v1 file has neither and
111
+ * discarding a v1 file to get a tidier type would throw away the numbers every
112
+ * paired ecosystem is keyed on. An entry without them is still a perfectly good
113
+ * witness; it simply cannot be restored until the plugin next attaches and
114
+ * fills them in.
115
+ */
116
+ export interface EndpointRecord {
117
+ number: number;
118
+ role?: string;
119
+ label?: string;
120
+ }
121
+ /** The on-disk shape (v2). */
86
122
  export interface EndpointMapFile {
87
123
  version: number;
88
- /** `UniqueID → endpoint number`. */
124
+ /** `UniqueID → {number, role?, label?}`. */
125
+ endpoints: Record<string, EndpointRecord>;
126
+ }
127
+ /** The v1 on-disk shape — `UniqueID → endpoint number`. Read-only, for tests and migration. */
128
+ export interface EndpointMapFileV1 {
129
+ version: 1;
89
130
  endpoints: Record<string, number>;
90
131
  }
91
132
  /** One live endpoint, as the detector needs to see it. */
92
133
  export interface LiveEndpointNumber {
93
134
  uniqueId: string;
94
135
  endpointNumber: number;
136
+ /**
137
+ * What it would take to rebuild this endpoint at the next start. Optional
138
+ * so a caller that genuinely does not know (the E5 migration seed, which
139
+ * has no live set at all) cannot be forced to invent them — an absent
140
+ * value never erases a recorded one.
141
+ */
142
+ role?: string;
143
+ label?: string;
144
+ }
145
+ /** An entry complete enough for `node.ts` to reconstruct before going online. */
146
+ export interface RestorableEndpoint {
147
+ uniqueId: string;
148
+ endpointNumber: number;
149
+ role: string;
150
+ label: string;
95
151
  }
96
152
  /** The outcome of reading the file: absent, usable, or present-but-broken. */
97
153
  export interface EndpointMapLoad {
98
- numbers: Map<string, number>;
154
+ endpoints: Map<string, EndpointRecord>;
99
155
  /** True when a file was there at all — absent is a first run, not a fault. */
100
156
  present: boolean;
101
157
  /** Set only when a file was present and could not be used. */
102
158
  problem?: string;
103
159
  }
104
- /** Read `endpoint-map.json`. Never throws — the caller decides what a fault means. */
160
+ /**
161
+ * Read `endpoint-map.json`. Never throws — the caller decides what a fault means.
162
+ *
163
+ * **A v1 file is migrated, never rejected.** Its entries are numbers-only, so
164
+ * they load as records with no `role`/`label` and are simply not restorable
165
+ * until the next attach records them; the numbers themselves are the identity
166
+ * every paired ecosystem is keyed on and must survive the upgrade untouched.
167
+ */
105
168
  export declare function loadEndpointMap(storagePath: string): EndpointMapLoad;
106
169
  /** Delete `endpoint-map.json`. Returns whether a file was actually removed. */
107
170
  export declare function deleteEndpointMap(storagePath: string): boolean;
@@ -149,6 +212,18 @@ export declare class EndpointMapStore {
149
212
  /** The recorded number for a `UniqueID`, if there is one. */
150
213
  numberFor(uniqueId: string): number | undefined;
151
214
  get size(): number;
215
+ /**
216
+ * The entries complete enough to rebuild before the stack goes online
217
+ * (issue #141).
218
+ *
219
+ * Entries missing `role` or `label` are silently absent rather than
220
+ * reported as a fault: that is precisely a v1 file's normal state, and one
221
+ * attach fills it in. Order is the map's own insertion order, which is the
222
+ * order the numbers were first recorded — irrelevant to matter.js, which
223
+ * keys each endpoint's number on its `Endpoint.id`, but stable, which makes
224
+ * the log read the same way twice.
225
+ */
226
+ restorable(): RestorableEndpoint[];
152
227
  /**
153
228
  * Compare the live endpoint numbers against the map (PRD §4.3).
154
229
  *
@@ -25,6 +25,18 @@
25
25
  * baseline stays, so the drift keeps being reported until a human resolves it
26
26
  * with §3.11.
27
27
  *
28
+ * **It also carries what it takes to REBUILD an endpoint** (issue #141). Numbers
29
+ * alone were enough while the file was only a witness, but a node that comes
30
+ * online with an empty aggregator and waits for the plugin tells every paired
31
+ * ecosystem that every accessory has gone — Apple re-adds them as new arrivals
32
+ * and the user's room assignments are destroyed on every restart. So each entry
33
+ * also records the `role` and `label` the endpoint was last created with, which
34
+ * is exactly (and only) what `createEndpoint` needs; `node.ts` restores the set
35
+ * from here before the stack goes online. `options` is deliberately NOT stored:
36
+ * nothing in this node reads it (window-covering polarity is applied
37
+ * plugin-side), so persisting it would be storing a field to satisfy a sentence
38
+ * rather than a caller.
39
+ *
28
40
  * Stdlib only — no matter.js import — which is what lets the whole detector be
29
41
  * tested without a Matter stack. Callers hand in `{uniqueId, endpointNumber}`
30
42
  * pairs; deriving `uniqueId` from an Indigo device id is `endpoints.ts`'s job.
@@ -72,48 +84,110 @@ export function refuseReasonFor(state) {
72
84
  }
73
85
  /** Sibling of `identity.json` in the bridge storage dir. */
74
86
  export const ENDPOINT_MAP_FILE = "endpoint-map.json";
75
- /** Schema version of the persisted file. Bump only on an incompatible change. */
76
- export const ENDPOINT_MAP_VERSION = 1;
87
+ /**
88
+ * Schema version of the persisted file.
89
+ *
90
+ * **2 since issue #141**, which added `role`/`label` to every entry so the
91
+ * endpoint set can be rebuilt without the plugin. Version 1 files are still
92
+ * read — see {@link ENDPOINT_MAP_VERSION_LEGACY} — because a v1 file holds the
93
+ * one thing that can never be re-derived: the numbers paired ecosystems know.
94
+ */
95
+ export const ENDPOINT_MAP_VERSION = 2;
96
+ /** The numbers-only shape shipped by E5. Still read; never written again. */
97
+ export const ENDPOINT_MAP_VERSION_LEGACY = 1;
77
98
  /** Stable keys so a repeated failure replaces its warning rather than stacking. */
78
99
  const WARN_PERSIST = "endpoint-map-persist";
79
100
  const WARN_DELETE = "endpoint-map-delete";
80
- function isEndpointMapFile(value) {
81
- if (typeof value !== "object" || value === null) {
82
- return false;
101
+ function isNonEmptyString(value) {
102
+ return typeof value === "string" && value.length > 0;
103
+ }
104
+ function isEndpointNumber(value) {
105
+ return typeof value === "number" && Number.isInteger(value) && value >= 0;
106
+ }
107
+ /**
108
+ * Read one entry in either schema, or `undefined` if it is not usable.
109
+ *
110
+ * A v2 entry with a bad `role`/`label` keeps its number and loses only the
111
+ * fields that were wrong, for the same reason a v1 file is not discarded: the
112
+ * number is the irreplaceable part, and refusing the whole file over a label
113
+ * would turn a cosmetic corruption into a refuse-to-start.
114
+ */
115
+ function readRecord(value) {
116
+ if (isEndpointNumber(value)) {
117
+ return { number: value };
118
+ }
119
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
120
+ return undefined;
83
121
  }
84
122
  const candidate = value;
85
- if (candidate.version !== ENDPOINT_MAP_VERSION) {
86
- return false;
123
+ if (!isEndpointNumber(candidate.number)) {
124
+ return undefined;
125
+ }
126
+ const record = { number: candidate.number };
127
+ if (isNonEmptyString(candidate.role)) {
128
+ record.role = candidate.role;
87
129
  }
88
- const { endpoints } = candidate;
89
- if (typeof endpoints !== "object" || endpoints === null || Array.isArray(endpoints)) {
90
- return false;
130
+ if (isNonEmptyString(candidate.label)) {
131
+ record.label = candidate.label;
91
132
  }
92
- return Object.values(endpoints).every(number => typeof number === "number" && Number.isInteger(number) && number >= 0);
133
+ return record;
134
+ }
135
+ /**
136
+ * Parse the `endpoints` object of either schema version, or `undefined` if the
137
+ * file is not an endpoint map at all.
138
+ */
139
+ function readEndpoints(value) {
140
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
141
+ return undefined;
142
+ }
143
+ const endpoints = new Map();
144
+ for (const [uniqueId, entry] of Object.entries(value)) {
145
+ const record = readRecord(entry);
146
+ if (record === undefined) {
147
+ return undefined;
148
+ }
149
+ endpoints.set(uniqueId, record);
150
+ }
151
+ return endpoints;
152
+ }
153
+ function isKnownVersion(version) {
154
+ return version === ENDPOINT_MAP_VERSION || version === ENDPOINT_MAP_VERSION_LEGACY;
93
155
  }
94
156
  function isNotFound(error) {
95
157
  return error?.code === "ENOENT";
96
158
  }
97
- /** Read `endpoint-map.json`. Never throws — the caller decides what a fault means. */
159
+ /**
160
+ * Read `endpoint-map.json`. Never throws — the caller decides what a fault means.
161
+ *
162
+ * **A v1 file is migrated, never rejected.** Its entries are numbers-only, so
163
+ * they load as records with no `role`/`label` and are simply not restorable
164
+ * until the next attach records them; the numbers themselves are the identity
165
+ * every paired ecosystem is keyed on and must survive the upgrade untouched.
166
+ */
98
167
  export function loadEndpointMap(storagePath) {
99
168
  const file = join(storagePath, ENDPOINT_MAP_FILE);
100
169
  try {
101
170
  const parsed = JSON.parse(readFileSync(file, "utf8"));
102
- if (!isEndpointMapFile(parsed)) {
171
+ const version = parsed?.version;
172
+ const endpoints = isKnownVersion(version)
173
+ ? readEndpoints(parsed.endpoints)
174
+ : undefined;
175
+ if (endpoints === undefined) {
103
176
  return {
104
- numbers: new Map(),
177
+ endpoints: new Map(),
105
178
  present: true,
106
- problem: `${file} is not a version ${ENDPOINT_MAP_VERSION} endpoint map`,
179
+ problem: `${file} is not a version ${ENDPOINT_MAP_VERSION} ` +
180
+ `(or legacy version ${ENDPOINT_MAP_VERSION_LEGACY}) endpoint map`,
107
181
  };
108
182
  }
109
- return { numbers: new Map(Object.entries(parsed.endpoints)), present: true };
183
+ return { endpoints, present: true };
110
184
  }
111
185
  catch (error) {
112
186
  if (isNotFound(error)) {
113
- return { numbers: new Map(), present: false };
187
+ return { endpoints: new Map(), present: false };
114
188
  }
115
189
  return {
116
- numbers: new Map(),
190
+ endpoints: new Map(),
117
191
  present: true,
118
192
  problem: `${file} is unreadable (${describeError(error)})`,
119
193
  };
@@ -132,6 +206,49 @@ export function deleteEndpointMap(storagePath) {
132
206
  throw error;
133
207
  }
134
208
  }
209
+ /** A fresh record from a live endpoint, carrying whatever it could tell us. */
210
+ function recordFor(entry) {
211
+ const record = { number: entry.endpointNumber };
212
+ if (entry.role !== undefined) {
213
+ record.role = entry.role;
214
+ }
215
+ if (entry.label !== undefined) {
216
+ record.label = entry.label;
217
+ }
218
+ return record;
219
+ }
220
+ /**
221
+ * Refresh an existing record's restoration half from a live endpoint.
222
+ *
223
+ * An **absent** value never erases a recorded one: the seed path has no live
224
+ * set at all, and reading its silence as "this endpoint has no role any more"
225
+ * would strip a perfectly good entry of the very fields that make it
226
+ * restorable. Returns whether anything changed, so a steady state still costs
227
+ * no disk write.
228
+ */
229
+ function noteRestorable(record, entry) {
230
+ let changed = false;
231
+ if (entry.role !== undefined && record.role !== entry.role) {
232
+ record.role = entry.role;
233
+ changed = true;
234
+ }
235
+ if (entry.label !== undefined && record.label !== entry.label) {
236
+ record.label = entry.label;
237
+ changed = true;
238
+ }
239
+ return changed;
240
+ }
241
+ /** Why {@link EndpointMapStore.check} is writing, for the log line. */
242
+ function persistReason(added, refreshed) {
243
+ const parts = [];
244
+ if (added > 0) {
245
+ parts.push(`recorded ${added} new endpoint number(s)`);
246
+ }
247
+ if (refreshed > 0) {
248
+ parts.push(`refreshed ${refreshed} endpoint role/label(s)`);
249
+ }
250
+ return parts.length === 0 ? "retried after a failed write" : parts.join(" and ");
251
+ }
135
252
  /**
136
253
  * The map plus the operations §3.10/§3.11 and the drift detector need.
137
254
  *
@@ -143,7 +260,7 @@ export class EndpointMapStore {
143
260
  storagePath;
144
261
  log;
145
262
  now;
146
- #numbers = new Map();
263
+ #endpoints = new Map();
147
264
  #present = false;
148
265
  #problem;
149
266
  #checked = false;
@@ -179,7 +296,7 @@ export class EndpointMapStore {
179
296
  /** Read the file into memory. Idempotent; the last read wins. */
180
297
  load() {
181
298
  const loaded = loadEndpointMap(this.storagePath);
182
- this.#numbers = loaded.numbers;
299
+ this.#endpoints = loaded.endpoints;
183
300
  this.#present = loaded.present;
184
301
  this.#problem = loaded.problem;
185
302
  this.#checked = false;
@@ -193,7 +310,9 @@ export class EndpointMapStore {
193
310
  this.log("No endpoint map yet; the first reconcile will record one");
194
311
  }
195
312
  else {
196
- this.log(`Loaded endpoint map: ${loaded.numbers.size} endpoint number(s)`);
313
+ const restorable = this.restorable().length;
314
+ this.log(`Loaded endpoint map: ${loaded.endpoints.size} endpoint number(s), ` +
315
+ `${restorable} restorable at startup`);
197
316
  }
198
317
  return loaded;
199
318
  }
@@ -230,10 +349,36 @@ export class EndpointMapStore {
230
349
  }
231
350
  /** The recorded number for a `UniqueID`, if there is one. */
232
351
  numberFor(uniqueId) {
233
- return this.#numbers.get(uniqueId);
352
+ return this.#endpoints.get(uniqueId)?.number;
234
353
  }
235
354
  get size() {
236
- return this.#numbers.size;
355
+ return this.#endpoints.size;
356
+ }
357
+ /**
358
+ * The entries complete enough to rebuild before the stack goes online
359
+ * (issue #141).
360
+ *
361
+ * Entries missing `role` or `label` are silently absent rather than
362
+ * reported as a fault: that is precisely a v1 file's normal state, and one
363
+ * attach fills it in. Order is the map's own insertion order, which is the
364
+ * order the numbers were first recorded — irrelevant to matter.js, which
365
+ * keys each endpoint's number on its `Endpoint.id`, but stable, which makes
366
+ * the log read the same way twice.
367
+ */
368
+ restorable() {
369
+ const restorable = [];
370
+ for (const [uniqueId, record] of this.#endpoints) {
371
+ if (record.role === undefined || record.label === undefined) {
372
+ continue;
373
+ }
374
+ restorable.push({
375
+ uniqueId,
376
+ endpointNumber: record.number,
377
+ role: record.role,
378
+ label: record.label,
379
+ });
380
+ }
381
+ return restorable;
237
382
  }
238
383
  /**
239
384
  * Compare the live endpoint numbers against the map (PRD §4.3).
@@ -251,15 +396,23 @@ export class EndpointMapStore {
251
396
  check(live) {
252
397
  const drift = [];
253
398
  let added = 0;
254
- for (const { uniqueId, endpointNumber } of live) {
255
- const expected = this.#numbers.get(uniqueId);
256
- if (expected === undefined) {
257
- this.#numbers.set(uniqueId, endpointNumber);
399
+ let refreshed = 0;
400
+ for (const entry of live) {
401
+ const record = this.#endpoints.get(entry.uniqueId);
402
+ if (record === undefined) {
403
+ this.#endpoints.set(entry.uniqueId, recordFor(entry));
258
404
  added += 1;
259
405
  continue;
260
406
  }
261
- if (expected !== endpointNumber) {
262
- drift.push({ uniqueId, expected, actual: endpointNumber });
407
+ // The restoration half is refreshed even when the number drifted:
408
+ // a renamed accessory whose number also moved must still come back
409
+ // under its current name, and role/label are independent facts from
410
+ // the number. The NUMBER is never touched — see the class comment.
411
+ if (noteRestorable(record, entry)) {
412
+ refreshed += 1;
413
+ }
414
+ if (record.number !== entry.endpointNumber) {
415
+ drift.push({ uniqueId: entry.uniqueId, expected: record.number, actual: entry.endpointNumber });
263
416
  }
264
417
  }
265
418
  // `#dirty` is the retry: a write that failed last time leaves the map
@@ -267,8 +420,8 @@ export class EndpointMapStore {
267
420
  // steady state (`added === 0`, clean) still costs no I/O. Without it a
268
421
  // full disk at the moment of the first check would never be revisited,
269
422
  // and `checked` — see the `#dirty` field — would never come true again.
270
- if (added > 0 || this.#dirty) {
271
- this.persist(added > 0 ? `recorded ${added} new endpoint number(s)` : "retried after a failed write");
423
+ if (added > 0 || refreshed > 0 || this.#dirty) {
424
+ this.persist(persistReason(added, refreshed));
272
425
  }
273
426
  // An empty comparison compared nothing, so it cannot make `driftChecked`
274
427
  // true — the same rule {@link seed} already applies. §4.3 says
@@ -295,10 +448,10 @@ export class EndpointMapStore {
295
448
  * Returns whether the baseline reached disk.
296
449
  */
297
450
  seed(numbers, why) {
298
- this.#numbers = new Map(numbers.map(({ uniqueId, endpointNumber }) => [uniqueId, endpointNumber]));
451
+ this.#endpoints = new Map(numbers.map(entry => [entry.uniqueId, recordFor(entry)]));
299
452
  this.#problem = undefined;
300
453
  this.#checked = numbers.length > 0;
301
- return this.persist(`seeded with ${this.#numbers.size} endpoint number(s) — ${why}`);
454
+ return this.persist(`seeded with ${this.#endpoints.size} endpoint number(s) — ${why}`);
302
455
  }
303
456
  /**
304
457
  * §3.11 — throw the baseline away and adopt the live numbers as the truth.
@@ -322,9 +475,9 @@ export class EndpointMapStore {
322
475
  "records an empty baseline and stops refusing; the numbers themselves are " +
323
476
  "recorded by the reconcile that follows.");
324
477
  }
325
- this.#numbers = new Map(live.map(({ uniqueId, endpointNumber }) => [uniqueId, endpointNumber]));
478
+ this.#endpoints = new Map(live.map(entry => [entry.uniqueId, recordFor(entry)]));
326
479
  this.#problem = undefined;
327
- const persisted = this.persist(`rebuilt from ${this.#numbers.size} live endpoint(s)`);
480
+ const persisted = this.persist(`rebuilt from ${this.#endpoints.size} live endpoint(s)`);
328
481
  // Same rule as `check`: a rebuild from zero live endpoints — which is
329
482
  // the *normal* rebuild, since §1.1 keeps `attach` out of the recovery
330
483
  // commands — has compared nothing, and the baseline it wrote is empty.
@@ -364,7 +517,7 @@ export class EndpointMapStore {
364
517
  * what is corrupt.
365
518
  */
366
519
  discard() {
367
- this.#numbers = new Map();
520
+ this.#endpoints = new Map();
368
521
  this.#problem = undefined;
369
522
  this.#checked = false;
370
523
  this.#dirty = false;
@@ -407,7 +560,7 @@ export class EndpointMapStore {
407
560
  this.quarantineUnusable();
408
561
  const file = {
409
562
  version: ENDPOINT_MAP_VERSION,
410
- endpoints: Object.fromEntries(this.#numbers),
563
+ endpoints: Object.fromEntries(this.#endpoints),
411
564
  };
412
565
  try {
413
566
  writeJsonAtomic(join(this.storagePath, ENDPOINT_MAP_FILE), file);
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-map.js","sourceRoot":"","sources":["../src/endpoint-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAmB,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAmB/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,eAAe,CAAC,KAA4B;IACxD,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C,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;CACJ"}
@@ -30,6 +30,20 @@ import { Thermostat } from "@matter/main/clusters/thermostat";
30
30
  import { type CommandEventData, type EndpointSpec, type RoleValue } from "./protocol.js";
31
31
  /** Bridged Device Basic Information `UniqueID`, stable across restarts. */
32
32
  export declare function uniqueIdFor(indigoDeviceId: number): string;
33
+ /**
34
+ * The inverse of {@link uniqueIdFor}, or `undefined` for anything that is not
35
+ * one of ours.
36
+ *
37
+ * §6.3's "identity flows one way" is about the *protocol*: nothing on the wire
38
+ * is ever keyed on a derived value. `endpoint-map.json` is not on the wire — it
39
+ * is keyed by `UniqueID` because that is what drift is reported against — so
40
+ * restoring an endpoint from it (issue #141) needs the device id back. It lives
41
+ * next to the forward derivation so the two cannot drift apart, and it is
42
+ * strict rather than forgiving: `Number("indigo-1e3")`-style coercions would
43
+ * silently invent a device id, and an invented id is a new accessory in every
44
+ * paired ecosystem.
45
+ */
46
+ export declare function indigoDeviceIdFrom(uniqueId: string): number | undefined;
33
47
  /**
34
48
  * `Endpoint.id` derivation — the identity key of BRIDGE_PROTOCOL §4.1/§6.3.
35
49
  * Deliberately the *same* value as {@link uniqueIdFor}: one derivation means the
package/dist/endpoints.js CHANGED
@@ -58,9 +58,35 @@ import { describeErrorWithStack, ErrorCode, ProtocolError, Role, } from "./proto
58
58
  * plugin-side unit bug, so it is worth a debug line naming what moved.
59
59
  */
60
60
  const logger = Logger.get("indigo-matter-endpoints");
61
+ /** The one prefix {@link uniqueIdFor} and {@link indigoDeviceIdFrom} share. */
62
+ const UNIQUE_ID_PREFIX = "indigo-";
61
63
  /** Bridged Device Basic Information `UniqueID`, stable across restarts. */
62
64
  export function uniqueIdFor(indigoDeviceId) {
63
- return `indigo-${indigoDeviceId}`;
65
+ return `${UNIQUE_ID_PREFIX}${indigoDeviceId}`;
66
+ }
67
+ /**
68
+ * The inverse of {@link uniqueIdFor}, or `undefined` for anything that is not
69
+ * one of ours.
70
+ *
71
+ * §6.3's "identity flows one way" is about the *protocol*: nothing on the wire
72
+ * is ever keyed on a derived value. `endpoint-map.json` is not on the wire — it
73
+ * is keyed by `UniqueID` because that is what drift is reported against — so
74
+ * restoring an endpoint from it (issue #141) needs the device id back. It lives
75
+ * next to the forward derivation so the two cannot drift apart, and it is
76
+ * strict rather than forgiving: `Number("indigo-1e3")`-style coercions would
77
+ * silently invent a device id, and an invented id is a new accessory in every
78
+ * paired ecosystem.
79
+ */
80
+ export function indigoDeviceIdFrom(uniqueId) {
81
+ if (!uniqueId.startsWith(UNIQUE_ID_PREFIX)) {
82
+ return undefined;
83
+ }
84
+ const digits = uniqueId.slice(UNIQUE_ID_PREFIX.length);
85
+ if (!/^-?\d+$/.test(digits)) {
86
+ return undefined;
87
+ }
88
+ const indigoDeviceId = Number(digits);
89
+ return Number.isSafeInteger(indigoDeviceId) ? indigoDeviceId : undefined;
64
90
  }
65
91
  /**
66
92
  * `Endpoint.id` derivation — the identity key of BRIDGE_PROTOCOL §4.1/§6.3.