@jdcpuwiz/zoo-kit 1.4.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 +14 -0
- package/dist/cjs/devices.d.ts +20 -1
- package/dist/cjs/devices.js +36 -4
- package/dist/cjs/generated/contract.d.ts +1 -1
- package/dist/cjs/generated/contract.js +1 -1
- package/dist/cjs/whoami.d.ts +6 -0
- package/dist/cjs/whoami.js +4 -0
- package/dist/devices.d.ts +20 -1
- package/dist/devices.js +36 -4
- package/dist/generated/contract.d.ts +1 -1
- package/dist/generated/contract.js +1 -1
- package/dist/whoami.d.ts +6 -0
- package/dist/whoami.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -229,12 +229,26 @@ 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. |
|
|
235
236
|
| zoo-people refuses THIS app's key | treated as an outage (warned once), never as the phone's 401 |
|
|
236
237
|
| `app` set and the answer is another app's device | 401 |
|
|
237
238
|
|
|
239
|
+
### One pairing per device (1.5.0, additive — BP#149 P2)
|
|
240
|
+
|
|
241
|
+
zoo-people (≥0.23.0) also issues ONE `zd_` key per physical device; Wiz switches
|
|
242
|
+
apps on per device. The same `resolve` call takes it. New on `identity.device`:
|
|
243
|
+
`physicalDeviceId` (null for a legacy per-app key), `deviceName` (the physical
|
|
244
|
+
device's name) and `role` (the role/profile on this app's grant; = `appRole`).
|
|
245
|
+
`device.id` is the grant id, which is what zoo-people's revoke push carries.
|
|
246
|
+
|
|
247
|
+
| Situation | Answer |
|
|
248
|
+
|---|---|
|
|
249
|
+
| live `zd_` key, this app NOT switched on | **403** `reason:"not granted"` + `notGranted:{app, appLabel, deviceName}` — the phone KEEPS its key and shows "Ask Wiz to turn on <appLabel>"; never cached, so a grant takes effect on the next call. `requirePerson` throws `ZooKitAuthError(403)`. |
|
|
250
|
+
| any 401 from zoo-people | re-resolved ONCE before it is final (a grant or pairing written a moment ago never costs the phone its key) |
|
|
251
|
+
|
|
238
252
|
Keys live in memory only as sha256 hashes; `redeem` goes to the primary URL
|
|
239
253
|
only (a timed-out redeem may have landed) and primes the cache with the new
|
|
240
254
|
device. `selfRevoke(key)` forwards a phone's own Unpair. `ZooKitAuthError.status`
|
package/dist/cjs/devices.d.ts
CHANGED
|
@@ -27,9 +27,16 @@ export interface DevicePerson {
|
|
|
27
27
|
enabled: boolean;
|
|
28
28
|
}
|
|
29
29
|
export interface DeviceInfo {
|
|
30
|
+
/** The app's handle for this device: the legacy per-app Device id, or the DeviceGrant id for a `zd_` key. Revoke pushes carry this. */
|
|
30
31
|
id: string;
|
|
31
32
|
name: string;
|
|
32
33
|
appRole: string | null;
|
|
34
|
+
/** BP#149: the physical device (one pairing per phone/TV). Null for a legacy per-app key. */
|
|
35
|
+
physicalDeviceId: string | null;
|
|
36
|
+
/** BP#149: the physical device's name ("Shad's iPhone"); the per-app name for a legacy key. */
|
|
37
|
+
deviceName: string;
|
|
38
|
+
/** BP#149: the role/profile Wiz set on this app's grant (= appRole). */
|
|
39
|
+
role: string | null;
|
|
33
40
|
}
|
|
34
41
|
export interface DeviceIdentity {
|
|
35
42
|
kind: "person";
|
|
@@ -42,14 +49,26 @@ export interface DeviceIdentity {
|
|
|
42
49
|
}
|
|
43
50
|
/** fresh = zoo-people just said so; cached = inside the 60 s; stale = last-known-good during an outage. */
|
|
44
51
|
export type DeviceStatus = "fresh" | "cached" | "stale";
|
|
52
|
+
/**
|
|
53
|
+
* A refusal. 401 = the key is unknown or revoked (the phone may forget it).
|
|
54
|
+
* 403 = BP#149 "not granted": a live one-pairing (`zd_`) key whose device does
|
|
55
|
+
* not have THIS app switched on — the phone must KEEP its key and show
|
|
56
|
+
* "Ask Wiz to turn on <appLabel>"; once Wiz grants it the next call is admitted
|
|
57
|
+
* with no re-pair. 503 = zoo-people unreachable and the key not cached.
|
|
58
|
+
*/
|
|
45
59
|
export type DeviceVerdict = {
|
|
46
60
|
ok: true;
|
|
47
61
|
identity: DeviceIdentity;
|
|
48
62
|
status: DeviceStatus;
|
|
49
63
|
} | {
|
|
50
64
|
ok: false;
|
|
51
|
-
status: 401 | 503;
|
|
65
|
+
status: 401 | 403 | 503;
|
|
52
66
|
reason: string;
|
|
67
|
+
notGranted?: {
|
|
68
|
+
app: string;
|
|
69
|
+
appLabel: string;
|
|
70
|
+
deviceName: string;
|
|
71
|
+
};
|
|
53
72
|
};
|
|
54
73
|
export interface RedeemOptions {
|
|
55
74
|
deviceName?: string;
|
package/dist/cjs/devices.js
CHANGED
|
@@ -98,13 +98,21 @@ function toIdentity(raw) {
|
|
|
98
98
|
const person = toPersonPart(r.person);
|
|
99
99
|
if (!person || !str(r.deviceId) || !str(r.app))
|
|
100
100
|
return null;
|
|
101
|
+
const appRole = typeof r.appRole === "string" ? r.appRole : null;
|
|
101
102
|
return {
|
|
102
103
|
kind: "person",
|
|
103
104
|
via: "device",
|
|
104
105
|
slug: person.slug,
|
|
105
106
|
personId: person.id,
|
|
106
107
|
app: str(r.app),
|
|
107
|
-
device: {
|
|
108
|
+
device: {
|
|
109
|
+
id: str(r.deviceId),
|
|
110
|
+
name: str(r.name),
|
|
111
|
+
appRole,
|
|
112
|
+
physicalDeviceId: str(r.physicalDeviceId) || null,
|
|
113
|
+
deviceName: str(r.deviceName) || str(r.name),
|
|
114
|
+
role: appRole,
|
|
115
|
+
},
|
|
108
116
|
person,
|
|
109
117
|
};
|
|
110
118
|
}
|
|
@@ -172,13 +180,14 @@ function createDevices(options = {}) {
|
|
|
172
180
|
return { kind: "failed", error: out.error };
|
|
173
181
|
return { kind: "response", status: out.res.status, json: await (0, http_js_1.readJson)(out.res) };
|
|
174
182
|
}
|
|
175
|
-
async function lookup(key, h, prev) {
|
|
183
|
+
async function lookup(key, h, prev, retried = false) {
|
|
176
184
|
const outage = (why) => {
|
|
177
185
|
if (prev && now() - prev.at < o.staleMs && !revoked(prev.identity.device.id)) {
|
|
178
186
|
return { ok: true, identity: prev.identity, status: "stale" };
|
|
179
187
|
}
|
|
180
188
|
return refuse(o.outageStatus, `zoo-people unavailable (${why}) and key not cached`);
|
|
181
189
|
};
|
|
190
|
+
const askedAt = now();
|
|
182
191
|
const res = await post(exports.DEVICES_PATHS.resolve, { key });
|
|
183
192
|
if (res.kind === "failed")
|
|
184
193
|
return outage(res.error);
|
|
@@ -188,8 +197,17 @@ function createDevices(options = {}) {
|
|
|
188
197
|
if (!identity)
|
|
189
198
|
return outage("malformed answer");
|
|
190
199
|
if (revoked(identity.device.id)) {
|
|
191
|
-
|
|
192
|
-
|
|
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);
|
|
193
211
|
}
|
|
194
212
|
if (options.app && identity.app !== options.app) {
|
|
195
213
|
cache.delete(h);
|
|
@@ -203,7 +221,21 @@ function createDevices(options = {}) {
|
|
|
203
221
|
return { ok: true, identity, status: "fresh" };
|
|
204
222
|
}
|
|
205
223
|
if (res.status === 401 && err === "unknown-or-revoked") {
|
|
224
|
+
// BP#149: re-resolve ONCE before a 401 is final — a grant switched on (or
|
|
225
|
+
// a fresh pairing written) a moment ago must not cost the phone its key.
|
|
226
|
+
if (!retried)
|
|
227
|
+
return lookup(key, h, prev, true);
|
|
206
228
|
cache.delete(h);
|
|
229
|
+
const j = (res.json ?? {});
|
|
230
|
+
if (str(j.reason) === "not-granted") {
|
|
231
|
+
const app = str(j.app) || options.app || "";
|
|
232
|
+
return {
|
|
233
|
+
ok: false,
|
|
234
|
+
status: 403,
|
|
235
|
+
reason: "not granted",
|
|
236
|
+
notGranted: { app, appLabel: str(j.appLabel) || app, deviceName: str(j.deviceName) },
|
|
237
|
+
};
|
|
238
|
+
}
|
|
207
239
|
return refuse(401, "unknown or revoked device");
|
|
208
240
|
}
|
|
209
241
|
// Any other answer (our own app key refused, a 4xx we don't know) is OUR
|
|
@@ -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.
|
|
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.
|
|
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/cjs/whoami.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ export interface Anonymous {
|
|
|
19
19
|
reason?: string;
|
|
20
20
|
/** True when the answer is "could not check" (zoo-people down) rather than "no" — requirePerson answers 503. */
|
|
21
21
|
unavailable?: boolean;
|
|
22
|
+
/** BP#149: a live one-pairing key whose device doesn't have this app switched on (keep the key; ask Wiz). */
|
|
23
|
+
notGranted?: {
|
|
24
|
+
app: string;
|
|
25
|
+
appLabel: string;
|
|
26
|
+
deviceName: string;
|
|
27
|
+
};
|
|
22
28
|
}
|
|
23
29
|
export type Identity = PersonIdentity | AppIdentity | Anonymous;
|
|
24
30
|
export interface AuthentikOptions {
|
package/dist/cjs/whoami.js
CHANGED
|
@@ -124,6 +124,8 @@ async function whoami(req, opts = {}) {
|
|
|
124
124
|
}
|
|
125
125
|
if (v.status === 503)
|
|
126
126
|
return { kind: "anonymous", reason: v.reason, unavailable: true };
|
|
127
|
+
if (v.status === 403)
|
|
128
|
+
return { kind: "anonymous", reason: v.reason, notGranted: v.notGranted };
|
|
127
129
|
if (!opts.resolveDeviceKey)
|
|
128
130
|
return { kind: "anonymous", reason: v.reason };
|
|
129
131
|
}
|
|
@@ -201,6 +203,8 @@ async function requirePerson(req, opts = {}) {
|
|
|
201
203
|
return who;
|
|
202
204
|
if (who.kind === "anonymous" && who.unavailable)
|
|
203
205
|
throw new ZooKitAuthError(503, who.reason ?? "");
|
|
206
|
+
if (who.kind === "anonymous" && who.notGranted)
|
|
207
|
+
throw new ZooKitAuthError(403, "not granted");
|
|
204
208
|
throw new ZooKitAuthError(401, who.kind === "anonymous" ? (who.reason ?? "") : "an app key is not a person");
|
|
205
209
|
}
|
|
206
210
|
/**
|
package/dist/devices.d.ts
CHANGED
|
@@ -27,9 +27,16 @@ export interface DevicePerson {
|
|
|
27
27
|
enabled: boolean;
|
|
28
28
|
}
|
|
29
29
|
export interface DeviceInfo {
|
|
30
|
+
/** The app's handle for this device: the legacy per-app Device id, or the DeviceGrant id for a `zd_` key. Revoke pushes carry this. */
|
|
30
31
|
id: string;
|
|
31
32
|
name: string;
|
|
32
33
|
appRole: string | null;
|
|
34
|
+
/** BP#149: the physical device (one pairing per phone/TV). Null for a legacy per-app key. */
|
|
35
|
+
physicalDeviceId: string | null;
|
|
36
|
+
/** BP#149: the physical device's name ("Shad's iPhone"); the per-app name for a legacy key. */
|
|
37
|
+
deviceName: string;
|
|
38
|
+
/** BP#149: the role/profile Wiz set on this app's grant (= appRole). */
|
|
39
|
+
role: string | null;
|
|
33
40
|
}
|
|
34
41
|
export interface DeviceIdentity {
|
|
35
42
|
kind: "person";
|
|
@@ -42,14 +49,26 @@ export interface DeviceIdentity {
|
|
|
42
49
|
}
|
|
43
50
|
/** fresh = zoo-people just said so; cached = inside the 60 s; stale = last-known-good during an outage. */
|
|
44
51
|
export type DeviceStatus = "fresh" | "cached" | "stale";
|
|
52
|
+
/**
|
|
53
|
+
* A refusal. 401 = the key is unknown or revoked (the phone may forget it).
|
|
54
|
+
* 403 = BP#149 "not granted": a live one-pairing (`zd_`) key whose device does
|
|
55
|
+
* not have THIS app switched on — the phone must KEEP its key and show
|
|
56
|
+
* "Ask Wiz to turn on <appLabel>"; once Wiz grants it the next call is admitted
|
|
57
|
+
* with no re-pair. 503 = zoo-people unreachable and the key not cached.
|
|
58
|
+
*/
|
|
45
59
|
export type DeviceVerdict = {
|
|
46
60
|
ok: true;
|
|
47
61
|
identity: DeviceIdentity;
|
|
48
62
|
status: DeviceStatus;
|
|
49
63
|
} | {
|
|
50
64
|
ok: false;
|
|
51
|
-
status: 401 | 503;
|
|
65
|
+
status: 401 | 403 | 503;
|
|
52
66
|
reason: string;
|
|
67
|
+
notGranted?: {
|
|
68
|
+
app: string;
|
|
69
|
+
appLabel: string;
|
|
70
|
+
deviceName: string;
|
|
71
|
+
};
|
|
53
72
|
};
|
|
54
73
|
export interface RedeemOptions {
|
|
55
74
|
deviceName?: string;
|
package/dist/devices.js
CHANGED
|
@@ -94,13 +94,21 @@ function toIdentity(raw) {
|
|
|
94
94
|
const person = toPersonPart(r.person);
|
|
95
95
|
if (!person || !str(r.deviceId) || !str(r.app))
|
|
96
96
|
return null;
|
|
97
|
+
const appRole = typeof r.appRole === "string" ? r.appRole : null;
|
|
97
98
|
return {
|
|
98
99
|
kind: "person",
|
|
99
100
|
via: "device",
|
|
100
101
|
slug: person.slug,
|
|
101
102
|
personId: person.id,
|
|
102
103
|
app: str(r.app),
|
|
103
|
-
device: {
|
|
104
|
+
device: {
|
|
105
|
+
id: str(r.deviceId),
|
|
106
|
+
name: str(r.name),
|
|
107
|
+
appRole,
|
|
108
|
+
physicalDeviceId: str(r.physicalDeviceId) || null,
|
|
109
|
+
deviceName: str(r.deviceName) || str(r.name),
|
|
110
|
+
role: appRole,
|
|
111
|
+
},
|
|
104
112
|
person,
|
|
105
113
|
};
|
|
106
114
|
}
|
|
@@ -168,13 +176,14 @@ export function createDevices(options = {}) {
|
|
|
168
176
|
return { kind: "failed", error: out.error };
|
|
169
177
|
return { kind: "response", status: out.res.status, json: await readJson(out.res) };
|
|
170
178
|
}
|
|
171
|
-
async function lookup(key, h, prev) {
|
|
179
|
+
async function lookup(key, h, prev, retried = false) {
|
|
172
180
|
const outage = (why) => {
|
|
173
181
|
if (prev && now() - prev.at < o.staleMs && !revoked(prev.identity.device.id)) {
|
|
174
182
|
return { ok: true, identity: prev.identity, status: "stale" };
|
|
175
183
|
}
|
|
176
184
|
return refuse(o.outageStatus, `zoo-people unavailable (${why}) and key not cached`);
|
|
177
185
|
};
|
|
186
|
+
const askedAt = now();
|
|
178
187
|
const res = await post(DEVICES_PATHS.resolve, { key });
|
|
179
188
|
if (res.kind === "failed")
|
|
180
189
|
return outage(res.error);
|
|
@@ -184,8 +193,17 @@ export function createDevices(options = {}) {
|
|
|
184
193
|
if (!identity)
|
|
185
194
|
return outage("malformed answer");
|
|
186
195
|
if (revoked(identity.device.id)) {
|
|
187
|
-
|
|
188
|
-
|
|
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);
|
|
189
207
|
}
|
|
190
208
|
if (options.app && identity.app !== options.app) {
|
|
191
209
|
cache.delete(h);
|
|
@@ -199,7 +217,21 @@ export function createDevices(options = {}) {
|
|
|
199
217
|
return { ok: true, identity, status: "fresh" };
|
|
200
218
|
}
|
|
201
219
|
if (res.status === 401 && err === "unknown-or-revoked") {
|
|
220
|
+
// BP#149: re-resolve ONCE before a 401 is final — a grant switched on (or
|
|
221
|
+
// a fresh pairing written) a moment ago must not cost the phone its key.
|
|
222
|
+
if (!retried)
|
|
223
|
+
return lookup(key, h, prev, true);
|
|
202
224
|
cache.delete(h);
|
|
225
|
+
const j = (res.json ?? {});
|
|
226
|
+
if (str(j.reason) === "not-granted") {
|
|
227
|
+
const app = str(j.app) || options.app || "";
|
|
228
|
+
return {
|
|
229
|
+
ok: false,
|
|
230
|
+
status: 403,
|
|
231
|
+
reason: "not granted",
|
|
232
|
+
notGranted: { app, appLabel: str(j.appLabel) || app, deviceName: str(j.deviceName) },
|
|
233
|
+
};
|
|
234
|
+
}
|
|
203
235
|
return refuse(401, "unknown or revoked device");
|
|
204
236
|
}
|
|
205
237
|
// Any other answer (our own app key refused, a 4xx we don't know) is OUR
|
|
@@ -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.
|
|
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.
|
|
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/dist/whoami.d.ts
CHANGED
|
@@ -19,6 +19,12 @@ export interface Anonymous {
|
|
|
19
19
|
reason?: string;
|
|
20
20
|
/** True when the answer is "could not check" (zoo-people down) rather than "no" — requirePerson answers 503. */
|
|
21
21
|
unavailable?: boolean;
|
|
22
|
+
/** BP#149: a live one-pairing key whose device doesn't have this app switched on (keep the key; ask Wiz). */
|
|
23
|
+
notGranted?: {
|
|
24
|
+
app: string;
|
|
25
|
+
appLabel: string;
|
|
26
|
+
deviceName: string;
|
|
27
|
+
};
|
|
22
28
|
}
|
|
23
29
|
export type Identity = PersonIdentity | AppIdentity | Anonymous;
|
|
24
30
|
export interface AuthentikOptions {
|
package/dist/whoami.js
CHANGED
|
@@ -115,6 +115,8 @@ export async function whoami(req, opts = {}) {
|
|
|
115
115
|
}
|
|
116
116
|
if (v.status === 503)
|
|
117
117
|
return { kind: "anonymous", reason: v.reason, unavailable: true };
|
|
118
|
+
if (v.status === 403)
|
|
119
|
+
return { kind: "anonymous", reason: v.reason, notGranted: v.notGranted };
|
|
118
120
|
if (!opts.resolveDeviceKey)
|
|
119
121
|
return { kind: "anonymous", reason: v.reason };
|
|
120
122
|
}
|
|
@@ -191,6 +193,8 @@ export async function requirePerson(req, opts = {}) {
|
|
|
191
193
|
return who;
|
|
192
194
|
if (who.kind === "anonymous" && who.unavailable)
|
|
193
195
|
throw new ZooKitAuthError(503, who.reason ?? "");
|
|
196
|
+
if (who.kind === "anonymous" && who.notGranted)
|
|
197
|
+
throw new ZooKitAuthError(403, "not granted");
|
|
194
198
|
throw new ZooKitAuthError(401, who.kind === "anonymous" ? (who.reason ?? "") : "an app key is not a person");
|
|
195
199
|
}
|
|
196
200
|
/**
|
package/package.json
CHANGED