@jdcpuwiz/zoo-kit 1.5.0 → 1.5.1

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
@@ -229,6 +229,7 @@ export const POST = devices.revokeHandler();
229
229
  |---|---|
230
230
  | valid key | 200, cached 60 s (`status: "fresh"` then `"cached"`) |
231
231
  | revoke push arrived | the very next call is 401, even inside the 60 s (and an answer in flight when it landed is not re-cached) |
232
+ | app switched back on after a revoke push (1.5.1) | admitted on the next call: a 200 to a question asked AFTER the push clears the tombstone (the grant id is stable across off/on) |
232
233
  | zoo-people says `unknown-or-revoked` | 401, cache + last-known-good dropped |
233
234
  | zoo-people down, key answered valid in the last 7 days | 200 (`status: "stale"`) |
234
235
  | zoo-people down, key unknown | refused — **503 by default**, never 401 (zoo-health-ios forgets its key on a 401). `outageStatus: 401` opts out. |
@@ -187,6 +187,7 @@ function createDevices(options = {}) {
187
187
  }
188
188
  return refuse(o.outageStatus, `zoo-people unavailable (${why}) and key not cached`);
189
189
  };
190
+ const askedAt = now();
190
191
  const res = await post(exports.DEVICES_PATHS.resolve, { key });
191
192
  if (res.kind === "failed")
192
193
  return outage(res.error);
@@ -196,8 +197,17 @@ function createDevices(options = {}) {
196
197
  if (!identity)
197
198
  return outage("malformed answer");
198
199
  if (revoked(identity.device.id)) {
199
- cache.delete(h);
200
- return refuse(401, "device revoked");
200
+ // The tombstone exists to stop an answer that was IN FLIGHT when the
201
+ // revoke push landed from re-caching. A 200 to a question asked AFTER
202
+ // the push is zoo-people's current word — the app was switched back on
203
+ // (BP#149 P3: the grant id is stable, so without this a re-granted app
204
+ // answered 401 for 10 minutes and a phone could forget its key).
205
+ const t = tombstones.get(identity.device.id) ?? 0;
206
+ if (t >= askedAt) {
207
+ cache.delete(h);
208
+ return refuse(401, "device revoked");
209
+ }
210
+ tombstones.delete(identity.device.id);
201
211
  }
202
212
  if (options.app && identity.app !== options.app) {
203
213
  cache.delete(h);
@@ -1,5 +1,5 @@
1
1
  /** The kit's own version — reported as `kit` by the health handler. */
2
- export declare const KIT_VERSION = "1.5.0";
2
+ export declare const KIT_VERSION = "1.5.1";
3
3
  /** The exact keys a v1 Person may carry; anything else is dropped. */
4
4
  export declare const PERSON_KEYS: readonly ["authentikUsername", "dob", "enabled", "haEntityId", "headingColor", "id", "kind", "name", "photoUrl", "role", "slug", "sortOrder", "traccarDeviceId"];
5
5
  export declare const NOTIFY_PRIORITIES: readonly ["passive", "active", "time-sensitive", "critical"];
@@ -4,7 +4,7 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.SLUG_PATTERN = exports.NOTIFY_PRIORITIES = exports.PERSON_KEYS = exports.KIT_VERSION = void 0;
6
6
  /** The kit's own version — reported as `kit` by the health handler. */
7
- exports.KIT_VERSION = "1.5.0";
7
+ exports.KIT_VERSION = "1.5.1";
8
8
  /** The exact keys a v1 Person may carry; anything else is dropped. */
9
9
  exports.PERSON_KEYS = ["authentikUsername", "dob", "enabled", "haEntityId", "headingColor", "id", "kind", "name", "photoUrl", "role", "slug", "sortOrder", "traccarDeviceId"];
10
10
  exports.NOTIFY_PRIORITIES = ["passive", "active", "time-sensitive", "critical"];
package/dist/devices.js CHANGED
@@ -183,6 +183,7 @@ export function createDevices(options = {}) {
183
183
  }
184
184
  return refuse(o.outageStatus, `zoo-people unavailable (${why}) and key not cached`);
185
185
  };
186
+ const askedAt = now();
186
187
  const res = await post(DEVICES_PATHS.resolve, { key });
187
188
  if (res.kind === "failed")
188
189
  return outage(res.error);
@@ -192,8 +193,17 @@ export function createDevices(options = {}) {
192
193
  if (!identity)
193
194
  return outage("malformed answer");
194
195
  if (revoked(identity.device.id)) {
195
- cache.delete(h);
196
- return refuse(401, "device revoked");
196
+ // The tombstone exists to stop an answer that was IN FLIGHT when the
197
+ // revoke push landed from re-caching. A 200 to a question asked AFTER
198
+ // the push is zoo-people's current word — the app was switched back on
199
+ // (BP#149 P3: the grant id is stable, so without this a re-granted app
200
+ // answered 401 for 10 minutes and a phone could forget its key).
201
+ const t = tombstones.get(identity.device.id) ?? 0;
202
+ if (t >= askedAt) {
203
+ cache.delete(h);
204
+ return refuse(401, "device revoked");
205
+ }
206
+ tombstones.delete(identity.device.id);
197
207
  }
198
208
  if (options.app && identity.app !== options.app) {
199
209
  cache.delete(h);
@@ -1,5 +1,5 @@
1
1
  /** The kit's own version — reported as `kit` by the health handler. */
2
- export declare const KIT_VERSION = "1.5.0";
2
+ export declare const KIT_VERSION = "1.5.1";
3
3
  /** The exact keys a v1 Person may carry; anything else is dropped. */
4
4
  export declare const PERSON_KEYS: readonly ["authentikUsername", "dob", "enabled", "haEntityId", "headingColor", "id", "kind", "name", "photoUrl", "role", "slug", "sortOrder", "traccarDeviceId"];
5
5
  export declare const NOTIFY_PRIORITIES: readonly ["passive", "active", "time-sensitive", "critical"];
@@ -1,7 +1,7 @@
1
1
  // GENERATED by packages/zoo-kit/scripts/generate.mjs from contracts/v1/*.v1.yaml + packages/zoo-kit/package.json.
2
2
  // Do not edit — change the contract and run `npm run gen`.
3
3
  /** The kit's own version — reported as `kit` by the health handler. */
4
- export const KIT_VERSION = "1.5.0";
4
+ export const KIT_VERSION = "1.5.1";
5
5
  /** The exact keys a v1 Person may carry; anything else is dropped. */
6
6
  export const PERSON_KEYS = ["authentikUsername", "dob", "enabled", "haEntityId", "headingColor", "id", "kind", "name", "photoUrl", "role", "slug", "sortOrder", "traccarDeviceId"];
7
7
  export const NOTIFY_PRIORITIES = ["passive", "active", "time-sensitive", "critical"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jdcpuwiz/zoo-kit",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Thin, pinned server-side client for the homelab's shared services: notify, whoami, people, health, app keys.",
5
5
  "license": "MIT",
6
6
  "type": "module",