@jdcpuwiz/zoo-kit 1.3.0 → 1.4.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
@@ -178,6 +178,20 @@ Answers are cached 5 min and served stale ≤15 min while the directory is down.
178
178
  `People` itself is unchanged; the extra member lives on `PeopleClient`, so a
179
179
  hand-rolled `People` stub still type-checks.
180
180
 
181
+ ### people.signature (1.4.0, additive — BP#130 S8a)
182
+
183
+ A person's one signature, set on their zoo-people profile (draw, type or
184
+ upload; a PNG with a transparent background):
185
+
186
+ ```ts
187
+ const s = await people.signature("shad"); // {status: ok|none|unavailable|unconfigured, png, sha256, error?}
188
+ ```
189
+
190
+ `GET /api/v1/people/{slug}/signature` on the same `ZOO_PEOPLE_URLS` with the
191
+ same token. zoo-people admits it on its OWN caller list (`SIGNATURE_CALLERS`,
192
+ default `timesheet`, `zoo-studio`); any other key gets 401. Never cached, never
193
+ throws.
194
+
181
195
  ## devices (1.3.0, additive — BP#129 P10c)
182
196
 
183
197
  One device pairing for the fleet: zoo-people owns every paired phone; an app
@@ -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.3.0";
2
+ export declare const KIT_VERSION = "1.4.0";
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.3.0";
7
+ exports.KIT_VERSION = "1.4.0";
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"];
@@ -12,7 +12,7 @@
12
12
  export { ENV, appKeyEnv, appKeyForEnv, appUrlsEnv, checkConfig, envSuffix, type ConfigReport } from "./env.js";
13
13
  export { CATEGORIES, CATEGORY_ALIASES, CATEGORY_SLUGS, canonicalCategory, customCategory, isCanonicalCategory, isCategoryAlias, toCategory, type CategoryAlias, type CategoryInput, type CustomCategory, type NotifyCategory, } from "./categories.js";
14
14
  export { NOTIFY_DEFAULTS, NOTIFY_PATH, dedupeKey, notify, notifyConfigured, type NotifyAction, type NotifyDryRun, type NotifyFailed, type NotifyInput, type NotifyOptions, type NotifyPriority, type NotifyResult, type NotifySent, } from "./notify.js";
15
- export { PEOPLE_DEFAULTS, PEOPLE_PATHS, createPeople, people, toPerson, type Contact, type Contacts, type ContactsResult, type ContactsStatus, type People, type PeopleClient, type PeopleList, type PeopleOptions, type PeopleStatus, type Person, type ResolveStatus, type ResolvedUsername, } from "./people.js";
15
+ export { PEOPLE_DEFAULTS, PEOPLE_PATHS, createPeople, people, toPerson, type Contact, type Contacts, type ContactsResult, type ContactsStatus, type People, type PeopleClient, type SignatureResult, type PeopleList, type PeopleOptions, type PeopleStatus, type Person, type ResolveStatus, type ResolvedUsername, } from "./people.js";
16
16
  export { DEVICES_DEFAULTS, DEVICES_PATHS, DEVICE_REVOKE_PATH, createDevices, devices, type DeviceIdentity, type DeviceInfo, type DevicePerson, type DeviceStatus, type DeviceVerdict, type Devices, type DevicesOptions, type RedeemOptions, type RedeemResult, } from "./devices.js";
17
17
  export { ZooKitAuthError, cameThroughGate, gateSecretOk, readAuthentikUsername, requireApp, requirePerson, whoami, type Anonymous, type AuthentikOptions, type DeviceAnswer, type Identity, type PersonIdentity, type SessionAnswer, type WhoamiOptions, } from "./whoami.js";
18
18
  export { ZooKitConfigError, bearerOf, callApp, checkApp, safeEqual, type AppIdentity, type AppVerdict, type CallAppOptions, type HeaderBag, type RequestLike, } from "./keys.js";
@@ -39,6 +39,7 @@ export declare const PEOPLE_PATHS: {
39
39
  readonly list: "/api/v1/people";
40
40
  readonly whoamiResolve: "/api/v1/whoami-resolve";
41
41
  readonly contactsSearch: "/api/v1/contacts/search";
42
+ readonly signature: (slug: string) => string;
42
43
  };
43
44
  /**
44
45
  * A card from the directory's Contacts book (v1.2, additive — BP#127 P9c).
@@ -91,7 +92,21 @@ export interface People {
91
92
  export type PeopleClient = People & {
92
93
  /** Search Wiz's own Contacts book through the directory. */
93
94
  contacts: Contacts;
95
+ /**
96
+ * A person's signature PNG (transparent background) — v1.4, additive, BP#130 S8a.
97
+ * zoo-people admits it on its OWN caller list (`SIGNATURE_CALLERS`: timesheet,
98
+ * zoo-studio). Never throws; never cached (a person can redraw it any time).
99
+ */
100
+ signature(slug: string): Promise<SignatureResult>;
94
101
  };
