@deveye/types 0.18.2 → 0.19.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/package.json +1 -1
- package/src/domain/device.ts +6 -2
- package/src/domain/featureDomain.ts +46 -0
- package/src/domain/featureRegistry.ts +28 -0
- package/src/domain/home.ts +7 -4
- package/src/domain/live.ts +15 -5
- package/src/domain/project.ts +56 -0
- package/src/domain/report.ts +34 -2
- package/src/domain/secrecy.ts +3 -0
- package/src/domain/twoFactor.ts +7 -3
- package/src/domain/workspace.ts +1 -1
- package/src/domain/workspaceRole.ts +9 -2
- package/src/features/admin.ts +1 -51
- package/src/features/domain.ts +40 -0
- package/src/features/home.ts +1 -1
- package/src/features/links.ts +37 -0
- package/src/features/registry.ts +4 -0
- package/src/features/secrecy.ts +22 -8
- package/src/features/twoFactor.ts +1 -1
- package/src/features/user.ts +32 -4
- package/src/features/workspace.ts +2 -2
- package/src/http/auth.ts +64 -11
- package/src/http/device.ts +14 -10
- package/src/index.ts +65 -10
- package/src/protocol/agent.ts +38 -0
- package/src/protocol/error.ts +3 -0
- package/src/sdk/client-ambient.d.ts +60 -1
- package/src/sdk/client.ts +103 -5
- package/src/sdk/domains.test.ts +30 -0
- package/src/sdk/domains.ts +29 -0
- package/src/sdk/manifest.test.ts +60 -0
- package/src/sdk/manifest.ts +97 -4
- package/src/sdk/providers.ts +126 -4
- package/src/sdk/server.ts +198 -10
- package/src/sdk/testing.test.ts +55 -1
- package/src/sdk/testing.ts +192 -2
package/package.json
CHANGED
package/src/domain/device.ts
CHANGED
|
@@ -120,10 +120,14 @@ export interface DeviceRow {
|
|
|
120
120
|
fingerprint: string;
|
|
121
121
|
platform: string;
|
|
122
122
|
status: DeviceStatus;
|
|
123
|
-
/** X25519 public key (base64) used for command signature verification. */
|
|
124
|
-
public_key: string | null;
|
|
125
123
|
/** SHA-256 hash of the device token (the raw token lives only on the agent). */
|
|
126
124
|
token_hash: string;
|
|
125
|
+
/**
|
|
126
|
+
* Hash of the token being replaced, during a rotation: accepted until the
|
|
127
|
+
* agent has authenticated once with the new one (a rotation frame can be
|
|
128
|
+
* lost in flight), then cleared.
|
|
129
|
+
*/
|
|
130
|
+
token_hash_prev: string | null;
|
|
127
131
|
last_seen: number | null;
|
|
128
132
|
created: number;
|
|
129
133
|
/** Agent version from the last `agent.hello`; null until first connection. */
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A domain name a feature serves under, declared in the feature's settings
|
|
5
|
+
* and verified in two stages: ownership (a TXT record DevEye checks itself),
|
|
6
|
+
* then service (the owning feature's own probe).
|
|
7
|
+
*
|
|
8
|
+
* Host and token travel in the clear: both are published in the DNS.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const DNS_RECORD_TYPES = ['A', 'AAAA', 'CNAME', 'MX', 'TXT', 'SRV'] as const;
|
|
12
|
+
|
|
13
|
+
export const dnsRecordSchema = z.object({
|
|
14
|
+
type: z.enum(DNS_RECORD_TYPES),
|
|
15
|
+
/** Fully qualified, without the trailing dot. */
|
|
16
|
+
name: z.string().min(1).max(255),
|
|
17
|
+
value: z.string().min(1).max(4096),
|
|
18
|
+
/** MX and SRV only. */
|
|
19
|
+
priority: z.number().int().nonnegative().optional()
|
|
20
|
+
});
|
|
21
|
+
export type DnsRecord = z.infer<typeof dnsRecordSchema>;
|
|
22
|
+
|
|
23
|
+
/** `pending` until the first check has run. */
|
|
24
|
+
export const domainStateSchema = z.enum(['pending', 'ok', 'failed']);
|
|
25
|
+
export type DomainState = z.infer<typeof domainStateSchema>;
|
|
26
|
+
|
|
27
|
+
export const FEATURE_DOMAIN_HOST_MAX = 253;
|
|
28
|
+
|
|
29
|
+
export const featureDomainSchema = z.object({
|
|
30
|
+
id: z.number().int().positive(),
|
|
31
|
+
host: z.string().min(1).max(FEATURE_DOMAIN_HOST_MAX),
|
|
32
|
+
/** The TXT record that proves ownership. */
|
|
33
|
+
ownership: dnsRecordSchema,
|
|
34
|
+
/** What the owning feature asks to publish on top of it. */
|
|
35
|
+
records: z.array(dnsRecordSchema),
|
|
36
|
+
dnsState: domainStateSchema,
|
|
37
|
+
dnsError: z.string(),
|
|
38
|
+
probeState: domainStateSchema,
|
|
39
|
+
probeError: z.string(),
|
|
40
|
+
/** Unix seconds. Null until both stages have passed once. */
|
|
41
|
+
verifiedAt: z.number().int().nullable(),
|
|
42
|
+
checkedAt: z.number().int().nullable(),
|
|
43
|
+
/** How many of the feature's items designate this domain. */
|
|
44
|
+
useCount: z.number().int().nonnegative()
|
|
45
|
+
});
|
|
46
|
+
export type FeatureDomain = z.infer<typeof featureDomainSchema>;
|
|
@@ -270,6 +270,18 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
270
270
|
sources: {
|
|
271
271
|
hint: 'La clé d’API du NVD, facultative : sans elle le catalogue se remplit quand même, elle ne fait que relever le quota de requêtes.'
|
|
272
272
|
}
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
id: 'mailserver',
|
|
276
|
+
label: 'Serveur mail',
|
|
277
|
+
description:
|
|
278
|
+
'Lecture : les adresses hébergées et leur activité. Écriture : créer une adresse, régler son quota, déclarer un domaine.',
|
|
279
|
+
icon: 'at',
|
|
280
|
+
notifies: false,
|
|
281
|
+
hasItems: true,
|
|
282
|
+
itemNoun: 'adresse',
|
|
283
|
+
itemNounGender: 'f',
|
|
284
|
+
shareTier: 'open'
|
|
273
285
|
}
|
|
274
286
|
];
|
|
275
287
|
|
|
@@ -391,6 +403,22 @@ export const SHAREABLE_FEATURES: readonly WorkspaceFeatureId[] = FEATURE_REGISTR
|
|
|
391
403
|
*/
|
|
392
404
|
export const SHARE_WIRED_FEATURES: readonly WorkspaceFeatureId[] = ['backup'];
|
|
393
405
|
|
|
406
|
+
/**
|
|
407
|
+
* Celles dont un projet relie les éléments : le module Projets tient une table
|
|
408
|
+
* de liaison par famille, et son contrat d'usage (`PROJECTS_USAGE_PROVIDER`) ne
|
|
409
|
+
* connaît que celles-ci. Partagée entre client et serveur, comme
|
|
410
|
+
* {@link SHARE_WIRED_FEATURES} : le serveur rend une liste vide pour une autre,
|
|
411
|
+
* le client n'affiche pas l'onglet. En relier une de plus, c'est une entrée ici
|
|
412
|
+
* et une dans le `Record` du contrat.
|
|
413
|
+
*/
|
|
414
|
+
export const PROJECT_LINKED_FEATURES: readonly WorkspaceFeatureId[] = [
|
|
415
|
+
'git',
|
|
416
|
+
'database',
|
|
417
|
+
'audience',
|
|
418
|
+
'deploy',
|
|
419
|
+
'uptime'
|
|
420
|
+
];
|
|
421
|
+
|
|
394
422
|
/** Les fonctionnalités qui savent prévenir, dans l'ordre du registre. */
|
|
395
423
|
export const NOTIFYING_FEATURES: readonly WorkspaceFeatureId[] = FEATURE_REGISTRY.filter(
|
|
396
424
|
(f) => f.notifies
|
package/src/domain/home.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
* tenant des tuiles ordonnées de n'importe quels genres (appareil,
|
|
13
13
|
* fonctionnalité, raccourci, dossier). Aucune section par défaut ; l'intitulé
|
|
14
14
|
* est facultatif. Stockée en clair : métadonnée de personnalisation, jamais de
|
|
15
|
-
*
|
|
15
|
+
* contenu utilisateur.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -37,7 +37,8 @@ export const nativeHomeFeatureIdSchema = z.enum([
|
|
|
37
37
|
'finance',
|
|
38
38
|
'audience',
|
|
39
39
|
'osint',
|
|
40
|
-
'cve'
|
|
40
|
+
'cve',
|
|
41
|
+
'mailserver'
|
|
41
42
|
]);
|
|
42
43
|
export type NativeHomeFeatureId = z.infer<typeof nativeHomeFeatureIdSchema>;
|
|
43
44
|
|
|
@@ -107,7 +108,9 @@ export const shortcutItemSchema = z.object({
|
|
|
107
108
|
id: z.string().min(1).max(64),
|
|
108
109
|
/** Unknown/legacy templates degrade to a generic link rather than dropping the tile. */
|
|
109
110
|
template: shortcutTemplateSchema.catch('link'),
|
|
110
|
-
|
|
111
|
+
// http(s) seulement : `z.string().url()` accepte `javascript:` et `data:`, et
|
|
112
|
+
// cette valeur devient le `href` d'une tuile.
|
|
113
|
+
url: z.url({ protocol: /^https?$/ }).max(SHORTCUT_URL_MAX_LENGTH),
|
|
111
114
|
/** Optional: empty → the tile falls back to the fetched name (account, og:title…). */
|
|
112
115
|
title: z.string().max(80),
|
|
113
116
|
description: z.string().max(200).optional(),
|
|
@@ -244,7 +247,7 @@ export const shortcutPreviewSchema = z.object({
|
|
|
244
247
|
ok: z.boolean(),
|
|
245
248
|
title: z.string().nullable(),
|
|
246
249
|
subtitle: z.string().nullable(),
|
|
247
|
-
imageUrl: z.
|
|
250
|
+
imageUrl: z.url({ protocol: /^https?$/ }).nullable(),
|
|
248
251
|
stats: z.array(z.object({ label: z.string(), value: z.string() })).max(4),
|
|
249
252
|
/**
|
|
250
253
|
* Optional live/online status, rendered as a small green/red dot in the tile
|
package/src/domain/live.ts
CHANGED
|
@@ -131,9 +131,9 @@ export const nativeLiveTopicSchema = z.enum([
|
|
|
131
131
|
/** Réglages de compte (avatar, couleur, thème, chiffrement). */
|
|
132
132
|
'account',
|
|
133
133
|
/**
|
|
134
|
-
* Les comptes du site
|
|
135
|
-
*
|
|
136
|
-
*
|
|
134
|
+
* Les comptes du site : ce que la page Utilisateurs montre. Jamais diffusé
|
|
135
|
+
* dans une salle, la page n'appartient à aucun espace : les administrateurs
|
|
136
|
+
* sont visés par compte (`userChanged`).
|
|
137
137
|
*/
|
|
138
138
|
'admin',
|
|
139
139
|
/**
|
|
@@ -142,7 +142,13 @@ export const nativeLiveTopicSchema = z.enum([
|
|
|
142
142
|
* quelle fonctionnalité, et un canal change pour toutes à la fois alors que
|
|
143
143
|
* `mutates` est déclaré par commande.
|
|
144
144
|
*/
|
|
145
|
-
'notify'
|
|
145
|
+
'notify',
|
|
146
|
+
/**
|
|
147
|
+
* Les domaines déclarés par une fonctionnalité de l'espace, et leur état de
|
|
148
|
+
* vérification. À part pour la même raison que `notify` : ils se relisent
|
|
149
|
+
* depuis les réglages de n'importe quelle fonctionnalité qui en gère.
|
|
150
|
+
*/
|
|
151
|
+
'domain'
|
|
146
152
|
]);
|
|
147
153
|
export type NativeLiveTopic = z.infer<typeof nativeLiveTopicSchema>;
|
|
148
154
|
|
|
@@ -193,6 +199,7 @@ export const TOPIC_FEATURE: Record<NativeLiveTopic, WorkspaceFeatureId | null> =
|
|
|
193
199
|
audience: 'audience',
|
|
194
200
|
osint: 'osint',
|
|
195
201
|
cve: 'cve',
|
|
202
|
+
mailserver: 'mailserver',
|
|
196
203
|
workspace: null,
|
|
197
204
|
home: null,
|
|
198
205
|
account: null,
|
|
@@ -201,7 +208,10 @@ export const TOPIC_FEATURE: Record<NativeLiveTopic, WorkspaceFeatureId | null> =
|
|
|
201
208
|
admin: null,
|
|
202
209
|
// Aucun droit de feature à vérifier : la relecture déclenchée est gardée
|
|
203
210
|
// côté commande. Même nature que `workspace`.
|
|
204
|
-
notify: null
|
|
211
|
+
notify: null,
|
|
212
|
+
// Même régime : la trame ne porte aucune donnée, et `domain.list` vérifie
|
|
213
|
+
// le droit sur la fonctionnalité visée.
|
|
214
|
+
domain: null
|
|
205
215
|
};
|
|
206
216
|
|
|
207
217
|
/**
|
package/src/domain/project.ts
CHANGED
|
@@ -7,3 +7,59 @@ import { z } from 'zod';
|
|
|
7
7
|
*/
|
|
8
8
|
export const projectStatusSchema = z.enum(['draft', 'active', 'paused', 'done']);
|
|
9
9
|
export type ProjectStatus = z.infer<typeof projectStatusSchema>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Les intitulés des états, pour les écrans qui parlent des projets sans être
|
|
13
|
+
* Projets : la fiche d'une base, la coquille de réglages d'un élément.
|
|
14
|
+
*/
|
|
15
|
+
export const PROJECT_STATUS_LABELS: Record<ProjectStatus, string> = {
|
|
16
|
+
draft: 'Brouillon',
|
|
17
|
+
active: 'En cours',
|
|
18
|
+
paused: 'En pause',
|
|
19
|
+
done: 'Terminé'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Pourquoi il n'y a rien à relier. Une raison plutôt qu'une liste vide : les deux sont structurelles. */
|
|
23
|
+
export const itemProjectsBlockerSchema = z.enum([
|
|
24
|
+
/** Le module Projets n'est pas installé sur ce serveur. */
|
|
25
|
+
'module',
|
|
26
|
+
/** Un projet ne relie pas les éléments de cette fonctionnalité. */
|
|
27
|
+
'feature'
|
|
28
|
+
]);
|
|
29
|
+
export type ItemProjectsBlocker = z.infer<typeof itemProjectsBlockerSchema>;
|
|
30
|
+
|
|
31
|
+
/** Un projet auquel l'élément réglé est relié, ou pourrait l'être. */
|
|
32
|
+
export const itemProjectSchema = z.object({
|
|
33
|
+
projectId: z.number().int().positive(),
|
|
34
|
+
title: z.string(),
|
|
35
|
+
status: projectStatusSchema,
|
|
36
|
+
/** Rangé : montré parce qu'il relie encore l'élément, jamais proposé à vide. */
|
|
37
|
+
archived: z.boolean(),
|
|
38
|
+
linked: z.boolean()
|
|
39
|
+
});
|
|
40
|
+
export type ItemProject = z.infer<typeof itemProjectSchema>;
|
|
41
|
+
|
|
42
|
+
/** Les projets d'un espace, tels que l'écran les groupe. */
|
|
43
|
+
export const itemProjectGroupSchema = z.object({
|
|
44
|
+
workspaceId: z.number().int().positive(),
|
|
45
|
+
workspaceName: z.string(),
|
|
46
|
+
/** L'espace actif : l'écran le met en tête. */
|
|
47
|
+
isActive: z.boolean(),
|
|
48
|
+
/** L'espace d'origine de l'élément ; ailleurs il n'y est que projeté. */
|
|
49
|
+
isHome: z.boolean(),
|
|
50
|
+
/** L'appelant tient `projects: write` ici. Faux : les cases sont inertes, la liste reste lisible. */
|
|
51
|
+
writable: z.boolean(),
|
|
52
|
+
projects: z.array(itemProjectSchema)
|
|
53
|
+
});
|
|
54
|
+
export type ItemProjectGroup = z.infer<typeof itemProjectGroupSchema>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Les projets qui relient cet élément, dans chacun des espaces de l'appelant où
|
|
58
|
+
* il est visible. Un espace où l'appelant n'a pas accès à Projets n'y figure
|
|
59
|
+
* pas : les titres des projets d'un espace ne se lisent pas de l'extérieur.
|
|
60
|
+
*/
|
|
61
|
+
export const itemProjectsStateSchema = z.object({
|
|
62
|
+
groups: z.array(itemProjectGroupSchema),
|
|
63
|
+
blocker: itemProjectsBlockerSchema.nullable()
|
|
64
|
+
});
|
|
65
|
+
export type ItemProjectsState = z.infer<typeof itemProjectsStateSchema>;
|
package/src/domain/report.ts
CHANGED
|
@@ -204,6 +204,22 @@ export type TcpConnection = z.infer<typeof tcpConnectionSchema>;
|
|
|
204
204
|
export const agentServiceScopeSchema = z.enum(['none', 'user', 'system']);
|
|
205
205
|
export type AgentServiceScope = z.infer<typeof agentServiceScopeSchema>;
|
|
206
206
|
|
|
207
|
+
/**
|
|
208
|
+
* What the machine's own operator allows this server to order, read from the
|
|
209
|
+
* `[policy]` section of `agent.toml`. No frame can change it: it is the one
|
|
210
|
+
* thing on the device the server does not decide. `false` = the agent refuses
|
|
211
|
+
* the order, whatever the caller's permissions say.
|
|
212
|
+
*/
|
|
213
|
+
export const agentPolicySchema = z.object({
|
|
214
|
+
terminal: z.boolean(),
|
|
215
|
+
filesWrite: z.boolean(),
|
|
216
|
+
power: z.boolean(),
|
|
217
|
+
pkgUpgrade: z.boolean(),
|
|
218
|
+
serviceElevate: z.boolean(),
|
|
219
|
+
destroy: z.boolean()
|
|
220
|
+
});
|
|
221
|
+
export type AgentPolicy = z.infer<typeof agentPolicySchema>;
|
|
222
|
+
|
|
207
223
|
export const agentInfoSchema = z.object({
|
|
208
224
|
/** Running as root (Unix euid 0) / elevated (Windows). */
|
|
209
225
|
privileged: z.boolean(),
|
|
@@ -223,7 +239,17 @@ export const agentInfoSchema = z.object({
|
|
|
223
239
|
* ne dit pas (elle vaut `0.0.0` sur une construction locale). Vide par
|
|
224
240
|
* défaut : un agent qui ne dit rien n'a pas ces sondes.
|
|
225
241
|
*/
|
|
226
|
-
probes: z.array(z.string().max(32)).max(16).default([])
|
|
242
|
+
probes: z.array(z.string().max(32)).max(16).default([]),
|
|
243
|
+
policy: agentPolicySchema.default({
|
|
244
|
+
terminal: true,
|
|
245
|
+
filesWrite: true,
|
|
246
|
+
power: true,
|
|
247
|
+
pkgUpgrade: true,
|
|
248
|
+
serviceElevate: true,
|
|
249
|
+
destroy: true
|
|
250
|
+
}),
|
|
251
|
+
/** The agent reaches this server over plain http/ws (opted in locally): everything, shell included, travels in clear. */
|
|
252
|
+
insecureTransport: z.boolean().default(false)
|
|
227
253
|
});
|
|
228
254
|
|
|
229
255
|
export type AgentInfo = z.infer<typeof agentInfoSchema>;
|
|
@@ -446,6 +472,12 @@ export const authWindowSchema = z.object({
|
|
|
446
472
|
* La source n'a pas pu être lue (pas de journal, pas les droits) : sans ce
|
|
447
473
|
* drapeau, une machine aveugle passerait pour une machine tranquille.
|
|
448
474
|
*/
|
|
449
|
-
unavailable: z.boolean().default(false)
|
|
475
|
+
unavailable: z.boolean().default(false),
|
|
476
|
+
/**
|
|
477
|
+
* Le plafond de lignes a été atteint : seules les plus récentes ont été
|
|
478
|
+
* comptées, les compteurs sont donc minorés. Un flot qui sature le relevé
|
|
479
|
+
* ne doit pas se lire comme une fenêtre calme.
|
|
480
|
+
*/
|
|
481
|
+
truncated: z.boolean().default(false)
|
|
450
482
|
});
|
|
451
483
|
export type AuthWindow = z.infer<typeof authWindowSchema>;
|
package/src/domain/secrecy.ts
CHANGED
|
@@ -58,7 +58,10 @@ export interface UserSecretKeyRow {
|
|
|
58
58
|
kdf_salt: Uint8Array | null;
|
|
59
59
|
recovery_wrapped: string | null;
|
|
60
60
|
recovery_salt: Uint8Array | null;
|
|
61
|
+
/** Argon2id profile the password wrap was derived under; rows re-wrap to the current one on unlock. */
|
|
61
62
|
version: number;
|
|
63
|
+
/** Argon2id profile of the recovery wrap; upgraded when the code is next used or renewed. */
|
|
64
|
+
recovery_version: number;
|
|
62
65
|
created: number;
|
|
63
66
|
updated: number;
|
|
64
67
|
}
|
package/src/domain/twoFactor.ts
CHANGED
|
@@ -11,11 +11,13 @@ export type TwoFactorStatus = z.infer<typeof twoFactorStatusSchema>;
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* One-time provisioning payload returned when starting 2FA setup. The secret
|
|
14
|
-
* and otpauth URL are shown once; the
|
|
14
|
+
* and otpauth URL are shown once; the QR code comes drawn by the server.
|
|
15
15
|
*/
|
|
16
16
|
export const twoFactorSetupSchema = z.object({
|
|
17
17
|
secret: z.string().min(1),
|
|
18
18
|
otpauthUrl: z.string().min(1),
|
|
19
|
+
/** The otpauth URL as a PNG data URL, drawn by the server: the secret goes to no third party. */
|
|
20
|
+
qrDataUrl: z.string().startsWith('data:image/png;base64,'),
|
|
19
21
|
backupCodes: z.array(z.string().min(1))
|
|
20
22
|
});
|
|
21
23
|
|
|
@@ -23,17 +25,19 @@ export type TwoFactorSetup = z.infer<typeof twoFactorSetupSchema>;
|
|
|
23
25
|
|
|
24
26
|
export interface TwoFactorRow {
|
|
25
27
|
user_id: number;
|
|
26
|
-
/**
|
|
28
|
+
/** TOTP secret sealed under the server key (encrypted at rest, server-readable). */
|
|
27
29
|
secret_enc: string;
|
|
28
30
|
enabled: number;
|
|
29
31
|
created: number;
|
|
30
32
|
confirmed_at: number | null;
|
|
33
|
+
/** Time step of the last accepted TOTP code; a step at or before it is refused (replay). */
|
|
34
|
+
last_used_counter: number | null;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
export interface BackupCodeRow {
|
|
34
38
|
id: number;
|
|
35
39
|
user_id: number;
|
|
36
|
-
/**
|
|
40
|
+
/** HMAC-SHA256 of the normalized code under a key derived from the server key; raw codes are shown once. */
|
|
37
41
|
code_hash: string;
|
|
38
42
|
used_at: number | null;
|
|
39
43
|
created: number;
|
package/src/domain/workspace.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { minimalUserSchema } from './user';
|
|
|
7
7
|
* - `personal` : créé avec le compte, un seul membre (son propriétaire), ni
|
|
8
8
|
* quittable ni supprimable, jamais partageable. C'est le repli implicite quand
|
|
9
9
|
* une commande ne vise aucun espace en particulier.
|
|
10
|
-
* - `shared` : créé à la demande, plusieurs membres
|
|
10
|
+
* - `shared` : créé à la demande, plusieurs membres et rôles.
|
|
11
11
|
*/
|
|
12
12
|
export const workspaceKindSchema = z.enum(['personal', 'shared']);
|
|
13
13
|
export type WorkspaceKind = z.infer<typeof workspaceKindSchema>;
|
|
@@ -88,7 +88,14 @@ export const workspaceFeatureIdSchema = z.enum([
|
|
|
88
88
|
* Veille CVE. `read` = lire le fil et chercher dans le catalogue, `write` =
|
|
89
89
|
* épingler une CVE pour tout l'espace et poser la clé d'API du NVD.
|
|
90
90
|
*/
|
|
91
|
-
'cve'
|
|
91
|
+
'cve',
|
|
92
|
+
/**
|
|
93
|
+
* Serveur mail. `read` = voir les adresses hébergées et leur activité,
|
|
94
|
+
* `write` = créer une adresse, régler son quota, déclarer un domaine.
|
|
95
|
+
* Réinitialiser un mot de passe et purger la file d'envoi sont des
|
|
96
|
+
* permissions propres du module.
|
|
97
|
+
*/
|
|
98
|
+
'mailserver'
|
|
92
99
|
]);
|
|
93
100
|
|
|
94
101
|
export type WorkspaceFeatureId = z.infer<typeof workspaceFeatureIdSchema>;
|
|
@@ -181,7 +188,7 @@ export const workspaceRoleSchema = z.object({
|
|
|
181
188
|
position: z.number().int().nonnegative(),
|
|
182
189
|
capabilities: z.array(workspaceCapabilitySchema),
|
|
183
190
|
features: z.array(workspaceFeatureGrantSchema),
|
|
184
|
-
/** Attribué d'office à qui rejoint l'espace
|
|
191
|
+
/** Attribué d'office à qui rejoint l'espace. */
|
|
185
192
|
isDefault: z.boolean(),
|
|
186
193
|
memberCount: z.number().int().nonnegative()
|
|
187
194
|
});
|
package/src/features/admin.ts
CHANGED
|
@@ -25,23 +25,6 @@ export const adminUserSchema = z.object({
|
|
|
25
25
|
|
|
26
26
|
export type AdminUser = z.infer<typeof adminUserSchema>;
|
|
27
27
|
|
|
28
|
-
/** Invitation à créer un compte, en attente d'être consommée. */
|
|
29
|
-
export const adminInviteSchema = z.object({
|
|
30
|
-
token: z.string(),
|
|
31
|
-
url: z.string(),
|
|
32
|
-
/** Adresse sur laquelle l'invitation est verrouillée, ou `null`. */
|
|
33
|
-
email: z.string().nullable(),
|
|
34
|
-
/** Espace rejoint dès la création du compte, ou `null`. */
|
|
35
|
-
workspaceName: z.string().nullable(),
|
|
36
|
-
expiresAt: z.number().int().nullable(),
|
|
37
|
-
maxUses: z.number().int().positive().nullable(),
|
|
38
|
-
uses: z.number().int().nonnegative(),
|
|
39
|
-
createdBy: z.string(),
|
|
40
|
-
created: z.number().int().nonnegative()
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export type AdminInvite = z.infer<typeof adminInviteSchema>;
|
|
44
|
-
|
|
45
28
|
export const adminUserList = {
|
|
46
29
|
command: 'admin.userList' as const,
|
|
47
30
|
input: z.object({}),
|
|
@@ -71,42 +54,9 @@ export const adminDeleteUser = {
|
|
|
71
54
|
output: z.object({ userId: z.number().int().positive() })
|
|
72
55
|
};
|
|
73
56
|
|
|
74
|
-
export const adminInviteList = {
|
|
75
|
-
command: 'admin.inviteList' as const,
|
|
76
|
-
input: z.object({}),
|
|
77
|
-
output: z.object({ invites: z.array(adminInviteSchema) })
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const adminInviteCreate = {
|
|
81
|
-
command: 'admin.inviteCreate' as const,
|
|
82
|
-
input: z.object({
|
|
83
|
-
/** Verrouille l'invitation sur une adresse ; vide = ouverte. */
|
|
84
|
-
email: z.string().max(320),
|
|
85
|
-
/** Espace rejoint à la création du compte ; `null` = aucun. */
|
|
86
|
-
workspaceId: z.number().int().positive().nullable(),
|
|
87
|
-
ttlSeconds: z
|
|
88
|
-
.number()
|
|
89
|
-
.int()
|
|
90
|
-
.positive()
|
|
91
|
-
.max(30 * 24 * 3600)
|
|
92
|
-
.nullable(),
|
|
93
|
-
maxUses: z.number().int().positive().max(100).nullable()
|
|
94
|
-
}),
|
|
95
|
-
output: z.object({ invite: adminInviteSchema })
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const adminInviteRevoke = {
|
|
99
|
-
command: 'admin.inviteRevoke' as const,
|
|
100
|
-
input: z.object({ token: z.string().min(1) }),
|
|
101
|
-
output: z.object({ token: z.string().min(1) })
|
|
102
|
-
};
|
|
103
|
-
|
|
104
57
|
export const adminCommands = [
|
|
105
58
|
adminUserList,
|
|
106
59
|
adminSetUserRole,
|
|
107
60
|
adminSetUserStatus,
|
|
108
|
-
adminDeleteUser
|
|
109
|
-
adminInviteList,
|
|
110
|
-
adminInviteCreate,
|
|
111
|
-
adminInviteRevoke
|
|
61
|
+
adminDeleteUser
|
|
112
62
|
] as const;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FEATURE_DOMAIN_HOST_MAX, featureDomainSchema } from '../domain/featureDomain';
|
|
3
|
+
import { featureIdSchema } from '../domain/workspaceRole';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The domains of one feature in the active workspace. Cross-cutting: the
|
|
7
|
+
* feature is an input, and each command authorizes against it (read to list,
|
|
8
|
+
* write for the rest). A feature whose manifest declares no `domains` is
|
|
9
|
+
* refused.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const domainList = {
|
|
13
|
+
command: 'domain.list' as const,
|
|
14
|
+
input: z.object({ feature: featureIdSchema }),
|
|
15
|
+
output: z.object({ domains: z.array(featureDomainSchema) })
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const domainAdd = {
|
|
19
|
+
command: 'domain.add' as const,
|
|
20
|
+
input: z.object({
|
|
21
|
+
feature: featureIdSchema,
|
|
22
|
+
host: z.string().min(1).max(FEATURE_DOMAIN_HOST_MAX)
|
|
23
|
+
}),
|
|
24
|
+
output: z.object({ domain: featureDomainSchema })
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Runs both stages now instead of waiting for the background pass. */
|
|
28
|
+
export const domainVerify = {
|
|
29
|
+
command: 'domain.verify' as const,
|
|
30
|
+
input: z.object({ feature: featureIdSchema, id: z.number().int().positive() }),
|
|
31
|
+
output: z.object({ domain: featureDomainSchema })
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const domainRemove = {
|
|
35
|
+
command: 'domain.remove' as const,
|
|
36
|
+
input: z.object({ feature: featureIdSchema, id: z.number().int().positive() }),
|
|
37
|
+
output: z.object({ ok: z.literal(true) })
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const domainCommands = [domainList, domainAdd, domainVerify, domainRemove] as const;
|
package/src/features/home.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const homeShortcutPreview = {
|
|
|
22
22
|
command: 'home.shortcutPreview' as const,
|
|
23
23
|
input: z.object({
|
|
24
24
|
template: shortcutTemplateSchema,
|
|
25
|
-
url: z.
|
|
25
|
+
url: z.url({ protocol: /^https?$/ }).max(SHORTCUT_URL_MAX_LENGTH),
|
|
26
26
|
/** Bypass the server cache and re-fetch (Ctrl/Cmd-click on the tile). */
|
|
27
27
|
refresh: z.boolean().optional()
|
|
28
28
|
}),
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import { itemProjectsStateSchema } from '../domain/project';
|
|
4
|
+
import { itemRefSchema } from '../domain/sharing';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Ce qui relie un élément d'espace aux projets qui l'utilisent, réglé depuis
|
|
8
|
+
* les réglages de l'élément. Transversal comme `share.*` : le couple
|
|
9
|
+
* `(feature, itemId)` est une donnée d'entrée, et le geste porte sur un espace
|
|
10
|
+
* qui n'est pas forcément l'actif, ce qu'aucune commande de module ne peut
|
|
11
|
+
* faire. Les liaisons restent celles de Projets, qui les tient par son contrat
|
|
12
|
+
* d'usage.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Les projets qui relient cet élément, espace par espace. */
|
|
16
|
+
export const projectLinksGet = {
|
|
17
|
+
command: 'links.projectsGet' as const,
|
|
18
|
+
input: itemRefSchema,
|
|
19
|
+
output: itemProjectsStateSchema
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Attache l'élément à un projet, ou l'en retire. Un seul projet par appel : la
|
|
24
|
+
* case de l'écran est la commande, et un échec ne laisse pas les autres dans un
|
|
25
|
+
* état incertain.
|
|
26
|
+
*/
|
|
27
|
+
export const projectLinksSet = {
|
|
28
|
+
command: 'links.projectsSet' as const,
|
|
29
|
+
input: itemRefSchema.extend({
|
|
30
|
+
workspaceId: z.number().int().positive(),
|
|
31
|
+
projectId: z.number().int().positive(),
|
|
32
|
+
linked: z.boolean()
|
|
33
|
+
}),
|
|
34
|
+
output: itemProjectsStateSchema
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const linksCommands = [projectLinksGet, projectLinksSet] as const;
|
package/src/features/registry.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { agentCommands } from './agent';
|
|
3
|
+
import { domainCommands } from './domain';
|
|
3
4
|
import { feedbackCommands } from './feedback';
|
|
4
5
|
import { homeCommands } from './home';
|
|
6
|
+
import { linksCommands } from './links';
|
|
5
7
|
import { liveCommands } from './live';
|
|
6
8
|
import { logsCommands } from './logs';
|
|
7
9
|
import { notifyCommands } from './notify';
|
|
@@ -30,6 +32,8 @@ export const featureCommands = [
|
|
|
30
32
|
...homeCommands,
|
|
31
33
|
...notifyCommands,
|
|
32
34
|
...sharingCommands,
|
|
35
|
+
...linksCommands,
|
|
36
|
+
...domainCommands,
|
|
33
37
|
...liveCommands
|
|
34
38
|
] as const;
|
|
35
39
|
|
package/src/features/secrecy.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { secrecyStatusSchema } from '../domain/secrecy';
|
|
3
|
+
import { passwordSchema } from '../http/auth';
|
|
4
|
+
|
|
5
|
+
/** A password being verified: whatever the account already has. Bounded so Argon2 never eats a megabyte. */
|
|
6
|
+
const existingPassword = z.string().min(1).max(512);
|
|
7
|
+
const newPassword = passwordSchema;
|
|
3
8
|
|
|
4
9
|
/** Current state of password-based encryption for the caller. */
|
|
5
10
|
export const secrecyStatus = {
|
|
@@ -14,7 +19,7 @@ export const secrecyStatus = {
|
|
|
14
19
|
*/
|
|
15
20
|
export const secrecyUnlock = {
|
|
16
21
|
command: 'secrecy.unlock' as const,
|
|
17
|
-
input: z.object({ password:
|
|
22
|
+
input: z.object({ password: existingPassword }),
|
|
18
23
|
output: z.object({ status: secrecyStatusSchema })
|
|
19
24
|
};
|
|
20
25
|
|
|
@@ -26,7 +31,7 @@ export const secrecyUnlock = {
|
|
|
26
31
|
export const secrecyEnable = {
|
|
27
32
|
command: 'secrecy.enable' as const,
|
|
28
33
|
input: z.object({
|
|
29
|
-
password:
|
|
34
|
+
password: existingPassword,
|
|
30
35
|
recovery: z.boolean()
|
|
31
36
|
}),
|
|
32
37
|
output: z.object({
|
|
@@ -39,7 +44,7 @@ export const secrecyEnable = {
|
|
|
39
44
|
/** Disable the feature: re-wrap the DEK with the server key. */
|
|
40
45
|
export const secrecyDisable = {
|
|
41
46
|
command: 'secrecy.disable' as const,
|
|
42
|
-
input: z.object({ password:
|
|
47
|
+
input: z.object({ password: existingPassword }),
|
|
43
48
|
output: z.object({ status: secrecyStatusSchema })
|
|
44
49
|
};
|
|
45
50
|
|
|
@@ -91,15 +96,23 @@ export const secrecyLock = {
|
|
|
91
96
|
|
|
92
97
|
/**
|
|
93
98
|
* Recover access after a forgotten password using the recovery code, choosing
|
|
94
|
-
* a new password to re-wrap the DEK with.
|
|
99
|
+
* a new password to re-wrap the DEK with. The code that served is replaced: the
|
|
100
|
+
* new one is returned exactly once. Every other session of the account closes.
|
|
95
101
|
*/
|
|
96
102
|
export const secrecyRecover = {
|
|
97
103
|
command: 'secrecy.recover' as const,
|
|
98
104
|
input: z.object({
|
|
99
|
-
recoveryCode: z.string().min(1),
|
|
100
|
-
newPassword
|
|
105
|
+
recoveryCode: z.string().min(1).max(64),
|
|
106
|
+
newPassword
|
|
101
107
|
}),
|
|
102
|
-
output: z.object({ status: secrecyStatusSchema })
|
|
108
|
+
output: z.object({ status: secrecyStatusSchema, recoveryCode: z.string().min(1) })
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** Replace the recovery code (password required). The previous code stops working at once. */
|
|
112
|
+
export const secrecyRegenerateRecovery = {
|
|
113
|
+
command: 'secrecy.regenerateRecovery' as const,
|
|
114
|
+
input: z.object({ password: existingPassword }),
|
|
115
|
+
output: z.object({ status: secrecyStatusSchema, recoveryCode: z.string().min(1) })
|
|
103
116
|
};
|
|
104
117
|
|
|
105
118
|
export const secrecyCommands = [
|
|
@@ -111,5 +124,6 @@ export const secrecyCommands = [
|
|
|
111
124
|
secrecyHold,
|
|
112
125
|
secrecyTouch,
|
|
113
126
|
secrecyLock,
|
|
114
|
-
secrecyRecover
|
|
127
|
+
secrecyRecover,
|
|
128
|
+
secrecyRegenerateRecovery
|
|
115
129
|
] as const;
|
|
@@ -24,7 +24,7 @@ export const twoFactorEnable = {
|
|
|
24
24
|
/** Disable 2FA (requires a valid current code or backup code). */
|
|
25
25
|
export const twoFactorDisable = {
|
|
26
26
|
command: 'twofa.disable' as const,
|
|
27
|
-
input: z.object({ code: z.string().min(6).max(
|
|
27
|
+
input: z.object({ code: z.string().min(6).max(24) }),
|
|
28
28
|
output: z.object({ status: twoFactorStatusSchema })
|
|
29
29
|
};
|
|
30
30
|
|