@deveye/types 0.18.3 → 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/device.ts +6 -2
- package/src/domain/featureRegistry.ts +16 -0
- package/src/domain/home.ts +5 -3
- package/src/domain/live.ts +3 -3
- package/src/domain/project.ts +56 -0
- package/src/domain/remoteInstance.test.ts +35 -0
- package/src/domain/remoteInstance.ts +70 -0
- package/src/domain/report.ts +34 -2
- package/src/domain/secrecy.ts +3 -0
- package/src/domain/sharing.ts +46 -1
- package/src/domain/twoFactor.ts +7 -3
- package/src/domain/workspace.ts +1 -1
- package/src/domain/workspaceRole.ts +1 -1
- package/src/features/admin.ts +1 -51
- package/src/features/home.ts +1 -1
- package/src/features/links.ts +37 -0
- package/src/features/registry.ts +4 -0
- package/src/features/remote.ts +52 -0
- package/src/features/secrecy.ts +22 -8
- package/src/features/sharing.ts +78 -2
- 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 +113 -15
- package/src/http/device.ts +14 -10
- package/src/http/status.ts +2 -0
- package/src/index.ts +89 -12
- package/src/protocol/agent.ts +38 -0
- package/src/protocol/error.ts +3 -0
- package/src/sdk/client-ambient.d.ts +60 -5
- package/src/sdk/client.ts +81 -3
- package/src/sdk/copy.test.ts +374 -0
- package/src/sdk/copy.ts +435 -0
- package/src/sdk/manifest.test.ts +27 -0
- package/src/sdk/manifest.ts +60 -1
- package/src/sdk/providers.ts +102 -0
- package/src/sdk/server.ts +188 -10
- package/src/sdk/testing.test.ts +22 -0
- package/src/sdk/testing.ts +91 -2
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;
|
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;
|
|
@@ -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
|
|
package/src/features/user.ts
CHANGED
|
@@ -37,17 +37,29 @@ export const THEME_SLOT_COUNT = 5;
|
|
|
37
37
|
*/
|
|
38
38
|
export const THEME_SLOT_IMAGE_MAX_LENGTH = 1_500_000;
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* A wallpaper value: an image data URL, or an https URL. The theme belongs to
|
|
42
|
+
* the workspace, so every member's browser loads what one member saved: a free
|
|
43
|
+
* string would let `http:` or any other scheme through to all of them.
|
|
44
|
+
*/
|
|
45
|
+
const THEME_IMAGE =
|
|
46
|
+
/^(data:image\/(png|jpeg|webp|avif|gif);base64,[A-Za-z0-9+/]+=*|https:\/\/[^\s"'()\\]+)$/;
|
|
47
|
+
|
|
40
48
|
export const themeStateSchema = z.object({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
/** A hex colour: it is written as-is into CSS custom properties on every member's page. */
|
|
50
|
+
accent: z
|
|
51
|
+
.string()
|
|
52
|
+
.regex(/^#[0-9a-fA-F]{6}$/)
|
|
53
|
+
.nullable(),
|
|
54
|
+
bgPreset: z.string().max(40).nullable(),
|
|
55
|
+
bgImage: z.string().max(THEME_IMAGE_MAX_LENGTH).regex(THEME_IMAGE).nullable(),
|
|
44
56
|
/**
|
|
45
57
|
* Saved background gallery: up to THEME_SLOT_COUNT slots, each a compressed
|
|
46
58
|
* data URL / raw URL, or null for an empty slot. Defaults to empty so themes
|
|
47
59
|
* saved before this field parse cleanly.
|
|
48
60
|
*/
|
|
49
61
|
bgImages: z
|
|
50
|
-
.array(z.string().max(THEME_SLOT_IMAGE_MAX_LENGTH).nullable())
|
|
62
|
+
.array(z.string().max(THEME_SLOT_IMAGE_MAX_LENGTH).regex(THEME_IMAGE).nullable())
|
|
51
63
|
.max(THEME_SLOT_COUNT)
|
|
52
64
|
.default([]),
|
|
53
65
|
bgDim: z.number().int().min(0).max(100),
|
|
@@ -93,7 +105,23 @@ export const userSetUsername = {
|
|
|
93
105
|
output: z.object({ username: usernameSchema })
|
|
94
106
|
};
|
|
95
107
|
|
|
108
|
+
/** The plan of an account, as a plan provider states it (`sdk/providers.ts`). */
|
|
109
|
+
export const accountPlanSchema = z.object({
|
|
110
|
+
id: z.string(),
|
|
111
|
+
label: z.string(),
|
|
112
|
+
limits: z.record(z.string(), z.number().int().nonnegative()),
|
|
113
|
+
trialEndsAt: z.number().int().nonnegative().optional()
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/** The caller's plan. `null`: this DevEye has no plan provider, everything is unlimited. */
|
|
117
|
+
export const userPlan = {
|
|
118
|
+
command: 'user.plan' as const,
|
|
119
|
+
input: z.object({}),
|
|
120
|
+
output: z.object({ plan: accountPlanSchema.nullable() })
|
|
121
|
+
};
|
|
122
|
+
|
|
96
123
|
export const userCommands = [
|
|
124
|
+
userPlan,
|
|
97
125
|
userSetAvatar,
|
|
98
126
|
userSetTheme,
|
|
99
127
|
userSetColor,
|
|
@@ -75,8 +75,8 @@ export const workspaceRemoveMember = {
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Ajoute un membre à l'espace actif, désigné par son adresse. Pas de lien ni
|
|
78
|
-
* d'acceptation : le compte existe
|
|
79
|
-
*
|
|
78
|
+
* d'acceptation : le compte existe déjà, et un lien serait un secret
|
|
79
|
+
* transmissible de plus.
|
|
80
80
|
*/
|
|
81
81
|
export const workspaceAddMember = {
|
|
82
82
|
command: 'workspace.addMember' 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,52 +41,147 @@ export const loginRequestSchema = z.object({
|
|
|
38
41
|
|
|
39
42
|
export type LoginRequest = z.infer<typeof loginRequestSchema>;
|
|
40
43
|
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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()
|
|
47
55
|
});
|
|
48
56
|
|
|
49
|
-
export type
|
|
57
|
+
export type SessionTokens = z.infer<typeof sessionTokensSchema>;
|
|
58
|
+
|
|
59
|
+
/** A password being chosen: the one account policy, at sign-up and at change. */
|
|
60
|
+
export const passwordSchema = z.string().min(8).max(512);
|
|
50
61
|
|
|
51
62
|
export const changePasswordRequestSchema = z.object({
|
|
52
63
|
currentPassword: z.string().min(1).max(512),
|
|
53
|
-
newPassword:
|
|
64
|
+
newPassword: passwordSchema
|
|
54
65
|
});
|
|
55
66
|
|
|
56
67
|
export type ChangePasswordRequest = z.infer<typeof changePasswordRequestSchema>;
|
|
57
68
|
|
|
58
|
-
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
|
+
});
|
|
59
74
|
|
|
60
75
|
export type ChangePasswordResponse = z.infer<typeof changePasswordResponseSchema>;
|
|
61
76
|
|
|
62
77
|
/**
|
|
63
78
|
* The auth flow returns the authenticated user and its workspaces in one shot.
|
|
64
|
-
* 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}).
|
|
65
81
|
*
|
|
66
82
|
* When 2FA is enabled, login first replies with `twoFactorRequired` and an
|
|
67
|
-
* 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.
|
|
68
85
|
*/
|
|
69
86
|
export const loginResponseSchema = z.discriminatedUnion('twoFactorRequired', [
|
|
70
|
-
sessionBundleSchema.extend({
|
|
71
|
-
|
|
87
|
+
sessionBundleSchema.extend({
|
|
88
|
+
twoFactorRequired: z.literal(false),
|
|
89
|
+
tokens: sessionTokensSchema.optional()
|
|
90
|
+
}),
|
|
91
|
+
z.object({ twoFactorRequired: z.literal(true), challenge: z.string().optional() })
|
|
72
92
|
]);
|
|
73
93
|
|
|
74
94
|
export type LoginResponse = z.infer<typeof loginResponseSchema>;
|
|
75
95
|
|
|
76
96
|
export const twoFactorChallengeRequestSchema = z.object({
|
|
77
97
|
/** A 6-digit TOTP code or a recovery backup code. */
|
|
78
|
-
code: z.string().min(6).max(
|
|
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()
|
|
79
101
|
});
|
|
80
102
|
|
|
81
103
|
export type TwoFactorChallengeRequest = z.infer<typeof twoFactorChallengeRequestSchema>;
|
|
82
104
|
|
|
83
|
-
|
|
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
|
+
});
|
|
84
113
|
|
|
85
114
|
export type RefreshResponse = z.infer<typeof refreshResponseSchema>;
|
|
86
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
|
+
|
|
87
125
|
export const meResponseSchema = sessionBundleSchema;
|
|
88
126
|
|
|
89
127
|
export type MeResponse = z.infer<typeof meResponseSchema>;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Self-service sign-up, in three steps: ask (`/signup`), open the mailed link
|
|
131
|
+
* (`/signup/verify`), choose a password (`/signup/complete`). No account exists
|
|
132
|
+
* before the last one.
|
|
133
|
+
*/
|
|
134
|
+
export const signupAvailabilitySchema = z.object({
|
|
135
|
+
/** Can an account be self-created here: the server allows it, or no account exists yet. */
|
|
136
|
+
open: z.boolean()
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
export type SignupAvailability = z.infer<typeof signupAvailabilitySchema>;
|
|
140
|
+
|
|
141
|
+
export const signupStartRequestSchema = z.object({
|
|
142
|
+
username: usernameSchema,
|
|
143
|
+
email: z.string().email().max(320),
|
|
144
|
+
/** Opaque hint carried to the first session (`signupPlan`), for whoever sent the visitor. */
|
|
145
|
+
plan: z
|
|
146
|
+
.string()
|
|
147
|
+
.regex(/^[a-z0-9_-]{1,64}$/)
|
|
148
|
+
.optional()
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export type SignupStartRequest = z.infer<typeof signupStartRequestSchema>;
|
|
152
|
+
|
|
153
|
+
export const signupStartResponseSchema = z.object({
|
|
154
|
+
/** Lets the asking tab follow the request (`X-Signup-Watch`). It is NOT the mailed token. */
|
|
155
|
+
watchToken: z.string()
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
export type SignupStartResponse = z.infer<typeof signupStartResponseSchema>;
|
|
159
|
+
|
|
160
|
+
export const signupStatusSchema = z.object({
|
|
161
|
+
/** `opened`: the mailed link was followed. An unknown watch token reads `pending`. */
|
|
162
|
+
state: z.enum(['pending', 'opened', 'done', 'expired'])
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
export type SignupStatus = z.infer<typeof signupStatusSchema>;
|
|
166
|
+
|
|
167
|
+
export const signupVerifyRequestSchema = z.object({ token: z.string().min(1).max(128) });
|
|
168
|
+
|
|
169
|
+
export type SignupVerifyRequest = z.infer<typeof signupVerifyRequestSchema>;
|
|
170
|
+
|
|
171
|
+
export const signupVerifyResponseSchema = z.object({ username: z.string(), email: z.string() });
|
|
172
|
+
|
|
173
|
+
export type SignupVerifyResponse = z.infer<typeof signupVerifyResponseSchema>;
|
|
174
|
+
|
|
175
|
+
export const signupCompleteRequestSchema = z.object({
|
|
176
|
+
token: z.string().min(1).max(128),
|
|
177
|
+
password: passwordSchema
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export type SignupCompleteRequest = z.infer<typeof signupCompleteRequestSchema>;
|
|
181
|
+
|
|
182
|
+
export const signupCompleteResponseSchema = sessionBundleSchema.extend({
|
|
183
|
+
/** The `plan` hint given at the first step, delivered once. */
|
|
184
|
+
signupPlan: z.string().nullable()
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
export type SignupCompleteResponse = z.infer<typeof signupCompleteResponseSchema>;
|
package/src/http/device.ts
CHANGED
|
@@ -11,17 +11,18 @@ import { devicePlatformSchema, deviceSchema } from '../domain/device';
|
|
|
11
11
|
* 4. The user confirms the device in the Clients page to activate it.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Hard cap on a code lifetime (30 days). A link code is a standing key to the
|
|
16
|
+
* workspace: it always expires.
|
|
17
|
+
*/
|
|
15
18
|
export const LINK_CODE_TTL_MAX_SECONDS = 30 * 24 * 60 * 60;
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
|
-
* Request a new link code. `ttlSeconds
|
|
19
|
-
*
|
|
20
|
-
* - `null` → no expiry (valid until used or deleted),
|
|
21
|
-
* - a number → custom lifetime in seconds.
|
|
21
|
+
* Request a new link code. `ttlSeconds` omitted → server default lifetime,
|
|
22
|
+
* otherwise a lifetime in seconds.
|
|
22
23
|
*/
|
|
23
24
|
export const linkCodeRequestSchema = z.object({
|
|
24
|
-
ttlSeconds: z.number().int().positive().max(LINK_CODE_TTL_MAX_SECONDS).
|
|
25
|
+
ttlSeconds: z.number().int().positive().max(LINK_CODE_TTL_MAX_SECONDS).optional(),
|
|
25
26
|
/**
|
|
26
27
|
* Approve the device the moment it enrols with this code, instead of
|
|
27
28
|
* leaving it `pending` for manual approval. Defaults to `false`.
|
|
@@ -60,17 +61,20 @@ export const enrollDeviceRequestSchema = z.object({
|
|
|
60
61
|
code: z.string().min(6).max(32),
|
|
61
62
|
name: z.string().min(1).max(128),
|
|
62
63
|
fingerprint: z.string().min(1).max(128),
|
|
63
|
-
platform: devicePlatformSchema.default('linux')
|
|
64
|
-
/** X25519 public key (base64) for command signature verification. */
|
|
65
|
-
publicKey: z.string().min(1).max(256)
|
|
64
|
+
platform: devicePlatformSchema.default('linux')
|
|
66
65
|
});
|
|
67
66
|
|
|
68
67
|
export type EnrollDeviceRequest = z.infer<typeof enrollDeviceRequestSchema>;
|
|
69
68
|
|
|
70
69
|
export const enrollDeviceResponseSchema = z.object({
|
|
71
70
|
deviceId: z.uuid(),
|
|
72
|
-
/**
|
|
71
|
+
/** Device token (JWT), rotated by the server before it expires. Stored only on the agent. */
|
|
73
72
|
deviceToken: z.string().min(1),
|
|
73
|
+
/**
|
|
74
|
+
* The server's order-signing public key (Ed25519, base64): the agent pins it
|
|
75
|
+
* and refuses any high-impact order that does not carry its signature.
|
|
76
|
+
*/
|
|
77
|
+
orderSigningKey: z.string().length(44),
|
|
74
78
|
device: deviceSchema
|
|
75
79
|
});
|
|
76
80
|
|
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
|
|