102
+ /** `status`: ok = png set; none = that person has no signature (or no such person). */
103
+ export interface SignatureResult {
104
+ status: "ok" | "none" | "unavailable" | "unconfigured";
105
+ png: Uint8Array | null;
106
+ /** Hex sha256 of `png`, as zoo-people reports it (ETag). */
107
+ sha256: string | null;
108
+ error?: string;
109
+ }
95
110
  /** A people client with its own cache. Most apps use the shared {@link people}. */
96
111
  export declare function createPeople(options?: PeopleOptions): PeopleClient;
97
112
  /** The process-wide people client. */
@@ -38,6 +38,7 @@ exports.PEOPLE_PATHS = {
38
38
  list: "/api/v1/people",
39
39
  whoamiResolve: "/api/v1/whoami-resolve",
40
40
  contactsSearch: "/api/v1/contacts/search",
41
+ signature: (slug) => `/api/v1/people/${encodeURIComponent(slug)}/signature`,
41
42
  };
42
43
  function toContact(raw) {
43
44
  if (!raw || typeof raw !== "object")
@@ -213,6 +214,30 @@ function createPeople(options = {}) {
213
214
  return r.contacts.find((c) => c.emails.includes(e)) ?? null;
214
215
  },
215
216
  },
217
+ async signature(slug) {
218
+ const sl = (slug ?? "").trim().toLowerCase();
219
+ if (!sl)
220
+ return { status: "none", png: null, sha256: null };
221
+ const c = config();
222
+ if (c.missing.length) {
223
+ (0, env_js_1.warnOnce)("people-unconfigured", `people is unavailable: ${c.missing.join(", ")} not set`);
224
+ return { status: "unconfigured", png: null, sha256: null, error: `not configured: ${c.missing.join(", ")} not set` };
225
+ }
226
+ const outcome = await (0, http_js_1.failoverFetch)(c.urls, exports.PEOPLE_PATHS.signature(sl), { method: "GET", headers: { Authorization: `Bearer ${c.token}`, Accept: "image/png" } }, o);
227
+ if (outcome.kind === "failed")
228
+ return { status: "unavailable", png: null, sha256: null, error: outcome.error };
229
+ const { res } = outcome;
230
+ if (res.status === 404)
231
+ return { status: "none", png: null, sha256: null };
232
+ if (!res.ok || !(res.headers.get("content-type") ?? "").startsWith("image/png")) {
233
+ if (!res.ok)
234
+ (0, env_js_1.warnOnce)(`people-signature-${res.status}`, `the people directory refused a signature read (${res.status}) — is this app in zoo-people's SIGNATURE_CALLERS?`);
235
+ return { status: "unavailable", png: null, sha256: null, error: `HTTP ${res.status}` };
236
+ }
237
+ const png = new Uint8Array(await res.arrayBuffer());
238
+ const sha = res.headers.get("x-signature-sha256") ?? ((res.headers.get("etag") ?? "").replace(/"/g, "") || null);
239
+ return { status: "ok", png, sha256: sha };
240
+ },
216
241
  clear() {
217
242
  listCache = null;
218
243
  users.clear();
@@ -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.3.0";
2
+ export declare const KIT_VERSION = "1.4.0";
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.3.0";
4
+ export const KIT_VERSION = "1.4.0";
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/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  export { ENV, appKeyEnv, appKeyForEnv, appUrlsEnv, checkConfig, envSuffix, type ConfigReport } from "./env.js";
13
13
  export { CATEGORIES, CATEGORY_ALIASES, CATEGORY_SLUGS, canonicalCategory, customCategory, isCanonicalCategory, isCategoryAlias, toCategory, type CategoryAlias, type CategoryInput, type CustomCategory, type NotifyCategory, } from "./categories.js";
14
14
  export { NOTIFY_DEFAULTS, NOTIFY_PATH, dedupeKey, notify, notifyConfigured, type NotifyAction, type NotifyDryRun, type NotifyFailed, type NotifyInput, type NotifyOptions, type NotifyPriority, type NotifyResult, type NotifySent, } from "./notify.js";
15
- export { PEOPLE_DEFAULTS, PEOPLE_PATHS, createPeople, people, toPerson, type Contact, type Contacts, type ContactsResult, type ContactsStatus, type People, type PeopleClient, type PeopleList, type PeopleOptions, type PeopleStatus, type Person, type ResolveStatus, type ResolvedUsername, } from "./people.js";
15
+ export { PEOPLE_DEFAULTS, PEOPLE_PATHS, createPeople, people, toPerson, type Contact, type Contacts, type ContactsResult, type ContactsStatus, type People, type PeopleClient, type SignatureResult, type PeopleList, type PeopleOptions, type PeopleStatus, type Person, type ResolveStatus, type ResolvedUsername, } from "./people.js";
16
16
  export { DEVICES_DEFAULTS, DEVICES_PATHS, DEVICE_REVOKE_PATH, createDevices, devices, type DeviceIdentity, type DeviceInfo, type DevicePerson, type DeviceStatus, type DeviceVerdict, type Devices, type DevicesOptions, type RedeemOptions, type RedeemResult, } from "./devices.js";
17
17
  export { ZooKitAuthError, cameThroughGate, gateSecretOk, readAuthentikUsername, requireApp, requirePerson, whoami, type Anonymous, type AuthentikOptions, type DeviceAnswer, type Identity, type PersonIdentity, type SessionAnswer, type WhoamiOptions, } from "./whoami.js";
18
18
  export { ZooKitConfigError, bearerOf, callApp, checkApp, safeEqual, type AppIdentity, type AppVerdict, type CallAppOptions, type HeaderBag, type RequestLike, } from "./keys.js";
package/dist/people.d.ts CHANGED
@@ -39,6 +39,7 @@ export declare const PEOPLE_PATHS: {
39
39
  readonly list: "/api/v1/people";
40
40
  readonly whoamiResolve: "/api/v1/whoami-resolve";
41
41
  readonly contactsSearch: "/api/v1/contacts/search";
42
+ readonly signature: (slug: string) => string;
42
43
  };
43
44
  /**
44
45
  * A card from the directory's Contacts book (v1.2, additive — BP#127 P9c).
@@ -91,7 +92,21 @@ export interface People {
91
92
  export type PeopleClient = People & {
92
93
  /** Search Wiz's own Contacts book through the directory. */
93
94
  contacts: Contacts;
95
+ /**
96
+ * A person's signature PNG (transparent background) — v1.4, additive, BP#130 S8a.
97
+ * zoo-people admits it on its OWN caller list (`SIGNATURE_CALLERS`: timesheet,
98
+ * zoo-studio). Never throws; never cached (a person can redraw it any time).
99
+ */
100
+ signature(slug: string): Promise<SignatureResult>;
94
101
  };
102
+ /** `status`: ok = png set; none = that person has no signature (or no such person). */
103
+ export interface SignatureResult {
104
+ status: "ok" | "none" | "unavailable" | "unconfigured";
105
+ png: Uint8Array | null;
106
+ /** Hex sha256 of `png`, as zoo-people reports it (ETag). */
107
+ sha256: string | null;
108
+ error?: string;
109
+ }
95
110
  /** A people client with its own cache. Most apps use the shared {@link people}. */
96
111
  export declare function createPeople(options?: PeopleOptions): PeopleClient;
97
112
  /** The process-wide people client. */
package/dist/people.js CHANGED
@@ -33,6 +33,7 @@ export const PEOPLE_PATHS = {
33
33
  list: "/api/v1/people",
34
34
  whoamiResolve: "/api/v1/whoami-resolve",
35
35
  contactsSearch: "/api/v1/contacts/search",
36
+ signature: (slug) => `/api/v1/people/${encodeURIComponent(slug)}/signature`,
36
37
  };
37
38
  function toContact(raw) {
38
39
  if (!raw || typeof raw !== "object")
@@ -208,6 +209,30 @@ export function createPeople(options = {}) {
208
209
  return r.contacts.find((c) => c.emails.includes(e)) ?? null;
209
210
  },
210
211
  },
212
+ async signature(slug) {
213
+ const sl = (slug ?? "").trim().toLowerCase();
214
+ if (!sl)
215
+ return { status: "none", png: null, sha256: null };
216
+ const c = config();
217
+ if (c.missing.length) {
218
+ warnOnce("people-unconfigured", `people is unavailable: ${c.missing.join(", ")} not set`);
219
+ return { status: "unconfigured", png: null, sha256: null, error: `not configured: ${c.missing.join(", ")} not set` };
220
+ }
221
+ const outcome = await failoverFetch(c.urls, PEOPLE_PATHS.signature(sl), { method: "GET", headers: { Authorization: `Bearer ${c.token}`, Accept: "image/png" } }, o);
222
+ if (outcome.kind === "failed")
223
+ return { status: "unavailable", png: null, sha256: null, error: outcome.error };
224
+ const { res } = outcome;
225
+ if (res.status === 404)
226
+ return { status: "none", png: null, sha256: null };
227
+ if (!res.ok || !(res.headers.get("content-type") ?? "").startsWith("image/png")) {
228
+ if (!res.ok)
229
+ warnOnce(`people-signature-${res.status}`, `the people directory refused a signature read (${res.status}) — is this app in zoo-people's SIGNATURE_CALLERS?`);
230
+ return { status: "unavailable", png: null, sha256: null, error: `HTTP ${res.status}` };
231
+ }
232
+ const png = new Uint8Array(await res.arrayBuffer());
233
+ const sha = res.headers.get("x-signature-sha256") ?? ((res.headers.get("etag") ?? "").replace(/"/g, "") || null);
234
+ return { status: "ok", png, sha256: sha };
235
+ },
211
236
  clear() {
212
237
  listCache = null;
213
238
  users.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jdcpuwiz/zoo-kit",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
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",