@deveye/types 0.20.1 → 0.20.3
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 +8 -13
- package/src/domain/deviceDocker.ts +5 -1
- package/src/domain/featureDomain.ts +3 -1
- package/src/domain/featureRegistry.ts +19 -12
- package/src/domain/maintenance.ts +7 -5
- package/src/domain/notifications.ts +2 -1
- package/src/domain/pathExclusions.test.ts +29 -0
- package/src/domain/pathExclusions.ts +85 -0
- package/src/domain/report.ts +5 -2
- package/src/domain/syncProtocol.ts +0 -9
- package/src/domain/user.ts +2 -0
- package/src/domain/workspace.ts +8 -1
- package/src/features/user.ts +24 -3
- package/src/http/auth.ts +11 -2
- package/src/http/device.ts +13 -27
- package/src/http/status.ts +26 -0
- package/src/index.ts +39 -9
- package/src/protocol/agent.ts +116 -10
- package/src/sdk/client-ambient.d.ts +118 -10
- package/src/sdk/client.ts +19 -1
- package/src/sdk/env.test.ts +150 -0
- package/src/sdk/env.ts +191 -0
- package/src/sdk/index.ts +1 -0
- package/src/sdk/manifest.test.ts +7 -0
- package/src/sdk/manifest.ts +15 -1
- package/src/sdk/pageLook.test.ts +26 -0
- package/src/sdk/pageLook.ts +81 -0
- package/src/sdk/providers.ts +83 -1
- package/src/sdk/server.ts +227 -24
- package/src/sdk/testing.test.ts +22 -1
- package/src/sdk/testing.ts +173 -19
package/package.json
CHANGED
package/src/domain/device.ts
CHANGED
|
@@ -3,23 +3,18 @@ import { deviceReportSchema, processCaptureSchema } from './report';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Lifecycle of a monitored machine (the Rust agent):
|
|
6
|
-
* - `pending`:
|
|
7
|
-
*
|
|
8
|
-
* - `
|
|
6
|
+
* - `pending`: a machine the workspace already knew, linked again. Its
|
|
7
|
+
* agent is refused at the socket until someone approves it.
|
|
8
|
+
* - `active`: in service. A first link lands here directly.
|
|
9
9
|
* - `pending_deletion`: deletion requested; on its next connection the agent is
|
|
10
10
|
* told to self-destruct, then the device is archived. Can
|
|
11
11
|
* be cancelled until the agent reconnects.
|
|
12
|
-
* - `archived`: agent
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* - `archived`: access revoked or agent removed. The token is wiped, the
|
|
13
|
+
* monitoring history stays browsable (read-only) until
|
|
14
|
+
* purged, and linking the machine again brings it back as
|
|
15
|
+
* `pending`.
|
|
15
16
|
*/
|
|
16
|
-
export const deviceStatusSchema = z.enum([
|
|
17
|
-
'pending',
|
|
18
|
-
'active',
|
|
19
|
-
'revoked',
|
|
20
|
-
'pending_deletion',
|
|
21
|
-
'archived'
|
|
22
|
-
]);
|
|
17
|
+
export const deviceStatusSchema = z.enum(['pending', 'active', 'pending_deletion', 'archived']);
|
|
23
18
|
export type DeviceStatus = z.infer<typeof deviceStatusSchema>;
|
|
24
19
|
|
|
25
20
|
export const devicePlatformSchema = z.enum(['linux', 'macos', 'windows']);
|
|
@@ -158,7 +158,10 @@ export const dockerActionSchema = z.enum([
|
|
|
158
158
|
'pruneBuildCache',
|
|
159
159
|
// Mise à jour d'un service.
|
|
160
160
|
'pull',
|
|
161
|
-
'recreate'
|
|
161
|
+
'recreate',
|
|
162
|
+
// Déploiement d'un service compose (`projet/service`) : son image, puis sa
|
|
163
|
+
// recréation seule. Refusable par la machine (`allow_docker_deploy`).
|
|
164
|
+
'composeDeploy'
|
|
162
165
|
]);
|
|
163
166
|
export type DockerAction = z.infer<typeof dockerActionSchema>;
|
|
164
167
|
|
|
@@ -170,6 +173,7 @@ export type DockerAction = z.infer<typeof dockerActionSchema>;
|
|
|
170
173
|
export const DOCKER_LONG_ACTIONS = [
|
|
171
174
|
'pull',
|
|
172
175
|
'recreate',
|
|
176
|
+
'composeDeploy',
|
|
173
177
|
'pruneContainers',
|
|
174
178
|
'pruneImages',
|
|
175
179
|
'pruneVolumes',
|
|
@@ -41,6 +41,8 @@ export const featureDomainSchema = z.object({
|
|
|
41
41
|
verifiedAt: z.number().int().nullable(),
|
|
42
42
|
checkedAt: z.number().int().nullable(),
|
|
43
43
|
/** How many of the feature's items designate this domain. */
|
|
44
|
-
useCount: z.number().int().nonnegative()
|
|
44
|
+
useCount: z.number().int().nonnegative(),
|
|
45
|
+
/** The owner's plan holds this name paused: it is not served until the limit rises. */
|
|
46
|
+
planPaused: z.boolean()
|
|
45
47
|
});
|
|
46
48
|
export type FeatureDomain = z.infer<typeof featureDomainSchema>;
|
|
@@ -58,9 +58,11 @@ export interface FeatureDescriptor {
|
|
|
58
58
|
/**
|
|
59
59
|
* La phrase de tête de l'onglet Notifications : QUAND la fonctionnalité
|
|
60
60
|
* prévient. Sans elle, l'onglet liste des canaux sans dire à quoi ils
|
|
61
|
-
* servent. Exigée dès que `notifies` est vrai.
|
|
61
|
+
* servent. Exigée dès que `notifies` est vrai. `perItem: false` quand rien
|
|
62
|
+
* ne part jamais au nom d'un élément : ses réglages n'ont alors pas
|
|
63
|
+
* d'onglet Notifications qui ne recevrait rien.
|
|
62
64
|
*/
|
|
63
|
-
notifications?: { hint: string };
|
|
65
|
+
notifications?: { hint: string; perItem?: boolean };
|
|
64
66
|
/**
|
|
65
67
|
* Un de ses éléments peut-il être rendu visible depuis un autre espace ?
|
|
66
68
|
* Décidé par le chiffrement : un élément partagé reste chiffré sous la clé
|
|
@@ -198,17 +200,17 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
198
200
|
id: 'deploy',
|
|
199
201
|
label: 'Déploiements',
|
|
200
202
|
description:
|
|
201
|
-
'Lecture : cibles et historique. Écriture : poser
|
|
203
|
+
'Lecture : cibles et historique. Écriture : poser un accès et déclencher une mise en production.',
|
|
202
204
|
icon: 'rocket',
|
|
203
205
|
notifies: true,
|
|
204
206
|
notifications: {
|
|
205
|
-
hint: 'Envoyées à l’atterrissage d’un déploiement, échec comme succès, y compris ceux lancés depuis Dokploy, une CI ou un push git.'
|
|
207
|
+
hint: 'Envoyées à l’atterrissage d’un déploiement, échec comme succès, y compris ceux lancés ailleurs : depuis Dokploy, une CI ou un push git.'
|
|
206
208
|
},
|
|
207
209
|
hasItems: true,
|
|
208
210
|
itemNoun: 'cible',
|
|
209
211
|
itemNounGender: 'f',
|
|
210
212
|
sources: {
|
|
211
|
-
hint: 'Les accès
|
|
213
|
+
hint: 'Les accès de l’espace : une instance Dokploy (adresse et clé d’API) ou un jeton GitHub. Chaque cible en désigne un ; corriger un accès corrige d’un coup toutes les cibles qui s’en servent.'
|
|
212
214
|
},
|
|
213
215
|
shareTier: 'open'
|
|
214
216
|
},
|
|
@@ -240,7 +242,7 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
240
242
|
hasItems: true,
|
|
241
243
|
itemNoun: 'travail',
|
|
242
244
|
sources: {
|
|
243
|
-
hint: 'Les destinations d’archives de l’espace : un dossier du serveur, une machine
|
|
245
|
+
hint: 'Les destinations d’archives de l’espace : un dossier du serveur, une machine, un bucket S3, un serveur SFTP ou WebDAV. Chaque travail écrit vers l’une d’elles ; la corriger corrige d’un coup tous les travaux qui s’en servent.'
|
|
244
246
|
},
|
|
245
247
|
shareTier: 'open'
|
|
246
248
|
},
|
|
@@ -248,11 +250,19 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
248
250
|
id: 'finance',
|
|
249
251
|
label: 'Finances',
|
|
250
252
|
description:
|
|
251
|
-
'
|
|
253
|
+
'La trésorerie de l’activité : comptes, opérations, échéances. La lecture seule est déjà lourde.',
|
|
252
254
|
icon: 'finance',
|
|
253
|
-
notifies:
|
|
255
|
+
notifies: true,
|
|
256
|
+
notifications: {
|
|
257
|
+
hint: 'Envoyées une semaine avant l’échéance d’une déclaration URSSAF de micro-entreprise, puis la veille, avec le chiffre d’affaires à déclarer ; et quand le consentement donné à une banque reliée approche de sa fin.',
|
|
258
|
+
// Un rappel concerne l'activité, jamais un compte.
|
|
259
|
+
perItem: false
|
|
260
|
+
},
|
|
254
261
|
hasItems: true,
|
|
255
262
|
itemNoun: 'compte',
|
|
263
|
+
sources: {
|
|
264
|
+
hint: 'Les banques reliées à l’espace. Chaque compte du livre en choisit une dans son onglet Banque ; ses lignes arrivent alors seules, toutes les six heures.'
|
|
265
|
+
},
|
|
256
266
|
shareTier: 'never'
|
|
257
267
|
},
|
|
258
268
|
{
|
|
@@ -274,10 +284,7 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
274
284
|
icon: 'search',
|
|
275
285
|
notifies: false,
|
|
276
286
|
hasItems: false,
|
|
277
|
-
shareTier: 'never'
|
|
278
|
-
sources: {
|
|
279
|
-
hint: 'Les clés d’API des fournisseurs, toutes facultatives : chaque sonde libre fonctionne déjà, une clé ne fait qu’enrichir la sienne.'
|
|
280
|
-
}
|
|
287
|
+
shareTier: 'never'
|
|
281
288
|
},
|
|
282
289
|
{
|
|
283
290
|
id: 'cve',
|
|
@@ -4,13 +4,15 @@ import { z } from 'zod';
|
|
|
4
4
|
* Maintenance, site-wide or per feature, set by the global admin (or by the
|
|
5
5
|
* database and the `MAINTENANCE` variable when the interface is out of reach).
|
|
6
6
|
*
|
|
7
|
-
* A feature has
|
|
8
|
-
* public route while its background service keeps running; `
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* A feature has three levels: `requests` refuses every non-admin command and
|
|
8
|
+
* public route while its background service keeps running; `preview` refuses
|
|
9
|
+
* the same, but hides the feature from non-admins instead of greying it out
|
|
10
|
+
* (a feature admins try out in production before opening it); `full` also
|
|
11
|
+
* stops the service, and refuses admins too, the feature no longer being able
|
|
12
|
+
* to answer.
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
|
-
export const featureMaintenanceLevelSchema = z.enum(['requests', 'full']);
|
|
15
|
+
export const featureMaintenanceLevelSchema = z.enum(['requests', 'preview', 'full']);
|
|
14
16
|
export type FeatureMaintenanceLevel = z.infer<typeof featureMaintenanceLevelSchema>;
|
|
15
17
|
|
|
16
18
|
/** What every client of a server knows: enough to eject, grey out and redirect. */
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { describe, it } from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { pathExclusionProblem } from './pathExclusions';
|
|
5
|
+
|
|
6
|
+
describe('pathExclusionProblem', () => {
|
|
7
|
+
it('accepts a relative path, refuses one that escapes or starts at the root', () => {
|
|
8
|
+
assert.equal(pathExclusionProblem('path', 'build/cache'), null);
|
|
9
|
+
assert.notEqual(pathExclusionProblem('path', '/etc'), null);
|
|
10
|
+
assert.notEqual(pathExclusionProblem('path', 'a/../b'), null);
|
|
11
|
+
assert.notEqual(pathExclusionProblem('path', 'a//b'), null);
|
|
12
|
+
assert.notEqual(pathExclusionProblem('path', 'a\\b'), null);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('refuses a name with a separator', () => {
|
|
16
|
+
assert.equal(pathExclusionProblem('name', 'node_modules'), null);
|
|
17
|
+
assert.notEqual(pathExclusionProblem('name', 'a/b'), null);
|
|
18
|
+
assert.notEqual(pathExclusionProblem('name', '..'), null);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('refuses what the agent’s regex engine cannot run', () => {
|
|
22
|
+
assert.equal(pathExclusionProblem('regex', '\\.log$'), null);
|
|
23
|
+
assert.equal(pathExclusionProblem('regex', '^(?<dir>tmp)/'), null);
|
|
24
|
+
assert.notEqual(pathExclusionProblem('regex', '('), null);
|
|
25
|
+
assert.notEqual(pathExclusionProblem('regex', 'foo(?=bar)'), null);
|
|
26
|
+
assert.notEqual(pathExclusionProblem('regex', '(?<!x)y'), null);
|
|
27
|
+
assert.notEqual(pathExclusionProblem('regex', '(a)\\1'), null);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** Longest exclusion pattern, shared by the server, the agent and the screens. */
|
|
4
|
+
export const PATH_EXCLUSION_PATTERN_MAX = 512;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How a path is excluded from a walked folder (a CloudSync share, a backed-up
|
|
8
|
+
* folder), always against the path relative to that folder's root:
|
|
9
|
+
* - `path`: exact relative path, a file or a folder prefix;
|
|
10
|
+
* - `name`: exact name of any path component (`node_modules`, `.git`);
|
|
11
|
+
* - `regex`: regular expression on the whole relative path, run by the
|
|
12
|
+
* agent's linear-time engine (no lookaround, no backreference).
|
|
13
|
+
*/
|
|
14
|
+
export const pathExclusionKindSchema = z.enum(['path', 'name', 'regex']);
|
|
15
|
+
export type PathExclusionKind = z.infer<typeof pathExclusionKindSchema>;
|
|
16
|
+
|
|
17
|
+
export const pathExclusionSchema = z.object({
|
|
18
|
+
kind: pathExclusionKindSchema,
|
|
19
|
+
pattern: z.string().min(1).max(PATH_EXCLUSION_PATTERN_MAX)
|
|
20
|
+
});
|
|
21
|
+
export type PathExclusion = z.infer<typeof pathExclusionSchema>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* One-click exclusions, all `name`: that kind catches the folder anywhere in
|
|
25
|
+
* the tree, not only at the root. Dependencies and caches a project rebuilds.
|
|
26
|
+
*/
|
|
27
|
+
export const PATH_EXCLUSION_SUGGESTIONS: readonly string[] = [
|
|
28
|
+
'node_modules',
|
|
29
|
+
'.git',
|
|
30
|
+
'.venv',
|
|
31
|
+
'__pycache__',
|
|
32
|
+
'target',
|
|
33
|
+
'dist',
|
|
34
|
+
'build',
|
|
35
|
+
'.cache',
|
|
36
|
+
'.next',
|
|
37
|
+
'.idea'
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const hasControlChar = (text: string): boolean => [...text].some((c) => c.charCodeAt(0) < 0x20);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* JavaScript accepts these, the agent's engine refuses them: a pattern the
|
|
44
|
+
* agent cannot compile would fail every walk of the folder.
|
|
45
|
+
*/
|
|
46
|
+
const UNSUPPORTED_REGEX = /\(\?<?[=!]|\\[1-9]|\\k</;
|
|
47
|
+
|
|
48
|
+
/** Why a pattern cannot be saved (French, shown as is), or `null` when it can. */
|
|
49
|
+
export function pathExclusionProblem(kind: PathExclusionKind, pattern: string): string | null {
|
|
50
|
+
if (pattern.length === 0) return 'Motif vide.';
|
|
51
|
+
if (pattern.length > PATH_EXCLUSION_PATTERN_MAX) {
|
|
52
|
+
return `Motif de plus de ${PATH_EXCLUSION_PATTERN_MAX} caractères.`;
|
|
53
|
+
}
|
|
54
|
+
switch (kind) {
|
|
55
|
+
case 'path': {
|
|
56
|
+
if (pattern.includes('\\')) return 'Un chemin s’écrit avec des « / ».';
|
|
57
|
+
if (hasControlChar(pattern)) return 'Caractère de contrôle interdit.';
|
|
58
|
+
if (pattern.startsWith('/')) {
|
|
59
|
+
return 'Le chemin est relatif au dossier : sans « / » au début.';
|
|
60
|
+
}
|
|
61
|
+
const segments = pattern.split('/');
|
|
62
|
+
if (segments.some((s) => s === '' || s === '.' || s === '..')) {
|
|
63
|
+
return 'Chemin relatif invalide : ni segment vide, ni « . », ni « .. ».';
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
case 'name':
|
|
68
|
+
if (pattern.includes('/') || pattern.includes('\\')) {
|
|
69
|
+
return 'Un nom ne peut pas contenir de séparateur.';
|
|
70
|
+
}
|
|
71
|
+
if (hasControlChar(pattern)) return 'Caractère de contrôle interdit.';
|
|
72
|
+
if (pattern === '.' || pattern === '..') return 'Nom invalide.';
|
|
73
|
+
return null;
|
|
74
|
+
case 'regex':
|
|
75
|
+
try {
|
|
76
|
+
new RegExp(pattern);
|
|
77
|
+
} catch {
|
|
78
|
+
return 'Expression régulière invalide.';
|
|
79
|
+
}
|
|
80
|
+
if (UNSUPPORTED_REGEX.test(pattern)) {
|
|
81
|
+
return 'Ni lookaround, ni référence arrière : l’agent ne les exécute pas.';
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/domain/report.ts
CHANGED
|
@@ -216,7 +216,9 @@ export const agentPolicySchema = z.object({
|
|
|
216
216
|
power: z.boolean(),
|
|
217
217
|
pkgUpgrade: z.boolean(),
|
|
218
218
|
serviceElevate: z.boolean(),
|
|
219
|
-
destroy: z.boolean()
|
|
219
|
+
destroy: z.boolean(),
|
|
220
|
+
/** Deployments (`composeDeploy`). Defaulted: an agent older than the switch reports without it. */
|
|
221
|
+
dockerDeploy: z.boolean().default(true)
|
|
220
222
|
});
|
|
221
223
|
export type AgentPolicy = z.infer<typeof agentPolicySchema>;
|
|
222
224
|
|
|
@@ -246,7 +248,8 @@ export const agentInfoSchema = z.object({
|
|
|
246
248
|
power: true,
|
|
247
249
|
pkgUpgrade: true,
|
|
248
250
|
serviceElevate: true,
|
|
249
|
-
destroy: true
|
|
251
|
+
destroy: true,
|
|
252
|
+
dockerDeploy: true
|
|
250
253
|
}),
|
|
251
254
|
/** The agent reaches this server over plain http/ws (opted in locally): everything, shell included, travels in clear. */
|
|
252
255
|
insecureTransport: z.boolean().default(false)
|
|
@@ -10,7 +10,6 @@ import { z } from 'zod';
|
|
|
10
10
|
*/
|
|
11
11
|
/** Bornes partagées serveur/agent/client. */
|
|
12
12
|
export const SYNC_REL_PATH_MAX = 1024;
|
|
13
|
-
export const SYNC_PATTERN_MAX = 512;
|
|
14
13
|
export const SYNC_STORAGE_PATH_MAX = 1024;
|
|
15
14
|
/** Taille max d'un chunk base64 sur le fil (≈ 1 Mo de binaire). */
|
|
16
15
|
export const SYNC_CHUNK_MAX = 1_400_000;
|
|
@@ -42,14 +41,6 @@ export const syncIndexFingerprintSchema = z.string().regex(/^\d+\.\d+\.[0-9a-f]{
|
|
|
42
41
|
export const sha256HexSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
43
42
|
export const syncShareStatusSchema = z.enum(['active', 'paused']);
|
|
44
43
|
export type SyncShareStatus = z.infer<typeof syncShareStatusSchema>;
|
|
45
|
-
/**
|
|
46
|
-
* Type d'exclusion :
|
|
47
|
-
* - `path` → chemin relatif exact (fichier ou préfixe de dossier),
|
|
48
|
-
* - `name` → nom exact d'un composant de chemin (ex. `node_modules`),
|
|
49
|
-
* - `regex` → expression régulière sur le chemin relatif (moteur linéaire).
|
|
50
|
-
*/
|
|
51
|
-
export const syncExclusionKindSchema = z.enum(['path', 'name', 'regex']);
|
|
52
|
-
export type SyncExclusionKind = z.infer<typeof syncExclusionKindSchema>;
|
|
53
44
|
export const syncSessionStateSchema = z.enum([
|
|
54
45
|
'scanning',
|
|
55
46
|
'planning',
|
package/src/domain/user.ts
CHANGED
|
@@ -146,4 +146,6 @@ export interface UserRow {
|
|
|
146
146
|
re_auth_interval: number | null;
|
|
147
147
|
last_login: number;
|
|
148
148
|
created: number;
|
|
149
|
+
/** Seconds. When the terms of use were accepted at sign-up; `null` for an account created without a site. */
|
|
150
|
+
terms_accepted_at: number | null;
|
|
149
151
|
}
|
package/src/domain/workspace.ts
CHANGED
|
@@ -21,7 +21,14 @@ export const workspaceSchema = z.object({
|
|
|
21
21
|
ownerUserId: z.number().int().positive(),
|
|
22
22
|
users: z.array(minimalUserSchema),
|
|
23
23
|
features: z.array(z.string().min(1)),
|
|
24
|
-
created: z.number().int().nonnegative()
|
|
24
|
+
created: z.number().int().nonnegative(),
|
|
25
|
+
/**
|
|
26
|
+
* L'offre du propriétaire tient cet espace partagé en pause : ses membres
|
|
27
|
+
* autres que lui n'y entrent plus, jusqu'à ce que la limite remonte.
|
|
28
|
+
*/
|
|
29
|
+
planPaused: z.boolean(),
|
|
30
|
+
/** Les membres que l'offre du propriétaire tient dehors, les derniers arrivés d'abord. */
|
|
31
|
+
pausedMemberIds: z.array(z.number().int().positive())
|
|
25
32
|
});
|
|
26
33
|
|
|
27
34
|
export type Workspace = z.infer<typeof workspaceSchema>;
|
package/src/features/user.ts
CHANGED
|
@@ -110,17 +110,38 @@ export const accountPlanSchema = z.object({
|
|
|
110
110
|
id: z.string(),
|
|
111
111
|
label: z.string(),
|
|
112
112
|
limits: z.record(z.string(), z.number().int().nonnegative()),
|
|
113
|
-
trialEndsAt: z.number().int().nonnegative().optional()
|
|
113
|
+
trialEndsAt: z.number().int().nonnegative().optional(),
|
|
114
|
+
changesAt: z.number().int().nonnegative().optional()
|
|
114
115
|
});
|
|
115
116
|
|
|
116
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* The caller's plan. `null`: this DevEye has no plan provider, everything is
|
|
119
|
+
* unlimited. `paused`: how many of the caller's items the plan holds paused,
|
|
120
|
+
* by `<featureId>.<quotaKey>`, only the keys that have some.
|
|
121
|
+
*/
|
|
117
122
|
export const userPlan = {
|
|
118
123
|
command: 'user.plan' as const,
|
|
119
124
|
input: z.object({}),
|
|
120
|
-
output: z.object({
|
|
125
|
+
output: z.object({
|
|
126
|
+
plan: accountPlanSchema.nullable(),
|
|
127
|
+
paused: z.record(z.string(), z.number().int().positive())
|
|
128
|
+
})
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Deletes the caller's account with everything it owns: the personal workspace,
|
|
133
|
+
* the shared workspaces it owns and their content. Modules are told first
|
|
134
|
+
* (`FeatureService.onAccountDeleted`), so a subscription ends with the account.
|
|
135
|
+
* The password is asked again: the session alone is not enough for this.
|
|
136
|
+
*/
|
|
137
|
+
export const userDeleteAccount = {
|
|
138
|
+
command: 'user.deleteAccount' as const,
|
|
139
|
+
input: z.object({ password: z.string().min(1).max(512) }),
|
|
140
|
+
output: z.object({ ok: z.literal(true) })
|
|
121
141
|
};
|
|
122
142
|
|
|
123
143
|
export const userCommands = [
|
|
144
|
+
userDeleteAccount,
|
|
124
145
|
userPlan,
|
|
125
146
|
userSetAvatar,
|
|
126
147
|
userSetTheme,
|
package/src/http/auth.ts
CHANGED
|
@@ -30,6 +30,8 @@ export const sessionBundleSchema = z.object({
|
|
|
30
30
|
* avant son premier rendu, pour ne pas faire clignoter le bouton.
|
|
31
31
|
*/
|
|
32
32
|
feedbackEnabled: z.boolean(),
|
|
33
|
+
/** The marketing site (`SITE_URL`), for the legal links. `null`: none. */
|
|
34
|
+
siteUrl: z.string().url().nullable(),
|
|
33
35
|
/**
|
|
34
36
|
* Admin only: the process booted with `MAINTENANCE=1` and no admin has
|
|
35
37
|
* closed the reminder. Shown once the site maintenance is lifted. Read at
|
|
@@ -139,7 +141,12 @@ export type MeResponse = z.infer<typeof meResponseSchema>;
|
|
|
139
141
|
*/
|
|
140
142
|
export const signupAvailabilitySchema = z.object({
|
|
141
143
|
/** Can an account be self-created here: the server allows it, or no account exists yet. */
|
|
142
|
-
open: z.boolean()
|
|
144
|
+
open: z.boolean(),
|
|
145
|
+
/**
|
|
146
|
+
* The marketing site of this DevEye (`SITE_URL`), where its legal pages
|
|
147
|
+
* live. `null` on a self-hosted instance without one: no terms to accept.
|
|
148
|
+
*/
|
|
149
|
+
siteUrl: z.string().url().nullable()
|
|
143
150
|
});
|
|
144
151
|
|
|
145
152
|
export type SignupAvailability = z.infer<typeof signupAvailabilitySchema>;
|
|
@@ -151,7 +158,9 @@ export const signupStartRequestSchema = z.object({
|
|
|
151
158
|
plan: z
|
|
152
159
|
.string()
|
|
153
160
|
.regex(/^[a-z0-9_-]{1,64}$/)
|
|
154
|
-
.optional()
|
|
161
|
+
.optional(),
|
|
162
|
+
/** The terms of use and privacy policy were accepted. Required when the server has a `siteUrl`. */
|
|
163
|
+
termsAccepted: z.boolean()
|
|
155
164
|
});
|
|
156
165
|
|
|
157
166
|
export type SignupStartRequest = z.infer<typeof signupStartRequestSchema>;
|
package/src/http/device.ts
CHANGED
|
@@ -5,29 +5,24 @@ import { devicePlatformSchema, deviceSchema } from '../domain/device';
|
|
|
5
5
|
* Device linking & enrollment (HTTP, distinct from the user feature protocol).
|
|
6
6
|
*
|
|
7
7
|
* Flow:
|
|
8
|
-
* 1. A
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* 1. A member holding `devices: write` issues a short-lived link code for the
|
|
9
|
+
* active workspace.
|
|
10
|
+
* 2. The agent posts the code and its machine fingerprint to enroll.
|
|
11
|
+
* 3. A fingerprint new to the workspace is enrolled `active`, once the plan
|
|
12
|
+
* allows one more device (checked before the code is consumed). A known
|
|
13
|
+
* fingerprint takes over that device record: a fresh token replaces the
|
|
14
|
+
* old one and the device waits, `pending`, for someone to approve it.
|
|
12
15
|
*/
|
|
13
16
|
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
* workspace: it always expires.
|
|
17
|
-
*/
|
|
18
|
-
export const LINK_CODE_TTL_MAX_SECONDS = 30 * 24 * 60 * 60;
|
|
17
|
+
/** Hard cap on a code lifetime (one hour). A link code is a key to the workspace. */
|
|
18
|
+
export const LINK_CODE_TTL_MAX_SECONDS = 60 * 60;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Request a new link code. `ttlSeconds` omitted → server default lifetime,
|
|
22
22
|
* otherwise a lifetime in seconds.
|
|
23
23
|
*/
|
|
24
24
|
export const linkCodeRequestSchema = z.object({
|
|
25
|
-
ttlSeconds: z.number().int().positive().max(LINK_CODE_TTL_MAX_SECONDS).optional()
|
|
26
|
-
/**
|
|
27
|
-
* Approve the device the moment it enrols with this code, instead of
|
|
28
|
-
* leaving it `pending` for manual approval. Defaults to `false`.
|
|
29
|
-
*/
|
|
30
|
-
autoApprove: z.boolean().default(false)
|
|
25
|
+
ttlSeconds: z.number().int().positive().max(LINK_CODE_TTL_MAX_SECONDS).optional()
|
|
31
26
|
});
|
|
32
27
|
|
|
33
28
|
export type LinkCodeRequest = z.infer<typeof linkCodeRequestSchema>;
|
|
@@ -35,22 +30,13 @@ export type LinkCodeRequest = z.infer<typeof linkCodeRequestSchema>;
|
|
|
35
30
|
export const linkCodeResponseSchema = z.object({
|
|
36
31
|
/** Short human-typable code (e.g. shown in the UI, entered on the agent). */
|
|
37
32
|
code: z.string().min(6).max(32),
|
|
38
|
-
/** Unix seconds when the code expires
|
|
39
|
-
expiresAt: z.number().int().positive()
|
|
40
|
-
/** Whether a device enrolling with this code is approved automatically. */
|
|
41
|
-
autoApprove: z.boolean()
|
|
33
|
+
/** Unix seconds when the code expires. */
|
|
34
|
+
expiresAt: z.number().int().positive()
|
|
42
35
|
});
|
|
43
36
|
|
|
44
37
|
export type LinkCodeResponse = z.infer<typeof linkCodeResponseSchema>;
|
|
45
38
|
|
|
46
|
-
/**
|
|
47
|
-
export const linkCodeUpdateSchema = z.object({
|
|
48
|
-
autoApprove: z.boolean()
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export type LinkCodeUpdate = z.infer<typeof linkCodeUpdateSchema>;
|
|
52
|
-
|
|
53
|
-
/** Currently-active (unconsumed, unexpired) link codes for the caller. */
|
|
39
|
+
/** The workspace's link codes still usable (unconsumed, unexpired). */
|
|
54
40
|
export const linkCodesListResponseSchema = z.object({
|
|
55
41
|
codes: z.array(linkCodeResponseSchema)
|
|
56
42
|
});
|
package/src/http/status.ts
CHANGED
|
@@ -41,3 +41,29 @@ export const serverStatusSchema = z.object({
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
export type ServerStatus = z.infer<typeof serverStatusSchema>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `GET /.well-known/deveye-build.json`: every file of the web client this
|
|
47
|
+
* server serves, with its SHA-256, written at build time. It is NOT a trusted
|
|
48
|
+
* reference (a compromised server would rewrite it along with the files): it
|
|
49
|
+
* is the LIST of what an integrity monitor on another instance must fetch,
|
|
50
|
+
* lazily loaded chunks included, which nothing else names.
|
|
51
|
+
*/
|
|
52
|
+
export const buildManifestSchema = z.object({
|
|
53
|
+
format: z.literal(1),
|
|
54
|
+
version: z.string(),
|
|
55
|
+
/** Path relative to the site root (no leading slash) to the file's SHA-256, hex. */
|
|
56
|
+
files: z.record(
|
|
57
|
+
z
|
|
58
|
+
.string()
|
|
59
|
+
.min(1)
|
|
60
|
+
.max(512)
|
|
61
|
+
.regex(/^(?!\/)(?!.*(^|\/)\.\.(\/|$))[^\s]+$/),
|
|
62
|
+
z.string().regex(/^[0-9a-f]{64}$/)
|
|
63
|
+
)
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export type BuildManifest = z.infer<typeof buildManifestSchema>;
|
|
67
|
+
|
|
68
|
+
/** Where a DevEye instance publishes its build manifest. */
|
|
69
|
+
export const BUILD_MANIFEST_PATH = '/.well-known/deveye-build.json';
|