@deveye/types 0.19.0 → 0.19.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/package.json +1 -1
- package/src/domain/remoteInstance.test.ts +35 -0
- package/src/domain/remoteInstance.ts +70 -0
- package/src/domain/sharing.ts +46 -1
- package/src/features/registry.ts +2 -0
- package/src/features/remote.ts +52 -0
- package/src/features/sharing.ts +78 -2
- package/src/http/auth.ts +52 -7
- package/src/http/status.ts +2 -0
- package/src/index.ts +39 -2
- package/src/sdk/client-ambient.d.ts +12 -4
- package/src/sdk/copy.test.ts +374 -0
- package/src/sdk/copy.ts +435 -0
- package/src/sdk/server.ts +86 -0
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { describe, it } from 'node:test';
|
|
3
|
+
|
|
4
|
+
import { normalizeRemoteOrigin } from './remoteInstance';
|
|
5
|
+
|
|
6
|
+
describe('normalizeRemoteOrigin', () => {
|
|
7
|
+
it('ramène une adresse à son origine', () => {
|
|
8
|
+
assert.equal(
|
|
9
|
+
normalizeRemoteOrigin(' https://DevEye.Exemple.fr/ '),
|
|
10
|
+
'https://deveye.exemple.fr'
|
|
11
|
+
);
|
|
12
|
+
assert.equal(
|
|
13
|
+
normalizeRemoteOrigin('https://deveye.exemple.fr:443'),
|
|
14
|
+
'https://deveye.exemple.fr'
|
|
15
|
+
);
|
|
16
|
+
assert.equal(normalizeRemoteOrigin('http://10.0.0.4:3000'), 'http://10.0.0.4:3000');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('refuse tout ce qui déborderait dans un en-tête CSP', () => {
|
|
20
|
+
for (const input of [
|
|
21
|
+
'deveye.exemple.fr',
|
|
22
|
+
'ftp://deveye.exemple.fr',
|
|
23
|
+
'https://*.exemple.fr',
|
|
24
|
+
'https://user:pass@exemple.fr',
|
|
25
|
+
'https://exemple.fr/chemin',
|
|
26
|
+
'https://exemple.fr/?q=1',
|
|
27
|
+
'https://exemple.fr/#a',
|
|
28
|
+
'https://[::1]:3000',
|
|
29
|
+
"https://exemple.fr; script-src 'unsafe-inline'",
|
|
30
|
+
'https://exemple.fr evil.example'
|
|
31
|
+
]) {
|
|
32
|
+
assert.equal(normalizeRemoteOrigin(input), null, input);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Une instance distante : un AUTRE serveur DevEye dont le compte range les
|
|
5
|
+
* espaces à côté des siens. Le serveur d'accueil n'en retient que l'adresse et
|
|
6
|
+
* un libellé, et ne la contacte jamais : c'est le navigateur qui y ouvre sa
|
|
7
|
+
* propre session, avec les identifiants de là-bas, qu'aucun serveur ne garde.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Instances distantes par compte. Chacune élargit la politique de contenu de sa page. */
|
|
11
|
+
export const REMOTE_INSTANCES_MAX = 5;
|
|
12
|
+
|
|
13
|
+
export const REMOTE_LABEL_MAX = 60;
|
|
14
|
+
|
|
15
|
+
/** Nom d'hôte ou IPv4. Une IPv6 littérale n'a pas de forme dans une source CSP. */
|
|
16
|
+
const HOST_PATTERN = /^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$/;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Ramène une adresse saisie à son origine (`https://hôte[:port]`), ou `null`.
|
|
20
|
+
* Stricte parce que l'origine finit dans un en-tête `Content-Security-Policy` :
|
|
21
|
+
* ni chemin, ni identifiants, ni joker, rien qui puisse y injecter une directive.
|
|
22
|
+
*/
|
|
23
|
+
export function normalizeRemoteOrigin(input: string): string | null {
|
|
24
|
+
let url: URL;
|
|
25
|
+
try {
|
|
26
|
+
url = new URL(input.trim());
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') return null;
|
|
31
|
+
if (url.username || url.password || url.search || url.hash) return null;
|
|
32
|
+
if (url.pathname !== '/' && url.pathname !== '') return null;
|
|
33
|
+
if (!HOST_PATTERN.test(url.hostname)) return null;
|
|
34
|
+
return url.origin;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const remoteOriginSchema = z
|
|
38
|
+
.string()
|
|
39
|
+
.min(1)
|
|
40
|
+
.max(255)
|
|
41
|
+
.transform((value, ctx) => {
|
|
42
|
+
const origin = normalizeRemoteOrigin(value);
|
|
43
|
+
if (origin === null) {
|
|
44
|
+
ctx.addIssue({
|
|
45
|
+
code: z.ZodIssueCode.custom,
|
|
46
|
+
message: 'Adresse attendue sous la forme https://hôte ou https://hôte:port'
|
|
47
|
+
});
|
|
48
|
+
return z.NEVER;
|
|
49
|
+
}
|
|
50
|
+
return origin;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const remoteInstanceSchema = z.object({
|
|
54
|
+
id: z.number().int().positive(),
|
|
55
|
+
label: z.string().min(1).max(REMOTE_LABEL_MAX),
|
|
56
|
+
origin: z.string().min(1).max(255),
|
|
57
|
+
created: z.number().int().nonnegative()
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export type RemoteInstance = z.infer<typeof remoteInstanceSchema>;
|
|
61
|
+
|
|
62
|
+
/** Ligne SQL (serveur uniquement). */
|
|
63
|
+
export interface RemoteInstanceRow {
|
|
64
|
+
id: number;
|
|
65
|
+
user_id: number;
|
|
66
|
+
label: string;
|
|
67
|
+
origin: string;
|
|
68
|
+
sort_order: number;
|
|
69
|
+
created: number;
|
|
70
|
+
}
|
package/src/domain/sharing.ts
CHANGED
|
@@ -64,10 +64,55 @@ export const itemShareStateSchema = z.object({
|
|
|
64
64
|
* pas pourquoi : c'est `share.movePreview`, une fois la cible choisie, qui
|
|
65
65
|
* porte les motifs.
|
|
66
66
|
*/
|
|
67
|
-
movable: z.boolean().default(false)
|
|
67
|
+
movable: z.boolean().default(false),
|
|
68
|
+
/**
|
|
69
|
+
* L'élément peut être copié ailleurs : sa fonctionnalité sait décrire ce
|
|
70
|
+
* dont il est fait, et l'appelant peut le lire. Vers où, c'est l'écran qui
|
|
71
|
+
* le propose : la cible peut être une autre instance, que ce serveur ignore.
|
|
72
|
+
*/
|
|
73
|
+
copyable: z.boolean().default(false)
|
|
68
74
|
});
|
|
69
75
|
export type ItemShareState = z.infer<typeof itemShareStateSchema>;
|
|
70
76
|
|
|
77
|
+
/** Le palier d'un élément : sous la clé de l'espace, ou sous celle du mot de passe de son auteur. */
|
|
78
|
+
export const itemTierSchema = z.enum(['open', 'private']);
|
|
79
|
+
|
|
80
|
+
/** Ce que la SOURCE dit d'une copie, avant d'avoir rien lu. */
|
|
81
|
+
export const itemCopyPlanSchema = z.object({
|
|
82
|
+
/** L'intitulé de l'élément, pour la confirmation ; `null` quand il est illisible d'ici. */
|
|
83
|
+
label: z.string().nullable(),
|
|
84
|
+
tier: itemTierSchema,
|
|
85
|
+
/** Pourquoi la copie est impossible, en phrases prêtes à afficher. Vide : elle peut partir. */
|
|
86
|
+
blockers: z.array(z.string()),
|
|
87
|
+
/** Ce que la copie n'emportera pas, à énumérer dans la confirmation. */
|
|
88
|
+
drops: z.array(z.string())
|
|
89
|
+
});
|
|
90
|
+
export type ItemCopyPlan = z.infer<typeof itemCopyPlanSchema>;
|
|
91
|
+
|
|
92
|
+
/** Ce que la DESTINATION dit d'une copie, avant de rien recevoir. */
|
|
93
|
+
export const itemCopyTargetSchema = z.object({
|
|
94
|
+
workspaceName: z.string(),
|
|
95
|
+
/**
|
|
96
|
+
* Le palier que la copie aura là-bas. Une copie `private` devient `open`
|
|
97
|
+
* dans un espace partagé, qui n'a pas de palier gardé : ses membres la liront.
|
|
98
|
+
*/
|
|
99
|
+
tier: itemTierSchema,
|
|
100
|
+
blockers: z.array(z.string())
|
|
101
|
+
});
|
|
102
|
+
export type ItemCopyTarget = z.infer<typeof itemCopyTargetSchema>;
|
|
103
|
+
|
|
104
|
+
/** Un paquet de copie découpé : de quoi le transporter, et vérifier à l'arrivée qu'il est entier. */
|
|
105
|
+
export const itemCopyManifestSchema = z.object({
|
|
106
|
+
bytes: z.number().int().nonnegative(),
|
|
107
|
+
chunks: z.number().int().positive().max(4096),
|
|
108
|
+
/** Condensé du paquet entier : la destination refuse ce qui a changé en route. */
|
|
109
|
+
sha256: z.string().regex(/^[0-9a-f]{64}$/)
|
|
110
|
+
});
|
|
111
|
+
export type ItemCopyManifest = z.infer<typeof itemCopyManifestSchema>;
|
|
112
|
+
|
|
113
|
+
/** Taille d'une tranche, en caractères : bien sous le plafond d'une trame. */
|
|
114
|
+
export const ITEM_COPY_CHUNK_CHARS = 512 * 1024;
|
|
115
|
+
|
|
71
116
|
/**
|
|
72
117
|
* Une liaison que le déplacement va rompre. Une liaison ne traverse jamais un
|
|
73
118
|
* espace : ce qui vise l'élément depuis celui qu'il quitte est retiré, et
|
package/src/features/registry.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { linksCommands } from './links';
|
|
|
7
7
|
import { liveCommands } from './live';
|
|
8
8
|
import { logsCommands } from './logs';
|
|
9
9
|
import { notifyCommands } from './notify';
|
|
10
|
+
import { remoteCommands } from './remote';
|
|
10
11
|
import { sharingCommands } from './sharing';
|
|
11
12
|
import { secrecyCommands } from './secrecy';
|
|
12
13
|
import { twoFactorCommands } from './twoFactor';
|
|
@@ -22,6 +23,7 @@ export interface FeatureCommandDescriptor<C extends string = string> {
|
|
|
22
23
|
|
|
23
24
|
export const featureCommands = [
|
|
24
25
|
...workspaceCommands,
|
|
26
|
+
...remoteCommands,
|
|
25
27
|
...adminCommands,
|
|
26
28
|
...userCommands,
|
|
27
29
|
...agentCommands,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
REMOTE_LABEL_MAX,
|
|
4
|
+
remoteInstanceSchema,
|
|
5
|
+
remoteOriginSchema
|
|
6
|
+
} from '../domain/remoteInstance';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Les instances distantes du compte. Commandes de compte : elles visent la
|
|
10
|
+
* ligne de l'appelant quel que soit l'espace porté par l'enveloppe.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const labelSchema = z.string().trim().min(1).max(REMOTE_LABEL_MAX);
|
|
14
|
+
|
|
15
|
+
export const remoteList = {
|
|
16
|
+
command: 'remote.list' as const,
|
|
17
|
+
input: z.object({}),
|
|
18
|
+
output: z.object({ instances: z.array(remoteInstanceSchema) })
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const remoteAdd = {
|
|
22
|
+
command: 'remote.add' as const,
|
|
23
|
+
input: z.object({ label: labelSchema, origin: remoteOriginSchema }),
|
|
24
|
+
output: z.object({ instance: remoteInstanceSchema })
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const remoteRename = {
|
|
28
|
+
command: 'remote.rename' as const,
|
|
29
|
+
input: z.object({ id: z.number().int().positive(), label: labelSchema }),
|
|
30
|
+
output: z.object({ instance: remoteInstanceSchema })
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const remoteRemove = {
|
|
34
|
+
command: 'remote.remove' as const,
|
|
35
|
+
input: z.object({ id: z.number().int().positive() }),
|
|
36
|
+
output: z.object({ id: z.number().int().positive() })
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** L'ordre complet des instances, tel que le menu des espaces les range. */
|
|
40
|
+
export const remoteReorder = {
|
|
41
|
+
command: 'remote.reorder' as const,
|
|
42
|
+
input: z.object({ ids: z.array(z.number().int().positive()).max(32) }),
|
|
43
|
+
output: z.object({ instances: z.array(remoteInstanceSchema) })
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const remoteCommands = [
|
|
47
|
+
remoteList,
|
|
48
|
+
remoteAdd,
|
|
49
|
+
remoteRename,
|
|
50
|
+
remoteRemove,
|
|
51
|
+
remoteReorder
|
|
52
|
+
] as const;
|
package/src/features/sharing.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
ITEM_COPY_CHUNK_CHARS,
|
|
4
5
|
itemAccessSchema,
|
|
6
|
+
itemCopyManifestSchema,
|
|
7
|
+
itemCopyPlanSchema,
|
|
8
|
+
itemCopyTargetSchema,
|
|
5
9
|
itemExtraOverridesSchema,
|
|
6
10
|
itemGrantStateSchema,
|
|
7
11
|
itemMovePreviewSchema,
|
|
8
12
|
itemRefSchema,
|
|
9
|
-
itemShareStateSchema
|
|
13
|
+
itemShareStateSchema,
|
|
14
|
+
itemTierSchema
|
|
10
15
|
} from '../domain/sharing';
|
|
16
|
+
import { featureIdSchema } from '../domain/workspaceRole';
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
19
|
* Le partage d'un élément et ses restrictions par rôle. Un module transversal :
|
|
@@ -104,11 +110,81 @@ export const itemMove = {
|
|
|
104
110
|
output: z.object({ workspaceId: z.number().int().positive() })
|
|
105
111
|
};
|
|
106
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Copier un élément vers un autre espace, d'ici ou d'une AUTRE instance. Le
|
|
115
|
+
* même chemin dans les deux cas : la source rend l'élément en clair, par
|
|
116
|
+
* tranches, au navigateur, qui le remet à la destination, laquelle le scelle
|
|
117
|
+
* sous sa propre clé. Les deux serveurs ne se parlent pas, et la moitié
|
|
118
|
+
* « source » ne sait rien de la cible.
|
|
119
|
+
*
|
|
120
|
+
* Les trois premières commandes visent l'espace de l'élément, les quatre
|
|
121
|
+
* suivantes l'espace d'arrivée, porté par l'enveloppe.
|
|
122
|
+
*/
|
|
123
|
+
export const itemCopyPlan = {
|
|
124
|
+
command: 'share.copyPlan' as const,
|
|
125
|
+
input: itemRefSchema,
|
|
126
|
+
output: itemCopyPlanSchema
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** Lit l'élément et le tient prêt, quelques minutes. `locked` : un élément gardé veut le coffre ouvert. */
|
|
130
|
+
export const itemCopyExport = {
|
|
131
|
+
command: 'share.copyExport' as const,
|
|
132
|
+
input: itemRefSchema,
|
|
133
|
+
output: itemCopyManifestSchema.extend({ exportId: z.string().uuid() })
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/** Une tranche du paquet. La dernière rendue, la source l'oublie. */
|
|
137
|
+
export const itemCopyChunk = {
|
|
138
|
+
command: 'share.copyChunk' as const,
|
|
139
|
+
input: z.object({ exportId: z.string().uuid(), index: z.number().int().nonnegative() }),
|
|
140
|
+
output: z.object({ data: z.string().max(ITEM_COPY_CHUNK_CHARS) })
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const itemCopyTarget = {
|
|
144
|
+
command: 'share.copyTarget' as const,
|
|
145
|
+
input: z.object({ feature: featureIdSchema, tier: itemTierSchema }),
|
|
146
|
+
output: itemCopyTargetSchema
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const itemCopyBegin = {
|
|
150
|
+
command: 'share.copyBegin' as const,
|
|
151
|
+
input: itemCopyManifestSchema.extend({ feature: featureIdSchema }),
|
|
152
|
+
output: z.object({ importId: z.string().uuid() })
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const itemCopyPut = {
|
|
156
|
+
command: 'share.copyPut' as const,
|
|
157
|
+
input: z.object({
|
|
158
|
+
importId: z.string().uuid(),
|
|
159
|
+
index: z.number().int().nonnegative(),
|
|
160
|
+
data: z.string().max(ITEM_COPY_CHUNK_CHARS)
|
|
161
|
+
}),
|
|
162
|
+
output: z.object({ received: z.number().int().nonnegative() })
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Vérifie le paquet, puis écrit l'élément d'un seul tenant. `locked` : le palier
|
|
167
|
+
* gardé veut le coffre ouvert. `feature` redit celle du transfert : c'est sur
|
|
168
|
+
* elle que le serveur prévient ceux qui regardent la liste d'arrivée.
|
|
169
|
+
*/
|
|
170
|
+
export const itemCopyCommit = {
|
|
171
|
+
command: 'share.copyCommit' as const,
|
|
172
|
+
input: z.object({ importId: z.string().uuid(), feature: featureIdSchema }),
|
|
173
|
+
output: z.object({ itemId: z.string() })
|
|
174
|
+
};
|
|
175
|
+
|
|
107
176
|
export const sharingCommands = [
|
|
108
177
|
shareGet,
|
|
109
178
|
shareSet,
|
|
110
179
|
itemGrantList,
|
|
111
180
|
itemGrantSet,
|
|
112
181
|
itemMovePreview,
|
|
113
|
-
itemMove
|
|
182
|
+
itemMove,
|
|
183
|
+
itemCopyPlan,
|
|
184
|
+
itemCopyExport,
|
|
185
|
+
itemCopyChunk,
|
|
186
|
+
itemCopyTarget,
|
|
187
|
+
itemCopyBegin,
|
|
188
|
+
itemCopyPut,
|
|
189
|
+
itemCopyCommit
|
|
114
190
|
] as const;
|
package/src/http/auth.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { homeLayoutSchema } from '../domain/home';
|
|
3
|
+
import { remoteInstanceSchema } from '../domain/remoteInstance';
|
|
3
4
|
import { usernameSchema, userSchema } from '../domain/user';
|
|
4
5
|
import { workspaceSchema } from '../domain/workspace';
|
|
5
6
|
import { workspacePermissionsSchema } from '../domain/workspaceRole';
|
|
@@ -15,6 +16,8 @@ import { themeStateSchema } from '../features/user';
|
|
|
15
16
|
export const sessionBundleSchema = z.object({
|
|
16
17
|
user: userSchema,
|
|
17
18
|
workspaces: z.array(workspaceSchema),
|
|
19
|
+
/** Les instances distantes du compte, dans l'ordre du menu. Leurs espaces se lisent là-bas. */
|
|
20
|
+
remoteInstances: z.array(remoteInstanceSchema),
|
|
18
21
|
/** Espace chargé à l'ouverture : le favori s'il est encore accessible, sinon le personnel. */
|
|
19
22
|
activeWorkspaceId: z.number().int().positive(),
|
|
20
23
|
theme: themeStateSchema.nullable(),
|
|
@@ -38,6 +41,21 @@ export const loginRequestSchema = z.object({
|
|
|
38
41
|
|
|
39
42
|
export type LoginRequest = z.infer<typeof loginRequestSchema>;
|
|
40
43
|
|
|
44
|
+
/**
|
|
45
|
+
* The tokens of a federated session: one opened by the page of ANOTHER DevEye
|
|
46
|
+
* instance, whose origin this server lists in `FEDERATION_ORIGINS`. Such a page
|
|
47
|
+
* cannot hold this server's cookies, so it carries the tokens itself: the access
|
|
48
|
+
* token as `Authorization: Bearer`, the refresh token in the body of `/refresh`.
|
|
49
|
+
*/
|
|
50
|
+
export const sessionTokensSchema = z.object({
|
|
51
|
+
access: z.string(),
|
|
52
|
+
refresh: z.string(),
|
|
53
|
+
/** Lifetime of `access`, so the page can renew it before it lapses. */
|
|
54
|
+
accessTtlSeconds: z.number().int().positive()
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export type SessionTokens = z.infer<typeof sessionTokensSchema>;
|
|
58
|
+
|
|
41
59
|
/** A password being chosen: the one account policy, at sign-up and at change. */
|
|
42
60
|
export const passwordSchema = z.string().min(8).max(512);
|
|
43
61
|
|
|
@@ -48,35 +66,62 @@ export const changePasswordRequestSchema = z.object({
|
|
|
48
66
|
|
|
49
67
|
export type ChangePasswordRequest = z.infer<typeof changePasswordRequestSchema>;
|
|
50
68
|
|
|
51
|
-
export const changePasswordResponseSchema = z.object({
|
|
69
|
+
export const changePasswordResponseSchema = z.object({
|
|
70
|
+
changed: z.literal(true),
|
|
71
|
+
/** The renewed tokens of a federated session. */
|
|
72
|
+
tokens: sessionTokensSchema.optional()
|
|
73
|
+
});
|
|
52
74
|
|
|
53
75
|
export type ChangePasswordResponse = z.infer<typeof changePasswordResponseSchema>;
|
|
54
76
|
|
|
55
77
|
/**
|
|
56
78
|
* The auth flow returns the authenticated user and its workspaces in one shot.
|
|
57
|
-
* Tokens are delivered as HttpOnly cookies, never in the JSON body
|
|
79
|
+
* Tokens are delivered as HttpOnly cookies, never in the JSON body, except to a
|
|
80
|
+
* federated origin (`tokens`, see {@link sessionTokensSchema}).
|
|
58
81
|
*
|
|
59
82
|
* When 2FA is enabled, login first replies with `twoFactorRequired` and an
|
|
60
|
-
* interim challenge token (cookie
|
|
83
|
+
* interim challenge token (a cookie, or `challenge` for a federated origin); the
|
|
84
|
+
* client then posts a TOTP/backup code.
|
|
61
85
|
*/
|
|
62
86
|
export const loginResponseSchema = z.discriminatedUnion('twoFactorRequired', [
|
|
63
|
-
sessionBundleSchema.extend({
|
|
64
|
-
|
|
87
|
+
sessionBundleSchema.extend({
|
|
88
|
+
twoFactorRequired: z.literal(false),
|
|
89
|
+
tokens: sessionTokensSchema.optional()
|
|
90
|
+
}),
|
|
91
|
+
z.object({ twoFactorRequired: z.literal(true), challenge: z.string().optional() })
|
|
65
92
|
]);
|
|
66
93
|
|
|
67
94
|
export type LoginResponse = z.infer<typeof loginResponseSchema>;
|
|
68
95
|
|
|
69
96
|
export const twoFactorChallengeRequestSchema = z.object({
|
|
70
97
|
/** A 6-digit TOTP code or a recovery backup code. */
|
|
71
|
-
code: z.string().min(6).max(24)
|
|
98
|
+
code: z.string().min(6).max(24),
|
|
99
|
+
/** The challenge handed by `/login`, from a federated origin (no cookie holds it there). */
|
|
100
|
+
challenge: z.string().max(2048).optional()
|
|
72
101
|
});
|
|
73
102
|
|
|
74
103
|
export type TwoFactorChallengeRequest = z.infer<typeof twoFactorChallengeRequestSchema>;
|
|
75
104
|
|
|
76
|
-
|
|
105
|
+
/** Body of `/refresh` and `/logout` from a federated origin; a same-origin page sends none. */
|
|
106
|
+
export const refreshRequestSchema = z.object({ refreshToken: z.string().max(2048) });
|
|
107
|
+
|
|
108
|
+
export type RefreshRequest = z.infer<typeof refreshRequestSchema>;
|
|
109
|
+
|
|
110
|
+
export const refreshResponseSchema = sessionBundleSchema.extend({
|
|
111
|
+
tokens: sessionTokensSchema.optional()
|
|
112
|
+
});
|
|
77
113
|
|
|
78
114
|
export type RefreshResponse = z.infer<typeof refreshResponseSchema>;
|
|
79
115
|
|
|
116
|
+
/**
|
|
117
|
+
* `POST /api/auth/ws-ticket`: what a federated page opens the socket with
|
|
118
|
+
* (`/ws?ticket=`), a browser being unable to set a header on a WebSocket.
|
|
119
|
+
* Seconds-lived and single-use.
|
|
120
|
+
*/
|
|
121
|
+
export const wsTicketResponseSchema = z.object({ ticket: z.string() });
|
|
122
|
+
|
|
123
|
+
export type WsTicketResponse = z.infer<typeof wsTicketResponseSchema>;
|
|
124
|
+
|
|
80
125
|
export const meResponseSchema = sessionBundleSchema;
|
|
81
126
|
|
|
82
127
|
export type MeResponse = z.infer<typeof meResponseSchema>;
|
package/src/http/status.ts
CHANGED
|
@@ -35,6 +35,8 @@ export const serverStatusSchema = z.object({
|
|
|
35
35
|
ready: z.boolean(),
|
|
36
36
|
/** DevEye server version (its `package.json`). */
|
|
37
37
|
version: z.string(),
|
|
38
|
+
/** Does this server let another instance's page open a session (`FEDERATION_ORIGINS`)? */
|
|
39
|
+
federation: z.boolean(),
|
|
38
40
|
tasks: z.array(bootTaskSchema)
|
|
39
41
|
});
|
|
40
42
|
|
package/src/index.ts
CHANGED
|
@@ -525,6 +525,14 @@ export type {
|
|
|
525
525
|
export { secrecyStatusSchema, secrecyWrapModeSchema } from './domain/secrecy';
|
|
526
526
|
export type { SecrecyStatus, SecrecyWrapMode, UserSecretKeyRow } from './domain/secrecy';
|
|
527
527
|
export { workspaceKindSchema, workspaceSchema } from './domain/workspace';
|
|
528
|
+
export {
|
|
529
|
+
REMOTE_INSTANCES_MAX,
|
|
530
|
+
REMOTE_LABEL_MAX,
|
|
531
|
+
normalizeRemoteOrigin,
|
|
532
|
+
remoteInstanceSchema,
|
|
533
|
+
remoteOriginSchema
|
|
534
|
+
} from './domain/remoteInstance';
|
|
535
|
+
export type { RemoteInstance, RemoteInstanceRow } from './domain/remoteInstance';
|
|
528
536
|
export {
|
|
529
537
|
EXTERNAL_FEATURE_ID_PATTERN,
|
|
530
538
|
externalFeatureIdSchema,
|
|
@@ -669,7 +677,12 @@ export {
|
|
|
669
677
|
itemExtraOverridesSchema,
|
|
670
678
|
itemGrantStateSchema,
|
|
671
679
|
itemMoveDependencySchema,
|
|
680
|
+
ITEM_COPY_CHUNK_CHARS,
|
|
681
|
+
itemCopyManifestSchema,
|
|
682
|
+
itemCopyPlanSchema,
|
|
683
|
+
itemCopyTargetSchema,
|
|
672
684
|
itemMovePreviewSchema,
|
|
685
|
+
itemTierSchema,
|
|
673
686
|
itemRefSchema,
|
|
674
687
|
itemRoleGrantSchema,
|
|
675
688
|
itemRoleGrantViewSchema,
|
|
@@ -683,6 +696,9 @@ export type {
|
|
|
683
696
|
ItemExtraOverrides,
|
|
684
697
|
ItemGrantState,
|
|
685
698
|
ItemMoveDependency,
|
|
699
|
+
ItemCopyManifest,
|
|
700
|
+
ItemCopyPlan,
|
|
701
|
+
ItemCopyTarget,
|
|
686
702
|
ItemMovePreview,
|
|
687
703
|
ItemRef,
|
|
688
704
|
ItemRoleGrant,
|
|
@@ -697,6 +713,13 @@ export {
|
|
|
697
713
|
itemGrantList,
|
|
698
714
|
itemGrantSet,
|
|
699
715
|
itemMove,
|
|
716
|
+
itemCopyBegin,
|
|
717
|
+
itemCopyChunk,
|
|
718
|
+
itemCopyCommit,
|
|
719
|
+
itemCopyExport,
|
|
720
|
+
itemCopyPlan,
|
|
721
|
+
itemCopyPut,
|
|
722
|
+
itemCopyTarget,
|
|
700
723
|
itemMovePreview,
|
|
701
724
|
shareGet,
|
|
702
725
|
shareSet,
|
|
@@ -782,6 +805,14 @@ export {
|
|
|
782
805
|
workspaceRoleUpdate,
|
|
783
806
|
workspaceSetFavorite
|
|
784
807
|
} from './features/workspace';
|
|
808
|
+
export {
|
|
809
|
+
remoteAdd,
|
|
810
|
+
remoteCommands,
|
|
811
|
+
remoteList,
|
|
812
|
+
remoteRemove,
|
|
813
|
+
remoteRename,
|
|
814
|
+
remoteReorder
|
|
815
|
+
} from './features/remote';
|
|
785
816
|
export {
|
|
786
817
|
AVATAR_MAX_LENGTH,
|
|
787
818
|
THEME_IMAGE_MAX_LENGTH,
|
|
@@ -891,8 +922,10 @@ export {
|
|
|
891
922
|
loginResponseSchema,
|
|
892
923
|
meResponseSchema,
|
|
893
924
|
passwordSchema,
|
|
925
|
+
refreshRequestSchema,
|
|
894
926
|
refreshResponseSchema,
|
|
895
927
|
sessionBundleSchema,
|
|
928
|
+
sessionTokensSchema,
|
|
896
929
|
signupAvailabilitySchema,
|
|
897
930
|
signupCompleteRequestSchema,
|
|
898
931
|
signupCompleteResponseSchema,
|
|
@@ -901,7 +934,8 @@ export {
|
|
|
901
934
|
signupStatusSchema,
|
|
902
935
|
signupVerifyRequestSchema,
|
|
903
936
|
signupVerifyResponseSchema,
|
|
904
|
-
twoFactorChallengeRequestSchema
|
|
937
|
+
twoFactorChallengeRequestSchema,
|
|
938
|
+
wsTicketResponseSchema
|
|
905
939
|
} from './http/auth';
|
|
906
940
|
export type {
|
|
907
941
|
ChangePasswordRequest,
|
|
@@ -909,8 +943,10 @@ export type {
|
|
|
909
943
|
LoginRequest,
|
|
910
944
|
LoginResponse,
|
|
911
945
|
MeResponse,
|
|
946
|
+
RefreshRequest,
|
|
912
947
|
RefreshResponse,
|
|
913
948
|
SessionBundle,
|
|
949
|
+
SessionTokens,
|
|
914
950
|
SignupAvailability,
|
|
915
951
|
SignupCompleteRequest,
|
|
916
952
|
SignupCompleteResponse,
|
|
@@ -919,7 +955,8 @@ export type {
|
|
|
919
955
|
SignupStatus,
|
|
920
956
|
SignupVerifyRequest,
|
|
921
957
|
SignupVerifyResponse,
|
|
922
|
-
TwoFactorChallengeRequest
|
|
958
|
+
TwoFactorChallengeRequest,
|
|
959
|
+
WsTicketResponse
|
|
923
960
|
} from './http/auth';
|
|
924
961
|
export {
|
|
925
962
|
AGENT_TARGETS,
|
|
@@ -469,13 +469,21 @@ declare module 'deveye-sdk-client' {
|
|
|
469
469
|
*/
|
|
470
470
|
export const APP_VERSION: string;
|
|
471
471
|
/**
|
|
472
|
-
* A validated GET on one of the app's HTTP routes
|
|
473
|
-
*
|
|
472
|
+
* A validated GET on one of the app's HTTP routes, authenticated as the
|
|
473
|
+
* session is (an expired access token is renewed and the call replayed
|
|
474
474
|
* once). For the routes that stay HTTP because they serve binaries.
|
|
475
|
+
*
|
|
476
|
+
* Always pass a PATH, never an absolute URL: the active workspace may live
|
|
477
|
+
* on a remote DevEye instance, and the host routes the call there.
|
|
475
478
|
*/
|
|
476
479
|
export function httpGet<T>(path: string, outputSchema?: ZodType<T>): Promise<T>;
|
|
477
|
-
/**
|
|
478
|
-
|
|
480
|
+
/**
|
|
481
|
+
* A raw `fetch` on one of the app's HTTP routes, for a response that is not
|
|
482
|
+
* the usual JSON envelope (a binary to download). Same routing and
|
|
483
|
+
* authentication as {@link httpGet}; a bare `fetch('/api/...')` would reach
|
|
484
|
+
* the wrong server from a remote workspace.
|
|
485
|
+
*/
|
|
486
|
+
export function httpFetch(path: string, init?: RequestInit): Promise<Response>;
|
|
479
487
|
/**
|
|
480
488
|
* The account's plan, kept live. `null` while loading AND when this DevEye
|
|
481
489
|
* has no plan provider (everything unlimited): never read it as "free".
|